+
+static int
+compare_account_name(gconstpointer a, gconstpointer b)
+{
+ const gchar* account_name = (const gchar*) a;
+ const gchar* account_name2 = (const gchar*) b;
+ return strcmp(account_name, account_name2);
+}
+
+void
+modest_account_mgr_set_account_busy(ModestAccountMgr* self, const gchar* account_name,
+ gboolean busy)
+{
+ ModestAccountMgrPrivate* priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ if (busy)
+ {
+ GSList *account_names = modest_account_mgr_account_names (self,
+ TRUE);
+ GSList* account =
+ g_slist_find_custom(account_names, account_name, (GCompareFunc) compare_account_name);
+ if (account && !modest_account_mgr_account_is_busy(self, account_name))
+ {
+ priv->busy_accounts = g_slist_append(priv->busy_accounts, g_strdup(account_name));
+ g_signal_emit_by_name(G_OBJECT(self), "account-busy-changed", account_name, TRUE);
+ }
+ g_slist_free(account_names);
+ }
+ else
+ {
+ GSList* account =
+ g_slist_find_custom(priv->busy_accounts, account_name, (GCompareFunc) compare_account_name);
+ if (account)
+ {
+ g_free(account->data);
+ priv->busy_accounts = g_slist_delete_link(priv->busy_accounts, account);
+ g_signal_emit_by_name(G_OBJECT(self), "account-busy-changed", account_name, FALSE);
+ }
+ }
+}
+
+gboolean
+modest_account_mgr_account_is_busy(ModestAccountMgr* self, const gchar* account_name)
+{
+ ModestAccountMgrPrivate* priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+ return (g_slist_find_custom(priv->busy_accounts, account_name, (GCompareFunc) compare_account_name)
+ != NULL);
+}
+