mirror of
https://github.com/moparisthebest/davmail
synced 2024-11-11 20:05:03 -05:00
OSX: crazy workaround from Dan Foody to fix attendee search on OSX Snow Leopard
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@717 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
e0d80701a3
commit
f6649d7217
@ -1924,6 +1924,8 @@ public class ExchangeSession {
|
||||
} else if (organizer != null && line.startsWith("ATTENDEE") && line.contains(organizer)) {
|
||||
// Ignore organizer as attendee
|
||||
continue;
|
||||
} else if (!fromServer && line.startsWith("ATTENDEE")) {
|
||||
line = replaceIcal4Principal(line);
|
||||
}
|
||||
|
||||
result.writeLine(line);
|
||||
@ -1938,6 +1940,20 @@ public class ExchangeSession {
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace iCal4 (Snow Leopard) principal paths with mailto expression
|
||||
*
|
||||
* @param value attendee value or ics line
|
||||
* @return fixed value
|
||||
*/
|
||||
protected String replaceIcal4Principal(String value) {
|
||||
if (value.contains("/principals/__uuids__/")) {
|
||||
return value.replaceAll("/principals/__uuids__/([^/]*)__AT__([^/]*)/", "mailto:$1@$2");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
protected String fixTimezoneId(String line, String validTimezoneId) {
|
||||
int startIndex = line.indexOf("TZID=");
|
||||
int endIndex = line.indexOf(':', startIndex + 5);
|
||||
@ -2113,6 +2129,7 @@ public class ExchangeSession {
|
||||
if (colonIndex >= 0) {
|
||||
value = value.substring(colonIndex + 1);
|
||||
}
|
||||
value = replaceIcal4Principal(value);
|
||||
if ("ORGANIZER".equals(key)) {
|
||||
organizer = value;
|
||||
// exclude current user and invalid values from recipients
|
||||
@ -2793,7 +2810,7 @@ public class ExchangeSession {
|
||||
* @throws IOException on error
|
||||
*/
|
||||
public FreeBusy getFreebusy(String attendee, String startDateValue, String endDateValue) throws IOException {
|
||||
|
||||
attendee = replaceIcal4Principal(attendee);
|
||||
if (attendee.startsWith("mailto:")) {
|
||||
attendee = attendee.substring("mailto:".length());
|
||||
}
|
||||
|
@ -76,7 +76,6 @@ public class LdapConnection extends AbstractConnection {
|
||||
static final HashMap<String, String> ATTRIBUTE_MAP = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
ATTRIBUTE_MAP.put("apple-generateduid", "AN");
|
||||
ATTRIBUTE_MAP.put("uid", "AN");
|
||||
ATTRIBUTE_MAP.put("mail", "EM");
|
||||
ATTRIBUTE_MAP.put("cn", "DN");
|
||||
@ -170,7 +169,7 @@ public class LdapConnection extends AbstractConnection {
|
||||
"<string>urn:uuid:%(guid)s</string>" +
|
||||
"</array>" +
|
||||
"<key>principalPath</key>" +
|
||||
"<string>/principals/users/%(email)s/</string>" +
|
||||
"<string>/principals/__uuids__/%(guid)s/</string>" +
|
||||
"</dict>" +
|
||||
"</dict>" +
|
||||
"</dict>" +
|
||||
@ -787,10 +786,6 @@ public class LdapConnection extends AbstractConnection {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// iCal: copy uid to apple-generateduid
|
||||
if (returningAttributes.contains("apple-generateduid") && person.get("uid") != null) {
|
||||
person.put("apple-generateduid", person.get("uid"));
|
||||
}
|
||||
// convert Contact entries
|
||||
for (Map.Entry<String, String> entry : person.entrySet()) {
|
||||
String contactAttribute = entry.getKey();
|
||||
@ -808,10 +803,12 @@ public class LdapConnection extends AbstractConnection {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: fix for iCal4/iCal3
|
||||
// iCal: copy cn to sn
|
||||
if (iCalSearch && ldapPerson.get("cn") != null && returningAttributes.contains("sn")) {
|
||||
ldapPerson.put("sn", ldapPerson.get("cn"));
|
||||
}
|
||||
//if (iCalSearch && ldapPerson.get("cn") != null && returningAttributes.contains("sn")) {
|
||||
// ldapPerson.put("sn", ldapPerson.get("cn"));
|
||||
//}
|
||||
|
||||
|
||||
// Process all attributes which have static mappings
|
||||
@ -828,15 +825,29 @@ public class LdapConnection extends AbstractConnection {
|
||||
if (needObjectClasses) {
|
||||
ldapPerson.put("objectClass", PERSON_OBJECT_CLASSES);
|
||||
}
|
||||
|
||||
// iCal: copy email to apple-generateduid, encode @
|
||||
if (returnAllAttributes || returningAttributes.contains("apple-generateduid")) {
|
||||
String mail = (String) ldapPerson.get("mail");
|
||||
if (mail != null) {
|
||||
ldapPerson.put("apple-generateduid", mail.replaceAll("@", "__AT__"));
|
||||
} else {
|
||||
// failover, should not happen
|
||||
ldapPerson.put("apple-generateduid", ldapPerson.get("uid"));
|
||||
}
|
||||
}
|
||||
|
||||
// iCal: replace current user alias with login name
|
||||
if (session.getAlias().equals(ldapPerson.get("uid"))) {
|
||||
if (returningAttributes.contains("uidnumber")) {
|
||||
ldapPerson.put("uidnumber", userName);
|
||||
}
|
||||
if (returningAttributes.contains("apple-generateduid")) {
|
||||
// TODO: check if this breaks iCal3
|
||||
/* if (returningAttributes.contains("apple-generateduid")) {
|
||||
ldapPerson.put("apple-generateduid", userName);
|
||||
ldapPerson.put("uid", userName);
|
||||
}
|
||||
*/
|
||||
}
|
||||
DavGatewayTray.debug(new BundleMessage("LOG_LDAP_REQ_SEARCH_SEND_PERSON", currentMessageId, ldapPerson.get("uid"), baseContext, ldapPerson));
|
||||
sendEntry(currentMessageId, "uid=" + ldapPerson.get("uid") + baseContext, ldapPerson);
|
||||
|
Loading…
Reference in New Issue
Block a user