diff options
author | Not Zed <NotZed@Ximian.com> | 2002-09-04 16:13:38 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2002-09-04 16:13:38 +0800 |
commit | a52720a9213d760bb8a9c21b354ab46de7b763dd (patch) | |
tree | 984be336497cf1bca255d02a0ea00428ed9e3924 | |
parent | d27b52023b0ed91a777bc838e4f9b898ca7e2201 (diff) | |
download | gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.tar gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.tar.gz gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.tar.bz2 gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.tar.lz gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.tar.xz gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.tar.zst gsoc2013-evolution-a52720a9213d760bb8a9c21b354ab46de7b763dd.zip |
clear nonfatal stuff.
2002-09-04 Not Zed <NotZed@Ximian.com>
* tests/folder/test4.c (main): clear nonfatal stuff.
* tests/folder/test6.c (main): check inbox and 'another folder'
because some servers do different things w/ inbox.
* providers/imap/camel-imap-message-cache.c
(camel_imap_message_cache_get): Dont try to open the directory
instead of an empty "" uid.
* providers/imap/camel-imap-folder.c (imap_get_message): we dont
want to g_return_if_fail, we need to set an exception and always
handle the case.
(get_message_simple): Set an exception if we get a construct
failure.
(imap_refresh_info): if we're refreshing inbox, force a reselect.
this is required for at least cryus. CHECK doesnt work either :(
* tests/lib/folders.c (test_folder_basic): for non-local stores,
the folder will have an extra ref for selection, take this into
account when checking ref leaks.
(test_folder_message_ops): Dont try to delete folder with messages
in it, it works generally with imap. also, change params so we
can test different mailbox types.
(test_folder_message_ops): disconnect remote services before
finishing off. doesn't need to stricly but makes ref count
checking more accurate.
(test_folder_message_ops): removed explicit remote sync, imap does
it itself now ...
* providers/imap/camel-imap-store.c:
(camel_imap_store_finalize): call service_disconnect, so it isn't
called later in the finalise chain, to properly cleanup on exit.
svn path=/trunk/; revision=17962
-rw-r--r-- | camel/ChangeLog | 33 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-folder.c | 23 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-message-cache.c | 3 | ||||
-rw-r--r-- | camel/providers/imap/camel-imap-store.c | 12 | ||||
-rw-r--r-- | camel/tests/folder/test2.c | 4 | ||||
-rw-r--r-- | camel/tests/folder/test4.c | 4 | ||||
-rw-r--r-- | camel/tests/folder/test6.c | 5 | ||||
-rw-r--r-- | camel/tests/folder/test7.c | 2 | ||||
-rw-r--r-- | camel/tests/lib/folders.c | 94 | ||||
-rw-r--r-- | camel/tests/lib/folders.h | 2 |
10 files changed, 137 insertions, 45 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 44a7c1b560..c362124039 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,5 +1,38 @@ 2002-09-04 Not Zed <NotZed@Ximian.com> + * tests/folder/test4.c (main): clear nonfatal stuff. + + * tests/folder/test6.c (main): check inbox and 'another folder' + because some servers do different things w/ inbox. + + * providers/imap/camel-imap-message-cache.c + (camel_imap_message_cache_get): Dont try to open the directory + instead of an empty "" uid. + + * providers/imap/camel-imap-folder.c (imap_get_message): we dont + want to g_return_if_fail, we need to set an exception and always + handle the case. + (get_message_simple): Set an exception if we get a construct + failure. + (imap_refresh_info): if we're refreshing inbox, force a reselect. + this is required for at least cryus. CHECK doesnt work either :( + + * tests/lib/folders.c (test_folder_basic): for non-local stores, + the folder will have an extra ref for selection, take this into + account when checking ref leaks. + (test_folder_message_ops): Dont try to delete folder with messages + in it, it works generally with imap. also, change params so we + can test different mailbox types. + (test_folder_message_ops): disconnect remote services before + finishing off. doesn't need to stricly but makes ref count + checking more accurate. + (test_folder_message_ops): removed explicit remote sync, imap does + it itself now ... + + * providers/imap/camel-imap-store.c: + (camel_imap_store_finalize): call service_disconnect, so it isn't + called later in the finalise chain, to properly cleanup on exit. + * camel-mime-parser.c (folder_scan_content): If we fake the from eof file boundary, also make sure we say we matched nothing. Also make the end case a little more robust to make sure we expired all diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c index ef5cec4656..1a2f5a79e9 100644 --- a/camel/providers/imap/camel-imap-folder.c +++ b/camel/providers/imap/camel-imap-folder.c @@ -478,9 +478,12 @@ imap_refresh_info (CamelFolder *folder, CamelException *ex) /* If the folder isn't selected, select it (which will force * a rescan if one is needed). - */ + * Also, if this is the INBOX, some servers (cryus) wont tell + * us with a NOOP of new messages, so force a reselect which + * should do it. */ CAMEL_SERVICE_LOCK (imap_store, connect_lock); - if (imap_store->current_folder != folder) { + if (imap_store->current_folder != folder + || strcasecmp(folder->full_name, "INBOX") == 0) { CAMEL_SERVICE_UNLOCK (imap_store, connect_lock); response = camel_imap_command (imap_store, folder, ex, NULL); if (response) { @@ -498,6 +501,14 @@ imap_refresh_info (CamelFolder *folder, CamelException *ex) if (imap_folder->need_rescan) imap_rescan (folder, camel_folder_summary_count (folder->summary), ex); else { +#if 0 + /* on some servers need to CHECKpoint INBOX to recieve new messages?? */ + /* rfc2060 suggests this, but havent seen a server that requires it */ + if (strcasecmp(folder->full_name, "INBOX") == 0) { + response = camel_imap_command (imap_store, folder, ex, "CHECK"); + camel_imap_response_free (imap_store, response); + } +#endif response = camel_imap_command (imap_store, folder, ex, "NOOP"); camel_imap_response_free (imap_store, response); } @@ -1853,6 +1864,8 @@ get_message_simple (CamelImapFolder *imap_folder, const char *uid, stream); camel_object_unref (CAMEL_OBJECT (stream)); if (ret == -1) { + camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, + _("Unable to retrieve message: %s"), strerror(errno)); camel_object_unref (CAMEL_OBJECT (msg)); return NULL; } @@ -1886,7 +1899,11 @@ imap_get_message (CamelFolder *folder, const char *uid, CamelException *ex) return NULL; mi = camel_folder_summary_uid (folder->summary, uid); - g_return_val_if_fail (mi != NULL, NULL); + if (mi == NULL) { + camel_exception_setv(ex, CAMEL_EXCEPTION_FOLDER_INVALID_UID, + _("Cannot get message: %s\n %s"), uid, _("No such message")); + return NULL; + } /* If the message is small, fetch it in one piece. */ if (mi->size < IMAP_SMALL_BODY_SIZE) { diff --git a/camel/providers/imap/camel-imap-message-cache.c b/camel/providers/imap/camel-imap-message-cache.c index b29a2280ef..0701ca45e4 100644 --- a/camel/providers/imap/camel-imap-message-cache.c +++ b/camel/providers/imap/camel-imap-message-cache.c @@ -395,6 +395,9 @@ camel_imap_message_cache_get (CamelImapMessageCache *cache, const char *uid, CamelStream *stream; char *path, *key; + if (uid[0] == 0) + return NULL; + path = g_strdup_printf ("%s/%s.%s", cache->path, uid, part_spec); key = strrchr (path, '/') + 1; stream = g_hash_table_lookup (cache->parts, key); diff --git a/camel/providers/imap/camel-imap-store.c b/camel/providers/imap/camel-imap-store.c index 7eb3c3accb..af4192e0c6 100644 --- a/camel/providers/imap/camel-imap-store.c +++ b/camel/providers/imap/camel-imap-store.c @@ -179,20 +179,14 @@ camel_imap_store_finalize (CamelObject *object) { CamelImapStore *imap_store = CAMEL_IMAP_STORE (object); + /* This frees current_folder, folders, authtypes, streams, and namespace. */ + camel_service_disconnect((CamelService *)imap_store, TRUE, NULL); + if (imap_store->summary) { camel_store_summary_save((CamelStoreSummary *)imap_store->summary); camel_object_unref(imap_store->summary); } - if (imap_store->istream) - camel_object_unref (CAMEL_OBJECT (imap_store->istream)); - - if (imap_store->ostream) - camel_object_unref (CAMEL_OBJECT (imap_store->ostream)); - - /* This frees current_folder, folders, authtypes, and namespace. */ - imap_disconnect_offline (CAMEL_SERVICE (object), FALSE, NULL); - if (imap_store->base_url) g_free (imap_store->base_url); if (imap_store->storage_path) diff --git a/camel/tests/folder/test2.c b/camel/tests/folder/test2.c index 50a89f89e8..afd35b1704 100644 --- a/camel/tests/folder/test2.c +++ b/camel/tests/folder/test2.c @@ -44,12 +44,12 @@ int main(int argc, char **argv) for (i=0;i<ARRAY_LEN(stores);i++) { char *name = stores[i]; - test_folder_message_ops(session, name, TRUE, FALSE); + test_folder_message_ops(session, name, TRUE, "testbox"); } /* create a pseudo-spool file, and check that */ creat("/tmp/camel-test/testbox", 0600); - test_folder_message_ops(session, "spool:///tmp/camel-test/testbox", FALSE, TRUE); + test_folder_message_ops(session, "spool:///tmp/camel-test/testbox", FALSE, "INBOX"); check_unref(session, 1); camel_exception_free(ex); diff --git a/camel/tests/folder/test4.c b/camel/tests/folder/test4.c index eb0bd3420b..e6c58e023d 100644 --- a/camel/tests/folder/test4.c +++ b/camel/tests/folder/test4.c @@ -41,9 +41,9 @@ int main(int argc, char **argv) /* tells make check to ignore us in the total count */ _exit(77); } - camel_test_nonfatal("The IMAP code is just rooted"); + /*camel_test_nonfatal("The IMAP code is just rooted");*/ test_folder_basic(session, path, FALSE, FALSE); - camel_test_fatal(); + /*camel_test_fatal();*/ } camel_object_unref((CamelObject *)session); diff --git a/camel/tests/folder/test6.c b/camel/tests/folder/test6.c index 215fa999bf..f0fd8a25ee 100644 --- a/camel/tests/folder/test6.c +++ b/camel/tests/folder/test6.c @@ -1,7 +1,7 @@ /* folder testing */ #include "camel-test.h" -#include "messages.h" +#include "folders.h" #include "session.h" #include <camel/camel-exception.h> @@ -44,7 +44,8 @@ int main(int argc, char **argv) _exit(77); } /*camel_test_nonfatal("The IMAP code is just rooted");*/ - test_folder_message_ops(session, path, FALSE); + test_folder_message_ops(session, path, FALSE, "testbox"); + test_folder_message_ops(session, path, FALSE, "INBOX"); /*camel_test_fatal();*/ } diff --git a/camel/tests/folder/test7.c b/camel/tests/folder/test7.c index 2f08712e4c..3dee12916d 100644 --- a/camel/tests/folder/test7.c +++ b/camel/tests/folder/test7.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) _exit(77); } camel_test_nonfatal("Dont know how many tests apply to NNTP"); - test_folder_message_ops(session, path, FALSE); + test_folder_message_ops(session, path, FALSE, "testbox"); camel_test_fatal(); } diff --git a/camel/tests/lib/folders.c b/camel/tests/lib/folders.c index e7de6b2397..a670576564 100644 --- a/camel/tests/lib/folders.c +++ b/camel/tests/lib/folders.c @@ -146,19 +146,24 @@ test_folder_not_message(CamelFolder *folder, const char *uid) CamelException *ex = camel_exception_new(); int found; - push("uid %s is not in folder", uid); + push("uid '%s' is not in folder", uid); /* first try getting info */ + push("no message info"); info = camel_folder_get_message_info(folder, uid); check(info == NULL); + pull(); /* then, getting message */ + push("no message"); msg = camel_folder_get_message(folder, uid, ex); check(camel_exception_is_set(ex)); check(msg == NULL); camel_exception_clear(ex); + pull(); /* see if it is not in the summary (only once) */ + push("not in summary list"); s = camel_folder_get_summary(folder); check(s != NULL); found = 0; @@ -169,8 +174,10 @@ test_folder_not_message(CamelFolder *folder, const char *uid) } check(found == 0); camel_folder_free_summary(folder, s); + pull(); /* check it is not in the uid list */ + push("not in uid list"); s = camel_folder_get_uids(folder); check(s != NULL); found = 0; @@ -180,6 +187,7 @@ test_folder_not_message(CamelFolder *folder, const char *uid) } check(found == 0); camel_folder_free_uids(folder, s); + pull(); camel_exception_free(ex); @@ -215,7 +223,7 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s } else { check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + check_unref(folder, 2); } pull(); @@ -231,14 +239,20 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s folder = camel_store_get_folder(store, "testbox", CAMEL_STORE_FOLDER_CREATE, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); push("getting an existing folder"); folder = camel_store_get_folder(store, "testbox", 0, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); push("renaming a non-existant folder"); @@ -263,7 +277,10 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s folder = camel_store_get_folder(store, "testbox2", 0, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); } @@ -298,7 +315,7 @@ test_folder_basic(CamelSession *session, const char *storename, int local, int s /* todo: cross-check everything with folder_info checks as well */ /* this should probably take a folder instead of a session ... */ void -test_folder_message_ops(CamelSession *session, const char *name, int local, int spool) +test_folder_message_ops(CamelSession *session, const char *name, int local, const char *mailbox) { CamelStore *store; CamelException *ex = camel_exception_new(); @@ -308,12 +325,6 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int int indexed, max; GPtrArray *uids; CamelMessageInfo *info; - char *mailbox; - - if (spool) - mailbox = "INBOX"; - else - mailbox = "testbox"; max=local?2:1; @@ -336,6 +347,16 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int else flags = CAMEL_STORE_FOLDER_CREATE; folder = camel_store_get_folder(store, mailbox, flags, ex); + + /* we can't create mailbox outside of namespace, since we have no api for it, try + using inbox namespace, works for courier */ + if (folder == NULL) { + char *mbox = g_strdup_printf("INBOX/%s", mailbox); + mailbox = mbox; + camel_exception_clear(ex); + folder = camel_store_get_folder(store, mailbox, flags, ex); + } + check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); check(folder != NULL); @@ -361,6 +382,7 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int camel_folder_append_message(folder, msg, NULL, NULL, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); +#if 0 /* sigh, this shouldn't be required, but the imap code is too dumb to do it itself */ if (!local) { push("forcing a refresh of folder updates"); @@ -368,44 +390,56 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); pull(); } - - if (!local) - camel_test_nonfatal("unread counts dont seem right for imap"); +#endif + /*if (!local) + camel_test_nonfatal("unread counts dont seem right for imap");*/ test_folder_counts(folder, j+1, j+1); - if (!local) - camel_test_fatal(); + /*if (!local) + camel_test_fatal();*/ push("checking it is in the right uid slot & exists"); uids = camel_folder_get_uids(folder); check(uids != NULL); check(uids->len == j+1); - test_folder_message(folder, uids->pdata[j]); + if (uids->len > j) + test_folder_message(folder, uids->pdata[j]); pull(); push("checking it is the right message (subject): %s", subject); - info = camel_folder_get_message_info(folder, uids->pdata[j]); - check_msg(strcmp(camel_message_info_subject(info), subject)==0, - "info->subject %s", camel_message_info_subject(info)); + if (uids->len > j) { + info = camel_folder_get_message_info(folder, uids->pdata[j]); + check(info != NULL); + check_msg(strcmp(camel_message_info_subject(info), subject)==0, + "info->subject %s", camel_message_info_subject(info)); + camel_folder_free_message_info(folder, info); + } camel_folder_free_uids(folder, uids); - camel_folder_free_message_info(folder, info); pull(); test_free(subject); + /*if (!local) + camel_test_fatal();*/ + check_unref(msg, 1); pull(); } - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); +#if 0 push("deleting test folder, with messages in it"); camel_store_delete_folder(store, mailbox, ex); check(camel_exception_is_set(ex)); camel_exception_clear(ex); pull(); +#endif push("re-opening folder"); folder = camel_store_get_folder(store, mailbox, flags, ex); @@ -506,16 +540,26 @@ test_folder_message_ops(CamelSession *session, const char *name, int local, int camel_folder_free_uids(folder, uids); pull(); - check_unref(folder, 1); + if (local) + check_unref(folder, 1); + else + check_unref(folder, 2); pull(); /* re-opening folder */ - if (!spool) { + if (strcasecmp(mailbox, "INBOX") != 0) { push("deleting test folder, with no messages in it"); camel_store_delete_folder(store, mailbox, ex); check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); pull(); } + if (!local) { + push("disconneect service"); + camel_service_disconnect((CamelService *)store, TRUE, ex); + check_msg(!camel_exception_is_set(ex), "%s", camel_exception_get_description(ex)); + pull(); + } + check_unref(store, 1); camel_test_end(); } diff --git a/camel/tests/lib/folders.h b/camel/tests/lib/folders.h index d3c9686dc2..ae981611d3 100644 --- a/camel/tests/lib/folders.h +++ b/camel/tests/lib/folders.h @@ -17,4 +17,4 @@ void test_folder_not_message(CamelFolder *folder, const char *uid); /* test basic folder ops on a store */ void test_folder_basic(CamelSession *session, const char *storename, int local, int spool); /* test basic message operations on a folder */ -void test_folder_message_ops(CamelSession *session, const char *storename, int local, int spool); +void test_folder_message_ops(CamelSession *session, const char *storename, int local, const char *foldername); |