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
/* 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) {
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);
}
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;
}
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) {
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;
}
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;
}
check(found == 0);
camel_folder_free_uids(folder, s);
+ pull();
camel_exception_free(ex);
} 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();
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");
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();
}
/* 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();
int indexed, max;
GPtrArray *uids;
CamelMessageInfo *info;
- char *mailbox;
-
- if (spool)
- mailbox = "INBOX";
- else
- mailbox = "testbox";
max=local?2:1;
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);
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");
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);
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();
}