[kune-commits] r1769 - in trunk/src/main/java/cc/kune: chat/client core/client/cookies core/shared

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Sun Mar 18 13:04:17 CET 2012


Author: vjrj_
Date: 2012-03-18 13:04:16 +0100 (Sun, 18 Mar 2012)
New Revision: 1769

Added:
   trunk/src/main/java/cc/kune/chat/client/XmppSessionProvider.java
Modified:
   trunk/src/main/java/cc/kune/chat/client/ChatGinModule.java
   trunk/src/main/java/cc/kune/chat/client/ChatInstances.java
   trunk/src/main/java/cc/kune/core/client/cookies/CookiesManagerImpl.java
   trunk/src/main/java/cc/kune/core/shared/SessionConstants.java
Log:
Cookie remove improved. Chat instances improved to avoid dups objects (Suco).

Modified: trunk/src/main/java/cc/kune/chat/client/ChatGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/ChatGinModule.java	2012-03-18 02:35:00 UTC (rev 1768)
+++ trunk/src/main/java/cc/kune/chat/client/ChatGinModule.java	2012-03-18 12:04:16 UTC (rev 1769)
@@ -27,6 +27,20 @@
 import cc.kune.core.client.avatar.SmallAvatarDecorator;
 import cc.kune.core.client.contacts.SimpleContactManager;
 
+import com.calclab.emite.core.client.conn.XmppConnection;
+import com.calclab.emite.core.client.xmpp.sasl.SASLManager;
+import com.calclab.emite.core.client.xmpp.session.XmppSession;
+import com.calclab.emite.im.client.chat.ChatManager;
+import com.calclab.emite.im.client.presence.PresenceManager;
+import com.calclab.emite.im.client.roster.SubscriptionHandler;
+import com.calclab.emite.im.client.roster.SubscriptionManager;
+import com.calclab.emite.im.client.roster.XmppRoster;
+import com.calclab.emite.reconnect.client.SessionReconnect;
+import com.calclab.emite.xep.avatar.client.AvatarManager;
+import com.calclab.emite.xep.muc.client.RoomManager;
+import com.calclab.emite.xep.storage.client.PrivateStorageManager;
+import com.google.inject.Singleton;
+
 public class ChatGinModule extends ExtendedGinModule {
   /*
    * (non-Javadoc)
@@ -46,5 +60,24 @@
     // bind(OpenGroupPublicChatRoomButton.class);
     s(ChatClientTool.class);
     s(ChatClientActions.class);
+
+    // This is needed because of Suco use and to prevent object duplicates
+    bind(XmppSession.class).toProvider(ChatInstances.XmppSessionProvider.class).in(Singleton.class);
+    bind(XmppRoster.class).toProvider(ChatInstances.XmppRosterProvider.class).in(Singleton.class);
+    bind(ChatManager.class).toProvider(ChatInstances.ChatManagerProvider.class).in(Singleton.class);
+    bind(RoomManager.class).toProvider(ChatInstances.RoomManagerProvider.class).in(Singleton.class);
+    bind(SessionReconnect.class).toProvider(ChatInstances.SessionReconnectProvider.class).in(
+        Singleton.class);
+    bind(AvatarManager.class).toProvider(ChatInstances.AvatarManagerProvider.class).in(Singleton.class);
+    bind(PresenceManager.class).toProvider(ChatInstances.PresenceManagerProvider.class).in(
+        Singleton.class);
+    bind(PrivateStorageManager.class).toProvider(ChatInstances.PrivateStorageManagerProvider.class).in(
+        Singleton.class);
+    bind(SubscriptionManager.class).toProvider(ChatInstances.SubscriptionManagerProvider.class).in(
+        Singleton.class);
+    bind(SubscriptionHandler.class).toProvider(ChatInstances.SubscriptionHandlerProvider.class).in(
+        Singleton.class);
+    bind(XmppConnection.class).toProvider(ChatInstances.XmppConnectionProvider.class).in(Singleton.class);
+    bind(SASLManager.class).toProvider(ChatInstances.SASLManagerProvider.class).in(Singleton.class);
   }
 }

Modified: trunk/src/main/java/cc/kune/chat/client/ChatInstances.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/ChatInstances.java	2012-03-18 02:35:00 UTC (rev 1768)
+++ trunk/src/main/java/cc/kune/chat/client/ChatInstances.java	2012-03-18 12:04:16 UTC (rev 1769)
@@ -19,6 +19,8 @@
  */
 package cc.kune.chat.client;
 
+import com.calclab.emite.core.client.conn.XmppConnection;
+import com.calclab.emite.core.client.xmpp.sasl.SASLManager;
 import com.calclab.emite.core.client.xmpp.session.XmppSession;
 import com.calclab.emite.im.client.chat.ChatManager;
 import com.calclab.emite.im.client.presence.PresenceManager;
@@ -30,9 +32,92 @@
 import com.calclab.emite.xep.muc.client.RoomManager;
 import com.calclab.emite.xep.storage.client.PrivateStorageManager;
 import com.calclab.suco.client.Suco;
+import com.google.inject.Provider;
 
 public class ChatInstances {
 
+  public class AvatarManagerProvider implements Provider<AvatarManager> {
+    @Override
+    public AvatarManager get() {
+      return Suco.get(AvatarManager.class);
+    }
+  }
+
+  public class ChatManagerProvider implements Provider<ChatManager> {
+    @Override
+    public ChatManager get() {
+      return Suco.get(ChatManager.class);
+    }
+  }
+
+  public class PresenceManagerProvider implements Provider<PresenceManager> {
+    @Override
+    public PresenceManager get() {
+      return Suco.get(PresenceManager.class);
+    }
+  }
+
+  public class PrivateStorageManagerProvider implements Provider<PrivateStorageManager> {
+    @Override
+    public PrivateStorageManager get() {
+      return Suco.get(PrivateStorageManager.class);
+    }
+  }
+
+  public class RoomManagerProvider implements Provider<RoomManager> {
+    @Override
+    public RoomManager get() {
+      return Suco.get(RoomManager.class);
+    }
+  }
+
+  public class SASLManagerProvider implements Provider<SASLManager> {
+    @Override
+    public SASLManager get() {
+      return Suco.get(SASLManager.class);
+    }
+  }
+
+  public class SessionReconnectProvider implements Provider<SessionReconnect> {
+    @Override
+    public SessionReconnect get() {
+      return Suco.get(SessionReconnect.class);
+    }
+  }
+
+  public class SubscriptionHandlerProvider implements Provider<SubscriptionHandler> {
+    @Override
+    public SubscriptionHandler get() {
+      return Suco.get(SubscriptionHandler.class);
+    }
+  }
+
+  public class SubscriptionManagerProvider implements Provider<SubscriptionManager> {
+    @Override
+    public SubscriptionManager get() {
+      return Suco.get(SubscriptionManager.class);
+    }
+  }
+  public class XmppConnectionProvider implements Provider<XmppConnection> {
+    @Override
+    public XmppConnection get() {
+      return Suco.get(XmppConnection.class);
+    }
+  }
+  public class XmppRosterProvider implements Provider<XmppRoster> {
+    @Override
+    public XmppRoster get() {
+      return Suco.get(XmppRoster.class);
+    }
+  }
+
+  public class XmppSessionProvider implements Provider<XmppSession> {
+    @Override
+    public XmppSession get() {
+      return Suco.get(XmppSession.class);
+    }
+  }
+
   public final AvatarManager avatarManager;
   public final ChatManager chatManager;
   public final PresenceManager presenceManager;

Added: trunk/src/main/java/cc/kune/chat/client/XmppSessionProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/XmppSessionProvider.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/chat/client/XmppSessionProvider.java	2012-03-18 12:04:16 UTC (rev 1769)
@@ -0,0 +1,14 @@
+package cc.kune.chat.client;
+
+import com.calclab.emite.core.client.xmpp.session.XmppSession;
+import com.calclab.suco.client.Suco;
+import com.google.inject.Provider;
+
+public class XmppSessionProvider implements Provider<XmppSession> {
+
+  @Override
+  public XmppSession get() {
+    return Suco.get(XmppSession.class);
+  }
+
+}

Modified: trunk/src/main/java/cc/kune/core/client/cookies/CookiesManagerImpl.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/cookies/CookiesManagerImpl.java	2012-03-18 02:35:00 UTC (rev 1768)
+++ trunk/src/main/java/cc/kune/core/client/cookies/CookiesManagerImpl.java	2012-03-18 12:04:16 UTC (rev 1769)
@@ -56,8 +56,10 @@
     // http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ded86778ee56690/515dc513c7d085eb?lnk=st&q=remove+cookie#515dc513c7d085eb
     // http://code.google.com/p/google-web-toolkit/issues/detail?id=1735&q=removeCookie
     Cookies.removeCookie(SessionConstants.USERHASH);
+    Cookies.removeCookie(SessionConstants.JSESSIONID);
     // Workaround:
     Cookies.setCookie(SessionConstants.USERHASH, null, new Date(0), null, "/", false);
+    Cookies.setCookie(SessionConstants.JSESSIONID, null, new Date(0), null, "/", false);
   }
 
   @Override
@@ -73,7 +75,7 @@
     // http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ
     final Date expires = new Date(System.currentTimeMillis() + SessionConstants.SESSION_DURATION);
     Cookies.setCookie(SessionConstants.USERHASH, userHash, expires, null, "/", false);
-    Cookies.setCookie("JSESSIONID", userHash, expires, null, "/", false);
+    Cookies.setCookie(SessionConstants.JSESSIONID, userHash, expires, null, "/", false);
     Log.info("Received hash: " + userHash, null);
   }
 }

Modified: trunk/src/main/java/cc/kune/core/shared/SessionConstants.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/SessionConstants.java	2012-03-18 02:35:00 UTC (rev 1768)
+++ trunk/src/main/java/cc/kune/core/shared/SessionConstants.java	2012-03-18 12:04:16 UTC (rev 1769)
@@ -6,8 +6,9 @@
   public final static long A_DAY = _AN_HOUR * 24;
   public final static long ANON_SESSION_DURATION = A_DAY;
   public final static long ANON_SESSION_DURATION_AFTER_REG = A_DAY * 365;
+  public static final String JSESSIONID = "JSESSIONID";
+  // session duration
   public final static long SESSION_DURATION = A_DAY * 30; // four weeks login
-                                                          // session duration
   // public final static long SESSION_DURATION = 100; // For test
   public final static String USERHASH = "k007userHash";
 




More information about the kune-commits mailing list