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>
34 #include <nbtk/nbtk-gtk.h>
37 #include <libempathy/empathy-utils.h>
39 #include <telepathy-glib/account.h>
40 #include <telepathy-glib/account-manager.h>
41 #include <telepathy-glib/connection-manager.h>
42 #include <telepathy-glib/util.h>
43 #include <dbus/dbus-protocol.h>
45 #include "empathy-account-widget.h"
46 #include "empathy-account-widget-private.h"
47 #include "empathy-account-widget-sip.h"
48 #include "empathy-account-widget-irc.h"
49 #include "empathy-ui-utils.h"
51 #define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
52 #include <libempathy/empathy-debug.h>
54 G_DEFINE_TYPE (EmpathyAccountWidget, empathy_account_widget, G_TYPE_OBJECT)
57 EmpathyAccountSettings *settings;
59 GtkWidget *table_common_settings;
60 GtkWidget *apply_button;
61 GtkWidget *cancel_button;
62 GtkWidget *entry_password;
63 GtkWidget *button_forget;
64 GtkWidget *spinbutton_port;
65 GtkWidget *enabled_checkbox;
69 gboolean contains_pending_changes;
71 /* An EmpathyAccountWidget can be used to either create an account or
72 * modify it. When we are creating an account, this member is set to TRUE */
73 gboolean creating_account;
74 /* If we are creating a new account, this member is set to TRUE once the
75 * account has been created */
76 gboolean account_created;
78 TpAccountManager *account_manager;
81 } EmpathyAccountWidgetPriv;
97 static guint signals[LAST_SIGNAL] = { 0 };
99 #define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyAccountWidget)
100 #define CHANGED_TIMEOUT 300
103 account_widget_set_control_buttons_sensitivity (EmpathyAccountWidget *self,
106 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
110 gtk_widget_set_sensitive (priv->apply_button, sensitive);
111 gtk_widget_set_sensitive (
112 priv->cancel_button, sensitive || priv->creating_account);
114 priv->contains_pending_changes = sensitive;
119 account_widget_handle_control_buttons_sensitivity (EmpathyAccountWidget *self)
121 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
124 is_valid = empathy_account_settings_is_valid (priv->settings);
127 account_widget_set_control_buttons_sensitivity (self, is_valid);
129 g_signal_emit (self, signals[HANDLE_APPLY], 0, is_valid);
133 account_widget_entry_changed_common (EmpathyAccountWidget *self,
134 GtkEntry *entry, gboolean focus)
137 const gchar *param_name;
138 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
140 str = gtk_entry_get_text (entry);
141 param_name = g_object_get_data (G_OBJECT (entry), "param_name");
143 if (EMP_STR_EMPTY (str))
145 const gchar *value = NULL;
147 empathy_account_settings_unset (priv->settings, param_name);
151 value = empathy_account_settings_get_string (priv->settings,
153 DEBUG ("Unset %s and restore to %s", param_name, value);
154 gtk_entry_set_text (entry, value ? value : "");
159 DEBUG ("Setting %s to %s", param_name,
160 tp_strdiff (param_name, "password") ? str : "***");
161 empathy_account_settings_set_string (priv->settings, param_name, str);
166 account_widget_entry_changed_cb (GtkEditable *entry,
167 EmpathyAccountWidget *self)
169 account_widget_entry_changed_common (self, GTK_ENTRY (entry), FALSE);
170 account_widget_handle_control_buttons_sensitivity (self);
174 account_widget_int_changed_cb (GtkWidget *widget,
175 EmpathyAccountWidget *self)
177 const gchar *param_name;
179 const gchar *signature;
180 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
182 value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (widget));
183 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
185 signature = empathy_account_settings_get_dbus_signature (priv->settings,
187 g_return_if_fail (signature != NULL);
189 DEBUG ("Setting %s to %d", param_name, value);
191 switch ((int)*signature)
193 case DBUS_TYPE_INT16:
194 case DBUS_TYPE_INT32:
195 empathy_account_settings_set_int32 (priv->settings, param_name, value);
197 case DBUS_TYPE_INT64:
198 empathy_account_settings_set_int64 (priv->settings, param_name, value);
200 case DBUS_TYPE_UINT16:
201 case DBUS_TYPE_UINT32:
202 empathy_account_settings_set_uint32 (priv->settings, param_name, value);
204 case DBUS_TYPE_UINT64:
205 empathy_account_settings_set_uint64 (priv->settings, param_name, value);
208 g_return_if_reached ();
211 account_widget_handle_control_buttons_sensitivity (self);
215 account_widget_checkbutton_toggled_cb (GtkWidget *widget,
216 EmpathyAccountWidget *self)
219 gboolean default_value;
220 const gchar *param_name;
221 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
223 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
224 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
226 /* FIXME: This is ugly! checkbox don't have a "not-set" value so we
227 * always unset the param and set the value if different from the
229 empathy_account_settings_unset (priv->settings, param_name);
230 default_value = empathy_account_settings_get_boolean (priv->settings,
233 if (default_value == value)
235 DEBUG ("Unset %s and restore to %d", param_name, default_value);
239 DEBUG ("Setting %s to %d", param_name, value);
240 empathy_account_settings_set_boolean (priv->settings, param_name, value);
243 account_widget_handle_control_buttons_sensitivity (self);
247 account_widget_forget_clicked_cb (GtkWidget *button,
248 EmpathyAccountWidget *self)
250 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
251 const gchar *param_name;
253 param_name = g_object_get_data (G_OBJECT (priv->entry_password),
256 DEBUG ("Unset %s", param_name);
257 empathy_account_settings_unset (priv->settings, param_name);
258 gtk_entry_set_text (GTK_ENTRY (priv->entry_password), "");
260 account_widget_handle_control_buttons_sensitivity (self);
264 account_widget_password_changed_cb (GtkWidget *entry,
265 EmpathyAccountWidget *self)
267 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
270 str = gtk_entry_get_text (GTK_ENTRY (entry));
271 gtk_widget_set_sensitive (priv->button_forget, !EMP_STR_EMPTY (str));
275 account_widget_jabber_ssl_toggled_cb (GtkWidget *checkbutton_ssl,
276 EmpathyAccountWidget *self)
278 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
282 value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkbutton_ssl));
283 port = empathy_account_settings_get_uint32 (priv->settings, "port");
287 if (port == 5222 || port == 0)
292 if (port == 5223 || port == 0)
296 gtk_spin_button_set_value (GTK_SPIN_BUTTON (priv->spinbutton_port), port);
300 account_widget_combobox_changed_cb (GtkWidget *widget,
301 EmpathyAccountWidget *self)
307 const gchar *default_value;
308 const gchar *param_name;
309 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
311 if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
314 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
315 /* the param value is stored in the first column */
316 gtk_tree_model_get (model, &iter, 0, &value, -1);
318 param_name = g_object_get_data (G_OBJECT (widget), "param_name");
320 v = empathy_account_settings_get_default (priv->settings, param_name);
321 default_value = g_value_get_string (v);
323 if (!tp_strdiff (value, default_value))
325 DEBUG ("Unset %s and restore to %s", param_name, default_value);
326 empathy_account_settings_unset (priv->settings, param_name);
330 DEBUG ("Setting %s to %s", param_name, value);
331 empathy_account_settings_set_string (priv->settings, param_name, value);
334 account_widget_handle_control_buttons_sensitivity (self);
338 account_widget_setup_widget (EmpathyAccountWidget *self,
340 const gchar *param_name)
342 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
344 g_object_set_data_full (G_OBJECT (widget), "param_name",
345 g_strdup (param_name), g_free);
347 if (GTK_IS_SPIN_BUTTON (widget))
350 const gchar *signature;
352 signature = empathy_account_settings_get_dbus_signature (priv->settings,
354 g_return_if_fail (signature != NULL);
356 switch ((int)*signature)
358 case DBUS_TYPE_INT16:
359 case DBUS_TYPE_INT32:
360 value = empathy_account_settings_get_int32 (priv->settings,
363 case DBUS_TYPE_INT64:
364 value = empathy_account_settings_get_int64 (priv->settings,
367 case DBUS_TYPE_UINT16:
368 case DBUS_TYPE_UINT32:
369 value = empathy_account_settings_get_uint32 (priv->settings,
372 case DBUS_TYPE_UINT64:
373 value = empathy_account_settings_get_uint64 (priv->settings,
377 g_return_if_reached ();
380 gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
382 g_signal_connect (widget, "value-changed",
383 G_CALLBACK (account_widget_int_changed_cb),
386 else if (GTK_IS_ENTRY (widget))
388 const gchar *str = NULL;
390 str = empathy_account_settings_get_string (priv->settings, param_name);
391 gtk_entry_set_text (GTK_ENTRY (widget), str ? str : "");
393 if (strstr (param_name, "password"))
395 gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE);
398 g_signal_connect (widget, "changed",
399 G_CALLBACK (account_widget_entry_changed_cb), self);
401 else if (GTK_IS_TOGGLE_BUTTON (widget))
403 gboolean value = FALSE;
405 value = empathy_account_settings_get_boolean (priv->settings,
407 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
409 g_signal_connect (widget, "toggled",
410 G_CALLBACK (account_widget_checkbutton_toggled_cb),
413 else if (GTK_IS_COMBO_BOX (widget))
415 /* The combo box's model has to contain the param value in its first
416 * column (as a string) */
422 str = empathy_account_settings_get_string (priv->settings, param_name);
423 model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
425 valid = gtk_tree_model_get_iter_first (model, &iter);
430 gtk_tree_model_get (model, &iter, 0, &name, -1);
431 if (!tp_strdiff (name, str))
433 gtk_combo_box_set_active_iter (GTK_COMBO_BOX (widget), &iter);
438 valid = gtk_tree_model_iter_next (model, &iter);
444 g_signal_connect (widget, "changed",
445 G_CALLBACK (account_widget_combobox_changed_cb),
450 DEBUG ("Unknown type of widget for param %s", param_name);
455 account_widget_generic_format_param_name (const gchar *param_name)
460 str = g_strdup (param_name);
462 if (str && g_ascii_isalpha (str[0]))
463 str[0] = g_ascii_toupper (str[0]);
465 while ((p = strchr (str, '-')) != NULL)
467 if (p[1] != '\0' && g_ascii_isalpha (p[1]))
470 p[1] = g_ascii_toupper (p[1]);
480 accounts_widget_generic_setup (EmpathyAccountWidget *self,
481 GtkWidget *table_common_settings,
482 GtkWidget *table_advanced_settings)
484 TpConnectionManagerParam *params, *param;
485 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
487 params = empathy_account_settings_get_tp_params (priv->settings);
489 for (param = params; param != NULL && param->name != NULL; param++)
491 GtkWidget *table_settings;
493 GtkWidget *widget = NULL;
494 gchar *param_name_formatted;
496 if (param->flags & TP_CONN_MGR_PARAM_FLAG_REQUIRED)
497 table_settings = table_common_settings;
498 else if (priv->simple)
501 table_settings = table_advanced_settings;
503 param_name_formatted = account_widget_generic_format_param_name
505 g_object_get (table_settings, "n-rows", &n_rows, NULL);
506 gtk_table_resize (GTK_TABLE (table_settings), ++n_rows, 2);
508 if (param->dbus_signature[0] == 's')
512 str = g_strdup_printf (_("%s:"), param_name_formatted);
513 widget = gtk_label_new (str);
514 gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
517 gtk_table_attach (GTK_TABLE (table_settings),
523 gtk_widget_show (widget);
525 widget = gtk_entry_new ();
526 if (strcmp (param->name, "account") == 0)
528 g_signal_connect (widget, "realize",
529 G_CALLBACK (gtk_widget_grab_focus),
532 gtk_table_attach (GTK_TABLE (table_settings),
536 GTK_FILL | GTK_EXPAND, 0,
538 gtk_widget_show (widget);
540 /* int types: ynqiuxt. double type is 'd' */
541 else if (param->dbus_signature[0] == 'y' ||
542 param->dbus_signature[0] == 'n' ||
543 param->dbus_signature[0] == 'q' ||
544 param->dbus_signature[0] == 'i' ||
545 param->dbus_signature[0] == 'u' ||
546 param->dbus_signature[0] == 'x' ||
547 param->dbus_signature[0] == 't' ||
548 param->dbus_signature[0] == 'd')
555 switch (param->dbus_signature[0])
557 case 'y': minint = G_MININT8; maxint = G_MAXINT8; break;
558 case 'n': minint = G_MININT16; maxint = G_MAXINT16; break;
559 case 'q': minint = 0; maxint = G_MAXUINT16; break;
560 case 'i': minint = G_MININT32; maxint = G_MAXINT32; break;
561 case 'u': minint = 0; maxint = G_MAXUINT32; break;
562 case 'x': minint = G_MININT64; maxint = G_MAXINT64; break;
563 case 't': minint = 0; maxint = G_MAXUINT64; break;
564 case 'd': minint = G_MININT32; maxint = G_MAXINT32;
568 str = g_strdup_printf (_("%s:"), param_name_formatted);
569 widget = gtk_label_new (str);
570 gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5);
573 gtk_table_attach (GTK_TABLE (table_settings),
579 gtk_widget_show (widget);
581 widget = gtk_spin_button_new_with_range (minint, maxint, step);
582 gtk_table_attach (GTK_TABLE (table_settings),
586 GTK_FILL | GTK_EXPAND, 0,
588 gtk_widget_show (widget);
590 else if (param->dbus_signature[0] == 'b')
592 widget = gtk_check_button_new_with_label (param_name_formatted);
593 gtk_table_attach (GTK_TABLE (table_settings),
597 GTK_FILL | GTK_EXPAND, 0,
599 gtk_widget_show (widget);
603 DEBUG ("Unknown signature for param %s: %s",
604 param_name_formatted, param->dbus_signature);
608 account_widget_setup_widget (self, widget, param->name);
610 g_free (param_name_formatted);
615 account_widget_handle_params_valist (EmpathyAccountWidget *self,
616 const gchar *first_widget,
622 for (name = first_widget; name; name = va_arg (args, const gchar *))
624 const gchar *param_name;
626 param_name = va_arg (args, const gchar *);
627 object = gtk_builder_get_object (self->ui_details->gui, name);
631 g_warning ("Builder is missing object '%s'.", name);
635 account_widget_setup_widget (self, GTK_WIDGET (object), param_name);
640 account_widget_cancel_clicked_cb (GtkWidget *button,
641 EmpathyAccountWidget *self)
643 g_signal_emit (self, signals[CANCELLED], 0);
647 account_widget_account_enabled_cb (GObject *source_object,
651 GError *error = NULL;
652 TpAccount *account = TP_ACCOUNT (source_object);
653 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
654 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
656 tp_account_set_enabled_finish (account, res, &error);
660 DEBUG ("Could not automatically enable new account: %s", error->message);
661 g_error_free (error);
665 priv->account_created = TRUE;
666 g_signal_emit (widget, signals[ACCOUNT_CREATED], 0);
671 account_widget_applied_cb (GObject *source_object,
675 GError *error = NULL;
677 EmpathyAccountSettings *settings = EMPATHY_ACCOUNT_SETTINGS (source_object);
678 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
679 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
681 empathy_account_settings_apply_finish (settings, res, &error);
685 DEBUG ("Could not apply changes to account: %s", error->message);
686 g_error_free (error);
690 account = empathy_account_settings_get_account (priv->settings);
694 if (priv->creating_account)
696 /* By default, when an account is created, we enable it. */
697 tp_account_set_enabled_async (account, TRUE,
698 account_widget_account_enabled_cb, widget);
700 else if (priv->enabled_checkbox != NULL)
702 gboolean enabled_checked;
706 gtk_toggle_button_get_active (
707 GTK_TOGGLE_BUTTON (priv->enabled_checkbox));
709 nbtk_gtk_light_switch_get_active (
710 NBTK_GTK_LIGHT_SWITCH (priv->enabled_checkbox));
713 if (tp_account_is_enabled (account) && enabled_checked)
715 /* After having applied changes to a user account, we
716 * automatically reconnect it. This is done so the new
717 * information entered by the user is validated on the server. */
718 tp_account_reconnect_async (account, NULL, NULL);
723 account_widget_set_control_buttons_sensitivity (widget, FALSE);
727 account_widget_apply_clicked_cb (GtkWidget *button,
728 EmpathyAccountWidget *self)
730 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
732 empathy_account_settings_apply_async (priv->settings,
733 account_widget_applied_cb, self);
737 account_widget_setup_generic (EmpathyAccountWidget *self)
739 GtkWidget *table_common_settings;
740 GtkWidget *table_advanced_settings;
742 table_common_settings = GTK_WIDGET (gtk_builder_get_object
743 (self->ui_details->gui, "table_common_settings"));
744 table_advanced_settings = GTK_WIDGET (gtk_builder_get_object
745 (self->ui_details->gui, "table_advanced_settings"));
747 accounts_widget_generic_setup (self, table_common_settings,
748 table_advanced_settings);
750 g_object_unref (self->ui_details->gui);
754 account_widget_settings_ready_cb (EmpathyAccountSettings *settings,
758 EmpathyAccountWidget *self = user_data;
759 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
761 if (empathy_account_settings_is_ready (priv->settings))
762 account_widget_setup_generic (self);
766 account_widget_build_generic (EmpathyAccountWidget *self,
767 const char *filename)
769 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
770 GtkWidget *expander_advanced;
772 self->ui_details->gui = empathy_builder_get_file (filename,
773 "table_common_settings", &priv->table_common_settings,
774 "vbox_generic_settings", &self->ui_details->widget,
775 "expander_advanced_settings", &expander_advanced,
779 gtk_widget_hide (expander_advanced);
781 g_object_ref (self->ui_details->gui);
783 if (empathy_account_settings_is_ready (priv->settings))
784 account_widget_setup_generic (self);
786 g_signal_connect (priv->settings, "notify::ready",
787 G_CALLBACK (account_widget_settings_ready_cb), self);
791 account_widget_build_salut (EmpathyAccountWidget *self,
792 const char *filename)
794 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
796 self->ui_details->gui = empathy_builder_get_file (filename,
797 "table_common_settings", &priv->table_common_settings,
798 "vbox_salut_settings", &self->ui_details->widget,
801 empathy_account_widget_handle_params (self,
802 "entry_published", "published-name",
803 "entry_nickname", "nickname",
804 "entry_first_name", "first-name",
805 "entry_last_name", "last-name",
806 "entry_email", "email",
810 self->ui_details->default_focus = g_strdup ("entry_first_name");
814 account_widget_build_irc (EmpathyAccountWidget *self,
815 const char *filename)
817 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
818 empathy_account_widget_irc_build (self, filename,
819 &priv->table_common_settings);
823 account_widget_build_sip (EmpathyAccountWidget *self,
824 const char *filename)
826 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
827 empathy_account_widget_sip_build (self, filename,
828 &priv->table_common_settings);
832 account_widget_build_msn (EmpathyAccountWidget *self,
833 const char *filename)
835 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
839 self->ui_details->gui = empathy_builder_get_file (filename,
840 "vbox_msn_simple", &self->ui_details->widget,
843 empathy_account_widget_handle_params (self,
844 "entry_id_simple", "account",
845 "entry_password_simple", "password",
848 self->ui_details->default_focus = g_strdup ("entry_id_simple");
852 self->ui_details->gui = empathy_builder_get_file (filename,
853 "table_common_msn_settings", &priv->table_common_settings,
854 "vbox_msn_settings", &self->ui_details->widget,
857 empathy_account_widget_handle_params (self,
858 "entry_id", "account",
859 "entry_password", "password",
860 "entry_server", "server",
861 "spinbutton_port", "port",
864 self->ui_details->default_focus = g_strdup ("entry_id");
865 self->ui_details->add_forget = TRUE;
870 account_widget_build_jabber (EmpathyAccountWidget *self,
871 const char *filename)
873 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
874 GtkWidget *spinbutton_port;
875 GtkWidget *checkbutton_ssl;
876 GtkWidget *label_id, *label_password;
877 GtkWidget *label_id_create, *label_password_create;
878 GtkWidget *label_example_gtalk, *label_example_jabber;
881 is_gtalk = !tp_strdiff (
882 empathy_account_settings_get_icon_name (priv->settings),
885 if (priv->simple && !is_gtalk)
887 self->ui_details->gui = empathy_builder_get_file (filename,
888 "vbox_jabber_simple", &self->ui_details->widget,
889 "label_id_simple", &label_id,
890 "label_id_create", &label_id_create,
891 "label_password_simple", &label_password,
892 "label_password_create", &label_password_create,
895 if (empathy_account_settings_get_boolean (priv->settings, "register"))
897 gtk_widget_hide (label_id);
898 gtk_widget_hide (label_password);
899 gtk_widget_show (label_id_create);
900 gtk_widget_show (label_password_create);
903 empathy_account_widget_handle_params (self,
904 "entry_id_simple", "account",
905 "entry_password_simple", "password",
908 self->ui_details->default_focus = g_strdup ("entry_id_simple");
910 else if (priv->simple && is_gtalk)
912 self->ui_details->gui = empathy_builder_get_file (filename,
913 "vbox_gtalk_simple", &self->ui_details->widget,
916 empathy_account_widget_handle_params (self,
917 "entry_id_g_simple", "account",
918 "entry_password_g_simple", "password",
921 self->ui_details->default_focus = g_strdup ("entry_id_g_simple");
925 self->ui_details->gui = empathy_builder_get_file (filename,
926 "table_common_settings", &priv->table_common_settings,
927 "vbox_jabber_settings", &self->ui_details->widget,
928 "spinbutton_port", &spinbutton_port,
929 "checkbutton_ssl", &checkbutton_ssl,
930 "label_username_example", &label_example_jabber,
931 "label_username_g_example", &label_example_gtalk,
934 empathy_account_widget_handle_params (self,
935 "entry_id", "account",
936 "entry_password", "password",
937 "entry_resource", "resource",
938 "entry_server", "server",
939 "spinbutton_port", "port",
940 "spinbutton_priority", "priority",
941 "checkbutton_ssl", "old-ssl",
942 "checkbutton_ignore_ssl_errors", "ignore-ssl-errors",
943 "checkbutton_encryption", "require-encryption",
946 self->ui_details->default_focus = g_strdup ("entry_id");
947 self->ui_details->add_forget = TRUE;
948 priv->spinbutton_port = spinbutton_port;
950 g_signal_connect (checkbutton_ssl, "toggled",
951 G_CALLBACK (account_widget_jabber_ssl_toggled_cb),
956 gtk_widget_hide (label_example_jabber);
957 gtk_widget_show (label_example_gtalk);
963 account_widget_build_icq (EmpathyAccountWidget *self,
964 const char *filename)
966 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
967 GtkWidget *spinbutton_port;
971 self->ui_details->gui = empathy_builder_get_file (filename,
972 "vbox_icq_simple", &self->ui_details->widget,
975 empathy_account_widget_handle_params (self,
976 "entry_uin_simple", "account",
977 "entry_password_simple", "password",
980 self->ui_details->default_focus = g_strdup ("entry_uin_simple");
984 self->ui_details->gui = empathy_builder_get_file (filename,
985 "table_common_settings", &priv->table_common_settings,
986 "vbox_icq_settings", &self->ui_details->widget,
987 "spinbutton_port", &spinbutton_port,
990 empathy_account_widget_handle_params (self,
991 "entry_uin", "account",
992 "entry_password", "password",
993 "entry_server", "server",
994 "spinbutton_port", "port",
995 "entry_charset", "charset",
998 self->ui_details->default_focus = g_strdup ("entry_uin");
999 self->ui_details->add_forget = TRUE;
1004 account_widget_build_aim (EmpathyAccountWidget *self,
1005 const char *filename)
1007 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1008 GtkWidget *spinbutton_port;
1012 self->ui_details->gui = empathy_builder_get_file (filename,
1013 "vbox_aim_simple", &self->ui_details->widget,
1016 empathy_account_widget_handle_params (self,
1017 "entry_screenname_simple", "account",
1018 "entry_password_simple", "password",
1021 self->ui_details->default_focus = g_strdup ("entry_screenname_simple");
1025 self->ui_details->gui = empathy_builder_get_file (filename,
1026 "table_common_settings", &priv->table_common_settings,
1027 "vbox_aim_settings", &self->ui_details->widget,
1028 "spinbutton_port", &spinbutton_port,
1031 empathy_account_widget_handle_params (self,
1032 "entry_screenname", "account",
1033 "entry_password", "password",
1034 "entry_server", "server",
1035 "spinbutton_port", "port",
1038 self->ui_details->default_focus = g_strdup ("entry_screenname");
1039 self->ui_details->add_forget = TRUE;
1044 account_widget_build_yahoo (EmpathyAccountWidget *self,
1045 const char *filename)
1047 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1051 self->ui_details->gui = empathy_builder_get_file (filename,
1052 "vbox_yahoo_simple", &self->ui_details->widget,
1055 empathy_account_widget_handle_params (self,
1056 "entry_id_simple", "account",
1057 "entry_password_simple", "password",
1060 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1064 self->ui_details->gui = empathy_builder_get_file (filename,
1065 "table_common_settings", &priv->table_common_settings,
1066 "vbox_yahoo_settings", &self->ui_details->widget,
1069 empathy_account_widget_handle_params (self,
1070 "entry_id", "account",
1071 "entry_password", "password",
1072 "entry_server", "server",
1073 "entry_locale", "room-list-locale",
1074 "entry_charset", "charset",
1075 "spinbutton_port", "port",
1076 "checkbutton_yahoojp", "yahoojp",
1077 "checkbutton_ignore_invites", "ignore-invites",
1080 self->ui_details->default_focus = g_strdup ("entry_id");
1081 self->ui_details->add_forget = TRUE;
1086 account_widget_build_groupwise (EmpathyAccountWidget *self,
1087 const char *filename)
1089 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1093 self->ui_details->gui = empathy_builder_get_file (filename,
1094 "vbox_groupwise_simple", &self->ui_details->widget,
1097 empathy_account_widget_handle_params (self,
1098 "entry_id_simple", "account",
1099 "entry_password_simple", "password",
1102 self->ui_details->default_focus = g_strdup ("entry_id_simple");
1106 self->ui_details->gui = empathy_builder_get_file (filename,
1107 "table_common_groupwise_settings", &priv->table_common_settings,
1108 "vbox_groupwise_settings", &self->ui_details->widget,
1111 empathy_account_widget_handle_params (self,
1112 "entry_id", "account",
1113 "entry_password", "password",
1114 "entry_server", "server",
1115 "spinbutton_port", "port",
1118 self->ui_details->default_focus = g_strdup ("entry_id");
1119 self->ui_details->add_forget = TRUE;
1124 account_widget_destroy_cb (GtkWidget *widget,
1125 EmpathyAccountWidget *self)
1127 g_object_unref (self);
1131 empathy_account_widget_enabled_cb (TpAccount *account,
1135 EmpathyAccountWidget *widget = EMPATHY_ACCOUNT_WIDGET (user_data);
1136 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
1137 gboolean enabled = tp_account_is_enabled (account);
1139 if (priv->enabled_checkbox != NULL)
1142 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->enabled_checkbox),
1145 nbtk_gtk_light_switch_set_active (
1146 NBTK_GTK_LIGHT_SWITCH (priv->enabled_checkbox),
1148 #endif /* HAVE_MOBLIN */
1154 account_widget_enabled_released_cb (GtkToggleButton *toggle_button,
1157 account_widget_switch_flipped_cb (NbtkGtkLightSwitch *sw,
1160 #endif /* HAVE_MOBLIN */
1162 EmpathyAccountWidgetPriv *priv = GET_PRIV (user_data);
1167 state = gtk_toggle_button_get_active (toggle_button);
1170 account = empathy_account_settings_get_account (priv->settings);
1172 /* Enable the account according to the value of the "Enabled" checkbox */
1173 tp_account_set_enabled_async (account, state, NULL, NULL);
1177 do_set_property (GObject *object,
1179 const GValue *value,
1182 EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
1187 priv->settings = g_value_dup_object (value);
1190 priv->simple = g_value_get_boolean (value);
1192 case PROP_CREATING_ACCOUNT:
1193 priv->creating_account = g_value_get_boolean (value);
1196 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1201 do_get_property (GObject *object,
1206 EmpathyAccountWidgetPriv *priv = GET_PRIV (object);
1211 g_value_set_string (value,
1212 empathy_account_settings_get_protocol (priv->settings));
1215 g_value_set_object (value, priv->settings);
1218 g_value_set_boolean (value, priv->simple);
1220 case PROP_CREATING_ACCOUNT:
1221 g_value_set_boolean (value, priv->creating_account);
1224 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
1229 presence_changed_cb (TpAccountManager *manager,
1230 TpConnectionPresenceType state,
1231 const gchar *status,
1232 const gchar *message,
1233 EmpathyAccountWidget *self)
1235 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1237 if (state > TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
1239 /* We are online, display a Login button */
1242 gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), FALSE);
1243 gtk_button_set_label (GTK_BUTTON (priv->apply_button), _("L_og in"));
1245 image = gtk_image_new_from_stock (GTK_STOCK_CONNECT,
1246 GTK_ICON_SIZE_BUTTON);
1247 gtk_button_set_image (GTK_BUTTON (priv->apply_button), image);
1251 /* We are offline, display a Save button */
1252 gtk_button_set_image (GTK_BUTTON (priv->apply_button), NULL);
1253 gtk_button_set_use_stock (GTK_BUTTON (priv->apply_button), TRUE);
1254 gtk_button_set_label (GTK_BUTTON (priv->apply_button), GTK_STOCK_SAVE);
1259 account_manager_ready_cb (GObject *source_object,
1260 GAsyncResult *result,
1263 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (user_data);
1264 TpAccountManager *account_manager = TP_ACCOUNT_MANAGER (source_object);
1265 GError *error = NULL;
1266 TpConnectionPresenceType state;
1268 if (!tp_account_manager_prepare_finish (account_manager, result, &error))
1270 DEBUG ("Failed to prepare account manager: %s", error->message);
1271 g_error_free (error);
1275 state = tp_account_manager_get_most_available_presence (account_manager, NULL,
1278 /* simulate a presence change so the apply button will be changed
1280 presence_changed_cb (account_manager, state, NULL, NULL, self);
1283 #define WIDGET(cm, proto) \
1284 { #cm, #proto, "empathy-account-widget-"#proto".ui", \
1285 account_widget_build_##proto }
1288 do_constructed (GObject *obj)
1290 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
1291 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1293 const gchar *protocol, *cm_name;
1296 const gchar *cm_name;
1297 const gchar *protocol;
1299 void (*func)(EmpathyAccountWidget *self, const gchar *filename);
1301 { "salut", "local-xmpp", "empathy-account-widget-local-xmpp.ui",
1302 account_widget_build_salut },
1303 WIDGET (gabble, jabber),
1304 WIDGET (butterfly, msn),
1307 WIDGET (haze, yahoo),
1308 WIDGET (haze, groupwise),
1310 WIDGET (sofiasip, sip),
1313 cm_name = empathy_account_settings_get_cm (priv->settings);
1314 protocol = empathy_account_settings_get_protocol (priv->settings);
1316 for (i = 0 ; i < G_N_ELEMENTS (widgets); i++)
1318 if (!tp_strdiff (widgets[i].cm_name, cm_name) &&
1319 !tp_strdiff (widgets[i].protocol, protocol))
1323 filename = empathy_file_lookup (widgets[i].file,
1325 widgets[i].func (self, filename);
1332 if (i == G_N_ELEMENTS (widgets))
1334 gchar *filename = empathy_file_lookup (
1335 "empathy-account-widget-generic.ui", "libempathy-gtk");
1336 account_widget_build_generic (self, filename);
1340 /* handle default focus */
1341 if (self->ui_details->default_focus != NULL)
1343 GObject *default_focus_entry;
1345 default_focus_entry = gtk_builder_get_object
1346 (self->ui_details->gui, self->ui_details->default_focus);
1347 g_signal_connect (default_focus_entry, "realize",
1348 G_CALLBACK (gtk_widget_grab_focus),
1352 /* handle forget button */
1353 if (self->ui_details->add_forget)
1355 const gchar *password = NULL;
1357 priv->button_forget = GTK_WIDGET (gtk_builder_get_object
1358 (self->ui_details->gui, "button_forget"));
1359 priv->entry_password = GTK_WIDGET (gtk_builder_get_object
1360 (self->ui_details->gui, "entry_password"));
1362 password = empathy_account_settings_get_string (priv->settings,
1364 gtk_widget_set_sensitive (priv->button_forget,
1365 !EMP_STR_EMPTY (password));
1367 g_signal_connect (priv->button_forget, "clicked",
1368 G_CALLBACK (account_widget_forget_clicked_cb),
1370 g_signal_connect (priv->entry_password, "changed",
1371 G_CALLBACK (account_widget_password_changed_cb),
1375 /* handle apply and cancel button */
1378 GtkWidget *hbox = gtk_hbox_new (TRUE, 3);
1380 priv->cancel_button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
1382 if (priv->creating_account)
1384 priv->account_manager = tp_account_manager_dup ();
1386 empathy_signal_connect_weak (priv->account_manager,
1387 "most-available-presence-changed",
1388 G_CALLBACK (presence_changed_cb), obj);
1390 tp_account_manager_prepare_async (priv->account_manager, NULL,
1391 account_manager_ready_cb, self);
1393 /* Assumre we are offline, display a Save button. We'll update
1394 * it once the account manager is ready if needed */
1395 priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_SAVE);
1399 /* We are editing an existing account, display an Apply button */
1400 priv->apply_button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
1403 gtk_box_pack_end (GTK_BOX (hbox), priv->apply_button, TRUE,
1405 gtk_box_pack_end (GTK_BOX (hbox), priv->cancel_button, TRUE,
1408 gtk_box_pack_end (GTK_BOX (self->ui_details->widget), hbox, FALSE,
1411 g_signal_connect (priv->cancel_button, "clicked",
1412 G_CALLBACK (account_widget_cancel_clicked_cb),
1414 g_signal_connect (priv->apply_button, "clicked",
1415 G_CALLBACK (account_widget_apply_clicked_cb),
1417 gtk_widget_show_all (hbox);
1419 if (priv->creating_account)
1420 /* When creating an account, the user might have nothing to enter.
1421 * That means that no control interaction might occur,
1422 * so we update the control button sensitivity manually.
1424 account_widget_handle_control_buttons_sensitivity (self);
1426 account_widget_set_control_buttons_sensitivity (self, FALSE);
1429 account = empathy_account_settings_get_account (priv->settings);
1431 if (account != NULL)
1433 g_signal_connect (account, "notify::enabled",
1434 G_CALLBACK (empathy_account_widget_enabled_cb), self);
1437 /* handle the "Enabled" checkbox. We only add it when modifying an account */
1438 if (!priv->creating_account && priv->table_common_settings != NULL)
1443 guint nb_rows, nb_columns;
1444 gboolean is_enabled;
1446 is_enabled = tp_account_is_enabled (account);
1449 priv->enabled_checkbox =
1450 gtk_check_button_new_with_label (_("Enabled"));
1452 gtk_toggle_button_set_active (
1453 GTK_TOGGLE_BUTTON (priv->enabled_checkbox), is_enabled);
1455 /* Translators: this is used only when built on a moblin platform */
1456 w = gtk_label_new (_("Account:"));
1457 gtk_misc_set_alignment (GTK_MISC (w), 0, 0.5);
1459 priv->enabled_checkbox = nbtk_gtk_light_switch_new ();
1461 nbtk_gtk_light_switch_set_active (
1462 NBTK_GTK_LIGHT_SWITCH (priv->enabled_checkbox), is_enabled);
1464 gtk_widget_show (w);
1465 #endif /* HAVE_MOBLIN */
1467 g_object_get (priv->table_common_settings, "n-rows", &nb_rows,
1468 "n-columns", &nb_columns, NULL);
1470 gtk_table_resize (GTK_TABLE (priv->table_common_settings), ++nb_rows,
1474 gtk_table_attach (GTK_TABLE (priv->table_common_settings),
1475 priv->enabled_checkbox,
1476 0, nb_columns, nb_rows - 1, nb_rows,
1477 GTK_EXPAND | GTK_FILL, 0, 0, 0);
1479 gtk_table_attach (GTK_TABLE (priv->table_common_settings),
1481 0, 1, nb_rows - 1, nb_rows,
1483 gtk_table_attach (GTK_TABLE (priv->table_common_settings),
1484 priv->enabled_checkbox,
1485 1, nb_columns, nb_rows - 1, nb_rows,
1486 GTK_EXPAND | GTK_FILL, 0, 0, 0);
1487 #endif /* HAVE_MOBLIN */
1489 gtk_widget_show (priv->enabled_checkbox);
1492 g_signal_connect (G_OBJECT (priv->enabled_checkbox), "released",
1493 G_CALLBACK (account_widget_enabled_released_cb), self);
1495 g_signal_connect (G_OBJECT (priv->enabled_checkbox), "switch-flipped",
1496 G_CALLBACK (account_widget_switch_flipped_cb), self);
1497 #endif /* HAVE_MOBLIN */
1500 /* hook up to widget destruction to unref ourselves */
1501 g_signal_connect (self->ui_details->widget, "destroy",
1502 G_CALLBACK (account_widget_destroy_cb), self);
1504 empathy_builder_unref_and_keep_widget (self->ui_details->gui,
1505 self->ui_details->widget);
1506 self->ui_details->gui = NULL;
1510 do_dispose (GObject *obj)
1512 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
1513 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1515 if (priv->dispose_run)
1518 priv->dispose_run = TRUE;
1520 empathy_account_settings_is_ready (priv->settings);
1522 if (priv->settings != NULL)
1525 account = empathy_account_settings_get_account (priv->settings);
1527 if (account != NULL)
1529 g_signal_handlers_disconnect_by_func (account,
1530 empathy_account_widget_enabled_cb, self);
1533 g_object_unref (priv->settings);
1534 priv->settings = NULL;
1537 if (priv->account_manager != NULL)
1539 g_object_unref (priv->account_manager);
1540 priv->account_manager = NULL;
1543 if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose != NULL)
1544 G_OBJECT_CLASS (empathy_account_widget_parent_class)->dispose (obj);
1548 do_finalize (GObject *obj)
1550 EmpathyAccountWidget *self = EMPATHY_ACCOUNT_WIDGET (obj);
1552 g_free (self->ui_details->default_focus);
1553 g_slice_free (EmpathyAccountWidgetUIDetails, self->ui_details);
1555 if (G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize != NULL)
1556 G_OBJECT_CLASS (empathy_account_widget_parent_class)->finalize (obj);
1560 empathy_account_widget_class_init (EmpathyAccountWidgetClass *klass)
1562 GObjectClass *oclass = G_OBJECT_CLASS (klass);
1563 GParamSpec *param_spec;
1565 oclass->get_property = do_get_property;
1566 oclass->set_property = do_set_property;
1567 oclass->constructed = do_constructed;
1568 oclass->dispose = do_dispose;
1569 oclass->finalize = do_finalize;
1571 param_spec = g_param_spec_string ("protocol",
1572 "protocol", "The protocol of the account",
1574 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
1575 g_object_class_install_property (oclass, PROP_PROTOCOL, param_spec);
1577 param_spec = g_param_spec_object ("settings",
1578 "settings", "The settings of the account",
1579 EMPATHY_TYPE_ACCOUNT_SETTINGS,
1580 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
1581 g_object_class_install_property (oclass, PROP_SETTINGS, param_spec);
1583 param_spec = g_param_spec_boolean ("simple",
1584 "simple", "Whether the account widget is a simple or an advanced one",
1586 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
1587 g_object_class_install_property (oclass, PROP_SIMPLE, param_spec);
1589 param_spec = g_param_spec_boolean ("creating-account",
1591 "TRUE if we're creating an account, FALSE if we're modifying it",
1593 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
1594 g_object_class_install_property (oclass, PROP_CREATING_ACCOUNT, param_spec);
1596 signals[HANDLE_APPLY] =
1597 g_signal_new ("handle-apply", G_TYPE_FROM_CLASS (klass),
1598 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
1599 g_cclosure_marshal_VOID__BOOLEAN,
1603 /* This signal is emitted when an account has been created and enabled. */
1604 signals[ACCOUNT_CREATED] =
1605 g_signal_new ("account-created", G_TYPE_FROM_CLASS (klass),
1606 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
1607 g_cclosure_marshal_VOID__VOID,
1611 signals[CANCELLED] =
1612 g_signal_new ("cancelled", G_TYPE_FROM_CLASS (klass),
1613 G_SIGNAL_RUN_LAST, 0, NULL, NULL,
1614 g_cclosure_marshal_VOID__VOID,
1618 g_type_class_add_private (klass, sizeof (EmpathyAccountWidgetPriv));
1622 empathy_account_widget_init (EmpathyAccountWidget *self)
1624 EmpathyAccountWidgetPriv *priv =
1625 G_TYPE_INSTANCE_GET_PRIVATE ((self), EMPATHY_TYPE_ACCOUNT_WIDGET,
1626 EmpathyAccountWidgetPriv);
1629 priv->dispose_run = FALSE;
1631 self->ui_details = g_slice_new0 (EmpathyAccountWidgetUIDetails);
1634 /* public methods */
1637 empathy_account_widget_discard_pending_changes
1638 (EmpathyAccountWidget *widget)
1640 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
1642 empathy_account_settings_discard_changes (priv->settings);
1643 priv->contains_pending_changes = FALSE;
1647 empathy_account_widget_contains_pending_changes (EmpathyAccountWidget *widget)
1649 EmpathyAccountWidgetPriv *priv = GET_PRIV (widget);
1651 if (priv->creating_account && !priv->account_created)
1652 /* We always want to warn the user if he's in the process of creating a
1653 * new account which hasn't been actually created yet. */
1656 return priv->contains_pending_changes;
1660 empathy_account_widget_handle_params (EmpathyAccountWidget *self,
1661 const gchar *first_widget,
1666 va_start (args, first_widget);
1667 account_widget_handle_params_valist (self, first_widget, args);
1672 empathy_account_widget_get_widget (EmpathyAccountWidget *widget)
1674 return widget->ui_details->widget;
1677 EmpathyAccountWidget *
1678 empathy_account_widget_new_for_protocol (EmpathyAccountSettings *settings,
1681 EmpathyAccountWidget *self;
1683 g_return_val_if_fail (EMPATHY_IS_ACCOUNT_SETTINGS (settings), NULL);
1686 (EMPATHY_TYPE_ACCOUNT_WIDGET,
1687 "settings", settings, "simple", simple,
1689 empathy_account_settings_get_account (settings) == NULL,
1696 empathy_account_widget_get_default_display_name (EmpathyAccountWidget *self)
1698 EmpathyAccountWidgetPriv *priv = GET_PRIV (self);
1699 const gchar *login_id;
1700 const gchar *protocol, *p;
1701 gchar *default_display_name;
1703 login_id = empathy_account_settings_get_string (priv->settings, "account");
1704 protocol = empathy_account_settings_get_protocol (priv->settings);
1706 if (login_id != NULL)
1708 /* TODO: this should be done in empathy-account-widget-irc */
1709 if (!tp_strdiff (protocol, "irc"))
1711 const gchar* server;
1712 server = empathy_account_settings_get_string (priv->settings,
1715 /* To translators: The first parameter is the login id and the
1716 * second one is the server. The resulting string will be something
1717 * like: "MyUserName on chat.freenode.net".
1718 * You should reverse the order of these arguments if the
1719 * server should come before the login id in your locale.*/
1720 default_display_name = g_strdup_printf (_("%1$s on %2$s"),
1725 default_display_name = g_strdup (login_id);
1728 return default_display_name;
1731 if ((p = empathy_protocol_name_to_display_name (protocol)) != NULL)
1734 if (protocol != NULL)
1736 /* To translators: The parameter is the protocol name. The resulting
1737 * string will be something like: "Jabber Account" */
1738 default_display_name = g_strdup_printf (_("%s Account"), protocol);
1742 default_display_name = g_strdup (_("New account"));
1745 return default_display_name;