aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/abstract/MCAbstractMessagePart.cc
blob: be6e8e9b76fd68819383c38585e11ff217b72d9c (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
78
79
#include "MCAbstractMessagePart.h"

#include "MCMessageHeader.h"

using namespace mailcore;

void AbstractMessagePart::init()
{
    mMainPart = NULL;
    mHeader = NULL;
    setPartType(PartTypeMessage);
}

AbstractMessagePart::AbstractMessagePart()
{
    init();
}

AbstractMessagePart::AbstractMessagePart(AbstractMessagePart * other) : AbstractPart(other)
{
    init();
    if (other->mainPart() != NULL) {
        setMainPart((AbstractPart *) other->mainPart()->copy()->autorelease());
    }
    if (other->mHeader != NULL) {
        setHeader((MessageHeader *) other->header()->copy()->autorelease());
    }
}

AbstractMessagePart::~AbstractMessagePart()
{
    MC_SAFE_RELEASE(mMainPart);
    MC_SAFE_RELEASE(mHeader);
}

String * AbstractMessagePart::description()
{
    String * result = String::string();
    result->appendUTF8Format("<%s:%p %s>", className()->UTF8Characters(), this, mMainPart->description()->UTF8Characters());
    return result;
}

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

MessageHeader * AbstractMessagePart::header()
{
    if (mHeader == NULL) {
        mHeader = new MessageHeader();
    }
    return mHeader;
}

void AbstractMessagePart::setHeader(MessageHeader * header)
{
    MC_SAFE_REPLACE_RETAIN(MessageHeader, mHeader, header);
}

AbstractPart * AbstractMessagePart::mainPart()
{
    return mMainPart;
}

void AbstractMessagePart::setMainPart(AbstractPart * mainPart)
{
    MC_SAFE_REPLACE_RETAIN(AbstractPart, mMainPart, mainPart);
}

AbstractPart * AbstractMessagePart::partForContentID(String * contentID)
{
    return mainPart()->partForContentID(contentID);
}

AbstractPart * AbstractMessagePart::partForUniqueID(String * contentID)
{
    return mainPart()->partForUniqueID(contentID);
}