MCPcopy Create free account
hub / github.com/MailCore/mailcore2 / fetchMessage

Method fetchMessage

src/core/imap/MCIMAPSession.cpp:2822–2876  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2820}
2821
2822Data * IMAPSession::fetchMessage(String * folder, bool identifier_is_uid, uint32_t identifier,
2823 IMAPProgressCallback * progressCallback, ErrorCode * pError)
2824{
2825 char * rfc822;
2826 size_t rfc822_len;
2827 int r;
2828 Data * data;
2829
2830 selectIfNeeded(folder, pError);
2831 if (* pError != ErrorNone)
2832 return NULL;
2833
2834 mProgressItemsCount = 0;
2835 mProgressCallback = progressCallback;
2836
2837 rfc822 = NULL;
2838 r = fetch_rfc822(mImap, identifier_is_uid, identifier, &rfc822, &rfc822_len);
2839 if (r == MAILIMAP_NO_ERROR) {
2840 size_t len;
2841
2842 len = 0;
2843 if (rfc822 != NULL) {
2844 len = strlen(rfc822);
2845 }
2846 bodyProgress((unsigned int) len, (unsigned int) len);
2847 }
2848 mProgressCallback = NULL;
2849
2850 if (r == MAILIMAP_ERROR_STREAM) {
2851 mShouldDisconnect = true;
2852 * pError = ErrorConnection;
2853 return NULL;
2854 }
2855 else if (r == MAILIMAP_ERROR_PARSE) {
2856 mShouldDisconnect = true;
2857 * pError = ErrorParse;
2858 return NULL;
2859 }
2860 else if (hasError(r)) {
2861 * pError = ErrorFetch;
2862 return NULL;
2863 }
2864
2865 if (rfc822 == NULL) {
2866 data = Data::data();
2867 }
2868 else {
2869 data = Data::dataWithBytes(rfc822, (unsigned int) rfc822_len);
2870 }
2871
2872 mailimap_nstring_free(rfc822);
2873 * pError = ErrorNone;
2874
2875 return data;
2876}
2877
2878static void nstringDeallocator(char * bytes, unsigned int length) {
2879 mailimap_nstring_free(bytes);

Callers

nothing calls this directly

Calls 3

fetch_rfc822Function · 0.85
hasErrorFunction · 0.85
dataFunction · 0.50

Tested by

no test coverage detected