diff --git a/ChangeLog b/ChangeLog index a2ba604f4..e40b7f3cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2012-02-03 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoMailFolder.m (-exists): new method that + returns whether an IMAP folder exists or not yet. + 2012-02-01 Wolfgang Sourdeau * OpenChange/MAPIStoreUserContext.m (-destroy): dont't release diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index f1a9e15cd..98bc94c85 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -82,6 +82,8 @@ - (void) markForExpunge; - (void) expungeLastMarkedFolder; +- (BOOL) exists; + - (BOOL) create; - (NSException *) expunge; diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 03e7b9b15..87cece7d8 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -248,7 +248,7 @@ static NSString *defaultUserID = @"anyone"; if (!filenames) { filenames = [NSMutableArray new]; - if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]]) + if ([self exists]) { uids = [self fetchUIDsMatchingQualifier: nil sortOrdering: @"DATE"]; if (![uids isKindOfClass: [NSException class]]) @@ -555,7 +555,7 @@ static NSString *defaultUserID = @"anyone"; NSString *archiveName; EOQualifier *notDeleted; - if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]]) + if ([self exists]) { notDeleted = [EOQualifier qualifierWithQualifierFormat: @"(not (flags = %@))", @"deleted"]; @@ -722,7 +722,7 @@ static NSString *defaultUserID = @"anyone"; { // We check for the existence of the IMAP folder (likely to be the // Sent mailbox) prior to appending messages to it. - if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]] + if ([self exists] || ![[self imap4Connection] createMailbox: [[self imap4Connection] imap4FolderNameForURL: [self imap4URL]] atURL: [[self mailAccountFolder] imap4URL]]) return [[self imap4Connection] postData: _data flags: _flags @@ -835,7 +835,7 @@ static NSString *defaultUserID = @"anyone"; inContainer: self]; } else if (isdigit ([_key characterAtIndex: 0]) - && [[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]]) + && [self exists]) { obj = [SOGoMailObject objectWithName: _key inContainer: self]; if ([_key hasSuffix: @".eml"]) @@ -863,6 +863,11 @@ static NSString *defaultUserID = @"anyone"; return [[self imap4Connection] createMailbox:_name atURL:[self imap4URL]]; } +- (BOOL) exists +{ + return [[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]]; +} + - (BOOL) create { NSException *error;