mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-07-05 16:35:10 +00:00
(feat) added photo support in GAL search ops
This commit is contained in:
@@ -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: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>"];
|
||||
@@ -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: @"<Result xmlns=\"Search:\">"];
|
||||
[s appendString: @"<Properties>"];
|
||||
@@ -2837,7 +2867,7 @@ void handle_eas_terminate(int signum)
|
||||
[s appendFormat: @"<LastName xmlns=\"Gal:\">%@</LastName>", [o activeSyncRepresentationInContext: context]];
|
||||
|
||||
if ([current_mail length] > 0)
|
||||
[s appendFormat: @"<EmailAddress xmlns=\"Gal:\">%@</EmailAddress>", current_mail];
|
||||
[s appendFormat: @"<EmailAddress xmlns=\"Gal:\">%@</EmailAddress>", [current_mail activeSyncRepresentationInContext: context]];
|
||||
|
||||
if ((o = [contact objectForKey: @"telephonenumber"]))
|
||||
[s appendFormat: @"<Phone xmlns=\"Gal:\">%@</Phone>", [o activeSyncRepresentationInContext: context]];
|
||||
@@ -2850,9 +2880,27 @@ void handle_eas_terminate(int signum)
|
||||
|
||||
if ((o = [contact objectForKey: @"o"]))
|
||||
[s appendFormat: @"<Company xmlns=\"Gal:\">%@</Company>", [o activeSyncRepresentationInContext: context]];
|
||||
|
||||
|
||||
if ([[context objectForKey: @"ASProtocolVersion"] floatValue] >= 14.1 && withPhoto)
|
||||
{
|
||||
o = [contact objectForKey: @"photo"];
|
||||
if (o && [o length] <= maxSize && total < maxPictures)
|
||||
{
|
||||
[s appendString: @"<Picture xmlns=\"Gal:\"><Status>1</Status><Data>"];
|
||||
[s appendString: [o activeSyncRepresentationInContext: context]];
|
||||
[s appendString: @"</Data></Picture>"];
|
||||
}
|
||||
else if (!o)
|
||||
[s appendString: @"<Picture xmlns=\"Gal:\"><Status>173</Status></Picture>"];
|
||||
else if ([o length] > maxSize)
|
||||
[s appendString: @"<Picture xmlns=\"Gal:\"><Status>174</Status></Picture>"];
|
||||
else if (total >= maxPictures)
|
||||
[s appendString: @"<Picture xmlns=\"Gal:\"><Status>175</Status></Picture>"];
|
||||
}
|
||||
|
||||
[s appendString: @"</Properties>"];
|
||||
[s appendString: @"</Result>"];
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
- (int) internalSyncInterval;
|
||||
- (int) maximumSyncWindowSize;
|
||||
- (int) maximumSyncResponseSize;
|
||||
- (int) maximumPictureSize;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user