aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/abstract/MCAbstractMessage.cc
blob: a7e7399224a8bf5030b6eb1e8f82050bd6469474 (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
80
81
82
#include "MCAbstractMessage.h"

#include "MCMessageHeader.h"
#include "MCHTMLRenderer.h"

using namespace mailcore;

AbstractMessage::AbstractMessage()
{
    init();
}

AbstractMessage::AbstractMessage(AbstractMessage * other)
{
    init();
    mHeader = (MessageHeader *) MC_SAFE_COPY(other->mHeader);
}

void AbstractMessage::init()
{
    mHeader = NULL;
}

AbstractMessage::~AbstractMessage()
{
    MC_SAFE_RELEASE(mHeader);
}

String * AbstractMessage::description()
{
    if (mHeader != NULL) {
        String * result = String::string();
        result->appendUTF8Format("<%s:%p\n", className()->UTF8Characters(), this);
        result->appendString(mHeader->description());
        result->appendUTF8Characters(">");
        return result;
    }
    else {
        return Object::description();
    }
}

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

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

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

AbstractPart * AbstractMessage::partForContentID(String * contentID)
{
    MCAssert(0);
    return NULL;
}

AbstractPart * AbstractMessage::partForUniqueID(String * uniqueID)
{
    MCAssert(0);
    return NULL;
}

Array * AbstractMessage::attachments()
{
    return HTMLRenderer::attachmentsForMessage(this);
}

Array * AbstractMessage::htmlInlineAttachments()
{
    return HTMLRenderer::htmlInlineAttachmentsForMessage(this);
}