Skip to content

Commit

Permalink
(fix) now dynamically detect and use the IMAP separator (fixes #1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
extrafu committed Sep 4, 2019
1 parent 936f7dd commit 3187bca
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
6 changes: 0 additions & 6 deletions Documentation/SOGoInstallationGuide.asciidoc
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions SoObjects/Mailer/SOGoMailAccount.h
Expand Up @@ -75,6 +75,7 @@ typedef enum {

/* capabilities */
- (BOOL) hasCapability: (NSString *) capability;
- (NSString *) imap4Separator;
- (BOOL) supportsQuotas;
- (BOOL) supportsQResync;

Expand Down
12 changes: 12 additions & 0 deletions SoObjects/Mailer/SOGoMailAccount.m
Expand Up @@ -257,6 +257,18 @@ - (BOOL) hasCapability: (NSString *) capability
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"];
Expand Down
1 change: 0 additions & 1 deletion SoObjects/SOGo/SOGoDomainDefaults.h
Expand Up @@ -44,7 +44,6 @@
- (NSString *) imapCASServiceName;
- (NSString *) imapAclStyle;
- (NSString *) imapAclGroupIdPrefix;
- (NSString *) imapFolderSeparator;
- (BOOL) imapAclConformsToIMAPExt;
- (BOOL) forceExternalLoginWithEmail;
- (BOOL) externalAvatarsEnabled;
Expand Down
5 changes: 0 additions & 5 deletions SoObjects/SOGo/SOGoDomainDefaults.m
Expand Up @@ -137,11 +137,6 @@ - (NSString *) imapAclGroupIdPrefix
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
Expand Down
18 changes: 13 additions & 5 deletions SoObjects/SOGo/SOGoSieveManager.m
Expand Up @@ -446,6 +446,7 @@ - (NSArray *) _extractSieveRules: (NSArray *) rules
}

- (NSString *) _extractSieveAction: (NSDictionary *) action
delimiter: (NSString *) delimiter
{
NSString *sieveAction, *method, *requirement, *argument, *flag, *mailbox;
NSDictionary *mailLabels;
Expand Down Expand Up @@ -488,7 +489,7 @@ - (NSString *) _extractSieveAction: (NSDictionary *) action
dd = [user domainDefaults];
mailbox
= [[argument componentsSeparatedByString: @"/"]
componentsJoinedByString: [dd imapFolderSeparator]];
componentsJoinedByString: delimiter];
sieveAction = [NSString stringWithFormat: @"%@ %@",
method, [mailbox asSieveQuotedString]];
}
Expand Down Expand Up @@ -520,6 +521,7 @@ - (NSString *) _extractSieveAction: (NSDictionary *) action
}

- (NSArray *) _extractSieveActions: (NSArray *) actions
delimiter: (NSString *) delimiter
{
NSMutableArray *sieveActions;
NSString *sieveAction;
Expand All @@ -529,7 +531,8 @@ - (NSArray *) _extractSieveActions: (NSArray *) actions
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];
}
Expand All @@ -538,6 +541,7 @@ - (NSArray *) _extractSieveActions: (NSArray *) actions
}

- (NSString *) _convertScriptToSieve: (NSDictionary *) newScript
delimiter: (NSString *) delimiter
{
NSMutableString *sieveText;
NSString *match;
Expand Down Expand Up @@ -565,7 +569,8 @@ - (NSString *) _convertScriptToSieve: (NSDictionary *) newScript
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 "]];
Expand All @@ -577,6 +582,7 @@ - (NSString *) _convertScriptToSieve: (NSDictionary *) newScript
}

- (NSString *) sieveScriptWithRequirements: (NSMutableArray *) newRequirements
delimiter: (NSString *) delimiter
{
NSMutableString *sieveScript;
NSString *sieveText;
Expand All @@ -599,7 +605,8 @@ - (NSString *) sieveScriptWithRequirements: (NSMutableArray *) newRequirements
currentScript = [scripts objectAtIndex: count];
if ([[currentScript objectForKey: @"active"] boolValue])
{
sieveText = [self _convertScriptToSieve: currentScript];
sieveText = [self _convertScriptToSieve: currentScript
delimiter: delimiter];
[sieveScript appendString: sieveText];
}
}
Expand Down Expand Up @@ -815,7 +822,8 @@ - (BOOL) updateFiltersForAccount: (SOGoMailAccount *) theAccount
script = [NSMutableString string];

// We first handle filters
filterScript = [self sieveScriptWithRequirements: req];
filterScript = [self sieveScriptWithRequirements: req
delimiter: [theAccount imap4Separator]];
if (filterScript)
{
if ([filterScript length])
Expand Down

0 comments on commit 3187bca

Please sign in to comment.