]> git.0d.be Git - empathy.git/blobdiff - libempathy-gtk/empathy-account-widget.c
debug-window: fix typo
[empathy.git] / libempathy-gtk / empathy-account-widget.c
index 00f85df6dbbf88d2d644d9fd9e80f8f1351f9e46..794e7d5247a4ccb84dc81abf73183ad93930f5fd 100644 (file)
  *          Danielle Madeley <danielle.madeley@collabora.co.uk>
  */
 
-#include <config.h>
+#include "config.h"
 
-#include <string.h>
-
-#include <gtk/gtk.h>
 #include <glib/gi18n-lib.h>
 
-#include <gio/gdesktopappinfo.h>
-
 #include <libempathy/empathy-utils.h>
 
-#include <telepathy-glib/account.h>
-#include <telepathy-glib/account-manager.h>
-#include <telepathy-glib/connection-manager.h>
-#include <telepathy-glib/util.h>
 #include <dbus/dbus-protocol.h>
 
-#include "empathy-account-widget.h"
 #include "empathy-account-widget-private.h"
 #include "empathy-account-widget-sip.h"
 #include "empathy-account-widget-irc.h"
@@ -134,8 +124,6 @@ enum {
   LAST_SIGNAL
 };
 
-static void account_widget_apply_and_log_in (EmpathyAccountWidget *);
-
 enum {
   RESPONSE_LAUNCH
 };
@@ -174,14 +162,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
 /* Based on http://www.ietf.org/rfc/rfc2812.txt (section 2.3.1) */
 #define IRC_SPECIAL       "_\\[\\]{}\\\\|`^"
 #define IRC_NICK_NAME     "(["ALPHA IRC_SPECIAL"]["ALPHADIGITDASH IRC_SPECIAL"]*)"
-/*   user       =  1*( %x01-09 / %x0B-0C / %x0E-1F / %x21-3F / %x41-FF )
- *                ; any octet except NUL, CR, LF, " " and "@"
- *
- * so technically, like so many other places in IRC, we should be using arrays
- * of bytes here rather than UTF-8 strings. Life: too short. In practice this
- * will always be ASCII.
- */
-#define IRC_USER_NAME     "([^\r\n@ ])+"
 
 /* Based on http://www.ietf.org/rfc/rfc4622.txt (section 2.2)
  * We just exclude invalid characters to avoid ucschars and other redundant
@@ -198,7 +178,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
 
 #define ACCOUNT_REGEX_ICQ      "^"ICQ_USER_NAME"$"
 #define ACCOUNT_REGEX_IRC      "^"IRC_NICK_NAME"$"
-#define USERNAME_REGEX_IRC     "^"IRC_USER_NAME"$"
 #define ACCOUNT_REGEX_JABBER   "^"JABBER_USER_NAME"@[^@/]+"
 #define ACCOUNT_REGEX_MSN      "^"MSN_USER_NAME"@"HOST"$"
 #define ACCOUNT_REGEX_YAHOO    "^"YAHOO_USER_NAME"$"
@@ -520,7 +499,7 @@ password_entry_activated_cb (GtkEntry *entry,
     EmpathyAccountWidget *self)
 {
     if (gtk_widget_get_sensitive (self->priv->apply_button))
-        account_widget_apply_and_log_in (self);
+        empathy_account_widget_apply_and_log_in (self);
 }
 
 static void
@@ -528,7 +507,7 @@ account_entry_activated_cb (GtkEntry *entry,
     EmpathyAccountWidget *self)
 {
     if (gtk_widget_get_sensitive (self->priv->apply_button))
-        account_widget_apply_and_log_in (self);
+        empathy_account_widget_apply_and_log_in (self);
 }
 
 void
@@ -1002,8 +981,8 @@ account_widget_applied_cb (GObject *source_object,
   g_object_unref (self);
 }
 
-static void
-account_widget_apply_and_log_in (EmpathyAccountWidget *self)
+void
+empathy_account_widget_apply_and_log_in (EmpathyAccountWidget *self)
 {
   gboolean display_name_overridden;
 
@@ -1044,7 +1023,7 @@ static void
 account_widget_apply_clicked_cb (GtkWidget *button,
     EmpathyAccountWidget *self)
 {
-    account_widget_apply_and_log_in (self);
+    empathy_account_widget_apply_and_log_in (self);
 }
 
 static void
@@ -1138,8 +1117,6 @@ account_widget_build_irc (EmpathyAccountWidget *self,
 
   empathy_account_settings_set_regex (self->priv->settings, "account",
       ACCOUNT_REGEX_IRC);
-  empathy_account_settings_set_regex (self->priv->settings, "username",
-      USERNAME_REGEX_IRC);
 
   if (self->priv->simple)
     {
@@ -1877,16 +1854,11 @@ static void
 remember_password_toggled_cb (GtkToggleButton *button,
     EmpathyAccountWidget *self)
 {
-  if (gtk_toggle_button_get_active (button))
-    {
-      gtk_widget_set_sensitive (self->priv->param_password_widget, TRUE);
-    }
-  else
-    {
-      gtk_widget_set_sensitive (self->priv->param_password_widget, FALSE);
-      gtk_entry_set_text (GTK_ENTRY (self->priv->param_password_widget), "");
-      empathy_account_settings_unset (self->priv->settings, "password");
-    }
+  empathy_account_settings_set_remember_password (self->priv->settings,
+      gtk_toggle_button_get_active (button));
+
+  if (!self->priv->automatic_change)
+    empathy_account_widget_changed (self);
 }
 
 static void
@@ -1899,21 +1871,23 @@ account_settings_password_retrieved_cb (GObject *object,
   password = empathy_account_settings_dup_string (
       self->priv->settings, "password");
 
+  /* We have to do this so that when we call gtk_entry_set_text,
+   * the ::changed callback doesn't think the user made the
+   * change. This is also used in remember_password_toggled_cb. */
+  self->priv->automatic_change = TRUE;
+
   if (password != NULL)
     {
-      /* We have to do this so that when we call gtk_entry_set_text,
-       * the ::changed callback doesn't think the user made the
-       * change. */
-      self->priv->automatic_change = TRUE;
       gtk_entry_set_text (GTK_ENTRY (self->priv->param_password_widget),
           password);
-      self->priv->automatic_change = FALSE;
     }
 
   gtk_toggle_button_set_active (
       GTK_TOGGLE_BUTTON (self->priv->remember_password_widget),
       !EMP_STR_EMPTY (password));
 
+  self->priv->automatic_change = FALSE;
+
   g_free (password);
 }
 
@@ -2004,6 +1978,9 @@ do_constructed (GObject *obj)
           password = empathy_account_settings_dup_string (self->priv->settings,
               "password");
 
+          /* FIXME: we should enable this checkbox only if the password is
+           * stored for good in the password storage, not only for the session
+           * (bgo #683571) */
           gtk_toggle_button_set_active (
               GTK_TOGGLE_BUTTON (self->priv->remember_password_widget),
               !EMP_STR_EMPTY (password));
@@ -2021,13 +1998,17 @@ do_constructed (GObject *obj)
       g_signal_connect (self->priv->remember_password_widget, "toggled",
           G_CALLBACK (remember_password_toggled_cb), self);
 
+      self->priv->automatic_change = TRUE;
       remember_password_toggled_cb (
           GTK_TOGGLE_BUTTON (self->priv->remember_password_widget), self);
+      self->priv->automatic_change = FALSE;
     }
   else if (self->priv->remember_password_widget != NULL
       && !empathy_account_settings_supports_sasl (self->priv->settings))
     {
       gtk_widget_set_visible (self->priv->remember_password_widget, FALSE);
+      empathy_account_settings_set_remember_password (self->priv->settings,
+          TRUE);
     }
 
   /* dup and init the account-manager */