* src/dbus_api/modest-dbus-callbacks.c:
authorJose Dapena Paz <jdapena@igalia.com>
Thu, 18 Oct 2007 10:20:25 +0000 (10:20 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 18 Oct 2007 10:20:25 +0000 (10:20 +0000)
* Now get_folders method also obtains folders from mmc
  (fixes NB#65058).
* src/modest-tny-account-store.[ch]:
* Added new method to obtain the mmc account.

pmo-trunk-r3527

src/dbus_api/modest-dbus-callbacks.c
src/modest-tny-account-store.c
src/modest-tny-account-store.h

index 07b1f96..ac7c768 100644 (file)
@@ -1477,18 +1477,21 @@ static void
 on_dbus_method_get_folders (DBusConnection *con, DBusMessage *message)
 {
        DBusMessage  *reply = NULL;
 on_dbus_method_get_folders (DBusConnection *con, DBusMessage *message)
 {
        DBusMessage  *reply = NULL;
+       ModestAccountMgr *account_mgr = NULL;
+       gchar *account_name = NULL;
+       GList *folder_names = NULL;     
+       TnyAccount *account_local = NULL;
+       TnyAccount *account_mmc = NULL;
        
        /* Get the TnyStoreAccount so we can get the folders: */
        
        /* Get the TnyStoreAccount so we can get the folders: */
-       ModestAccountMgr *account_mgr = modest_runtime_get_account_mgr();
-       gchar *account_name = modest_account_mgr_get_default_account (account_mgr);
+       account_mgr = modest_runtime_get_account_mgr();
+       account_name = modest_account_mgr_get_default_account (account_mgr);
        if (!account_name) {
                g_printerr ("modest: no account found\n");
        }
        
        if (!account_name) {
                g_printerr ("modest: no account found\n");
        }
        
-       GList *folder_names = NULL;
-       
-       TnyAccount *account = NULL;
        if (account_name) {
        if (account_name) {
+               TnyAccount *account = NULL;
                if (account_mgr) {
                        account = modest_tny_account_store_get_server_account (
                                modest_runtime_get_account_store(), account_name, 
                if (account_mgr) {
                        account = modest_tny_account_store_get_server_account (
                                modest_runtime_get_account_store(), account_name, 
@@ -1513,13 +1516,22 @@ on_dbus_method_get_folders (DBusConnection *con, DBusMessage *message)
         * because they are (currently) used with all accounts:
         * TODO: This is not working. It seems to get only the Merged Folder (with an ID of "" (not NULL)).
         */
         * because they are (currently) used with all accounts:
         * TODO: This is not working. It seems to get only the Merged Folder (with an ID of "" (not NULL)).
         */
-       TnyAccount *account_local = 
+       account_local = 
                modest_tny_account_store_get_local_folders_account (modest_runtime_get_account_store());
        add_folders_to_list (TNY_FOLDER_STORE (account_local), &folder_names);
 
        g_object_unref (account_local);
        account_local = NULL;
 
                modest_tny_account_store_get_local_folders_account (modest_runtime_get_account_store());
        add_folders_to_list (TNY_FOLDER_STORE (account_local), &folder_names);
 
        g_object_unref (account_local);
        account_local = NULL;
 
+       /* Obtain the mmc account */
+       account_mmc = 
+               modest_tny_account_store_get_mmc_folders_account (modest_runtime_get_account_store());
+       if (account_mmc) {
+               add_folders_to_list (TNY_FOLDER_STORE (account_mmc), &folder_names);
+               g_object_unref (account_mmc);
+               account_mmc = NULL;
+       }
+
        /* specs require us to sort the folder names, although
         * this is really not the place to do that...
         */
        /* specs require us to sort the folder names, although
         * this is really not the place to do that...
         */
index 3a08292..94b1f46 100644 (file)
@@ -1437,6 +1437,16 @@ modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self)
        return account;
 }
 
        return account;
 }
 
+TnyAccount*
+modest_tny_account_store_get_mmc_folders_account (ModestTnyAccountStore *self)
+{
+       g_return_val_if_fail (MODEST_IS_TNY_ACCOUNT_STORE (self), NULL);
+       
+       return modest_tny_account_store_get_tny_account_by (self, MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
+                                                           MODEST_MMC_ACCOUNT_ID);
+
+}
+
 /*********************************************************************************/
 static void
 add_existing_accounts (ModestTnyAccountStore *self)
 /*********************************************************************************/
 static void
 add_existing_accounts (ModestTnyAccountStore *self)
index b116c71..4c326be 100644 (file)
@@ -169,6 +169,16 @@ TnySessionCamel*    modest_tny_account_store_get_session    (TnyAccountStore *se
  **/
 TnyAccount * modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self);
 
  **/
 TnyAccount * modest_tny_account_store_get_local_folders_account (ModestTnyAccountStore *self);
 
+/**
+ * modest_tny_account_store_get_mmc_folders_account:
+ * @self: a TnyAccountStore instance
+ * 
+ * Get the mmc folders account.
+ *
+ * Returns: a #TnyAccount, or %NULL if no mmc account is available now.
+ */
+TnyAccount * modest_tny_account_store_get_mmc_folders_account (ModestTnyAccountStore *self);
+
 /** modest_tny_account_store_forget_already_asked:
   * @self: a TnyAccountStore instance
   * @account: the account to forget the already asked status for
 /** modest_tny_account_store_forget_already_asked:
   * @self: a TnyAccountStore instance
   * @account: the account to forget the already asked status for