From a3c14d3f22f4f1a07cf72e3200ac5f1f3b4c843d Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 30 Mar 2012 12:47:30 +0200 Subject: factor out account_can_be_enabled() https://bugzilla.gnome.org/show_bug.cgi?id=673141 --- src/empathy-accounts-dialog.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c index bab9dac29..c21db2bc7 100644 --- a/src/empathy-accounts-dialog.c +++ b/src/empathy-accounts-dialog.c @@ -303,6 +303,23 @@ account_is_selected (EmpathyAccountsDialog *dialog, return account == selected_account; } +static gboolean +account_can_be_enabled (TpAccount *account) +{ + TpStorageRestrictionFlags storage_restrictions; + + storage_restrictions = tp_account_get_storage_restrictions (account); + if (storage_restrictions & TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_ENABLED) + return FALSE; + + /* Butterfly accounts shouldn't be used any more */ + if (!tp_strdiff (tp_account_get_connection_manager (account), + "butterfly")) + return FALSE; + + return TRUE; +} + static void accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog, TpAccount *account) @@ -314,7 +331,6 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog, guint presence; gboolean account_enabled; gboolean creating_account; - TpStorageRestrictionFlags storage_restrictions = 0; gboolean display_switch = TRUE; /* do not update the infobar when the account is not selected */ @@ -341,14 +357,7 @@ accounts_dialog_update_status_infobar (EmpathyAccountsDialog *dialog, if (!account_enabled) presence = TP_CONNECTION_PRESENCE_TYPE_OFFLINE; - storage_restrictions = tp_account_get_storage_restrictions (account); - if (storage_restrictions & TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_ENABLED) - display_switch = FALSE; - - /* Butterfly accounts shouldn't be used any more */ - if (!tp_strdiff (tp_account_get_connection_manager (account), - "butterfly")) - display_switch = FALSE; + display_switch = account_can_be_enabled (account); } else { -- cgit v1.2.3