diff options
author | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2015-01-03 23:10:15 -0800 |
---|---|---|
committer | Hoa V. DINH <dinh.viet.hoa@gmail.com> | 2015-01-03 23:10:24 -0800 |
commit | da10b9124b52e34ac49edd1120bc04926e0a44e6 (patch) | |
tree | e0b788d613d7cac4408a983dfedd55721fbdc187 /src/objc/imap | |
parent | a54deab9ad377fb36b21ec1fd67a67cb71824ea9 (diff) |
Refactoring, fixed #1013
Diffstat (limited to 'src/objc/imap')
-rw-r--r-- | src/objc/imap/MCOIMAPFolderInfo.h | 5 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPFolderInfo.m | 32 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPFolderInfo.mm | 72 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPFolderInfoOperation.mm | 14 | ||||
-rwxr-xr-x | src/objc/imap/MCOIMAPSession.mm | 8 |
5 files changed, 80 insertions, 51 deletions
diff --git a/src/objc/imap/MCOIMAPFolderInfo.h b/src/objc/imap/MCOIMAPFolderInfo.h index 53ad35b8..1397e841 100644 --- a/src/objc/imap/MCOIMAPFolderInfo.h +++ b/src/objc/imap/MCOIMAPFolderInfo.h @@ -14,10 +14,7 @@ /* This class holds IMAP folder metadata */ -@interface MCOIMAPFolderInfo : NSObject - -/** Create an empty instance */ -+ (MCOIMAPFolderInfo *) info; +@interface MCOIMAPFolderInfo : NSObject <NSCopying> /** The folder's IMAP UIDNEXT value. Used to determine the uid for the next received message. */ @property (nonatomic, assign) uint32_t uidNext; diff --git a/src/objc/imap/MCOIMAPFolderInfo.m b/src/objc/imap/MCOIMAPFolderInfo.m deleted file mode 100644 index be1d2c3e..00000000 --- a/src/objc/imap/MCOIMAPFolderInfo.m +++ /dev/null @@ -1,32 +0,0 @@ -// -// MCOIMAPFolderInfo.m -// mailcore2 -// -// Created by DINH Viêt Hoà on 3/25/13. -// Copyright (c) 2013 MailCore. All rights reserved. -// - -#import "MCOIMAPFolderInfo.h" - -@implementation MCOIMAPFolderInfo { - uint32_t _uidNext; - uint32_t _uidValidity; - uint64_t _modSequenceValue; - int _messageCount; - uint32_t _firstUnseenUid; - BOOL _allowsNewPermanentFlags; -} - -@synthesize uidNext = _uidNext; -@synthesize uidValidity = _uidValidity; -@synthesize modSequenceValue = _modSequenceValue; -@synthesize messageCount = _messageCount; -@synthesize firstUnseenUid = _firstUnseenUid; -@synthesize allowsNewPermanentFlags = _allowsNewPermanentFlags; - -+ (MCOIMAPFolderInfo *) info -{ - return [[[MCOIMAPFolderInfo alloc] init] autorelease]; -} - -@end diff --git a/src/objc/imap/MCOIMAPFolderInfo.mm b/src/objc/imap/MCOIMAPFolderInfo.mm new file mode 100644 index 00000000..50c7f995 --- /dev/null +++ b/src/objc/imap/MCOIMAPFolderInfo.mm @@ -0,0 +1,72 @@ +// +// MCOIMAPFolderInfo.m +// mailcore2 +// +// Created by DINH Viêt Hoà on 3/25/13. +// Copyright (c) 2013 MailCore. All rights reserved. +// + +#import "MCOIMAPFolderInfo.h" +#import "NSObject+MCO.h" + +#include "MCIMAPFolderInfo.h" + +#define nativeType mailcore::IMAPFolderInfo + +@implementation MCOIMAPFolderInfo { + mailcore::IMAPFolderInfo * _nativeInfo; +} + ++ (void) load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + +- (id) initWithMCFolderInfo:(mailcore::IMAPFolderInfo *)info +{ + self = [super init]; + + info->retain(); + _nativeInfo = info; + + return self; +} + +- (void) dealloc +{ + MC_SAFE_RELEASE(_nativeInfo); + [super dealloc]; +} + ++ (NSObject *) mco_objectWithMCObject:(mailcore::Object *)object +{ + mailcore::IMAPFolderInfo * info = (mailcore::IMAPFolderInfo *) object; + return [[[self alloc] initWithMCFolderInfo:info] autorelease]; +} + +- (mailcore::Object *) mco_mcObject +{ + return _nativeInfo; +} + +- (id) copyWithZone:(NSZone *)zone +{ + nativeType * nativeObject = (nativeType *) [self mco_mcObject]->copy(); + id result = [[self class] mco_objectWithMCObject:nativeObject]; + MC_SAFE_RELEASE(nativeObject); + return [result retain]; +} + +- (NSString *) description +{ + return MCO_OBJC_BRIDGE_GET(description); +} + +MCO_OBJC_SYNTHESIZE_SCALAR(uint32_t, uint32_t, setUidNext, uidNext) +MCO_OBJC_SYNTHESIZE_SCALAR(uint32_t, uint32_t, setUidValidity, uidValidity) +MCO_OBJC_SYNTHESIZE_SCALAR(uint64_t, uint64_t, setModSequenceValue, modSequenceValue) +MCO_OBJC_SYNTHESIZE_SCALAR(int, int, setMessageCount, messageCount) +MCO_OBJC_SYNTHESIZE_SCALAR(uint32_t, uint32_t, setFirstUnseenUid, firstUnseenUid) +MCO_OBJC_SYNTHESIZE_SCALAR(BOOL, bool, setAllowsNewPermanentFlags, allowsNewPermanentFlags) + +@end diff --git a/src/objc/imap/MCOIMAPFolderInfoOperation.mm b/src/objc/imap/MCOIMAPFolderInfoOperation.mm index f4d322af..10c22462 100644 --- a/src/objc/imap/MCOIMAPFolderInfoOperation.mm +++ b/src/objc/imap/MCOIMAPFolderInfoOperation.mm @@ -56,20 +56,12 @@ typedef void (^CompletionType)(NSError *error, MCOIMAPFolderInfo *info); { if (_completionBlock == NULL) return; - + nativeType *op = MCO_NATIVE_INSTANCE; if (op->error() == mailcore::ErrorNone) { - MCOIMAPFolderInfo * info = [MCOIMAPFolderInfo info]; - [info setUidNext:MCO_NATIVE_INSTANCE->uidNext()]; - [info setUidValidity:MCO_NATIVE_INSTANCE->uidValidity()]; - [info setModSequenceValue:MCO_NATIVE_INSTANCE->modSequenceValue()]; - [info setMessageCount:MCO_NATIVE_INSTANCE->messageCount()]; - [info setFirstUnseenUid:MCO_NATIVE_INSTANCE->firstUnseenUid()]; - [info setAllowsNewPermanentFlags:MCO_NATIVE_INSTANCE->allowsNewPermanentFlags()]; - + MCOIMAPFolderInfo * info = MCO_TO_OBJC(op->info()); _completionBlock(nil, info); - } - else { + } else { _completionBlock([NSError mco_errorWithErrorCode:op->error()], nil); } [_completionBlock release]; diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index 325beda7..97673518 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -321,10 +321,10 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue, uids:(MCOIndexSet *)uids modSeq:(uint64_t)modSeq { - IMAPFetchMessagesOperation * coreOp = MCO_NATIVE_INSTANCE->syncMessagesByUID([folder mco_mcString], - (IMAPMessagesRequestKind) requestKind, - MCO_FROM_OBJC(IndexSet, uids), - modSeq); + IMAPFetchMessagesOperation * coreOp = MCO_NATIVE_INSTANCE->syncMessagesByUIDOperation([folder mco_mcString], + (IMAPMessagesRequestKind) requestKind, + MCO_FROM_OBJC(IndexSet, uids), + modSeq); return MCO_TO_OBJC_OP(coreOp); } |