From 622a810e13a3b84ecff6c620ae39c3828ea3214e Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Tue, 3 Jul 2007 10:05:33 +0000 Subject: [PATCH] 2007-07-03 Murray Cumming (modest_tny_account_store_get_tny_account_by): Do not allow accounts to be found by their display name. This is never useful. * src/modest-tny-account-store.c: (on_account_removed): Find the account by its ID, instead of trying to use its ID as its display name. * src/modest-tny-account-store.h: * src/modest-tny-account.c: (modest_tny_account_get_special_folder): Add a g_warning() when tny_folder_store_get_folders() returns an empty list for the maildir. * src/modest-tny-send-queue.c: (modest_tny_send_queue_get_outbox): Add a g_warning() when this returns NULL, because that it not allowed by tinymail. pmo-trunk-r2544 --- ChangeLog2 | 16 ++++++++++++++++ src/modest-tny-account-store.c | 19 ++++++++++++------- src/modest-tny-account-store.h | 1 - src/modest-tny-account.c | 21 ++++++++++++++++++++- src/modest-tny-send-queue.c | 6 ++++++ 5 files changed, 54 insertions(+), 9 deletions(-) diff --git a/ChangeLog2 b/ChangeLog2 index 8cd38dd..badf363 100644 --- a/ChangeLog2 +++ b/ChangeLog2 @@ -1,3 +1,19 @@ +2007-07-03 Murray Cumming + + (modest_tny_account_store_get_tny_account_by): Do not allow accounts to + be found by their display name. This is never useful. + * src/modest-tny-account-store.c: (on_account_removed): Find the account + by its ID, instead of trying to use its ID as its display name. + + * src/modest-tny-account-store.h: + * src/modest-tny-account.c: + (modest_tny_account_get_special_folder): Add a g_warning() when + tny_folder_store_get_folders() returns an empty list for the maildir. + + * src/modest-tny-send-queue.c: (modest_tny_send_queue_get_outbox): + Add a g_warning() when this returns NULL, because that it not allowed + by tinymail. + 2007-07-02 Armin Burgmeier * src/maemo/easysetup/modest-easysetup-wizard.c: Added a confirmation diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index b4119dc..73fe5b7 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -344,7 +344,7 @@ on_account_removed (ModestAccountMgr *acc_mgr, /* Clear the account cache */ store_account = modest_tny_account_store_get_tny_account_by (self, - MODEST_TNY_ACCOUNT_STORE_QUERY_NAME, + MODEST_TNY_ACCOUNT_STORE_QUERY_ID, account); if (store_account) { tny_store_account_delete_cache (TNY_STORE_ACCOUNT (store_account)); @@ -1164,9 +1164,6 @@ modest_tny_account_store_get_tny_account_by (ModestTnyAccountStore *self, case MODEST_TNY_ACCOUNT_STORE_QUERY_ID: val = tny_account_get_id (TNY_ACCOUNT(cursor->data)); break; - case MODEST_TNY_ACCOUNT_STORE_QUERY_NAME: - val = modest_tny_account_get_parent_modest_account_name_for_server_account (TNY_ACCOUNT(cursor->data)); - break; case MODEST_TNY_ACCOUNT_STORE_QUERY_URL: val = tny_account_get_url_string (TNY_ACCOUNT(cursor->data)); break; @@ -1190,9 +1187,6 @@ modest_tny_account_store_get_tny_account_by (ModestTnyAccountStore *self, case MODEST_TNY_ACCOUNT_STORE_QUERY_ID: val = tny_account_get_id (TNY_ACCOUNT(cursor->data)); break; - case MODEST_TNY_ACCOUNT_STORE_QUERY_NAME: - val = tny_account_get_name (TNY_ACCOUNT(cursor->data)); - break; case MODEST_TNY_ACCOUNT_STORE_QUERY_URL: val = tny_account_get_url_string (TNY_ACCOUNT(cursor->data)); break; @@ -1212,6 +1206,17 @@ modest_tny_account_store_get_tny_account_by (ModestTnyAccountStore *self, end: if (account) g_object_ref (G_OBJECT(account)); + else { + /* Warn if nothing was found. This is generally unusual. */ + switch (type) { + case MODEST_TNY_ACCOUNT_STORE_QUERY_ID: + g_warning("%s: Failed to find account with ID=%s\n", __FUNCTION__, str); + break; + case MODEST_TNY_ACCOUNT_STORE_QUERY_URL: + g_warning("%s: Failed to find account with URL=%s\n", __FUNCTION__, str); + break; + } + } return account; } diff --git a/src/modest-tny-account-store.h b/src/modest-tny-account-store.h index 50dc0b8..6b01a28 100644 --- a/src/modest-tny-account-store.h +++ b/src/modest-tny-account-store.h @@ -79,7 +79,6 @@ struct _ModestTnyAccountStoreClass { typedef enum { MODEST_TNY_ACCOUNT_STORE_QUERY_ID, - MODEST_TNY_ACCOUNT_STORE_QUERY_NAME, MODEST_TNY_ACCOUNT_STORE_QUERY_URL, } ModestTnyAccountStoreQueryType; diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index ebb0b06..8b750e3 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -83,6 +83,11 @@ modest_tny_account_get_special_folder (TnyAccount *account, local_account = modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(), MODEST_TNY_ACCOUNT_STORE_QUERY_ID, account_id); + if (!local_account) { + g_printerr ("modest: %s: modest_tny_account_store_get_tny_account_by(ID) returned NULL for %s\n", __FUNCTION__, account_id); + return NULL; + } + g_free (account_id); } else { /* Other local folders are all in one on-disk directory: */ @@ -100,9 +105,17 @@ modest_tny_account_get_special_folder (TnyAccount *account, /* There is no need to do this _async, as these are local folders. */ /* TODO: However, this seems to fail sometimes when the network is busy, - * returning an empty list. murrayc. */ + * returning an empty list. murrayc. */ tny_folder_store_get_folders (TNY_FOLDER_STORE (local_account), folders, NULL, NULL); + + if (tny_list_get_length (folders) == 0) { + gchar* url_string = tny_account_get_url_string (local_account); + g_printerr ("modest: %s: tny_folder_store_get_folders() returned an empty list for account with URL '%s'\n", + __FUNCTION__, url_string); + g_free (url_string); + } + iter = tny_list_create_iterator (folders); while (!tny_iterator_is_done (iter)) { @@ -121,6 +134,12 @@ modest_tny_account_get_special_folder (TnyAccount *account, g_object_unref (G_OBJECT (iter)); g_object_unref (G_OBJECT (local_account)); + /* + if (!special_folder) { + g_warning ("%s: Returning NULL.", __FUNCTION__); + } + */ + return special_folder; } diff --git a/src/modest-tny-send-queue.c b/src/modest-tny-send-queue.c index cefdd25..372651c 100644 --- a/src/modest-tny-send-queue.c +++ b/src/modest-tny-send-queue.c @@ -211,6 +211,12 @@ modest_tny_send_queue_get_outbox (TnySendQueue *self) } folder = modest_tny_account_get_special_folder (TNY_ACCOUNT(account), TNY_FOLDER_TYPE_OUTBOX); + + /* This vfunc's tinymail contract does not allow it to return NULL. */ + if (!folder) { + g_warning("%s: Returning NULL.\n", __FUNCTION__); + } + g_object_unref (G_OBJECT(account)); return folder; -- 1.7.9.5