summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Dasmohapatra <vivek@collabora.co.uk>2010-10-12 15:33:58 +0100
committerVivek Dasmohapatra <vivek@collabora.co.uk>2010-10-12 15:43:44 +0100
commit08e39a3aa4003b2a31c6a548610cf5fa32bf3b9d (patch)
tree3b75751092f6180ce488dacd0b98b4782de60820
parent8f2a2ccc5fd7e860581ffcbe2709f975cbc90856 (diff)
downloadtelepathy-mission-control-08e39a3aa4003b2a31c6a548610cf5fa32bf3b9d.tar.gz
Helper functions to map the enabled flag to the enabled tri-state in SSO
-rw-r--r--test/account-store-libaccounts.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/account-store-libaccounts.c b/test/account-store-libaccounts.c
index 9118101d..266d85a1 100644
--- a/test/account-store-libaccounts.c
+++ b/test/account-store-libaccounts.c
@@ -345,6 +345,61 @@ static gboolean key_is_global (const char *ag_key)
return TRUE;
}
+/* enabled is actually a tri-state<->boolean mapping */
+static gboolean _sso_account_enabled (AgAccount *account, AgService *service)
+{
+ gboolean local = FALSE;
+ gboolean global = FALSE;
+ AgService *original = ag_account_get_selected_service (account);
+
+ if (service == NULL)
+ {
+ _ag_account_select_default_im_service (account);
+ local = ag_account_get_enabled (account);
+ }
+ else
+ {
+ if (original != service)
+ ag_account_select_service (account, service);
+
+ local = ag_account_get_enabled (account);
+ }
+
+ ag_account_select_service (account, NULL);
+ global = ag_account_get_enabled (account);
+
+ ag_account_select_service (account, original);
+
+ g_debug ("_sso_account_enabled: global:%d && local:%d", global, local);
+
+ return local && global;
+}
+
+static void _sso_account_enable (AgAccount *account,
+ AgService *service,
+ gboolean on)
+{
+ AgService *original = ag_account_get_selected_service (account);
+
+ /* turn the local enabled flag on/off as required */
+ if (service != NULL)
+ ag_account_select_service (account, service);
+ else
+ _ag_account_select_default_im_service (account);
+
+ ag_account_set_enabled (account, on);
+
+ /* if we are turning the account on, the global flag must also be set *
+ * NOTE: this isn't needed when turning the account off */
+ if (on)
+ {
+ ag_account_select_service (account, NULL);
+ ag_account_set_enabled (account, on);
+ }
+
+ ag_account_select_service (account, original);
+}
+
gchar *
libaccounts_get (const gchar *mc_account,
const gchar *key)