blob: afaf96af530535eac329a22d4d2d12228f3c045d (
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
|
//
// MCOAttachment.m
// mailcore2
//
// Created by DINH Viêt Hoà on 3/22/13.
// Copyright (c) 2013 MailCore. All rights reserved.
//
#import "MCOAttachment.h"
#include "MCAttachment.h"
#import "MCOAbstractPart+Private.h"
#import "MCOUtils.h"
#import "NSString+MCO.h"
#import "NSObject+MCO.h"
@implementation MCOAttachment {
NSData * _data;
}
#define nativeType mailcore::Attachment
+ (void) load
{
MCORegisterClass(self, &typeid(nativeType));
}
+ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object
{
mailcore::Attachment * attachment = (mailcore::Attachment *) object;
return [[[self alloc] initWithMCPart:attachment] autorelease];
}
- (id) init
{
mailcore::Attachment * attachment = new mailcore::Attachment();
self = [self initWithMCPart:attachment];
attachment->release();
return self;
}
- (void) dealloc
{
[_data release];
[super dealloc];
}
+ (NSString *) mimeTypeForFilename:(NSString *)filename
{
return [NSString mco_stringWithMCString:mailcore::Attachment::mimeTypeForFilename([filename mco_mcString])];
}
+ (MCOAttachment *) attachmentWithContentsOfFile:(NSString *)filename
{
mailcore::Attachment * result = mailcore::Attachment::attachmentWithContentsOfFile([filename mco_mcString]);
return MCO_TO_OBJC(result);
}
+ (MCOAttachment *) attachmentWithData:(NSData *)data filename:(NSString *)filename
{
mailcore::Attachment * result = mailcore::Attachment::attachmentWithData([filename mco_mcString], [data mco_mcData]);
return MCO_TO_OBJC(result);
}
+ (MCOAttachment *) attachmentWithHTMLString:(NSString *)htmlString
{
mailcore::Attachment * result = mailcore::Attachment::attachmentWithHTMLString([htmlString mco_mcString]);
return MCO_TO_OBJC(result);
}
+ (MCOAttachment *) attachmentWithRFC822Message:(NSData *)messageData
{
mailcore::Attachment * result = mailcore::Attachment::attachmentWithRFC822Message([messageData mco_mcData]);
return MCO_TO_OBJC(result);
}
+ (MCOAttachment *) attachmentWithText:(NSString *)text
{
mailcore::Attachment * result = mailcore::Attachment::attachmentWithText([text mco_mcString]);
return MCO_TO_OBJC(result);
}
MCO_OBJC_SYNTHESIZE_DATA(setData, data)
- (NSString *) decodedString
{
mailcore::String *result = MCO_NATIVE_INSTANCE->decodedString();
return [NSString mco_stringWithMCString:result];
}
@end
|