-
- 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
- }
- String path = n.stripPathFromFilename(uri.getPath());\r
- OCFile new_file = OCFile.createNewFile(getContentProvider(),\r
- getAccount(),\r
- n.getProperty(NodeProperty.PATH),\r
- 0,//Long.parseLong(n.getProperty(NodeProperty.CONTENT_LENGTH)),\r
- 0,//Long.parseLong(n.getProperty(NodeProperty.CREATE_DATE)),\r
- 0,//Long.parseLong(n.getProperty(NodeProperty.LAST_MODIFIED_DATE)),\r
- n.getProperty(NodeProperty.RESOURCE_TYPE),\r
- parent_id);\r
- new_file.save();\r
- if (override_parent) {\r
- parent_id = new_file.getFileId();\r
- override_parent = false;\r
- }
-
- if (!TextUtils.isEmpty(n.getProperty(NodeProperty.NAME)) &&
- n.getProperty(NodeProperty.RESOURCE_TYPE).equals("DIR")) {
-
- HttpPropFind method = new HttpPropFind(uri.getPath() + path + n.getProperty(NodeProperty.NAME).replace(" ", "%20") + "/");
- HttpResponse response = fireRawRequest(method);
- parseResponse(response, uri, client, targetHost, n.getChildList(), true, new_file.getFileId());
- }
- }
- }
+\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 null;\r
+ }\r
+\r
+ protected Uri getUri() {\r
+ return Uri.parse(this.getAccountManager().getUserData(getAccount(),\r
+ AccountAuthenticator.KEY_OC_URL));\r
+ }\r
+\r
+ protected WebdavClient 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;\r
+ }\r