- }
-
- public OwnCloudVersion getDiscoveredVersion() {
- return mOCVersion;
- }
-
- private boolean tryConnection(Uri uri) {
- WebdavClient wc = new WebdavClient(uri);
- wc.allowUnsignedCertificates();
- GetMethod get = new GetMethod(uri.toString());
- boolean retval = false;
- try {
- int status = wc.executeMethod(get);
- switch (status) {
- case HttpStatus.SC_OK: {
- String response = get.getResponseBodyAsString();
- JSONObject json = new JSONObject(response);
- if (!json.getBoolean("installed")) {
- mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED;
- break;
- }
- mOCVersion = new OwnCloudVersion(json.getString("version"));
- if (!mOCVersion.isVersionValid())
- break;
- retval = true;
- break;
+
+ private boolean tryConnection(Uri uri) {
+ WebdavClient wc = new WebdavClient(uri);
+ wc.allowSelfsignedCertificates();
+ GetMethod get = new GetMethod(uri.toString());
+ boolean retval = false;
+ try {
+ int status = wc.executeMethod(get);
+ switch (status) {
+ case HttpStatus.SC_OK: {
+ String response = get.getResponseBodyAsString();
+ JSONObject json = new JSONObject(response);
+ if (!json.getBoolean("installed")) {
+ mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED;
+ break;
+ }
+ mOCVersion = new OwnCloudVersion(json.getString("version"));
+ if (!mOCVersion.isVersionValid())
+ break;
+ retval = true;
+ break;
+ }
+ case HttpStatus.SC_NOT_FOUND:
+ mLatestResult = ResultType.FILE_NOT_FOUND;
+ break;
+ case HttpStatus.SC_INTERNAL_SERVER_ERROR:
+ mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED;
+ break;
+ default:
+ mLatestResult = ResultType.UNKNOWN_ERROR;
+ Log.e(TAG, "Not handled status received from server: " + status);
+ }
+
+ } catch (Exception e) {
+ if (e instanceof UnknownHostException
+ || e instanceof ConnectException) {
+ mLatestResult = ResultType.HOST_NOT_AVAILABLE;
+ } else if (e instanceof JSONException) {
+ mLatestResult = ResultType.INSTANCE_NOT_CONFIGURED;
+ } else if (e instanceof SSLHandshakeException) {
+ mLatestResult = ResultType.SSL_INIT_ERROR;
+ } else {
+ mLatestResult = ResultType.UNKNOWN_ERROR;
+ }
+ e.printStackTrace();