From b8fafe42da6ab097c30038fc179cf6e526731317 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 4 Jan 2010 15:58:52 +0000 Subject: [PATCH 1/3] Monotone-Parent: f6829bdd7a8f8207d69f2c7bd6e1dc52fe733eb0 Monotone-Revision: 2d07c11d93d913a43469f1241e1bd63bece15be7 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-01-04T15:58:52 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++ SoObjects/Mailer/SOGoMailAccount.h | 1 + SoObjects/Mailer/SOGoMailAccount.m | 62 +++++++++++++++++++++------ SoObjects/Mailer/SOGoMailBaseObject.m | 2 +- SoObjects/Mailer/SOGoMailFolder.h | 3 ++ SoObjects/Mailer/SOGoMailFolder.m | 11 ++++- SoObjects/Mailer/SOGoMailForward.m | 12 ++---- SoObjects/SOGo/NSString+Utilities.h | 2 +- SoObjects/SOGo/NSString+Utilities.m | 17 ++++++++ 9 files changed, 92 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 099cc3e04..da85627a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-04 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoMailForward.m (-): we use + -[SOGoUserDefaults mailComposeMessageType] instead of querying the + defaults key, so that the fallbacking mechanism between the + different preference layers can be used. + 2009-12-26 Ludovic Marcotte * SoObjects/SOGo/SOGoMailer.m (_smtpSendData: diff --git a/SoObjects/Mailer/SOGoMailAccount.h b/SoObjects/Mailer/SOGoMailAccount.h index edebb4b59..65c300396 100644 --- a/SoObjects/Mailer/SOGoMailAccount.h +++ b/SoObjects/Mailer/SOGoMailAccount.h @@ -55,6 +55,7 @@ typedef enum { SOGoSentFolder *sentFolder; SOGoTrashFolder *trashFolder; SOGoIMAPAclStyle imapAclStyle; + NSMutableArray *namespaces; } - (void) setAccountName: (NSString *) newAccountName; diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index d46b2316b..bc708cf55 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -39,6 +39,7 @@ #import #import +#import #import #import #import @@ -67,6 +68,7 @@ static NSString *sieveScriptName = @"sogo"; trashFolder = nil; accountName = nil; imapAclStyle = undefined; + namespaces = nil; } return self; @@ -74,6 +76,7 @@ static NSString *sieveScriptName = @"sogo"; - (void) dealloc { + [namespaces release]; [inboxFolder release]; [draftsFolder release]; [sentFolder release]; @@ -94,24 +97,55 @@ static NSString *sieveScriptName = @"sogo"; return NO; } +- (void) _appendNamespace: (NSArray *) namespace + toFolders: (NSMutableArray *) folders +{ + NSString *newFolder; + NSDictionary *currentPart; + int count, max; + + max = [namespace count]; + for (count = 0; count < max; count++) + { + currentPart = [namespace objectAtIndex: count]; + newFolder + = [[currentPart objectForKey: @"prefix"] substringFromIndex: 1]; + if ([newFolder length]) + [folders addObject: [newFolder asCSSIdentifier]]; + } +} + +- (void) _appendNamespaces: (NSMutableArray *) folders +{ + NSDictionary *namespaceDict; + NSArray *namespace; + NGImap4Client *client; + + client = [[self imap4Connection] client]; + namespaceDict = [client namespace]; + namespace = [namespaceDict objectForKey: @"personal"]; + if (namespace) + [self _appendNamespace: namespace toFolders: folders]; + namespace = [namespaceDict objectForKey: @"other users"]; + if (namespace) + [self _appendNamespace: namespace toFolders: folders]; + namespace = [namespaceDict objectForKey: @"shared"]; + if (namespace) + [self _appendNamespace: namespace toFolders: folders]; +} + - (NSArray *) toManyRelationshipKeys { NSMutableArray *folders; - NSArray *imapFolders, *additionalFolders; - - folders = [NSMutableArray array]; + NSArray *imapFolders; imapFolders = [[self imap4Connection] subfoldersForURL: [self imap4URL]]; - additionalFolders - = [NSArray arrayWithObject: [self draftsFolderNameInContext: nil]]; - if ([imapFolders count] > 0) - [folders addObjectsFromArray: imapFolders]; - if ([additionalFolders count] > 0) - { - [folders removeObjectsInArray: additionalFolders]; - [folders addObjectsFromArray: additionalFolders]; - } - + folders = [imapFolders mutableCopy]; + [folders autorelease]; + [folders addObjectUniquely: [self draftsFolderNameInContext: nil]]; + + [self _appendNamespaces: folders]; + return [folders stringsWithFormat: @"folder%@"]; } @@ -420,6 +454,8 @@ static NSString *sieveScriptName = @"sogo"; Class klazz; id obj; + [[[self imap4Connection] client] namespace]; + if ([_key hasPrefix: @"folder"]) { folderName = [_key substringFromIndex: 6]; diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index 176dfaef0..cb29b51fb 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -120,7 +120,7 @@ static BOOL debugOn = YES; { if (!imap4) { - imap4 = [[self mailManager] connectionForURL: [self imap4URL] + imap4 = [[self mailManager] connectionForURL: [self imap4URL] password: [self imap4Password]]; if (imap4) [imap4 retain]; diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 35e75ca12..faccca516 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -43,8 +43,11 @@ NSMutableArray *filenames; NSString *folderType; NSDictionary *mailboxACL; + BOOL isNamespace; } +- (void) setIsNamespace: (BOOL) newIsNamespace; + - (NSString *) absoluteImap4Name; /* messages */ diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index e5875d1f5..199170c88 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -44,6 +44,7 @@ #import #import +#import #import #import #import @@ -106,6 +107,7 @@ static NSString *defaultUserID = @"anyone"; { [self _adjustOwner]; mailboxACL = nil; + isNamespace = NO; } return self; @@ -113,7 +115,7 @@ static NSString *defaultUserID = @"anyone"; - (void) dealloc { - [filenames release]; + [filenames release]; [folderType release]; [mailboxACL release]; [super dealloc]; @@ -121,9 +123,14 @@ static NSString *defaultUserID = @"anyone"; /* IMAP4 */ +- (void) setIsNamespace: (BOOL) newIsNamespace +{ + isNamespace = newIsNamespace; +} + - (NSString *) relativeImap4Name { - return [nameInContainer substringFromIndex: 6]; + return [[nameInContainer substringFromIndex: 6] fromCSSIdentifier]; } - (NSString *) absoluteImap4Name diff --git a/SoObjects/Mailer/SOGoMailForward.m b/SoObjects/Mailer/SOGoMailForward.m index 52159376e..3eb5d8980 100644 --- a/SoObjects/Mailer/SOGoMailForward.m +++ b/SoObjects/Mailer/SOGoMailForward.m @@ -34,17 +34,13 @@ - (id) init { + SOGoUserDefaults *ud; + if ((self = [super init])) { - SOGoUserDefaults *ud; ud = [[context activeUser] userDefaults]; - - // Backward comptability with <= 1.1.0 (ComposeMessagesType) - if ([ud objectForKey: @"ComposeMessagesType"]) - htmlComposition = [[ud objectForKey: @"ComposeMessagesType"] isEqualToString: @"html"]; - else - htmlComposition = [[ud objectForKey: @"SOGoMailComposeMessageType"] isEqualToString: @"html"]; - + htmlComposition + = [[ud mailComposeMessageType] isEqualToString: @"html"]; sourceMail = nil; currentValue = nil; } diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index c3b37f2f3..7ae807b8b 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -47,7 +47,7 @@ - (NSString *) jsonRepresentation; - (NSString *) asCSSIdentifier; - +- (NSString *) fromCSSIdentifier; /* bare email addresses */ - (NSString *) pureEMailAddress; diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index 230757265..080b965e5 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -322,6 +322,23 @@ static NSMutableCharacterSet *urlStartChars = nil; return cssIdentifier; } +- (NSString *) fromCSSIdentifier +{ + NSMutableString *newString; + + newString = [NSMutableString stringWithString: self]; + [newString replaceString: @"_U_" withString: @"_"]; + [newString replaceString: @"_D_" withString: @"."]; + [newString replaceString: @"_H_" withString: @"#"]; + [newString replaceString: @"_A_" withString: @"@"]; + [newString replaceString: @"_S_" withString: @"*"]; + [newString replaceString: @"_C_" withString: @":"]; + [newString replaceString: @"_CO_" withString: @","]; + [newString replaceString: @"_SP_" withString: @" "]; + + return newString; +} + - (NSString *) pureEMailAddress { NSString *pureAddress; From 623fbc186f571d7c3ed87a9c1e6c42de0dabebc5 Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 4 Jan 2010 15:59:40 +0000 Subject: [PATCH 2/3] reverted previous commit Monotone-Parent: 2d07c11d93d913a43469f1241e1bd63bece15be7 Monotone-Revision: 85b7e15d67f23e989d9e37bf3c1afb60aa11ddc3 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-01-04T15:59:40 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 --- SoObjects/Mailer/SOGoMailAccount.h | 1 - SoObjects/Mailer/SOGoMailAccount.m | 62 ++++++--------------------- SoObjects/Mailer/SOGoMailBaseObject.m | 2 +- SoObjects/Mailer/SOGoMailFolder.h | 3 -- SoObjects/Mailer/SOGoMailFolder.m | 11 +---- SoObjects/Mailer/SOGoMailForward.m | 12 ++++-- SoObjects/SOGo/NSString+Utilities.h | 2 +- SoObjects/SOGo/NSString+Utilities.m | 17 -------- 9 files changed, 25 insertions(+), 92 deletions(-) diff --git a/ChangeLog b/ChangeLog index da85627a0..099cc3e04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,3 @@ -2010-01-04 Wolfgang Sourdeau - - * SoObjects/Mailer/SOGoMailForward.m (-): we use - -[SOGoUserDefaults mailComposeMessageType] instead of querying the - defaults key, so that the fallbacking mechanism between the - different preference layers can be used. - 2009-12-26 Ludovic Marcotte * SoObjects/SOGo/SOGoMailer.m (_smtpSendData: diff --git a/SoObjects/Mailer/SOGoMailAccount.h b/SoObjects/Mailer/SOGoMailAccount.h index 65c300396..edebb4b59 100644 --- a/SoObjects/Mailer/SOGoMailAccount.h +++ b/SoObjects/Mailer/SOGoMailAccount.h @@ -55,7 +55,6 @@ typedef enum { SOGoSentFolder *sentFolder; SOGoTrashFolder *trashFolder; SOGoIMAPAclStyle imapAclStyle; - NSMutableArray *namespaces; } - (void) setAccountName: (NSString *) newAccountName; diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index bc708cf55..d46b2316b 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -39,7 +39,6 @@ #import #import -#import #import #import #import @@ -68,7 +67,6 @@ static NSString *sieveScriptName = @"sogo"; trashFolder = nil; accountName = nil; imapAclStyle = undefined; - namespaces = nil; } return self; @@ -76,7 +74,6 @@ static NSString *sieveScriptName = @"sogo"; - (void) dealloc { - [namespaces release]; [inboxFolder release]; [draftsFolder release]; [sentFolder release]; @@ -97,55 +94,24 @@ static NSString *sieveScriptName = @"sogo"; return NO; } -- (void) _appendNamespace: (NSArray *) namespace - toFolders: (NSMutableArray *) folders -{ - NSString *newFolder; - NSDictionary *currentPart; - int count, max; - - max = [namespace count]; - for (count = 0; count < max; count++) - { - currentPart = [namespace objectAtIndex: count]; - newFolder - = [[currentPart objectForKey: @"prefix"] substringFromIndex: 1]; - if ([newFolder length]) - [folders addObject: [newFolder asCSSIdentifier]]; - } -} - -- (void) _appendNamespaces: (NSMutableArray *) folders -{ - NSDictionary *namespaceDict; - NSArray *namespace; - NGImap4Client *client; - - client = [[self imap4Connection] client]; - namespaceDict = [client namespace]; - namespace = [namespaceDict objectForKey: @"personal"]; - if (namespace) - [self _appendNamespace: namespace toFolders: folders]; - namespace = [namespaceDict objectForKey: @"other users"]; - if (namespace) - [self _appendNamespace: namespace toFolders: folders]; - namespace = [namespaceDict objectForKey: @"shared"]; - if (namespace) - [self _appendNamespace: namespace toFolders: folders]; -} - - (NSArray *) toManyRelationshipKeys { NSMutableArray *folders; - NSArray *imapFolders; + NSArray *imapFolders, *additionalFolders; + + folders = [NSMutableArray array]; imapFolders = [[self imap4Connection] subfoldersForURL: [self imap4URL]]; - folders = [imapFolders mutableCopy]; - [folders autorelease]; - [folders addObjectUniquely: [self draftsFolderNameInContext: nil]]; - - [self _appendNamespaces: folders]; - + additionalFolders + = [NSArray arrayWithObject: [self draftsFolderNameInContext: nil]]; + if ([imapFolders count] > 0) + [folders addObjectsFromArray: imapFolders]; + if ([additionalFolders count] > 0) + { + [folders removeObjectsInArray: additionalFolders]; + [folders addObjectsFromArray: additionalFolders]; + } + return [folders stringsWithFormat: @"folder%@"]; } @@ -454,8 +420,6 @@ static NSString *sieveScriptName = @"sogo"; Class klazz; id obj; - [[[self imap4Connection] client] namespace]; - if ([_key hasPrefix: @"folder"]) { folderName = [_key substringFromIndex: 6]; diff --git a/SoObjects/Mailer/SOGoMailBaseObject.m b/SoObjects/Mailer/SOGoMailBaseObject.m index cb29b51fb..176dfaef0 100644 --- a/SoObjects/Mailer/SOGoMailBaseObject.m +++ b/SoObjects/Mailer/SOGoMailBaseObject.m @@ -120,7 +120,7 @@ static BOOL debugOn = YES; { if (!imap4) { - imap4 = [[self mailManager] connectionForURL: [self imap4URL] + imap4 = [[self mailManager] connectionForURL: [self imap4URL] password: [self imap4Password]]; if (imap4) [imap4 retain]; diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index faccca516..35e75ca12 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -43,11 +43,8 @@ NSMutableArray *filenames; NSString *folderType; NSDictionary *mailboxACL; - BOOL isNamespace; } -- (void) setIsNamespace: (BOOL) newIsNamespace; - - (NSString *) absoluteImap4Name; /* messages */ diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 199170c88..e5875d1f5 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -44,7 +44,6 @@ #import #import -#import #import #import #import @@ -107,7 +106,6 @@ static NSString *defaultUserID = @"anyone"; { [self _adjustOwner]; mailboxACL = nil; - isNamespace = NO; } return self; @@ -115,7 +113,7 @@ static NSString *defaultUserID = @"anyone"; - (void) dealloc { - [filenames release]; + [filenames release]; [folderType release]; [mailboxACL release]; [super dealloc]; @@ -123,14 +121,9 @@ static NSString *defaultUserID = @"anyone"; /* IMAP4 */ -- (void) setIsNamespace: (BOOL) newIsNamespace -{ - isNamespace = newIsNamespace; -} - - (NSString *) relativeImap4Name { - return [[nameInContainer substringFromIndex: 6] fromCSSIdentifier]; + return [nameInContainer substringFromIndex: 6]; } - (NSString *) absoluteImap4Name diff --git a/SoObjects/Mailer/SOGoMailForward.m b/SoObjects/Mailer/SOGoMailForward.m index 3eb5d8980..52159376e 100644 --- a/SoObjects/Mailer/SOGoMailForward.m +++ b/SoObjects/Mailer/SOGoMailForward.m @@ -34,13 +34,17 @@ - (id) init { - SOGoUserDefaults *ud; - if ((self = [super init])) { + SOGoUserDefaults *ud; ud = [[context activeUser] userDefaults]; - htmlComposition - = [[ud mailComposeMessageType] isEqualToString: @"html"]; + + // Backward comptability with <= 1.1.0 (ComposeMessagesType) + if ([ud objectForKey: @"ComposeMessagesType"]) + htmlComposition = [[ud objectForKey: @"ComposeMessagesType"] isEqualToString: @"html"]; + else + htmlComposition = [[ud objectForKey: @"SOGoMailComposeMessageType"] isEqualToString: @"html"]; + sourceMail = nil; currentValue = nil; } diff --git a/SoObjects/SOGo/NSString+Utilities.h b/SoObjects/SOGo/NSString+Utilities.h index 7ae807b8b..c3b37f2f3 100644 --- a/SoObjects/SOGo/NSString+Utilities.h +++ b/SoObjects/SOGo/NSString+Utilities.h @@ -47,7 +47,7 @@ - (NSString *) jsonRepresentation; - (NSString *) asCSSIdentifier; -- (NSString *) fromCSSIdentifier; + /* bare email addresses */ - (NSString *) pureEMailAddress; diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index 080b965e5..230757265 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -322,23 +322,6 @@ static NSMutableCharacterSet *urlStartChars = nil; return cssIdentifier; } -- (NSString *) fromCSSIdentifier -{ - NSMutableString *newString; - - newString = [NSMutableString stringWithString: self]; - [newString replaceString: @"_U_" withString: @"_"]; - [newString replaceString: @"_D_" withString: @"."]; - [newString replaceString: @"_H_" withString: @"#"]; - [newString replaceString: @"_A_" withString: @"@"]; - [newString replaceString: @"_S_" withString: @"*"]; - [newString replaceString: @"_C_" withString: @":"]; - [newString replaceString: @"_CO_" withString: @","]; - [newString replaceString: @"_SP_" withString: @" "]; - - return newString; -} - - (NSString *) pureEMailAddress { NSString *pureAddress; From 1af27ac214f73a5d2a189df6fed243f0b8b5983b Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 4 Jan 2010 15:59:57 +0000 Subject: [PATCH 3/3] Monotone-Parent: 85b7e15d67f23e989d9e37bf3c1afb60aa11ddc3 Monotone-Revision: f910b2c688865ff7576908ec3caa65dbd9cd74a2 Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2010-01-04T15:59:57 Monotone-Branch: ca.inverse.sogo --- ChangeLog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 099cc3e04..da85627a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-01-04 Wolfgang Sourdeau + + * SoObjects/Mailer/SOGoMailForward.m (-): we use + -[SOGoUserDefaults mailComposeMessageType] instead of querying the + defaults key, so that the fallbacking mechanism between the + different preference layers can be used. + 2009-12-26 Ludovic Marcotte * SoObjects/SOGo/SOGoMailer.m (_smtpSendData: