Merge pull request #186 from owncloud/fixed_contradicted_messages_in_login_view
[pub/Android/ownCloud.git] / src / com / owncloud / android / syncadapter / AbstractOwnCloudSyncAdapter.java
index ecb320e..469ee3b 100644 (file)
@@ -1,10 +1,10 @@
 /* ownCloud Android client application\r
  *   Copyright (C) 2011  Bartek Przybylski\r
+ *   Copyright (C) 2012-2013 ownCloud Inc.\r
  *\r
  *   This program is free software: you can redistribute it and/or modify\r
- *   it under the terms of the GNU General Public License as published by\r
- *   the Free Software Foundation, either version 3 of the License, or\r
- *   (at your option) any later version.\r
+ *   it under the terms of the GNU General Public License version 2,\r
+ *   as published by the Free Software Foundation.\r
  *\r
  *   This program is distributed in the hope that it will be useful,\r
  *   but WITHOUT ANY WARRANTY; without even the implied warranty of\r
@@ -28,9 +28,9 @@ import org.apache.http.client.ClientProtocolException;
 import org.apache.http.conn.ConnectionKeepAliveStrategy;\r
 import org.apache.http.protocol.HttpContext;\r
 \r
-import com.owncloud.android.authenticator.AccountAuthenticator;\r
+import com.owncloud.android.AccountUtils;\r
 import com.owncloud.android.datamodel.DataStorageManager;\r
-import com.owncloud.android.utils.OwnCloudClientUtils;\r
+import com.owncloud.android.network.OwnCloudClientUtils;\r
 \r
 import android.accounts.Account;\r
 import android.accounts.AccountManager;\r
@@ -39,7 +39,6 @@ import android.accounts.OperationCanceledException;
 import android.content.AbstractThreadedSyncAdapter;\r
 import android.content.ContentProviderClient;\r
 import android.content.Context;\r
-import android.net.Uri;\r
 import eu.alefzero.webdav.WebdavClient;\r
 \r
 /**\r
@@ -143,21 +142,14 @@ public abstract class AbstractOwnCloudSyncAdapter extends
         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
-            if (this.getAccountManager().getUserData(getAccount(),\r
-                    AccountAuthenticator.KEY_OC_URL) == null) {\r
-                throw new UnknownHostException();\r
-            }\r
-            mClient = OwnCloudClientUtils.createOwnCloudClient(account, getContext());\r
+    protected void initClientForCurrentAccount() throws OperationCanceledException, AuthenticatorException, IOException {\r
+        if (AccountUtils.constructFullURLForAccount(getContext(), account) == null) {\r
+            throw new UnknownHostException();\r
         }\r
-\r
+        mClient = OwnCloudClientUtils.createOwnCloudClient(account, getContext());\r
+    }\r
+    \r
+    protected WebdavClient getClient() {\r
         return mClient;\r
     }\r
 }
\ No newline at end of file