/* disconnect the list of TnyAccounts */
static void
-foreach_account_disconnect (gpointer data,
- gpointer user_data)
+account_disconnect (TnyAccount *account)
{
- tny_camel_account_set_online (TNY_CAMEL_ACCOUNT(data), FALSE, NULL, NULL);
+ g_return_if_fail (account && TNY_IS_ACCOUNT(account));
+ tny_camel_account_set_online (TNY_CAMEL_ACCOUNT(account), FALSE, NULL, NULL);
}
+/* disconnect the list of TnyAccounts */
+static void
+account_verify_last_ref (TnyAccount *account, const gchar *str)
+{
+ gchar *txt;
+
+ g_return_if_fail (account && TNY_IS_ACCOUNT(account));
+
+ txt = g_strdup_printf ("%s: %s", str ? str : "?", tny_account_get_name(account));
+ modest_runtime_verify_object_last_ref(G_OBJECT(account),txt);
+ g_free (txt);
+}
+
+
+
+
static void
foreach_account_append_to_list (gpointer data,
gpointer user_data)
{
TnyList *list;
-
+
list = TNY_LIST (user_data);
tny_list_append (list, G_OBJECT (data));
}
if (found) {
/* Remove from the list */
tny_list_remove (priv->store_accounts, G_OBJECT (mmc_account));
-
+
/* Notify observers */
g_signal_emit (G_OBJECT (self),
signals [ACCOUNT_REMOVED_SIGNAL],
/* Destroy all accounts. Disconnect all accounts before they are destroyed */
if (priv->store_accounts) {
- tny_list_foreach (priv->store_accounts, foreach_account_disconnect, NULL);
+ tny_list_foreach (priv->store_accounts, (GFunc)account_disconnect, NULL);
+ tny_list_foreach (priv->store_accounts, (GFunc)account_verify_last_ref, "store");
g_object_unref (priv->store_accounts);
priv->store_accounts = NULL;
}
-
+
if (priv->transport_accounts) {
- tny_list_foreach (priv->transport_accounts, foreach_account_disconnect, NULL);
+ tny_list_foreach (priv->transport_accounts, (GFunc)account_disconnect, NULL);
+ tny_list_foreach (priv->transport_accounts, (GFunc)account_verify_last_ref, "transport");
g_object_unref (priv->transport_accounts);
priv->transport_accounts = NULL;
}
g_return_val_if_fail (self, NULL);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
-
- if (priv->device)
+
+ if (priv->device)
return g_object_ref (G_OBJECT(priv->device));
else
return NULL;
return account;
}
+
TnyAccount*
modest_tny_account_store_get_server_account (ModestTnyAccountStore *self,
const gchar *account_name,
/* Add accounts to the lists */
tny_list_append (priv->store_accounts, G_OBJECT (store_account));
tny_list_append (priv->transport_accounts, G_OBJECT (transport_account));
-
+
/* Create a new pseudo-account with an outbox for this
transport account and add it to the global outbox
in the local account */
}
static void
-on_account_removed (ModestAccountMgr *acc_mgr,
- const gchar *account,
+on_account_removed (ModestAccountMgr *acc_mgr, const gchar *account,
gpointer user_data)
{
TnyAccount *store_account = NULL, *transport_account = NULL;
modest_tny_account_store_get_server_account (self, account, TNY_ACCOUNT_TYPE_STORE);
transport_account =
modest_tny_account_store_get_server_account (self, account, TNY_ACCOUNT_TYPE_TRANSPORT);
-
+
/* If there was any problem creating the account, for example,
with the configuration system this could not exist */
if (store_account) {
/* Notify the observers */
g_signal_emit (G_OBJECT (self), signals [ACCOUNT_REMOVED_SIGNAL], 0, store_account);
+ account_disconnect (store_account); /* disconnect the account */
g_object_unref (store_account);
} else {
g_warning ("There is no store account for account %s\n", account);
/* Notify the observers */
g_signal_emit (G_OBJECT (self), signals [ACCOUNT_REMOVED_SIGNAL], 0, transport_account);
+ account_disconnect (transport_account); /* disconnect the account */
g_object_unref (transport_account);
} else {
g_warning ("There is no transport account for account %s\n", account);