Browse Source

fix: contact et les chatrooms

Martin Passard 7 years ago
parent
commit
be610c76b7
5 changed files with 28 additions and 12 deletions
  1. 13 6
      src/IRC/Server.java
  2. 6 1
      src/data/ISP.java
  3. 7 0
      src/data/ISPdata.java
  4. 1 1
      src/main/Cache.java
  5. 1 4
      src/main/Main.java

+ 13 - 6
src/IRC/Server.java

@@ -1,5 +1,6 @@
 package IRC;
 package IRC;
 
 
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.List;
 
 
@@ -120,15 +121,21 @@ public class Server implements AffichableSurIRC{
 		return this.t.equals(Type.IRC);
 		return this.t.equals(Type.IRC);
 	}
 	}
 
 
-	@Override
-	public List<String> toStringIRC() {
-		List<String> s = new LinkedList<>();
+	public List<String> toStringIRC(){
+		List<String> res = new ArrayList<>();
+		res.add(toString());
+		return res;
+	}
+
+	
+	public String toString() {
+		
 		if(isIRC()) {
 		if(isIRC()) {
-			s.add("IRC://"+address+" chan:"+chan+" port:"+port);
+			return "IRC://"+address+" chan:"+chan+" port:"+port;
 		}else {
 		}else {
-			s.add(address);
+			return address;
 		}
 		}
-		return s;
+		
 	}
 	}
 	
 	
 	
 	

+ 6 - 1
src/data/ISP.java

@@ -7,6 +7,7 @@ import java.util.List;
 import IRC.Server;
 import IRC.Server;
 import main.AffichableSurIRC;
 import main.AffichableSurIRC;
 import main.Cache;
 import main.Cache;
+import main.Main;
 
 
 public class ISP implements AffichableSurIRC {
 public class ISP implements AffichableSurIRC {
 
 
@@ -235,11 +236,15 @@ public class ISP implements AffichableSurIRC {
 		s.add("Mail: "+getData().emailSyntaxer());
 		s.add("Mail: "+getData().emailSyntaxer());
 		String chats="Chat : ";
 		String chats="Chat : ";
 		Server[] chans = getData().getIrcChan();
 		Server[] chans = getData().getIrcChan();
-		if(chans!= null) {
+		if(chans != null) {
 			for(int i=0; i<chans.length; i++) {
 			for(int i=0; i<chans.length; i++) {
 				chats+=chans[i].toString()+" ";
 				chats+=chans[i].toString()+" ";
 			}
 			}
 			s.add(chats);
 			s.add(chats);
+		} else {
+			if(Main.isDebug()) {
+			s.add("Chans a Null");
+			}
 		}
 		}
 		return s;
 		return s;
 	}
 	}

+ 7 - 0
src/data/ISPdata.java

@@ -5,6 +5,7 @@ import org.json.JSONException;
 import org.json.JSONObject;
 import org.json.JSONObject;
 
 
 import IRC.Server;
 import IRC.Server;
+import main.Main;
 
 
 public class ISPdata {
 public class ISPdata {
 
 
@@ -52,8 +53,13 @@ public class ISPdata {
 
 
 			}
 			}
 		}catch(JSONException jsonE) {	// Si il n'y a pas de chatroom
 		}catch(JSONException jsonE) {	// Si il n'y a pas de chatroom
+			if(Main.isDebug()) {
+				System.err.println("Warning : Pas de chatroom pour "+this.shortname);
+				jsonE.printStackTrace(System.err);
+			}
 			chatrooms = new Server[0];
 			chatrooms = new Server[0];
 		}
 		}
+		this.ircChan = chatrooms;
 		this.progressStatus = getInt(jo,"progressStatus");
 		this.progressStatus = getInt(jo,"progressStatus");
 		this.membersCount = getInt(jo,"memberCount",0);
 		this.membersCount = getInt(jo,"memberCount",0);
 		this.subscribersCount = getInt(jo,"subscriberCount",0);
 		this.subscribersCount = getInt(jo,"subscriberCount",0);
@@ -63,6 +69,7 @@ public class ISPdata {
 			this.joinDate = "?";
 			this.joinDate = "?";
 		}
 		}
 		this.creationDate = getString(jo,"creationDate","?");
 		this.creationDate = getString(jo,"creationDate","?");
+		this.email = getString(jo,"email","?");
 
 
 	}
 	}
 	
 	

+ 1 - 1
src/main/Cache.java

@@ -164,7 +164,7 @@ public class Cache implements AffichableSurIRC {
 
 
 	public ISP getISPWithName(String s) {
 	public ISP getISPWithName(String s) {
 		for(ISP i : cache) {
 		for(ISP i : cache) {
-			if(i.getShortestName().equalsIgnoreCase(s) || i.getName().equalsIgnoreCase(s)) {
+			if(i.getShortestName().toLowerCase().contains(s.toLowerCase()) || i.getName().toLowerCase().contains(s.toLowerCase())) {
 				return i;
 				return i;
 			}
 			}
 		}
 		}

+ 1 - 4
src/main/Main.java

@@ -33,11 +33,8 @@ public class Main {
 			CacheReloader cacheReloader = new CacheReloader(3600); // Met à jour la base toute les heures.
 			CacheReloader cacheReloader = new CacheReloader(3600); // Met à jour la base toute les heures.
 			cacheReloader.start();
 			cacheReloader.start();
 			
 			
-			
-			
-			
-			
 			System.out.println("Debug? "+DEBUG);
 			System.out.println("Debug? "+DEBUG);
+			
 
 
 		}catch(ConnectException ce) {
 		}catch(ConnectException ce) {
 			failures++;
 			failures++;