2007-04-30 Murray Cumming <murrayc@murrayc.com>
authorMurray Cumming <murrayc@murrayc.com>
Mon, 30 Apr 2007 11:51:00 +0000 (11:51 +0000)
committerMurray Cumming <murrayc@murrayc.com>
Mon, 30 Apr 2007 11:51:00 +0000 (11:51 +0000)
* src/modest-account-mgr-helpers.c:
        (modest_account_mgr_get_account_data): Add a more helpful error message, and comment,
        for the case that the account does not exist.

        * src/widgets/modest-folder-view.c: (filter_row): Use the tinymail account ID
        (equivalent to the modest account name) rather than the tinymail account name
        (equivalent to the modest account title - human readable) to get the account data.
        Check for null account data to prevent the crash, and add a TODO comment saying that
        this needs fixing because it is using the server account name instead of the account name.

pmo-trunk-r1721

ChangeLog2
src/modest-account-mgr-helpers.c
src/widgets/modest-folder-view.c

index af242f6..39c19a5 100644 (file)
@@ -1,3 +1,15 @@
+2007-04-30  Murray Cumming  <murrayc@murrayc.com>
+
+       * src/modest-account-mgr-helpers.c:
+       (modest_account_mgr_get_account_data): Add a more helpful error message, and comment, 
+       for the case that the account does not exist.
+       
+       * src/widgets/modest-folder-view.c: (filter_row): Use the tinymail account ID 
+       (equivalent to the modest account name) rather than the tinymail account name 
+       (equivalent to the modest account title - human readable) to get the account data.
+       Check for null account data to prevent the crash, and add a TODO comment saying that 
+       this needs fixing because it is using the server account name instead of the account name.
+
 2007-04-29  Murray Cumming  <murrayc@murrayc.com>
 
        * src/maemo/easysetup/modest-easysetup-wizard.c: (show_error):
index a5f0460..6b2c10d 100644 (file)
@@ -446,7 +446,13 @@ modest_account_mgr_get_account_data     (ModestAccountMgr *self, const gchar* na
        
        g_return_val_if_fail (self, NULL);
        g_return_val_if_fail (name, NULL);
-       g_return_val_if_fail (modest_account_mgr_account_exists (self, name,FALSE), NULL);      
+       
+       if (!modest_account_mgr_account_exists (self, name, FALSE)) {
+               /* For instance, maybe you are mistakenly checking for a server account name? */
+               g_warning ("%s: Account %s does not exist.", __FUNCTION__, name);
+               return NULL;
+       }
+       
        data = g_slice_new0 (ModestAccountData);
        
        data->account_name = g_strdup (name);
index 3ce3072..a698c79 100644 (file)
@@ -666,17 +666,23 @@ filter_row (GtkTreeModel *model,
                ModestAccountMgr *mgr;
 
                acc = TNY_ACCOUNT (instance);
-               account_id = tny_account_get_id (acc);
+               account_id = tny_account_get_id (acc); /* Non human-readable name, not the title */
                mgr = modest_runtime_get_account_mgr ();
-               acc_data = modest_account_mgr_get_account_data (mgr, tny_account_get_name (acc));
-
-               if (strcmp (account_id, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) &&
-                   strcmp (account_id, MODEST_MMC_ACCOUNT_ID)) {
-                       /* Show only the default account */
-                       if (!acc_data->is_default)
-                               retval = FALSE;
+               
+               /* TODO: This does not work because acc is the _server_account, 
+                * and this code assumes that it is the normal account, which uses a server account.
+                * Maybe we need some way to get the parent account from the server account.
+                */
+               acc_data = modest_account_mgr_get_account_data (mgr, account_id);
+               if (acc_data) {
+                       if (strcmp (account_id, MODEST_LOCAL_FOLDERS_ACCOUNT_ID) &&
+                           strcmp (account_id, MODEST_MMC_ACCOUNT_ID)) {
+                               /* Show only the default account */
+                               if (!acc_data->is_default)
+                                       retval = FALSE;
+                       }
+                       modest_account_mgr_free_account_data (mgr, acc_data);
                }
-               modest_account_mgr_free_account_data (mgr, acc_data);
        }
 
        g_object_unref (instance);