Merge pull request #100 from Zentyal/jag/recipient-from-client-call
mapistore: can use client data to get recipient address
This commit is contained in:
commit
c1b0fd53dc
|
@ -178,56 +178,100 @@ rtf2html (NSData *compressedRTF)
|
||||||
andColumns: (struct SPropTagArray *) columns
|
andColumns: (struct SPropTagArray *) columns
|
||||||
{
|
{
|
||||||
NSMutableDictionary *recipientProperties;
|
NSMutableDictionary *recipientProperties;
|
||||||
|
enum MAPITAGS prop_tag;
|
||||||
|
char *displayName = NULL;
|
||||||
|
char *email = NULL;
|
||||||
|
enum MAPI_OBJTYPE object_type = 0;
|
||||||
|
char *smtpAddress = NULL;
|
||||||
SOGoUser *recipientUser;
|
SOGoUser *recipientUser;
|
||||||
NSUInteger count;
|
NSUInteger count;
|
||||||
|
NSString *recipientEmail = nil;
|
||||||
|
NSString *recipientFullName = nil;
|
||||||
id value;
|
id value;
|
||||||
|
|
||||||
recipientProperties = [NSMutableDictionary dictionaryWithCapacity: columns->cValues + 2];
|
recipientProperties = [NSMutableDictionary dictionaryWithCapacity: columns->cValues + 2];
|
||||||
|
|
||||||
|
for (count = 0; count < columns->cValues; count++)
|
||||||
|
{
|
||||||
|
prop_tag = columns->aulPropTag[count];
|
||||||
|
switch(prop_tag) {
|
||||||
|
case PidTagDisplayName:
|
||||||
|
displayName = recipient->data[count];
|
||||||
|
break;
|
||||||
|
case PidTagEmailAddress:
|
||||||
|
email = recipient->data[count];
|
||||||
|
break;
|
||||||
|
case PidTagObjectType:
|
||||||
|
object_type = *((uint8_t*) recipient->data[count]);
|
||||||
|
break;
|
||||||
|
case PidTagSmtpAddress:
|
||||||
|
smtpAddress = recipient->data[count];
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (recipient->data[count])
|
||||||
|
{
|
||||||
|
value = NSObjectFromValuePointer (prop_tag,
|
||||||
|
recipient->data[count]);
|
||||||
|
if (value)
|
||||||
|
[recipientProperties setObject: value
|
||||||
|
forKey: MAPIPropertyKey (prop_tag)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (recipient->username)
|
if (recipient->username)
|
||||||
{
|
{
|
||||||
value = [NSString stringWithUTF8String: recipient->username];
|
value = [NSString stringWithUTF8String: recipient->username];
|
||||||
[recipientProperties setObject: value forKey: @"x500dn"];
|
[recipientProperties setObject: value forKey: @"x500dn"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (object_type == MAPI_MAILUSER && recipient->username)
|
||||||
|
{
|
||||||
|
/* values from user object have priority uppon the data passed for the client */
|
||||||
recipientUser = [SOGoUser userWithLogin: [value lowercaseString]];
|
recipientUser = [SOGoUser userWithLogin: [value lowercaseString]];
|
||||||
if (recipientUser)
|
if (recipientUser)
|
||||||
{
|
{
|
||||||
value = [recipientUser cn];
|
value = [recipientUser cn];
|
||||||
if ([value length] > 0)
|
if ([value length] > 0)
|
||||||
[recipientProperties setObject: value forKey: @"fullName"];
|
recipientFullName = value;
|
||||||
|
|
||||||
value = [[recipientUser allEmails] objectAtIndex: 0];
|
value = [[recipientUser allEmails] objectAtIndex: 0];
|
||||||
if ([value length] > 0)
|
if ([value length] > 0)
|
||||||
[recipientProperties setObject: value forKey: @"email"];
|
recipientEmail = value;
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (recipient->data[0])
|
|
||||||
{
|
|
||||||
value = [NSString stringWithUTF8String: recipient->data[0]];
|
|
||||||
if ([value length] > 0)
|
|
||||||
[recipientProperties setObject: value forKey: @"fullName"];
|
|
||||||
}
|
|
||||||
if (recipient->data[1])
|
|
||||||
{
|
|
||||||
value = [NSString stringWithUTF8String: recipient->data[1]];
|
|
||||||
if ([value length] > 0)
|
|
||||||
[recipientProperties setObject: value forKey: @"email"];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (count = 0; count < columns->cValues; count++)
|
/* If we do not have values from the user object we try to get them from the parameters */
|
||||||
|
if (!recipientFullName && displayName)
|
||||||
{
|
{
|
||||||
if (recipient->data[count])
|
value = [NSString stringWithUTF8String: displayName];
|
||||||
{
|
if ([value length] > 0)
|
||||||
value = NSObjectFromValuePointer (columns->aulPropTag[count],
|
recipientFullName = value;
|
||||||
recipient->data[count]);
|
|
||||||
if (value)
|
|
||||||
[recipientProperties setObject: value
|
|
||||||
forKey: MAPIPropertyKey (columns->aulPropTag[count])];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!recipientEmail && email)
|
||||||
|
{
|
||||||
|
value = [NSString stringWithUTF8String: email];
|
||||||
|
if ([value length] > 0)
|
||||||
|
recipientEmail = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recipientEmail && smtpAddress)
|
||||||
|
{
|
||||||
|
value = [NSString stringWithUTF8String: smtpAddress];
|
||||||
|
if ([value length] > 0)
|
||||||
|
recipientEmail = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now we can set the properties if we have them */
|
||||||
|
if (recipientFullName)
|
||||||
|
[recipientProperties setObject: recipientFullName forKey: @"fullName"];
|
||||||
|
|
||||||
|
if (recipientEmail)
|
||||||
|
[recipientProperties setObject: recipientEmail forKey: @"email"];
|
||||||
|
|
||||||
return recipientProperties;
|
return recipientProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue