[kune-commits] r1032 - in trunk: . src/main/java/org/ourproject/kune/chat/client src/main/java/org/ourproject/kune/workspace/client/socialnet

vjrj vjrj at ourproject.org
Fri Jan 16 14:29:29 CET 2009


Author: vjrj
Date: 2009-01-16 14:29:28 +0100 (Fri, 16 Jan 2009)
New Revision: 1032

Modified:
   trunk/pom.xml
   trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngine.java
   trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java
   trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java
Log:
Complete - task Add a EmiteDialog option to show "Add a new buddy" dialog 


Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2009-01-13 09:42:36 UTC (rev 1031)
+++ trunk/pom.xml	2009-01-16 13:29:28 UTC (rev 1032)
@@ -94,7 +94,7 @@
     <dependency>
       <groupId>com.calclab.emite</groupId>
       <artifactId>emite</artifactId>
-      <version>0.4.3</version>
+      <version>0.4.4</version>
     </dependency>
     <dependency>
       <groupId>org.jivesoftware.smack</groupId>

Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngine.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngine.java	2009-01-13 09:42:36 UTC (rev 1031)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngine.java	2009-01-16 13:29:28 UTC (rev 1032)
@@ -29,6 +29,10 @@
 
     ChatConnectionOptions getChatOptions();
 
+    boolean isBuddie(String localUserName);
+
+    boolean isBuddie(XmppURI jid);
+
     boolean isLoggedIn();
 
     void joinRoom(String roomName, String userAlias);

Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java	2009-01-13 09:42:36 UTC (rev 1031)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java	2009-01-16 13:29:28 UTC (rev 1032)
@@ -19,6 +19,7 @@
  */
 package org.ourproject.kune.chat.client;
 
+import java.util.Collection;
 import java.util.Date;
 
 import org.ourproject.kune.platf.client.app.Application;
@@ -29,11 +30,11 @@
 import org.ourproject.kune.platf.client.state.Session;
 import org.ourproject.kune.platf.client.ui.WindowUtils;
 import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
-import org.ourproject.kune.workspace.client.site.Site;
 import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
 
 import com.allen_sauer.gwt.log.client.Log;
 import com.calclab.emite.core.client.xmpp.stanzas.XmppURI;
+import com.calclab.emite.im.client.roster.RosterItem;
 import com.calclab.emiteuimodule.client.EmiteUIDialog;
 import com.calclab.emiteuimodule.client.SubscriptionMode;
 import com.calclab.emiteuimodule.client.UserChatOptions;
@@ -55,6 +56,7 @@
     private ToolbarButton traybarButton;
     private final Provider<EmiteUIDialog> emiteUIProvider;
     private final Provider<FileDownloadUtils> downloadUtils;
+    private Collection<RosterItem> roster;
 
     public ChatEngineDefault(final I18nTranslationService i18n, final WorkspaceSkeleton ws, Application application,
             Session session, final Provider<EmiteUIDialog> emiteUIProvider,
@@ -97,7 +99,7 @@
     }
 
     public void addNewBuddie(String shortName) {
-        Site.important("In development (emite)");
+        emiteUIProvider.get().addBuddie(getLocalUserJid(shortName), shortName, "");
     }
 
     public void chat(XmppURI jid) {
@@ -108,6 +110,21 @@
         return chatOptions;
     }
 
+    public boolean isBuddie(String shortName) {
+        return isBuddie(getLocalUserJid(shortName));
+    }
+
+    public boolean isBuddie(XmppURI jid) {
+        if (roster != null) {
+            for (RosterItem item : roster) {
+                if (item.getJID().equalsNoResource(jid)) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     public boolean isLoggedIn() {
         return emiteUIProvider.get().isLoggedIn();
     }
@@ -138,6 +155,11 @@
         final String initialWindowTitle = Window.getTitle();
         chatOptions.userOptions = userChatOptions;
         if (emiteUIProvider.get().isDialogNotStarted()) {
+            emiteUIProvider.get().onRosterChanged(new Listener<Collection<RosterItem>>() {
+                public void onEvent(Collection<RosterItem> rosterChanged) {
+                    roster = rosterChanged;
+                }
+            });
             emiteUIProvider.get().start(userChatOptions, chatOptions.httpBase, chatOptions.domain,
                     chatOptions.roomHost, avatarProvider, i18n.t("Chat"));
         } else {
@@ -210,6 +232,10 @@
         }
     }
 
+    private XmppURI getLocalUserJid(String shortName) {
+        return XmppURI.jid(shortName + "@" + chatOptions.domain);
+    }
+
     private UserChatOptions getUserChatOptions(final String jid, final String passwd) {
         final String resource = "emiteui-" + new Date().getTime() + "-kune"; // +
         // getGwtMetaProperty(GWT_PROPERTY_RELEASE);

Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java	2009-01-13 09:42:36 UTC (rev 1031)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java	2009-01-16 13:29:28 UTC (rev 1032)
@@ -192,8 +192,8 @@
     private void registerActions() {
         final ActionToolbarButtonAndItemDescriptor<UserSimpleDTO> addAsBuddie = new ActionToolbarButtonAndItemDescriptor<UserSimpleDTO>(
                 AccessRolDTO.Viewer, ActionToolbarPosition.bottombar, new Listener<UserSimpleDTO>() {
-                    public void onEvent(final UserSimpleDTO group) {
-                        chatEngineProvider.get().addNewBuddie(group.getShortName());
+                    public void onEvent(final UserSimpleDTO user) {
+                        chatEngineProvider.get().addNewBuddie(user.getShortName());
                     }
                 });
         addAsBuddie.setMustBeAuthenticated(true);




More information about the kune-commits mailing list