diff options
author | libec <libor.huspenina@gmail.com> | 2015-11-04 10:27:51 +0100 |
---|---|---|
committer | libec <libor.huspenina@gmail.com> | 2015-11-04 10:27:51 +0100 |
commit | 6a4a30034edc7d7b3f0a824e9b38f43d4b9910df (patch) | |
tree | 24b1fa27ba31a06c95817fbd22f0123f6452b6e9 /src/objc | |
parent | e3a1b98d0ed520683f4e13a734d4a397ab761f5f (diff) |
adds support to send custom IMAP command
Diffstat (limited to 'src/objc')
-rwxr-xr-x | src/objc/imap/MCOIMAP.h | 1 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPCustomCommandOperation.h | 24 | ||||
-rw-r--r-- | src/objc/imap/MCOIMAPCustomCommandOperation.mm | 69 | ||||
-rwxr-xr-x | src/objc/imap/MCOIMAPSession.h | 3 | ||||
-rwxr-xr-x | src/objc/imap/MCOIMAPSession.mm | 5 |
5 files changed, 102 insertions, 0 deletions
diff --git a/src/objc/imap/MCOIMAP.h b/src/objc/imap/MCOIMAP.h index 1957afd8..9483a36b 100755 --- a/src/objc/imap/MCOIMAP.h +++ b/src/objc/imap/MCOIMAP.h @@ -41,5 +41,6 @@ #import <MailCore/MCOIMAPQuotaOperation.h> #import <MailCore/MCOIMAPSearchExpression.h> #import <MailCore/MCOIMAPMessageRenderingOperation.h> +#import <MailCore/MCOIMAPCustomCommandOperation.h> #endif diff --git a/src/objc/imap/MCOIMAPCustomCommandOperation.h b/src/objc/imap/MCOIMAPCustomCommandOperation.h new file mode 100644 index 00000000..87124533 --- /dev/null +++ b/src/objc/imap/MCOIMAPCustomCommandOperation.h @@ -0,0 +1,24 @@ +// +// MCOIMAPCustomCommandOperation.h +// mailcore2 +// +// Created by Libor Huspenina on 29/10/2015. +// Copyright © 2015 MailCore. All rights reserved. +// + +#ifndef MAILCORE_MCOIMAPCUSTOMCOMMANDOPERATION_H + +#define MAILCORE_MCOIMAPCUSTOMCOMMANDOPERATION_H + +#import <MailCore/MCOIMAPBaseOperation.h> +#import <MailCore/MCOConstants.h> + +NS_ASSUME_NONNULL_BEGIN +@interface MCOIMAPCustomCommandOperation : MCOIMAPBaseOperation + +- (void)start:(void(^)(NSError * __nullable error))completionBlock; + +@end +NS_ASSUME_NONNULL_END + +#endif diff --git a/src/objc/imap/MCOIMAPCustomCommandOperation.mm b/src/objc/imap/MCOIMAPCustomCommandOperation.mm new file mode 100644 index 00000000..a9193477 --- /dev/null +++ b/src/objc/imap/MCOIMAPCustomCommandOperation.mm @@ -0,0 +1,69 @@ +// +// MCOIMAPCustomCommandOperation.m +// mailcore2 +// +// Created by Libor Huspenina on 29/10/2015. +// Copyright © 2015 MailCore. All rights reserved. +// + +#import "MCOIMAPCustomCommandOperation.h" + +#include "MCAsyncIMAP.h" + +#import "MCOOperation+Private.h" +#import "MCOUtils.h" + +typedef void (^CompletionType)(NSError *error); + +@implementation MCOIMAPCustomCommandOperation { + CompletionType _completionBlock; +} + +#define nativeType mailcore::IMAPCustomCommandOperation + ++ (void)load +{ + MCORegisterClass(self, &typeid(nativeType)); +} + ++ (NSObject *)mco_objectWithMCObject:(mailcore::Object *)object +{ + nativeType * op = (nativeType *)object; + return [[[self alloc] initWithMCOperation:op] autorelease]; +} + +- (void)dealloc +{ + [_completionBlock release]; + [super dealloc]; +} + +- (void)start:(void(^)(NSError * __nullable error))completionBlock +{ + _completionBlock = [completionBlock copy]; + [self start]; +} + +- (void)cancel +{ + [_completionBlock release]; + _completionBlock = nil; + [super cancel]; +} + +- (void)operationCompleted +{ + if (_completionBlock == NULL) + return; + + nativeType *op = MCO_NATIVE_INSTANCE; + if (op->error() == mailcore::ErrorNone) { + _completionBlock(nil); + } else { + _completionBlock([NSError mco_errorWithErrorCode:op->error()]); + } + [_completionBlock release]; + _completionBlock = nil; +} + +@end diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h index 454def4a..6b3b071e 100755 --- a/src/objc/imap/MCOIMAPSession.h +++ b/src/objc/imap/MCOIMAPSession.h @@ -34,6 +34,7 @@ @class MCOIMAPMessageRenderingOperation; @class MCOIMAPMessage; @class MCOIMAPIdentity; +@class MCOIMAPCustomCommandOperation; /** This is the main IMAP class from which all operations are created @@ -680,6 +681,8 @@ vanishedMessages will be set only for servers that support QRESYNC. See [RFC5162 encoding:(MCOEncoding)encoding urgent:(BOOL)urgent DEPRECATED_ATTRIBUTE; +- (MCOIMAPCustomCommandOperation *) customCommandOperation:(NSString *)command; + /** Returns an operation to fetch an attachment. diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm index 97673518..07e140b5 100755 --- a/src/objc/imap/MCOIMAPSession.mm +++ b/src/objc/imap/MCOIMAPSession.mm @@ -435,6 +435,11 @@ MCO_OBJC_SYNTHESIZE_SCALAR(dispatch_queue_t, dispatch_queue_t, setDispatchQueue, return MCO_TO_OBJC_OP(coreOp); } +- (MCOIMAPCustomCommandOperation *) customCommandOperation:(NSString *)command { + IMAPCustomCommandOperation *customOp = MCO_NATIVE_INSTANCE->sendCustomCommand([command mco_mcString], false); + return MCO_TO_OBJC_OP(customOp); +} + - (MCOIMAPFetchContentOperation *) fetchMessageAttachmentOperationWithFolder:(NSString *)folder uid:(uint32_t)uid partID:(NSString *)partID |