2007-06-07 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Thu, 7 Jun 2007 12:19:30 +0000 (12:19 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Thu, 7 Jun 2007 12:19:30 +0000 (12:19 +0000)
* src/modest-tny-account-store.h:
        * src/modest-tny-account-store.c:
        Added modest_tny_account_store_get_local_folders_account().

        * src/modest-tny-folder.h:
        * src/modest-tny-folder.c:
        (modest_tny_folder_get_account):
        Added this replacement for tny_folder_get_account() which returns
        the local-folders account for TnyMergeFolders, to avoid the
        warning about the unimplemented get_account_func() vfunc().

        (modest_tny_folder_get_rules),
        * src/modest-ui-actions.c:
        (modest_ui_actions_on_folder_selection_changed):
        * src/modest-mail-operation.c:
        (modest_mail_operation_remove_folder),
        (modest_mail_operation_xfer_folder),
        (modest_mail_operation_rename_folder),
        (modest_mail_operation_get_msg),
        (modest_mail_operation_get_msgs_full),
        (modest_mail_operation_remove_msg),
        (modest_mail_operation_xfer_msgs),
        (modest_mail_operation_refresh_folder):
        Use modest_tny_folder_get_account() instead of tny_folder_get_account().

pmo-trunk-r2097

ChangeLog2
src/modest-mail-operation.c
src/modest-tny-account-store.c
src/modest-tny-account-store.h
src/modest-tny-folder.c
src/modest-tny-folder.h
src/modest-tny-simple-folder-store.c [deleted file]
src/modest-tny-simple-folder-store.h [deleted file]
src/modest-ui-actions.c

index aa7f76a..a63d8d6 100644 (file)
@@ -1,5 +1,32 @@
 2007-06-07  Murray Cumming  <murrayc@murrayc.com>
 
+       * src/modest-tny-account-store.h:
+       * src/modest-tny-account-store.c:
+       Added modest_tny_account_store_get_local_folders_account().
+       
+       * src/modest-tny-folder.h:
+       * src/modest-tny-folder.c:
+       (modest_tny_folder_get_account):
+       Added this replacement for tny_folder_get_account() which returns 
+       the local-folders account for TnyMergeFolders, to avoid the 
+       warning about the unimplemented get_account_func() vfunc().
+       
+       (modest_tny_folder_get_rules),
+       * src/modest-ui-actions.c:
+       (modest_ui_actions_on_folder_selection_changed):
+       * src/modest-mail-operation.c:
+       (modest_mail_operation_remove_folder),
+       (modest_mail_operation_xfer_folder),
+       (modest_mail_operation_rename_folder),
+       (modest_mail_operation_get_msg),
+       (modest_mail_operation_get_msgs_full),
+       (modest_mail_operation_remove_msg),
+       (modest_mail_operation_xfer_msgs),
+       (modest_mail_operation_refresh_folder):
+       Use modest_tny_folder_get_account() instead of tny_folder_get_account().
+       
+2007-06-07  Murray Cumming  <murrayc@murrayc.com>
+
        * src/modest-account-mgr-helpers.c: (get_security_for_conf_string),
        (modest_server_account_set_security): 
        * src/modest-defs.h: Add comments explaining that our 
index 78351a4..4384bf0 100644 (file)
@@ -1170,7 +1170,7 @@ modest_mail_operation_remove_folder (ModestMailOperation *self,
        }
 
        /* Get the account */
-       account = tny_folder_get_account (folder);
+       account = modest_tny_folder_get_account (folder);
        priv->account = g_object_ref(account);
 
        /* Delete folder or move to trash */
@@ -1279,7 +1279,7 @@ modest_mail_operation_xfer_folder (ModestMailOperation *self,
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
 
        /* Get account and set it into mail_operation */
-       priv->account = tny_folder_get_account (TNY_FOLDER(folder));
+       priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
 
        /* Get folder rules */
@@ -1340,7 +1340,7 @@ modest_mail_operation_rename_folder (ModestMailOperation *self,
        priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
 
        /* Get account and set it into mail_operation */
-       priv->account = tny_folder_get_account (TNY_FOLDER(folder));
+       priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
 
        /* Check folder rules */
        rules = modest_tny_folder_get_rules (TNY_FOLDER (folder));
@@ -1392,7 +1392,7 @@ void modest_mail_operation_get_msg (ModestMailOperation *self,
        /* Get message from folder */
        if (folder) {
                /* Get account and set it into mail_operation */
-               priv->account = tny_folder_get_account (TNY_FOLDER(folder));
+               priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
 
                helper = g_slice_new0 (GetMsgAsyncHelper);
                helper->mail_op = self;
@@ -1659,7 +1659,7 @@ modest_mail_operation_get_msgs_full (ModestMailOperation *self,
                iter = tny_list_create_iterator (header_list);
                header = TNY_HEADER (tny_iterator_get_current (iter));
                folder = tny_header_get_folder (header);                
-               priv->account = tny_folder_get_account (TNY_FOLDER(folder));
+               priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
                g_object_unref (header);
                g_object_unref (folder);
 
@@ -1733,7 +1733,7 @@ modest_mail_operation_remove_msg (ModestMailOperation *self,
        folder = tny_header_get_folder (header);
 
        /* Get account and set it into mail_operation */
-       priv->account = tny_folder_get_account (TNY_FOLDER(folder));
+       priv->account = modest_tny_folder_get_account (TNY_FOLDER(folder));
 
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
 
@@ -1742,7 +1742,7 @@ modest_mail_operation_remove_msg (ModestMailOperation *self,
                TnyFolder *trash_folder;
                TnyStoreAccount *store_account;
 
-               store_account = TNY_STORE_ACCOUNT (tny_folder_get_account (folder));
+               store_account = TNY_STORE_ACCOUNT (modest_tny_folder_get_account (folder));
                trash_folder = modest_tny_account_get_special_folder (TNY_ACCOUNT(store_account),
                                                                      TNY_FOLDER_TYPE_TRASH);
                if (trash_folder) {
@@ -1917,7 +1917,7 @@ modest_mail_operation_xfer_msgs (ModestMailOperation *self,
        g_object_unref (iter);
 
        /* Get account and set it into mail_operation */
-       priv->account = tny_folder_get_account (src_folder);
+       priv->account = modest_tny_folder_get_account (src_folder);
 
        /* Transfer messages */
        tny_folder_transfer_msgs_async (src_folder, 
@@ -2004,7 +2004,7 @@ modest_mail_operation_refresh_folder  (ModestMailOperation *self,
        priv->status = MODEST_MAIL_OPERATION_STATUS_IN_PROGRESS;
 
        /* Get account and set it into mail_operation */
-       priv->account = tny_folder_get_account (folder);
+       priv->account = modest_tny_folder_get_account  (folder);
 
        /* Refresh the folder. TODO: tinymail could issue a status
           updates before the callback call then this could happen. We
index 81f573c..7733aa8 100644 (file)
@@ -1254,3 +1254,27 @@ gboolean modest_tny_account_is_virtual_local_folders (TnyAccount *self)
         * for anything else. */
        return MODEST_IS_TNY_LOCAL_FOLDERS_ACCOUNT (self);
 }
+
+TnyAccount* modest_tny_account_store_get_local_folders_account (TnyAccountStore *self)
+{
+       TnyAccount *account = NULL;
+       ModestTnyAccountStorePrivate *priv;     
+       GSList *cursor;
+
+       g_return_val_if_fail (self, NULL);
+       
+       priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+
+       for (cursor = priv->store_accounts; cursor ; cursor = cursor->next) {
+               TnyAccount *this_account = TNY_ACCOUNT(cursor->data);
+               if (modest_tny_account_is_virtual_local_folders (this_account)) {
+                                account = this_account;
+                                break;
+               }
+       }
+
+       if (account)
+               g_object_ref (G_OBJECT(account));
+       
+       return account;
+}
index 17018a3..2e5cbb3 100644 (file)
@@ -150,6 +150,12 @@ TnyAccount* modest_tny_account_store_get_transport_account_for_open_connection (
  */
 TnySessionCamel*    modest_tny_account_store_get_session    (TnyAccountStore *self);
 
+/** modest_tny_account_store_get_local_folders_account:
+ * @self: a TnyAccountStore instance
+ * 
+ * Get the user-visible local folders account.
+ **/
+TnyAccount * modest_tny_account_store_get_local_folders_account (TnyAccountStore *self);
 
 /** modest_tny_account_is_virtual_local_folders:
  * @self A TnyAccount.
index f5e1e0d..f4c0014 100644 (file)
@@ -36,6 +36,8 @@
 #include <tny-merge-folder.h>
 #include <camel/camel-folder.h>
 #include <modest-protocol-info.h>
+#include <modest-runtime.h>
+#include <modest-tny-account-store.h>
 
 TnyFolderType
 modest_tny_folder_guess_folder_type_from_name (const gchar* name)
@@ -143,7 +145,7 @@ modest_tny_folder_get_rules   (TnyFolder *folder)
        } else {
                ModestTransportStoreProtocol proto;
                TnyAccount *account =
-                       tny_folder_get_account ((TnyFolder*)folder);
+                       modest_tny_folder_get_account ((TnyFolder*)folder);
                if (!account)
                        return -1; /* no account: nothing is allowed */
                
@@ -302,3 +304,22 @@ modest_tny_folder_get_header_unique_id (TnyHeader *header)
 
        return retval;
 }
+
+TnyAccount *modest_tny_folder_get_account (TnyFolder *folder)
+{
+       TnyAccount *account = NULL;
+       
+       if (TNY_IS_MERGE_FOLDER (folder)) {
+               /* TnyMergeFolder does not support get_account(), 
+                * because it could be merging folders from multiple accounts.
+                * So we assume that this is the local folders account: */
+                
+               account = modest_tny_account_store_get_local_folders_account (
+                       TNY_ACCOUNT_STORE (modest_runtime_get_account_store()));
+       } else {
+               account = tny_folder_get_account (folder);
+       }
+       
+       return account;
+}
+
index 1997d17..02d2299 100644 (file)
@@ -130,6 +130,17 @@ ModestTnyFolderRules  modest_tny_folder_get_rules   (TnyFolder *folder);
  */
 gboolean modest_tny_folder_is_outbox_for_account (TnyFolder *folder, 
                                                  TnyAccount *account);
+                                       
+/**
+ * modest_tny_folder_get_account:
+ * @folder: a folder
+ * 
+ * Get the parent account of the folder or, for TnyMergeFolder 
+ * instances, get the local-folders account.
+ *  
+ * Returns: the account. You should call g_object_unref() on this.
+ */      
+TnyAccount *modest_tny_folder_get_account (TnyFolder *folder);
 
 /**
  * modest_tny_msg_get_header_unique_id:
diff --git a/src/modest-tny-simple-folder-store.c b/src/modest-tny-simple-folder-store.c
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/src/modest-tny-simple-folder-store.h b/src/modest-tny-simple-folder-store.h
deleted file mode 100644 (file)
index e69de29..0000000
index 19c2619..8715a8f 100644 (file)
@@ -1240,7 +1240,7 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
                        
                        if (!TNY_IS_MERGE_FOLDER (folder_store)) { /* TnyMergeFolder can have no get_account() implementation. */
                                /* Update the active account */
-                               TnyAccount *account = tny_folder_get_account (TNY_FOLDER (folder_store));
+                               TnyAccount *account = modest_tny_folder_get_account (TNY_FOLDER (folder_store));
                                set_active_account_from_tny_account (account, MODEST_WINDOW (main_window));
                                g_object_unref (account);
                        }