From 4c0f7459e4a32b96496120a0d39edfebf5b5e474 Mon Sep 17 00:00:00 2001 From: Chenthill Palanisamy Date: Wed, 10 Feb 2010 06:09:36 +0530 Subject: [PATCH] Bug 609398 - [IMAPX] Subscriptions are not respected. --- camel/providers/imapx/camel-imapx-server.c | 1 - camel/providers/imapx/camel-imapx-store.c | 496 +++++------------------------ camel/providers/imapx/camel-imapx-store.h | 16 +- camel/providers/imapx/camel-imapx-utils.h | 2 +- 4 files changed, 96 insertions(+), 419 deletions(-) diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c index d17689f..df9a39d 100644 --- a/camel/providers/imapx/camel-imapx-server.c +++ b/camel/providers/imapx/camel-imapx-server.c @@ -3488,7 +3488,6 @@ imapx_server_get_message (CamelIMAPXServer *is, CamelFolder *folder, const gchar stream = camel_stream_fs_new_with_name(cache_file, O_RDONLY, 0); else { camel_exception_set (ex, 1, "failed to copy the tmp file"); - g_assert_not_reached (); } } else { camel_exception_setv(ex, 1, "closing tmp stream failed: %s", g_strerror(errno)); diff --git a/camel/providers/imapx/camel-imapx-store.c b/camel/providers/imapx/camel-imapx-store.c index 659626e..ec6422b 100644 --- a/camel/providers/imapx/camel-imapx-store.c +++ b/camel/providers/imapx/camel-imapx-store.c @@ -84,7 +84,41 @@ imapx_name_equal(gconstpointer a, gconstpointer b) return g_str_equal(aname, bname); } -static void imapx_construct(CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex) +static void +imapx_parse_receiving_options (CamelIMAPXStore *istore, CamelURL *url) +{ + if (camel_url_get_param (url, "use_lsub")) + istore->rec_options |= IMAPX_SUBSCRIPTIONS; + + if (camel_url_get_param (url, "override_namespace") && camel_url_get_param (url, "namespace")) { + istore->rec_options |= IMAPX_OVERRIDE_NAMESPACE; + g_free(istore->namespace); + istore->namespace = g_strdup (camel_url_get_param (url, "namespace")); + } + + if (camel_url_get_param (url, "check_all")) + istore->rec_options |= IMAPX_CHECK_ALL; + + if (camel_url_get_param (url, "check_lsub")) + istore->rec_options |= IMAPX_CHECK_LSUB; + + if (camel_url_get_param (url, "filter")) { + istore->rec_options |= IMAPX_FILTER_INBOX; + ((CamelStore *) istore)->flags |= CAMEL_STORE_FILTER_INBOX; + } + + if (camel_url_get_param (url, "filter_junk")) + istore->rec_options |= IMAPX_FILTER_JUNK; + + if (camel_url_get_param (url, "filter_junk_inbox")) + istore->rec_options |= IMAPX_FILTER_JUNK_INBOX; + + if (camel_url_get_param (url, "use_idle")) + istore->rec_options |= IMAPX_USE_IDLE; +} + +static void +imapx_construct(CamelService *service, CamelSession *session, CamelProvider *provider, CamelURL *url, CamelException *ex) { gchar *summary; CamelIMAPXStore *store = (CamelIMAPXStore *)service; @@ -93,6 +127,11 @@ static void imapx_construct(CamelService *service, CamelSession *session, CamelP if (camel_exception_is_set(ex)) return; + store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD | + CAMEL_URL_HIDE_PARAMS | + CAMEL_URL_HIDE_AUTH)); + imapx_parse_receiving_options (store, service->url); + store->summary = camel_imapx_store_summary_new(); store->storage_path = camel_session_get_storage_path(session, service, ex); if (store->storage_path) { @@ -102,15 +141,12 @@ static void imapx_construct(CamelService *service, CamelSession *session, CamelP camel_store_summary_set_uri_base((CamelStoreSummary *)store->summary, service->url); camel_store_summary_load((CamelStoreSummary *)store->summary); } - - store->base_url = camel_url_to_string (service->url, (CAMEL_URL_HIDE_PASSWORD | - CAMEL_URL_HIDE_PARAMS | - CAMEL_URL_HIDE_AUTH)); } extern CamelServiceAuthType camel_imapx_password_authtype; extern CamelServiceAuthType camel_imapx_apop_authtype; +/* TODO implement */ static GList * imapx_query_auth_types (CamelService *service, CamelException *ex) { @@ -121,63 +157,9 @@ imapx_query_auth_types (CamelService *service, CamelException *ex) if (types == NULL) return NULL; -#if 0 - if (connect_to_server_wrapper (service, NULL)) { - types = g_list_concat(types, g_list_copy(store->engine->auth)); - imapx_disconnect (service, TRUE, NULL); - } else { - camel_exception_setv (ex, CAMEL_EXCEPTION_SERVICE_UNAVAILABLE, - _("Could not connect to POP server on %s"), - service->url->host); - } -#endif return types; } -#if 0 -static void -store_get_pass(CamelIMAPXStore *store) -{ - if (((CamelService *)store)->url->passwd == NULL) { - gchar *prompt; - CamelException ex; - - camel_exception_init(&ex); - - prompt = g_strdup_printf (_("%sPlease enter the IMAP password for %s@%s"), - store->login_error?store->login_error:"", - ((CamelService *)store)->url->user, - ((CamelService *)store)->url->host); - ((CamelService *)store)->url->passwd = camel_session_get_password(camel_service_get_session((CamelService *)store), - (CamelService *)store, NULL, - prompt, "password", CAMEL_SESSION_PASSWORD_SECRET, &ex); - g_free (prompt); - if (camel_exception_is_set(&ex)) - camel_exception_throw_ex(&ex); - } -} - -static struct _CamelSasl * -store_get_sasl(struct _CamelIMAPXDriver *driver, CamelIMAPXStore *store) -{ - store_get_pass(store); - - if (((CamelService *)store)->url->authmech) - return camel_sasl_new("imap", ((CamelService *)store)->url->authmech, (CamelService *)store); - - return NULL; -} - -static void -store_get_login(struct _CamelIMAPXDriver *driver, gchar **login, gchar **pass, CamelIMAPXStore *store) -{ - store_get_pass(store); - - *login = g_strdup(((CamelService *)store)->url->user); - *pass = g_strdup(((CamelService *)store)->url->passwd); -} -#endif - static gchar * imapx_get_name (CamelService *service, gboolean brief) { @@ -340,118 +322,6 @@ imapx_get_inbox(CamelStore *store, CamelException *ex) return NULL; } -#if 0 -static CamelFolderInfo * -folders_build_info(CamelURL *base, struct _list_info *li) -{ - gchar *path, *full_name, *name; - CamelFolderInfo *fi; - - full_name = imapx_list_get_path(li); - name = strrchr(full_name, '/'); - if (name) - name++; - else - name = full_name; - - path = alloca(strlen(full_name)+2); - sprintf(path, "/%s", full_name); - camel_url_set_path(base, path); - - fi = g_malloc0(sizeof(*fi)); - fi->uri = camel_url_to_string(base, CAMEL_URL_HIDE_ALL); - fi->name = g_strdup(name); - fi->full_name = full_name; - fi->unread = -1; - fi->total = -1; - fi->flags = li->flags; - - if (!g_ascii_strcasecmp(fi->full_name, "inbox")) - fi->flags |= CAMEL_FOLDER_SYSTEM; - - /* TODO: could look up count here ... */ - /* ?? */ - /*folder = camel_object_bag_get(store->folders, "INBOX");*/ - - return fi; -} - -/* - a - a/b - a/b/c - a/d - b - c/d - -*/ - -/* note, pname is the raw name, not the folderinfo name */ -/* note also this free's as we go, since we never go 'backwards' */ -static CamelFolderInfo * -folders_build_rec(CamelURL *base, GPtrArray *folders, gint *ip, CamelFolderInfo *pfi, gchar *pname) -{ - gint plen = 0; - CamelFolderInfo *last = NULL, *first = NULL; - - if (pfi) - plen = strlen(pname); - - for (;(*ip)<(gint)folders->len;) { - CamelFolderInfo *fi; - struct _list_info *li; - - li = folders->pdata[*ip]; - printf("checking '%s' is child of '%s'\n", li->name, pname); - - /* is this a child of the parent? */ - if (pfi != NULL - && (strncmp(pname, li->name, strlen(pname)) != 0 - || li->name[plen] != li->separator)) { - printf(" nope\n"); - break; - } - printf(" yep\n"); - - /* is this not an immediate child of the parent? */ -#if 0 - gchar *p; - if (pfi != NULL - && li->separator != 0 - && (p = strchr(li->name + plen + 1, li->separator)) != NULL) { - if (last == NULL) { - struct _list_info tli; - - tli.flags = CAMEL_FOLDER_NOSELECT|CAMEL_FOLDER_CHILDREN; - tli.separator = li->separator; - tli.name = g_strndup(li->name, p-li->name+1); - fi = folders_build_info(base, &tli); - fi->parent = pfi; - if (pfi && pfi->child == NULL) - pfi->child = fi; - i = folders_build_rec(folders, i, fi, tli.name); - break; - } - } -#endif - - fi = folders_build_info(base, li); - fi->parent = pfi; - if (last != NULL) - last->next = fi; - last = fi; - if (first == NULL) - first = fi; - - (*ip)++; - fi->child = folders_build_rec(base, folders, ip, fi, li->name); - imapx_free_list(li); - } - - return first; -} -#endif - /* folder_name is path name */ static CamelFolderInfo * imapx_build_folder_info (CamelIMAPXStore *imapx_store, const gchar *folder_name) @@ -630,7 +500,8 @@ get_folder_info_offline (CamelStore *store, const gchar *top, if ((g_str_equal (name, full_name) || imapx_match_pattern (ns, pattern, full_name) || (include_inbox && !g_ascii_strcasecmp (full_name, "INBOX"))) - && ( TRUE + && ( ((imapx_store->rec_options & IMAPX_SUBSCRIPTIONS) == 0 + || (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED) == 0) || (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) || (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIPTION_LIST) != 0)) { @@ -674,7 +545,7 @@ get_folder_info_offline (CamelStore *store, const gchar *top, } static void -add_folders_to_summary (CamelIMAPXStore *istore, GPtrArray *folders, GHashTable **table) +add_folders_to_summary (CamelIMAPXStore *istore, GPtrArray *folders, GHashTable *table, gboolean subcribed) { gint i = 0; @@ -698,9 +569,6 @@ add_folders_to_summary (CamelIMAPXStore *istore, GPtrArray *folders, GHashTable camel_store_summary_touch ((CamelStoreSummary *) istore->summary); } - if (!table) - continue; - fi = camel_folder_info_new (); fi->full_name = g_strdup(camel_store_info_path(istore->summary, si)); if (!g_ascii_strcasecmp(fi->full_name, "inbox")) { @@ -709,6 +577,15 @@ add_folders_to_summary (CamelIMAPXStore *istore, GPtrArray *folders, GHashTable } else fi->name = g_strdup(camel_store_info_name(istore->summary, si)); + hfi = g_hash_table_lookup (table, fi->name); + if (hfi) { + if (subcribed) + hfi->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED; + + camel_folder_info_free (fi); + continue; + } + /* HACK: some servers report noinferiors for all folders (uw-imapd) We just translate this into nochildren, and let the imap layer enforce it. See create folder */ @@ -716,6 +593,9 @@ add_folders_to_summary (CamelIMAPXStore *istore, GPtrArray *folders, GHashTable li->flags = (li->flags & ~CAMEL_FOLDER_NOINFERIORS) | CAMEL_FOLDER_NOCHILDREN; fi->flags = li->flags; + if (subcribed) + fi->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED; + url = camel_url_new (istore->base_url, NULL); path = alloca(strlen(fi->full_name)+2); sprintf(path, "/%s", fi->full_name); @@ -729,11 +609,7 @@ add_folders_to_summary (CamelIMAPXStore *istore, GPtrArray *folders, GHashTable fi->total = -1; fi->unread = -1; - hfi = g_hash_table_lookup (*table, fi->name); - if (hfi == NULL) - g_hash_table_insert (*table, fi->name, fi); - else if ((hfi->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) ^ (fi->flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)) - hfi->flags |= CAMEL_STORE_INFO_FOLDER_SUBSCRIBED; + g_hash_table_insert (table, fi->name, fi); } } @@ -745,12 +621,18 @@ free_list (gpointer data, gpointer user_data) } static void -fetch_folders_for_pattern (CamelIMAPXStore *istore, const gchar *pattern, guint32 flags, GHashTable **table, CamelException *ex) +imapx_get_folders_free(gpointer k, gpointer v, gpointer d) +{ + camel_folder_info_free(v); +} + +static void +fetch_folders_for_pattern (CamelIMAPXStore *istore, const gchar *pattern, guint32 flags, GHashTable *table, CamelException *ex) { GPtrArray *folders = NULL; folders = camel_imapx_server_list (istore->server, pattern, flags, ex); - add_folders_to_summary (istore, folders, table); + add_folders_to_summary (istore, folders, table, (flags & CAMEL_STORE_FOLDER_INFO_SUBSCRIBED)); g_ptr_array_foreach (folders, free_list, folders); g_ptr_array_free (folders, TRUE); @@ -800,9 +682,9 @@ fetch_folders_for_namespaces (CamelIMAPXStore *istore, const gchar *pattern, Cam pat = g_strdup (pattern); flags |= CAMEL_STORE_FOLDER_INFO_RECURSIVE; - fetch_folders_for_pattern (istore, pat, flags, &folders, ex); + fetch_folders_for_pattern (istore, pat, flags, folders, ex); flags |= CAMEL_STORE_FOLDER_INFO_SUBSCRIBED; - fetch_folders_for_pattern (istore, pat, flags, &folders, ex); + fetch_folders_for_pattern (istore, pat, flags, folders, ex); g_free (pat); @@ -840,7 +722,7 @@ sync_folders (CamelIMAPXStore *istore, const gchar *pattern, CamelException *ex) continue; } - if (!pattern || imapx_match_pattern (camel_imapx_store_summary_namespace_find_full (istore->summary, full_name), pattern, full_name)) { + if (!pattern || !*pattern || imapx_match_pattern (camel_imapx_store_summary_namespace_find_full (istore->summary, full_name), pattern, full_name)) { if ((fi = g_hash_table_lookup(folders_from_server, camel_store_info_path(istore->summary, si))) != NULL) { if (((fi->flags ^ si->flags) & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED)) { si->flags = (si->flags & ~CAMEL_FOLDER_SUBSCRIBED) | (fi->flags & CAMEL_FOLDER_SUBSCRIBED); @@ -871,6 +753,9 @@ sync_folders (CamelIMAPXStore *istore, const gchar *pattern, CamelException *ex) } camel_store_summary_info_free((CamelStoreSummary *)istore->summary, si); } + + g_hash_table_foreach (folders_from_server, imapx_get_folders_free, NULL); + g_hash_table_destroy (folders_from_server); } static CamelFolderInfo * @@ -890,13 +775,10 @@ imapx_get_folder_info(CamelStore *store, const gchar *top, guint32 flags, CamelE if (!camel_service_connect((CamelService *)store, ex)) return NULL; - if (camel_store_summary_count ((CamelStoreSummary *) istore->summary) == 0) { - sync_folders (istore, top, ex); - camel_store_summary_save((CamelStoreSummary *) istore->summary); - } + sync_folders (istore, top, ex); + camel_store_summary_save((CamelStoreSummary *) istore->summary); fi = get_folder_info_offline (store, top, flags, ex); - return fi; } @@ -946,231 +828,21 @@ imapx_can_refresh_folder (CamelStore *store, CamelFolderInfo *info, CamelExcepti return res; } -/* ********************************************************************** */ -#if 0 -static gint store_resp_fetch(CamelIMAPXEngine *ie, guint32 id, gpointer data) -{ - struct _fetch_info *finfo; - CamelIMAPXStore *istore = data; - CamelMessageInfo *info; - struct _pending_fetch *pending; - - finfo = imapx_parse_fetch(ie->stream); - if (istore->selected) { - if ((finfo->got & FETCH_UID) == 0) { - printf("didn't get uid in fetch response?\n"); - } else { - info = camel_folder_summary_index(((CamelFolder *)istore->selected)->summary, id-1); - /* exists, check/update */ - if (info) { - if (strcmp(finfo->uid, camel_message_info_uid(info)) != 0) { - printf("summary at index %d has uid %s expected %s\n", id, camel_message_info_uid(info), finfo->uid); - /* uid mismatch??? try do it based on uid instead? try to reorder? i dont know? */ - camel_message_info_free(info); - info = camel_folder_summary_uid(((CamelFolder *)istore->selected)->summary, finfo->uid); - } - } - - if (info) { - if (finfo->got & (FETCH_FLAGS)) { - printf("updating flags for uid '%s'\n", finfo->uid); - info->flags = finfo->flags; - camel_folder_change_info_change_uid(istore->selected->changes, finfo->uid); - } - if (finfo->got & FETCH_MINFO) { - printf("got envelope unexpectedly?\n"); - } - /* other things go here, like body fetches */ - } else { - pending = g_hash_table_lookup(istore->pending_fetch_table, finfo->uid); - - /* we need to create a new info, we only care about flags and minfo */ - - if (pending) - info = pending->info; - else { - info = camel_folder_summary_info_new(((CamelFolder *)istore->selected)->summary); - camel_message_info_set_uid(info, g_strdup(finfo->uid)); - } - - if (finfo->got & FETCH_FLAGS) - info->flags = finfo->flags; - - if (finfo->got & FETCH_MINFO) { - /* if we only use ENVELOPE? */ - camel_message_info_set_subject(info, g_strdup(camel_message_info_subject(finfo->minfo))); - camel_message_info_set_from(info, g_strdup(camel_message_info_from(finfo->minfo))); - camel_message_info_set_to(info, g_strdup(camel_message_info_to(finfo->minfo))); - camel_message_info_set_cc(info, g_strdup(camel_message_info_cc(finfo->minfo))); - info->date_sent = finfo->minfo->date_sent; - camel_folder_summary_add(((CamelFolder *)istore->selected)->summary, info); - camel_folder_change_info_add_uid(istore->selected->changes, finfo->uid); - if (pending) { - camel_dlist_remove((CamelDListNode *)pending); - g_hash_table_remove(istore->pending_fetch_table, finfo->uid); - /*e_memchunk_free(istore->pending_fetch_chunks, pending);*/ - } - } else if (finfo->got & FETCH_HEADER) { - /* if we only use HEADER? */ - CamelMimeParser *mp; - - if (pending == NULL) - camel_message_info_free(info); - mp = camel_mime_parser_new(); - camel_mime_parser_init_with_stream(mp, finfo->header); - info = camel_folder_summary_info_new_from_parser(((CamelFolder *)istore->selected)->summary, mp); - camel_object_unref(mp); - camel_message_info_set_uid(info, g_strdup(finfo->uid)); - - camel_folder_summary_add(((CamelFolder *)istore->selected)->summary, info); - camel_folder_change_info_add_uid(istore->selected->changes, finfo->uid); - if (pending) { - /* FIXME: use a dlist */ - camel_dlist_remove((CamelDListNode *)pending); - g_hash_table_remove(istore->pending_fetch_table, camel_message_info_uid(pending->info)); - camel_message_info_free(pending->info); - /*e_memchunk_free(istore->pending_fetch_chunks, pending);*/ - } - } else if (finfo->got & FETCH_FLAGS) { - if (pending == NULL) { - pending = e_memchunk_alloc(istore->pending_fetch_chunks); - pending->info = info; - g_hash_table_insert(istore->pending_fetch_table, (gchar *)camel_message_info_uid(info), pending); - camel_dlist_addtail(&istore->pending_fetch_list, (CamelDListNode *)pending); - } - } else { - if (pending == NULL) - camel_message_info_free(info); - printf("got unexpected fetch response?\n"); - imapx_dump_fetch(finfo); - } - } - } - } else { - printf("unexpected fetch response, no folder selected?\n"); - } - /*imapx_dump_fetch(finfo);*/ - imapx_free_fetch(finfo); - - return camel_imapx_engine_skip(ie); -} -#endif - -/* ********************************************************************** */ - -/* should be moved to imapx-utils? - stuff in imapx-utils should be moved to imapx-parse? */ - -/* ********************************************************************** */ - -#if 0 -void -camel_imapx_store_folder_selected(CamelIMAPXStore *store, CamelIMAPXFolder *folder, CamelIMAPXSelectResponse *select) -{ - CamelIMAPXCommand * volatile ic = NULL; - CamelIMAPXStore *istore = (CamelIMAPXStore *)store; - gint i; - struct _uidset_state ss; - GPtrArray *fetch; - CamelMessageInfo *info; - struct _pending_fetch *fw, *fn; - - printf("imap folder selected\n"); - - if (select->uidvalidity == folder->uidvalidity - && select->exists == folder->exists - && select->recent == folder->recent - && select->unseen == folder->unseen) { - /* no work to do? */ - return; - } - - istore->pending_fetch_table = g_hash_table_new(g_str_hash, g_str_equal); - istore->pending_fetch_chunks = e_memchunk_new(256, sizeof(struct _pending_fetch)); - - /* perform an update - flags first (and see what we have) */ - CAMEL_TRY { - ic = camel_imapx_engine_command_new(istore->engine, "FETCH", NULL, "FETCH 1:%d (UID FLAGS)", select->exists); - camel_imapx_engine_command_queue(istore->engine, ic); - while (camel_imapx_engine_iterate(istore->engine, ic) > 0) - ; - - if (ic->status->result != IMAP_OK) - camel_exception_throw(1, "fetch failed: %s", ic->status->text); - - /* pending_fetch_list now contains any new messages */ - /* FIXME: how do we work out no-longer present messages? */ - printf("now fetching info for messages?\n"); - uidset_init(&ss, store->engine); - ic = camel_imapx_engine_command_new(istore->engine, "FETCH", NULL, "UID FETCH "); - fw = (struct _pending_fetch *)istore->pending_fetch_list.head; - fn = fw->next; - while (fn) { - info = fw->info; - /* if the uid set fills, then flush the command out */ - if (uidset_add(&ss, ic, camel_message_info_uid(info)) - || (fn->next == NULL && uidset_done(&ss, ic))) { - camel_imapx_engine_command_add(istore->engine, ic, " (FLAGS RFC822.HEADER)"); - camel_imapx_engine_command_queue(istore->engine, ic); - while (camel_imapx_engine_iterate(istore->engine, ic) > 0) - ; - if (ic->status->result != IMAP_OK) - camel_exception_throw(1, "fetch failed: %s", ic->status->text); - /* if not end ... */ - camel_imapx_engine_command_free(istore->engine, ic); - ic = camel_imapx_engine_command_new(istore->engine, "FETCH", NULL, "UID FETCH "); - } - fw = fn; - fn = fn->next; - } - - printf("The pending list should now be empty: %s\n", camel_dlist_empty(&istore->pending_fetch_list)?"TRUE":"FALSE"); - for (i=0;i<10;i++) { - info = camel_folder_summary_index(((CamelFolder *)istore->selected)->summary, i); - if (info) { - printf("message info [%d] =\n", i); - camel_message_info_dump(info); - camel_message_info_free(info); - } - } - } CAMEL_CATCH (e) { - /* FIXME: cleanup */ - camel_exception_throw_ex(e); - } CAMEL_DONE; - - g_hash_table_destroy(istore->pending_fetch_table); - istore->pending_fetch_table = NULL; - e_memchunk_destroy(istore->pending_fetch_chunks); - - camel_imapx_engine_command_free(istore->engine, ic); -} -#endif - -#if 0 -/*char *uids[] = {"1", "2", "4", "5", "6", "7", "9", "11", "12", 0};*/ -/*char *uids[] = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", 0};*/ -gchar *uids[] = {"1", "3", "5", "7", "9", "11", "12", "13", "14", "15", "20", "21", "24", "25", "26", 0}; - -void -uidset_test(CamelIMAPXEngine *ie) +static gboolean +imapx_folder_subscribed (CamelStore *store, const gchar *folder_name) { - struct _uidset_state ss; - CamelIMAPXCommand *ic; - gint i; + CamelIMAPXStore *istore = CAMEL_IMAPX_STORE (store); + CamelStoreInfo *si; + gint is_subscribed = FALSE; - /*ic = camel_imapx_engine_command_new(ie, 0, "FETCH", NULL, "FETCH ");*/ - uidset_init(&ss, 0, 0); - for (i=0;uids[i];i++) { - if (uidset_add(&ss, uids[i])) { - printf("\n[%d] flushing uids\n", i); - } + si = camel_store_summary_path((CamelStoreSummary *)istore->summary, folder_name); + if (si) { + is_subscribed = (si->flags & CAMEL_STORE_INFO_FOLDER_SUBSCRIBED) != 0; + camel_store_summary_info_free((CamelStoreSummary *)istore->summary, si); } - if (uidset_done(&ss)) { - printf("\nflushing uids\n"); - } + return is_subscribed; } -#endif static void camel_imapx_store_class_init(CamelIMAPXStoreClass *klass) @@ -1199,6 +871,8 @@ camel_imapx_store_class_init(CamelIMAPXStoreClass *klass) camel_store_class->rename_folder = imapx_rename_folder; camel_store_class->delete_folder = imapx_delete_folder; camel_store_class->get_folder_info = imapx_get_folder_info; + camel_store_class->folder_subscribed = imapx_folder_subscribed; + camel_store_class->free_folder_info = camel_store_free_folder_info_full; ((CamelStoreClass *)klass)->hash_folder_name = imapx_name_hash; ((CamelStoreClass *)klass)->compare_folder_name = imapx_name_equal; diff --git a/camel/providers/imapx/camel-imapx-store.h b/camel/providers/imapx/camel-imapx-store.h index 773e5a0..bfcedb4 100644 --- a/camel/providers/imapx/camel-imapx-store.h +++ b/camel/providers/imapx/camel-imapx-store.h @@ -39,12 +39,14 @@ extern "C" { #define CAMEL_IMAPX_STORE_CLASS(k) (CAMEL_CHECK_CLASS_CAST ((k), CAMEL_IMAPX_STORE_TYPE, CamelIMAPXStoreClass)) #define CAMEL_IS_IMAP_STORE(o) (CAMEL_CHECK_TYPE((o), CAMEL_IMAPX_STORE_TYPE)) -struct _pending_fetch { - struct _pending_fetch *next; - struct _pending_fetch *prev; - - struct _CamelMessageInfo *info; -}; +#define IMAPX_OVERRIDE_NAMESPACE (1 << 0) +#define IMAPX_CHECK_ALL (1 << 1) +#define IMAPX_FILTER_INBOX (1 << 2) +#define IMAPX_FILTER_JUNK (1 << 3) +#define IMAPX_FILTER_JUNK_INBOX (1 << 4) +#define IMAPX_SUBSCRIPTIONS (1 << 5) +#define IMAPX_CHECK_LSUB (1 << 6) +#define IMAPX_USE_IDLE (1 << 7) typedef struct { CamelOfflineStore parent_object; @@ -54,6 +56,8 @@ typedef struct { CamelIMAPXStoreSummary *summary; /* in-memory list of folders */ gchar *namespace, dir_sep, *base_url, *storage_path; + guint32 rec_options; + /* if we had a login error, what to show to user */ gchar *login_error; diff --git a/camel/providers/imapx/camel-imapx-utils.h b/camel/providers/imapx/camel-imapx-utils.h index 1c13aa8..51f4ce0 100644 --- a/camel/providers/imapx/camel-imapx-utils.h +++ b/camel/providers/imapx/camel-imapx-utils.h @@ -75,7 +75,7 @@ enum { IMAPX_CAPABILITY_IMAP4REV1 = (1 << 1), IMAPX_CAPABILITY_STATUS = (1 << 2), IMAPX_CAPABILITY_NAMESPACE = (1 << 3), - IMAPX_CAPABILITY_UIDPLUS = (1 << 4), + IMAPX_CAPABILITY_UIDPLUS = (1 << 4), IMAPX_CAPABILITY_LITERALPLUS = (1 << 5), IMAPX_CAPABILITY_STARTTLS = (1 << 6), IMAPX_CAPABILITY_IDLE = (1 << 7), -- 2.7.4