This wraps the android.util.logging into Log_OC which , if its enabled
[pub/Android/ownCloud.git] / src / com / owncloud / android / AccountUtils.java
index 49b0a62..f38b2e7 100644 (file)
@@ -1,9 +1,10 @@
 /* ownCloud Android client application\r
  *   Copyright (C) 2012  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
+ *   the Free Software Foundation, either version 2 of the License, or\r
  *   (at your option) any later version.\r
  *\r
  *   This program is distributed in the hope that it will be useful,\r
@@ -107,5 +108,27 @@ public class AccountUtils {
         }\r
         return null;\r
     }\r
+    \r
+    /**\r
+     * Constructs full url to host and webdav resource basing on host version\r
+     * @param context\r
+     * @param account\r
+     * @return url or null on failure\r
+     */\r
+    public static String constructFullURLForAccount(Context context, Account account) {\r
+        try {\r
+            AccountManager ama = AccountManager.get(context);\r
+            String baseurl = ama.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL);\r
+            String strver  = ama.getUserData(account, AccountAuthenticator.KEY_OC_VERSION);\r
+            OwnCloudVersion ver = new OwnCloudVersion(strver);\r
+            String webdavpath = getWebdavPath(ver);\r
+\r
+            if (webdavpath == null) return null;\r
+            return baseurl + webdavpath;\r
+        } catch (Exception e) {\r
+            e.printStackTrace();\r
+            return null;\r
+        }\r
+    }\r
 \r
 }\r