From 8bceb3eac6eca2598343b8815c9204e80563b007 Mon Sep 17 00:00:00 2001 From: Sergei Epatov Date: Wed, 22 Mar 2017 12:56:34 +0200 Subject: [PATCH] Fix do not return error on empty part returned from server, return just zero length (2) --- src/core/imap/MCIMAPSession.cpp | 18 +++++++++++------- src/core/imap/MCIMAPSession.h | 5 +++++ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/core/imap/MCIMAPSession.cpp b/src/core/imap/MCIMAPSession.cpp index 998332259..66f2751fe 100644 --- a/src/core/imap/MCIMAPSession.cpp +++ b/src/core/imap/MCIMAPSession.cpp @@ -398,6 +398,7 @@ void IMAPSession::init() mRamblerRuServer = false; mHermesServer = false; mQipServer = false; + mOutlookServer = false; mLastFetchedSequenceNumber = 0; mCurrentFolder = NULL; pthread_mutex_init(&mIdleLock, NULL); @@ -719,6 +720,7 @@ void IMAPSession::connect(ErrorCode * pError) mRamblerRuServer = (mHostname->locationOfString(MCSTR(".rambler.ru")) != -1); mHermesServer = (mWelcomeString->locationOfString(MCSTR("Hermes")) != -1); mQipServer = (mWelcomeString->locationOfString(MCSTR("QIP IMAP server")) != -1); + mOutlookServer = (mHostname->locationOfString(MCSTR(".outlook.com")) != -1); } mState = STATE_CONNECTED; @@ -1989,10 +1991,8 @@ void IMAPSession::expunge(String * folder, ErrorCode * pError) * pError = ErrorNone; } -static int -fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier, - struct mailimap_fetch_type * fetch_type, - char ** result, size_t * result_len) +int IMAPSession::fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier, + mailimap_fetch_type * fetch_type, char ** result, size_t * result_len) { int r; struct mailimap_msg_att * msg_att; @@ -2051,7 +2051,12 @@ fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier, mailimap_fetch_list_free(fetch_result); if (text == NULL) { - text_length = 0; + if (mOutlookServer) { + text_length = 0; + } + else { + return MAILIMAP_ERROR_FETCH; + } } * result = text; @@ -2717,8 +2722,7 @@ Array * IMAPSession::fetchMessagesByNumberWithExtraHeaders(String * folder, IMAP return result; } -static int fetch_rfc822(mailimap * session, bool identifier_is_uid, - uint32_t identifier, char ** result, size_t * result_len) +int IMAPSession::fetch_rfc822(mailimap * session, bool identifier_is_uid, uint32_t identifier, char ** result, size_t * result_len) { struct mailimap_section * section; struct mailimap_fetch_att * fetch_att; diff --git a/src/core/imap/MCIMAPSession.h b/src/core/imap/MCIMAPSession.h index 596235372..40c2743cd 100644 --- a/src/core/imap/MCIMAPSession.h +++ b/src/core/imap/MCIMAPSession.h @@ -8,6 +8,8 @@ #ifdef __cplusplus +typedef struct mailimap_fetch_type mailimap_fetch_type; + namespace mailcore { extern String * IMAPNamespacePersonal; @@ -273,6 +275,7 @@ namespace mailcore { bool mRamblerRuServer; bool mHermesServer; bool mQipServer; + bool mOutlookServer; unsigned int mLastFetchedSequenceNumber; String * mCurrentFolder; @@ -322,6 +325,8 @@ namespace mailcore { bool wholePart, uint32_t offset, uint32_t length, Encoding encoding, IMAPProgressCallback * progressCallback, ErrorCode * pError); void storeLabels(String * folder, bool identifier_is_uid, IndexSet * identifiers, IMAPStoreFlagsRequestKind kind, Array * labels, ErrorCode * pError); + int fetch_rfc822(mailimap * session, bool identifier_is_uid, uint32_t identifier, char ** result, size_t * result_len); + int fetch_imap(mailimap * imap, bool identifier_is_uid, uint32_t identifier, mailimap_fetch_type * fetch_type, char ** result, size_t * result_len); }; }