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

#import "MCOIMAPBaseOperation.h"
#import "MCOIMAPBaseOperation+Private.h"

#import "MCOOperation+Private.h"

#import "MCAsyncIMAP.h"
#import "MCOIMAPSession.h"
#import "NSObject+MCO.h"

class MCOIMAPBaseOperationIMAPCallback : public mailcore::IMAPOperationCallback {
public:
    MCOIMAPBaseOperationIMAPCallback(MCOIMAPBaseOperation * op)
    {
        mOperation = op;
    }
    
    virtual ~MCOIMAPBaseOperationIMAPCallback()
    {
    }
    
    virtual void bodyProgress(mailcore::IMAPOperation * session, unsigned int current, unsigned int maximum) {
        [mOperation bodyProgress:current maximum:maximum];
    }
    
    virtual void itemProgress(mailcore::IMAPOperation * session, unsigned int current, unsigned int maximum) {
        [mOperation itemProgress:current maximum:maximum];
    }
    
private:
    MCOIMAPBaseOperation * mOperation;
};

@implementation MCOIMAPBaseOperation {
    MCOIMAPBaseOperationIMAPCallback * _imapCallback;
    MCOIMAPSession * _session;
}

#define nativeType mailcore::IMAPOperation

MCO_OBJC_SYNTHESIZE_SCALAR(BOOL, bool, setUrgent, isUrgent)

- (instancetype) initWithMCOperation:(mailcore::Operation *)op
{
    self = [super initWithMCOperation:op];
    
    _imapCallback = new MCOIMAPBaseOperationIMAPCallback(self);
    ((mailcore::IMAPOperation *) op)->setImapCallback(_imapCallback);
    
    return self;
}

- (void) dealloc
{
    [_session release];
    delete _imapCallback;
    [super dealloc];
}

- (void) setSession:(MCOIMAPSession *)session
{
    [_session release];
    _session = [session retain];
}

- (MCOIMAPSession *) session
{
    return _session;
}

- (void) bodyProgress:(unsigned int)current maximum:(unsigned int)maximum
{
}

- (void) itemProgress:(unsigned int)current maximum:(unsigned int)maximum
{
}

@end