diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2010-06-19 22:03:00 +0100 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-06-28 13:29:56 +0100 |
commit | 79603ec0951bd8193acac1a3efbda70bb7404e28 (patch) | |
tree | b9643fd37357608795eb6b3f1a49b766973d1884 | |
parent | 8d504b79544970ed356e4f0117d614ed6347a3e2 (diff) | |
download | evolution-data-server-79603ec0951bd8193acac1a3efbda70bb7404e28.tar.gz |
Cope with unsolicited FETCH having both FLAGS and UID.
This'll happen once we're using CONDSTORE or QRESYNC
(cherry picked from commit 25646a07ead3bc8b042397805f867894156b4861)
-rw-r--r-- | camel/providers/imapx/camel-imapx-server.c | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/camel/providers/imapx/camel-imapx-server.c b/camel/providers/imapx/camel-imapx-server.c index 252016733..377f0226e 100644 --- a/camel/providers/imapx/camel-imapx-server.c +++ b/camel/providers/imapx/camel-imapx-server.c @@ -1255,8 +1255,23 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex) } } - if (finfo->got & FETCH_FLAGS && !(finfo->got & FETCH_UID)) { - if (imap->select_folder) { + if ((finfo->got & FETCH_FLAGS) && !(finfo->got & FETCH_HEADER)) { + CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL); + /* This is either a refresh_info job, check to see if it is and update + if so, otherwise it must've been an unsolicited response, so update + the summary to match */ + + if (job && (finfo->got & FETCH_UID)) { + struct _refresh_info r; + + r.uid = finfo->uid; + finfo->uid = NULL; + r.server_flags = finfo->flags; + r.server_user_flags = finfo->user_flags; + finfo->user_flags = NULL; + r.exists = FALSE; + g_array_append_val(job->u.refresh_info.infos, r); + } else if (imap->select_folder) { CamelFolder *folder; CamelMessageInfo *mi = NULL; gboolean changed = FALSE; @@ -1267,11 +1282,22 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex) c(printf("flag changed: %d\n", id)); - if ( (uid = camel_folder_summary_uid_from_index (folder->summary, id - 1))) - { + if (finfo->got & FETCH_UID) { + uid = finfo->uid; + finfo->uid = NULL; + } else { + uid = camel_folder_summary_uid_from_index (folder->summary, id - 1); + } + + if (uid) { mi = camel_folder_summary_uid (folder->summary, uid); if (mi) changed = imapx_update_message_info_flags (mi, finfo->flags, finfo->user_flags, folder); + else { + /* This (UID + FLAGS for previously unknown message) might + happen during a SELECT (QRESYNC). We should use it. */ + c(printf("flags changed for unknown uid %s\n.", uid)); + } finfo->user_flags = NULL; } @@ -1296,27 +1322,6 @@ imapx_untagged(CamelIMAPXServer *imap, CamelException *ex) } } - if ((finfo->got & (FETCH_FLAGS|FETCH_UID)) == (FETCH_FLAGS|FETCH_UID) && !(finfo->got & FETCH_HEADER)) { - CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL); - - /* This is either a refresh_info job, check to see if it is and update - if so, otherwise it must've been an unsolicited response, so update - the summary to match */ - - if (job) { - struct _refresh_info r; - - r.uid = finfo->uid; - finfo->uid = NULL; - r.server_flags = finfo->flags; - r.server_user_flags = finfo->user_flags; - finfo->user_flags = NULL; - r.exists = FALSE; - g_array_append_val(job->u.refresh_info.infos, r); - } else { - } - } - if ((finfo->got & (FETCH_HEADER|FETCH_UID)) == (FETCH_HEADER|FETCH_UID)) { CamelIMAPXJob *job = imapx_match_active_job (imap, IMAPX_JOB_FETCH_NEW_MESSAGES|IMAPX_JOB_REFRESH_INFO, NULL); |