aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/imap/MCIMAPMessagePart.cpp
blob: 20744ad21efaa107cf3953be49f49786679a9c71 (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
#include "MCIMAPMessagePart.h"

#include "MCDefines.h"

using namespace mailcore;

IMAPMessagePart::IMAPMessagePart()
{
    init();
}

IMAPMessagePart::IMAPMessagePart(IMAPMessagePart * other) : AbstractMessagePart(other)
{
    init();
    MC_SAFE_REPLACE_COPY(String, mPartID, other->mPartID);
}

IMAPMessagePart::~IMAPMessagePart()
{
    MC_SAFE_RELEASE(mPartID);
}

Object * IMAPMessagePart::copy()
{
    return new IMAPMessagePart(this);
}

void IMAPMessagePart::init()
{
    mPartID = NULL;
}

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

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

HashMap * IMAPMessagePart::serializable()
{
    HashMap * result = AbstractMessagePart::serializable();
    if (partID() != NULL) {
        result->setObjectForKey(MCSTR("partID"), partID());
    }
    return result;
}

void IMAPMessagePart::importSerializable(HashMap * serializable)
{
    AbstractMessagePart::importSerializable(serializable);
    String * partID = (String *) serializable->objectForKey(MCSTR("partID"));
    setPartID(partID);
}

static void * createObject()
{
    return new IMAPMessagePart();
}

INITIALIZE(IMAPMessagePart)
{
    Object::registerObjectConstructor("mailcore::IMAPMessagePart", &createObject);
}