(fix) now dynamically detect and use the IMAP separator (fixes #1490)

pull/259/head
Ludovic Marcotte 2019-09-04 13:45:53 -04:00
parent 936f7dde09
commit 3187bca0ef
7 changed files with 27 additions and 17 deletions

View File

@ -1960,12 +1960,6 @@ Defaults to `/tmp`.
The default value is `YES`.
|S |NGImap4ConnectionStringSeparator
|Parameter used to set the IMAP mailbox separator. Setting this will
also have an impact on the mailbox separator used by Sieve filters.
The default separator is `/`.
|S |NGImap4AuthMechanism
|Trigger the use of the IMAP `AUTHENTICATE` command with the specified
SASL mechanism. Please note that feature might be limited at this time.

1
NEWS
View File

@ -12,6 +12,7 @@ Enhancements
- [web] prohibit duplicate contact categories in Preferences module
- [web] improve constrat of text in toolbar with input fields
- [web] updated Angular Material to version 1.1.20
- [core] now dynamically detect and use the IMAP separator (#1490)
Bug fixes
- [web] properly handle Windows-1256 charaset (#4781)

View File

@ -75,6 +75,7 @@ typedef enum {
/* capabilities */
- (BOOL) hasCapability: (NSString *) capability;
- (NSString *) imap4Separator;
- (BOOL) supportsQuotas;
- (BOOL) supportsQResync;

View File

@ -257,6 +257,18 @@ static NSString *inboxFolderName = @"INBOX";
return [capabilities containsObject: capability];
}
- (NSString *) imap4Separator
{
NGImap4Client *imapClient;
imapClient = [[self imap4Connection] client];
if (![imapClient delimiter])
[imapClient list: @"INBOX" pattern: @""];
return [imapClient delimiter];
}
- (BOOL) supportsQuotas
{
return [self hasCapability: @"quota"];

View File

@ -44,7 +44,6 @@
- (NSString *) imapCASServiceName;
- (NSString *) imapAclStyle;
- (NSString *) imapAclGroupIdPrefix;
- (NSString *) imapFolderSeparator;
- (BOOL) imapAclConformsToIMAPExt;
- (BOOL) forceExternalLoginWithEmail;
- (BOOL) externalAvatarsEnabled;

View File

@ -137,11 +137,6 @@
return [self stringForKey: @"NGImap4ConnectionGroupIdPrefix"];
}
- (NSString *) imapFolderSeparator
{
return [self stringForKey: @"NGImap4ConnectionStringSeparator"];
}
#warning this should be determined from the capabilities
/* http://www.tools.ietf.org/wg/imapext/draft-ietf-imapext-acl/ */
- (BOOL) imapAclConformsToIMAPExt

View File

@ -446,6 +446,7 @@ static NSString *sieveScriptName = @"sogo";
}
- (NSString *) _extractSieveAction: (NSDictionary *) action
delimiter: (NSString *) delimiter
{
NSString *sieveAction, *method, *requirement, *argument, *flag, *mailbox;
NSDictionary *mailLabels;
@ -488,7 +489,7 @@ static NSString *sieveScriptName = @"sogo";
dd = [user domainDefaults];
mailbox
= [[argument componentsSeparatedByString: @"/"]
componentsJoinedByString: [dd imapFolderSeparator]];
componentsJoinedByString: delimiter];
sieveAction = [NSString stringWithFormat: @"%@ %@",
method, [mailbox asSieveQuotedString]];
}
@ -520,6 +521,7 @@ static NSString *sieveScriptName = @"sogo";
}
- (NSArray *) _extractSieveActions: (NSArray *) actions
delimiter: (NSString *) delimiter
{
NSMutableArray *sieveActions;
NSString *sieveAction;
@ -529,7 +531,8 @@ static NSString *sieveScriptName = @"sogo";
sieveActions = [NSMutableArray arrayWithCapacity: max];
for (count = 0; !scriptError && count < max; count++)
{
sieveAction = [self _extractSieveAction: [actions objectAtIndex: count]];
sieveAction = [self _extractSieveAction: [actions objectAtIndex: count]
delimiter: delimiter];
if (!scriptError)
[sieveActions addObject: sieveAction];
}
@ -538,6 +541,7 @@ static NSString *sieveScriptName = @"sogo";
}
- (NSString *) _convertScriptToSieve: (NSDictionary *) newScript
delimiter: (NSString *) delimiter
{
NSMutableString *sieveText;
NSString *match;
@ -565,7 +569,8 @@ static NSString *sieveScriptName = @"sogo";
else
scriptError = [NSString stringWithFormat: @"Bad test: %@", match];
}
sieveActions = [self _extractSieveActions: [newScript objectForKey: @"actions"]];
sieveActions = [self _extractSieveActions: [newScript objectForKey: @"actions"]
delimiter: delimiter];
if ([sieveActions count])
[sieveText appendFormat: @" %@;\r\n",
[sieveActions componentsJoinedByString: @";\r\n "]];
@ -577,6 +582,7 @@ static NSString *sieveScriptName = @"sogo";
}
- (NSString *) sieveScriptWithRequirements: (NSMutableArray *) newRequirements
delimiter: (NSString *) delimiter
{
NSMutableString *sieveScript;
NSString *sieveText;
@ -599,7 +605,8 @@ static NSString *sieveScriptName = @"sogo";
currentScript = [scripts objectAtIndex: count];
if ([[currentScript objectForKey: @"active"] boolValue])
{
sieveText = [self _convertScriptToSieve: currentScript];
sieveText = [self _convertScriptToSieve: currentScript
delimiter: delimiter];
[sieveScript appendString: sieveText];
}
}
@ -815,7 +822,8 @@ static NSString *sieveScriptName = @"sogo";
script = [NSMutableString string];
// We first handle filters
filterScript = [self sieveScriptWithRequirements: req];
filterScript = [self sieveScriptWithRequirements: req
delimiter: [theAccount imap4Separator]];
if (filterScript)
{
if ([filterScript length])