blob: d70b29740a051e424f57b9fd4cda0a50c83a4200 (
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
83
84
85
86
87
88
89
90
91
92
93
94
|
#include "MCAbstractMultipart.h"
using namespace mailcore;
AbstractMultipart::AbstractMultipart()
{
init();
}
AbstractMultipart::AbstractMultipart(AbstractMultipart * other) : AbstractPart(other)
{
init();
setPartType(other->partType());
Array * parts = Array::array();
for(unsigned int i = 0 ; i < other->parts()->count() ; i ++) {
AbstractPart * part = (AbstractPart *) other->parts()->objectAtIndex(i);
parts->addObject(part->copy()->autorelease());
}
setParts(parts);
}
void AbstractMultipart::init()
{
mParts = NULL;
setPartType(PartTypeMultipartMixed);
}
AbstractMultipart::~AbstractMultipart()
{
MC_SAFE_RELEASE(mParts);
}
Array * AbstractMultipart::parts()
{
return mParts;
}
void AbstractMultipart::setParts(Array * parts)
{
MC_SAFE_REPLACE_COPY(Array, mParts, parts);
}
String * AbstractMultipart::description()
{
String * result = String::string();
const char * partTypeName = NULL;
switch (partType()) {
default:
case PartTypeMultipartMixed:
partTypeName = "mixed";
break;
case PartTypeMultipartRelated:
partTypeName = "related";
break;
case PartTypeMultipartAlternative:
partTypeName = "alternative";
break;
}
result->appendUTF8Format("<%s:%p %s %s>",
MCUTF8(className()), this, partTypeName, MCUTF8(mParts->description()));
return result;
}
Object * AbstractMultipart::copy()
{
return new AbstractMultipart(this);
}
AbstractPart * AbstractMultipart::partForContentID(String * contentID)
{
for(unsigned int i = 0 ; i < parts()->count() ; i ++) {
mailcore::AbstractPart * subpart = (mailcore::AbstractPart *) parts()->objectAtIndex(i);
mailcore::AbstractPart * result = subpart->partForContentID(contentID);
if (result != NULL)
return result;
}
return NULL;
}
AbstractPart * AbstractMultipart::partForUniqueID(String * uniqueID)
{
for(unsigned int i = 0 ; i < parts()->count() ; i ++) {
mailcore::AbstractPart * subpart = (mailcore::AbstractPart *) parts()->objectAtIndex(i);
mailcore::AbstractPart * result = subpart->partForUniqueID(uniqueID);
if (result != NULL)
return result;
}
return NULL;
}
|