aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/async/imap/MCIMAPFetchContentOperation.cc
blob: de3b911e5be3fc3c3643bf4fdf45cc3093229cba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
//  IMAPFetchContentOperation.cc
//  mailcore2
//
//  Created by DINH Viêt Hoà on 1/12/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#include "MCIMAPFetchContentOperation.h"

#include "MCIMAPSession.h"
#include "MCIMAPAsyncConnection.h"

using namespace mailcore;

IMAPFetchContentOperation::IMAPFetchContentOperation()
{
    mUid = 0;
    mPartID = NULL;
    mEncoding = Encoding7Bit;
    mData = NULL;
}

IMAPFetchContentOperation::~IMAPFetchContentOperation()
{
    MC_SAFE_RELEASE(mPartID);
    MC_SAFE_RELEASE(mData);
}

void IMAPFetchContentOperation::setUid(uint32_t uid)
{
    mUid = uid;
}

uint32_t IMAPFetchContentOperation::uid()
{
    return mUid;
}

void IMAPFetchContentOperation::setPartID(String * partID)
{
    MC_SAFE_REPLACE_COPY(String, mPartID, partID);
}

String * IMAPFetchContentOperation::partID()
{
    return mPartID;
}

void IMAPFetchContentOperation::setEncoding(Encoding encoding)
{
    mEncoding = encoding;
}

Encoding IMAPFetchContentOperation::encoding()
{
    return mEncoding;
}

Data * IMAPFetchContentOperation::data()
{
    return mData;
}

void IMAPFetchContentOperation::main()
{
    ErrorCode error;
    if (mPartID != NULL) {
        mData = session()->session()->fetchMessageAttachmentByUID(folder(), mUid, mPartID, mEncoding, this, &error);
    }
    else {
        mData = session()->session()->fetchMessageByUID(folder(), mUid, this, &error);
    }
    MC_SAFE_RETAIN(mData);
    setError(error);
}