diff options
author | CodaFi <devteam.codafi@gmail.com> | 2013-06-23 15:05:34 -0600 |
---|---|---|
committer | CodaFi <devteam.codafi@gmail.com> | 2013-06-23 15:05:34 -0600 |
commit | bf7692b7dfde52d439e0ab4d18d9ee814a3d29fd (patch) | |
tree | 958dd79433ef34a73a260b0e856b9ef0eb930e84 | |
parent | 4838d93cd40698a899bcf6c93b05a3412c4c45fb (diff) |
Implement Message ID
-rw-r--r-- | src/core/imap/MCIMAPMessage.cc | 14 | ||||
-rw-r--r-- | src/core/imap/MCIMAPMessage.h | 4 | ||||
-rw-r--r-- | src/core/imap/MCIMAPSession.cc | 28 | ||||
-rw-r--r-- | src/objc/abstract/MCOConstants.h | 20 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPMessage.h | 5 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPMessage.mm | 1 |
6 files changed, 58 insertions, 14 deletions
diff --git a/src/core/imap/MCIMAPMessage.cc b/src/core/imap/MCIMAPMessage.cc index f8b9f4e6..8da33130 100644 --- a/src/core/imap/MCIMAPMessage.cc +++ b/src/core/imap/MCIMAPMessage.cc @@ -17,8 +17,8 @@ void IMAPMessage::init() mUid = 0; mFlags = MessageFlagNone; mOriginalFlags = MessageFlagNone; - mMainPart = NULL; - mLabels = NULL; + mMainPart = NULL; + mLabels = NULL; mModSeqValue = 0; } @@ -122,6 +122,16 @@ Array * IMAPMessage::gmailLabels() return mLabels; } +void IMAPMessage::setGmailMessageID(uint64_t msgID) +{ + mMessageID = msgID; +} + +uint64_t IMAPMessage::gmailMessageID() +{ + return mMessageID; +} + void IMAPMessage::setGmailThreadID(uint64_t threadID) { mThreadID = threadID; diff --git a/src/core/imap/MCIMAPMessage.h b/src/core/imap/MCIMAPMessage.h index 3c2ee9c0..7053ef92 100644 --- a/src/core/imap/MCIMAPMessage.h +++ b/src/core/imap/MCIMAPMessage.h @@ -38,6 +38,9 @@ namespace mailcore { virtual void setGmailLabels(Array * /* String */ labels); virtual Array * /* String */ gmailLabels(); + virtual void setGmailMessageID(uint64_t msgID); + virtual uint64_t gmailMessageID(); + virtual void setGmailThreadID(uint64_t threadID); virtual uint64_t gmailThreadID(); @@ -62,6 +65,7 @@ namespace mailcore { MessageFlag mOriginalFlags; AbstractPart * mMainPart; Array * /* String */ mLabels; + uint64_t mMessageID; uint64_t mThreadID; void init(); }; diff --git a/src/core/imap/MCIMAPSession.cc b/src/core/imap/MCIMAPSession.cc index 254f9865..a03c3edb 100644 --- a/src/core/imap/MCIMAPSession.cc +++ b/src/core/imap/MCIMAPSession.cc @@ -1584,6 +1584,7 @@ struct msg_att_handler_data { bool needsBody; bool needsFlags; bool needsGmailLabels; + bool needsGmailMessageID; bool needsGmailThreadID; uint32_t startUid; }; @@ -1597,7 +1598,8 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context) bool hasBody; bool hasFlags; bool hasGmailLabels; - bool hasGmailThreadID; + bool hasGmailMessageID; + bool hasGmailThreadID; struct msg_att_handler_data * msg_att_context; // struct IMAPSession * self; @@ -1611,6 +1613,7 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context) bool needsBody; bool needsFlags; bool needsGmailLabels; + bool needsGmailMessageID; bool needsGmailThreadID; uint32_t startUid; @@ -1626,6 +1629,7 @@ 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; + needsGmailMessageID = msg_att_context->needsGmailMessageID; needsGmailThreadID = msg_att_context->needsGmailThreadID; startUid = msg_att_context->startUid; @@ -1633,6 +1637,7 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context) hasBody = false; hasFlags = false; hasGmailLabels = false; + hasGmailMessageID = false; hasGmailThreadID = false; msg = new IMAPMessage(); @@ -1732,6 +1737,13 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context) msg->setGmailThreadID(*threadID); hasGmailThreadID = true; } + else if (ext_data->ext_extension == &mailimap_extension_xgmmsgid) { + uint64_t * msgID; + + msgID = (uint64_t *) ext_data->ext_data; + msg->setGmailMessageID(*msgID); + hasGmailMessageID = true; + } } } for(item_iter = clist_begin(msg_att->att_list) ; item_iter != NULL ; item_iter = clist_next(item_iter)) { @@ -1770,6 +1782,10 @@ static void msg_att_handler(struct mailimap_msg_att * msg_att, void * context) msg->release(); return; } + if (needsGmailMessageID && !hasGmailMessageID) { + msg->release(); + return; + } if (uid != 0) { msg->setUid(uid); } @@ -1797,12 +1813,13 @@ IMAPSyncResult * IMAPSession::fetchMessages(String * folder, IMAPMessagesRequest bool needsBody; bool needsFlags; bool needsGmailLabels; + bool needsGmailMessageID; bool needsGmailThreadID; Array * messages; IndexSet * vanishedMessages; selectIfNeeded(folder, pError); - if (* pError != ErrorNone) + if (* pError != ErrorNone) return NULL; if (mNeedsMboxMailWorkaround) { @@ -1821,6 +1838,7 @@ IMAPSyncResult * IMAPSession::fetchMessages(String * folder, IMAPMessagesRequest needsBody = false; needsFlags = false; needsGmailLabels = false; + needsGmailMessageID = false; needsGmailThreadID = false; fetch_type = mailimap_fetch_type_new_fetch_att_list_empty(); @@ -1843,6 +1861,11 @@ IMAPSyncResult * IMAPSession::fetchMessages(String * folder, IMAPMessagesRequest mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att); needsGmailThreadID = true; } + if ((requestKind & IMAPMessagesRequestKindGmailMessageID) != 0) { + fetch_att = mailimap_fetch_att_new_xgmmsgid(); + mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att); + needsGmailMessageID = true; + } if ((requestKind & IMAPMessagesRequestKindFullHeaders) != 0) { clist * hdrlist; char * header; @@ -1932,6 +1955,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.needsGmailMessageID = needsGmailMessageID; msg_att_data.needsGmailThreadID = needsGmailThreadID; mailimap_set_msg_att_handler(mImap, msg_att_handler, &msg_att_data); diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h index 8b73aeaf..8fafabf3 100644 --- a/src/objc/abstract/MCOConstants.h +++ b/src/objc/abstract/MCOConstants.h @@ -119,23 +119,25 @@ typedef enum { /** It's the information to fetch for a given message in the IMAP FETCH request.*/ typedef enum { /** UID of the message.*/ - MCOIMAPMessagesRequestKindUid = 0, /** This is the default and it's always fetched*/ + MCOIMAPMessagesRequestKindUid = 0, /** This is the default and it's always fetched*/ /** Flags of the message.*/ - MCOIMAPMessagesRequestKindFlags = 1 << 0, + MCOIMAPMessagesRequestKindFlags = 1 << 0, /** Headers of the message (parsed by the server).*/ - MCOIMAPMessagesRequestKindHeaders = 1 << 1, + MCOIMAPMessagesRequestKindHeaders = 1 << 1, /** MIME structure of the message.*/ - MCOIMAPMessagesRequestKindStructure = 1 << 2, + MCOIMAPMessagesRequestKindStructure = 1 << 2, /** Received date.*/ - MCOIMAPMessagesRequestKindInternalDate = 1 << 3, + MCOIMAPMessagesRequestKindInternalDate = 1 << 3, /** Headers through headers data.*/ - MCOIMAPMessagesRequestKindFullHeaders = 1 << 4, + MCOIMAPMessagesRequestKindFullHeaders = 1 << 4, /** Subject of the message.*/ - MCOIMAPMessagesRequestKindHeaderSubject = 1 << 5, + MCOIMAPMessagesRequestKindHeaderSubject = 1 << 5, /** Gmail Labels.*/ - MCOIMAPMessagesRequestKindGmailLabels = 1 << 6, + MCOIMAPMessagesRequestKindGmailLabels = 1 << 6, + /** Gmail Message ID.*/ + MCOIMAPMessagesRequestKindGmailMessageID = 1 << 7, /** Gmail Thread ID.*/ - MCOIMAPMessagesRequestKindGmailThreadID = 1 << 7, + MCOIMAPMessagesRequestKindGmailThreadID = 1 << 8, } MCOIMAPMessagesRequestKind; /** It defines the behavior of the STORE flags request.*/ diff --git a/src/objc/imap/MCOIMAPMessage.h b/src/objc/imap/MCOIMAPMessage.h index ab9771ca..06e437d8 100644 --- a/src/objc/imap/MCOIMAPMessage.h +++ b/src/objc/imap/MCOIMAPMessage.h @@ -49,7 +49,10 @@ /** All Gmail labels of the message */ @property (nonatomic, copy) NSArray * /* NSString */ gmailLabels; -/** Gmail thread iD of the message */ +/** Gmail message ID of the message */ +@property (nonatomic, assign) uint64_t gmailMessageID; + +/** Gmail thread ID of the message */ @property (nonatomic, assign) uint64_t gmailThreadID; /** diff --git a/src/objc/imap/MCOIMAPMessage.mm b/src/objc/imap/MCOIMAPMessage.mm index b5845bc2..c9bfcbb9 100644 --- a/src/objc/imap/MCOIMAPMessage.mm +++ b/src/objc/imap/MCOIMAPMessage.mm @@ -48,6 +48,7 @@ MCO_OBJC_SYNTHESIZE_SCALAR(uint64_t, uint64_t, setModSeqValue, modSeqValue) MCO_OBJC_SYNTHESIZE(AbstractPart, setMainPart, mainPart) MCO_OBJC_SYNTHESIZE_ARRAY(setGmailLabels, gmailLabels) MCO_OBJC_SYNTHESIZE_SCALAR(uint64_t, uint64_t, setGmailThreadID, gmailThreadID) +MCO_OBJC_SYNTHESIZE_SCALAR(uint64_t, uint64_t, setGmailMessageID, gmailMessageID) - (MCOAbstractPart *) partForPartID:(NSString *)partID { |