X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-account-mgr.c;h=bbbb2e8c6d559e6b3615bd232cd6de85ddfaa9fa;hp=e3de89928b1fe34eec29f1a038d21ba2f4e1a818;hb=6ae65afc6c85e5221c0ab94b5d4d07828e7da1ff;hpb=a2f971fd9378912d99ca8ce97c514bba81a3c4e2 diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index e3de899..bbbb2e8 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -33,6 +33,7 @@ #include #include #include +#include /* 'private'/'protected' functions */ static void modest_account_mgr_class_init (ModestAccountMgrClass * klass); @@ -258,6 +259,10 @@ null_means_empty (const gchar * str) gboolean modest_account_mgr_add_account (ModestAccountMgr *self, const gchar *name, + const gchar *display_name, + const gchar *user_fullname, + const gchar *user_email, + const gchar *retrieve_type, const gchar *store_account, const gchar *transport_account, gboolean enabled) @@ -332,6 +337,20 @@ modest_account_mgr_add_account (ModestAccountMgr *self, modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_LEAVE_ON_SERVER, TRUE, FALSE); modest_account_mgr_set_bool (self, name, MODEST_ACCOUNT_ENABLED, enabled,FALSE); + /* Fill other data */ + modest_account_mgr_set_string (self, name, + MODEST_ACCOUNT_DISPLAY_NAME, + display_name, FALSE); + modest_account_mgr_set_string (self, name, + MODEST_ACCOUNT_FULLNAME, + user_fullname, FALSE); + modest_account_mgr_set_string (self, name, + MODEST_ACCOUNT_EMAIL, + user_email, FALSE); + modest_account_mgr_set_string (self, name, + MODEST_ACCOUNT_RETRIEVE, + retrieve_type, FALSE); + /* Notify the observers */ g_signal_emit (self, signals[ACCOUNT_INSERTED_SIGNAL], 0, name); @@ -340,7 +359,11 @@ modest_account_mgr_add_account (ModestAccountMgr *self, if (!default_account) modest_account_mgr_set_default_account (self, name); g_free (default_account); - + + /* (re)set the automatic account update */ + modest_platform_set_update_interval + (modest_conf_get_int (priv->modest_conf, MODEST_CONF_UPDATE_INTERVAL, NULL)); + return TRUE; } @@ -449,7 +472,7 @@ modest_account_mgr_add_server_account (ModestAccountMgr * self, /* Add the security settings: */ modest_account_mgr_set_server_account_security (self, name, security); - + cleanup: if (!ok) { g_printerr ("modest: failed to add server account\n"); @@ -576,6 +599,14 @@ modest_account_mgr_remove_account (ModestAccountMgr * self, will retrieve also the deleted account */ g_signal_emit (G_OBJECT(self), signals[ACCOUNT_REMOVED_SIGNAL], 0, name); + /* if this was the last account, stop any auto-updating */ + /* (re)set the automatic account update */ + GSList *acc_names = modest_account_mgr_account_names (self, TRUE); + if (!acc_names) + modest_platform_set_update_interval (0); + else + modest_account_mgr_free_account_names (acc_names); + return TRUE; } @@ -794,7 +825,7 @@ modest_account_mgr_get_list (ModestAccountMgr *self, const gchar *name, const gchar *key, ModestConfValueType list_type, gboolean server_account) { - ModestAccountMgrPrivate *priv; + ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); const gchar *keyname; GSList *retval; @@ -1136,8 +1167,9 @@ _modest_account_mgr_get_account_keyname (const gchar *account_name, const gchar* retval = g_strconcat (namespace, "/", escaped_account_name, NULL); /* Sanity check: */ - if (!modest_conf_key_is_valid (retval)) { - g_warning ("%s: Generated conf key was invalid: %s", __FUNCTION__, retval); + if (!retval || !modest_conf_key_is_valid (retval)) { + g_warning ("%s: Generated conf key was invalid: %s", __FUNCTION__, + retval ? retval: ""); g_free (retval); retval = NULL; } @@ -1214,9 +1246,13 @@ modest_account_mgr_set_account_busy(ModestAccountMgr* self, const gchar* account_name, gboolean busy) { - ModestAccountMgrPrivate* priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); - if (busy) - { + ModestAccountMgrPrivate* priv; + + g_return_if_fail (MODEST_IS_ACCOUNT_MGR(self)); + g_return_if_fail (account_name); + + 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); @@ -1242,11 +1278,17 @@ modest_account_mgr_set_account_busy(ModestAccountMgr* self, } gboolean -modest_account_mgr_account_is_busy(ModestAccountMgr* self, const gchar* account_name) +modest_account_mgr_account_is_busy (ModestAccountMgr* self, const gchar* account_name) { - ModestAccountMgrPrivate* priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); + ModestAccountMgrPrivate* priv; + + g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE); + g_return_val_if_fail (account_name, FALSE); + + priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); + return (g_slist_find_custom(priv->busy_accounts, account_name, (GCompareFunc) compare_account_name) - != NULL); + != NULL); } void