aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objc
diff options
context:
space:
mode:
authorGravatar CodaFi <devteam.codafi@gmail.com>2013-07-08 09:17:18 -0600
committerGravatar CodaFi <devteam.codafi@gmail.com>2013-07-08 09:17:18 -0600
commit1b69c3bdedd080ee83911a1364c2bcb326e9fb91 (patch)
tree01d10fcf09eecd3ea643729dd65e3cd0c0dd97ae /src/objc
parent1c7c1d4a5474b093f82f43d514bbb043047d4489 (diff)
parent4a66387ae118a620c1b09a1ae606cecf6bf70319 (diff)
Merge remote-tracking branch 'upstream/master' into NSCoding-NSCopying
Diffstat (limited to 'src/objc')
-rw-r--r--src/objc/abstract/MCOConstants.h2
-rw-r--r--src/objc/imap/MCOIMAPSession.h9
-rw-r--r--src/objc/imap/MCOIMAPSession.mm3
-rw-r--r--src/objc/pop/MCOPOPSession.mm2
-rw-r--r--src/objc/rfc822/MCOMessageBuilder.h10
-rw-r--r--src/objc/rfc822/MCOMessageBuilder.mm16
-rw-r--r--src/objc/rfc822/MCOMessageParser.h10
-rw-r--r--src/objc/rfc822/MCOMessageParser.mm15
-rw-r--r--src/objc/smtp/MCOSMTPSession.h3
-rw-r--r--src/objc/smtp/MCOSMTPSession.mm3
-rw-r--r--src/objc/utils/NSError+MCO.mm50
11 files changed, 114 insertions, 9 deletions
diff --git a/src/objc/abstract/MCOConstants.h b/src/objc/abstract/MCOConstants.h
index 5ec21422..58239811 100644
--- a/src/objc/abstract/MCOConstants.h
+++ b/src/objc/abstract/MCOConstants.h
@@ -324,6 +324,8 @@ typedef enum {
MCOErrorDeleteMessage,
/** SMTP: Error while checking account.*/
MCOErrorInvalidAccount,
+ /** The count of all errors */
+ MCOErrorCodeCount,
} MCOErrorCode;
/** Here's the list of connection log types.*/
diff --git a/src/objc/imap/MCOIMAPSession.h b/src/objc/imap/MCOIMAPSession.h
index 0358f7ad..3a6cbc6f 100644
--- a/src/objc/imap/MCOIMAPSession.h
+++ b/src/objc/imap/MCOIMAPSession.h
@@ -40,16 +40,19 @@
@interface MCOIMAPSession : NSObject
/** This is the hostname of the IMAP server to connect to. */
-@property (nonatomic, strong) NSString *hostname;
+@property (nonatomic, copy) NSString *hostname;
/** This is the port of the IMAP server to connect to. */
@property (nonatomic, assign) unsigned int port;
/** This is the username of the account. */
-@property (nonatomic, strong) NSString *username;
+@property (nonatomic, copy) NSString *username;
/** This is the password of the account. */
-@property (nonatomic, strong) NSString *password;
+@property (nonatomic, copy) NSString *password;
+
+/** This is the OAuth2 token. */
+@property (nonatomic, copy) NSString *OAuth2Token;
/**
This is the authentication type to use to connect.
diff --git a/src/objc/imap/MCOIMAPSession.mm b/src/objc/imap/MCOIMAPSession.mm
index 43f366e6..1dff0f1f 100644
--- a/src/objc/imap/MCOIMAPSession.mm
+++ b/src/objc/imap/MCOIMAPSession.mm
@@ -35,7 +35,7 @@ public:
mSession = session;
}
- virtual void log(void * context, void * sender, ConnectionLogType logType, Data * data)
+ virtual void log(void * sender, ConnectionLogType logType, Data * data)
{
[mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)];
}
@@ -77,6 +77,7 @@ MCO_OBJC_SYNTHESIZE_STRING(setHostname, hostname)
MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setPort, port)
MCO_OBJC_SYNTHESIZE_STRING(setUsername, username)
MCO_OBJC_SYNTHESIZE_STRING(setPassword, password)
+MCO_OBJC_SYNTHESIZE_STRING(setOAuth2Token, OAuth2Token)
MCO_OBJC_SYNTHESIZE_SCALAR(MCOAuthType, mailcore::AuthType, setAuthType, authType)
MCO_OBJC_SYNTHESIZE_SCALAR(MCOConnectionType, mailcore::ConnectionType, setConnectionType, connectionType)
MCO_OBJC_SYNTHESIZE_SCALAR(NSTimeInterval, time_t, setTimeout, timeout)
diff --git a/src/objc/pop/MCOPOPSession.mm b/src/objc/pop/MCOPOPSession.mm
index 42c76646..fb48cb1e 100644
--- a/src/objc/pop/MCOPOPSession.mm
+++ b/src/objc/pop/MCOPOPSession.mm
@@ -31,7 +31,7 @@ public:
mSession = session;
}
- virtual void log(void * context, void * sender, ConnectionLogType logType, Data * data)
+ virtual void log(void * sender, ConnectionLogType logType, Data * data)
{
[mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)];
}
diff --git a/src/objc/rfc822/MCOMessageBuilder.h b/src/objc/rfc822/MCOMessageBuilder.h
index 217ec49c..5ba199a4 100644
--- a/src/objc/rfc822/MCOMessageBuilder.h
+++ b/src/objc/rfc822/MCOMessageBuilder.h
@@ -61,6 +61,16 @@
/** HTML rendering of the message to be displayed in a web view. The delegate can be nil.*/
- (NSString *) htmlRenderingWithDelegate:(id <MCOHTMLRendererDelegate>)delegate;
+/** HTML rendering of the body of the message to be displayed in a web view.*/
+- (NSString *) htmlBodyRendering;
+
+/** Text rendering of the message.*/
+- (NSString *) plainTextRendering;
+
+/** Text rendering of the body of the 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.*/
+- (NSString *) plainTextBodyRendering;
+
@end
#endif
diff --git a/src/objc/rfc822/MCOMessageBuilder.mm b/src/objc/rfc822/MCOMessageBuilder.mm
index 2cb26448..dfcf6028 100644
--- a/src/objc/rfc822/MCOMessageBuilder.mm
+++ b/src/objc/rfc822/MCOMessageBuilder.mm
@@ -75,4 +75,20 @@ MCO_OBJC_SYNTHESIZE_STRING(setBoundaryPrefix, boundaryPrefix)
return result;
}
+
+- (NSString *) htmlBodyRendering
+{
+ return MCO_OBJC_BRIDGE_GET(htmlBodyRendering);
+}
+
+- (NSString *) plainTextRendering
+{
+ return MCO_OBJC_BRIDGE_GET(plainTextRendering);
+}
+
+- (NSString *) plainTextBodyRendering
+{
+ return MCO_OBJC_BRIDGE_GET(plainTextBodyRendering);
+}
+
@end
diff --git a/src/objc/rfc822/MCOMessageParser.h b/src/objc/rfc822/MCOMessageParser.h
index fac86b89..5a009bb7 100644
--- a/src/objc/rfc822/MCOMessageParser.h
+++ b/src/objc/rfc822/MCOMessageParser.h
@@ -38,6 +38,16 @@
/** HTML rendering of the message to be displayed in a web view. delegate can be nil.*/
- (NSString *) htmlRenderingWithDelegate:(id <MCOHTMLRendererDelegate>)delegate;
+/** HTML rendering of the body of the message to be displayed in a web view.*/
+- (NSString *) htmlBodyRendering;
+
+/** Text rendering of the message.*/
+- (NSString *) plainTextRendering;
+
+/** Text rendering of the body of the 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.*/
+- (NSString *) plainTextBodyRendering;
+
@end
#endif
diff --git a/src/objc/rfc822/MCOMessageParser.mm b/src/objc/rfc822/MCOMessageParser.mm
index 7d7f9fcb..8e3f1261 100644
--- a/src/objc/rfc822/MCOMessageParser.mm
+++ b/src/objc/rfc822/MCOMessageParser.mm
@@ -69,4 +69,19 @@
return result;
}
+- (NSString *) htmlBodyRendering
+{
+ return MCO_OBJC_BRIDGE_GET(htmlBodyRendering);
+}
+
+- (NSString *) plainTextRendering
+{
+ return MCO_OBJC_BRIDGE_GET(plainTextRendering);
+}
+
+- (NSString *) plainTextBodyRendering
+{
+ return MCO_OBJC_BRIDGE_GET(plainTextBodyRendering);
+}
+
@end
diff --git a/src/objc/smtp/MCOSMTPSession.h b/src/objc/smtp/MCOSMTPSession.h
index 44d37942..bb7c5f57 100644
--- a/src/objc/smtp/MCOSMTPSession.h
+++ b/src/objc/smtp/MCOSMTPSession.h
@@ -39,6 +39,9 @@
/** This is the password of the account. */
@property (nonatomic, copy) NSString * password;
+/** This is the OAuth2 token. */
+@property (nonatomic, copy) NSString *OAuth2Token;
+
/**
This is the authentication type to use to connect.
`MCOAuthTypeSASLNone` means that it uses the clear-text is used (and is the default).
diff --git a/src/objc/smtp/MCOSMTPSession.mm b/src/objc/smtp/MCOSMTPSession.mm
index 1538d53a..c9f9f0fc 100644
--- a/src/objc/smtp/MCOSMTPSession.mm
+++ b/src/objc/smtp/MCOSMTPSession.mm
@@ -32,7 +32,7 @@ public:
mSession = session;
}
- virtual void log(void * context, void * sender, ConnectionLogType logType, Data * data)
+ virtual void log(void * sender, ConnectionLogType logType, Data * data)
{
[mSession _logWithSender:sender connectionType:(MCOConnectionLogType)logType data:MCO_TO_OBJC(data)];
}
@@ -74,6 +74,7 @@ MCO_OBJC_SYNTHESIZE_STRING(setHostname, hostname)
MCO_OBJC_SYNTHESIZE_SCALAR(unsigned int, unsigned int, setPort, port)
MCO_OBJC_SYNTHESIZE_STRING(setUsername, username)
MCO_OBJC_SYNTHESIZE_STRING(setPassword, password)
+MCO_OBJC_SYNTHESIZE_STRING(setOAuth2Token, OAuth2Token)
MCO_OBJC_SYNTHESIZE_SCALAR(MCOAuthType, mailcore::AuthType, setAuthType, authType)
MCO_OBJC_SYNTHESIZE_SCALAR(MCOConnectionType, mailcore::ConnectionType, setConnectionType, connectionType)
MCO_OBJC_SYNTHESIZE_SCALAR(NSTimeInterval, time_t, setTimeout, timeout)
diff --git a/src/objc/utils/NSError+MCO.mm b/src/objc/utils/NSError+MCO.mm
index c9f4f998..47abf809 100644
--- a/src/objc/utils/NSError+MCO.mm
+++ b/src/objc/utils/NSError+MCO.mm
@@ -7,15 +7,59 @@
#import "MCOConstants.h"
+static NSString * MCOLocalizedDescriptionTable[] = {
+ @"The operation succeeded.", /** MCOErrorNone */
+ @"A stable connection to the server could not be established.", /** MCOErrorConnection */
+ @"The server does not support TLS/SSL connections.", /** MCOErrorTLSNotAvailable */
+ @"Unable to parse response from server.", /** MCOErrorParse */
+ @"The certificate for this server is invalid.", /** MCOErrorCertificate */
+ @"Unable to authenticate with the current session's credentials.", /** MCOErrorAuthentication */
+ @"IMAP is not enabled for this Gmail account.", /** MCOErrorGmailIMAPNotEnabled */
+ @"Bandwidth limits were exceeded while requesting data from this Gmail account.", /** MCOErrorGmailExceededBandwidthLimit */
+ @"Too many simultaneous connections were made to this Gmail account.", /** MCOErrorGmailTooManySimultaneousConnections */
+ @"MobileMe is no longer an active mail service.", /** MCOErrorMobileMeMoved */
+ @"Yahoo!'s servers are currently unavailable.", /** MCOErrorYahooUnavailable */
+ @"The requested folder does not exist. Folder selection failed", /** MCOErrorNonExistantFolder */
+ @"An error occured while renaming the requested folder.", /** MCOErrorRename */
+ @"An error occured while deleting the requested folder.", /** MCOErrorDelete */
+ @"An error occured while creating the requested folder.", /** MCOErrorCreate */
+ @"An error occured while (un)subscribing to the requested folder.", /** MCOErrorSubscribe */
+ @"An error occured while appending a message to the requested folder.", /** MCOErrorAppend */
+ @"An error occured while copying a message to the requested folder.", /** MCOErrorCopy */
+ @"An error occured while expunging a message in the requested folder.", /** MCOErrorExpunge */
+ @"An error occured while fetching messages in the requested folder.", /** MCOErrorFetch */
+ @"An error occured during an IDLE operation.", /** MCOErrorIdle */
+ @"An error occured while requesting the server's identity.", /** MCOErrorIdentity */
+ @"An error occured while requesting the server's namespace.", /** MCOErrorNamespace */
+ @"An error occured while storing flags.", /** MCOErrorStore */
+ @"An error occured while requesting the server's capabilities.", /** MCOErrorCapability */
+ @"The server does not support STARTTLS connections.", /** MCOErrorStartTLSNotAvailable */
+ @"Attempted to send a message with an illegal attachment.", /** MCOErrorSendMessageIllegalAttachment */
+ @"The SMTP storage limit was hit while trying to send a large message.", /** MCOErrorStorageLimit */
+ @"Sending messages is not allowed on this server.", /** MCOErrorSendMessageNotAllowed */
+ @"The current HotMail account cannot connect to WebMail.", /** MCOErrorNeedsConnectToWebmail */
+ @"An error occured while sending the message.", /** MCOErrorSendMessage */
+ @"Authentication is required for this SMTP server.", /** MCOErrorAuthenticationRequired */
+ @"An error occured while fetching a message list on the POP server.", /** MCOErrorFetchMessageList */
+ @"An error occured while deleting a message on the POP server.", /** MCOErrorDeleteMessage */
+ @"Account check failed because the account is invalid.", /** MCOErrorInvalidAccount */
+};
+
@implementation NSError (MCO)
+ (NSError *)mco_errorWithErrorCode:(mailcore::ErrorCode)code {
if (code == mailcore::ErrorNone) {
return nil;
}
-
+
+ NSMutableDictionary *userInfo = [[NSMutableDictionary alloc] init];
+ if (code < MCOErrorCodeCount) {
+ NSString * localizedString = NSLocalizedStringFromTable(MCOLocalizedDescriptionTable[code], @"description of errors of mailcore", @"MailCore");
+ [userInfo setObject:localizedString forKey:NSLocalizedDescriptionKey];
+ }
+
NSError *error = [NSError errorWithDomain:MCOErrorDomain
code:(int)code
- userInfo:nil];
+ userInfo:userInfo];
return error;
}
-@end \ No newline at end of file
+@end