1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-11-12 04:15:08 -05:00

LDAP: iCal autocomplete fix from Dan Foody

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@446 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-03-17 07:43:37 +00:00
parent 56befe6e77
commit e319712ce9

View File

@ -69,6 +69,7 @@ public class LdapConnection extends AbstractConnection {
static final HashMap<String, String> STATIC_ATTRIBUTE_MAP = new HashMap<String, String>(); static final HashMap<String, String> STATIC_ATTRIBUTE_MAP = new HashMap<String, String>();
static final String COMPUTER_GUID = "52486C30-F0AB-48E3-9C37-37E9B28CDD7B"; static final String COMPUTER_GUID = "52486C30-F0AB-48E3-9C37-37E9B28CDD7B";
static final String VIRTUALHOST_GUID = "D6DD8A10-1098-11DE-8C30-0800200C9A66";
static final String SERVICEINFO = static final String SERVICEINFO =
"<?xml version='1.0' encoding='UTF-8'?>" + "<?xml version='1.0' encoding='UTF-8'?>" +
@ -81,7 +82,7 @@ public class LdapConnection extends AbstractConnection {
"</array>" + "</array>" +
"<key>com.apple.macosxserver.virtualhosts</key>" + "<key>com.apple.macosxserver.virtualhosts</key>" +
"<dict>" + "<dict>" +
"<key>" + COMPUTER_GUID + "</key>" + "<key>"+VIRTUALHOST_GUID+"</key>" +
"<dict>" + "<dict>" +
"<key>hostDetails</key>" + "<key>hostDetails</key>" +
"<dict>" + "<dict>" +
@ -131,7 +132,7 @@ public class LdapConnection extends AbstractConnection {
"</plist>"; "</plist>";
static { static {
STATIC_ATTRIBUTE_MAP.put("apple-serviceslocator", COMPUTER_GUID + ":4607DAE0-9FEA-46F1-B0BD-EC212D780CEF:calendar"); STATIC_ATTRIBUTE_MAP.put("apple-serviceslocator", COMPUTER_GUID+":"+VIRTUALHOST_GUID+":calendar");
} }
static final HashSet<String> EXTENDED_ATTRIBUTES = new HashSet<String>(); static final HashSet<String> EXTENDED_ATTRIBUTES = new HashSet<String>();
@ -706,19 +707,13 @@ public class LdapConnection extends AbstractConnection {
} }
protected String hostName() { protected String hostName() {
if (Settings.getBooleanProperty("davmail.allowRemote")) { try {
try { return java.net.InetAddress.getLocalHost().getHostName();
return java.net.InetAddress.getLocalHost().getHostName(); } catch (java.net.UnknownHostException ex) {
} catch (java.net.UnknownHostException ex) { DavGatewayTray.debug("Couldn't get hostname");
DavGatewayTray.debug("Couldn't get hostname");
}
} }
// When not allowing remote, we must return 'localhost' as the hostname. // If we can't get the hostname, just return localhost.
// NOTE: When allowRemote is true, then the URL used to connect to DavMail
// must have the hostname match the name returned by 'hostname'.
// When allowRemote is false, then the URL used to connect to DavMail
// must have the hostname be 'localhost'
return "localhost"; return "localhost";
} }
@ -731,8 +726,6 @@ public class LdapConnection extends AbstractConnection {
* @throws IOException on error * @throws IOException on error
*/ */
protected void sendComputerContext(int currentMessageId, Set<String> returningAttributes) throws IOException { protected void sendComputerContext(int currentMessageId, Set<String> returningAttributes) throws IOException {
DavGatewayTray.debug("Sending computer context");
String customServiceInfo = SERVICEINFO.replaceAll("localhost", hostName()); String customServiceInfo = SERVICEINFO.replaceAll("localhost", hostName());
customServiceInfo = customServiceInfo.replaceAll("9999", Settings.getProperty("davmail.caldavPort")); customServiceInfo = customServiceInfo.replaceAll("9999", Settings.getProperty("davmail.caldavPort"));
@ -746,7 +739,10 @@ public class LdapConnection extends AbstractConnection {
addIf(attributes, returningAttributes, "apple-serviceslocator", "::anyService"); addIf(attributes, returningAttributes, "apple-serviceslocator", "::anyService");
addIf(attributes, returningAttributes, "cn", hostName()); addIf(attributes, returningAttributes, "cn", hostName());
sendEntry(currentMessageId, "cn=" + hostName() + ", " + COMPUTER_CONTEXT, attributes); String dn = "cn=" + hostName() + ", " + COMPUTER_CONTEXT;
DavGatewayTray.debug("Sending computer context " + dn);
sendEntry(currentMessageId, dn, attributes);
} }
/** /**
@ -900,4 +896,3 @@ public class LdapConnection extends AbstractConnection {
} }
} }