X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/435b31ba4f3597cc7a43270cd4a54fb0180956c1..5f61cb15552eb2fda01716078a9191b88cebf764:/src/eu/alefzero/owncloud/FileDownloader.java diff --git a/src/eu/alefzero/owncloud/FileDownloader.java b/src/eu/alefzero/owncloud/FileDownloader.java index b8fffbcf..1936e8ea 100644 --- a/src/eu/alefzero/owncloud/FileDownloader.java +++ b/src/eu/alefzero/owncloud/FileDownloader.java @@ -22,6 +22,7 @@ import android.util.Log; import eu.alefzero.owncloud.authenticator.AccountAuthenticator; import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta; import eu.alefzero.owncloud.ui.activity.FileDisplayActivity; +import eu.alefzero.owncloud.utils.OwnCloudVersion; import eu.alefzero.webdav.WebdavClient; public class FileDownloader extends Service { @@ -82,10 +83,13 @@ public class FileDownloader extends Service { void downloadFile() { AccountManager am = (AccountManager) getSystemService(ACCOUNT_SERVICE); - Uri oc_url = Uri.parse(am.getUserData(mAccount, - AccountAuthenticator.KEY_OC_URL)); + String oc_base_url = am.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL); + OwnCloudVersion ocv = new OwnCloudVersion(am + .getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION)); + String webdav_path = AccountUtils.getWebdavPath(ocv); + Uri oc_url = Uri.parse(oc_base_url+webdav_path); - WebdavClient wdc = new WebdavClient(oc_url); + WebdavClient wdc = new WebdavClient(Uri.parse(oc_base_url + webdav_path)); String username = mAccount.name.split("@")[0]; String password = ""; @@ -94,6 +98,7 @@ public class FileDownloader extends Service { AccountAuthenticator.AUTH_TOKEN_TYPE, true); } catch (Exception e) { e.printStackTrace(); + return; } wdc.setCredentials(username, password); @@ -113,17 +118,19 @@ public class FileDownloader extends Service { File file = new File(dir, mFilePath.replace('/', '.')); Log.e(TAG, file.getAbsolutePath() + " " + oc_url.toString()); - wdc.downloadFile(mFilePath, file); - ContentValues cv = new ContentValues(); - cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getAbsolutePath()); - getContentResolver().update( - ProviderTableMeta.CONTENT_URI, - cv, - ProviderTableMeta.FILE_NAME + "=? AND " - + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?", - new String[] { - mFilePath.substring(mFilePath.lastIndexOf('/') + 1), - mAccount.name }); + Log.e(TAG, mFilePath+""); + if (wdc.downloadFile(mFilePath, file)) { + ContentValues cv = new ContentValues(); + cv.put(ProviderTableMeta.FILE_STORAGE_PATH, file.getAbsolutePath()); + getContentResolver().update( + ProviderTableMeta.CONTENT_URI, + cv, + ProviderTableMeta.FILE_NAME + "=? AND " + + ProviderTableMeta.FILE_ACCOUNT_OWNER + "=?", + new String[] { + mFilePath.substring(mFilePath.lastIndexOf('/') + 1), + mAccount.name }); + } nm.cancel(1); Intent end = new Intent(DOWNLOAD_FINISH_MESSAGE); sendBroadcast(end);