1
0
mirror of https://github.com/etesync/android synced 2024-12-23 23:18:46 +00:00

Resource detection fixes

* check TXT records for <service>._tcp.domain.tld instead of domain.tld
* duplicate log to ADB for successful resource detection
This commit is contained in:
Ricki Hirner 2015-10-19 01:04:59 +02:00
parent 94770fb0c8
commit 82f80fed1c
No known key found for this signature in database
GPG Key ID: C4A212CF0B2B4566
4 changed files with 34 additions and 13 deletions

View File

@ -45,6 +45,7 @@ import at.bitfire.dav4android.property.CurrentUserPrivilegeSet;
import at.bitfire.dav4android.property.DisplayName;
import at.bitfire.dav4android.property.ResourceType;
import at.bitfire.dav4android.property.SupportedCalendarComponentSet;
import at.bitfire.davdroid.Constants;
import at.bitfire.davdroid.HttpClient;
import lombok.NonNull;
@ -396,18 +397,18 @@ public class DavResourceFinder {
log.info("Found " + service + " service: fqdn=" + fqdn + ", port=" + port);
// look for TXT record too (for initial context path)
records = new Lookup(domain, Type.TXT).run();
if (records != null && records.length >= 1) {
TXTRecord txt = (TXTRecord)records[0];
for (String segment : (String[])txt.getStrings().toArray(new String[0]))
records = new Lookup(query, Type.TXT).run();
if (records != null)
for (Record record : records)
if (record instanceof TXTRecord)
for (String segment : (List<String>) ((TXTRecord) record).getStrings())
if (segment.startsWith("path=")) {
paths.add(segment.substring(5));
log.info("Found TXT record; initial context path=" + paths);
break;
}
}
// if there's TXT record if it it's wrong, try well-known
// if there's TXT record and if it it's wrong, try well-known
paths.add("/.well-known/" + service.name);
// if this fails, too, try "/"
paths.add("/");

View File

@ -21,12 +21,19 @@ import android.content.Intent;
import android.content.Loader;
import android.os.Bundle;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringReader;
import at.bitfire.davdroid.Constants;
import at.bitfire.davdroid.R;
import at.bitfire.davdroid.log.StringLogger;
import at.bitfire.davdroid.resource.DavResourceFinder;
import at.bitfire.davdroid.resource.LocalTaskList;
import at.bitfire.davdroid.resource.ServerInfo;
import at.bitfire.davdroid.ui.DebugInfoActivity;
import lombok.Cleanup;
public class QueryServerDialogFragment extends DialogFragment implements LoaderCallbacks<ServerInfo> {
public static final String KEY_SERVER_INFO = "server_info";
@ -154,7 +161,20 @@ public class QueryServerDialogFragment extends DialogFragment implements LoaderC
DavResourceFinder finder = new DavResourceFinder(logger, context, serverInfo);
finder.findResources();
// duplicate logs to ADB
String logs = logger.toString();
try {
@Cleanup BufferedReader logStream = new BufferedReader(new StringReader(logs));
Constants.log.info("Successful resource detection:");
String line;
while ((line = logStream.readLine()) != null)
Constants.log.debug(line);
} catch (IOException e) {
Constants.log.error("Couldn't read resource detection logs", e);
}
serverInfo.setLogs(logger.toString());
return serverInfo;
}
}

View File

@ -145,7 +145,7 @@ Dieses Programm ist freie Software. Sie können es unter den Bedingungen der GNU
<string name="setup_account_details">Konto-Details</string>
<string name="setup_account_name">Kontoname:</string>
<string name="setup_account_name_hint">Mein CalDAV/CardDAV-Konto</string>
<string name="setup_account_name_info">\"Verwenden Sie Ihre Email-Adresse als Kontoname, da Android den Kontonamen als ORGANIZER-Feld in Terminen benutzt. Sie können keine zwei Konten mit dem gleichen Namen anlegen.</string>
<string name="setup_account_name_info">Verwenden Sie Ihre Email-Adresse als Kontoname, da Android den Kontonamen als ORGANIZER-Feld in Terminen benutzt. Sie können keine zwei Konten mit dem gleichen Namen anlegen.</string>
<string name="setup_read_only">schreibgeschützt</string>
<!--sync errors and DebugInfoActivity-->
<string name="debug_info_title">Debug-Info</string>

View File

@ -178,7 +178,7 @@
<string name="setup_account_details">Account details</string>
<string name="setup_account_name">Account name:</string>
<string name="setup_account_name_hint">My CalDAV/CardDAV Account</string>
<string name="setup_account_name_info">"Use your email address as account name because Android will use the account name as ORGANIZER field for events you create. You can't have two accounts with the same name.</string>
<string name="setup_account_name_info">Use your email address as account name because Android will use the account name as ORGANIZER field for events you create. You can\'t have two accounts with the same name.</string>
<string name="setup_read_only">read-only</string>
<!-- sync errors and DebugInfoActivity -->