aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2011-03-17 05:34:48 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-04-08 18:41:30 +0800
commit563630a2afed64a18df0936a5da7aa178ef8e474 (patch)
treedc357ea6f23ae0c4e482d7702b0b66e48e336669
parent0e8272e711be19be93995495a570531f6ecbdf10 (diff)
downloadgsoc2013-empathy-563630a2afed64a18df0936a5da7aa178ef8e474.tar
gsoc2013-empathy-563630a2afed64a18df0936a5da7aa178ef8e474.tar.gz
gsoc2013-empathy-563630a2afed64a18df0936a5da7aa178ef8e474.tar.bz2
gsoc2013-empathy-563630a2afed64a18df0936a5da7aa178ef8e474.tar.lz
gsoc2013-empathy-563630a2afed64a18df0936a5da7aa178ef8e474.tar.xz
gsoc2013-empathy-563630a2afed64a18df0936a5da7aa178ef8e474.tar.zst
gsoc2013-empathy-563630a2afed64a18df0936a5da7aa178ef8e474.zip
Disable all other psyke accounts when one is enabled
-rw-r--r--libempathy-gtk/empathy-account-widget-skype.c73
-rw-r--r--libempathy-gtk/empathy-account-widget-skype.h3
-rw-r--r--src/empathy-accounts-dialog.c14
3 files changed, 89 insertions, 1 deletions
diff --git a/libempathy-gtk/empathy-account-widget-skype.c b/libempathy-gtk/empathy-account-widget-skype.c
index ea39da898..439c373cc 100644
--- a/libempathy-gtk/empathy-account-widget-skype.c
+++ b/libempathy-gtk/empathy-account-widget-skype.c
@@ -958,3 +958,76 @@ empathy_account_widget_skype_show_eula (GtkWindow *parent)
return (result == GTK_RESPONSE_ACCEPT);
}
+gboolean
+empathy_accounts_dialog_skype_disable_other_accounts (TpAccount *account,
+ GtkWindow *parent)
+{
+ TpAccountManager *am = tp_account_manager_dup ();
+ GList *accounts, *ptr;
+ gboolean other_psyke_accounts = FALSE;
+
+ /* check if any other psyke accounts are enabled */
+ accounts = tp_account_manager_get_valid_accounts (am);
+
+ for (ptr = accounts; ptr != NULL; ptr = ptr->next)
+ {
+ TpAccount *a = ptr->data;
+
+ if (tp_strdiff (
+ tp_proxy_get_object_path (account),
+ tp_proxy_get_object_path (a)) &&
+ tp_account_is_enabled (a) &&
+ !tp_strdiff (tp_account_get_connection_manager (a), "psyke"))
+ {
+ other_psyke_accounts = TRUE;
+ break;
+ }
+ }
+
+ g_list_free (accounts);
+
+ if (other_psyke_accounts)
+ {
+ GtkWidget *msg = gtk_message_dialog_new (parent, 0,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+ "%s\n\n%s",
+ _("Multiple Skype accounts can not be enabled simultaneously. "
+ "Enabling this Skype account will disable all others."),
+ _("Continue to enable this account?"));
+ int response;
+
+ response = gtk_dialog_run (GTK_DIALOG (msg));
+ gtk_widget_destroy (msg);
+
+ if (response != GTK_RESPONSE_YES)
+ {
+ /* the user chose not to proceed */
+ g_object_unref (am);
+
+ return FALSE;
+ }
+
+ /* the user chose to proceed, disable the other accounts */
+ accounts = tp_account_manager_get_valid_accounts (am);
+
+ for (ptr = accounts; ptr != NULL; ptr = ptr->next)
+ {
+ TpAccount *a = ptr->data;
+
+ if (tp_strdiff (
+ tp_proxy_get_object_path (account),
+ tp_proxy_get_object_path (a)) &&
+ tp_account_is_enabled (a) &&
+ !tp_strdiff (tp_account_get_connection_manager (a), "psyke"))
+ {
+ tp_account_set_enabled_async (a, FALSE, NULL, NULL);
+ }
+ }
+
+ g_list_free (accounts);
+ }
+
+ g_object_unref (am);
+
+ return TRUE;
+}
diff --git a/libempathy-gtk/empathy-account-widget-skype.h b/libempathy-gtk/empathy-account-widget-skype.h
index 3ca1e76bc..5ba0c6ed5 100644
--- a/libempathy-gtk/empathy-account-widget-skype.h
+++ b/libempathy-gtk/empathy-account-widget-skype.h
@@ -30,7 +30,8 @@ G_BEGIN_DECLS
void empathy_account_widget_build_skype (EmpathyAccountWidget *self,
const char *filename);
gboolean empathy_account_widget_skype_show_eula (GtkWindow *parent);
-
+gboolean empathy_accounts_dialog_skype_disable_other_accounts (
+ TpAccount *account, GtkWindow *parent);
G_END_DECLS
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index 215102eb1..6619442a8 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -258,6 +258,20 @@ accounts_dialog_enable_switch_flipped (MxGtkLightSwitch *sw,
if (account == NULL)
return;
+ if (state == TRUE &&
+ !tp_strdiff (tp_account_get_connection_manager (account), "psyke"))
+ {
+ /* psyke typically doesn't support more than one simultaneous connection
+ * unless you've compiled it to do so */
+ if (!empathy_accounts_dialog_skype_disable_other_accounts (account,
+ GTK_WINDOW (dialog)))
+ {
+ /* user chose not to proceed */
+ mx_gtk_light_switch_set_active (sw, FALSE);
+ return;
+ }
+ }
+
tp_account_set_enabled_async (account, state,
accounts_dialog_enable_account_cb, NULL);
}