aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc/imap
diff options
context:
space:
mode:
authorGravatar Pushkar Singh <pushkar@hothouselabs.com>2013-07-20 22:49:28 -0700
committerGravatar Pushkar Singh <pushkar@hothouselabs.com>2013-07-20 22:49:28 -0700
commit52473496926f12877dca66ad44ac1af65e9406d6 (patch)
treec839a7674083a7795d278faefeea161a9d267fdc /src/objc/imap
parent0bc680acc776bd83dd9f0300015fc85b5e9aad7f (diff)
parent798a4b1117527acc1de523b13577d86fe7df990b (diff)
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/objc/imap')
-rw-r--r--src/objc/imap/MCOIMAP.h1
-rw-r--r--src/objc/imap/MCOIMAPFetchMessagesOperation.h3
-rw-r--r--src/objc/imap/MCOIMAPFetchMessagesOperation.mm8
-rw-r--r--src/objc/imap/MCOIMAPMessageRenderingOperation.h35
-rw-r--r--src/objc/imap/MCOIMAPMessageRenderingOperation.mm61
-rw-r--r--src/objc/imap/MCOIMAPSearchExpression.mm2
-rw-r--r--src/objc/imap/MCOIMAPSession.h60
-rw-r--r--src/objc/imap/MCOIMAPSession.mm41
8 files changed, 209 insertions, 2 deletions
diff --git a/src/objc/imap/MCOIMAP.h b/src/objc/imap/MCOIMAP.h
index a6c1ff0c..f0994042 100644
--- a/src/objc/imap/MCOIMAP.h
+++ b/src/objc/imap/MCOIMAP.h
@@ -37,5 +37,6 @@
#import <MailCore/MCOIMAPIdentityOperation.h>
#import <MailCore/MCOIMAPCapabilityOperation.h>
#import <MailCore/MCOIMAPSearchExpression.h>
+#import <MailCore/MCOIMAPMessageRenderingOperation.h>
#endif
diff --git a/src/objc/imap/MCOIMAPFetchMessagesOperation.h b/src/objc/imap/MCOIMAPFetchMessagesOperation.h
index 659d9bca..c232764d 100644
--- a/src/objc/imap/MCOIMAPFetchMessagesOperation.h
+++ b/src/objc/imap/MCOIMAPFetchMessagesOperation.h
@@ -22,6 +22,9 @@
/** This block will be called each time a new message is downloaded. */
@property (nonatomic, copy) MCOIMAPBaseOperationItemProgressBlock progress;
+/** Extra headers to request. Must set requestKind | IMAPMessagesRequestKindExtraHeaders */
+@property (nonatomic, copy) NSArray * extraHeaders;
+
/**
Starts the asynchronous fetch operation.
diff --git a/src/objc/imap/MCOIMAPFetchMessagesOperation.mm b/src/objc/imap/MCOIMAPFetchMessagesOperation.mm
index 6892ab1b..5ae4cfe7 100644
--- a/src/objc/imap/MCOIMAPFetchMessagesOperation.mm
+++ b/src/objc/imap/MCOIMAPFetchMessagesOperation.mm
@@ -64,4 +64,12 @@ typedef void (^CompletionType)(NSError *error, NSArray * messages, MCOIndexSet *
}
}
+- (void)setExtraHeaders:(NSArray *)extraHeaders {
+ MCO_NATIVE_INSTANCE->setExtraHeaders(MCO_FROM_OBJC(mailcore::Array, extraHeaders));
+}
+
+- (NSArray *)extraHeaders {
+ return MCO_TO_OBJC(MCO_NATIVE_INSTANCE->extraHeaders());
+}
+
@end
diff --git a/src/objc/imap/MCOIMAPMessageRenderingOperation.h b/src/objc/imap/MCOIMAPMessageRenderingOperation.h
new file mode 100644
index 00000000..c22909a2
--- /dev/null
+++ b/src/objc/imap/MCOIMAPMessageRenderingOperation.h
@@ -0,0 +1,35 @@
+//
+// MCOIMAPMessageRenderingOperation.h
+// mailcore2
+//
+// Created by Paul Young on 07/07/2013.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#ifndef __MAILCORE_MCOIMAPMESSAGERENDERINGOPERATION_H_
+
+#define __MAILCORE_MCOIMAPMESSAGERENDERINGOPERATION_H_
+
+#import <MailCore/MCOIMAPBaseOperation.h>
+
+/**
+ The class is used to get the HTML string of a message.
+ */
+
+@interface MCOIMAPMessageRenderingOperation : MCOIMAPBaseOperation
+
+/**
+ Starts the asynchronous operation.
+
+ @param completionBlock Called when the operation is finished.
+
+ - On success `error` will be nil and `htmlString` will contain the message
+
+ - On failure, `error` will be set and `htmlString` will be nil
+ */
+
+- (void) start:(void (^)(NSString * htmlString, NSError * error))completionBlock;
+
+@end
+
+#endif
diff --git a/src/objc/imap/MCOIMAPMessageRenderingOperation.mm b/src/objc/imap/MCOIMAPMessageRenderingOperation.mm
new file mode 100644
index 00000000..983b6cac
--- /dev/null
+++ b/src/objc/imap/MCOIMAPMessageRenderingOperation.mm
@@ -0,0 +1,61 @@
+//
+// MCOIMAPMessageRenderingOperation.mm
+// mailcore2
+//
+// Created by Paul Young on 07/07/2013.
+// Copyright (c) 2013 MailCore. All rights reserved.
+//
+
+#import "MCOIMAPMessageRenderingOperation.h"
+
+#include "MCAsyncIMAP.h"
+#include "MCIMAPMessageRenderingOperation.h"
+
+#import "MCOOperation+Private.h"
+#import "MCOUtils.h"
+
+typedef void (^CompletionType)(NSString * htmlString, NSError * error);
+
+@implementation MCOIMAPMessageRenderingOperation {
+ CompletionType _completionBlock;
+}
+
+#define nativeType mailcore::IMAPMessageRenderingOperation
+
++ (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 (^)(NSString * htmlString, NSError * error))completionBlock {
+ _completionBlock = [completionBlock copy];
+ [self start];
+}
+
+- (void)operationCompleted {
+ if (_completionBlock == NULL)
+ return;
+
+ nativeType *op = MCO_NATIVE_INSTANCE;
+ if (op->error() == mailcore::ErrorNone) {
+ _completionBlock([NSString mco_stringWithMCString:op->result()], nil);
+ } else {
+ _completionBlock(nil, [NSError mco_errorWithErrorCode:op->error()]);
+ }
+ [_completionBlock release];
+ _completionBlock = nil;
+}
+
+@end
diff --git a/src/objc/imap/MCOIMAPSearchExpression.mm b/src/objc/imap/MCOIMAPSearchExpression.mm
index dc2e027a..f1bc3046 100644
--- a/src/objc/imap/MCOIMAPSearchExpression.mm
+++ b/src/objc/imap/MCOIMAPSearchExpression.mm
@@ -84,7 +84,7 @@
+ (MCOIMAPSearchExpression *) searchAnd:(MCOIMAPSearchExpression *)expression other:(MCOIMAPSearchExpression *)other
{
- mailcore::IMAPSearchExpression * result = mailcore::IMAPSearchExpression::searchOr(expression->_nativeExpr, other->_nativeExpr);
+ mailcore::IMAPSearchExpression * result = mailcore::IMAPSearchExpression::searchAnd(expression->_nativeExpr, other->_nativeExpr);
return MCO_TO_OBJC(result);
}
diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h
index 3a6cbc6f..5db608f7 100644
--- a/src/objc/imap/MCOIMAPSession.h
+++ b/src/objc/imap/MCOIMAPSession.h
@@ -29,6 +29,8 @@
@class MCOIMAPSearchExpression;
@class MCOIMAPIdentityOperation;
@class MCOIMAPCapabilityOperation;
+@class MCOIMAPMessageRenderingOperation;
+@class MCOIMAPMessage;
/**
This is the main IMAP class from which all operations are created
@@ -71,7 +73,7 @@
@property (nonatomic, assign) NSTimeInterval timeout;
/** When set to YES, the connection will fail if the certificate is incorrect. */
-@property (nonatomic, assign) BOOL checkCertificateEnabled;
+@property (nonatomic, assign, getter=isCheckCertificateEnabled) BOOL checkCertificateEnabled;
/** When set to YES, VoIP capability will be enabled on the IMAP connection on iOS */
@property (nonatomic, assign, getter=isVoIPEnabled) BOOL voIPEnabled;
@@ -534,6 +536,62 @@
- (MCOIMAPSearchOperation *) searchExpressionOperationWithFolder:(NSString *)folder
expression:(MCOIMAPSearchExpression *)expression;
+/** @name Rendering Operations */
+
+/**
+ Returns an operation to render the HTML version of a message to be displayed in a web view.
+
+ MCOIMAPMessageRenderingOperation * op = [session htmlRenderingOperationWithMessage:msg
+ folder:@"INBOX"];
+
+ [op start:^(NSString * htmlString, NSError * error) {
+ ...
+ }];
+*/
+- (MCOIMAPMessageRenderingOperation *) htmlRenderingOperationWithMessage:(MCOIMAPMessage *)message
+ folder:(NSString *)folder;
+
+/**
+ Returns an operation to render the HTML body of a message to be displayed in a web view.
+
+ MCOIMAPMessageRenderingOperation * op = [session htmlBodyRenderingOperationWithMessage:msg
+ folder:@"INBOX"];
+
+ [op start:^(NSString * htmlString, NSError * error) {
+ ...
+ }];
+ */
+- (MCOIMAPMessageRenderingOperation *) htmlBodyRenderingOperationWithMessage:(MCOIMAPMessage *)message
+ folder:(NSString *)folder;
+
+/**
+ Returns an operation to render the plain text version of a message.
+
+ MCOIMAPMessageRenderingOperation * op = [session plainTextRenderingOperationWithMessage:msg
+ folder:@"INBOX"];
+
+ [op start:^(NSString * htmlString, NSError * error) {
+ ...
+ }];
+ */
+- (MCOIMAPMessageRenderingOperation *) plainTextRenderingOperationWithMessage:(MCOIMAPMessage *)message
+ folder:(NSString *)folder;
+
+/**
+ Returns an operation to render the plain text body of a message.
+ All end of line will be removed and white spaces cleaned up.
+ This method can be used to generate the summary of the message.
+
+ MCOIMAPMessageRenderingOperation * op = [session plainTextBodyRenderingOperationWithMessage:msg
+ folder:@"INBOX"];
+
+ [op start:^(NSString * htmlString, NSError * error) {
+ ...
+ }];
+ */
+- (MCOIMAPMessageRenderingOperation *) plainTextBodyRenderingOperationWithMessage:(MCOIMAPMessage *)message
+ folder:(NSString *)folder;
+
@end
#endif
diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm
index 1dff0f1f..2546e612 100644
--- a/src/objc/imap/MCOIMAPSession.mm
+++ b/src/objc/imap/MCOIMAPSession.mm
@@ -14,11 +14,14 @@
#import "MCOIMAPOperation.h"
#import "MCOIMAPFetchFoldersOperation.h"
#import "MCOIMAPBaseOperation+Private.h"
+#import "MCOIMAPMessageRenderingOperation.h"
#import "MCOUtils.h"
#import <MailCore/MCAsync.h>
+#include "MCIMAPMessageRenderingOperation.h"
+
using namespace mailcore;
@@ -87,6 +90,16 @@ MCO_OBJC_SYNTHESIZE_SCALAR(char, char, setDelimiter, delimiter)
MCO_OBJC_SYNTHESIZE_SCALAR(BOOL, BOOL, setAllowsFolderConcurrentAccessEnabled, allowsFolderConcurrentAccessEnabled)
MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, maximumConnections)
+- (void) setDefaultNamespace:(MCOIMAPNamespace *)defaultNamespace
+{
+ _session->setDefaultNamespace(MCO_FROM_OBJC(IMAPNamespace, defaultNamespace));
+}
+
+- (MCOIMAPNamespace *) defaultNamespace
+{
+ return MCO_TO_OBJC(_session->defaultNamespace());
+}
+
- (void) setConnectionLogger:(MCOConnectionLogger)connectionLogger
{
[_connectionLogger release];
@@ -354,4 +367,32 @@ MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setMaximumConnections, ma
_connectionLogger(sender, logType, data);
}
+- (MCOIMAPMessageRenderingOperation *) htmlRenderingOperationWithMessage:(MCOIMAPMessage *)message
+ folder:(NSString *)folder
+{
+ IMAPMessageRenderingOperation * coreOp = MCO_NATIVE_INSTANCE->htmlRenderingOperation(MCO_FROM_OBJC(IMAPMessage, message), [folder mco_mcString]);
+ return MCO_TO_OBJC_OP(coreOp);
+}
+
+- (MCOIMAPMessageRenderingOperation *) htmlBodyRenderingOperationWithMessage:(MCOIMAPMessage *)message
+ folder:(NSString *)folder
+{
+ IMAPMessageRenderingOperation * coreOp = MCO_NATIVE_INSTANCE->htmlBodyRenderingOperation(MCO_FROM_OBJC(IMAPMessage, message), [folder mco_mcString]);
+ return MCO_TO_OBJC_OP(coreOp);
+}
+
+- (MCOIMAPMessageRenderingOperation *) plainTextRenderingOperationWithMessage:(MCOIMAPMessage *)message
+ folder:(NSString *)folder
+{
+ IMAPMessageRenderingOperation * coreOp = MCO_NATIVE_INSTANCE->plainTextRenderingOperation(MCO_FROM_OBJC(IMAPMessage, message), [folder mco_mcString]);
+ return MCO_TO_OBJC_OP(coreOp);
+}
+
+- (MCOIMAPMessageRenderingOperation *) plainTextBodyRenderingOperationWithMessage:(MCOIMAPMessage *)message
+ folder:(NSString *)folder
+{
+ IMAPMessageRenderingOperation * coreOp = MCO_NATIVE_INSTANCE->plainTextBodyRenderingOperation(MCO_FROM_OBJC(IMAPMessage, message), [folder mco_mcString]);
+ return MCO_TO_OBJC_OP(coreOp);
+}
+
@end