[kune-commits] r1277 - in trunk: script src/main/java/cc/kune/client src/main/java/cc/kune/core/client src/main/java/cc/kune/core/client/errors src/main/java/cc/kune/core/client/sitebar src/main/java/cc/kune/core/client/sn/actions src/main/java/cc/kune/core/client/state src/main/java/cc/kune/core/public src/main/java/cc/kune/wave/client src/test/java/cc/kune/core/client/state

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Tue Mar 15 15:25:37 CET 2011


Author: vjrj_
Date: 2011-03-15 15:25:36 +0100 (Tue, 15 Mar 2011)
New Revision: 1277

Added:
   trunk/src/main/java/cc/kune/core/client/errors/InvalidKuneTokenException.java
   trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java
   trunk/src/main/java/cc/kune/wave/client/SitebarWaveStatus.java
   trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java
   trunk/src/main/java/cc/kune/wave/client/WaveParts.java
Modified:
   trunk/script/generateAbout.sh
   trunk/src/main/java/cc/kune/client/KuneGinjector.java
   trunk/src/main/java/cc/kune/core/client/CoreGinModule.java
   trunk/src/main/java/cc/kune/core/client/CoreParts.java
   trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignOutLink.java
   trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java
   trunk/src/main/java/cc/kune/core/public/ws.css
   trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java
   trunk/src/main/java/cc/kune/wave/client/WaveClientSimpleAuthenticator.java
   trunk/src/test/java/cc/kune/core/client/state/StateManagerTest.java
Log:
NEW - # 35: Spaces selector integration with login/logout and history 
http://kune.ourproject.org/issues/ticket/35

Modified: trunk/script/generateAbout.sh
===================================================================
--- trunk/script/generateAbout.sh	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/script/generateAbout.sh	2011-03-15 14:25:36 UTC (rev 1277)
@@ -17,5 +17,5 @@
 #echo "--------------------------------------------------------------------------------" >> $tmp
 echo Version $VER '('$SVNVER')' >> $tmp
 
-txt2html --prepend_file bin/header.html -h 80 --preserve_indent -8 --style_url frame-def.css --infile $tmp --infile CREDITS --infile COPYRIGHT --outfile src/main/java/cc/kune/core/public/about.html
+txt2html --prepend_file script/header.html -h 80 --preserve_indent -8 --style_url frame-def.css --infile $tmp --infile CREDITS --infile COPYRIGHT --outfile src/main/java/cc/kune/core/public/about.html
 rm $tmp

Modified: trunk/src/main/java/cc/kune/client/KuneGinjector.java
===================================================================
--- trunk/src/main/java/cc/kune/client/KuneGinjector.java	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/main/java/cc/kune/client/KuneGinjector.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -50,6 +50,8 @@
 import cc.kune.core.shared.i18n.I18nTranslationService;
 import cc.kune.pspace.client.PSpaceGinModule;
 import cc.kune.pspace.client.PSpacePresenter;
+import cc.kune.wave.client.WaveGinModule;
+import cc.kune.wave.client.WaveParts;
 
 import com.google.gwt.event.shared.EventBus;
 import com.google.gwt.inject.client.AsyncProvider;
@@ -58,7 +60,7 @@
 import com.google.inject.Provider;
 import com.gwtplatform.mvp.client.proxy.ProxyFailureHandler;
 
- at GinModules({ CoreGinModule.class, ChatGinModule.class, PSpaceGinModule.class })
+ at GinModules({ CoreGinModule.class, ChatGinModule.class, WaveGinModule.class, PSpaceGinModule.class })
 public interface KuneGinjector extends Ginjector {
 
     /*
@@ -125,4 +127,6 @@
     AsyncProvider<UserConfirmPresenter> getUserConfirmPresenter();
 
     AsyncProvider<UserNotifierPresenter> getUserNotifierPresenter();
+
+    WaveParts getWaveParts();
 }

Modified: trunk/src/main/java/cc/kune/core/client/CoreGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreGinModule.java	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/main/java/cc/kune/core/client/CoreGinModule.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -101,7 +101,6 @@
 import cc.kune.gspace.client.WsArmorImpl;
 import cc.kune.msgs.client.UserMessagesPanel;
 import cc.kune.msgs.client.UserMessagesPresenter;
-import cc.kune.wave.client.WaveClientManager;
 
 import com.google.gwt.event.shared.EventBus;
 import com.google.inject.Singleton;
@@ -195,7 +194,6 @@
         bind(CookiesManager.class).to(CookiesManagerImpl.class).in(Singleton.class);
         bind(BeforeSignOut.class).in(Singleton.class);
         bind(SiteTokenListeners.class).asEagerSingleton();
-        bind(WaveClientManager.class).in(Singleton.class);
         bind(CoreParts.class).asEagerSingleton();
 
         // SN

Modified: trunk/src/main/java/cc/kune/core/client/CoreParts.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreParts.java	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/main/java/cc/kune/core/client/CoreParts.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -9,7 +9,6 @@
 import cc.kune.core.client.sn.actions.registry.UserSNConfActions;
 import cc.kune.core.client.state.Session;
 import cc.kune.core.client.ui.footer.license.EntityLicensePresenter;
-import cc.kune.wave.client.WaveClientManager;
 
 import com.google.inject.Inject;
 import com.google.inject.Provider;
@@ -21,7 +20,7 @@
             final Provider<UserSNPresenter> buddiesAndParticipationPresenter,
             final Provider<GroupSNConfActions> groupMembersConfActions,
             final Provider<UserSNConfActions> userSNConfActions, final Provider<SiteUserOptionsPresenter> userOptions,
-            final Provider<EntityLicensePresenter> licenseFooter, final Provider<WaveClientManager> waveClientManager) {
+            final Provider<EntityLicensePresenter> licenseFooter) {
         session.onInitDataReceived(true, new AppStartHandler() {
             @Override
             public void onAppStart(final AppStartEvent event) {
@@ -31,7 +30,6 @@
                 buddiesAndParticipationPresenter.get();
                 userOptions.get();
                 licenseFooter.get();
-                waveClientManager.get();
             }
         });
     }

Added: trunk/src/main/java/cc/kune/core/client/errors/InvalidKuneTokenException.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/InvalidKuneTokenException.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/errors/InvalidKuneTokenException.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -0,0 +1,33 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.client.errors;
+
+public class InvalidKuneTokenException extends DefaultException {
+
+    private static final long serialVersionUID = -4511846108911183386L;
+
+    public InvalidKuneTokenException(String message) {
+        super(message);
+    }
+
+    public InvalidKuneTokenException() {
+        super();
+    }
+}


Property changes on: trunk/src/main/java/cc/kune/core/client/errors/InvalidKuneTokenException.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignOutLink.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignOutLink.java	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignOutLink.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -40,6 +40,7 @@
 import cc.kune.core.client.state.UserSignOutEvent;
 import cc.kune.core.client.state.UserSignOutEvent.UserSignOutHandler;
 import cc.kune.core.shared.i18n.I18nTranslationService;
+import cc.kune.wave.client.WaveClientSimpleAuthenticator;
 
 import com.google.gwt.event.shared.EventBus;
 import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -59,17 +60,19 @@
         private final EventBus eventBus;
         private final Session session;
         private final Provider<UserServiceAsync> userService;
+        private final WaveClientSimpleAuthenticator waveAuth;
 
         @Inject
         public SitebarSignOutAction(final EventBus eventBus, final I18nTranslationService i18n,
                 final BeforeSignOut beforeSignOut, final Provider<UserServiceAsync> userService, final Session session,
-                final CookiesManager cookiesManager) {
+                final CookiesManager cookiesManager, final WaveClientSimpleAuthenticator waveAuth) {
             super();
             this.eventBus = eventBus;
             this.userService = userService;
             this.session = session;
             this.cookiesManager = cookiesManager;
             this.beforeSignOut = beforeSignOut;
+            this.waveAuth = waveAuth;
             putValue(Action.NAME, i18n.t("Sign out"));
         }
 
@@ -77,25 +80,28 @@
         public void actionPerformed(final ActionEvent event) {
             eventBus.fireEvent(new ProgressShowEvent());
             if (beforeSignOut.checkBeforeAction()) {
-                userService.get().logout(session.getUserHash(), new AsyncCallback<Void>() {
+                waveAuth.doLogout(new AsyncCallback<Void>() {
                     @Override
                     public void onFailure(final Throwable caught) {
-                        eventBus.fireEvent(new ProgressHideEvent());
-                        if (caught instanceof SessionExpiredException) {
-                            clientUIsignOut();
-                        } else if (caught instanceof UserMustBeLoggedException) {
-                            clientUIsignOut();
-                        } else {
-                            throw new UIException("Other kind of exception in doLogout", caught);
-                        }
+                        onLogoutFail(caught);
                     }
 
                     @Override
-                    public void onSuccess(final Void arg0) {
-                        eventBus.fireEvent(new ProgressHideEvent());
-                        clientUIsignOut();
+                    public void onSuccess(final Void result) {
+                        userService.get().logout(session.getUserHash(), new AsyncCallback<Void>() {
+                            @Override
+                            public void onFailure(final Throwable caught) {
+                                onLogoutFail(caught);
+                            }
+
+                            @Override
+                            public void onSuccess(final Void arg0) {
+                                eventBus.fireEvent(new ProgressHideEvent());
+                                clientUIsignOut();
+                            }
+
+                        });
                     }
-
                 });
             } else {
                 eventBus.fireEvent(new ProgressHideEvent());
@@ -108,6 +114,17 @@
             session.setCurrentUserInfo(null);
         }
 
+        private void onLogoutFail(final Throwable caught) {
+            eventBus.fireEvent(new ProgressHideEvent());
+            if (caught instanceof SessionExpiredException) {
+                clientUIsignOut();
+            } else if (caught instanceof UserMustBeLoggedException) {
+                clientUIsignOut();
+            } else {
+                throw new UIException("Other kind of exception in doLogout", caught);
+            }
+        }
+
     }
     public static final String SITE_SIGN_OUT = "k-ssolp-lb";
 

Added: trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -0,0 +1,45 @@
+package cc.kune.core.client.sn.actions;
+
+import cc.kune.common.client.actions.AbstractExtendedAction;
+import cc.kune.common.client.actions.ui.descrip.GuiActionDescrip;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.UserSignInEvent;
+import cc.kune.core.client.state.UserSignInEvent.UserSignInHandler;
+import cc.kune.core.client.state.UserSignOutEvent;
+import cc.kune.core.client.state.UserSignOutEvent.UserSignOutHandler;
+
+import com.google.inject.Inject;
+
+public abstract class SessionAction extends AbstractExtendedAction {
+    protected final Session session;
+
+    @Inject
+    public SessionAction(final Session session, final boolean authNeed) {
+        this.session = session;
+        session.onUserSignIn(true, new UserSignInHandler() {
+            @Override
+            public void onUserSignIn(UserSignInEvent event) {
+                refreshStatus(authNeed, true);
+            }
+        });
+        session.onUserSignOut(true, new UserSignOutHandler() {
+            @Override
+            public void onUserSignOut(UserSignOutEvent event) {
+                refreshStatus(authNeed, false);
+            }
+        });
+    }
+
+    public void refreshStatus(final boolean authNeed, final boolean isLogged) {
+        boolean newVisibility = false;
+        boolean newEnabled = false;
+        if (authNeed && !isLogged) {
+            newVisibility = newEnabled = false;
+        } else {
+            // Auth ok
+            newVisibility = newEnabled = true;
+        }
+        setEnabled(newEnabled);
+        putValue(GuiActionDescrip.VISIBLE, newVisibility);
+    }
+}


Property changes on: trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/main/java/cc/kune/core/client/state/StateManagerDefault.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -22,6 +22,8 @@
 
 import java.util.HashMap;
 
+import org.waveprotocol.box.webclient.client.HistorySupport;
+
 import cc.kune.common.client.actions.BeforeActionCollection;
 import cc.kune.common.client.actions.BeforeActionListener;
 import cc.kune.common.client.errors.NotImplementedException;
@@ -57,13 +59,16 @@
     private final Session session;
     private final HashMap<String, HistoryTokenCallback> siteTokens;
 
+    // private final SpaceSelectorPresenter spaceSelector;
+
     @Inject
-    public StateManagerDefault(final ContentCache contentProvider, final Session session,
-            final HistoryWrapper history, final EventBus eventBus) {
+    public StateManagerDefault(final ContentCache contentProvider, final Session session, final HistoryWrapper history,
+            final EventBus eventBus) {
         this.eventBus = eventBus;
         this.contentProvider = contentProvider;
         this.session = session;
         this.history = history;
+        // this.spaceSelector = spaceSelector;
         this.previousToken = null;
         this.resumedToken = null;
         siteTokens = new HashMap<String, HistoryTokenCallback>();
@@ -166,7 +171,17 @@
             Log.debug("StateManager: on history changed (" + historyToken + ")");
             if (tokenListener == null) {
                 // Ok, normal token change
-                onHistoryChanged(new StateToken(historyToken));
+                // Is a Wave token?
+                if (historyToken == null || HistorySupport.waveRefFromHistoryToken(historyToken) == null) {
+                    // Non wave token
+                    onHistoryChanged(new StateToken(historyToken));
+                } else {
+                    // Wave token
+                    // spaceSelector.onUserSpaceSelect();
+                    if (session.isNotLogged()) {
+                        // use r=? argument?
+                    }
+                }
             } else {
                 // token is one of #newgroup #signin #translate ...
                 if (previousToken == null) {

Modified: trunk/src/main/java/cc/kune/core/public/ws.css
===================================================================
--- trunk/src/main/java/cc/kune/core/public/ws.css	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/main/java/cc/kune/core/public/ws.css	2011-03-15 14:25:36 UTC (rev 1277)
@@ -388,6 +388,24 @@
     padding: 0 3px 0 0 !important;
 }
 
+.k-sitebar-wave-status {
+    font: 13px 'Ubuntu', arial;
+    /* font-weight: bold; */
+    color: #B3B3B3;
+    white-space: nowrap;
+    background: none;
+    border: 0px;
+    padding: 1px 7px 0 0 !important;
+}
+
+.k-sitebar-wave-status, .k-sitebar-wave-status-online {
+  color: red;
+}
+
+.k-sitebar-wave-status, .k-sitebar-wave-status-offline {
+  color: green;
+}
+
 .k-sitebar button:hover {
     border: 0px;
     background: none;

Added: trunk/src/main/java/cc/kune/wave/client/SitebarWaveStatus.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/SitebarWaveStatus.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/wave/client/SitebarWaveStatus.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -0,0 +1,59 @@
+package cc.kune.wave.client;
+
+import org.waveprotocol.box.webclient.client.ClientEvents;
+import org.waveprotocol.box.webclient.client.events.NetworkStatusEvent;
+import org.waveprotocol.box.webclient.client.events.NetworkStatusEventHandler;
+
+import cc.kune.common.client.actions.AbstractAction;
+import cc.kune.common.client.actions.Action;
+import cc.kune.common.client.actions.ActionEvent;
+import cc.kune.common.client.actions.ui.descrip.IconLabelDescriptor;
+import cc.kune.common.client.noti.NotifyUser;
+import cc.kune.core.client.sitebar.SitebarActionsPresenter;
+import cc.kune.core.client.sn.actions.SessionAction;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.i18n.I18nTranslationService;
+
+import com.google.inject.Inject;
+
+public class SitebarWaveStatus {
+
+    public static class SitebarWaveStatusAction extends SessionAction {
+
+        @Inject
+        public SitebarWaveStatusAction(final Session session, final I18nTranslationService i18n) {
+            super(session, true);
+            ClientEvents.get().addNetworkStatusEventHandler(new NetworkStatusEventHandler() {
+                @Override
+                public void onNetworkStatus(final NetworkStatusEvent event) {
+                    switch (event.getStatus()) {
+                    case CONNECTED:
+                    case RECONNECTED:
+                        putValue(Action.NAME, i18n.t("Online"));
+                        putValue(AbstractAction.STYLES, "k-sitebar-wave-status, k-sitebar-wave-status-online");
+                        break;
+                    case DISCONNECTED:
+                        putValue(Action.NAME, i18n.t("Offline"));
+                        putValue(AbstractAction.STYLES, "k-sitebar-wave-status, k-sitebar-wave-status-offline");
+                        break;
+                    case RECONNECTING:
+                        NotifyUser.showProgress(i18n.t("Connecting"));
+                        break;
+                    }
+                }
+            });
+        }
+
+        @Override
+        public void actionPerformed(final ActionEvent event) {
+            // Do nothing
+        }
+    }
+
+    @Inject
+    public SitebarWaveStatus(final SitebarActionsPresenter sitebar, final SitebarWaveStatusAction action) {
+        final IconLabelDescriptor status = new IconLabelDescriptor(action);
+        status.setPosition(0);
+        sitebar.getRightToolbar().addAction(status);
+    }
+}


Property changes on: trunk/src/main/java/cc/kune/wave/client/SitebarWaveStatus.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/main/java/cc/kune/wave/client/WaveClientManager.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -1,10 +1,5 @@
 package cc.kune.wave.client;
 
-import org.waveprotocol.box.webclient.client.ClientEvents;
-import org.waveprotocol.box.webclient.client.events.NetworkStatusEvent;
-import org.waveprotocol.box.webclient.client.events.NetworkStatusEventHandler;
-
-import cc.kune.common.client.noti.NotifyUser;
 import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
 import cc.kune.core.client.rpcservices.UserServiceAsync;
 import cc.kune.core.client.state.Session;
@@ -22,6 +17,8 @@
 import com.google.inject.Inject;
 
 public class WaveClientManager {
+    private WebClient webClient;
+
     @Inject
     public WaveClientManager(final Session session, final StateManager stateManager,
             final UserServiceAsync userService, final WsArmor wsArmor) {
@@ -29,7 +26,6 @@
             @Override
             public void onUserSignIn(final UserSignInEvent event) {
                 userService.getWaveClientParameters(session.getUserHash(), new AsyncCallbackSimple<WaveClientParams>() {
-                    private WebClient webClient;
 
                     @Override
                     public void onSuccess(final WaveClientParams result) {
@@ -39,10 +35,10 @@
                         setClientFlags(JsonUtils.safeEval(result.getClientFlags()));
                         // Only for testing:
                         final ForIsWidget userSpace = wsArmor.getUserSpace();
-                        if (userSpace.getWidgetCount() > 0) {
-                            userSpace.remove(0);
-                        }
-                        if (webClient ==  null) {
+                        if (webClient == null) {
+                            if (userSpace.getWidgetCount() > 0) {
+                                userSpace.remove(0);
+                            }
                             webClient = new WebClient();
                             userSpace.add(webClient);
                         }
@@ -53,36 +49,26 @@
         session.onUserSignOut(true, new UserSignOutHandler() {
             @Override
             public void onUserSignOut(final UserSignOutEvent event) {
-            }
-        });
-        ClientEvents.get().addNetworkStatusEventHandler(new NetworkStatusEventHandler() {
-            @Override
-            public void onNetworkStatus(NetworkStatusEvent event) {
-                switch (event.getStatus()) {
-                  case CONNECTED:
-                  case RECONNECTED:
-                      NotifyUser.info("Online");
-                    break;
-                  case DISCONNECTED:
-                    NotifyUser.info("Offline");
-                    break;
-                  case RECONNECTING:
-                      NotifyUser.showProgress("Connecting");
-                    break;
+                // While we don't find a way to logout in WebClient
+                // Garbage collector
+                // https://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/0e48c15839f9c9dc
+                if (webClient != null) {
+                    webClient.removeFromParent();
+                    webClient = null;
                 }
             }
-          });
+        });
     }
 
     private native void setClientFlags(JavaScriptObject object) /*-{
-        $wnd.__client_flags = object;
+		$wnd.__client_flags = object;
     }-*/;
 
     private native void setSessionJSON(JavaScriptObject object) /*-{
-        $wnd.__session = object;
+		$wnd.__session = object;
     }-*/;
 
     private native void setUseSocketIO(boolean use) /*-{
-        $wnd.__useSocketIO = use;
+		$wnd.__useSocketIO = use;
     }-*/;
 }

Modified: trunk/src/main/java/cc/kune/wave/client/WaveClientSimpleAuthenticator.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveClientSimpleAuthenticator.java	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/main/java/cc/kune/wave/client/WaveClientSimpleAuthenticator.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -1,5 +1,6 @@
 package cc.kune.wave.client;
 
+import cc.kune.common.client.log.Log;
 import cc.kune.common.client.noti.NotifyUser;
 import cc.kune.gspace.client.WsArmor;
 
@@ -46,10 +47,33 @@
                 }
             });
         } catch (final RequestException e) {
-            NotifyUser.error(e.getStackTrace().toString(), true);
+            Log.error(e.getStackTrace().toString());
         }
     }
 
+    public void doLogout(final AsyncCallback<Void> callback) {
+        // Original: <a href=\"/auth/signout?r=/\">"
+        final RequestBuilder request = new RequestBuilder(RequestBuilder.POST, "/auth/signout");
+        try {
+            request.setHeader("Content-Type", "application/x-www-form-urlencoded");
+            final StringBuffer params = new StringBuffer();
+            request.sendRequest(params.toString(), new RequestCallback() {
+                @Override
+                public void onError(final Request request, final Throwable exception) {
+                    NotifyUser.error(exception.getStackTrace().toString(), true);
+                    callback.onFailure(exception);
+                }
+
+                @Override
+                public void onResponseReceived(final Request request, final Response response) {
+                    callback.onSuccess(null);
+                }
+            });
+        } catch (final RequestException e) {
+            Log.error(e.getStackTrace().toString());
+        }
+    }
+
     public String getCookieTokenValue() {
         return Cookies.getCookie("JSESSIONID");
     }

Added: trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -0,0 +1,37 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.wave.client;
+
+import com.google.inject.Singleton;
+import com.gwtplatform.mvp.client.gin.AbstractPresenterModule;
+
+public class WaveGinModule extends AbstractPresenterModule {
+    /*
+     * (non-Javadoc)
+     * 
+     * @see com.google.gwt.inject.client.AbstractGinModule#configure()
+     */
+    @Override
+    protected void configure() {
+        bind(WaveClientManager.class).in(Singleton.class);
+        bind(SitebarWaveStatus.class).in(Singleton.class);
+        bind(WaveParts.class).asEagerSingleton();
+    }
+}


Property changes on: trunk/src/main/java/cc/kune/wave/client/WaveGinModule.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/src/main/java/cc/kune/wave/client/WaveParts.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WaveParts.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/wave/client/WaveParts.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -0,0 +1,23 @@
+package cc.kune.wave.client;
+
+import cc.kune.core.client.init.AppStartEvent;
+import cc.kune.core.client.init.AppStartEvent.AppStartHandler;
+import cc.kune.core.client.state.Session;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+
+public class WaveParts {
+
+    @Inject
+    public WaveParts(final Session session, final Provider<WaveClientManager> waveClientManager,
+            final Provider<SitebarWaveStatus> waveStatus) {
+        session.onInitDataReceived(true, new AppStartHandler() {
+            @Override
+            public void onAppStart(final AppStartEvent event) {
+                waveClientManager.get();
+                waveStatus.get();
+            }
+        });
+    }
+}


Property changes on: trunk/src/main/java/cc/kune/wave/client/WaveParts.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/src/test/java/cc/kune/core/client/state/StateManagerTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/client/state/StateManagerTest.java	2011-03-15 00:32:17 UTC (rev 1276)
+++ trunk/src/test/java/cc/kune/core/client/state/StateManagerTest.java	2011-03-15 14:25:36 UTC (rev 1277)
@@ -24,6 +24,7 @@
 import org.mockito.Mockito;
 
 import cc.kune.common.client.actions.BeforeActionListener;
+import cc.kune.core.client.sitebar.spaces.SpaceSelectorPresenter;
 import cc.kune.core.client.state.GroupChangedEvent.GroupChangedHandler;
 import cc.kune.core.client.state.StateChangedEvent.StateChangedHandler;
 import cc.kune.core.client.state.ToolChangedEvent.ToolChangedHandler;
@@ -42,6 +43,7 @@
     private GroupChangedHandler groupChangeHandler;
     private HistoryWrapper history;
     private Session session;
+    private SpaceSelectorPresenter spaceSelector;
     private StateAbstractDTO state;
     private StateChangedHandler stateChangeHandler;
     private StateManagerDefault stateManager;
@@ -52,6 +54,7 @@
         contentProvider = Mockito.mock(ContentCache.class);
         session = Mockito.mock(Session.class);
         history = Mockito.mock(HistoryWrapper.class);
+        spaceSelector = Mockito.mock(SpaceSelectorPresenter.class);
         eventBus = new EventBusTester();
         stateManager = new StateManagerDefault(contentProvider, session, history, eventBus);
         Mockito.when(session.getUserHash()).thenReturn(HASH);
@@ -159,6 +162,10 @@
                 (StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
     }
 
+    public void getWaveToken() {
+        stateManager.onHistoryChanged("example.com/w+abcd/~/conv+root/b+45kg");
+    }
+
     @SuppressWarnings("unchecked")
     @Test
     public void normalStartLoggedUser() {




More information about the kune-commits mailing list