Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Converted sample projects to latest Xcode project format and converte…

…d files from tabs to spaces
  • Loading branch information...
commit 7c13b7b9518e0bc2cdd86e092245e0e05afa0239 1 parent d6f68a6
@mronge mronge authored
Showing with 2,157 additions and 2,156 deletions.
  1. +7 −7 Examples/OSX/InboxLister/InboxLister.xcodeproj/project.pbxproj
  2. +3 −3 Examples/OSX/InboxLister/MyController.h
  3. +40 −40 Examples/OSX/InboxLister/MyController.m
  4. +5 −5 Examples/OSX/MessageSender/MessageSender.xcodeproj/project.pbxproj
  5. +3 −3 Examples/OSX/MessageSender/MyController.h
  6. +31 −31 Examples/OSX/MessageSender/MyController.m
  7. +5 −5 Examples/iOS/MessageSender/MessageSender/ViewController.m
  8. +3 −3 Source/CTBareAttachment.h
  9. +16 −16 Source/CTBareAttachment.m
  10. +2 −2 Source/CTBareMessage.h
  11. +10 −10 Source/CTBareMessage.m
  12. +28 −28 Source/CTCoreAccount.h
  13. +158 −157 Source/CTCoreAccount.m
  14. +15 −15 Source/CTCoreAddress.h
  15. +31 −31 Source/CTCoreAddress.m
  16. +2 −2 Source/CTCoreAttachment.h
  17. +35 −35 Source/CTCoreAttachment.m
  18. +59 −59 Source/CTCoreFolder.h
  19. +491 −491 Source/CTCoreFolder.m
  20. +49 −49 Source/CTCoreMessage.h
  21. +386 −386 Source/CTCoreMessage.m
  22. +3 −3 Source/CTESMTP.h
  23. +65 −65 Source/CTESMTP.m
  24. +2 −2 Source/CTMIME.h
  25. +69 −69 Source/CTMIME.m
  26. +2 −2 Source/CTMIMEFactory.h
  27. +39 −39 Source/CTMIMEFactory.m
  28. +1 −1  Source/CTMIME_Enumerator.h
  29. +35 −35 Source/CTMIME_Enumerator.m
  30. +63 −63 Source/CTMIME_HtmlPart.m
  31. +2 −2 Source/CTMIME_MessagePart.h
  32. +27 −27 Source/CTMIME_MessagePart.m
  33. +1 −1  Source/CTMIME_MultiPart.h
  34. +34 −34 Source/CTMIME_MultiPart.m
  35. +7 −7 Source/CTMIME_SinglePart.h
  36. +110 −110 Source/CTMIME_SinglePart.m
  37. +59 −59 Source/CTMIME_TextPart.m
  38. +4 −4 Source/CTSMTP.h
  39. +33 −33 Source/CTSMTP.m
  40. +55 −55 Source/CTSMTPAsyncConnection.m
  41. +14 −14 Source/CTSMTPConnection.h
  42. +32 −32 Source/CTSMTPConnection.m
  43. +3 −3 Source/MailCoreTypes.h
  44. +1 −1  Source/MailCoreUtilities.h
  45. +32 −32 Source/MailCoreUtilities.m
  46. +85 −85 main.m
View
14 Examples/OSX/InboxLister/InboxLister.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 42;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -87,6 +87,8 @@
080E96DDFE201D6D7F000001 /* Classes */ = {
isa = PBXGroup;
children = (
+ F8FF333D09D272810051FC62 /* MyController.m */,
+ F8FF333C09D272810051FC62 /* MyController.h */,
);
name = Classes;
sourceTree = "<group>";
@@ -136,8 +138,6 @@
children = (
32CA4F630368D1EE00C91783 /* InboxLister_Prefix.pch */,
29B97316FDCFA39411CA2CEA /* main.m */,
- F8FF333C09D272810051FC62 /* MyController.h */,
- F8FF333D09D272810051FC62 /* MyController.m */,
);
name = "Other Sources";
sourceTree = "<group>";
@@ -198,8 +198,11 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0430;
+ };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "InboxLister" */;
- compatibilityVersion = "Xcode 2.4";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -293,7 +296,6 @@
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
HEADER_SEARCH_PATHS = (
@@ -329,7 +331,6 @@
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
SDKROOT = macosx;
};
name = Debug;
@@ -339,7 +340,6 @@
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
SDKROOT = macosx;
};
name = Release;
View
6 Examples/OSX/InboxLister/MyController.h
@@ -9,10 +9,10 @@
IBOutlet id port;
IBOutlet id server;
IBOutlet id username;
- IBOutlet id useTLS;
+ IBOutlet id useTLS;
- CTCoreAccount *myAccount;
- NSMutableArray *myMessages;
+ CTCoreAccount *myAccount;
+ NSMutableArray *myMessages;
}
- (IBAction)connect:(id)sender;
- (NSMutableArray *)messages;
View
80 Examples/OSX/InboxLister/MyController.m
@@ -3,65 +3,65 @@
@implementation MyController
- (id)init
{
- self = [super init];
- if(self)
- {
- myAccount = [[CTCoreAccount alloc] init];
- myMessages = [[NSMutableArray alloc] init];
- }
- return self;
+ self = [super init];
+ if(self)
+ {
+ myAccount = [[CTCoreAccount alloc] init];
+ myMessages = [[NSMutableArray alloc] init];
+ }
+ return self;
}
- (void)dealloc
{
- [myAccount release];
- [myMessages release];
- [super dealloc];
+ [myAccount release];
+ [myMessages release];
+ [super dealloc];
}
- (IBAction)connect:(id)sender
{
- NSLog(@"Connecting...");
-
- if ([useTLS state] == NSOnState )
- {
- [myAccount connectToServer:[server stringValue] port:[port intValue] connectionType:CONNECTION_TYPE_TLS
- authType:IMAP_AUTH_TYPE_PLAIN login:[username stringValue] password:[password stringValue]];
- }
- else
- {
- [myAccount connectToServer:[server stringValue] port:[port intValue] connectionType:CONNECTION_TYPE_PLAIN
- authType:IMAP_AUTH_TYPE_PLAIN login:[username stringValue] password:[password stringValue]];
- }
- CTCoreFolder *inbox = [myAccount folderWithPath:@"INBOX"];
- NSLog(@"INBOX %@", inbox);
- // set the toIndex to 0 so all messages are loaded
- NSSet *messageSet = [inbox messageObjectsFromIndex:1 toIndex:0];
- NSLog(@"Done getting list of messages...");
-
- NSMutableSet *messagesProxy = [self mutableSetValueForKey:@"messages"];
- NSEnumerator *objEnum = [messageSet objectEnumerator];
- id msg;
-
- while(msg = [objEnum nextObject]) {
- [msg fetchBodyStructure];
- [messagesProxy addObject:msg];
- }
+ NSLog(@"Connecting...");
+
+ if ([useTLS state] == NSOnState )
+ {
+ [myAccount connectToServer:[server stringValue] port:[port intValue] connectionType:CONNECTION_TYPE_TLS
+ authType:IMAP_AUTH_TYPE_PLAIN login:[username stringValue] password:[password stringValue]];
+ }
+ else
+ {
+ [myAccount connectToServer:[server stringValue] port:[port intValue] connectionType:CONNECTION_TYPE_PLAIN
+ authType:IMAP_AUTH_TYPE_PLAIN login:[username stringValue] password:[password stringValue]];
+ }
+ CTCoreFolder *inbox = [myAccount folderWithPath:@"INBOX"];
+ NSLog(@"INBOX %@", inbox);
+ // set the toIndex to 0 so all messages are loaded
+ NSSet *messageSet = [inbox messageObjectsFromIndex:1 toIndex:0];
+ NSLog(@"Done getting list of messages...");
+
+ NSMutableSet *messagesProxy = [self mutableSetValueForKey:@"messages"];
+ NSEnumerator *objEnum = [messageSet objectEnumerator];
+ id msg;
+
+ while(msg = [objEnum nextObject]) {
+ [msg fetchBodyStructure];
+ [messagesProxy addObject:msg];
+ }
}
- (NSMutableArray *)messages
{
- return myMessages;
+ return myMessages;
}
- (void)setMessages:(NSMutableArray *)messages
{
- [messages retain];
- [myMessages release];
- myMessages = messages;
+ [messages retain];
+ [myMessages release];
+ myMessages = messages;
}
@end
View
10 Examples/OSX/MessageSender/MessageSender.xcodeproj/project.pbxproj
@@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 42;
+ objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
@@ -197,8 +197,11 @@
/* Begin PBXProject section */
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0430;
+ };
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "MessageSender" */;
- compatibilityVersion = "Xcode 2.4";
+ compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
@@ -292,7 +295,6 @@
buildSettings = {
COPY_PHASE_STRIP = NO;
GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
HEADER_SEARCH_PATHS = (
@@ -328,7 +330,6 @@
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
SDKROOT = macosx;
};
name = Debug;
@@ -338,7 +339,6 @@
buildSettings = {
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- PREBINDING = NO;
SDKROOT = macosx;
};
name = Release;
View
6 Examples/OSX/MessageSender/MyController.h
@@ -9,10 +9,10 @@
IBOutlet id port;
IBOutlet id server;
IBOutlet id username;
- IBOutlet id useAuth;
- IBOutlet id useTLS;
+ IBOutlet id useAuth;
+ IBOutlet id useTLS;
- CTCoreMessage *myMessage;
+ CTCoreMessage *myMessage;
}
- (IBAction)sendMessage:(id)sender;
- (NSString *)to;
View
62 Examples/OSX/MessageSender/MyController.m
@@ -3,77 +3,77 @@
@implementation MyController
- (id)init
{
- self = [super init];
- if(self)
- {
- myMessage = [[CTCoreMessage alloc] init];
- }
- return self;
+ self = [super init];
+ if(self)
+ {
+ myMessage = [[CTCoreMessage alloc] init];
+ }
+ return self;
}
- (void)dealloc
{
- [myMessage release];
- [super dealloc];
+ [myMessage release];
+ [super dealloc];
}
- (IBAction)sendMessage:(id)sender
{
- CTCoreMessage *msg = [[CTCoreMessage alloc] init];
- [msg setTo:[myMessage to]];
- [msg setFrom:[myMessage from]];
- [msg setBody:[myMessage body]];
- [msg setSubject:[myMessage subject]];
+ CTCoreMessage *msg = [[CTCoreMessage alloc] init];
+ [msg setTo:[myMessage to]];
+ [msg setFrom:[myMessage from]];
+ [msg setBody:[myMessage body]];
+ [msg setSubject:[myMessage subject]];
- BOOL auth = ([useAuth state] == NSOnState);
- BOOL tls = ([useTLS state] == NSOnState);
- [CTSMTPConnection sendMessage:msg server:[server stringValue] username:[username stringValue]
- password:[password stringValue] port:[port intValue] useTLS:tls useAuth:auth];
- [msg release];
+ BOOL auth = ([useAuth state] == NSOnState);
+ BOOL tls = ([useTLS state] == NSOnState);
+ [CTSMTPConnection sendMessage:msg server:[server stringValue] username:[username stringValue]
+ password:[password stringValue] port:[port intValue] useTLS:tls useAuth:auth];
+ [msg release];
}
- (NSString *)to
{
- return [[[myMessage to] anyObject] email];
+ return [[[myMessage to] anyObject] email];
}
- (void)setTo:(NSString *)aValue
{
- CTCoreAddress *addr = [CTCoreAddress address];
- [addr setEmail:aValue];
- [myMessage setTo:[NSSet setWithObject:addr]];
+ CTCoreAddress *addr = [CTCoreAddress address];
+ [addr setEmail:aValue];
+ [myMessage setTo:[NSSet setWithObject:addr]];
}
- (NSString *)from
{
- return [[[myMessage from] anyObject] email];
+ return [[[myMessage from] anyObject] email];
}
- (void)setFrom:(NSString *)aValue
{
- CTCoreAddress *addr = [CTCoreAddress address];
- [addr setEmail:aValue];
- [addr setName:@""];
- [myMessage setFrom:[NSSet setWithObject:addr]];
+ CTCoreAddress *addr = [CTCoreAddress address];
+ [addr setEmail:aValue];
+ [addr setName:@""];
+ [myMessage setFrom:[NSSet setWithObject:addr]];
}
- (NSString *)subject
{
- return [myMessage subject];
+ return [myMessage subject];
}
- (void)setSubject:(NSString *)aValue
{
- [myMessage setSubject:aValue];
+ [myMessage setSubject:aValue];
}
- (NSString *)body
{
- return [myMessage body];
+ return [myMessage body];
}
- (void)setBody:(NSString *)aValue
{
- [myMessage setBody:aValue];
+ [myMessage setBody:aValue];
}
@end
View
10 Examples/iOS/MessageSender/MessageSender/ViewController.m
@@ -21,13 +21,13 @@ - (void)didReceiveMemoryWarning
- (void)viewDidLoad
{
[super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
-
+ // Do any additional setup after loading the view, typically from a nib.
+
CTCoreMessage *msg = [[CTCoreMessage alloc] init];
// [CTSMTPConnection sendMessage:msg server:[server stringValue] username:[username stringValue]
// password:[password stringValue] port:[port intValue] useTLS:tls useAuth:auth];
- [msg release];
+ [msg release];
}
- (void)viewDidUnload
@@ -49,12 +49,12 @@ - (void)viewDidAppear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated
{
- [super viewWillDisappear:animated];
+ [super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
- [super viewDidDisappear:animated];
+ [super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
View
6 Source/CTBareAttachment.h
@@ -36,9 +36,9 @@
//TODO Document me
@interface CTBareAttachment : NSObject {
- CTMIME_SinglePart *mMIMEPart;
- NSString *mFilename;
- NSString *mContentType;
+ CTMIME_SinglePart *mMIMEPart;
+ NSString *mFilename;
+ NSString *mContentType;
}
@property(retain) NSString *filename;
@property(retain) NSString *contentType;
View
32 Source/CTBareAttachment.m
@@ -42,22 +42,22 @@ @implementation CTBareAttachment
@synthesize filename=mFilename;
- (id)initWithMIMESinglePart:(CTMIME_SinglePart *)part {
- self = [super init];
- if (self) {
- mMIMEPart = [part retain];
- self.filename = mMIMEPart.filename;
- self.contentType = mMIMEPart.contentType;
- }
- return self;
+ self = [super init];
+ if (self) {
+ mMIMEPart = [part retain];
+ self.filename = mMIMEPart.filename;
+ self.contentType = mMIMEPart.contentType;
+ }
+ return self;
}
-(NSString*)decodedFilename {
- return MailCoreDecodeMIMEPhrase((char *)[self.filename UTF8String]);
+ return MailCoreDecodeMIMEPhrase((char *)[self.filename UTF8String]);
}
- (NSString *)description {
- return [NSString stringWithFormat:@"ContentType: %@\tFilename: %@",
- self.contentType, self.filename];
+ return [NSString stringWithFormat:@"ContentType: %@\tFilename: %@",
+ self.contentType, self.filename];
}
- (CTCoreAttachment *)fetchFullAttachment {
@@ -66,9 +66,9 @@ - (CTCoreAttachment *)fetchFullAttachment {
- (CTCoreAttachment *)fetchFullAttachmentWithProgress:(CTProgressBlock)block {
[mMIMEPart fetchPartWithProgress:block];
- CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithData:mMIMEPart.data
+ CTCoreAttachment *attach = [[CTCoreAttachment alloc] initWithData:mMIMEPart.data
contentType:self.contentType filename:self.filename];
- return [attach autorelease];
+ return [attach autorelease];
}
- (CTMIME_SinglePart *)part {
@@ -76,9 +76,9 @@ - (CTMIME_SinglePart *)part {
}
- (void)dealloc {
- [mMIMEPart release];
- [mFilename release];
- [mContentType release];
- [super dealloc];
+ [mMIMEPart release];
+ [mFilename release];
+ [mContentType release];
+ [super dealloc];
}
@end
View
4 Source/CTBareMessage.h
@@ -35,8 +35,8 @@
//TODO Document me
//TODO Eventually CTCoreMessage should inherit from this
@interface CTBareMessage : NSObject {
- NSString *mUid;
- unsigned int mFlags;
+ NSString *mUid;
+ unsigned int mFlags;
}
@property(retain) NSString *uid;
@property unsigned int flags;
View
20 Source/CTBareMessage.m
@@ -35,24 +35,24 @@ @implementation CTBareMessage
@synthesize uid=mUid, flags=mFlags;
- (id)init {
- self = [super init];
- if (self != nil) {
- self.uid = @"";
- self.flags = 0;
- }
- return self;
+ self = [super init];
+ if (self != nil) {
+ self.uid = @"";
+ self.flags = 0;
+ }
+ return self;
}
- (NSString *)description {
- return [NSString stringWithFormat:@"UID: %@\n Flags: %d\n", self.uid, self.flags];
+ return [NSString stringWithFormat:@"UID: %@\n Flags: %d\n", self.uid, self.flags];
}
- (NSUInteger)hash {
- NSString *str = [NSString stringWithFormat:@"%@%d", self.uid, self.flags];
- return [str hash];
+ NSString *str = [NSString stringWithFormat:@"%@%d", self.uid, self.flags];
+ return [str hash];
}
- (BOOL)isEqual:(id)anObject {
- return ([self hash] == [anObject hash]);
+ return ([self hash] == [anObject hash]);
}
@end
View
56 Source/CTCoreAccount.h
@@ -33,62 +33,62 @@
#import <libetpan/libetpan.h>
/*!
- @class CTCoreAccount
- CTCoreAccount is the base class with which you establish a connection to the
- IMAP server. After establishing a connection with CTCoreAccount you can access
- all of the folders (I use the term folder instead of mailbox) on the server.
- All methods throw an exception on failure.
+ @class CTCoreAccount
+ CTCoreAccount is the base class with which you establish a connection to the
+ IMAP server. After establishing a connection with CTCoreAccount you can access
+ all of the folders (I use the term folder instead of mailbox) on the server.
+ All methods throw an exception on failure.
*/
@class CTCoreFolder;
@interface CTCoreAccount : NSObject {
- struct mailstorage *myStorage;
- BOOL connected;
+ struct mailstorage *myStorage;
+ BOOL connected;
}
/*!
- @abstract Retrieves the list of all the available folders from the server.
- @result Returns a NSSet which contains NSStrings of the folders pathnames.
+ @abstract Retrieves the list of all the available folders from the server.
+ @result Returns a NSSet which contains NSStrings of the folders pathnames.
*/
- (NSSet *)allFolders;
/*!
- @abstract Retrieves a list of only the subscribed folders from the server.
- @result Returns a NSSet which contains NSStrings of the folders pathnames.
+ @abstract Retrieves a list of only the subscribed folders from the server.
+ @result Returns a NSSet which contains NSStrings of the folders pathnames.
*/
- (NSSet *)subscribedFolders;
/*!
- @abstract If you have the path of a folder on the server use this method to retrieve just the one folder.
- @param path A NSString specifying the path of the folder to retrieve from the server.
- @result Returns a CTCoreFolder.
+ @abstract If you have the path of a folder on the server use this method to retrieve just the one folder.
+ @param path A NSString specifying the path of the folder to retrieve from the server.
+ @result Returns a CTCoreFolder.
*/
- (CTCoreFolder *)folderWithPath:(NSString *)path;
/*!
- @abstract This method initiates the connection to the server.
- @param server The address of the server.
- @param port The port to connect to.
- @param connnectionType What kind of connection to use, it can be one of these three values:
- CONNECTION_TYPE_PLAIN, CONNECTION_TYPE_STARTTLS, CONNECTION_TYPE_TRY_STARTTLS, CONNECTION_TYPE_TLS
- @param authType The authentication type, only IMAP_AUTH_TYPE_PLAIN is currently supported
- @param login The username to connect with.
- @param password The password to use to connect.
+ @abstract This method initiates the connection to the server.
+ @param server The address of the server.
+ @param port The port to connect to.
+ @param connnectionType What kind of connection to use, it can be one of these three values:
+ CONNECTION_TYPE_PLAIN, CONNECTION_TYPE_STARTTLS, CONNECTION_TYPE_TRY_STARTTLS, CONNECTION_TYPE_TLS
+ @param authType The authentication type, only IMAP_AUTH_TYPE_PLAIN is currently supported
+ @param login The username to connect with.
+ @param password The password to use to connect.
*/
- (void)connectToServer:(NSString *)server port:(int)port connectionType:(int)conType authType:(int)authType
- login:(NSString *)login password:(NSString *)password;
-
+ login:(NSString *)login password:(NSString *)password;
+
/*!
- @abstract This method returns the current connection status.
- @result Returns YES or NO as the status of the connection.
+ @abstract This method returns the current connection status.
+ @result Returns YES or NO as the status of the connection.
*/
- (BOOL)isConnected;
/*!
- @abstract Terminates the connection. If you terminate this connection it will also affect the
- connectivity of CTCoreFolders and CTMessages that rely on this account.
+ @abstract Terminates the connection. If you terminate this connection it will also affect the
+ connectivity of CTCoreFolders and CTMessages that rely on this account.
*/
- (void)disconnect;
View
315 Source/CTCoreAccount.m
@@ -39,222 +39,223 @@ @interface CTCoreAccount (Private)
@implementation CTCoreAccount
- (id)init {
- self = [super init];
- if (self) {
- connected = NO;
- myStorage = mailstorage_new(NULL);
- assert(myStorage != NULL);
- }
- return self;
+ self = [super init];
+ if (self) {
+ connected = NO;
+ myStorage = mailstorage_new(NULL);
+ assert(myStorage != NULL);
+ }
+ return self;
}
- (void)dealloc {
- mailstorage_disconnect(myStorage);
- mailstorage_free(myStorage);
- [super dealloc];
+ mailstorage_disconnect(myStorage);
+ mailstorage_free(myStorage);
+ [super dealloc];
}
- (BOOL)isConnected {
- return connected;
+ return connected;
}
//TODO, should I use the cache?
- (void)connectToServer:(NSString *)server port:(int)port
- connectionType:(int)conType authType:(int)authType
- login:(NSString *)login password:(NSString *)password {
- int err = 0;
- int imap_cached = 0;
-
- const char* auth_type_to_pass = NULL;
- if(authType == IMAP_AUTH_TYPE_SASL_CRAM_MD5) {
- auth_type_to_pass = "CRAM-MD5";
- }
-
- err = imap_mailstorage_init_sasl(myStorage,
- (char *)[server cStringUsingEncoding:NSUTF8StringEncoding],
- (uint16_t)port, NULL,
- conType,
- auth_type_to_pass,
- NULL,
- NULL, NULL,
- (char *)[login cStringUsingEncoding:NSUTF8StringEncoding], (char *)[login cStringUsingEncoding:NSUTF8StringEncoding],
- (char *)[password cStringUsingEncoding:NSUTF8StringEncoding], NULL,
- imap_cached, NULL);
-
- if (err != MAIL_NO_ERROR) {
- NSException *exception = [NSException
- exceptionWithName:CTMemoryError
- reason:CTMemoryErrorDesc
- userInfo:nil];
- [exception raise];
- }
-
- err = mailstorage_connect(myStorage);
- if (err == MAIL_ERROR_LOGIN) {
- NSException *exception = [NSException
- exceptionWithName:CTLoginError
- reason:CTLoginErrorDesc
- userInfo:nil];
- [exception raise];
- }
- else if (err != MAIL_NO_ERROR) {
- NSException *exception = [NSException
- exceptionWithName:CTUnknownError
- reason:[NSString stringWithFormat:@"Error number: %d",err]
- userInfo:nil];
- [exception raise];
- }
- else
- connected = YES;
+ connectionType:(int)conType authType:(int)authType
+ login:(NSString *)login password:(NSString *)password {
+ int err = 0;
+ int imap_cached = 0;
+
+ const char* auth_type_to_pass = NULL;
+ if(authType == IMAP_AUTH_TYPE_SASL_CRAM_MD5) {
+ auth_type_to_pass = "CRAM-MD5";
+ }
+
+ err = imap_mailstorage_init_sasl(myStorage,
+ (char *)[server cStringUsingEncoding:NSUTF8StringEncoding],
+ (uint16_t)port, NULL,
+ conType,
+ auth_type_to_pass,
+ NULL,
+ NULL, NULL,
+ (char *)[login cStringUsingEncoding:NSUTF8StringEncoding], (char *)[login cStringUsingEncoding:NSUTF8StringEncoding],
+ (char *)[password cStringUsingEncoding:NSUTF8StringEncoding], NULL,
+ imap_cached, NULL);
+
+ if (err != MAIL_NO_ERROR) {
+ NSException *exception = [NSException
+ exceptionWithName:CTMemoryError
+ reason:CTMemoryErrorDesc
+ userInfo:nil];
+ [exception raise];
+ }
+
+ err = mailstorage_connect(myStorage);
+ if (err == MAIL_ERROR_LOGIN) {
+ NSException *exception = [NSException
+ exceptionWithName:CTLoginError
+ reason:CTLoginErrorDesc
+ userInfo:nil];
+ [exception raise];
+ }
+ else if (err != MAIL_NO_ERROR) {
+ NSException *exception = [NSException
+ exceptionWithName:CTUnknownError
+ reason:[NSString stringWithFormat:@"Error number: %d",err]
+ userInfo:nil];
+ [exception raise];
+ }
+ else {
+ connected = YES;
+ }
}
- (void)idle {
int err = mailimap_idle([self session]);
-
+
if (err != 0) {
- NSException *exception = [NSException
+ NSException *exception = [NSException
exceptionWithName:CTUnknownError
reason:[NSString stringWithFormat:@"Error number: %d", err]
userInfo:nil];
- [exception raise];
+ [exception raise];
}
}
- (NSString*)read {
char * buf = mailimap_read_line([self session]);
-
+
if (buf == NULL) {
return nil;
}
-
+
return [NSString stringWithCString:buf encoding:NSUTF8StringEncoding];
}
- (void)done {
int err = mailimap_idle_done([self session]);
-
+
if (err != 0) {
- NSException *exception = [NSException
+ NSException *exception = [NSException
exceptionWithName:CTUnknownError
reason:[NSString stringWithFormat:@"Error number: %d", err]
userInfo:nil];
- [exception raise];
+ [exception raise];
}
}
- (void)disconnect {
- connected = NO;
- mailstorage_disconnect(myStorage);
+ connected = NO;
+ mailstorage_disconnect(myStorage);
}
- (CTCoreFolder *)folderWithPath:(NSString *)path {
- CTCoreFolder *folder = [[CTCoreFolder alloc] initWithPath:path inAccount:self];
- return [folder autorelease];
+ CTCoreFolder *folder = [[CTCoreFolder alloc] initWithPath:path inAccount:self];
+ return [folder autorelease];
}
- (mailimap *)session {
- struct imap_cached_session_state_data * cached_data;
- struct imap_session_state_data * data;
- mailsession *session;
-
- session = myStorage->sto_session;
- if(session == nil) {
- return nil;
- }
- if (strcasecmp(session->sess_driver->sess_name, "imap-cached") == 0) {
- cached_data = session->sess_data;
- session = cached_data->imap_ancestor;
- }
-
- data = session->sess_data;
- return data->imap_session;
+ struct imap_cached_session_state_data * cached_data;
+ struct imap_session_state_data * data;
+ mailsession *session;
+
+ session = myStorage->sto_session;
+ if(session == nil) {
+ return nil;
+ }
+ if (strcasecmp(session->sess_driver->sess_name, "imap-cached") == 0) {
+ cached_data = session->sess_data;
+ session = cached_data->imap_ancestor;
+ }
+
+ data = session->sess_data;
+ return data->imap_session;
}
- (struct mailstorage *)storageStruct {
- return myStorage;
+ return myStorage;
}
- (NSSet *)subscribedFolders {
- struct mailimap_mailbox_list * mailboxStruct;
- clist *subscribedList;
- clistiter *cur;
-
- NSString *mailboxNameObject;
- char *mailboxName;
- int err;
-
- NSMutableSet *subscribedFolders = [NSMutableSet set];
-
- //Fill the subscribed folder array
- err = mailimap_lsub([self session], "", "*", &subscribedList);
- if (err != MAIL_NO_ERROR) {
- NSException *exception = [NSException
- exceptionWithName:CTUnknownError
- reason:[NSString stringWithFormat:@"Error number: %d",err]
- userInfo:nil];
- [exception raise];
- }
- else if (clist_isempty(subscribedList)) {
- NSException *exception = [NSException
- exceptionWithName:CTNoSubscribedFolders
- reason:CTNoSubscribedFoldersDesc
- userInfo:nil];
- [exception raise];
- }
- for(cur = clist_begin(subscribedList); cur != NULL; cur = cur->next) {
- mailboxStruct = cur->data;
- mailboxName = mailboxStruct->mb_name;
- mailboxNameObject = [NSString stringWithCString:mailboxName encoding:NSUTF8StringEncoding];
- [subscribedFolders addObject:mailboxNameObject];
- }
- mailimap_list_result_free(subscribedList);
- return subscribedFolders;
+ struct mailimap_mailbox_list * mailboxStruct;
+ clist *subscribedList;
+ clistiter *cur;
+
+ NSString *mailboxNameObject;
+ char *mailboxName;
+ int err;
+
+ NSMutableSet *subscribedFolders = [NSMutableSet set];
+
+ //Fill the subscribed folder array
+ err = mailimap_lsub([self session], "", "*", &subscribedList);
+ if (err != MAIL_NO_ERROR) {
+ NSException *exception = [NSException
+ exceptionWithName:CTUnknownError
+ reason:[NSString stringWithFormat:@"Error number: %d",err]
+ userInfo:nil];
+ [exception raise];
+ }
+ else if (clist_isempty(subscribedList)) {
+ NSException *exception = [NSException
+ exceptionWithName:CTNoSubscribedFolders
+ reason:CTNoSubscribedFoldersDesc
+ userInfo:nil];
+ [exception raise];
+ }
+ for(cur = clist_begin(subscribedList); cur != NULL; cur = cur->next) {
+ mailboxStruct = cur->data;
+ mailboxName = mailboxStruct->mb_name;
+ mailboxNameObject = [NSString stringWithCString:mailboxName encoding:NSUTF8StringEncoding];
+ [subscribedFolders addObject:mailboxNameObject];
+ }
+ mailimap_list_result_free(subscribedList);
+ return subscribedFolders;
}
- (NSSet *)allFolders {
- struct mailimap_mailbox_list * mailboxStruct;
- clist *allList;
- clistiter *cur;
-
- NSString *mailboxNameObject;
- char *mailboxName;
- int err;
-
- NSMutableSet *allFolders = [NSMutableSet set];
-
- //Now, fill the all folders array
- //TODO Fix this so it doesn't use *
- err = mailimap_list([self session], "", "*", &allList);
- if (err != MAIL_NO_ERROR)
- {
- NSException *exception = [NSException
- exceptionWithName:CTUnknownError
- reason:[NSString stringWithFormat:@"Error number: %d",err]
- userInfo:nil];
- [exception raise];
- }
- else if (clist_isempty(allList))
- {
- NSException *exception = [NSException
- exceptionWithName:CTNoFolders
- reason:CTNoFoldersDesc
- userInfo:nil];
- [exception raise];
- }
- for(cur = clist_begin(allList); cur != NULL; cur = cur->next)
- {
- mailboxStruct = cur->data;
- mailboxName = mailboxStruct->mb_name;
- mailboxNameObject = [NSString stringWithCString:mailboxName encoding:NSUTF8StringEncoding];
- [allFolders addObject:mailboxNameObject];
- }
- mailimap_list_result_free(allList);
- return allFolders;
+ struct mailimap_mailbox_list * mailboxStruct;
+ clist *allList;
+ clistiter *cur;
+
+ NSString *mailboxNameObject;
+ char *mailboxName;
+ int err;
+
+ NSMutableSet *allFolders = [NSMutableSet set];
+
+ //Now, fill the all folders array
+ //TODO Fix this so it doesn't use *
+ err = mailimap_list([self session], "", "*", &allList);
+ if (err != MAIL_NO_ERROR)
+ {
+ NSException *exception = [NSException
+ exceptionWithName:CTUnknownError
+ reason:[NSString stringWithFormat:@"Error number: %d",err]
+ userInfo:nil];
+ [exception raise];
+ }
+ else if (clist_isempty(allList))
+ {
+ NSException *exception = [NSException
+ exceptionWithName:CTNoFolders
+ reason:CTNoFoldersDesc
+ userInfo:nil];
+ [exception raise];
+ }
+ for(cur = clist_begin(allList); cur != NULL; cur = cur->next)
+ {
+ mailboxStruct = cur->data;
+ mailboxName = mailboxStruct->mb_name;
+ mailboxNameObject = [NSString stringWithCString:mailboxName encoding:NSUTF8StringEncoding];
+ [allFolders addObject:mailboxNameObject];
+ }
+ mailimap_list_result_free(allList);
+ return allFolders;
}
@end
View
30 Source/CTCoreAddress.h
@@ -32,59 +32,59 @@
#import <Foundation/Foundation.h>
/*!
- @class @CTCoreAddress
- This is a very simple class designed to make it easier to work with email addresses since many times
- the e-mail address and name are both encoded in the MIME e-mail fields. This class should be very straight
- forward, you can get and set a name and an e-mail address.
+ @class @CTCoreAddress
+ This is a very simple class designed to make it easier to work with email addresses since many times
+ the e-mail address and name are both encoded in the MIME e-mail fields. This class should be very straight
+ forward, you can get and set a name and an e-mail address.
*/
@interface CTCoreAddress : NSObject {
- NSString *email;
- NSString *name;
+ NSString *email;
+ NSString *name;
}
/*!
- @abstract Returns a CTCoreAddress with the name and e-mail address set as an empty string.
+ @abstract Returns a CTCoreAddress with the name and e-mail address set as an empty string.
*/
+ (id)address;
/*!
- @abstract Returns a CTCoreAddress set with the specified name and email.
+ @abstract Returns a CTCoreAddress set with the specified name and email.
*/
+ (id)addressWithName:(NSString *)aName email:(NSString *)aEmail;
/*!
- @abstract Returns a CTCoreAddress set with the specified name and email.
+ @abstract Returns a CTCoreAddress set with the specified name and email.
*/
- (id)initWithName:(NSString *)aName email:(NSString *)aEmail;
/*!
- @abstract Returns the name as a NSString
+ @abstract Returns the name as a NSString
*/
- (NSString *)name;
-(NSString*)decodedName; // added by Gabor
/*!
- @abstract Sets the name.
+ @abstract Sets the name.
*/
- (void)setName:(NSString *)aValue;
/*!
- @abstract Returns the e-mail as a NSString
+ @abstract Returns the e-mail as a NSString
*/
- (NSString *)email;
/*!
- @abstract Sets the e-mail.
+ @abstract Sets the e-mail.
*/
- (void)setEmail:(NSString *)aValue;
/*!
- @abstract Works like the typical isEqual: method
+ @abstract Works like the typical isEqual: method
*/
- (BOOL)isEqual:(id)object;
/*!
- @abstract Standard description method
+ @abstract Standard description method
*/
- (NSString *)description;
@end
View
62 Source/CTCoreAddress.m
@@ -35,34 +35,34 @@
@implementation CTCoreAddress
+ (id)address {
- CTCoreAddress *aAddress = [[CTCoreAddress alloc] init];
- return [aAddress autorelease];
+ CTCoreAddress *aAddress = [[CTCoreAddress alloc] init];
+ return [aAddress autorelease];
}
+ (id)addressWithName:(NSString *)aName email:(NSString *)aEmail {
- CTCoreAddress *aAddress = [[CTCoreAddress alloc] initWithName:aName email:aEmail];
- return [aAddress autorelease];
+ CTCoreAddress *aAddress = [[CTCoreAddress alloc] initWithName:aName email:aEmail];
+ return [aAddress autorelease];
}
- (id)initWithName:(NSString *)aName email:(NSString *)aEmail {
- self = [super init];
- if (self) {
- [self setName:aName];
- [self setEmail:aEmail];
- }
- return self;
+ self = [super init];
+ if (self) {
+ [self setName:aName];
+ [self setEmail:aEmail];
+ }
+ return self;
}
- (id)init {
- self = [super init];
- if (self) {
- [self setName:@""];
- [self setEmail:@""];
- }
- return self;
+ self = [super init];
+ if (self) {
+ [self setName:@""];
+ [self setEmail:@""];
+ }
+ return self;
}
@@ -71,43 +71,43 @@ -(NSString*)decodedName {
}
- (NSString *)name {
- return name;
+ return name;
}
- (void)setName:(NSString *)aValue {
- NSString *oldName = name;
- name = [aValue retain];
- [oldName release];
+ NSString *oldName = name;
+ name = [aValue retain];
+ [oldName release];
}
- (NSString *)email {
- return email;
+ return email;
}
- (void)setEmail:(NSString *)aValue {
- NSString *oldEmail = email;
- email = [aValue retain];
- [oldEmail release];
+ NSString *oldEmail = email;
+ email = [aValue retain];
+ [oldEmail release];
}
- (NSString *)description {
- return [NSString stringWithFormat:@"<%@,%@>", [self name],[self email]];
+ return [NSString stringWithFormat:@"<%@,%@>", [self name],[self email]];
}
- (BOOL)isEqual:(id)object {
- if (![object isKindOfClass:[CTCoreAddress class]])
- return NO;
- return [[object name] isEqualToString:[self name]] && [[object email] isEqualToString:[self email]];
+ if (![object isKindOfClass:[CTCoreAddress class]])
+ return NO;
+ return [[object name] isEqualToString:[self name]] && [[object email] isEqualToString:[self email]];
}
- (void)dealloc {
- [email release];
- [name release];
- [super dealloc];
+ [email release];
+ [name release];
+ [super dealloc];
}
@end
View
4 Source/CTCoreAttachment.h
@@ -33,12 +33,12 @@
#import "CTBareAttachment.h"
@interface CTCoreAttachment : CTBareAttachment {
- NSData *mData;
+ NSData *mData;
}
@property(retain) NSData *data;
- (id)initWithContentsOfFile:(NSString *)path;
- (id)initWithData:(NSData *)data contentType:(NSString *)contentType
- filename:(NSString *)filename;
+ filename:(NSString *)filename;
- (BOOL)writeToFile:(NSString *)path;
@end
View
70 Source/CTCoreAttachment.m
@@ -37,50 +37,50 @@ @implementation CTCoreAttachment
@synthesize data=mData;
- (id)initWithContentsOfFile:(NSString *)path {
- NSData *data = [NSData dataWithContentsOfFile:path];
- NSString *filePathExt = [path pathExtension];
-
- NSString *contentType = nil;
+ NSData *data = [NSData dataWithContentsOfFile:path];
+ NSString *filePathExt = [path pathExtension];
+
+ NSString *contentType = nil;
//TODO: This won't work on iOS
- NSDictionary *contentTypes = [NSDictionary dictionaryWithContentsOfFile:CTContentTypesPath];
- for (NSString *key in [contentTypes allKeys]) {
- NSArray *fileExtensions = [contentTypes objectForKey:key];
- for (NSString *ext in fileExtensions) {
- if ([filePathExt isEqual:ext]) {
- contentType = key;
- break;
- }
- }
- if (contentType != nil)
- break;
- }
-
- // We couldn't find a content-type, set it to something generic
- if (contentType == nil) {
- contentType = @"application/octet-stream";
- }
-
- NSString *filename = [path lastPathComponent];
- return [self initWithData:data contentType:contentType filename:filename];
+ NSDictionary *contentTypes = [NSDictionary dictionaryWithContentsOfFile:CTContentTypesPath];
+ for (NSString *key in [contentTypes allKeys]) {
+ NSArray *fileExtensions = [contentTypes objectForKey:key];
+ for (NSString *ext in fileExtensions) {
+ if ([filePathExt isEqual:ext]) {
+ contentType = key;
+ break;
+ }
+ }
+ if (contentType != nil)
+ break;
+ }
+
+ // We couldn't find a content-type, set it to something generic
+ if (contentType == nil) {
+ contentType = @"application/octet-stream";
+ }
+
+ NSString *filename = [path lastPathComponent];
+ return [self initWithData:data contentType:contentType filename:filename];
}
- (id)initWithData:(NSData *)data contentType:(NSString *)contentType
- filename:(NSString *)filename {
- self = [super init];
- if (self) {
- self.data = data;
- self.contentType = contentType;
- self.filename = filename;
- }
- return self;
+ filename:(NSString *)filename {
+ self = [super init];
+ if (self) {
+ self.data = data;
+ self.contentType = contentType;
+ self.filename = filename;
+ }
+ return self;
}
- (BOOL)writeToFile:(NSString *)path {
- return [mData writeToFile:path atomically:YES];
+ return [mData writeToFile:path atomically:YES];
}
- (void)dealloc {
- [mData release];
- [super dealloc];
+ [mData release];
+ [super dealloc];
}
@end
View
118 Source/CTCoreFolder.h
@@ -33,51 +33,51 @@
#import <libetpan/libetpan.h>
/*!
- @class CTCoreFolder
- CTCoreFolder is the class used to get and set attributes for a server side folder. It is also the
- class used to get a list of messages from the server. You need to make sure and establish a connection
- first by calling connect. All methods throw an exceptions on failure.
+ @class CTCoreFolder
+ CTCoreFolder is the class used to get and set attributes for a server side folder. It is also the
+ class used to get a list of messages from the server. You need to make sure and establish a connection
+ first by calling connect. All methods throw an exceptions on failure.
*/
@class CTCoreMessage, CTCoreAccount;
@interface CTCoreFolder : NSObject {
- struct mailfolder *myFolder;
- CTCoreAccount *myAccount;
- NSString *myPath;
- BOOL connected;
+ struct mailfolder *myFolder;
+ CTCoreAccount *myAccount;
+ NSString *myPath;
+ BOOL connected;
}
/*!
- @abstract This method is used to initialize a folder. This method or the
- method in CTCoreAccount folderWithPath can be used to setup a folder.
- @param inAccount This parameter must be passed in so the folder can initiate it's connection.
+ @abstract This method is used to initialize a folder. This method or the
+ method in CTCoreAccount folderWithPath can be used to setup a folder.
+ @param inAccount This parameter must be passed in so the folder can initiate it's connection.
*/
- (id)initWithPath:(NSString *)path inAccount:(CTCoreAccount *)account;
/*!
- @abstract This initiates the connection after the folder has been initalized.
+ @abstract This initiates the connection after the folder has been initalized.
*/
- (void)connect;
/*!
- @abstract This method terminates the connection, make sure you don't have any message
- connections open from this folder before disconnecting.
+ @abstract This method terminates the connection, make sure you don't have any message
+ connections open from this folder before disconnecting.
*/
- (void)disconnect;
/*
- Implementation is in alpha.
+ Implementation is in alpha.
*/
//TODO Document Me!
- (NSSet *)messageObjectsFromIndex:(unsigned int)start toIndex:(unsigned int)end;
/*!
- @abstract This will return the message from this folder with the UID that was passed in. If the message
- can't be found, nil is returned
- @param uid The uid as an NSString for the message to retrieve.
- @result A CTMessage object is returned which can be used to get further information and perform operations
- on the message.
+ @abstract This will return the message from this folder with the UID that was passed in. If the message
+ can't be found, nil is returned
+ @param uid The uid as an NSString for the message to retrieve.
+ @result A CTMessage object is returned which can be used to get further information and perform operations
+ on the message.
*/
- (CTCoreMessage *)messageWithUID:(NSString *)uid;
@@ -87,19 +87,19 @@
- (NSSet *)messageListWithFetchAttributes:(NSArray *)attributes;
/*!
- @abstract This validates the passed in UID. The server can at times change the set of UID's for a folder. So
- you should verify that the server is still using the same set when connecting.
- @param uid The UID to verify.
- @return YES if the UID is valid.
+ @abstract This validates the passed in UID. The server can at times change the set of UID's for a folder. So
+ you should verify that the server is still using the same set when connecting.
+ @param uid The UID to verify.
+ @return YES if the UID is valid.
*/
- (BOOL)isUIDValid:(NSString *)uid;
/*!
- @abstract Pulls the sequence number for the messag with the specified uid.
- It does not perform UID validation, and the sequence ID is only
- valid per session.
- @param The uid for the message
- @return > 1 if successful, 0 on err
+ @abstract Pulls the sequence number for the messag with the specified uid.
+ It does not perform UID validation, and the sequence ID is only
+ valid per session.
+ @param The uid for the message
+ @return > 1 if successful, 0 on err
*/
- (NSUInteger)sequenceNumberForUID:(NSString *)uid;
@@ -109,64 +109,64 @@
/*!
- @abstract The folder name.
+ @abstract The folder name.
*/
- (NSString *)name;
/*!
- @abstract The entire path of folder.
+ @abstract The entire path of folder.
*/
- (NSString *)path;
/*!
- @abstract This will change the path of the folder. Use this method to rename the folder on the server
- or to move the folder on the server.
- @param path The new path for the folder as an NSString.
+ @abstract This will change the path of the folder. Use this method to rename the folder on the server
+ or to move the folder on the server.
+ @param path The new path for the folder as an NSString.
*/
- (void)setPath:(NSString *)path;
/*!
- @abstract If the folder doesn't exist on the server this method will create it. Make sure the pathname
- has been set first.
+ @abstract If the folder doesn't exist on the server this method will create it. Make sure the pathname
+ has been set first.
*/
- (void)create;
/*!
- @abstract This method will remove the folder and any messages contained within from the server.
- Be careful when using this method because there is no way to undo.
+ @abstract This method will remove the folder and any messages contained within from the server.
+ Be careful when using this method because there is no way to undo.
*/
- (void)delete;
/*!
- @abstract The folder will be listed as subscribed on the server.
+ @abstract The folder will be listed as subscribed on the server.
*/
- (void)subscribe;
/*!
- @abstract The folder will be listed as unsubscribed.
+ @abstract The folder will be listed as unsubscribed.
*/
- (void)unsubscribe;
/*!
- @abstract Returns the message flags. You must AND/OR using the defines constants.
- Here is a list of message flags:
- CTFlagNew, CTFlagSeen, CTFlagFlagged, CTFlagDeleted,
- CTFlagAnswered, CTFlagForwarded.
+ @abstract Returns the message flags. You must AND/OR using the defines constants.
+ Here is a list of message flags:
+ CTFlagNew, CTFlagSeen, CTFlagFlagged, CTFlagDeleted,
+ CTFlagAnswered, CTFlagForwarded.
*/
- (unsigned int)flagsForMessage:(CTCoreMessage *)msg;
/*!
- @abstract Sets the message's flags on the server, take a look at the
- documentation for flagsForMessage:
+ @abstract Sets the message's flags on the server, take a look at the
+ documentation for flagsForMessage:
*/
- (void)setFlags:(unsigned int)flags forMessage:(CTCoreMessage *)msg;
/*!
- @astract Deletes all messages contained in the folder that are marked for
- deletion. Deleting messages in IMAP is a little strange, first
- you need to set the message flag CTFlagDeleted to CTFlagSet, and
- then when you call expunge on the folder the message is contained
- in, it will be deleted.
+ @astract Deletes all messages contained in the folder that are marked for
+ deletion. Deleting messages in IMAP is a little strange, first
+ you need to set the message flag CTFlagDeleted to CTFlagSet, and
+ then when you call expunge on the folder the message is contained
+ in, it will be deleted.
*/
- (void)expunge;
@@ -181,22 +181,22 @@
- (void)moveMessage: (NSString *)path forMessage:(CTCoreMessage *)msg;
/*!
- @abstract Returns the number of unread messages. This causes a round trip to the server, as it fetches
- the count for each call.
- @result A NSUInteger containing the number of unread messages.
+ @abstract Returns the number of unread messages. This causes a round trip to the server, as it fetches
+ the count for each call.
+ @result A NSUInteger containing the number of unread messages.
*/
- (NSUInteger)unreadMessageCount;
/*!
- @abstract Returns the number of messages in the folder. The count was retrieved when the folder connection was
- established, so to refresh the count you must disconnect and reconnect.
- @result A NSUInteger containing the number of messages.
+ @abstract Returns the number of messages in the folder. The count was retrieved when the folder connection was
+ established, so to refresh the count you must disconnect and reconnect.
+ @result A NSUInteger containing the number of messages.
*/
- (NSUInteger)totalMessageCount;
/*!
- @abstract Returns the uid validity value for the folder
- @result An integer containing the uid validity
+ @abstract Returns the uid validity value for the folder
+ @result An integer containing the uid validity
*/
- (NSUInteger)uidValidity;
View
982 Source/CTCoreFolder.m
@@ -43,608 +43,608 @@ int imap_flags_to_flags(struct mailimap_msg_att_dynamic * att_dyn,
@interface CTCoreFolder (Private)
@end
-
+
@implementation CTCoreFolder
- (id)initWithPath:(NSString *)path inAccount:(CTCoreAccount *)account; {
- struct mailstorage *storage = (struct mailstorage *)[account storageStruct];
- self = [super init];
- if (self)
- {
- myPath = [path retain];
- connected = NO;
- myAccount = [account retain];
- myFolder = mailfolder_new(storage, (char *)[myPath cStringUsingEncoding:NSUTF8StringEncoding], NULL);
- assert(myFolder != NULL);
- }
- return self;
+ struct mailstorage *storage = (struct mailstorage *)[account storageStruct];
+ self = [super init];
+ if (self)
+ {
+ myPath = [path retain];
+ connected = NO;
+ myAccount = [account retain];
+ myFolder = mailfolder_new(storage, (char *)[myPath cStringUsingEncoding:NSUTF8StringEncoding], NULL);
+ assert(myFolder != NULL);
+ }
+ return self;
}
- (void)dealloc {
- if (connected)
- [self disconnect];
-
- mailfolder_free(myFolder);
- [myAccount release];
- [myPath release];
- [super dealloc];
+ if (connected)
+ [self disconnect];
+
+ mailfolder_free(myFolder);
+ [myAccount release];
+ [myPath release];
+ [super dealloc];
}
- (void)connect {
- int err = MAIL_NO_ERROR;
- err = mailfolder_connect(myFolder);
- IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
- [NSString stringWithFormat:@"Error number: %d",err]);
- connected = YES;
+ int err = MAIL_NO_ERROR;
+ err = mailfolder_connect(myFolder);
+ IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
+ [NSString stringWithFormat:@"Error number: %d",err]);
+ connected = YES;
}
- (void)disconnect {
- if(connected)
- mailfolder_disconnect(myFolder);
+ if(connected)
+ mailfolder_disconnect(myFolder);
}
- (NSString *)name {
- //Get the last part of the path
- NSArray *pathParts = [myPath componentsSeparatedByString:@"."];
- return [pathParts objectAtIndex:[pathParts count]-1];
+ //Get the last part of the path
+ NSArray *pathParts = [myPath componentsSeparatedByString:@"."];
+ return [pathParts objectAtIndex:[pathParts count]-1];
}
- (NSString *)path {
- return myPath;
+ return myPath;
}
- (void)setPath:(NSString *)path; {
- int err;
- const char *newPath = [path cStringUsingEncoding:NSUTF8StringEncoding];
- const char *oldPath = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
-
- [self connect];
- [self unsubscribe];
- err = mailimap_rename([myAccount session], oldPath, newPath);
- IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
- [NSString stringWithFormat:@"Error number: %d",err]);
- [path retain];
- [myPath release];
- myPath = path;
- [self subscribe];
+ int err;
+ const char *newPath = [path cStringUsingEncoding:NSUTF8StringEncoding];
+ const char *oldPath = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
+
+ [self connect];
+ [self unsubscribe];
+ err = mailimap_rename([myAccount session], oldPath, newPath);
+ IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
+ [NSString stringWithFormat:@"Error number: %d",err]);
+ [path retain];
+ [myPath release];
+ myPath = path;
+ [self subscribe];
}
- (void)create {
- int err;
- const char *path = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
-
- err = mailimap_create([myAccount session], path);
- IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
- [NSString stringWithFormat:@"Error number: %d",err]);
- [self connect];
- [self subscribe];
+ int err;
+ const char *path = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
+
+ err = mailimap_create([myAccount session], path);
+ IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
+ [NSString stringWithFormat:@"Error number: %d",err]);
+ [self connect];
+ [self subscribe];
}
- (void)delete {
- int err;
- const char *path = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
-
- [self connect];
- [self unsubscribe];
- err = mailimap_delete([myAccount session], path);
- IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
- [NSString stringWithFormat:@"Error number: %d",err]);
+ int err;
+ const char *path = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
+
+ [self connect];
+ [self unsubscribe];
+ err = mailimap_delete([myAccount session], path);
+ IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
+ [NSString stringWithFormat:@"Error number: %d",err]);
}
- (void)subscribe {
- int err;
- const char *path = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
-
- [self connect];
- err = mailimap_subscribe([myAccount session], path);
- IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
- [NSString stringWithFormat:@"Error number: %d",err]);
+ int err;
+ const char *path = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
+
+ [self connect];
+ err = mailimap_subscribe([myAccount session], path);
+ IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
+ [NSString stringWithFormat:@"Error number: %d",err]);
}
- (void)unsubscribe {
- int err;
- const char *path = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
-
- [self connect];
- err = mailimap_unsubscribe([myAccount session], path);
- IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
- [NSString stringWithFormat:@"Error number: %d",err]);
+ int err;
+ const char *path = [myPath cStringUsingEncoding:NSUTF8StringEncoding];
+
+ [self connect];
+ err = mailimap_unsubscribe([myAccount session], path);
+ IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
+ [NSString stringWithFormat:@"Error number: %d",err]);
}
- (struct mailfolder *)folderStruct {
- return myFolder;
+ return myFolder;
}
- (BOOL)isUIDValid:(NSString *)uid {
- uint32_t uidvalidity, check_uidvalidity;
- uidvalidity = [self uidValidity];
- check_uidvalidity = (uint32_t)[[[uid componentsSeparatedByString:@"-"] objectAtIndex:0] doubleValue];
- return (uidvalidity == check_uidvalidity);
+ uint32_t uidvalidity, check_uidvalidity;
+ uidvalidity = [self uidValidity];
+ check_uidvalidity = (uint32_t)[[[uid componentsSeparatedByString:@"-"] objectAtIndex:0] doubleValue];
+ return (uidvalidity == check_uidvalidity);
}
- (NSUInteger)uidValidity {
- [self connect];
- mailimap *imapSession;
- imapSession = [self imapSession];
- if (imapSession->imap_selection_info != NULL) {
- return imapSession->imap_selection_info->sel_uidvalidity;
- }
- return 0;
+ [self connect];
+ mailimap *imapSession;
+ imapSession = [self imapSession];
+ if (imapSession->imap_selection_info != NULL) {
+ return imapSession->imap_selection_info->sel_uidvalidity;
+ }
+ return 0;
}
- (void)check {
- [self connect];
- int err = mailfolder_check(myFolder);
- IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
- [NSString stringWithFormat:@"Error number: %d",err]);
+ [self connect];
+ int err = mailfolder_check(myFolder);
+ IfTrue_RaiseException(err != MAILIMAP_NO_ERROR, CTUnknownError,
+ [NSString stringWithFormat:@"Error number: %d",err]);
}
- (NSUInteger)sequenceNumberForUID:(NSString *)uid {
- //TODO check UID validity
- //TODO factor out this duplicate code
-
- int r;
- struct mailimap_fetch_att * fetch_att;
- struct mailimap_fetch_type * fetch_type;
- struct mailimap_set * set;
- clist * fetch_result;
- //TODO factor this out
- NSUInteger uidnum = (unsigned int)[[[uid componentsSeparatedByString:@"-"] objectAtIndex:1] doubleValue];
-
- [self connect];
- set = mailimap_set_new_single(uidnum);
- if (set == NULL)
- return 0;
-
- fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
- fetch_att = mailimap_fetch_att_new_uid();
- r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
- if (r != MAILIMAP_NO_ERROR) {
- mailimap_fetch_att_free(fetch_att);
- return 0;
- }
-
- r = mailimap_uid_fetch([self imapSession], set, fetch_type, &fetch_result);
- if (r != MAIL_NO_ERROR) {
- NSException *exception = [NSException
- exceptionWithName:CTUnknownError
- reason:[NSString stringWithFormat:@"Error number: %d",r]
- userInfo:nil];
- [exception raise];
- }
-
- mailimap_fetch_type_free(fetch_type);
- mailimap_set_free(set);
-
- if (r != MAILIMAP_NO_ERROR)
- return 0; //Add exception
- NSUInteger sequenceNumber = 0;
- if (!clist_isempty(fetch_result)) {
- struct mailimap_msg_att *msg_att = (struct mailimap_msg_att *)clist_nth_data(fetch_result, 0);
- sequenceNumber = msg_att->att_number;
- }
- mailimap_fetch_list_free(fetch_result);
- return sequenceNumber;
+ //TODO check UID validity
+ //TODO factor out this duplicate code
+
+ int r;
+ struct mailimap_fetch_att * fetch_att;
+ struct mailimap_fetch_type * fetch_type;
+ struct mailimap_set * set;
+ clist * fetch_result;
+ //TODO factor this out
+ NSUInteger uidnum = (unsigned int)[[[uid componentsSeparatedByString:@"-"] objectAtIndex:1] doubleValue];
+
+ [self connect];
+ set = mailimap_set_new_single(uidnum);
+ if (set == NULL)
+ return 0;
+
+ fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
+ fetch_att = mailimap_fetch_att_new_uid();
+ r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
+ if (r != MAILIMAP_NO_ERROR) {
+ mailimap_fetch_att_free(fetch_att);
+ return 0;
+ }
+
+ r = mailimap_uid_fetch([self imapSession], set, fetch_type, &fetch_result);
+ if (r != MAIL_NO_ERROR) {
+ NSException *exception = [NSException
+ exceptionWithName:CTUnknownError
+ reason:[NSString stringWithFormat:@"Error number: %d",r]
+ userInfo:nil];
+ [exception raise];
+ }
+
+ mailimap_fetch_type_free(fetch_type);
+ mailimap_set_free(set);
+
+ if (r != MAILIMAP_NO_ERROR)
+ return 0; //Add exception
+ NSUInteger sequenceNumber = 0;
+ if (!clist_isempty(fetch_result)) {
+ struct mailimap_msg_att *msg_att = (struct mailimap_msg_att *)clist_nth_data(fetch_result, 0);
+ sequenceNumber = msg_att->att_number;
+ }
+ mailimap_fetch_list_free(fetch_result);
+ return sequenceNumber;
}
- (NSSet *)messageListWithFetchAttributes:(NSArray *)attributes {
- int r;
- struct mailimap_fetch_att * fetch_att;
- struct mailimap_fetch_type * fetch_type;
- struct mailimap_set * set;
- clist * fetch_result;
-
- [self connect];
- set = mailimap_set_new_interval(1, 0);
- if (set == NULL)
- return nil;
-
- fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
- fetch_att = mailimap_fetch_att_new_uid();
- r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
- if (r != MAILIMAP_NO_ERROR) {
- mailimap_fetch_att_free(fetch_att);
- return nil;
- }
-
- fetch_att = mailimap_fetch_att_new_flags();
- if (fetch_att == NULL) {
- mailimap_fetch_type_free(fetch_type);
- return nil;
- }
-
- r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
- if (r != MAILIMAP_NO_ERROR) {
- mailimap_fetch_att_free(fetch_att);
- mailimap_fetch_type_free(fetch_type);
- return nil;
- }
-
- r = mailimap_fetch([self imapSession], set, fetch_type, &fetch_result);
- if (r != MAIL_NO_ERROR) {
- NSException *exception = [NSException
- exceptionWithName:CTUnknownError
- reason:[NSString stringWithFormat:@"Error number: %d",r]
- userInfo:nil];
- [exception raise];
- }
-
- mailimap_fetch_type_free(fetch_type);
- mailimap_set_free(set);
-
- if (r != MAILIMAP_NO_ERROR)
- return nil; //Add exception
-
- NSMutableSet *messages = [NSMutableSet set];
- NSUInteger uidValidity = [self uidValidity];
- clistiter *iter;
- for(iter = clist_begin(fetch_result); iter != NULL; iter = clist_next(iter)) {
- CTBareMessage *msg = [[CTBareMessage alloc] init];
-
- struct mailimap_msg_att *msg_att = clist_content(iter);
- clistiter * item_cur;
- uint32_t uid;
- struct mail_flags *flags;
-
- uid = 0;
- for(item_cur = clist_begin(msg_att->att_list); item_cur != NULL;
- item_cur = clist_next(item_cur)) {
- struct mailimap_msg_att_item * item;
-
- NSString *str;
- item = clist_content(item_cur);
- switch (item->att_type) {
- case MAILIMAP_MSG_ATT_ITEM_STATIC:
- switch (item->att_data.att_static->att_type) {
- case MAILIMAP_MSG_ATT_UID:
- str = [[NSString alloc] initWithFormat:@"%d-%d", uidValidity,
- item->att_data.att_static->att_data.att_uid];
- msg.uid = str;
- [str release];
- break;
- }
- break;
- case MAILIMAP_MSG_ATT_ITEM_DYNAMIC:
- r = imap_flags_to_flags(item->att_data.att_dyn, &flags);
- if (r == MAIL_NO_ERROR) {
- msg.flags = flags->fl_flags;
- }
- mail_flags_free(flags);
- break;
- }
- }
- [messages addObject:msg];
- [msg release];
- }
- mailimap_fetch_list_free(fetch_result);
- return messages;
+ int r;
+ struct mailimap_fetch_att * fetch_att;
+ struct mailimap_fetch_type * fetch_type;
+ struct mailimap_set * set;
+ clist * fetch_result;
+
+ [self connect];
+ set = mailimap_set_new_interval(1, 0);
+ if (set == NULL)
+ return nil;
+
+ fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
+ fetch_att = mailimap_fetch_att_new_uid();
+ r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
+ if (r != MAILIMAP_NO_ERROR) {
+ mailimap_fetch_att_free(fetch_att);
+ return nil;
+ }
+
+ fetch_att = mailimap_fetch_att_new_flags();
+ if (fetch_att == NULL) {
+ mailimap_fetch_type_free(fetch_type);
+ return nil;
+ }
+
+ r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
+ if (r != MAILIMAP_NO_ERROR) {
+ mailimap_fetch_att_free(fetch_att);
+ mailimap_fetch_type_free(fetch_type);
+ return nil;
+ }
+
+ r = mailimap_fetch([self imapSession], set, fetch_type, &fetch_result);
+ if (r != MAIL_NO_ERROR) {
+ NSException *exception = [NSException
+ exceptionWithName:CTUnknownError
+ reason:[NSString stringWithFormat:@"Error number: %d",r]
+ userInfo:nil];
+ [exception raise];
+ }
+
+ mailimap_fetch_type_free(fetch_type);
+ mailimap_set_free(set);
+
+ if (r != MAILIMAP_NO_ERROR)
+ return nil; //Add exception
+
+ NSMutableSet *messages = [NSMutableSet set];
+ NSUInteger uidValidity = [self uidValidity];
+ clistiter *iter;
+ for(iter = clist_begin(fetch_result); iter != NULL; iter = clist_next(iter)) {
+ CTBareMessage *msg = [[CTBareMessage alloc] init];
+
+ struct mailimap_msg_att *msg_att = clist_content(iter);
+ clistiter * item_cur;
+ uint32_t uid;
+ struct mail_flags *flags;
+
+ uid = 0;
+ for(item_cur = clist_begin(msg_att->att_list); item_cur != NULL;
+ item_cur = clist_next(item_cur)) {
+ struct mailimap_msg_att_item * item;
+
+ NSString *str;
+ item = clist_content(item_cur);
+ switch (item->att_type) {
+ case MAILIMAP_MSG_ATT_ITEM_STATIC:
+ switch (item->att_data.att_static->att_type) {
+ case MAILIMAP_MSG_ATT_UID:
+ str = [[NSString alloc] initWithFormat:@"%d-%d", uidValidity,
+ item->att_data.att_static->att_data.att_uid];
+ msg.uid = str;
+ [str release];
+ break;
+ }
+ break;
+ case MAILIMAP_MSG_ATT_ITEM_DYNAMIC:
+ r = imap_flags_to_flags(item->att_data.att_dyn, &flags);
+ if (r == MAIL_NO_ERROR) {
+ msg.flags = flags->fl_flags;
+ }
+ mail_flags_free(flags);
+ break;
+ }
+ }
+ [messages addObject:msg];
+ [msg release];
+ }
+ mailimap_fetch_list_free(fetch_result);
+ return messages;
}
- (NSSet *)messageObjectsFromIndex:(unsigned int)start toIndex:(unsigned int)end {
- struct mailmessage_list * env_list;
- int r;
- struct mailimap_fetch_att * fetch_att;
- struct mailimap_fetch_type * fetch_type;
- struct mailimap_set * set;
- clist * fetch_result;
-
- [self connect];
- set = mailimap_set_new_interval(start, end);
- if (set == NULL)
- return nil;
-
- fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
- fetch_att = mailimap_fetch_att_new_uid();
- r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
- if (r != MAILIMAP_NO_ERROR) {
- mailimap_fetch_att_free(fetch_att);
- return nil;
- }
-
- fetch_att = mailimap_fetch_att_new_rfc822_size();
- if (fetch_att == NULL) {
- mailimap_fetch_type_free(fetch_type);
- return nil;
- }
-
- r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
- if (r != MAILIMAP_NO_ERROR) {
- mailimap_fetch_att_free(fetch_att);
- mailimap_fetch_type_free(fetch_type);
- return nil;
- }
-
- r = mailimap_fetch([self imapSession], set, fetch_type, &fetch_result);
- if (r != MAIL_NO_ERROR) {
- NSException *exception = [NSException
- exceptionWithName:CTUnknownError
- reason:[NSString stringWithFormat:@"Error number: %d",r]
- userInfo:nil];
- [exception raise];
- }
-
- mailimap_fetch_type_free(fetch_type);
- mailimap_set_free(set);
-
- if (r != MAILIMAP_NO_ERROR)
- return nil; //Add exception
-
- env_list = NULL;
- r = uid_list_to_env_list(fetch_result, &env_list, [self folderSession], imap_message_driver);
- r = mailfolder_get_envelopes_list(myFolder, env_list);
- if (r != MAIL_NO_ERROR) {
- if ( env_list != NULL )
- mailmessage_list_free(env_list);
- NSException *exception = [NSException
- exceptionWithName:CTUnknownError
- reason:[NSString stringWithFormat:@"Error number: %d",r]
- userInfo:nil];
- [exception raise];
- }
-
- int len = carray_count(env_list->msg_tab);
- int i;
- CTCoreMessage *msgObject;
- struct mailmessage *msg;
- clistiter *fetchResultIter = clist_begin(fetch_result);
- NSMutableSet *messages = [NSMutableSet set];
- for(i=0; i<len; i++) {
- msg = carray_get(env_list->msg_tab, i);
- msgObject = [[CTCoreMessage alloc] initWithMessageStruct:msg];
- struct mailimap_msg_att *msg_att = (struct mailimap_msg_att *)clist_content(fetchResultIter);
- if(msg_att != nil) {
- [msgObject setSequenceNumber:msg_att->att_number];
- [messages addObject:msgObject];
- }
- [msgObject release];
- fetchResultIter = clist_next(fetchResultIter);
- }
- if ( env_list != NULL ) {
- //I am only freeing the message array because the messages themselves are in use
- carray_free(env_list->msg_tab);
- free(env_list);
- }
- mailimap_fetch_list_free(fetch_result);
- return messages;
+ struct mailmessage_list * env_list;
+ int r;
+ struct mailimap_fetch_att * fetch_att;
+ struct mailimap_fetch_type * fetch_type;
+ struct mailimap_set * set;
+ clist * fetch_result;
+
+ [self connect];
+ set = mailimap_set_new_interval(start, end);
+ if (set == NULL)
+ return nil;
+
+ fetch_type = mailimap_fetch_type_new_fetch_att_list_empty();
+ fetch_att = mailimap_fetch_att_new_uid();
+ r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
+ if (r != MAILIMAP_NO_ERROR) {
+ mailimap_fetch_att_free(fetch_att);
+ return nil;
+ }
+
+ fetch_att = mailimap_fetch_att_new_rfc822_size();
+ if (fetch_att == NULL) {
+ mailimap_fetch_type_free(fetch_type);
+ return nil;
+ }
+
+ r = mailimap_fetch_type_new_fetch_att_list_add(fetch_type, fetch_att);
+ if (r != MAILIMAP_NO_ERROR) {
+ mailimap_fetch_att_free(fetch_att);
+ mailimap_fetch_type_free(fetch_type);
+ return nil;
+ }
+
+ r = mailimap_fetch([self imapSession], set, fetch_type, &fetch_result);
+ if (r != MAIL_NO_ERROR) {
+ NSException *exception = [NSException
+ exceptionWithName:CTUnknownError
+ reason:[NSString stringWithFormat:@"Error number: %d",r]
+ userInfo:nil];