diff --git a/ChangeLog b/ChangeLog index 452b9ed9f..e1a1bd2b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-08-25 Ludovic Marcotte + + * It's now possible to use SSL or TLS for the + SOGoIMAPServer value. Also updated the documentation + to give samples. Fixed the "port" value save from + the preferences module. + 2010-08-24 Wolfgang Sourdeau * UI/WebServerResources/generic.js: (log): added a hack to enable diff --git a/Documentation/SOGo Installation Guide.odt b/Documentation/SOGo Installation Guide.odt index e3dab88e1..959544011 100644 Binary files a/Documentation/SOGo Installation Guide.odt and b/Documentation/SOGo Installation Guide.odt differ diff --git a/SoObjects/Mailer/SOGoMailAccount.m b/SoObjects/Mailer/SOGoMailAccount.m index 92720b104..f956c5bd7 100644 --- a/SoObjects/Mailer/SOGoMailAccount.m +++ b/SoObjects/Mailer/SOGoMailAccount.m @@ -521,18 +521,17 @@ static NSString *sieveScriptName = @"sogo"; mailAccount = [self _mailAccount]; encryption = [mailAccount objectForKey: @"encryption"]; + defaultPort = [[mailAccount objectForKey: @"port"] intValue]; - if ([encryption isEqualToString: @"ssl"]) - { + if (!defaultPort) + defaultPort = 143; + + if ([encryption isEqualToString: @"ssl"] || + [encryption isEqualToString: @"tls"]) protocol = @"imaps"; - defaultPort = 993; - } else - { protocol = @"imap"; - defaultPort = 143; - } - + username = [mailAccount objectForKey: @"userName"]; escUsername = [[username stringByEscapingURL] stringByReplacingString: @"@" diff --git a/SoObjects/SOGo/SOGoUser.m b/SoObjects/SOGo/SOGoUser.m index 5b0b83d52..2e7469082 100644 --- a/SoObjects/SOGo/SOGoUser.m +++ b/SoObjects/SOGo/SOGoUser.m @@ -502,10 +502,11 @@ - (void) _appendSystemMailAccount { + NSString *fullName, *imapLogin, *imapServer, *signature, *encryption, *port, *scheme; NSMutableDictionary *mailAccount, *identity, *mailboxes; NSMutableArray *identities; - NSString *fullName, *imapLogin, *imapServer, *signature; NSArray *mails; + NSURL *url; unsigned int count, max; mailAccount = [NSMutableDictionary new]; @@ -516,8 +517,46 @@ if (!imapServer) imapServer = [[self domainDefaults] imapServer]; + // imapServer might have the following format + // localhost + // localhost:143 + // imap://localhost + // imap://localhost:143 + // imaps://localhost:993 + // imaps://localhost:143/?tls=YES + // imaps://localhost/?tls=YES + url = [NSURL URLWithString: imapServer]; + + scheme = [url scheme]; + port = [url port]; + + encryption = @"none"; + port = @"143"; + + if ([url query] && [[url query] caseInsensitiveCompare: @"tls=YES"] == NSOrderedSame) + encryption = @"tls"; + + if ([port intValue] == 0) + { + if (scheme) + { + if ([scheme caseInsensitiveCompare: @"imaps"] == NSOrderedSame && + ![encryption isEqualToString: @"tls"]) + { + encryption = @"ssl"; + port = @"993"; + } + } + } + + if ([url host]) + imapServer = [url host]; + [mailAccount setObject: imapLogin forKey: @"userName"]; [mailAccount setObject: imapServer forKey: @"serverName"]; + [mailAccount setObject: port forKey: @"port"]; + [mailAccount setObject: encryption forKey: @"encryption"]; + identities = [NSMutableArray new]; mails = [self allEmails]; diff --git a/SoObjects/SOGo/SOGoUserDefaults.m b/SoObjects/SOGo/SOGoUserDefaults.m index bdd10a13e..8513efa4f 100644 --- a/SoObjects/SOGo/SOGoUserDefaults.m +++ b/SoObjects/SOGo/SOGoUserDefaults.m @@ -1,6 +1,6 @@ /* SOGoUserDefaults.m - this file is part of SOGo * - * Copyright (C) 2009 Inverse inc. + * Copyright (C) 2009-2010 Inverse inc. * * Author: Wolfgang Sourdeau * diff --git a/UI/PreferencesUI/UIxPreferences.m b/UI/PreferencesUI/UIxPreferences.m index 928c69956..1b8e76593 100644 --- a/UI/PreferencesUI/UIxPreferences.m +++ b/UI/PreferencesUI/UIxPreferences.m @@ -1162,7 +1162,7 @@ { knownKeys = [NSArray arrayWithObjects: @"name", @"serverName", @"userName", @"password", @"encryption", - @"identities", @"mailboxes", nil]; + @"identities", @"mailboxes", @"port", nil]; [knownKeys retain]; }