1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-11-14 05:15:04 -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:
mguessan 2009-09-14 21:16:15 +00:00
parent e0d80701a3
commit f6649d7217
2 changed files with 40 additions and 12 deletions

View File

@ -1924,6 +1924,8 @@ public class ExchangeSession {
} else if (organizer != null && line.startsWith("ATTENDEE") && line.contains(organizer)) { } else if (organizer != null && line.startsWith("ATTENDEE") && line.contains(organizer)) {
// Ignore organizer as attendee // Ignore organizer as attendee
continue; continue;
} else if (!fromServer && line.startsWith("ATTENDEE")) {
line = replaceIcal4Principal(line);
} }
result.writeLine(line); result.writeLine(line);
@ -1938,6 +1940,20 @@ public class ExchangeSession {
return result.toString(); 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) { protected String fixTimezoneId(String line, String validTimezoneId) {
int startIndex = line.indexOf("TZID="); int startIndex = line.indexOf("TZID=");
int endIndex = line.indexOf(':', startIndex + 5); int endIndex = line.indexOf(':', startIndex + 5);
@ -2113,6 +2129,7 @@ public class ExchangeSession {
if (colonIndex >= 0) { if (colonIndex >= 0) {
value = value.substring(colonIndex + 1); value = value.substring(colonIndex + 1);
} }
value = replaceIcal4Principal(value);
if ("ORGANIZER".equals(key)) { if ("ORGANIZER".equals(key)) {
organizer = value; organizer = value;
// exclude current user and invalid values from recipients // exclude current user and invalid values from recipients
@ -2793,7 +2810,7 @@ public class ExchangeSession {
* @throws IOException on error * @throws IOException on error
*/ */
public FreeBusy getFreebusy(String attendee, String startDateValue, String endDateValue) throws IOException { public FreeBusy getFreebusy(String attendee, String startDateValue, String endDateValue) throws IOException {
attendee = replaceIcal4Principal(attendee);
if (attendee.startsWith("mailto:")) { if (attendee.startsWith("mailto:")) {
attendee = attendee.substring("mailto:".length()); attendee = attendee.substring("mailto:".length());
} }

View File

@ -76,7 +76,6 @@ public class LdapConnection extends AbstractConnection {
static final HashMap<String, String> ATTRIBUTE_MAP = new HashMap<String, String>(); static final HashMap<String, String> ATTRIBUTE_MAP = new HashMap<String, String>();
static { static {
ATTRIBUTE_MAP.put("apple-generateduid", "AN");
ATTRIBUTE_MAP.put("uid", "AN"); ATTRIBUTE_MAP.put("uid", "AN");
ATTRIBUTE_MAP.put("mail", "EM"); ATTRIBUTE_MAP.put("mail", "EM");
ATTRIBUTE_MAP.put("cn", "DN"); ATTRIBUTE_MAP.put("cn", "DN");
@ -170,7 +169,7 @@ public class LdapConnection extends AbstractConnection {
"<string>urn:uuid:%(guid)s</string>" + "<string>urn:uuid:%(guid)s</string>" +
"</array>" + "</array>" +
"<key>principalPath</key>" + "<key>principalPath</key>" +
"<string>/principals/users/%(email)s/</string>" + "<string>/principals/__uuids__/%(guid)s/</string>" +
"</dict>" + "</dict>" +
"</dict>" + "</dict>" +
"</dict>" + "</dict>" +
@ -787,10 +786,6 @@ public class LdapConnection extends AbstractConnection {
} }
} }
} else { } 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 // convert Contact entries
for (Map.Entry<String, String> entry : person.entrySet()) { for (Map.Entry<String, String> entry : person.entrySet()) {
String contactAttribute = entry.getKey(); String contactAttribute = entry.getKey();
@ -808,10 +803,12 @@ public class LdapConnection extends AbstractConnection {
} }
} }
// TODO: fix for iCal4/iCal3
// iCal: copy cn to sn // iCal: copy cn to sn
if (iCalSearch && ldapPerson.get("cn") != null && returningAttributes.contains("sn")) { //if (iCalSearch && ldapPerson.get("cn") != null && returningAttributes.contains("sn")) {
ldapPerson.put("sn", ldapPerson.get("cn")); // ldapPerson.put("sn", ldapPerson.get("cn"));
} //}
// Process all attributes which have static mappings // Process all attributes which have static mappings
@ -828,15 +825,29 @@ public class LdapConnection extends AbstractConnection {
if (needObjectClasses) { if (needObjectClasses) {
ldapPerson.put("objectClass", PERSON_OBJECT_CLASSES); 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 // iCal: replace current user alias with login name
if (session.getAlias().equals(ldapPerson.get("uid"))) { if (session.getAlias().equals(ldapPerson.get("uid"))) {
if (returningAttributes.contains("uidnumber")) { if (returningAttributes.contains("uidnumber")) {
ldapPerson.put("uidnumber", userName); 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("apple-generateduid", userName);
ldapPerson.put("uid", userName); ldapPerson.put("uid", userName);
} }
*/
} }
DavGatewayTray.debug(new BundleMessage("LOG_LDAP_REQ_SEARCH_SEND_PERSON", currentMessageId, ldapPerson.get("uid"), baseContext, ldapPerson)); DavGatewayTray.debug(new BundleMessage("LOG_LDAP_REQ_SEARCH_SEND_PERSON", currentMessageId, ldapPerson.get("uid"), baseContext, ldapPerson));
sendEntry(currentMessageId, "uid=" + ldapPerson.get("uid") + baseContext, ldapPerson); sendEntry(currentMessageId, "uid=" + ldapPerson.get("uid") + baseContext, ldapPerson);