aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/imap/MCIMAPSession.cc
diff options
context:
space:
mode:
authorGravatar CodaFi <devteam.codafi@gmail.com>2013-06-22 22:04:03 -0600
committerGravatar CodaFi <devteam.codafi@gmail.com>2013-06-22 22:04:03 -0600
commitb0a968ba727c703528efbfa803267fa67aec37d1 (patch)
treeef3a6a6ba81618d0cb8654335891f6849a0e3f33 /src/core/imap/MCIMAPSession.cc
parent59408009d5cd0c002b138881f2bb67d274da91bb (diff)
Implement Gmail Thread ID
Diffstat (limited to 'src/core/imap/MCIMAPSession.cc')
-rw-r--r--src/core/imap/MCIMAPSession.cc31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc
index 52e819d9..e0c00d39 100644
--- a/src/core/imap/MCIMAPSession.cc
+++ b/src/core/imap/MCIMAPSession.cc
@@ -1582,6 +1582,7 @@ struct msg_att_handler_data {
bool needsBody;
bool needsFlags;
bool needsGmailLabels;
+ bool needsGmailThreadID;
uint32_t startUid;
};
@@ -1594,6 +1595,7 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context)
bool hasBody;
bool hasFlags;
bool hasGmailLabels;
+ bool hasGmailThreadID;
struct msg_att_handler_data * msg_att_context;
// struct
IMAPSession * self;
@@ -1607,6 +1609,7 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context)
bool needsBody;
bool needsFlags;
bool needsGmailLabels;
+ bool needsGmailThreadID;
uint32_t startUid;
msg_att_context = (struct msg_att_handler_data *) context;
@@ -1621,13 +1624,15 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context)
needsBody = msg_att_context->needsBody;
needsFlags = msg_att_context->needsFlags;
needsGmailLabels = msg_att_context->needsGmailLabels;
+ needsGmailThreadID = msg_att_context->needsGmailThreadID;
startUid = msg_att_context->startUid;
hasHeader = false;
hasBody = false;
hasFlags = false;
hasGmailLabels = false;
-
+ hasGmailThreadID = false;
+
msg = new IMAPMessage();
uid = 0;
@@ -1718,6 +1723,13 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context)
}
labels->release();
}
+ if (ext_data->ext_extension == &mailimap_extension_xgmthrid) {
+ String * threadID;
+
+ threadID = String::stringWithUTF8Characters((char *) ext_data->ext_data);
+ msg->setGmailThreadID(threadID);
+ hasGmailThreadID = true;
+ }
}
}
for(item_iter = clist_begin(msg_att->att_list) ; item_iter != NULL ; item_iter = clist_next(item_iter)) {
@@ -1752,7 +1764,10 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context)
msg->release();
return;
}
-
+ if (needsGmailThreadID && !hasGmailThreadID) {
+ msg->release();
+ return;
+ }
if (uid != 0) {
msg->setUid(uid);
}
@@ -1780,6 +1795,7 @@ IMAPSyncResult * IMAPSession::fetchMessages(String * folder, IMAPMessagesRequest
bool needsBody;
bool needsFlags;
bool needsGmailLabels;
+ bool needsGmailThreadID;
Array * messages;
IndexSet * vanishedMessages;
@@ -1803,7 +1819,8 @@ IMAPSyncResult * IMAPSession::fetchMessages(String * folder, IMAPMessagesRequest
needsBody = false;
needsFlags = false;
needsGmailLabels = false;
-
+ needsGmailThreadID = false;
+
fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
fetch_att = mailimap_fetch_att_new_uid();
mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
@@ -1819,6 +1836,12 @@ IMAPSyncResult * IMAPSession::fetchMessages(String * folder, IMAPMessagesRequest
mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
needsGmailLabels = true;
}
+ if ((requestKind & IMAPMessagesRequestKindGmailThreadID) != 0) {
+ MCLog("request flags");
+ fetch_att = mailimap_fetch_att_new_xgmthrid();
+ mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
+ needsGmailThreadID = true;
+ }
if ((requestKind & IMAPMessagesRequestKindFullHeaders) != 0) {
clist * hdrlist;
char * header;
@@ -1908,7 +1931,7 @@ IMAPSyncResult * IMAPSession::fetchMessages(String * folder, IMAPMessagesRequest
msg_att_data.needsFlags = needsFlags;
msg_att_data.needsGmailLabels = needsGmailLabels;
msg_att_data.startUid = startUid;
-
+ msg_att_data.needsGmailThreadID = needsGmailThreadID;
mailimap_set_msg_att_handler(mImap, msg_att_handler, &msg_att_data);
mBodyProgressEnabled = false;