diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2014-06-10 23:14:52 -0700 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2014-06-10 23:15:18 -0700 |
commit | c5134f25a97bf78a78967fe46d49b3ebfafcef41 (patch) | |
tree | af96e418f43060bbc508c2cd13c9f42ff1fe160b /src/core/abstract | |
parent | ea117396056a81619d8f1b73649c1f81b9ad3d16 (diff) |
case insensitive header lookup
Diffstat (limited to 'src/core/abstract')
-rw-r--r-- | src/core/abstract/MCMessageHeader.cc | 21 | ||||
-rw-r--r-- | src/core/abstract/MCMessageHeader.h | 1 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/core/abstract/MCMessageHeader.cc b/src/core/abstract/MCMessageHeader.cc index 789da25e..fb3e43cb 100644 --- a/src/core/abstract/MCMessageHeader.cc +++ b/src/core/abstract/MCMessageHeader.cc @@ -63,6 +63,7 @@ void MessageHeader::init(bool generateDate, bool generateMessageID) mDate = (time_t) -1; mReceivedDate = (time_t) -1; mExtraHeaders = NULL; + mlcExtraHeaders = NULL; if (generateDate) { time_t date; @@ -114,6 +115,7 @@ MessageHeader::~MessageHeader() MC_SAFE_RELEASE(mReplyTo); MC_SAFE_RELEASE(mSubject); MC_SAFE_RELEASE(mExtraHeaders); + MC_SAFE_RELEASE(mlcExtraHeaders); } String * MessageHeader::description() @@ -298,6 +300,13 @@ String * MessageHeader::userAgent() void MessageHeader::setExtraHeaders(HashMap * headers) { MC_SAFE_REPLACE_COPY(HashMap, mExtraHeaders, headers); + MC_SAFE_RELEASE(mlcExtraHeaders); + if (mExtraHeaders != NULL) { + mlcExtraHeaders = new HashMap(); + mc_foreachhashmapKeyAndValue(String, key, String, value, mExtraHeaders) { + mlcExtraHeaders->setObjectForKey(key->lowercaseString(), value); + } + } } Array * MessageHeader::allExtraHeadersNames() @@ -309,13 +318,18 @@ Array * MessageHeader::allExtraHeadersNames() void MessageHeader::setExtraHeader(String * name, String * object) { - if (mExtraHeaders == NULL) + if (mExtraHeaders == NULL) { mExtraHeaders = new HashMap(); + } + if (mlcExtraHeaders == NULL) { + mlcExtraHeaders = new HashMap(); + } if (object == NULL) { removeExtraHeader(name); return; } mExtraHeaders->setObjectForKey(name, object); + mlcExtraHeaders->setObjectForKey(name->lowercaseString(), object); } void MessageHeader::removeExtraHeader(String * name) @@ -323,13 +337,14 @@ void MessageHeader::removeExtraHeader(String * name) if (mExtraHeaders == NULL) return; mExtraHeaders->removeObjectForKey(name); + mlcExtraHeaders->removeObjectForKey(name); } String * MessageHeader::extraHeaderValueForName(String * name) { - if (mExtraHeaders == NULL) + if (mlcExtraHeaders == NULL) return NULL; - return (String *) mExtraHeaders->objectForKey(name); + return (String *) mlcExtraHeaders->objectForKey(name->lowercaseString()); } String * MessageHeader::extractedSubject() diff --git a/src/core/abstract/MCMessageHeader.h b/src/core/abstract/MCMessageHeader.h index c6f1fbef..4fef0b7f 100644 --- a/src/core/abstract/MCMessageHeader.h +++ b/src/core/abstract/MCMessageHeader.h @@ -96,6 +96,7 @@ namespace mailcore { time_t mDate; time_t mReceivedDate; HashMap * mExtraHeaders; + HashMap * mlcExtraHeaders; void init(bool generateDate, bool generateMessageID); void setExtraHeaders(HashMap *headers); Array * recipientWithReplyAll(bool replyAll, bool includeTo, bool includeCc, Array * senderEmails); |