2007-05-28 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Mon, 28 May 2007 09:48:34 +0000 (09:48 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Mon, 28 May 2007 09:48:34 +0000 (09:48 +0000)
* src/modest-local-folder-info.h:
        * src/modest-local-folder-info.c:
        (modest_per_account_local_outbox_folder_info_get_maildir_path),
        (modest_per_account_local_outbox_folder_info_get_maildir_path_to_ou
        tbox_folder): Take a modest account name instead of a server TnyAccount,
        so we can have per-modest-account rather than per-transport-account
        outboxes.
        We must make sure that we change or recreate the exisitng send queues
        when the connection changes for connection-specific transport accounts.

        * src/modest-tny-account-store.c:
        (create_per_account_local_outbox_folders): Create outboxed per modest
        account, not per transport account.

        * src/modest-tny-account.h:
        * src/modest-tny-account.c:
        (modest_tny_account_get_special_folder): For outboxes, get the
        parent modest account name. The account is ignored for other folders.
        (modest_tny_account_new_for_per_account_local_outbox_folder): Take a
        modest account name rather than a server TnyAccount.

pmo-trunk-r1979

ChangeLog2
src/modest-cache-mgr.c
src/modest-local-folder-info.c
src/modest-local-folder-info.h
src/modest-tny-account-store.c
src/modest-tny-account.c
src/modest-tny-account.h

index cf9002f..7388b0a 100644 (file)
@@ -1,3 +1,26 @@
+2007-05-28  Murray Cumming  <murrayc@murrayc.com>
+
+       * src/modest-local-folder-info.h:
+       * src/modest-local-folder-info.c:
+       (modest_per_account_local_outbox_folder_info_get_maildir_path),
+       (modest_per_account_local_outbox_folder_info_get_maildir_path_to_ou
+       tbox_folder): Take a modest account name instead of a server TnyAccount,
+       so we can have per-modest-account rather than per-transport-account 
+       outboxes.
+       We must make sure that we change or recreate the exisitng send queues 
+       when the connection changes for connection-specific transport accounts.
+       
+       * src/modest-tny-account-store.c:
+       (create_per_account_local_outbox_folders): Create outboxed per modest 
+       account, not per transport account.
+       
+       * src/modest-tny-account.h:
+       * src/modest-tny-account.c:
+       (modest_tny_account_get_special_folder): For outboxes, get the 
+       parent modest account name. The account is ignored for other folders.
+       (modest_tny_account_new_for_per_account_local_outbox_folder): Take a 
+       modest account name rather than a server TnyAccount.
+
 2007-05-25  Murray Cumming  <murrayc@murrayc.com>
 
        * src/modest-tny-account.c:
index 6e64be6..87023d5 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <config.h>
 #include <modest-cache-mgr.h>
+#include <stdio.h>
 
 /* 'private'/'protected' functions */
 static void modest_cache_mgr_class_init (ModestCacheMgrClass *klass);
@@ -183,6 +184,11 @@ modest_cache_mgr_get_cache   (ModestCacheMgr* self, ModestCacheMgrCacheType type
        GHashTable *cache;
        
        g_return_val_if_fail (self, NULL);
+       
+       if (!(type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM)) {
+               printf ("DEBUG: %s: incorrect type = %d\n", __FUNCTION__, type);        
+       }
+       
        g_return_val_if_fail (type >= 0 && type <= MODEST_CACHE_MGR_CACHE_TYPE_NUM, NULL);
 
        priv  = MODEST_CACHE_MGR_GET_PRIVATE(self);
index f066809..9ab4465 100644 (file)
@@ -113,20 +113,20 @@ modest_local_folder_info_get_maildir_path (void)
                                 NULL);
 }
 
-gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (TnyAccount *account)
+gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (const gchar* account_name)
 {
        /* This directory should contain an "outbox" child directory: */
        return g_build_filename (g_get_home_dir(),
                                 MODEST_DIR,
                                 MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDERS_MAILDIR, 
-                                tny_account_get_id (account),
+                                account_name,
                                 NULL);
 }
 
-gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (TnyAccount *account)
+gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (const gchar* account_name)
 {
        gchar *path_to_account_folder = 
-               modest_per_account_local_outbox_folder_info_get_maildir_path(account);
+               modest_per_account_local_outbox_folder_info_get_maildir_path(account_name);
        if (!path_to_account_folder)
                return NULL;
 
index de83755..da0fe58 100644 (file)
@@ -94,7 +94,7 @@ gchar *modest_local_folder_info_get_maildir_path (void);
  * string, which must be freed by the caller.
  *
  */
-gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (TnyAccount *account);
+gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (const gchar* account_name);
 
 /**
  * modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder
@@ -105,7 +105,7 @@ gchar *modest_per_account_local_outbox_folder_info_get_maildir_path (TnyAccount
  * string, which must be freed by the caller.
  *
  */
-gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (TnyAccount *account);
+gchar *modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (const gchar* account_name);
 
 G_END_DECLS
 #endif /* __MODEST_LOCAL_FOLDER_INFO_H__ */
index a8ece28..4b69b59 100644 (file)
@@ -503,42 +503,28 @@ create_per_account_local_outbox_folders (TnyAccountStore *self)
                MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
        
        /* printf("DEBUG: %s: priv->store_accounts_outboxes = %p\n", __FUNCTION__, priv->store_accounts_outboxes); */
-               
-       if (priv->store_accounts_outboxes) {
-                       return;
-       }
-       
-       /* This transport accounts must be created before calling this function.
-        * Otherwise, we have an infinite loop when there are no accounts. */
-        if (!(priv->transport_accounts))
-               return;
-#if 0
-       /* Create the transport accounts, if necessary: */
-       if (!(priv->transport_accounts)) {
-               get_server_accounts (self, NULL /* TnyList */, 
-                       TNY_ACCOUNT_TYPE_TRANSPORT);
-       }
-#endif
        
        GSList *accounts = NULL;
        
        GSList *account_names  = modest_account_mgr_account_names (priv->account_mgr, 
                TRUE /* including disabled accounts */);
        
-       GSList *iter = account_names;
-       for (iter = priv->transport_accounts; iter; iter = g_slist_next (iter)) {
+       GSList *iter = NULL;
+       for (iter = account_names; iter; iter = g_slist_next (iter)) {
                
-               TnyAccount *transport_account = (TnyAccount*)iter->data;
+               const gchar* account_name = (const gchar*)iter->data;
                
                /* Create a per-account local outbox folder (a _store_ account) 
                 * for each _transport_ account: */
                TnyAccount *tny_account_outbox =
                        modest_tny_account_new_for_per_account_local_outbox_folder (
-                               priv->account_mgr, transport_account, priv->session);
+                               priv->account_mgr, account_name, priv->session);
                                
                accounts = g_slist_append (accounts, tny_account_outbox); /* cache it */
        };
        
+       g_slist_free (account_names);
+       
        priv->store_accounts_outboxes = accounts;
 }
 
@@ -849,7 +835,7 @@ modest_tny_account_store_alert (TnyAccountStore *self, TnyAlertType type,
        g_free (prompt);
 
 
-       printf("DEBUG: %s: returning %d\n", __FUNCTION__, retval);
+       /* printf("DEBUG: %s: returning %d\n", __FUNCTION__, retval); */
        return retval;
 }
 
index 9464edf..fda4366 100644 (file)
@@ -65,13 +65,17 @@ modest_tny_account_get_special_folder (TnyAccount *account,
         
        /* Per-account outbox folders are each in their own on-disk directory: */
        if (special_type == TNY_FOLDER_TYPE_OUTBOX) {
+               const gchar *modest_account_name = 
+                       modest_tny_account_get_parent_modest_account_name_for_server_account (account);
+               g_assert (modest_account_name);
+
                gchar *account_id = g_strdup_printf (
                        MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s", 
-                       tny_account_get_id (account));
+                       modest_account_name);
                
-                       local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
+               local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
                                                                        account_id);
-                       g_free (account_id);
+               g_free (account_id);
        } else {
                /* Other local folders are all in one on-disk directory: */
                local_account = modest_tny_account_store_get_tny_account_by_id (modest_runtime_get_account_store(),
@@ -433,11 +437,10 @@ modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySess
 
 
 TnyAccount*
-modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *account_mgr, TnyAccount *account, TnySessionCamel *session)
+modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *account_mgr, const gchar* account_name, TnySessionCamel *session)
 {
        g_return_val_if_fail (account_mgr, NULL);
-       g_return_val_if_fail (account, NULL);
-       g_return_val_if_fail (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_TRANSPORT, NULL);
+       g_return_val_if_fail (account_name, NULL);
        
        /* Notice that we create a ModestTnyOutboxAccount here, 
         * instead of just a TnyCamelStoreAccount,
@@ -453,14 +456,14 @@ modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *ac
        
        /* Make sure that the paths exists on-disk so that TnyCamelStoreAccount can 
         * find it to create a TnyFolder for it: */
-       gchar *folder_dir = modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (account); 
+       gchar *folder_dir = modest_per_account_local_outbox_folder_info_get_maildir_path_to_outbox_folder (account_name); 
        modest_init_one_local_folder(folder_dir);
        g_free (folder_dir);
        folder_dir = NULL;
 
        /* This path should contain just one directory - "outbox": */
        gchar *maildir = 
-               modest_per_account_local_outbox_folder_info_get_maildir_path (account);
+               modest_per_account_local_outbox_folder_info_get_maildir_path (account_name);
                        
        CamelURL *url = camel_url_new ("maildir:", NULL);
        camel_url_set_path (url, maildir);
@@ -482,7 +485,7 @@ modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *ac
        
        gchar *account_id = g_strdup_printf (
                MODEST_PER_ACCOUNT_LOCAL_OUTBOX_FOLDER_ACCOUNT_ID_PREFIX "%s", 
-               tny_account_get_id (account));
+               account_name);
        tny_account_set_id (TNY_ACCOUNT(tny_account), account_id);
        g_free (account_id);
        
index 02d6611..a2d7dca 100644 (file)
@@ -79,7 +79,7 @@ TnyAccount* modest_tny_account_new_for_local_folders (ModestAccountMgr *account_
 /**
  * modest_tny_account_new_for_per_account_local_outbox_folder:
  * @account_mgr: a valid account mgr instance
- * @account: a valid account instance
+ * @account_name: a modest account name.
  * @session: a tny camel session
  * 
  * get the per-account local outbox folder (pseudo) account.
@@ -87,7 +87,7 @@ TnyAccount* modest_tny_account_new_for_local_folders (ModestAccountMgr *account_
  * Returns: a new per-account local outbox folder TnyAccount or NULL in case of error.
  */
 TnyAccount* modest_tny_account_new_for_per_account_local_outbox_folder (
-       ModestAccountMgr *account_mgr, TnyAccount *account,
+       ModestAccountMgr *account_mgr, const gchar* account_name,
        TnySessionCamel *session);
        
 /**
@@ -95,7 +95,7 @@ TnyAccount* modest_tny_account_new_for_per_account_local_outbox_folder (
  * @self: a TnyAccount
  * @special_type: the special folder to get
  * 
- * get the special (Inbox,Outbox,Sent,Draft etc.) folder for this account
+ * get the special (Inbox,Outbox,Sent,Draft etc.) folder for this server account's parent modest account.
  * Note: currently, the implementation will always return a local folder for this.
  * This can be changed later to return really account-specific special folders,
  * such as (for example) server-side Sent/Junk mail for IMAP accounts