[kune-commits] r1876 - in trunk: . src/main/java/cc/kune/client src/main/java/cc/kune/common/client/utils src/main/java/cc/kune/core/client src/main/java/cc/kune/core/client/auth src/main/java/cc/kune/core/client/events src/main/java/cc/kune/core/client/i18n src/main/java/cc/kune/core/client/init src/main/java/cc/kune/core/shared/dto

Vicente J. Ruiz Jurado vjrj_ at ourproject.org
Thu May 24 15:20:00 CEST 2012


Author: vjrj_
Date: 2012-05-24 15:19:59 +0200 (Thu, 24 May 2012)
New Revision: 1876

Added:
   trunk/src/main/java/cc/kune/core/client/CoreConstants.java
   trunk/src/main/java/cc/kune/core/client/auth/EmailNotVerifiedReminder.java
   trunk/src/main/java/cc/kune/core/client/init/WebSocketChecker.java
Modified:
   trunk/TODO
   trunk/TROUBLESHOOT
   trunk/src/main/java/cc/kune/client/OnAppStartFactory.java
   trunk/src/main/java/cc/kune/common/client/utils/WindowUtils.java
   trunk/src/main/java/cc/kune/core/client/CoreParts.java
   trunk/src/main/java/cc/kune/core/client/events/AppStartEvent.java
   trunk/src/main/java/cc/kune/core/client/events/AppStopEvent.java
   trunk/src/main/java/cc/kune/core/client/events/UserSignOutEvent.java
   trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java
   trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java
   trunk/src/main/java/cc/kune/core/shared/dto/UserSimpleDTO.java
Log:
CLOSED - # 271: Add two new UserNotifications: Email not confirmed, Websocket not supported 
http://kune.ourproject.org/issues/ticket/271

Modified: trunk/TODO
===================================================================
--- trunk/TODO	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/TODO	2012-05-24 13:19:59 UTC (rev 1876)
@@ -12,6 +12,8 @@
    nick == assigned to
 
 * SHORT-TERM (URGENT)
+** Stats via munin
+GRANT SELECT ON kune_dev.* TO kune_stats@'localhost' IDENTIFIED BY 'db4kune';
 ** Session expired
 12-04-09 00:14:29 GWTServiceFilter [INFO] --------------------------------------------------------------------------------
 2012-04-09 00:14:29 GWTServiceFilter [DEBUG] SERVICE: /ws/UserService - UserService

Modified: trunk/TROUBLESHOOT
===================================================================
--- trunk/TROUBLESHOOT	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/TROUBLESHOOT	2012-05-24 13:19:59 UTC (rev 1876)
@@ -25,8 +25,13 @@
 ** Mysql
 *** Mysql: Caused by: java.sql.SQLException: Access denied for user 'kune'@'localhost' (using password: YES)
 
-Check that the password you have use in the database creation it's the same like the kune.properties. If it's wrong maybe you have to remove the mysql user (DROP USER) and repeat the GRANT sentences of the INSTALL.
+Check that the password you have use in the database creation it's the same like the kune.properties. If it's wrong maybe you have to remove the mysql user (DROP USER) and repeat the GRANT sentences of the INSTALL, for instance:
 
+DROP USER kune at localhost;
+GRANT ALL PRIVILEGES ON kune_prod.* TO kune at localhost IDENTIFIED BY 'db4kune';
+GRANT ALL PRIVILEGES ON kune_openfire.* TO kune at localhost IDENTIFIED BY 'db4kune';
+FLUSH PRIVILEGES;
+
 Also, be sure you do a "mvn compile" if you are running kune from the source and you change the kune.properties file to not use the old one.
 
 If you have this problem with openfire it's not enough to change the password in openfire.xml because probably it's already stored in the ofProperty openfire table and you need to change the password there.

Modified: trunk/src/main/java/cc/kune/client/OnAppStartFactory.java
===================================================================
--- trunk/src/main/java/cc/kune/client/OnAppStartFactory.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/client/OnAppStartFactory.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -38,7 +38,6 @@
       @Override
       public void onAppStart(final AppStartEvent event) {
         newGroup.get();
-        //
       }
     });
   }

Modified: trunk/src/main/java/cc/kune/common/client/utils/WindowUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/common/client/utils/WindowUtils.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/common/client/utils/WindowUtils.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -15,9 +15,33 @@
  */
 package cc.kune.common.client.utils;
 
-
 public class WindowUtils {
 
+  /**
+   * https://developer.mozilla.org/en/DOM/window.location
+   * 
+   * @param newUrl
+   */
+  public static native void changeHref(String newUrl) /*-{
+		$wnd.location.href = newUrl;
+  }-*/;
+
+  /**
+   * https://developer.mozilla.org/en/DOM/window.location
+   * 
+   * "If you need to change pathname but keep the hash as is, use the replace() method instead, which should work consistently across browsers."
+   * 
+   * @param newUrl
+   */
+  public static native void changeHrefKeepHash(String newUrl) /*-{
+		// $wnd.location.href = newUrl;
+		$wnd.location.replace(newUrl);
+  }-*/;
+
+  public static native boolean dontHasWebSocket() /*-{
+		return !window.WebSocket
+  }-*/;
+
   private static native String getHash() /*-{
 		return $wnd.location.hash;
   }-*/;

Added: trunk/src/main/java/cc/kune/core/client/CoreConstants.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreConstants.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/CoreConstants.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -0,0 +1,29 @@
+/*
+ *
+ * Copyright (C) 2007-2012 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;
+
+public class CoreConstants {
+  public static final String MOZILLA_FF_LINK = "https://www.mozilla.com/en-US/firefox/fx/";
+
+  private CoreConstants() {
+  }
+
+}

Modified: trunk/src/main/java/cc/kune/core/client/CoreParts.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreParts.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/core/client/CoreParts.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -22,11 +22,13 @@
 import cc.kune.common.client.shortcuts.GlobalShortcuts;
 import cc.kune.common.shared.i18n.I18nTranslationService;
 import cc.kune.core.client.auth.AnonUsersManager;
+import cc.kune.core.client.auth.EmailNotVerifiedReminder;
 import cc.kune.core.client.auth.Register;
 import cc.kune.core.client.auth.SignIn;
 import cc.kune.core.client.events.AppStartEvent;
 import cc.kune.core.client.events.AppStartEvent.AppStartHandler;
 import cc.kune.core.client.groups.newgroup.NewGroup;
+import cc.kune.core.client.init.WebSocketChecker;
 import cc.kune.core.client.resources.CoreMessages;
 import cc.kune.core.client.sitebar.AboutKuneDialog;
 import cc.kune.core.client.sitebar.SiteUserOptionsPresenter;
@@ -72,7 +74,8 @@
       final Provider<UserOptions> userOptionsDialog, final Provider<GroupOptions> groupOptionsDialog,
       final Provider<PasswordResetPanel> passReset, final Provider<AskForPasswordResetPanel> askForPass,
       final GlobalShortcuts shortcuts, final I18nTranslationService i18n,
-      final Provider<TutorialViewer> tutorialViewer) {
+      final Provider<TutorialViewer> tutorialViewer, final Provider<WebSocketChecker> websocketChecker,
+      final Provider<EmailNotVerifiedReminder> emailNotVerifiedReminder) {
     session.onAppStart(true, new AppStartHandler() {
       @Override
       public void onAppStart(final AppStartEvent event) {
@@ -84,6 +87,8 @@
         anonUsers.get();
         spaceSelector.get();
         tutorialViewer.get();
+        emailNotVerifiedReminder.get();
+        websocketChecker.get();
       }
     });
     tokenListener.put(SiteTokens.SIGN_IN, new HistoryTokenAuthNotNeededCallback() {

Added: trunk/src/main/java/cc/kune/core/client/auth/EmailNotVerifiedReminder.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/EmailNotVerifiedReminder.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/auth/EmailNotVerifiedReminder.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -0,0 +1,69 @@
+/*
+ *
+ * Copyright (C) 2007-2012 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.auth;
+
+import java.util.Date;
+
+import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.common.shared.utils.TextUtils;
+import cc.kune.core.client.events.UserSignInEvent;
+import cc.kune.core.client.events.UserSignInEvent.UserSignInHandler;
+import cc.kune.core.client.i18n.I18n;
+import cc.kune.core.client.i18n.I18nUITranslationService;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.SiteTokens;
+import cc.kune.core.shared.SessionConstants;
+import cc.kune.core.shared.dto.UserSimpleDTO;
+
+import com.google.gwt.event.shared.EventBus;
+import com.google.inject.Inject;
+
+public class EmailNotVerifiedReminder {
+
+  /**
+   * This class checks if the user has verified the email if it's not, give some
+   * advice.
+   * 
+   * @param session
+   *          the session
+   */
+  @Inject
+  public EmailNotVerifiedReminder(final Session session, final EventBus eventBus,
+      final I18nUITranslationService i18n) {
+    session.onUserSignIn(true, new UserSignInHandler() {
+      @Override
+      public void onUserSignIn(final UserSignInEvent event) {
+        final UserSimpleDTO currentUser = session.getCurrentUser();
+        if (!currentUser.isEmailVerified()) {
+          final long now = new Date().getTime();
+          if ((currentUser.getCreatedOn() + SessionConstants._AN_HOUR) < now) {
+            final String link = TextUtils.generateHtmlLink("#" + SiteTokens.PREFS,
+                I18n.t("verify your email"), false);
+            NotifyUser.info(I18n.t(
+                "Your email is not verified, [%s] functionality will work better if you [%s]",
+                i18n.getSiteCommonName(), link), true);
+          }
+        }
+      }
+    });
+  }
+
+}

Modified: trunk/src/main/java/cc/kune/core/client/events/AppStartEvent.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/events/AppStartEvent.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/core/client/events/AppStartEvent.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -23,7 +23,6 @@
 import com.google.gwt.event.shared.GwtEvent;
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.event.shared.HasHandlers;
-import com.gwtplatform.mvp.client.HasEventBus;
 
 public class AppStartEvent extends GwtEvent<AppStartEvent.AppStartHandler> { 
 
@@ -37,7 +36,7 @@
 
   private static final Type<AppStartHandler> TYPE = new Type<AppStartHandler>();
 
-  public static void fire(HasEventBus source, cc.kune.core.shared.dto.InitDataDTO initData) {
+  public static void fire(HasHandlers source, cc.kune.core.shared.dto.InitDataDTO initData) {
     source.fireEvent(new AppStartEvent(initData));
   }
 

Modified: trunk/src/main/java/cc/kune/core/client/events/AppStopEvent.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/events/AppStopEvent.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/core/client/events/AppStopEvent.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -23,21 +23,20 @@
 import com.google.gwt.event.shared.GwtEvent;
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.event.shared.HasHandlers;
-import com.gwtplatform.mvp.client.HasEventBus;
 
-public class AppStopEvent extends GwtEvent<AppStopEvent.AppStopHandler> { 
+public class AppStopEvent extends GwtEvent<AppStopEvent.AppStopHandler> {
 
-  public interface HasAppStopHandlers extends HasHandlers {
-    HandlerRegistration addAppStopHandler(AppStopHandler handler);
-  }
-
   public interface AppStopHandler extends EventHandler {
     public void onAppStop(AppStopEvent event);
   }
 
+  public interface HasAppStopHandlers extends HasHandlers {
+    HandlerRegistration addAppStopHandler(AppStopHandler handler);
+  }
+
   private static final Type<AppStopHandler> TYPE = new Type<AppStopHandler>();
 
-  public static void fire(HasEventBus source) {
+  public static void fire(final HasHandlers source) {
     source.fireEvent(new AppStopEvent());
   }
 
@@ -45,31 +44,28 @@
     return TYPE;
   }
 
-
   public AppStopEvent() {
   }
 
   @Override
-  public Type<AppStopHandler> getAssociatedType() {
-    return TYPE;
-  }
-
-  @Override
-  protected void dispatch(AppStopHandler handler) {
+  protected void dispatch(final AppStopHandler handler) {
     handler.onAppStop(this);
   }
 
   @Override
-  public boolean equals(Object other) {
+  public boolean equals(final Object other) {
     if (other != null && other.getClass().equals(this.getClass())) {
-          AppStopEvent o = (AppStopEvent) other;
-      return true
-        ;
+      return true;
     }
     return false;
   }
 
   @Override
+  public Type<AppStopHandler> getAssociatedType() {
+    return TYPE;
+  }
+
+  @Override
   public int hashCode() {
     int hashCode = 23;
     hashCode = (hashCode * 37) + getClass().hashCode();
@@ -78,8 +74,7 @@
 
   @Override
   public String toString() {
-    return "AppStopEvent["
-    + "]";
+    return "AppStopEvent[" + "]";
   }
 
 }

Modified: trunk/src/main/java/cc/kune/core/client/events/UserSignOutEvent.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/events/UserSignOutEvent.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/core/client/events/UserSignOutEvent.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -23,7 +23,6 @@
 import com.google.gwt.event.shared.GwtEvent;
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.event.shared.HasHandlers;
-import com.gwtplatform.mvp.client.HasEventBus;
 
 public class UserSignOutEvent extends GwtEvent<UserSignOutEvent.UserSignOutHandler> {
 
@@ -37,7 +36,7 @@
 
   private static final Type<UserSignOutHandler> TYPE = new Type<UserSignOutHandler>();
 
-  public static void fire(final HasEventBus source) {
+  public static void fire(final HasHandlers source) {
     source.fireEvent(new UserSignOutEvent());
   }
 

Modified: trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/core/client/i18n/I18nUITranslationService.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -147,18 +147,6 @@
   }
 
   /**
-   * https://developer.mozilla.org/en/DOM/window.location
-   * 
-   * "If you need to change pathname but keep the hash as is, use the replace() method instead, which should work consistently across browsers."
-   * 
-   * @param newUrl
-   */
-  private native void changeHref(String newUrl) /*-{
-		// $wnd.location.href = newUrl;
-		$wnd.location.replace(newUrl);
-  }-*/;
-
-  /**
    * See in:
    * http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread
    * /5e4e25050d3be984/7035ec39354d06aa?lnk=gst&q=get+locale&rnum=23
@@ -170,7 +158,7 @@
    *          String value of the new locale to go to.
    */
   private void changeLanguageInUrl(final String newLocale) {
-    Location location = WindowUtils.getLocation();
+    final Location location = WindowUtils.getLocation();
     final String hash = location.getHash();
     final String query = location.getQueryString();
     final String protocol = location.getProtocol();
@@ -179,7 +167,7 @@
     Log.info("Locale current query: " + query);
     Log.info("Locale current hash: " + hash);
     Log.info("Locale new Url: " + newUrl);
-    changeHref(protocol + "//" + location.getHost() + newUrl);
+    WindowUtils.changeHrefKeepHash(protocol + "//" + location.getHost() + newUrl);
   }
 
   public void changeToLanguageIfNecessary(final String wantedLang, final String wantedLangEnglishName,

Modified: trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/core/client/init/AppStarterDefault.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -26,6 +26,8 @@
 import cc.kune.common.client.notify.UserNotifyEvent;
 import cc.kune.common.client.resources.CommonResources;
 import cc.kune.common.shared.utils.SimpleResponseCallback;
+import cc.kune.common.shared.utils.TextUtils;
+import cc.kune.core.client.CoreConstants;
 import cc.kune.core.client.events.AppStartEvent;
 import cc.kune.core.client.events.AppStopEvent;
 import cc.kune.core.client.rpcservices.SiteServiceAsync;
@@ -114,8 +116,9 @@
             NotifyUser.askConfirmation(
                 res.important32(),
                 "Your browser is currently unsupported",
-                "Please, use a free/libre modern navigator like <a class='k-link' href='https://www.mozilla.com/en-US/firefox/fx/'>Mozilla Firefox</a> instead. Continue anyway?",
-                new SimpleResponseCallback() {
+                "Please, use a free/libre modern navigator like "
+                    + TextUtils.generateHtmlLink(CoreConstants.MOZILLA_FF_LINK, "Mozilla Firefox")
+                    + " instead. Continue anyway?", new SimpleResponseCallback() {
                   @Override
                   public void onCancel() {
                   }

Added: trunk/src/main/java/cc/kune/core/client/init/WebSocketChecker.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/init/WebSocketChecker.java	                        (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/init/WebSocketChecker.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -0,0 +1,74 @@
+/*
+ *
+ * Copyright (C) 2007-2012 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.init;
+
+import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.common.client.resources.CommonResources;
+import cc.kune.common.client.utils.WindowUtils;
+import cc.kune.common.shared.utils.SimpleResponseCallback;
+import cc.kune.common.shared.utils.TextUtils;
+import cc.kune.core.client.CoreConstants;
+import cc.kune.core.client.events.AppStartEvent;
+import cc.kune.core.client.events.AppStartEvent.AppStartHandler;
+import cc.kune.core.client.i18n.I18n;
+import cc.kune.core.client.state.Session;
+
+import com.google.inject.Inject;
+
+public class WebSocketChecker {
+
+  /**
+   * This class check if the browser supports websockets and give some advices
+   * to the user.
+   * 
+   * @param session
+   *          the session
+   * @param res
+   *          the resources
+   */
+  @Inject
+  public WebSocketChecker(final Session session, final CommonResources res) {
+    session.onAppStart(true, new AppStartHandler() {
+      @Override
+      public void onAppStart(final AppStartEvent event) {
+        if (WindowUtils.dontHasWebSocket()) {
+          final String mozLink = TextUtils.generateHtmlLink(CoreConstants.MOZILLA_FF_LINK,
+              "Mozilla Firefox");
+          NotifyUser.askConfirmation(
+              res.important32(),
+              I18n.t("Your browser is currently unsupported"),
+              I18n.t(
+                  "Please, use a free/libre modern and updated navigator like [%s] instead. Some functionality like concurrent edition will now work properly. Continue anyway?",
+                  mozLink), new SimpleResponseCallback() {
+                @Override
+                public void onCancel() {
+                  WindowUtils.changeHref(mozLink);
+                }
+
+                @Override
+                public void onSuccess() {
+                }
+              });
+        }
+      }
+    });
+  }
+}

Modified: trunk/src/main/java/cc/kune/core/shared/dto/UserSimpleDTO.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/dto/UserSimpleDTO.java	2012-05-23 22:18:52 UTC (rev 1875)
+++ trunk/src/main/java/cc/kune/core/shared/dto/UserSimpleDTO.java	2012-05-24 13:19:59 UTC (rev 1876)
@@ -26,6 +26,7 @@
 public class UserSimpleDTO implements IsSerializable {
   private String compoundName;
   private I18nCountryDTO country;
+  private Long createdOn;
   private String email;
   private EmailNotificationFrequency emailNotifFreq;
   private boolean emailVerified;
@@ -90,6 +91,10 @@
     return country;
   }
 
+  public Long getCreatedOn() {
+    return createdOn;
+  }
+
   public String getEmail() {
     return email;
   }
@@ -151,6 +156,10 @@
     this.country = country;
   }
 
+  public void setCreatedOn(final Long createdOn) {
+    this.createdOn = createdOn;
+  }
+
   public void setEmail(final String email) {
     this.email = email;
   }




More information about the kune-commits mailing list