mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-19 03:49:28 +00:00
(fix) now cache heartbeat and folders during EAS ping ops (fixes #3606)
This commit is contained in:
@@ -2082,19 +2082,37 @@ void handle_terminate(int signum)
|
||||
|
||||
if (![allCollections count])
|
||||
{
|
||||
// We received an empty Ping request. Return status '3' to ask client to resend the request with complete body.
|
||||
s = [NSMutableString string];
|
||||
[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
|
||||
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
|
||||
[s appendString: @"<Ping xmlns=\"Ping:\">"];
|
||||
[s appendString: @"<Status>3</Status>"];
|
||||
[s appendString: @"</Ping>"];
|
||||
heartbeatInterval = [[[o properties] objectForKey: @"PingHeartbeatInterval"] intValue];
|
||||
|
||||
d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml];
|
||||
if (debugOn)
|
||||
[self logWithFormat: @"EAS - Empty Ping request - using cached HeatbeatInterval (%d)", heartbeatInterval];
|
||||
|
||||
[theResponse setContent: d];
|
||||
if (heartbeatInterval > defaultInterval || heartbeatInterval == 0)
|
||||
{
|
||||
heartbeatInterval = defaultInterval;
|
||||
status = 5;
|
||||
}
|
||||
|
||||
return;
|
||||
allFoldersID = [[o properties] objectForKey: @"PingCachedFolders"];
|
||||
if (![allFoldersID count])
|
||||
{
|
||||
// We received an empty Ping request. Return status '3' to ask client to resend the request with complete body.
|
||||
s = [NSMutableString string];
|
||||
[s appendString: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
|
||||
[s appendString: @"<!DOCTYPE ActiveSync PUBLIC \"-//MICROSOFT//DTD ActiveSync//EN\" \"http://www.microsoft.com/\">"];
|
||||
[s appendString: @"<Ping xmlns=\"Ping:\">"];
|
||||
[s appendString: @"<Status>3</Status>"];
|
||||
[s appendString: @"</Ping>"];
|
||||
|
||||
d = [[s dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml];
|
||||
|
||||
[theResponse setContent: d];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (debugOn)
|
||||
[self logWithFormat: @"EAS - Empty Ping request - using cached folders %@", allFoldersID];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2104,6 +2122,16 @@ void handle_terminate(int signum)
|
||||
collectionId = [[(id) [aCollection getElementsByTagName: @"Id"] lastObject] textValue];
|
||||
[allFoldersID addObject: collectionId];
|
||||
}
|
||||
|
||||
if (![allFoldersID isEqualToArray: [[o properties] objectForKey: @"PingCachedFolders"]])
|
||||
{
|
||||
if (debugOn)
|
||||
[self logWithFormat: @"EAS - Ping - Save folderlist to cache (HeartbeatInterval: %d) (%@)", heartbeatInterval, allFoldersID];
|
||||
|
||||
[[o properties] setObject: [NSNumber numberWithInteger: heartbeatInterval] forKey: @"PingHeartbeatInterval"];
|
||||
[[o properties] setObject: allFoldersID forKey: @"PingCachedFolders"];
|
||||
[o save];
|
||||
}
|
||||
}
|
||||
|
||||
foldersWithChanges = [NSMutableArray array];
|
||||
|
||||
Reference in New Issue
Block a user