aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/rfc822/MCOMessageParser.mm
blob: a964c0648d09f8bf88ad684bcf4d7c104c0d2554 (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
//
//  MCOMessageParser.m
//  mailcore2
//
//  Created by DINH Viêt Hoà on 3/22/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#import "MCOMessageParser.h"

#include "MCRFC822.h"

#import "NSObject+MCO.h"
#import "MCOAbstractMessage+Private.h"
#import "MCOUtils.h"

@implementation MCOMessageParser {
    id <MCOMessageParserDelegate> _delegate;
}

@synthesize delegate = _delegate;

#define nativeType mailcore::MessageParser

+ (void) initialize
{
    MCORegisterClass(self, &typeid(nativeType));
}

+ (id) mco_objectWithMCObject:(mailcore::Object *)object
{
    mailcore::MessageParser * msg = (mailcore::MessageParser *) object;
    return [[[self alloc] initWithMCMessage:msg] autorelease];
}

+ (MCOMessageParser *) messageParserWithData:(NSData *)data
{
    return [[[MCOMessageParser alloc] initWithData:data] autorelease];
}

- (id) initWithData:(NSData *)data
{
    mailcore::MessageParser * message = new mailcore::MessageParser([data mco_mcData]);
    self = [super initWithMCMessage:message];
    message->release();
    return self;
}

- (void) dealloc
{
    [super dealloc];
}

- (MCOAbstractPart *) mainPart
{
    return MCO_OBJC_BRIDGE_GET(mainPart);
}

- (NSData *) data
{
    return MCO_OBJC_BRIDGE_GET(data);
}

- (NSString *) htmlRendering
{
#warning should implement callbacks
    return MCO_TO_OBJC(MCO_NATIVE_INSTANCE->htmlRendering());
}

@end