diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index 3361f2d3b..6bdb6f471 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -2759,7 +2759,7 @@ void handle_eas_terminate(int signum) inResponse: (WOResponse *) theResponse { SOGoContactSourceFolder *currentFolder; - NSArray *allKeys, *allContacts, *mails; + NSArray *allKeys, *allContacts, *mails, *a; NSDictionary *systemSources, *contact; SOGoContactFolders *contactFolders; NSString *current_mail, *query; @@ -2769,7 +2769,10 @@ void handle_eas_terminate(int signum) NSData *d; id o; - int i, j, total; + int i, j, t, v, total, minResult, maxResult, maxSize, maxPictures; + BOOL withPhoto; + + withPhoto = NO; query = [[(id)[theDocumentElement getElementsByTagName: @"Query"] lastObject] textValue]; @@ -2778,6 +2781,33 @@ void handle_eas_terminate(int signum) systemSources = [contactFolders systemSources]; allKeys = [systemSources allKeys]; + // We check for the maximum number of results to return. + a = [[[(id)[theDocumentElement getElementsByTagName: @"Range"] lastObject] textValue] componentsSeparatedByString: @"-"]; + minResult = [[a objectAtIndex: 0] intValue]; + maxResult = [[a objectAtIndex: 1] intValue]; + + if (maxResult == 0) + maxResult = 99; + + if ((o = [(id)[[(id)[theDocumentElement getElementsByTagName: @"Options"] lastObject] getElementsByTagName: @"Picture"] lastObject])) + { + withPhoto = YES; + + // We check for a MaxSize, default to 102400. + maxSize = [[[(id)[o getElementsByTagName: @"MaxSize"] lastObject] textValue] intValue]; + + // We check if we must overwrite the maxSize with a system preference. This can be useful + // if we don't want to have pictures in the response. + if ((v = [[SOGoSystemDefaults sharedSystemDefaults] maximumPictureSize])) + maxSize = v; + + // We check for a MaxPictures, default to 99. + maxPictures = [[[(id)[o getElementsByTagName: @"MaxPictures"] lastObject] textValue] intValue]; + + if (maxPictures == 0) + maxPictures = 99; + } + s = [NSMutableString string]; [s appendString: @""]; @@ -2799,7 +2829,7 @@ void handle_eas_terminate(int signum) ordering: NSOrderedAscending inDomain: [[context activeUser] domain]]; - for (j = 0; j < [allContacts count]; j++) + for (j = minResult; (j < [allContacts count] && j < maxResult) ; j++) { contact = [allContacts objectAtIndex: j]; @@ -2817,9 +2847,9 @@ void handle_eas_terminate(int signum) else mails = [NSArray arrayWithObjects: o ? o : @"", nil]; - for (total = 0; total < [mails count]; total++) + for (t = 0; t < [mails count]; t++) { - current_mail = [mails objectAtIndex: total]; + current_mail = [mails objectAtIndex: t]; [s appendString: @""]; [s appendString: @""]; @@ -2837,7 +2867,7 @@ void handle_eas_terminate(int signum) [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; if ([current_mail length] > 0) - [s appendFormat: @"%@", current_mail]; + [s appendFormat: @"%@", [current_mail activeSyncRepresentationInContext: context]]; if ((o = [contact objectForKey: @"telephonenumber"])) [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; @@ -2850,9 +2880,27 @@ void handle_eas_terminate(int signum) if ((o = [contact objectForKey: @"o"])) [s appendFormat: @"%@", [o activeSyncRepresentationInContext: context]]; - + + if ([[context objectForKey: @"ASProtocolVersion"] floatValue] >= 14.1 && withPhoto) + { + o = [contact objectForKey: @"photo"]; + if (o && [o length] <= maxSize && total < maxPictures) + { + [s appendString: @"1"]; + [s appendString: [o activeSyncRepresentationInContext: context]]; + [s appendString: @""]; + } + else if (!o) + [s appendString: @"173"]; + else if ([o length] > maxSize) + [s appendString: @"174"]; + else if (total >= maxPictures) + [s appendString: @"175"]; + } + [s appendString: @""]; [s appendString: @""]; + total++; } } } diff --git a/Documentation/SOGoInstallationGuide.asciidoc b/Documentation/SOGoInstallationGuide.asciidoc index 90306048e..0db3e7d92 100644 --- a/Documentation/SOGoInstallationGuide.asciidoc +++ b/Documentation/SOGoInstallationGuide.asciidoc @@ -2726,6 +2726,12 @@ have unexpected behaviour with various ActiveSync clients. EAS command. Defaults to `NO`, which means no logging is performed. + +|S |SOGoMaximumPictureSize +|Parameter used to overwrite the maximum number of bytes returned in the picture +for EAS Search operations in the GAL. + +If not set, it defaults to `102400` bytes, or 100 KB. |======================================================================= Please be aware of the following limitations: diff --git a/SoObjects/SOGo/SOGoSystemDefaults.h b/SoObjects/SOGo/SOGoSystemDefaults.h index b705c61c1..d97026853 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.h +++ b/SoObjects/SOGo/SOGoSystemDefaults.h @@ -111,6 +111,7 @@ - (int) internalSyncInterval; - (int) maximumSyncWindowSize; - (int) maximumSyncResponseSize; +- (int) maximumPictureSize; @end diff --git a/SoObjects/SOGo/SOGoSystemDefaults.m b/SoObjects/SOGo/SOGoSystemDefaults.m index b197238cb..7e2908d41 100644 --- a/SoObjects/SOGo/SOGoSystemDefaults.m +++ b/SoObjects/SOGo/SOGoSystemDefaults.m @@ -712,4 +712,19 @@ _injectConfigurationFromFile (NSMutableDictionary *defaultsDict, return v; } +// +// See https://msdn.microsoft.com/en-us/library/gg672032(v=exchg.80).aspx +// +- (int) maximumPictureSize +{ + int v; + + v = [self integerForKey: @"SOGoMaximumPictureSize"]; + + if (!v) + v = 102400; + + return v; +} + @end