-
- return 5 * 1000;
- }
- };
- }
-
- protected HttpPropFind getPropFindQuery() throws OperationCanceledException, AuthenticatorException, IOException {
- HttpPropFind query = new HttpPropFind(getUri().toString());
- query.setHeader("Content-type", "text/xml");
- query.setHeader("User-Agent", "Android-ownCloud");
- return query;
- }
-
- protected HttpResponse fireRawRequest(HttpRequest query) throws ClientProtocolException, OperationCanceledException, AuthenticatorException, IOException {
- BasicHttpContext httpContext = new BasicHttpContext();
- BasicScheme basicAuth = new BasicScheme();
- httpContext.setAttribute("preemptive-auth", basicAuth);
-
- HttpResponse response = getClient().execute(mHost, query, httpContext);
- return response;
- }
-
- protected TreeNode fireRequest(HttpRequest query) throws ClientProtocolException, OperationCanceledException, AuthenticatorException, IOException {
- HttpResponse response = fireRawRequest(query);
-
- TreeNode root = new TreeNode();
- root.setProperty(TreeNode.NodeProperty.NAME, "");
- this.parseResponse(response, getUri(), getClient(), mHost, root.getChildList(), false, 0);
- return root;
- }
-
- protected Uri getUri() {
- return Uri.parse(this.getAccountManager().getUserData(getAccount(), AccountAuthenticator.KEY_OC_URL));
- }
-
- private DefaultHttpClient getClient() throws OperationCanceledException, AuthenticatorException, IOException {
- if(mClient == null) {
- String username = getAccount().name.split("@")[0];
- String password = this.getAccountManager().blockingGetAuthToken(getAccount(), AccountAuthenticator.AUTH_TOKEN_TYPE, true);
- if (this.getAccountManager().getUserData(getAccount(), AccountAuthenticator.KEY_OC_URL) == null) {
- throw new UnknownHostException();
- }
- Uri uri = getUri();
-
- mClient = new WebdavClient(uri);
- mClient.setCredentials(username, password);
- mClient.allowUnsignedCertificates();
- mHost = mClient.getTargetHost();
- }
-
- return mClient.getHttpClient();
- }
-
- private void parseResponse(HttpResponse resp, Uri uri, DefaultHttpClient client, HttpHost targetHost, LinkedList<TreeNode> insertList, boolean sf, long parent_id) throws IOException, OperationCanceledException, AuthenticatorException {
- boolean skipFirst = sf, override_parent = !sf;
- for (TreeNode n :WebdavUtils.parseResponseToNodes(resp.getEntity().getContent())) {\r
- if (skipFirst) {\r
- skipFirst = false;\r
- continue;\r
- }
+\r
+ return 5 * 1000;\r
+ }\r
+ };\r
+ }\r
+\r
+ protected HttpPropFind getPropFindQuery()\r
+ throws OperationCanceledException, AuthenticatorException,\r
+ IOException {\r
+ HttpPropFind query = new HttpPropFind(getUri().toString());\r
+ query.setHeader("Content-type", "text/xml");\r
+ query.setHeader("User-Agent", "Android-ownCloud");\r
+ return query;\r
+ }\r
+\r
+ protected HttpResponse fireRawRequest(HttpRequest query)\r
+ throws ClientProtocolException, OperationCanceledException,\r
+ AuthenticatorException, IOException {\r
+ BasicHttpContext httpContext = new BasicHttpContext();\r
+ BasicScheme basicAuth = new BasicScheme();\r
+ httpContext.setAttribute("preemptive-auth", basicAuth);\r
+\r
+ HttpResponse response = getClient().execute(mHost, query, httpContext);\r
+ return response;\r
+ }\r
+\r
+ protected TreeNode fireRequest(HttpRequest query)\r
+ throws ClientProtocolException, OperationCanceledException,\r
+ AuthenticatorException, IOException {\r
+ HttpResponse response = fireRawRequest(query);\r
+\r
+ TreeNode root = new TreeNode();\r
+ root.setProperty(TreeNode.NodeProperty.NAME, "");\r
+ this.parseResponse(response, getUri(), getClient(), mHost,\r
+ root.getChildList(), false, 0);\r
+ return root;\r
+ }\r
+\r
+ protected Uri getUri() {\r
+ return Uri.parse(this.getAccountManager().getUserData(getAccount(),\r
+ AccountAuthenticator.KEY_OC_URL));\r
+ }\r
+\r
+ private DefaultHttpClient getClient() throws OperationCanceledException,\r
+ AuthenticatorException, IOException {\r
+ if (mClient == null) {\r
+ String username = getAccount().name.split("@")[0];\r
+ String password = this.getAccountManager().blockingGetAuthToken(\r
+ getAccount(), AccountAuthenticator.AUTH_TOKEN_TYPE, true);\r
+ if (this.getAccountManager().getUserData(getAccount(),\r
+ AccountAuthenticator.KEY_OC_URL) == null) {\r
+ throw new UnknownHostException();\r
+ }\r
+ Uri uri = getUri();\r
+\r
+ mClient = new WebdavClient(uri);\r
+ mClient.setCredentials(username, password);\r
+ mClient.allowUnsignedCertificates();\r
+ mHost = mClient.getTargetHost();\r
+ }\r
+\r
+ return mClient.getHttpClient();\r
+ }\r
+\r
+ private void parseResponse(HttpResponse resp, Uri uri,\r
+ DefaultHttpClient client, HttpHost targetHost,\r
+ LinkedList<TreeNode> insertList, boolean sf, long parent_id)\r
+ throws IOException, OperationCanceledException,\r
+ AuthenticatorException {\r
+ boolean skipFirst = sf, override_parent = !sf;\r
+ for (TreeNode n : WebdavUtils.parseResponseToNodes(resp.getEntity()\r
+ .getContent())) {\r
+ if (skipFirst) {\r
+ skipFirst = false;\r
+ continue;\r
+ }\r