+ /* Get the server and the transport account */
+ store_account =
+ 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) {
+ /* Clear the cache */
+ tny_store_account_delete_cache (TNY_STORE_ACCOUNT (store_account));
+
+ /* Notify the observers */
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_REMOVED_SIGNAL], 0, store_account);
+ g_object_unref (store_account);
+ } else {
+ g_warning ("There is no store account for account %s\n", account);
+ }
+
+ /* If there was any problem creating the account, for example,
+ with the configuration system this could not exist */
+ if (transport_account) {
+ TnyAccount *local_account = NULL;
+ TnyFolder *outbox = NULL;
+ ModestTnyAccountStorePrivate *priv = NULL;
+
+ /* Remove the OUTBOX of the account from the global outbox */
+ priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+ outbox = g_hash_table_lookup (priv->outbox_of_transport, transport_account);
+
+ if (TNY_IS_FOLDER (outbox)) {
+ local_account = modest_tny_account_store_get_local_folders_account (self);
+ modest_tny_local_folders_account_remove_folder_from_outbox (MODEST_TNY_LOCAL_FOLDERS_ACCOUNT (local_account),
+ outbox);
+ g_hash_table_remove (priv->outbox_of_transport, transport_account);
+
+ /* Notify the change in the local account */
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_CHANGED_SIGNAL], 0, local_account);
+ g_object_unref (local_account);
+ } else {
+ g_warning ("Removing a transport account that has no outbox");
+ }
+
+ /* Notify the observers */
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_REMOVED_SIGNAL], 0, transport_account);
+ g_object_unref (transport_account);
+ } else {
+ g_warning ("There is no transport account for account %s\n", account);
+ }
+}
+
+static void
+add_connection_specific_transport_accounts (ModestTnyAccountStore *self)
+{
+ ModestTnyAccountStorePrivate *priv = NULL;
+ GSList *list_specifics = NULL, *iter = NULL;
+
+ priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+
+ ModestConf *conf = modest_runtime_get_conf ();
+
+ GError *err = NULL;
+ list_specifics = modest_conf_get_list (conf,
+ MODEST_CONF_CONNECTION_SPECIFIC_SMTP_LIST,
+ MODEST_CONF_VALUE_STRING, &err);
+ if (err) {
+ g_printerr ("modest: %s: error getting list: %s\n.", __FUNCTION__, err->message);
+ g_error_free (err);
+ err = NULL;
+ }
+
+ /* Look at each connection-specific transport account for the
+ * modest account: */
+ iter = list_specifics;
+ while (iter) {
+ /* The list alternates between the connection name and the transport name: */
+ iter = g_slist_next (iter);
+ if (iter) {
+ const gchar* transport_account_name = (const gchar*) (iter->data);
+ if (transport_account_name) {
+ TnyAccount * tny_account = NULL;
+ /* Add the account: */
+ tny_account =
+ modest_tny_account_new_from_server_account_name (priv->account_mgr,
+ priv->session,
+ transport_account_name);
+ if (tny_account) {
+ g_object_set_data (G_OBJECT(tny_account),
+ "account_store",
+ (gpointer)self);
+
+ tny_list_append (priv->transport_accounts, G_OBJECT (tny_account));
+ g_object_unref (tny_account);
+ } else
+ g_printerr ("modest: failed to create smtp-specific account for %s\n",
+ transport_account_name);
+ }
+ }
+ iter = g_slist_next (iter);
+ }