2 * Copyright (C) 2006-2007 Imendio AB
3 * Copyright (C) 2007-2009 Collabora Ltd.
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301 USA
20 * Authors: Xavier Claessens <xclaesse@gmail.com>
21 * Martyn Russell <martyn@imendio.com>
22 * Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
23 * Jonathan Tellier <jonathan.tellier@gmail.com>
31 #include <glib/gi18n-lib.h>
33 #include <gio/gdesktopappinfo.h>
35 #include <libempathy/empathy-utils.h>
37 #include <telepathy-glib/account.h>
38 #include <telepathy-glib/account-manager.h>
39 #include <telepathy-glib/connection-manager.h>
40 #include <telepathy-glib/util.h>
41 #include <dbus/dbus-protocol.h>
43 #include "empathy-account-widget.h"
44 #include "empathy-account-widget-private.h"
45 #include "empathy-account-widget-sip.h"
46 #include "empathy-account-widget-irc.h"
47 #include "empathy-ui-utils.h"
49 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
50 #include <libempathy/empathy-debug.h>
52 G_DEFINE_TYPE (EmpathyAccountWidget, empathy_account_widget, G_TYPE_OBJECT)
64 const gchar *label_username_example;
65 gboolean show_advanced;
68 static ServiceInfo services_infos[N_SERVICES] = {
69 { "label_username_example", TRUE },
70 { "label_username_g_example", FALSE },
71 { "label_username_f_example", FALSE },
75 EmpathyAccountSettings *settings;
77 GtkWidget *table_common_settings;
78 GtkWidget *apply_button;
79 GtkWidget *cancel_button;
80 GtkWidget *entry_password;
81 GtkWidget *spinbutton_port;
82 GtkWidget *radiobutton_reuse;
86 gboolean contains_pending_changes;
88 /* An EmpathyAccountWidget can be used to either create an account or
89 * modify it. When we are creating an account, this member is set to TRUE */
90 gboolean creating_account;
92 /* whether there are any other real accounts. Necessary so we know whether
93 * it's safe to dismiss this widget in some cases (eg, whether the Cancel
94 * button should be sensitive) */
95 gboolean other_accounts_exist;
97 /* if TRUE, the GTK+ destroy signal has been fired and so the widgets
98 * embedded in this account widget can't be used any more
99 * workaround because some async callbacks can be called after the
100 * widget has been destroyed */
103 TpAccountManager *account_manager;
105 GtkWidget *param_account_widget;
106 GtkWidget *param_password_widget;
108 gboolean automatic_change;
109 GtkWidget *remember_password_widget;
111 /* Used only for IRC accounts */
112 EmpathyIrcNetworkChooser *irc_network_chooser;
114 /* Used for 'special' XMPP account having a service associated ensuring that
115 * JIDs have a specific suffix; such as Facebook for example */
118 gboolean dispose_run;
119 } EmpathyAccountWidgetPriv;
125 PROP_CREATING_ACCOUNT,
126 PROP_OTHER_ACCOUNTS_EXIST,
136 static void account_widget_apply_and_log_in (EmpathyAccountWidget *);
142 static guint signals[LAST_SIGNAL] = { 0 };
144 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget)
145 #define CHANGED_TIMEOUT 300
148 #define DIGITS "(["DIGIT"]+)"
149 #define ALPHA "a-zA-Z"
150 #define ALPHAS "(["ALPHA"]+)"
151 #define ALPHADIGIT ALPHA DIGIT
152 #define ALPHADIGITS "(["ALPHADIGIT"]+)"
153 #define ALPHADIGITDASH ALPHA DIGIT "-"
154 #define ALPHADIGITDASHS "(["ALPHADIGITDASH"]*)"
156 #define HOSTNUMBER "("DIGITS"\\."DIGITS"\\."DIGITS"\\."DIGITS")"
157 #define TOPLABEL ALPHAS"|(["ALPHA"]" ALPHADIGITDASHS "["ALPHADIGIT"])"
158 #define DOMAINLABEL ALPHADIGITS"|(["ALPHADIGIT"]" ALPHADIGITDASHS \
160 #define HOSTNAME "((" DOMAINLABEL "\\.)+" TOPLABEL ")"
161 /* Based on http://www.ietf.org/rfc/rfc1738.txt (section 5) */
162 #define HOST "("HOSTNAME "|" HOSTNUMBER")"
163 /* Based on http://www.ietf.org/rfc/rfc0822.txt (appendix D) */
164 #define EMAIL_LOCALPART "([^\\(\\)<>@,;:\\\\\"\\[\\]\\s]+)"
166 /* UIN is digital according to the unofficial specification:
167 * http://iserverd.khstu.ru/docum_ext/icqv5.html#CTS
168 * 5 digits minimum according to http://en.wikipedia.org/wiki/ICQ#UIN
169 * According to an user, we can also provide an email address instead of the
171 #define ICQ_USER_NAME "((["DIGIT"]{5,})|"EMAIL_LOCALPART"@"HOST")"
173 /* Based on http://www.ietf.org/rfc/rfc2812.txt (section 2.3.1) */
174 #define IRC_SPECIAL "_\\[\\]{}\\\\|`^"
175 #define IRC_NICK_NAME "(["ALPHA IRC_SPECIAL"]["ALPHADIGITDASH IRC_SPECIAL"]*)"
176 /* user = 1*( %x01-09 / %x0B-0C / %x0E-1F / %x21-3F / %x41-FF )
177 * ; any octet except NUL, CR, LF, " " and "@"
179 * so technically, like so many other places in IRC, we should be using arrays
180 * of bytes here rather than UTF-8 strings. Life: too short. In practice this
181 * will always be ASCII.
183 #define IRC_USER_NAME "([^\r\n@ ])+"
185 /* Based on http://www.ietf.org/rfc/rfc4622.txt (section 2.2)
186 * We just exclude invalid characters to avoid ucschars and other redundant
188 #define JABBER_USER_NAME "([^@:'\"<>&\\s]+)"
189 /* ID is an email according to the unofficial specification:
190 * http://www.hypothetic.org/docs/msn/general/names.php */
191 #define MSN_USER_NAME EMAIL_LOCALPART
192 /* Based on the official help:
193 * http://help.yahoo.com/l/us/yahoo/edit/registration/edit-01.html */
194 #define YAHOO_USER_NAME "(["ALPHA"]["ALPHADIGIT"_\\.]{3,31})"
196 #define ACCOUNT_REGEX_ICQ "^"ICQ_USER_NAME"$"
197 #define ACCOUNT_REGEX_IRC "^"IRC_NICK_NAME"$"
198 #define USERNAME_REGEX_IRC "^"IRC_USER_NAME"$"
199 #define ACCOUNT_REGEX_JABBER "^"JABBER_USER_NAME"@"HOST"$"
200 #define ACCOUNT_REGEX_MSN "^"MSN_USER_NAME"@"HOST"$"
201 #define ACCOUNT_REGEX_YAHOO "^"YAHOO_USER_NAME"$"
204 account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self,
207 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
211 /* we hit this case because of the 'other-accounts-exist' property handler
212 * being called during init (before constructed()) */
213 if (priv->apply_button == NULL || priv->cancel_button == NULL)
216 gtk_widget_set_sensitive (priv->apply_button, sensitive);
217 gtk_widget_set_sensitive (priv->cancel_button,
218 (sensitive || priv->creating_account) && priv->other_accounts_exist);
222 /* We can't grab default if the widget hasn't be packed in a
226 window = gtk_widget_get_toplevel (priv->apply_button);
227 if (window != NULL &&
228 gtk_widget_is_toplevel (window))
230 gtk_widget_set_can_default (priv->apply_button, TRUE);
231 gtk_widget_grab_default (priv->apply_button);
238 account_widget_set_entry_highlighting (GtkEntry *entry,
241 g_return_if_fail (GTK_IS_ENTRY (entry));
245 GtkStyleContext *style;
248 style = gtk_widget_get_style_context (GTK_WIDGET (entry));
249 gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED,
252 /* Here we take the current theme colour and add it to
253 * the colour for white and average the two. This
254 * gives a colour which is inline with the theme but
257 empathy_make_color_whiter (&color);
259 gtk_widget_override_background_color (GTK_WIDGET (entry), 0, &color);
263 gtk_widget_override_background_color (GTK_WIDGET (entry), 0, NULL);
268 account_widget_handle_control_buttons_sensitivity (EmpathyAccountWidget *self)
270 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
273 is_valid = empathy_account_settings_is_valid (priv->settings);
276 account_widget_set_control_buttons_sensitivity (self, is_valid);
278 g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid);
282 account_widget_entry_changed_common (EmpathyAccountWidget *self,
283 GtkEntry *entry, gboolean focus)
286 const gchar *param_name;
287 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
288 gboolean prev_status;
289 gboolean curr_status;
291 str = gtk_entry_get_text (entry);
292 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
293 prev_status = empathy_account_settings_parameter_is_valid (priv->settings,
296 if (EMP_STR_EMPTY (str))
298 const gchar *value = NULL;
300 empathy_account_settings_unset (priv->settings, param_name);
304 value = empathy_account_settings_get_string (priv->settings,
306 DEBUG ("Unset %s and restore to %s", param_name, value);
307 gtk_entry_set_text (entry, value ? value : "");
312 DEBUG ("Setting %s to %s", param_name,
313 tp_strdiff (param_name, "password") ? str : "***");
314 empathy_account_settings_set_string (priv->settings, param_name, str);
317 curr_status = empathy_account_settings_parameter_is_valid (priv->settings,
319 if (curr_status != prev_status)
320 account_widget_set_entry_highlighting (entry, !curr_status);
324 account_widget_entry_changed_cb (GtkEditable *entry,
325 EmpathyAccountWidget *self)
327 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
329 if (priv->automatic_change)
332 account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
333 empathy_account_widget_changed (self);
337 account_widget_entry_map_cb (GtkEntry *entry,
338 EmpathyAccountWidget *self)
340 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
341 const gchar *param_name;
344 /* need to initialize input highlighting */
345 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
346 is_valid = empathy_account_settings_parameter_is_valid (priv->settings,
348 account_widget_set_entry_highlighting (entry, !is_valid);
352 account_widget_int_changed_cb (GtkWidget *widget,
353 EmpathyAccountWidget *self)
355 const gchar *param_name;
357 const gchar *signature;
358 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
360 value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
361 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
363 signature = empathy_account_settings_get_dbus_signature (priv->settings,
365 g_return_if_fail (signature != NULL);
367 DEBUG ("Setting %s to %d", param_name, value);
369 switch ((int)*signature)
371 case DBUS_TYPE_INT16:
372 case DBUS_TYPE_INT32:
373 empathy_account_settings_set_int32 (priv->settings, param_name, value);
375 case DBUS_TYPE_INT64:
376 empathy_account_settings_set_int64 (priv->settings, param_name, value);
378 case DBUS_TYPE_UINT16:
379 case DBUS_TYPE_UINT32:
380 empathy_account_settings_set_uint32 (priv->settings, param_name, value);
382 case DBUS_TYPE_UINT64:
383 empathy_account_settings_set_uint64 (priv->settings, param_name, value);
386 g_return_if_reached ();
389 empathy_account_widget_changed (self);
393 account_widget_checkbutton_toggled_cb (GtkWidget *widget,
394 EmpathyAccountWidget *self)
397 gboolean default_value;
398 const gchar *param_name;
399 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
401 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
402 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
404 /* FIXME: This is ugly! checkbox don't have a "not-set" value so we
405 * always unset the param and set the value if different from the
407 empathy_account_settings_unset (priv->settings, param_name);
408 default_value = empathy_account_settings_get_boolean (priv->settings,
411 if (default_value == value)
413 DEBUG ("Unset %s and restore to %d", param_name, default_value);
417 DEBUG ("Setting %s to %d", param_name, value);
418 empathy_account_settings_set_boolean (priv->settings, param_name, value);
421 empathy_account_widget_changed (self);
425 account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
426 EmpathyAccountWidget *self)
428 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
432 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl));
433 port = empathy_account_settings_get_uint32 (priv->settings, "port");
437 if (port == 5222 || port == 0)
442 if (port == 5223 || port == 0)
446 gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spinbutton_port), port);
448 priv->contains_pending_changes = TRUE;
452 account_widget_combobox_changed_cb (GtkWidget *widget,
453 EmpathyAccountWidget *self)
459 const gchar *default_value = NULL;
460 const gchar *param_name;
461 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
463 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
466 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
467 /* the param value is stored in the first column */
468 gtk_tree_model_get (model, &iter, 0, &value, -1);
470 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
472 v = empathy_account_settings_get_default (priv->settings, param_name);
474 default_value = g_value_get_string (v);
476 if (!tp_strdiff (value, default_value))
478 DEBUG ("Unset %s and restore to %s", param_name, default_value);
479 empathy_account_settings_unset (priv->settings, param_name);
483 DEBUG ("Setting %s to %s", param_name, value);
484 empathy_account_settings_set_string (priv->settings, param_name, value);
487 empathy_account_widget_changed (self);
491 clear_icon_released_cb (GtkEntry *entry,
492 GtkEntryIconPosition icon_pos,
494 EmpathyAccountWidget *self)
496 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
497 const gchar *param_name;
499 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
501 DEBUG ("Unset %s", param_name);
502 empathy_account_settings_unset (priv->settings, param_name);
503 gtk_entry_set_text (entry, "");
505 empathy_account_widget_changed (self);
509 password_entry_changed_cb (GtkEditable *entry,
510 EmpathyAccountWidget *self)
514 str = gtk_entry_get_text (GTK_ENTRY (entry));
516 gtk_entry_set_icon_sensitive (GTK_ENTRY (entry),
517 GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
521 password_entry_activated_cb (GtkEntry *entry,
522 EmpathyAccountWidget *self)
524 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
526 if (gtk_widget_get_sensitive (priv->apply_button))
527 account_widget_apply_and_log_in (self);
531 account_entry_activated_cb (GtkEntry *entry,
532 EmpathyAccountWidget *self)
534 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
536 if (gtk_widget_get_sensitive (priv->apply_button))
537 account_widget_apply_and_log_in (self);
541 empathy_account_widget_setup_widget (EmpathyAccountWidget *self,
543 const gchar *param_name)
545 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
547 g_object_set_data_full (G_OBJECT (widget), "param_name",
548 g_strdup (param_name), g_free);
550 if (GTK_IS_SPIN_BUTTON (widget))
553 const gchar *signature;
555 signature = empathy_account_settings_get_dbus_signature (priv->settings,
557 g_return_if_fail (signature != NULL);
559 switch ((int)*signature)
561 case DBUS_TYPE_INT16:
562 case DBUS_TYPE_INT32:
563 value = empathy_account_settings_get_int32 (priv->settings,
566 case DBUS_TYPE_INT64:
567 value = empathy_account_settings_get_int64 (priv->settings,
570 case DBUS_TYPE_UINT16:
571 case DBUS_TYPE_UINT32:
572 value = empathy_account_settings_get_uint32 (priv->settings,
575 case DBUS_TYPE_UINT64:
576 value = empathy_account_settings_get_uint64 (priv->settings,
580 g_return_if_reached ();
583 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
585 g_signal_connect (widget, "value-changed",
586 G_CALLBACK (account_widget_int_changed_cb),
589 else if (GTK_IS_ENTRY (widget))
591 const gchar *str = NULL;
593 str = empathy_account_settings_get_string (priv->settings, param_name);
594 gtk_entry_set_text (GTK_ENTRY (widget), str ? str : "");
596 if (!tp_strdiff (param_name, "account"))
597 priv->param_account_widget = widget;
598 else if (!tp_strdiff (param_name, "password"))
599 priv->param_password_widget = widget;
601 if (strstr (param_name, "password"))
603 gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE);
605 /* Add 'clear' icon */
606 gtk_entry_set_icon_from_stock (GTK_ENTRY (widget),
607 GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_CLEAR);
609 gtk_entry_set_icon_sensitive (GTK_ENTRY (widget),
610 GTK_ENTRY_ICON_SECONDARY, !EMP_STR_EMPTY (str));
612 g_signal_connect (widget, "icon-release",
613 G_CALLBACK (clear_icon_released_cb), self);
614 g_signal_connect (widget, "changed",
615 G_CALLBACK (password_entry_changed_cb), self);
616 g_signal_connect (widget, "activate",
617 G_CALLBACK (password_entry_activated_cb), self);
619 else if (strstr (param_name, "account"))
620 g_signal_connect (widget, "activate",
621 G_CALLBACK (account_entry_activated_cb), self);
624 g_signal_connect (widget, "changed",
625 G_CALLBACK (account_widget_entry_changed_cb), self);
626 g_signal_connect (widget, "map",
627 G_CALLBACK (account_widget_entry_map_cb), self);
629 else if (GTK_IS_TOGGLE_BUTTON (widget))
631 gboolean value = FALSE;
633 value = empathy_account_settings_get_boolean (priv->settings,
635 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
637 g_signal_connect (widget, "toggled",
638 G_CALLBACK (account_widget_checkbutton_toggled_cb),
641 else if (GTK_IS_COMBO_BOX (widget))
643 /* The combo box's model has to contain the param value in its first
644 * column (as a string) */
650 str = empathy_account_settings_get_string (priv->settings, param_name);
651 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
653 valid = gtk_tree_model_get_iter_first (model, &iter);
658 gtk_tree_model_get (model, &iter, 0, &name, -1);
659 if (!tp_strdiff (name, str))
661 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
666 valid = gtk_tree_model_iter_next (model, &iter);
672 g_signal_connect (widget, "changed",
673 G_CALLBACK (account_widget_combobox_changed_cb),
678 DEBUG ("Unknown type of widget for param %s", param_name);
681 gtk_widget_set_sensitive (widget,
682 empathy_account_settings_param_is_supported (priv->settings, param_name));
686 build_translated_params (void)
690 hash = g_hash_table_new (g_str_hash, g_str_equal);
691 g_hash_table_insert (hash, "account", _("Account"));
692 g_hash_table_insert (hash, "password", _("Password"));
693 g_hash_table_insert (hash, "server", _("Server"));
694 g_hash_table_insert (hash, "port", _("Port"));
700 account_widget_generic_format_param_name (const gchar *param_name)
704 static GHashTable *translated_params = NULL;
706 if (G_UNLIKELY (translated_params == NULL))
707 translated_params = build_translated_params ();
709 /* Translate most common parameters */
710 str = g_hash_table_lookup (translated_params, param_name);
712 return g_strdup (str);
714 str = g_strdup (param_name);
716 if (str && g_ascii_isalpha (str[0]))
717 str[0] = g_ascii_toupper (str[0]);
719 while ((p = strchr (str, '-')) != NULL)
721 if (p[1] != '\0' && g_ascii_isalpha (p[1]))
724 p[1] = g_ascii_toupper (p[1]);
734 accounts_widget_generic_setup (EmpathyAccountWidget *self,
735 GtkWidget *table_common_settings,
736 GtkWidget *table_advanced_settings)
738 TpConnectionManagerParam *params, *param;
739 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
741 params = empathy_account_settings_get_tp_params (priv->settings);
743 for (param = params; param != NULL && param->name != NULL; param++)
745 GtkWidget *table_settings;
747 GtkWidget *widget = NULL;
748 gchar *param_name_formatted;
750 if (param->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED)
751 table_settings = table_common_settings;
752 else if (priv->simple)
755 table_settings = table_advanced_settings;
757 param_name_formatted = account_widget_generic_format_param_name
759 g_object_get (table_settings, "n-rows", &n_rows, NULL);
760 gtk_table_resize (GTK_TABLE (table_settings), ++n_rows, 2);
762 if (param->dbus_signature[0] == 's')
766 str = g_strdup_printf (_("%s:"), param_name_formatted);
767 widget = gtk_label_new (str);
768 gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
771 gtk_table_attach (GTK_TABLE (table_settings),
777 gtk_widget_show (widget);
779 widget = gtk_entry_new ();
780 if (strcmp (param->name, "account") == 0)
782 g_signal_connect (widget, "realize",
783 G_CALLBACK (gtk_widget_grab_focus),
786 gtk_table_attach (GTK_TABLE (table_settings),
790 GTK_FILL | GTK_EXPAND, 0,
792 gtk_widget_show (widget);
794 /* int types: ynqiuxt. double type is 'd' */
795 else if (param->dbus_signature[0] == 'y' ||
796 param->dbus_signature[0] == 'n' ||
797 param->dbus_signature[0] == 'q' ||
798 param->dbus_signature[0] == 'i' ||
799 param->dbus_signature[0] == 'u' ||
800 param->dbus_signature[0] == 'x' ||
801 param->dbus_signature[0] == 't' ||
802 param->dbus_signature[0] == 'd')
809 switch (param->dbus_signature[0])
811 case 'y': minint = G_MININT8; maxint = G_MAXINT8; break;
812 case 'n': minint = G_MININT16; maxint = G_MAXINT16; break;
813 case 'q': minint = 0; maxint = G_MAXUINT16; break;
814 case 'i': minint = G_MININT32; maxint = G_MAXINT32; break;
815 case 'u': minint = 0; maxint = G_MAXUINT32; break;
816 case 'x': minint = G_MININT64; maxint = G_MAXINT64; break;
817 case 't': minint = 0; maxint = G_MAXUINT64; break;
818 case 'd': minint = G_MININT32; maxint = G_MAXINT32;
820 default: g_assert_not_reached ();
823 str = g_strdup_printf (_("%s:"), param_name_formatted);
824 widget = gtk_label_new (str);
825 gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
828 gtk_table_attach (GTK_TABLE (table_settings),
834 gtk_widget_show (widget);
836 widget = gtk_spin_button_new_with_range (minint, maxint, step);
837 gtk_table_attach (GTK_TABLE (table_settings),
841 GTK_FILL | GTK_EXPAND, 0,
843 gtk_widget_show (widget);
845 else if (param->dbus_signature[0] == 'b')
847 widget = gtk_check_button_new_with_label (param_name_formatted);
848 gtk_table_attach (GTK_TABLE (table_settings),
852 GTK_FILL | GTK_EXPAND, 0,
854 gtk_widget_show (widget);
858 DEBUG ("Unknown signature for param %s: %s",
859 param_name_formatted, param->dbus_signature);
863 empathy_account_widget_setup_widget (self, widget, param->name);
865 g_free (param_name_formatted);
870 account_widget_handle_params_valist (EmpathyAccountWidget *self,
871 const gchar *first_widget,
877 for (name = first_widget; name; name = va_arg (args, const gchar *))
879 const gchar *param_name;
881 param_name = va_arg (args, const gchar *);
882 object = gtk_builder_get_object (self->ui_details->gui, name);
886 g_warning ("Builder is missing object '%s'.", name);
890 empathy_account_widget_setup_widget (self, GTK_WIDGET (object),
896 account_widget_cancel_clicked_cb (GtkWidget *button,
897 EmpathyAccountWidget *self)
899 g_signal_emit (self, signals[CANCELLED], 0);
903 account_widget_account_enabled_cb (GObject *source_object,
907 GError *error = NULL;
908 TpAccount *account = TP_ACCOUNT (source_object);
909 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
910 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
912 tp_account_set_enabled_finish (account, res, &error);
916 DEBUG ("Could not enable the account: %s", error->message);
917 g_error_free (error);
921 empathy_connect_new_account (account, priv->account_manager);
924 /* unref widget - part of the workaround */
925 g_object_unref (widget);
929 account_widget_applied_cb (GObject *source_object,
933 GError *error = NULL;
935 EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
936 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
937 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
938 gboolean reconnect_required;
940 empathy_account_settings_apply_finish (settings, res, &reconnect_required,
945 DEBUG ("Could not apply changes to account: %s", error->message);
946 g_error_free (error);
950 account = empathy_account_settings_get_account (priv->settings);
954 if (priv->creating_account)
956 /* By default, when an account is created, we enable it. */
958 /* workaround to keep widget alive during async call */
959 g_object_ref (widget);
961 tp_account_set_enabled_async (account, TRUE,
962 account_widget_account_enabled_cb, widget);
963 g_signal_emit (widget, signals[ACCOUNT_CREATED], 0, account);
967 /* If the account was offline, we always want to try reconnecting,
968 * to give it a chance to connect if the previous params were wrong.
969 * tp_account_reconnect_async() won't do anything if the requested
970 * presence is offline anyway. */
971 if (tp_account_get_connection_status (account, NULL) ==
972 TP_CONNECTION_STATUS_DISCONNECTED)
973 reconnect_required = TRUE;
975 if (reconnect_required && tp_account_is_enabled (account)
976 && tp_account_is_enabled (account))
978 /* After having applied changes to a user account, we
979 * reconnect it if needed. This is done so the new
980 * information entered by the user is validated on the server. */
981 tp_account_reconnect_async (account, NULL, NULL);
986 if (!priv->destroyed)
987 account_widget_set_control_buttons_sensitivity (widget, FALSE);
989 priv->contains_pending_changes = FALSE;
991 /* unref the widget - part of the workaround */
992 g_object_unref (widget);
996 account_widget_apply_and_log_in (EmpathyAccountWidget *self)
998 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
999 gboolean display_name_overridden;
1001 if (priv->radiobutton_reuse != NULL)
1003 gboolean reuse = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (
1004 priv->radiobutton_reuse));
1006 DEBUG ("Set register param: %d", !reuse);
1007 empathy_account_settings_set_boolean (priv->settings, "register", !reuse);
1010 g_object_get (priv->settings,
1011 "display-name-overridden", &display_name_overridden, NULL);
1013 if (priv->creating_account || !display_name_overridden)
1015 gchar *display_name;
1017 /* set default display name for new accounts or update if user didn't
1018 * manually override it. */
1019 display_name = empathy_account_widget_get_default_display_name (self);
1021 empathy_account_settings_set_display_name_async (priv->settings,
1022 display_name, NULL, NULL);
1024 g_free (display_name);
1027 /* workaround to keep widget alive during async call */
1028 g_object_ref (self);
1029 empathy_account_settings_apply_async (priv->settings,
1030 account_widget_applied_cb, self);
1034 account_widget_apply_clicked_cb (GtkWidget *button,
1035 EmpathyAccountWidget *self)
1037 account_widget_apply_and_log_in (self);
1041 account_widget_setup_generic (EmpathyAccountWidget *self)
1043 GtkWidget *table_common_settings;
1044 GtkWidget *table_advanced_settings;
1046 table_common_settings = GTK_WIDGET (gtk_builder_get_object
1047 (self->ui_details->gui, "table_common_settings"));
1048 table_advanced_settings = GTK_WIDGET (gtk_builder_get_object
1049 (self->ui_details->gui, "table_advanced_settings"));
1051 accounts_widget_generic_setup (self, table_common_settings,
1052 table_advanced_settings);
1054 g_object_unref (self->ui_details->gui);
1058 account_widget_settings_ready_cb (EmpathyAccountSettings *settings,
1062 EmpathyAccountWidget *self = user_data;
1063 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1065 if (empathy_account_settings_is_ready (priv->settings))
1066 account_widget_setup_generic (self);
1070 account_widget_build_generic (EmpathyAccountWidget *self,
1071 const char *filename)
1073 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1074 GtkWidget *expander_advanced;
1076 self->ui_details->gui = empathy_builder_get_file (filename,
1077 "table_common_settings", &priv->table_common_settings,
1078 "vbox_generic_settings", &self->ui_details->widget,
1079 "expander_advanced_settings", &expander_advanced,
1083 gtk_widget_hide (expander_advanced);
1085 g_object_ref (self->ui_details->gui);
1087 if (empathy_account_settings_is_ready (priv->settings))
1088 account_widget_setup_generic (self);
1090 g_signal_connect (priv->settings, "notify::ready",
1091 G_CALLBACK (account_widget_settings_ready_cb), self);
1095 account_widget_launch_external_clicked (GtkWidget *button,
1098 if (!tp_strdiff (tp_account_get_storage_provider (account),
1099 "com.meego.libsocialweb"))
1101 /* we know how to handle this external provider */
1102 GDesktopAppInfo *desktop_info;
1103 GError *error = NULL;
1104 GdkAppLaunchContext *context = NULL;
1105 GdkDisplay *display;
1109 desktop_info = g_desktop_app_info_new ("gnome-control-center.desktop");
1110 if (desktop_info == NULL)
1112 g_critical ("Could not locate 'gnome-control-center.desktop'");
1116 /* glib doesn't have API to start a desktop file with args... (#637875) */
1117 cmd = g_strdup_printf ("%s bisho.desktop", g_app_info_get_commandline (
1118 (GAppInfo *) desktop_info));
1120 app_info = g_app_info_create_from_commandline (cmd, NULL, 0, &error);
1123 if (app_info == NULL)
1125 DEBUG ("Failed to create app info: %s", error->message);
1126 g_error_free (error);
1130 display = gdk_display_get_default ();
1131 context = gdk_display_get_app_launch_context (display);
1133 if (!g_app_info_launch (app_info, NULL, (GAppLaunchContext *) context,
1136 g_critical ("Failed to bisho: %s", error->message);
1137 g_clear_error (&error);
1141 g_object_unref (desktop_info);
1142 tp_clear_object (&app_info);
1143 tp_clear_object (&context);
1148 account_widget_build_external (EmpathyAccountWidget *self,
1149 EmpathyAccountSettings *settings)
1151 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1152 TpAccount *account = empathy_account_settings_get_account (settings);
1153 GtkWidget *bar, *widget;
1156 self->ui_details->widget = gtk_vbox_new (FALSE, 6);
1157 priv->table_common_settings = gtk_table_new (1, 2, FALSE);
1159 if (!tp_strdiff (tp_account_get_storage_provider (account),
1160 "com.meego.libsocialweb"))
1162 /* we know how to handle this external provider */
1163 str = g_strdup_printf (
1164 _("The account %s is edited via My Web Accounts."),
1165 empathy_account_settings_get_display_name (settings));
1169 str = g_strdup_printf (
1170 _("The account %s cannot be edited in Empathy."),
1171 empathy_account_settings_get_display_name (settings));
1174 widget = gtk_label_new (str);
1175 gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE);
1178 bar = gtk_info_bar_new ();
1179 gtk_info_bar_set_message_type (GTK_INFO_BAR (bar), GTK_MESSAGE_INFO);
1181 GTK_CONTAINER (gtk_info_bar_get_content_area (GTK_INFO_BAR (bar))),
1183 gtk_container_set_border_width (GTK_CONTAINER (bar), 6);
1185 if (!tp_strdiff (tp_account_get_storage_provider (account),
1186 "com.meego.libsocialweb"))
1188 /* we know how to handle this external provider */
1189 widget = gtk_info_bar_add_button (GTK_INFO_BAR (bar),
1190 _("Launch My Web Accounts"), RESPONSE_LAUNCH);
1192 g_signal_connect (widget, "clicked",
1193 G_CALLBACK (account_widget_launch_external_clicked), account);
1196 gtk_box_pack_start (GTK_BOX (self->ui_details->widget), bar,
1198 gtk_box_pack_start (GTK_BOX (self->ui_details->widget),
1199 priv->table_common_settings, FALSE, TRUE, 0);
1201 gtk_widget_show_all (self->ui_details->widget);
1205 account_widget_build_salut (EmpathyAccountWidget *self,
1206 const char *filename)
1208 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1209 GtkWidget *expander_advanced;
1211 self->ui_details->gui = empathy_builder_get_file (filename,
1212 "table_common_settings", &priv->table_common_settings,
1213 "vbox_salut_settings", &self->ui_details->widget,
1214 "expander_advanced_settings", &expander_advanced,
1217 empathy_account_widget_handle_params (self,
1218 "entry_published", "published-name",
1219 "entry_nickname", "nickname",
1220 "entry_first_name", "first-name",
1221 "entry_last_name", "last-name",
1222 "entry_email", "email",
1227 gtk_widget_hide (expander_advanced);
1229 self->ui_details->default_focus = g_strdup ("entry_first_name");
1233 account_widget_build_irc (EmpathyAccountWidget *self,
1234 const char *filename)
1236 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1238 empathy_account_settings_set_regex (priv->settings, "account",
1240 empathy_account_settings_set_regex (priv->settings, "username",
1241 USERNAME_REGEX_IRC);
1245 priv->irc_network_chooser = empathy_account_widget_irc_build_simple (self,
1250 priv->irc_network_chooser = empathy_account_widget_irc_build (self,
1251 filename, &priv->table_common_settings);
1256 account_widget_build_sip (EmpathyAccountWidget *self,
1257 const char *filename)
1259 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1260 empathy_account_widget_sip_build (self, filename,
1261 &priv->table_common_settings);
1265 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1266 self->ui_details->gui, "remember_password_simple"));
1270 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1271 self->ui_details->gui, "remember_password"));
1276 account_widget_build_msn (EmpathyAccountWidget *self,
1277 const char *filename)
1279 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1281 empathy_account_settings_set_regex (priv->settings, "account",
1286 self->ui_details->gui = empathy_builder_get_file (filename,
1287 "vbox_msn_simple", &self->ui_details->widget,
1290 empathy_account_widget_handle_params (self,
1291 "entry_id_simple", "account",
1292 "entry_password_simple", "password",
1295 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1297 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1298 self->ui_details->gui, "remember_password_simple"));
1302 self->ui_details->gui = empathy_builder_get_file (filename,
1303 "table_common_msn_settings", &priv->table_common_settings,
1304 "vbox_msn_settings", &self->ui_details->widget,
1307 empathy_account_widget_handle_params (self,
1308 "entry_id", "account",
1309 "entry_password", "password",
1310 "entry_server", "server",
1311 "spinbutton_port", "port",
1314 self->ui_details->default_focus = g_strdup ("entry_id");
1316 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1317 self->ui_details->gui, "remember_password"));
1322 suffix_id_widget_changed_cb (GtkWidget *entry,
1323 EmpathyAccountWidget *self)
1325 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1326 const gchar *account;
1328 g_assert (priv->jid_suffix != NULL);
1330 account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
1332 account = empathy_account_settings_get_string (priv->settings, "account");
1333 if (!EMP_STR_EMPTY (account) &&
1334 !g_str_has_suffix (account, priv->jid_suffix))
1338 tmp = g_strdup_printf ("%s%s", account, priv->jid_suffix);
1340 DEBUG ("Change account from '%s' to '%s'", account, tmp);
1342 empathy_account_settings_set_string (priv->settings, "account", tmp);
1346 empathy_account_widget_changed (self);
1350 remove_jid_suffix (EmpathyAccountWidget *self,
1353 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1355 g_assert (priv->jid_suffix != NULL);
1357 if (!g_str_has_suffix (str, priv->jid_suffix))
1358 return g_strdup (str);
1360 return g_strndup (str, strlen (str) - strlen (priv->jid_suffix));
1364 setup_id_widget_with_suffix (EmpathyAccountWidget *self,
1366 const gchar *suffix)
1368 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1369 const gchar *str = NULL;
1371 g_object_set_data_full (G_OBJECT (widget), "param_name",
1372 g_strdup ("account"), g_free);
1374 g_assert (priv->jid_suffix == NULL);
1375 priv->jid_suffix = g_strdup (suffix);
1377 str = empathy_account_settings_get_string (priv->settings, "account");
1382 tmp = remove_jid_suffix (self, str);
1383 gtk_entry_set_text (GTK_ENTRY (widget), tmp);
1387 priv->param_account_widget = widget;
1389 g_signal_connect (widget, "changed",
1390 G_CALLBACK (suffix_id_widget_changed_cb), self);
1394 account_widget_get_service (EmpathyAccountWidget *self)
1396 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1397 const gchar *icon_name, *service;
1399 icon_name = empathy_account_settings_get_icon_name (priv->settings);
1400 service = empathy_account_settings_get_service (priv->settings);
1402 /* Previous versions of Empathy didn't set the Service property on Facebook
1403 * and gtalk accounts, so we check using the icon name as well. */
1404 if (!tp_strdiff (icon_name, "im-google-talk") ||
1405 !tp_strdiff (service, "google-talk"))
1406 return GTALK_SERVICE;
1408 if (!tp_strdiff (icon_name, "im-facebook") ||
1409 !tp_strdiff (service, "facebook"))
1410 return FACEBOOK_SERVICE;
1416 account_widget_build_jabber (EmpathyAccountWidget *self,
1417 const char *filename)
1419 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1420 GtkWidget *spinbutton_port;
1421 GtkWidget *checkbutton_ssl;
1422 GtkWidget *label_id, *label_password;
1423 GtkWidget *label_id_create, *label_password_create;
1424 GtkWidget *label_example_fb;
1425 GtkWidget *label_example;
1426 GtkWidget *expander_advanced;
1427 GtkWidget *entry_id;
1430 service = account_widget_get_service (self);
1432 empathy_account_settings_set_regex (priv->settings, "account",
1433 ACCOUNT_REGEX_JABBER);
1435 if (priv->simple && service == NO_SERVICE)
1437 /* Simple widget for XMPP */
1438 self->ui_details->gui = empathy_builder_get_file (filename,
1439 "vbox_jabber_simple", &self->ui_details->widget,
1440 "label_id_simple", &label_id,
1441 "label_id_create", &label_id_create,
1442 "label_password_simple", &label_password,
1443 "label_password_create", &label_password_create,
1446 if (empathy_account_settings_get_boolean (priv->settings, "register"))
1448 gtk_widget_hide (label_id);
1449 gtk_widget_hide (label_password);
1450 gtk_widget_show (label_id_create);
1451 gtk_widget_show (label_password_create);
1454 empathy_account_widget_handle_params (self,
1455 "entry_id_simple", "account",
1456 "entry_password_simple", "password",
1459 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1461 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1462 self->ui_details->gui, "remember_password_simple"));
1464 else if (priv->simple && service == GTALK_SERVICE)
1466 /* Simple widget for Google Talk */
1467 self->ui_details->gui = empathy_builder_get_file (filename,
1468 "vbox_gtalk_simple", &self->ui_details->widget,
1471 empathy_account_widget_handle_params (self,
1472 "entry_id_g_simple", "account",
1473 "entry_password_g_simple", "password",
1476 self->ui_details->default_focus = g_strdup ("entry_id_g_simple");
1478 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1479 self->ui_details->gui, "remember_password_g_simple"));
1481 else if (priv->simple && service == FACEBOOK_SERVICE)
1483 /* Simple widget for Facebook */
1484 self->ui_details->gui = empathy_builder_get_file (filename,
1485 "vbox_fb_simple", &self->ui_details->widget,
1486 "entry_id_fb_simple", &entry_id,
1489 empathy_account_widget_handle_params (self,
1490 "entry_password_fb_simple", "password",
1493 setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com");
1495 self->ui_details->default_focus = g_strdup ("entry_id_fb_simple");
1497 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1498 self->ui_details->gui, "remember_password_fb_simple"));
1502 ServiceInfo info = services_infos[service];
1504 /* Full widget for XMPP, Google Talk and Facebook*/
1505 self->ui_details->gui = empathy_builder_get_file (filename,
1506 "table_common_settings", &priv->table_common_settings,
1507 "vbox_jabber_settings", &self->ui_details->widget,
1508 "spinbutton_port", &spinbutton_port,
1509 "checkbutton_ssl", &checkbutton_ssl,
1510 "label_username_f_example", &label_example_fb,
1511 info.label_username_example, &label_example,
1512 "expander_advanced", &expander_advanced,
1513 "entry_id", &entry_id,
1514 "label_id", &label_id,
1517 empathy_account_widget_handle_params (self,
1518 "entry_password", "password",
1519 "entry_resource", "resource",
1520 "entry_server", "server",
1521 "spinbutton_port", "port",
1522 "spinbutton_priority", "priority",
1523 "checkbutton_ssl", "old-ssl",
1524 "checkbutton_ignore_ssl_errors", "ignore-ssl-errors",
1525 "checkbutton_encryption", "require-encryption",
1528 if (service == FACEBOOK_SERVICE)
1530 gtk_label_set_label (GTK_LABEL (label_id), _("Username:"));
1532 /* Facebook special case the entry ID widget to hide the
1533 * "@chat.facebook.com" part */
1534 setup_id_widget_with_suffix (self, entry_id, "@chat.facebook.com");
1538 empathy_account_widget_setup_widget (self, entry_id, "account");
1541 self->ui_details->default_focus = g_strdup ("entry_id");
1542 priv->spinbutton_port = spinbutton_port;
1544 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1545 self->ui_details->gui, "remember_password"));
1547 g_signal_connect (checkbutton_ssl, "toggled",
1548 G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
1551 if (service == FACEBOOK_SERVICE)
1553 GtkContainer *parent;
1556 /* Removing the label from list of focusable widgets */
1557 parent = GTK_CONTAINER (gtk_widget_get_parent (label_example_fb));
1558 children = gtk_container_get_children (parent);
1559 children = g_list_remove (children, label_example_fb);
1560 gtk_container_set_focus_chain (parent, children);
1561 g_list_free (children);
1564 gtk_widget_show (label_example);
1566 if (!info.show_advanced)
1567 gtk_widget_hide (expander_advanced);
1572 account_widget_build_icq (EmpathyAccountWidget *self,
1573 const char *filename)
1575 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1576 GtkWidget *spinbutton_port;
1578 empathy_account_settings_set_regex (priv->settings, "account",
1583 self->ui_details->gui = empathy_builder_get_file (filename,
1584 "vbox_icq_simple", &self->ui_details->widget,
1587 empathy_account_widget_handle_params (self,
1588 "entry_uin_simple", "account",
1589 "entry_password_simple", "password",
1592 self->ui_details->default_focus = g_strdup ("entry_uin_simple");
1594 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1595 self->ui_details->gui, "remember_password_simple"));
1599 self->ui_details->gui = empathy_builder_get_file (filename,
1600 "table_common_settings", &priv->table_common_settings,
1601 "vbox_icq_settings", &self->ui_details->widget,
1602 "spinbutton_port", &spinbutton_port,
1605 empathy_account_widget_handle_params (self,
1606 "entry_uin", "account",
1607 "entry_password", "password",
1608 "entry_server", "server",
1609 "spinbutton_port", "port",
1610 "entry_charset", "charset",
1613 self->ui_details->default_focus = g_strdup ("entry_uin");
1615 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1616 self->ui_details->gui, "remember_password"));
1621 account_widget_build_aim (EmpathyAccountWidget *self,
1622 const char *filename)
1624 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1625 GtkWidget *spinbutton_port;
1629 self->ui_details->gui = empathy_builder_get_file (filename,
1630 "vbox_aim_simple", &self->ui_details->widget,
1633 empathy_account_widget_handle_params (self,
1634 "entry_screenname_simple", "account",
1635 "entry_password_simple", "password",
1638 self->ui_details->default_focus = g_strdup ("entry_screenname_simple");
1640 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1641 self->ui_details->gui, "remember_password_simple"));
1645 self->ui_details->gui = empathy_builder_get_file (filename,
1646 "table_common_settings", &priv->table_common_settings,
1647 "vbox_aim_settings", &self->ui_details->widget,
1648 "spinbutton_port", &spinbutton_port,
1651 empathy_account_widget_handle_params (self,
1652 "entry_screenname", "account",
1653 "entry_password", "password",
1654 "entry_server", "server",
1655 "spinbutton_port", "port",
1658 self->ui_details->default_focus = g_strdup ("entry_screenname");
1660 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1661 self->ui_details->gui, "remember_password"));
1666 account_widget_build_yahoo (EmpathyAccountWidget *self,
1667 const char *filename)
1669 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1671 empathy_account_settings_set_regex (priv->settings, "account",
1672 ACCOUNT_REGEX_YAHOO);
1676 self->ui_details->gui = empathy_builder_get_file (filename,
1677 "vbox_yahoo_simple", &self->ui_details->widget,
1680 empathy_account_widget_handle_params (self,
1681 "entry_id_simple", "account",
1682 "entry_password_simple", "password",
1685 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1687 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1688 self->ui_details->gui, "remember_password_simple"));
1692 self->ui_details->gui = empathy_builder_get_file (filename,
1693 "table_common_settings", &priv->table_common_settings,
1694 "vbox_yahoo_settings", &self->ui_details->widget,
1697 empathy_account_widget_handle_params (self,
1698 "entry_id", "account",
1699 "entry_password", "password",
1700 "entry_locale", "room-list-locale",
1701 "entry_charset", "charset",
1702 "spinbutton_port", "port",
1703 "checkbutton_ignore_invites", "ignore-invites",
1706 self->ui_details->default_focus = g_strdup ("entry_id");
1708 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1709 self->ui_details->gui, "remember_password"));
1714 account_widget_build_groupwise (EmpathyAccountWidget *self,
1715 const char *filename)
1717 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1721 self->ui_details->gui = empathy_builder_get_file (filename,
1722 "vbox_groupwise_simple", &self->ui_details->widget,
1725 empathy_account_widget_handle_params (self,
1726 "entry_id_simple", "account",
1727 "entry_password_simple", "password",
1730 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1732 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1733 self->ui_details->gui, "remember_password_simple"));
1737 self->ui_details->gui = empathy_builder_get_file (filename,
1738 "table_common_groupwise_settings", &priv->table_common_settings,
1739 "vbox_groupwise_settings", &self->ui_details->widget,
1742 empathy_account_widget_handle_params (self,
1743 "entry_id", "account",
1744 "entry_password", "password",
1745 "entry_server", "server",
1746 "spinbutton_port", "port",
1749 self->ui_details->default_focus = g_strdup ("entry_id");
1751 priv->remember_password_widget = GTK_WIDGET (gtk_builder_get_object (
1752 self->ui_details->gui, "remember_password"));
1757 account_widget_destroy_cb (GtkWidget *widget,
1758 EmpathyAccountWidget *self)
1760 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1761 /* set the destroyed flag - workaround */
1762 priv->destroyed = TRUE;
1764 g_object_unref (self);
1768 empathy_account_widget_set_other_accounts_exist (EmpathyAccountWidget *self,
1769 gboolean others_exist)
1771 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1773 priv->other_accounts_exist = others_exist;
1775 if (priv->creating_account)
1776 account_widget_handle_control_buttons_sensitivity (self);
1780 do_set_property (GObject *object,
1782 const GValue *value,
1785 EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
1790 priv->settings = g_value_dup_object (value);
1793 priv->simple = g_value_get_boolean (value);
1795 case PROP_CREATING_ACCOUNT:
1796 priv->creating_account = g_value_get_boolean (value);
1798 case PROP_OTHER_ACCOUNTS_EXIST:
1799 empathy_account_widget_set_other_accounts_exist (
1800 EMPATHY_ACCOUNT_WIDGET (object), g_value_get_boolean (value));
1803 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1808 do_get_property (GObject *object,
1813 EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
1818 g_value_set_string (value,
1819 empathy_account_settings_get_protocol (priv->settings));
1822 g_value_set_object (value, priv->settings);
1825 g_value_set_boolean (value, priv->simple);
1827 case PROP_CREATING_ACCOUNT:
1828 g_value_set_boolean (value, priv->creating_account);
1830 case PROP_OTHER_ACCOUNTS_EXIST:
1831 g_value_set_boolean (value, priv->other_accounts_exist);
1834 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1839 set_apply_button (EmpathyAccountWidget *self)
1841 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1844 /* We can't use the stock button as its accelerator ('A') clashes with the
1846 gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
1848 gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("A_pply"));
1849 gtk_button_set_use_underline (GTK_BUTTON (priv->apply_button), TRUE);
1851 image = gtk_image_new_from_stock (GTK_STOCK_APPLY, GTK_ICON_SIZE_BUTTON);
1852 gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
1856 presence_changed_cb (TpAccountManager *manager,
1857 TpConnectionPresenceType state,
1858 const gchar *status,
1859 const gchar *message,
1860 EmpathyAccountWidget *self)
1862 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1864 if (priv->destroyed)
1867 if (priv->apply_button == NULL)
1868 /* This button doesn't exist in 'simple' mode */
1871 if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE &&
1872 priv->creating_account)
1874 /* We are online and creating a new account, display a Login button */
1877 gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
1878 gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("L_og in"));
1880 image = gtk_image_new_from_stock (GTK_STOCK_CONNECT,
1881 GTK_ICON_SIZE_BUTTON);
1882 gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
1886 /* We are offline or modifying an existing account, display
1888 set_apply_button (self);
1893 account_manager_ready_cb (GObject *source_object,
1894 GAsyncResult *result,
1897 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (user_data);
1898 TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
1899 GError *error = NULL;
1900 TpConnectionPresenceType state;
1902 if (!tp_account_manager_prepare_finish (account_manager, result, &error))
1904 DEBUG ("Failed to prepare account manager: %s", error->message);
1905 g_error_free (error);
1909 state = tp_account_manager_get_most_available_presence (account_manager, NULL,
1912 /* simulate a presence change so the apply button will be changed
1914 presence_changed_cb (account_manager, state, NULL, NULL, self);
1917 g_object_unref (self);
1920 #define WIDGET(cm, proto) \
1921 { #cm, #proto, "empathy-account-widget-"#proto".ui", \
1922 account_widget_build_##proto }
1925 /* Meego doesn't support registration */
1927 add_register_buttons (EmpathyAccountWidget *self,
1930 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1931 const TpConnectionManagerProtocol *protocol;
1932 GtkWidget *radiobutton_register;
1933 GtkWidget *vbox = self->ui_details->widget;
1935 if (!priv->creating_account)
1938 protocol = empathy_account_settings_get_tp_protocol (priv->settings);
1939 if (protocol == NULL)
1942 if (!tp_connection_manager_protocol_can_register (protocol))
1945 if (account_widget_get_service (self) != NO_SERVICE)
1951 priv->radiobutton_reuse = gtk_radio_button_new_with_label (NULL,
1952 _("This account already exists on the server"));
1953 radiobutton_register = gtk_radio_button_new_with_label (
1954 gtk_radio_button_get_group (GTK_RADIO_BUTTON (priv->radiobutton_reuse)),
1955 _("Create a new account on the server"));
1957 gtk_box_pack_start (GTK_BOX (vbox), priv->radiobutton_reuse, FALSE, FALSE, 0);
1958 gtk_box_pack_start (GTK_BOX (vbox), radiobutton_register, FALSE, FALSE, 0);
1959 gtk_box_reorder_child (GTK_BOX (vbox), priv->radiobutton_reuse, 0);
1960 gtk_box_reorder_child (GTK_BOX (vbox), radiobutton_register, 1);
1961 gtk_widget_show (priv->radiobutton_reuse);
1962 gtk_widget_show (radiobutton_register);
1964 #endif /* HAVE_MEEGO */
1967 remember_password_toggled_cb (GtkToggleButton *button,
1968 EmpathyAccountWidget *self)
1970 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1972 if (gtk_toggle_button_get_active (button))
1974 gtk_widget_set_sensitive (priv->param_password_widget, TRUE);
1978 gtk_widget_set_sensitive (priv->param_password_widget, FALSE);
1979 gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), "");
1980 empathy_account_settings_unset (priv->settings, "password");
1985 account_settings_password_retrieved_cb (GObject *object,
1988 EmpathyAccountWidget *self = user_data;
1989 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1990 const gchar *password = empathy_account_settings_get_string (
1991 priv->settings, "password");
1993 if (password != NULL)
1995 /* We have to do this so that when we call gtk_entry_set_text,
1996 * the ::changed callback doesn't think the user made the
1998 priv->automatic_change = TRUE;
1999 gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), password);
2000 priv->automatic_change = FALSE;
2003 gtk_toggle_button_set_active (
2004 GTK_TOGGLE_BUTTON (priv->remember_password_widget),
2005 !EMP_STR_EMPTY (password));
2009 do_constructed (GObject *obj)
2011 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2012 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2014 TpStorageRestrictionFlags storage_restrictions;
2015 const gchar *display_name, *default_display_name;
2018 const gchar *cm_name;
2019 const gchar *protocol;
2021 void (*func)(EmpathyAccountWidget *self, const gchar *filename);
2023 { "salut", "local-xmpp", "empathy-account-widget-local-xmpp.ui",
2024 account_widget_build_salut },
2025 WIDGET (gabble, jabber),
2026 WIDGET (butterfly, msn),
2029 WIDGET (haze, yahoo),
2030 WIDGET (haze, groupwise),
2032 WIDGET (sofiasip, sip),
2035 account = empathy_account_settings_get_account (priv->settings);
2037 if (account != NULL)
2038 storage_restrictions = tp_account_get_storage_restrictions (account);
2040 storage_restrictions = 0;
2042 /* Empathy can only edit accounts without the Cannot_Set_Parameters flag */
2043 if (storage_restrictions & TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS)
2045 DEBUG ("Account is provided by an external storage provider");
2047 account_widget_build_external (self, priv->settings);
2051 const gchar *protocol, *cm_name;
2053 cm_name = empathy_account_settings_get_cm (priv->settings);
2054 protocol = empathy_account_settings_get_protocol (priv->settings);
2056 for (i = 0 ; i < G_N_ELEMENTS (widgets); i++)
2058 if (!tp_strdiff (widgets[i].cm_name, cm_name) &&
2059 !tp_strdiff (widgets[i].protocol, protocol))
2063 filename = empathy_file_lookup (widgets[i].file,
2065 widgets[i].func (self, filename);
2072 if (i == G_N_ELEMENTS (widgets))
2074 gchar *filename = empathy_file_lookup (
2075 "empathy-account-widget-generic.ui", "libempathy-gtk");
2076 account_widget_build_generic (self, filename);
2081 /* handle default focus */
2082 if (self->ui_details->default_focus != NULL)
2084 GObject *default_focus_entry;
2086 default_focus_entry = gtk_builder_get_object
2087 (self->ui_details->gui, self->ui_details->default_focus);
2088 g_signal_connect (default_focus_entry, "realize",
2089 G_CALLBACK (gtk_widget_grab_focus),
2093 /* remember password */
2094 if (priv->param_password_widget != NULL
2095 && priv->remember_password_widget != NULL
2096 && empathy_account_settings_supports_sasl (priv->settings))
2100 gtk_toggle_button_set_active (
2101 GTK_TOGGLE_BUTTON (priv->remember_password_widget), TRUE);
2105 gtk_toggle_button_set_active (
2106 GTK_TOGGLE_BUTTON (priv->remember_password_widget),
2107 !EMP_STR_EMPTY (empathy_account_settings_get_string (
2108 priv->settings, "password")));
2110 /* The password might not have been retrieved from the
2111 * keyring yet. We should update the remember password
2112 * toggle button and the password entry when/if it is. */
2113 tp_g_signal_connect_object (priv->settings, "password-retrieved",
2114 G_CALLBACK (account_settings_password_retrieved_cb), self, 0);
2117 g_signal_connect (priv->remember_password_widget, "toggled",
2118 G_CALLBACK (remember_password_toggled_cb), self);
2120 remember_password_toggled_cb (
2121 GTK_TOGGLE_BUTTON (priv->remember_password_widget), self);
2123 else if (priv->remember_password_widget != NULL
2124 && !empathy_account_settings_supports_sasl (priv->settings))
2126 gtk_widget_set_visible (priv->remember_password_widget, FALSE);
2129 /* dup and init the account-manager */
2130 priv->account_manager = tp_account_manager_dup ();
2132 g_object_ref (self);
2133 tp_account_manager_prepare_async (priv->account_manager, NULL,
2134 account_manager_ready_cb, self);
2136 /* handle apply and cancel button */
2137 if (!priv->simple &&
2138 !(storage_restrictions &
2139 TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS))
2141 GtkWidget *hbox = gtk_hbox_new (TRUE, 3);
2144 /* We can't use the stock button as its accelerator ('C') clashes with
2145 * the Close button. */
2146 priv->cancel_button = gtk_button_new ();
2147 gtk_button_set_label (GTK_BUTTON (priv->cancel_button), _("Ca_ncel"));
2148 gtk_button_set_use_underline (GTK_BUTTON (priv->cancel_button), TRUE);
2150 image = gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON);
2151 gtk_button_set_image (GTK_BUTTON (priv->cancel_button), image);
2153 priv->apply_button = gtk_button_new ();
2154 set_apply_button (self);
2156 /* We'll change this button to a "Log in" one if we are creating a new
2157 * account and are connected. */
2158 tp_g_signal_connect_object (priv->account_manager,
2159 "most-available-presence-changed",
2160 G_CALLBACK (presence_changed_cb), obj, 0);
2162 gtk_box_pack_end (GTK_BOX (hbox), priv->apply_button, TRUE,
2164 gtk_box_pack_end (GTK_BOX (hbox), priv->cancel_button, TRUE,
2167 gtk_box_pack_end (GTK_BOX (self->ui_details->widget), hbox, FALSE,
2170 g_signal_connect (priv->cancel_button, "clicked",
2171 G_CALLBACK (account_widget_cancel_clicked_cb),
2173 g_signal_connect (priv->apply_button, "clicked",
2174 G_CALLBACK (account_widget_apply_clicked_cb),
2176 gtk_widget_show_all (hbox);
2178 if (priv->creating_account)
2179 /* When creating an account, the user might have nothing to enter.
2180 * That means that no control interaction might occur,
2181 * so we update the control button sensitivity manually.
2183 account_widget_handle_control_buttons_sensitivity (self);
2185 account_widget_set_control_buttons_sensitivity (self, FALSE);
2189 add_register_buttons (self, account);
2190 #endif /* HAVE_MEEGO */
2192 /* hook up to widget destruction to unref ourselves */
2193 g_signal_connect (self->ui_details->widget, "destroy",
2194 G_CALLBACK (account_widget_destroy_cb), self);
2196 if (self->ui_details->gui != NULL)
2198 empathy_builder_unref_and_keep_widget (self->ui_details->gui,
2199 self->ui_details->widget);
2200 self->ui_details->gui = NULL;
2203 display_name = empathy_account_settings_get_display_name (priv->settings);
2204 default_display_name = empathy_account_widget_get_default_display_name (self);
2206 if (tp_strdiff (display_name, default_display_name) &&
2207 !priv->creating_account)
2209 /* The display name of the account is not the one that we'd assign by
2210 * default; assume that the user changed it manually */
2211 g_object_set (priv->settings, "display-name-overridden", TRUE, NULL);
2216 do_dispose (GObject *obj)
2218 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2219 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2221 if (priv->dispose_run)
2224 priv->dispose_run = TRUE;
2226 if (priv->settings != NULL)
2228 g_object_unref (priv->settings);
2229 priv->settings = NULL;
2232 if (priv->account_manager != NULL)
2234 g_object_unref (priv->account_manager);
2235 priv->account_manager = NULL;
2238 if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose != NULL)
2239 G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose (obj);
2243 do_finalize (GObject *obj)
2245 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
2246 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2248 g_free (self->ui_details->default_focus);
2249 g_slice_free (EmpathyAccountWidgetUIDetails, self->ui_details);
2251 g_free (priv->jid_suffix);
2253 if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize != NULL)
2254 G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize (obj);
2258 empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
2260 GObjectClass *oclass = G_OBJECT_CLASS (klass);
2261 GParamSpec *param_spec;
2263 oclass->get_property = do_get_property;
2264 oclass->set_property = do_set_property;
2265 oclass->constructed = do_constructed;
2266 oclass->dispose = do_dispose;
2267 oclass->finalize = do_finalize;
2269 param_spec = g_param_spec_string ("protocol",
2270 "protocol", "The protocol of the account",
2272 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
2273 g_object_class_install_property (oclass, PROP_PROTOCOL, param_spec);
2275 param_spec = g_param_spec_object ("settings",
2276 "settings", "The settings of the account",
2277 EMPATHY_TYPE_ACCOUNT_SETTINGS,
2278 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2279 g_object_class_install_property (oclass, PROP_SETTINGS, param_spec);
2281 param_spec = g_param_spec_boolean ("simple",
2282 "simple", "Whether the account widget is a simple or an advanced one",
2284 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2285 g_object_class_install_property (oclass, PROP_SIMPLE, param_spec);
2287 param_spec = g_param_spec_boolean ("creating-account",
2289 "TRUE if we're creating an account, FALSE if we're modifying it",
2291 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2292 g_object_class_install_property (oclass, PROP_CREATING_ACCOUNT, param_spec);
2294 param_spec = g_param_spec_boolean ("other-accounts-exist",
2295 "other-accounts-exist",
2296 "TRUE if there are any other accounts (even if this isn't yet saved)",
2298 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
2299 g_object_class_install_property (oclass, PROP_OTHER_ACCOUNTS_EXIST,
2302 signals[HANDLE_APPLY] =
2303 g_signal_new ("handle-apply", G_TYPE_FROM_CLASS (klass),
2304 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2305 g_cclosure_marshal_VOID__BOOLEAN,
2309 /* This signal is emitted when an account has been created and enabled. */
2310 signals[ACCOUNT_CREATED] =
2311 g_signal_new ("account-created", G_TYPE_FROM_CLASS (klass),
2312 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2313 g_cclosure_marshal_VOID__OBJECT,
2317 signals[CANCELLED] =
2318 g_signal_new ("cancelled", G_TYPE_FROM_CLASS (klass),
2319 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
2320 g_cclosure_marshal_VOID__VOID,
2324 g_type_class_add_private (klass, sizeof (EmpathyAccountWidgetPriv));
2328 empathy_account_widget_init (EmpathyAccountWidget *self)
2330 EmpathyAccountWidgetPriv *priv =
2331 G_TYPE_INSTANCE_GET_PRIVATE ((self), EMPATHY_TYPE_ACCOUNT_WIDGET,
2332 EmpathyAccountWidgetPriv);
2335 priv->dispose_run = FALSE;
2337 self->ui_details = g_slice_new0 (EmpathyAccountWidgetUIDetails);
2340 /* public methods */
2343 empathy_account_widget_discard_pending_changes
2344 (EmpathyAccountWidget *widget)
2346 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
2348 empathy_account_settings_discard_changes (priv->settings);
2349 priv->contains_pending_changes = FALSE;
2353 empathy_account_widget_contains_pending_changes (EmpathyAccountWidget *widget)
2355 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
2357 return priv->contains_pending_changes;
2361 empathy_account_widget_handle_params (EmpathyAccountWidget *self,
2362 const gchar *first_widget,
2367 va_start (args, first_widget);
2368 account_widget_handle_params_valist (self, first_widget, args);
2373 empathy_account_widget_get_widget (EmpathyAccountWidget *widget)
2375 return widget->ui_details->widget;
2378 EmpathyAccountWidget *
2379 empathy_account_widget_new_for_protocol (EmpathyAccountSettings *settings,
2382 EmpathyAccountWidget *self;
2384 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), NULL);
2387 (EMPATHY_TYPE_ACCOUNT_WIDGET,
2388 "settings", settings, "simple", simple,
2390 empathy_account_settings_get_account (settings) == NULL,
2397 empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
2399 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2400 const gchar *login_id;
2401 const gchar *protocol, *p;
2402 gchar *default_display_name;
2405 login_id = empathy_account_settings_get_string (priv->settings, "account");
2406 protocol = empathy_account_settings_get_protocol (priv->settings);
2407 service = account_widget_get_service (self);
2409 if (login_id != NULL)
2411 /* TODO: this should be done in empathy-account-widget-irc */
2412 if (!tp_strdiff (protocol, "irc"))
2414 EmpathyIrcNetwork *network;
2416 network = empathy_irc_network_chooser_get_network (
2417 priv->irc_network_chooser);
2418 g_assert (network != NULL);
2420 /* To translators: The first parameter is the login id and the
2421 * second one is the network. The resulting string will be something
2422 * like: "MyUserName on freenode".
2423 * You should reverse the order of these arguments if the
2424 * server should come before the login id in your locale.*/
2425 default_display_name = g_strdup_printf (_("%1$s on %2$s"),
2426 login_id, empathy_irc_network_get_name (network));
2428 else if (service == FACEBOOK_SERVICE)
2432 tmp = remove_jid_suffix (self, login_id);
2433 default_display_name = g_strdup_printf ("Facebook (%s)", tmp);
2438 default_display_name = g_strdup (login_id);
2441 return default_display_name;
2444 if ((p = empathy_protocol_name_to_display_name (protocol)) != NULL)
2447 if (protocol != NULL)
2449 /* To translators: The parameter is the protocol name. The resulting
2450 * string will be something like: "Jabber Account" */
2451 default_display_name = g_strdup_printf (_("%s Account"), protocol);
2455 default_display_name = g_strdup (_("New account"));
2458 return default_display_name;
2461 /* Used by subclass to indicate that widget contains pending changes */
2463 empathy_account_widget_changed (EmpathyAccountWidget *self)
2465 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2467 account_widget_handle_control_buttons_sensitivity (self);
2468 priv->contains_pending_changes = TRUE;
2472 empathy_account_widget_set_account_param (EmpathyAccountWidget *self,
2473 const gchar *account)
2475 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2477 if (priv->param_account_widget == NULL)
2480 gtk_entry_set_text (GTK_ENTRY (priv->param_account_widget), account);
2484 empathy_account_widget_set_password_param (EmpathyAccountWidget *self,
2485 const gchar *account)
2487 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
2489 if (priv->param_password_widget == NULL)
2492 gtk_entry_set_text (GTK_ENTRY (priv->param_password_widget), account);