Эх сурвалжийг харах

Merge pull request #304 from owncloud/refactor_remote_operation_to_create_folder

Created oc_framework; refactored remote operation to create folder into oc_framework
David A. Velasco 11 жил өмнө
parent
commit
30d231b631
100 өөрчлөгдсөн 1779 нэмэгдсэн , 764 устгасан
  1. 10 6
      .gitignore
  2. 1 1
      AndroidManifest.xml
  3. 66 49
      SETUP.md
  4. 10 0
      oc_framework-test-project/.classpath
  5. 33 0
      oc_framework-test-project/.project
  6. 4 0
      oc_framework-test-project/.settings/org.eclipse.jdt.core.prefs
  7. 34 0
      oc_framework-test-project/AndroidManifest.xml
  8. BIN
      oc_framework-test-project/ic_launcher-web.png
  9. BIN
      oc_framework-test-project/libs/android-support-v4.jar
  10. 10 0
      oc_framework-test-project/oc_framework-test-test/.classpath
  11. 34 0
      oc_framework-test-project/oc_framework-test-test/.project
  12. 4 0
      oc_framework-test-project/oc_framework-test-test/.settings/org.eclipse.jdt.core.prefs
  13. 17 0
      oc_framework-test-project/oc_framework-test-test/AndroidManifest.xml
  14. 14 0
      oc_framework-test-project/oc_framework-test-test/project.properties
  15. BIN
      oc_framework-test-project/oc_framework-test-test/res/drawable-hdpi/ic_launcher.png
  16. BIN
      oc_framework-test-project/oc_framework-test-test/res/drawable-ldpi/ic_launcher.png
  17. BIN
      oc_framework-test-project/oc_framework-test-test/res/drawable-mdpi/ic_launcher.png
  18. BIN
      oc_framework-test-project/oc_framework-test-test/res/drawable-xhdpi/ic_launcher.png
  19. 6 0
      oc_framework-test-project/oc_framework-test-test/res/values/strings.xml
  20. 96 0
      oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java
  21. 15 0
      oc_framework-test-project/project.properties
  22. BIN
      oc_framework-test-project/res/drawable-hdpi/ic_launcher.png
  23. BIN
      oc_framework-test-project/res/drawable-mdpi/ic_launcher.png
  24. BIN
      oc_framework-test-project/res/drawable-xhdpi/ic_launcher.png
  25. BIN
      oc_framework-test-project/res/drawable-xxhdpi/ic_launcher.png
  26. 16 0
      oc_framework-test-project/res/layout/activity_test.xml
  27. 9 0
      oc_framework-test-project/res/menu/test.xml
  28. 8 0
      oc_framework-test-project/res/values-sw600dp/dimens.xml
  29. 9 0
      oc_framework-test-project/res/values-sw720dp-land/dimens.xml
  30. 11 0
      oc_framework-test-project/res/values-v11/styles.xml
  31. 12 0
      oc_framework-test-project/res/values-v14/styles.xml
  32. 7 0
      oc_framework-test-project/res/values/dimens.xml
  33. 8 0
      oc_framework-test-project/res/values/strings.xml
  34. 20 0
      oc_framework-test-project/res/values/styles.xml
  35. 117 0
      oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java
  36. 9 0
      oc_framework/.classpath
  37. 33 0
      oc_framework/.project
  38. 4 0
      oc_framework/.settings/org.eclipse.jdt.core.prefs
  39. 11 0
      oc_framework/AndroidManifest.xml
  40. 92 0
      oc_framework/build.xml
  41. BIN
      oc_framework/libs/jackrabbit-webdav-2.2.5-jar-with-dependencies.jar
  42. 15 0
      oc_framework/project.properties
  43. 43 0
      oc_framework/src/com/owncloud/android/oc_framework/accounts/AccountTypeUtils.java
  44. 129 0
      oc_framework/src/com/owncloud/android/oc_framework/accounts/AccountUtils.java
  45. 105 0
      oc_framework/src/com/owncloud/android/oc_framework/accounts/OwnCloudAccount.java
  46. 6 5
      oc_framework/src/com/owncloud/android/oc_framework/network/AdvancedSslSocketFactory.java
  47. 4 3
      oc_framework/src/com/owncloud/android/oc_framework/network/AdvancedX509TrustManager.java
  48. 9 6
      oc_framework/src/com/owncloud/android/oc_framework/network/BearerAuthScheme.java
  49. 2 1
      oc_framework/src/com/owncloud/android/oc_framework/network/BearerCredentials.java
  50. 2 1
      oc_framework/src/com/owncloud/android/oc_framework/network/CertificateCombinedException.java
  51. 168 0
      oc_framework/src/com/owncloud/android/oc_framework/network/NetworkUtils.java
  52. 4 2
      oc_framework/src/com/owncloud/android/oc_framework/network/ProgressiveDataTransferer.java
  53. 4 6
      oc_framework/src/com/owncloud/android/oc_framework/network/webdav/ChunkFromFileChannelRequestEntity.java
  54. 4 6
      oc_framework/src/com/owncloud/android/oc_framework/network/webdav/FileRequestEntity.java
  55. 1 1
      oc_framework/src/com/owncloud/android/oc_framework/network/webdav/OnDatatransferProgressListener.java
  56. 151 0
      oc_framework/src/com/owncloud/android/oc_framework/network/webdav/OwnCloudClientFactory.java
  57. 12 24
      oc_framework/src/com/owncloud/android/oc_framework/network/webdav/WebdavClient.java
  58. 3 3
      oc_framework/src/com/owncloud/android/oc_framework/network/webdav/WebdavEntry.java
  59. 1 1
      oc_framework/src/com/owncloud/android/oc_framework/network/webdav/WebdavUtils.java
  60. 1 1
      oc_framework/src/com/owncloud/android/oc_framework/operations/OnRemoteOperationListener.java
  61. 1 1
      oc_framework/src/com/owncloud/android/oc_framework/operations/OperationCancelledException.java
  62. 15 15
      oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperation.java
  63. 9 6
      oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java
  64. 94 0
      oc_framework/src/com/owncloud/android/oc_framework/operations/remote/CreateRemoteFolderOperation.java
  65. 52 0
      oc_framework/src/com/owncloud/android/oc_framework/utils/FileUtils.java
  66. 1 1
      oc_framework/src/com/owncloud/android/oc_framework/utils/OwnCloudVersion.java
  67. 2 1
      project.properties
  68. 1 0
      res/values/strings.xml
  69. 1 0
      setup_env.bat
  70. 1 0
      setup_env.sh
  71. 0 24
      src/com/owncloud/android/MainApp.java
  72. 7 35
      src/com/owncloud/android/authentication/AccountAuthenticator.java
  73. 4 68
      src/com/owncloud/android/authentication/AccountUtils.java
  74. 45 45
      src/com/owncloud/android/authentication/AuthenticatorActivity.java
  75. 1 1
      src/com/owncloud/android/authentication/SsoWebViewClient.java
  76. 1 1
      src/com/owncloud/android/datamodel/FileDataStorageManager.java
  77. 1 1
      src/com/owncloud/android/datamodel/OCFile.java
  78. 1 1
      src/com/owncloud/android/db/DbHandler.java
  79. 1 1
      src/com/owncloud/android/files/BootupBroadcastReceiver.java
  80. 1 1
      src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java
  81. 3 3
      src/com/owncloud/android/files/OwnCloudFileObserver.java
  82. 10 12
      src/com/owncloud/android/files/services/FileDownloader.java
  83. 1 1
      src/com/owncloud/android/files/services/FileObserverService.java
  84. 18 20
      src/com/owncloud/android/files/services/FileUploader.java
  85. 1 1
      src/com/owncloud/android/media/MediaService.java
  86. 1 1
      src/com/owncloud/android/media/MediaServiceBinder.java
  87. 0 285
      src/com/owncloud/android/network/OwnCloudClientUtils.java
  88. 5 5
      src/com/owncloud/android/operations/ChunkedUploadFileOperation.java
  89. 50 61
      src/com/owncloud/android/operations/CreateFolderOperation.java
  90. 7 7
      src/com/owncloud/android/operations/DownloadFileOperation.java
  91. 5 4
      src/com/owncloud/android/operations/ExistenceCheckOperation.java
  92. 5 4
      src/com/owncloud/android/operations/OAuth2GetAccessToken.java
  93. 5 4
      src/com/owncloud/android/operations/OwnCloudServerCheckOperation.java
  94. 5 4
      src/com/owncloud/android/operations/RemoveFileOperation.java
  95. 6 4
      src/com/owncloud/android/operations/RenameFileOperation.java
  96. 7 6
      src/com/owncloud/android/operations/SynchronizeFileOperation.java
  97. 7 5
      src/com/owncloud/android/operations/SynchronizeFolderOperation.java
  98. 9 8
      src/com/owncloud/android/operations/UpdateOCVersionOperation.java
  99. 10 10
      src/com/owncloud/android/operations/UploadFileOperation.java
  100. 1 1
      src/com/owncloud/android/providers/FileContentProvider.java

+ 10 - 6
.gitignore

@@ -13,18 +13,22 @@ bin/
 gen/
 target/
 
-# Local configuration file (sdk path, etc)
+# Local configuration files (sdk path, etc)
 local.properties
+oc_workaround/local.properties
+oc_framework/local.properties
+oc_framework-test-project/local.properties
+tests/local.properties
 
 # Mac .DS_Store files
 .DS_Store
 
-# These files are created automatically by Eclipse:
-tests/proguard-project.txt
-tests/project.properties
-tests/ant.properties
-tests/build.xml
+# Proguard README
 proguard-project.txt
+oc_workaround/proguard-project.txt
+oc_framework/proguard-project.txt
+oc_framework-test-project/proguard-project.txt
+tests/proguard-project.txt
 
 # Should not be commited inside this repo:
 actionbarsherlock/

+ 1 - 1
AndroidManifest.xml

@@ -63,7 +63,7 @@
  		<activity android:name=".ui.activity.InstantUploadActivity">
         </activity>
         <activity android:name=".ui.activity.FailedUploadActivity" android:theme="@android:style/Theme.Dialog" android:excludeFromRecents="true"/>
-        <activity android:name=".Uploader" >
+        <activity android:name=".ui.activity.Uploader" >
             <intent-filter>
                 <action android:name="android.intent.action.SEND" >
                 </action>

+ 66 - 49
SETUP.md

@@ -1,56 +1,73 @@
   
-  If you want to start help developing ownCloud please follow the [contribution guidlines][0] and observe these instructions:
+If you want to start help developing ownCloud please follow the [contribution guidelines][0] and observe these instructions:
   
-  1. Fork and download android/develop repository:
-
-  -  NOTE: You must have git in your enviroment path
-  -  Navigate to https://github.com/owncloud/android, click fork.
-  -  Clone your new repo: "git clone git@github.com:YOURGITHUBNAME/android.git"
-  -  "cd android"
-  -  Checkout remote develop branch: "git checkout -b develop remotes/origin/develop"
-  -  Pull changes from your develop branch: "git pull origin develop"
-  -  Make sure to get the latest changes from official android/develop branch:
-  -  Make official owncloud repo known as upstream: "git remote add upstream git@github.com:owncloud/android.git"
-  -  Pull latest changes from upstream: "git pull upstream develop"
-
-  2. Building with console/maven:
-
-  -  OPTIONAL, CONTINUE WITH STEP 3 IF NOT REQUIRED!
-  -  NOTE: You must have mvn in your enviroment path
-  -  Download/install Android plugin for Maven, then build ownCloud with mvn:
-  -  "cd .."
-  -  "git clone https://github.com/mosabua/maven-android-sdk-deployer.git"
-  -  "cd maven-android-sdk-deployer"
-  -  "mvn -pl com.simpligility.android.sdk-deployer:android-17 -am install"
-  -  "cd ../android"
-  -  Now you can create APK using "mvn package"
-
-  3. Building with Eclipse:
-
-  -  NOTE: You must have android/tools, and 'platforms-tools' in your enviroment path
-  -  Prepare building with Eclipse:
-  -  "setup_env.bat" or "./setup_env.sh"
-  -  Open Eclipse and create new "Android Project from Existing Code". As root choose android/actionbarsherlock/library
-  -  Increase Android API level until project compiles. 14 should work. 
-  -  Clean project and compile.
-  -  Make sure android/actionbarsherlock/library/bin/library.jar was created!
-  -  Import OwnCloud Android project.
-  -  Increase Android API level to 17.
-  -  Clean project and compile.
-  -  After those actions you should be good to go. HAVE FUN!
-  -  NOTE: Even though API level is set to 17, APK also runs on older devices because in AndroidManifest.xml minSdkVersion is set to 8.
-
-  4. Create pull request:
+### 1. Fork and download android/develop repository:
+
+NOTE: You must have git in your environment path variable to perform the next operations.
+  
+* Navigate to https://github.com/owncloud/android, click fork.
+* Clone your new repo: "git clone git@github.com:YOURGITHUBNAME/android.git"
+* Move to the project folder with "cd android"
+* Checkout remote develop branch: "git checkout -b develop remotes/origin/develop"
+* Pull changes from your develop branch: "git pull origin develop"
+* Make official ownCloud repo known as upstream: "git remote add upstream git@github.com:owncloud/android.git"
+* Make sure to get the latest changes from official android/develop branch: "git pull upstream develop"
+
+At this point you can continue using different tools to build the project. Section 2, 3 and 4 describe some of the existing alternatives.  
+
+### 2. Building with Ant:
+  
+NOTE: You must have the Android SDK 'tools/', and 'platforms-tools/' folders in your environment path variable.
+
+* Complete the setup of project properties and resolve pending dependencies running "setup_env.bat" or "./setup_env.sh" .
+* Run "ant clean" .
+* Run "ant debug" to generate a debuggable version of the ownCkoud app.
+
+### 3. Building with console/maven:
+
+NOTE: You must have mvn in your environment path
+
+* Download/install Android plugin for Maven, then build ownCloud with mvn:
+* "cd .."
+* "git clone https://github.com/mosabua/maven-android-sdk-deployer.git"
+* "cd maven-android-sdk-deployer"
+* "mvn -pl com.simpligility.android.sdk-deployer:android-17 -am install"
+* "cd ../android"
+* Now you can create APK using "mvn package"
+
+### 4. Building with Eclipse:
+
+NOTE: You must have the Android SDK 'tools/', and 'platforms-tools/' folders in your environment path variable.
+
+* Complete the setup of project properties and resolve pending dependencies running "setup_env.bat" or "./setup_env.sh" .
+* Open Eclipse and create new "Android Project from Existing Code". Choose android/actionbarsherlock/library as root.
+* Clean project and compile.
+* If any error appear, check the project properties; in the 'Android' section, API Level should be greater or equal than 14.
+* Make sure android/actionbarsherlock/library/bin/library.jar was created.
+* Create a new "Android Project from Existing Code". Choose android/oc_framework/library as root.
+* Clean project and compile.
+* If any error appear, check the project properties; in the 'Android' section, API Level should be 19 or greater.
+* Make sure android/oc_framework/bin/classes.jar was created.  
+* Import ownCloud Android project.
+* Clean project and compile.
+* If any error appears, check the project properties; in the 'Android' section:
+  - API Level should be 19 or greater.
+  - Two library projects should appear referred in the bottom square: actionbarsherlock/library and oc_framework. Add them if needed. 
+* After those actions you should be good to go. HAVE FUN!
+
+NOTE: Even though API level is set to 19, APK also runs on older devices because in AndroidManifest.xml minSdkVersion is set to 8.
+
+### 5. Create pull request:
   
-  -  NOTE: You must sign the [Contributor Agreement][1] before your changes can be accepted!
-  -  Commit your changes locally: "git commit -a"
-  -  Push your changes to your Github repo: "git push"
-  -  Browse to https://github.com/YOURGITHUBNAME/android/pulls and issue pull request
-  -  Click "Edit" and set "base:develop"
-  -  Again, click "Edit" and set "compare:develop"
-  -  Enter description and send pull request.
+NOTE: You must sign the [Contributor Agreement][1] before your changes can be accepted!
+
+* Commit your changes locally: "git commit -a"
+* Push your changes to your Github repo: "git push"
+* Browse to https://github.com/YOURGITHUBNAME/android/pulls and issue pull request
+* Click "Edit" and set "base:develop"
+* Again, click "Edit" and set "compare:develop"
+* Enter description and send pull request.
 
 
 [0]: https://github.com/owncloud/android/blob/master/CONTRIBUTING.md
 [1]: http://owncloud.org/about/contributor-agreement/
-

+ 10 - 0
oc_framework-test-project/.classpath

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+	<classpathentry exported="true" kind="lib" path="/oc_framework/bin/oc_framework.jar"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>

+ 33 - 0
oc_framework-test-project/.project

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>oc_framework-test-project</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 4 - 0
oc_framework-test-project/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6

+ 34 - 0
oc_framework-test-project/AndroidManifest.xml

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.owncloud.android.oc_framework_test_project"
+    android:versionCode="1"
+    android:versionName="1.0" >
+    
+    <uses-permission android:name="android.permission.USE_CREDENTIALS" />
+    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
+    <uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
+    <uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
+    <uses-permission android:name="android.permission.INTERNET"/>
+        <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="19" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name="com.owncloud.android.oc_framework_test_project.TestActivity"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+    </application>
+
+</manifest>

BIN
oc_framework-test-project/ic_launcher-web.png


BIN
oc_framework-test-project/libs/android-support-v4.jar


+ 10 - 0
oc_framework-test-project/oc_framework-test-test/.classpath

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/oc_framework-test-project"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>

+ 34 - 0
oc_framework-test-project/oc_framework-test-test/.project

@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>oc_framework-test</name>
+	<comment></comment>
+	<projects>
+		<project>oc_framework-test-project</project>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 4 - 0
oc_framework-test-project/oc_framework-test-test/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6

+ 17 - 0
oc_framework-test-project/oc_framework-test-test/AndroidManifest.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.owncloud.android.oc_framework_test_project.test"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk android:minSdkVersion="8" />
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation
+        android:name="android.test.InstrumentationTestRunner"
+        android:label="Tests for com.owncloud.android.oc_framework_test_project"
+        android:targetPackage="com.owncloud.android.oc_framework_test_project" />
+
+</manifest>

+ 14 - 0
oc_framework-test-project/oc_framework-test-test/project.properties

@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19

BIN
oc_framework-test-project/oc_framework-test-test/res/drawable-hdpi/ic_launcher.png


BIN
oc_framework-test-project/oc_framework-test-test/res/drawable-ldpi/ic_launcher.png


BIN
oc_framework-test-project/oc_framework-test-test/res/drawable-mdpi/ic_launcher.png


BIN
oc_framework-test-project/oc_framework-test-test/res/drawable-xhdpi/ic_launcher.png


+ 6 - 0
oc_framework-test-project/oc_framework-test-test/res/values/strings.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">Oc_framework-testTest</string>
+
+</resources>

+ 96 - 0
oc_framework-test-project/oc_framework-test-test/src/com/owncloud/android/oc_framework_test_project/test/CreateFolderTest.java

@@ -0,0 +1,96 @@
+package com.owncloud.android.oc_framework_test_project.test;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework_test_project.TestActivity;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+ * Class to test Create Folder Operation
+ * @author masensio
+ *
+ */
+public class CreateFolderTest extends ActivityInstrumentationTestCase2<TestActivity> {
+
+	private TestActivity mActivity;
+	private String mCurrentDate;
+	
+	public CreateFolderTest() {
+	    super(TestActivity.class);
+	   
+		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss");
+		mCurrentDate = sdf.format(new Date());
+	}
+	
+	@Override
+	  protected void setUp() throws Exception {
+	    super.setUp();
+	    setActivityInitialTouchMode(false);
+	    mActivity = getActivity();
+	}
+	
+	/**
+	 * Test Create Folder
+	 */
+	public void testCreateFolder() {
+
+		String remotePath = "/testCreateFolder" + mCurrentDate;
+		boolean createFullPath = true;
+		
+		RemoteOperationResult result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
+		
+		// Create Subfolder
+		remotePath = "/testCreateFolder" + mCurrentDate + "/" + "testCreateFolder" + mCurrentDate;
+		createFullPath = true;
+		
+		result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.isSuccess() || result.getCode() == ResultCode.TIMEOUT);
+	}
+	
+	
+	/**
+	 * Test to Create Folder with special characters
+	 */
+	public void testCreateFolderSpecialCharacters() {		
+		boolean createFullPath = true;
+		
+		String remotePath = "/testSpecialCharacters_\\" + mCurrentDate;
+		RemoteOperationResult result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+		
+		remotePath = "/testSpecialCharacters_<" + mCurrentDate;		
+		result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+		
+		remotePath = "/testSpecialCharacters_>" + mCurrentDate;		
+		result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+		
+		remotePath = "/testSpecialCharacters_:" + mCurrentDate;		
+		result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+		
+		remotePath = "/testSpecialCharacters_\"" + mCurrentDate;		
+		result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+		
+		remotePath = "/testSpecialCharacters_|" + mCurrentDate;		
+		result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+		
+		remotePath = "/testSpecialCharacters_?" + mCurrentDate;		
+		result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+		
+		remotePath = "/testSpecialCharacters_*" + mCurrentDate;		
+		result =  mActivity.createFolder(remotePath, createFullPath);
+		assertTrue(result.getCode() == ResultCode.INVALID_CHARACTER_IN_NAME);
+	}
+
+
+}

+ 15 - 0
oc_framework-test-project/project.properties

@@ -0,0 +1,15 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
+android.library.reference.1=../oc_framework

BIN
oc_framework-test-project/res/drawable-hdpi/ic_launcher.png


BIN
oc_framework-test-project/res/drawable-mdpi/ic_launcher.png


BIN
oc_framework-test-project/res/drawable-xhdpi/ic_launcher.png


BIN
oc_framework-test-project/res/drawable-xxhdpi/ic_launcher.png


+ 16 - 0
oc_framework-test-project/res/layout/activity_test.xml

@@ -0,0 +1,16 @@
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="@dimen/activity_vertical_margin"
+    android:paddingLeft="@dimen/activity_horizontal_margin"
+    android:paddingRight="@dimen/activity_horizontal_margin"
+    android:paddingTop="@dimen/activity_vertical_margin"
+    tools:context=".TestActivity" >
+
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/hello_world" />
+
+</RelativeLayout>

+ 9 - 0
oc_framework-test-project/res/menu/test.xml

@@ -0,0 +1,9 @@
+<menu xmlns:android="http://schemas.android.com/apk/res/android" >
+
+    <item
+        android:id="@+id/action_settings"
+        android:orderInCategory="100"
+        android:showAsAction="never"
+        android:title="@string/action_settings"/>
+
+</menu>

+ 8 - 0
oc_framework-test-project/res/values-sw600dp/dimens.xml

@@ -0,0 +1,8 @@
+<resources>
+
+    <!--
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw600dp devices (e.g. 7" tablets) here.
+    -->
+
+</resources>

+ 9 - 0
oc_framework-test-project/res/values-sw720dp-land/dimens.xml

@@ -0,0 +1,9 @@
+<resources>
+
+    <!--
+         Customize dimensions originally defined in res/values/dimens.xml (such as
+         screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here.
+    -->
+    <dimen name="activity_horizontal_margin">128dp</dimen>
+
+</resources>

+ 11 - 0
oc_framework-test-project/res/values-v11/styles.xml

@@ -0,0 +1,11 @@
+<resources>
+
+    <!--
+        Base application theme for API 11+. This theme completely replaces
+        AppBaseTheme from res/values/styles.xml on API 11+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+        <!-- API 11 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 12 - 0
oc_framework-test-project/res/values-v14/styles.xml

@@ -0,0 +1,12 @@
+<resources>
+
+    <!--
+        Base application theme for API 14+. This theme completely replaces
+        AppBaseTheme from BOTH res/values/styles.xml and
+        res/values-v11/styles.xml on API 14+ devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+        <!-- API 14 theme customizations can go here. -->
+    </style>
+
+</resources>

+ 7 - 0
oc_framework-test-project/res/values/dimens.xml

@@ -0,0 +1,7 @@
+<resources>
+
+    <!-- Default screen margins, per the Android Design guidelines. -->
+    <dimen name="activity_horizontal_margin">16dp</dimen>
+    <dimen name="activity_vertical_margin">16dp</dimen>
+
+</resources>

+ 8 - 0
oc_framework-test-project/res/values/strings.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+    <string name="app_name">oc_framework-test-project</string>
+    <string name="action_settings">Settings</string>
+    <string name="hello_world">Hello world!</string>
+
+</resources>

+ 20 - 0
oc_framework-test-project/res/values/styles.xml

@@ -0,0 +1,20 @@
+<resources>
+
+    <!--
+        Base application theme, dependent on API level. This theme is replaced
+        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
+    -->
+    <style name="AppBaseTheme" parent="android:Theme.Light">
+        <!--
+            Theme customizations available in newer API levels can go in
+            res/values-vXX/styles.xml, while customizations related to
+            backward-compatibility can go here.
+        -->
+    </style>
+
+    <!-- Application theme. -->
+    <style name="AppTheme" parent="AppBaseTheme">
+        <!-- All customizations that are NOT specific to a particular API-level can go here. -->
+    </style>
+
+</resources>

+ 117 - 0
oc_framework-test-project/src/com/owncloud/android/oc_framework_test_project/TestActivity.java

@@ -0,0 +1,117 @@
+package com.owncloud.android.oc_framework_test_project;
+
+import java.io.IOException;
+
+import com.owncloud.android.oc_framework.accounts.AccountUtils.AccountNotFoundException;
+import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation;
+
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
+import android.app.Activity;
+import android.content.Context;
+import android.util.Log;
+import android.view.Menu;
+
+/**
+ * Activity to test OC framework
+ * @author masensio
+ *
+ */
+public class TestActivity extends Activity {
+	
+	private static final String TAG = "TestActivity";
+	
+	private Account mAccount = null;
+	private WebdavClient mClient;
+	
+	@Override
+	protected void onCreate(Bundle savedInstanceState) {
+		super.onCreate(savedInstanceState);
+		setContentView(R.layout.activity_test);
+		
+		// This account must exists on the simulator / device
+		String accountHost = "beta.owncloud.com";
+		String accountUser = "testandroid";
+		String accountName = accountUser + "@"+ accountHost;
+		String accountPass = "testandroid";
+		String accountType = "owncloud";	
+
+		AccountManager am = AccountManager.get(this);
+		
+		Account[] ocAccounts = am.getAccountsByType(accountType);
+        for (Account ac : ocAccounts) {
+           if (ac.name.equals(accountName)) {
+        	   mAccount = ac;
+        	   break;
+            }
+        }
+
+        // Get the WebDavClient
+        AuthTask task = new AuthTask();
+        task.execute(this.getApplicationContext());
+        
+	}
+
+	@Override
+	public boolean onCreateOptionsMenu(Menu menu) {
+		// Inflate the menu; this adds items to the action bar if it is present.
+		getMenuInflater().inflate(R.menu.test, menu);
+		return true;
+	}
+
+	/**
+	 * Access to the library method to Create a Folder
+	 * @param remotePath
+	 * @param createFullPath
+	 * @return
+	 */
+	public RemoteOperationResult createFolder(String remotePath, boolean createFullPath) {
+		
+		CreateRemoteFolderOperation createOperation = new CreateRemoteFolderOperation(remotePath, createFullPath);
+		RemoteOperationResult result =  createOperation.execute(mClient);
+		
+		return result;
+	}
+	
+	private class AuthTask extends AsyncTask<Context, Void, WebdavClient> {
+
+		@Override
+		protected WebdavClient doInBackground(Context... params) {
+			WebdavClient client = null;
+			try {
+				client = OwnCloudClientFactory.createOwnCloudClient(mAccount, (Context) params[0] );
+			} catch (OperationCanceledException e) {
+				Log.e(TAG, "Error while trying to access to " + mAccount.name, e);
+				e.printStackTrace();
+			} catch (AuthenticatorException e) {
+				Log.e(TAG, "Error while trying to access to " + mAccount.name, e);
+				e.printStackTrace();
+			} catch (AccountNotFoundException e) {
+				Log.e(TAG, "Error while trying to access to " + mAccount.name, e);
+				e.printStackTrace();
+			} catch (IOException e) {
+				Log.e(TAG, "Error while trying to access to " + mAccount.name, e);
+				e.printStackTrace();
+			} catch (IllegalStateException e) {
+				Log.e(TAG, "Error while trying to access to " + mAccount.name, e);
+				e.printStackTrace();
+			}
+			return client;
+		}
+
+		@Override
+		protected void onPostExecute(WebdavClient result) {
+			// TODO Auto-generated method stub
+			super.onPostExecute(result);
+			mClient = result;
+		}
+		
+	}
+}

+ 9 - 0
oc_framework/.classpath

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+	<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="gen"/>
+	<classpathentry kind="output" path="bin/classes"/>
+</classpath>

+ 33 - 0
oc_framework/.project

@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>oc_framework</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

+ 4 - 0
oc_framework/.settings/org.eclipse.jdt.core.prefs

@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6

+ 11 - 0
oc_framework/AndroidManifest.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.owncloud.android.oc_framework"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="19" />
+
+</manifest>

+ 92 - 0
oc_framework/build.xml

@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="ownCloudFramework" default="help">
+
+    <!-- The local.properties file is created and updated by the 'android' tool.
+         It contains the path to the SDK. It should *NOT* be checked into
+         Version Control Systems. -->
+    <property file="local.properties" />
+
+    <!-- The ant.properties file can be created by you. It is only edited by the
+         'android' tool to add properties to it.
+         This is the place to change some Ant specific build properties.
+         Here are some properties you may want to change/update:
+
+         source.dir
+             The name of the source directory. Default is 'src'.
+         out.dir
+             The name of the output directory. Default is 'bin'.
+
+         For other overridable properties, look at the beginning of the rules
+         files in the SDK, at tools/ant/build.xml
+
+         Properties related to the SDK location or the project target should
+         be updated using the 'android' tool with the 'update' action.
+
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems.
+
+         -->
+    <property file="ant.properties" />
+
+    <!-- if sdk.dir was not set from one of the property file, then
+         get it from the ANDROID_HOME env var.
+         This must be done before we load project.properties since
+         the proguard config can use sdk.dir -->
+    <property environment="env" />
+    <condition property="sdk.dir" value="${env.ANDROID_HOME}">
+        <isset property="env.ANDROID_HOME" />
+    </condition>
+
+    <!-- The project.properties file is created and updated by the 'android'
+         tool, as well as ADT.
+
+         This contains project specific properties such as project target, and library
+         dependencies. Lower level build properties are stored in ant.properties
+         (or in .classpath for Eclipse projects).
+
+         This file is an integral part of the build system for your
+         application and should be checked into Version Control Systems. -->
+    <loadproperties srcFile="project.properties" />
+
+    <!-- quick check on sdk.dir -->
+    <fail
+            message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
+            unless="sdk.dir"
+    />
+
+    <!--
+        Import per project custom build rules if present at the root of the project.
+        This is the place to put custom intermediary targets such as:
+            -pre-build
+            -pre-compile
+            -post-compile (This is typically used for code obfuscation.
+                           Compiled code location: ${out.classes.absolute.dir}
+                           If this is not done in place, override ${out.dex.input.absolute.dir})
+            -post-package
+            -post-build
+            -pre-clean
+    -->
+    <import file="custom_rules.xml" optional="true" />
+
+    <!-- Import the actual build file.
+
+         To customize existing targets, there are two options:
+         - Customize only one target:
+             - copy/paste the target into this file, *before* the
+               <import> task.
+             - customize it to your needs.
+         - Customize the whole content of build.xml
+             - copy/paste the content of the rules files (minus the top node)
+               into this file, replacing the <import> task.
+             - customize to your needs.
+
+         ***********************
+         ****** IMPORTANT ******
+         ***********************
+         In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
+         in order to avoid having your file be overridden by tools such as "android update project"
+    -->
+    <!-- version-tag: 1 -->
+    <import file="${sdk.dir}/tools/ant/build.xml" />
+
+</project>

BIN
oc_framework/libs/jackrabbit-webdav-2.2.5-jar-with-dependencies.jar


+ 15 - 0
oc_framework/project.properties

@@ -0,0 +1,15 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
+android.library=true

+ 43 - 0
oc_framework/src/com/owncloud/android/oc_framework/accounts/AccountTypeUtils.java

@@ -0,0 +1,43 @@
+/* ownCloud Android client application
+ *   Copyright (C) 2012  Bartek Przybylski
+ *   Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.oc_framework.accounts;
+
+/**
+ * @author masensio
+ * @author David A. Velasco
+ */
+public class AccountTypeUtils {
+
+    public static String getAuthTokenTypePass(String accountType) {
+        return accountType + ".password";
+    }
+    
+    public static String getAuthTokenTypeAccessToken(String accountType) {
+        return accountType  + ".oauth2.access_token";
+    }
+    
+    public static String getAuthTokenTypeRefreshToken(String accountType) {
+        return accountType  + ".oauth2.refresh_token";
+    }
+    
+    public static String getAuthTokenTypeSamlSessionCookie(String accountType) {
+        return accountType  +  ".saml.web_sso.session_cookie";
+    }
+    
+}

+ 129 - 0
oc_framework/src/com/owncloud/android/oc_framework/accounts/AccountUtils.java

@@ -0,0 +1,129 @@
+/* ownCloud Android client application
+ *   Copyright (C) 2012  Bartek Przybylski
+ *   Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.oc_framework.accounts;
+
+import com.owncloud.android.oc_framework.utils.OwnCloudVersion;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountsException;
+import android.content.Context;
+
+public class AccountUtils {
+    public static final String WEBDAV_PATH_1_2 = "/webdav/owncloud.php";
+    public static final String WEBDAV_PATH_2_0 = "/files/webdav.php";
+    public static final String WEBDAV_PATH_4_0 = "/remote.php/webdav";
+    private static final String ODAV_PATH = "/remote.php/odav";
+    private static final String SAML_SSO_PATH = "/remote.php/webdav";
+    public static final String CARDDAV_PATH_2_0 = "/apps/contacts/carddav.php";
+    public static final String CARDDAV_PATH_4_0 = "/remote/carddav.php";
+    public static final String STATUS_PATH = "/status.php";
+
+    /**
+     * 
+     * @param version version of owncloud
+     * @return webdav path for given OC version, null if OC version unknown
+     */
+    public static String getWebdavPath(OwnCloudVersion version, boolean supportsOAuth, boolean supportsSamlSso) {
+        if (version != null) {
+            if (supportsOAuth) {
+                return ODAV_PATH;
+            }
+            if (supportsSamlSso) {
+                return SAML_SSO_PATH;
+            }
+            if (version.compareTo(OwnCloudVersion.owncloud_v4) >= 0)
+                return WEBDAV_PATH_4_0;
+            if (version.compareTo(OwnCloudVersion.owncloud_v3) >= 0
+                    || version.compareTo(OwnCloudVersion.owncloud_v2) >= 0)
+                return WEBDAV_PATH_2_0;
+            if (version.compareTo(OwnCloudVersion.owncloud_v1) >= 0)
+                return WEBDAV_PATH_1_2;
+        }
+        return null;
+    }
+    
+//    /**
+//     * Returns the proper URL path to access the WebDAV interface of an ownCloud server,
+//     * according to its version and the authorization method used.
+//     * 
+//     * @param   version         Version of ownCloud server.
+//     * @param   authTokenType   Authorization token type, matching some of the AUTH_TOKEN_TYPE_* constants in {@link AccountAuthenticator}. 
+//     * @return                  WebDAV path for given OC version and authorization method, null if OC version is unknown.
+//     */
+//    public static String getWebdavPath(OwnCloudVersion version, String authTokenType) {
+//        if (version != null) {
+//            if (MainApp.getAuthTokenTypeAccessToken().equals(authTokenType)) {
+//                return ODAV_PATH;
+//            }
+//            if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(authTokenType)) {
+//                return SAML_SSO_PATH;
+//            }
+//            if (version.compareTo(OwnCloudVersion.owncloud_v4) >= 0)
+//                return WEBDAV_PATH_4_0;
+//            if (version.compareTo(OwnCloudVersion.owncloud_v3) >= 0
+//                    || version.compareTo(OwnCloudVersion.owncloud_v2) >= 0)
+//                return WEBDAV_PATH_2_0;
+//            if (version.compareTo(OwnCloudVersion.owncloud_v1) >= 0)
+//                return WEBDAV_PATH_1_2;
+//        }
+//        return null;
+//    }
+    
+    /**
+     * Constructs full url to host and webdav resource basing on host version
+     * @param context
+     * @param account
+     * @return url or null on failure
+     * @throws AccountNotFoundException     When 'account' is unknown for the AccountManager
+     */
+    public static String constructFullURLForAccount(Context context, Account account) throws AccountNotFoundException {
+        AccountManager ama = AccountManager.get(context);
+        String baseurl = ama.getUserData(account, OwnCloudAccount.Constants.KEY_OC_BASE_URL);
+        String strver  = ama.getUserData(account, OwnCloudAccount.Constants.KEY_OC_VERSION);
+        boolean supportsOAuth = (ama.getUserData(account, OwnCloudAccount.Constants.KEY_SUPPORTS_OAUTH2) != null);
+        boolean supportsSamlSso = (ama.getUserData(account, OwnCloudAccount.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null);
+        OwnCloudVersion ver = new OwnCloudVersion(strver);
+        String webdavpath = getWebdavPath(ver, supportsOAuth, supportsSamlSso);
+
+        if (baseurl == null || webdavpath == null) 
+            throw new AccountNotFoundException(account, "Account not found", null);
+        
+        return baseurl + webdavpath;
+    }
+    
+    
+    public static class AccountNotFoundException extends AccountsException {
+        
+        /** Generated - should be refreshed every time the class changes!! */
+        private static final long serialVersionUID = -9013287181793186830L;
+        
+        private Account mFailedAccount; 
+                
+        public AccountNotFoundException(Account failedAccount, String message, Throwable cause) {
+            super(message, cause);
+            mFailedAccount = failedAccount;
+        }
+        
+        public Account getFailedAccount() {
+            return mFailedAccount;
+        }
+    }
+
+}

+ 105 - 0
oc_framework/src/com/owncloud/android/oc_framework/accounts/OwnCloudAccount.java

@@ -0,0 +1,105 @@
+/* ownCloud Android client application
+ *   Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+package com.owncloud.android.oc_framework.accounts;
+
+import android.accounts.Account;
+import android.os.Parcel;
+import android.os.Parcelable;
+
+/**
+ * Account with extra information specific for ownCloud accounts.
+ * 
+ * TODO integrate in the main app
+ * 
+ * @author David A. Velasco
+ */
+public class OwnCloudAccount extends Account {
+
+	public static class Constants {
+	    /**
+	     * Value under this key should handle path to webdav php script. Will be
+	     * removed and usage should be replaced by combining
+	     * {@link com.owncloud.android.authentication.AuthenticatorActivity.KEY_OC_BASE_URL} and
+	     * {@link com.owncloud.android.oc_framework.utils.utils.OwnCloudVersion}
+	     * 
+	     * @deprecated
+	     */
+	    public static final String KEY_OC_URL = "oc_url";
+	    /**
+	     * Version should be 3 numbers separated by dot so it can be parsed by
+	     * {@link com.owncloud.android.oc_framework.utils.utils.OwnCloudVersion}
+	     */
+	    public static final String KEY_OC_VERSION = "oc_version";
+	    /**
+	     * Base url should point to owncloud installation without trailing / ie:
+	     * http://server/path or https://owncloud.server
+	     */
+	    public static final String KEY_OC_BASE_URL = "oc_base_url";
+	    /**
+	     * Flag signaling if the ownCloud server can be accessed with OAuth2 access tokens.
+	     */
+	    public static final String KEY_SUPPORTS_OAUTH2 = "oc_supports_oauth2";
+	    /**
+	     * Flag signaling if the ownCloud server can be accessed with session cookies from SAML-based web single-sign-on.
+	     */
+	    public static final String KEY_SUPPORTS_SAML_WEB_SSO = "oc_supports_saml_web_sso";
+	}
+	
+	private String mAuthTokenType;
+
+	public OwnCloudAccount(String name, String type, String authTokenType) {
+		super(name, type);
+		// TODO validate authTokentype as supported
+		mAuthTokenType = authTokenType;
+	}
+	
+    /**
+     * Reconstruct from parcel
+     * 
+     * @param source The source parcel
+     */
+	public OwnCloudAccount(Parcel source) {
+		super(source);
+        mAuthTokenType = source.readString();
+	}
+	
+    @Override
+    public void writeToParcel(Parcel dest, int flags) {
+    	super.writeToParcel(dest, flags);
+        dest.writeString(mAuthTokenType);
+    }
+	
+	
+	public String getAuthTokenType() {
+		return mAuthTokenType;
+	}
+
+	
+    public static final Parcelable.Creator<OwnCloudAccount> CREATOR = new Parcelable.Creator<OwnCloudAccount>() {
+        @Override
+        public OwnCloudAccount createFromParcel(Parcel source) {
+            return new OwnCloudAccount(source);
+        }
+
+        @Override
+        public OwnCloudAccount [] newArray(int size) {
+            return new OwnCloudAccount[size];
+        }
+    };
+	
+}

+ 6 - 5
src/com/owncloud/android/network/AdvancedSslSocketFactory.java → oc_framework/src/com/owncloud/android/oc_framework/network/AdvancedSslSocketFactory.java

@@ -16,7 +16,7 @@
  *
  */
 
-package com.owncloud.android.network;
+package com.owncloud.android.oc_framework.network;
 
 import java.io.IOException;
 import java.net.InetAddress;
@@ -39,7 +39,8 @@ import org.apache.commons.httpclient.params.HttpConnectionParams;
 import org.apache.commons.httpclient.protocol.ProtocolSocketFactory;
 import org.apache.http.conn.ssl.X509HostnameVerifier;
 
-import com.owncloud.android.Log_OC;
+import android.util.Log;
+
 
 
 /**
@@ -104,13 +105,13 @@ public class AdvancedSslSocketFactory implements ProtocolSocketFactory {
             final InetAddress localAddress, final int localPort,
             final HttpConnectionParams params) throws IOException,
             UnknownHostException, ConnectTimeoutException {
-        Log_OC.d(TAG, "Creating SSL Socket with remote " + host + ":" + port + ", local " + localAddress + ":" + localPort + ", params: " + params);
+        Log.d(TAG, "Creating SSL Socket with remote " + host + ":" + port + ", local " + localAddress + ":" + localPort + ", params: " + params);
         if (params == null) {
             throw new IllegalArgumentException("Parameters may not be null");
         } 
         int timeout = params.getConnectionTimeout();
         SocketFactory socketfactory = mSslContext.getSocketFactory();
-        Log_OC.d(TAG, " ... with connection timeout " + timeout + " and socket timeout " + params.getSoTimeout());
+        Log.d(TAG, " ... with connection timeout " + timeout + " and socket timeout " + params.getSoTimeout());
         Socket socket = socketfactory.createSocket();
         SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);
         SocketAddress remoteaddr = new InetSocketAddress(host, port);
@@ -126,7 +127,7 @@ public class AdvancedSslSocketFactory implements ProtocolSocketFactory {
      */
     public Socket createSocket(String host, int port) throws IOException,
             UnknownHostException {
-        Log_OC.d(TAG, "Creating SSL Socket with remote " + host + ":" + port);
+    	Log.d(TAG, "Creating SSL Socket with remote " + host + ":" + port);
         Socket socket = mSslContext.getSocketFactory().createSocket(host, port);
         verifyPeerIdentity(host, port, socket);
         return socket; 

+ 4 - 3
src/com/owncloud/android/network/AdvancedX509TrustManager.java → oc_framework/src/com/owncloud/android/oc_framework/network/AdvancedX509TrustManager.java

@@ -15,7 +15,7 @@
  *
  */
 
-package com.owncloud.android.network;
+package com.owncloud.android.oc_framework.network;
 
 import java.security.KeyStore;
 import java.security.KeyStoreException;
@@ -31,7 +31,8 @@ import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 import javax.net.ssl.X509TrustManager;
 
-import com.owncloud.android.Log_OC;
+import android.util.Log;
+
 
 
 /**
@@ -139,7 +140,7 @@ public class AdvancedX509TrustManager implements X509TrustManager {
         try {
             return (mKnownServersKeyStore.getCertificateAlias(cert) != null);
         } catch (KeyStoreException e) {
-            Log_OC.d(TAG, "Fail while checking certificate in the known-servers store");
+            Log.d(TAG, "Fail while checking certificate in the known-servers store");
             return false;
         }
     }

+ 9 - 6
src/com/owncloud/android/network/BearerAuthScheme.java → oc_framework/src/com/owncloud/android/oc_framework/network/BearerAuthScheme.java

@@ -1,3 +1,4 @@
+package com.owncloud.android.oc_framework.network;
 /* ownCloud Android client application
  *   Copyright (C) 2012  ownCloud Inc.
  *
@@ -15,7 +16,7 @@
  *
  */
 
-package com.owncloud.android.network;
+
 
 import java.util.Map;
 
@@ -27,7 +28,8 @@ import org.apache.commons.httpclient.auth.AuthenticationException;
 import org.apache.commons.httpclient.auth.InvalidCredentialsException;
 import org.apache.commons.httpclient.auth.MalformedChallengeException;
 
-import com.owncloud.android.Log_OC;
+import android.util.Log;
+
 
 
 /**
@@ -46,7 +48,8 @@ public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ {
     private boolean mComplete;
     
     /** Authentication parameter map */
-    private Map mParams = null;
+    @SuppressWarnings("rawtypes")
+	private Map mParams = null;
     
     
     /**
@@ -120,7 +123,7 @@ public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ {
      * @deprecated Use {@link #authenticate(Credentials, HttpMethod)}
      */
     public String authenticate(Credentials credentials, String method, String uri) throws AuthenticationException {
-        Log_OC.d(TAG, "enter BearerScheme.authenticate(Credentials, String, String)");
+        Log.d(TAG, "enter BearerScheme.authenticate(Credentials, String, String)");
 
         BearerCredentials bearer = null;
         try {
@@ -155,7 +158,7 @@ public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ {
      * @return a basic authorization string
      */
     public String authenticate(Credentials credentials, HttpMethod method) throws AuthenticationException {
-        Log_OC.d(TAG, "enter BearerScheme.authenticate(Credentials, HttpMethod)");
+        Log.d(TAG, "enter BearerScheme.authenticate(Credentials, HttpMethod)");
 
         if (method == null) {
             throw new IllegalArgumentException("Method may not be null");
@@ -199,7 +202,7 @@ public class BearerAuthScheme implements AuthScheme /*extends RFC2617Scheme*/ {
      * @since 3.0
      */
     public static String authenticate(BearerCredentials credentials, String charset) {
-        Log_OC.d(TAG, "enter BearerAuthScheme.authenticate(BearerCredentials, String)");
+        Log.d(TAG, "enter BearerAuthScheme.authenticate(BearerCredentials, String)");
 
         if (credentials == null) {
             throw new IllegalArgumentException("Credentials may not be null"); 

+ 2 - 1
src/com/owncloud/android/network/BearerCredentials.java → oc_framework/src/com/owncloud/android/oc_framework/network/BearerCredentials.java

@@ -1,3 +1,4 @@
+package com.owncloud.android.oc_framework.network;
 /* ownCloud Android client application
  *   Copyright (C) 2012  ownCloud Inc.
  *
@@ -15,7 +16,7 @@
  *
  */
 
-package com.owncloud.android.network;
+
 
 import org.apache.commons.httpclient.Credentials;
 import org.apache.commons.httpclient.util.LangUtils;

+ 2 - 1
src/com/owncloud/android/network/CertificateCombinedException.java → oc_framework/src/com/owncloud/android/oc_framework/network/CertificateCombinedException.java

@@ -1,3 +1,4 @@
+package com.owncloud.android.oc_framework.network;
 /* ownCloud Android client application
  *   Copyright (C) 2012-2013 ownCloud Inc.
  *
@@ -15,7 +16,7 @@
  *
  */
 
-package com.owncloud.android.network;
+
 
 import java.security.cert.CertPathValidatorException;
 import java.security.cert.CertificateException;

+ 168 - 0
oc_framework/src/com/owncloud/android/oc_framework/network/NetworkUtils.java

@@ -0,0 +1,168 @@
+/* ownCloud Android client application
+ *   Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package com.owncloud.android.oc_framework.network;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.GeneralSecurityException;
+import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.cert.Certificate;
+import java.security.cert.CertificateException;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.TrustManager;
+
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.protocol.Protocol;
+import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
+import org.apache.http.conn.ssl.X509HostnameVerifier;
+
+import android.content.Context;
+import android.util.Log;
+
+public class NetworkUtils {
+    
+    final private static String TAG = NetworkUtils.class.getSimpleName();
+    
+    /** Default timeout for waiting data from the server */
+    public static final int DEFAULT_DATA_TIMEOUT = 60000;
+    
+    /** Default timeout for establishing a connection */
+    public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
+
+    /** Connection manager for all the WebdavClients */
+    private static MultiThreadedHttpConnectionManager mConnManager = null;
+    
+    private static Protocol mDefaultHttpsProtocol = null;
+
+    private static AdvancedSslSocketFactory mAdvancedSslSocketFactory = null;
+
+    private static X509HostnameVerifier mHostnameVerifier = null;
+    
+    
+    /**
+     * Registers or unregisters the proper components for advanced SSL handling.
+     * @throws IOException 
+     */
+    public static void registerAdvancedSslContext(boolean register, Context context) throws GeneralSecurityException, IOException {
+        Protocol pr = null;
+        try {
+            pr = Protocol.getProtocol("https");
+            if (pr != null && mDefaultHttpsProtocol == null) {
+                mDefaultHttpsProtocol = pr;
+            }
+        } catch (IllegalStateException e) {
+            // nothing to do here; really
+        }
+        boolean isRegistered = (pr != null && pr.getSocketFactory() instanceof AdvancedSslSocketFactory);
+        if (register && !isRegistered) {
+            Protocol.registerProtocol("https", new Protocol("https", getAdvancedSslSocketFactory(context), 443));
+            
+        } else if (!register && isRegistered) {
+            if (mDefaultHttpsProtocol != null) {
+                Protocol.registerProtocol("https", mDefaultHttpsProtocol);
+            }
+        }
+    }
+    
+    public static AdvancedSslSocketFactory getAdvancedSslSocketFactory(Context context) throws GeneralSecurityException, IOException {
+        if (mAdvancedSslSocketFactory  == null) {
+            KeyStore trustStore = getKnownServersStore(context);
+            AdvancedX509TrustManager trustMgr = new AdvancedX509TrustManager(trustStore);
+            TrustManager[] tms = new TrustManager[] { trustMgr };
+                
+            SSLContext sslContext = SSLContext.getInstance("TLS");
+            sslContext.init(null, tms, null);
+                    
+            mHostnameVerifier = new BrowserCompatHostnameVerifier();
+            mAdvancedSslSocketFactory = new AdvancedSslSocketFactory(sslContext, trustMgr, mHostnameVerifier);
+        }
+        return mAdvancedSslSocketFactory;
+    }
+
+
+    private static String LOCAL_TRUSTSTORE_FILENAME = "knownServers.bks";
+    
+    private static String LOCAL_TRUSTSTORE_PASSWORD = "password";
+
+    private static KeyStore mKnownServersStore = null;
+    
+    /**
+     * Returns the local store of reliable server certificates, explicitly accepted by the user.
+     * 
+     * Returns a KeyStore instance with empty content if the local store was never created.
+     * 
+     * Loads the store from the storage environment if needed.
+     * 
+     * @param context                       Android context where the operation is being performed.
+     * @return                              KeyStore instance with explicitly-accepted server certificates. 
+     * @throws KeyStoreException            When the KeyStore instance could not be created.
+     * @throws IOException                  When an existing local trust store could not be loaded.
+     * @throws NoSuchAlgorithmException     When the existing local trust store was saved with an unsupported algorithm.
+     * @throws CertificateException         When an exception occurred while loading the certificates from the local trust store.
+     */
+    private static KeyStore getKnownServersStore(Context context) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
+        if (mKnownServersStore == null) {
+            //mKnownServersStore = KeyStore.getInstance("BKS");
+            mKnownServersStore = KeyStore.getInstance(KeyStore.getDefaultType());
+            File localTrustStoreFile = new File(context.getFilesDir(), LOCAL_TRUSTSTORE_FILENAME);
+            Log.d(TAG, "Searching known-servers store at " + localTrustStoreFile.getAbsolutePath());
+            if (localTrustStoreFile.exists()) {
+                InputStream in = new FileInputStream(localTrustStoreFile);
+                try {
+                    mKnownServersStore.load(in, LOCAL_TRUSTSTORE_PASSWORD.toCharArray());
+                } finally {
+                    in.close();
+                }
+            } else {
+                mKnownServersStore.load(null, LOCAL_TRUSTSTORE_PASSWORD.toCharArray()); // necessary to initialize an empty KeyStore instance
+            }
+        }
+        return mKnownServersStore;
+    }
+    
+    
+    public static void addCertToKnownServersStore(Certificate cert, Context context) throws  KeyStoreException, NoSuchAlgorithmException, 
+                                                                                            CertificateException, IOException {
+        KeyStore knownServers = getKnownServersStore(context);
+        knownServers.setCertificateEntry(Integer.toString(cert.hashCode()), cert);
+        FileOutputStream fos = null;
+        try {
+            fos = context.openFileOutput(LOCAL_TRUSTSTORE_FILENAME, Context.MODE_PRIVATE);
+            knownServers.store(fos, LOCAL_TRUSTSTORE_PASSWORD.toCharArray());
+        } finally {
+            fos.close();
+        }
+    }
+    
+    
+    static public MultiThreadedHttpConnectionManager getMultiThreadedConnManager() {
+        if (mConnManager == null) {
+            mConnManager = new MultiThreadedHttpConnectionManager();
+            mConnManager.getParams().setDefaultMaxConnectionsPerHost(5);
+            mConnManager.getParams().setMaxTotalConnections(5);
+        }
+        return mConnManager;
+    }
+
+
+}

+ 4 - 2
src/com/owncloud/android/network/ProgressiveDataTransferer.java → oc_framework/src/com/owncloud/android/oc_framework/network/ProgressiveDataTransferer.java

@@ -1,3 +1,4 @@
+package com.owncloud.android.oc_framework.network;
 /* ownCloud Android client application
  *   Copyright (C) 2012-2013 ownCloud Inc.
  *
@@ -15,11 +16,12 @@
  *
  */
 
-package com.owncloud.android.network;
+
 
 import java.util.Collection;
 
-import eu.alefzero.webdav.OnDatatransferProgressListener;
+import com.owncloud.android.oc_framework.network.webdav.OnDatatransferProgressListener;
+
 
 public interface ProgressiveDataTransferer {
 

+ 4 - 6
src/eu/alefzero/webdav/ChunkFromFileChannelRequestEntity.java → oc_framework/src/com/owncloud/android/oc_framework/network/webdav/ChunkFromFileChannelRequestEntity.java

@@ -15,7 +15,7 @@
  *
  */
 
-package eu.alefzero.webdav;
+package com.owncloud.android.oc_framework.network.webdav;
 
 import java.io.File;
 import java.io.IOException;
@@ -29,11 +29,9 @@ import java.util.Set;
 
 import org.apache.commons.httpclient.methods.RequestEntity;
 
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.network.ProgressiveDataTransferer;
+import com.owncloud.android.oc_framework.network.ProgressiveDataTransferer;
 
-
-import eu.alefzero.webdav.OnDatatransferProgressListener;
+import android.util.Log;
 
 
 /**
@@ -138,7 +136,7 @@ public class ChunkFromFileChannelRequestEntity implements RequestEntity, Progres
             }
             
         } catch (IOException io) {
-            Log_OC.e(TAG, io.getMessage());
+            Log.e(TAG, io.getMessage());
             throw new RuntimeException("Ugly solution to workaround the default policy of retries when the server falls while uploading ; temporal fix; really", io);   
             
         }

+ 4 - 6
src/eu/alefzero/webdav/FileRequestEntity.java → oc_framework/src/com/owncloud/android/oc_framework/network/webdav/FileRequestEntity.java

@@ -16,7 +16,7 @@
  *
  */
 
-package eu.alefzero.webdav;
+package com.owncloud.android.oc_framework.network.webdav;
 
 import java.io.File;
 import java.io.IOException;
@@ -31,11 +31,9 @@ import java.util.Set;
 
 import org.apache.commons.httpclient.methods.RequestEntity;
 
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.network.ProgressiveDataTransferer;
+import android.util.Log;
 
-
-import eu.alefzero.webdav.OnDatatransferProgressListener;
+import com.owncloud.android.oc_framework.network.ProgressiveDataTransferer;
 
 
 /**
@@ -122,7 +120,7 @@ public class FileRequestEntity implements RequestEntity, ProgressiveDataTransfer
             }
             
         } catch (IOException io) {
-            Log_OC.e("FileRequestException", io.getMessage());
+            Log.e("FileRequestException", io.getMessage());
             throw new RuntimeException("Ugly solution to workaround the default policy of retries when the server falls while uploading ; temporal fix; really", io);   
             
         } finally {

+ 1 - 1
src/eu/alefzero/webdav/OnDatatransferProgressListener.java → oc_framework/src/com/owncloud/android/oc_framework/network/webdav/OnDatatransferProgressListener.java

@@ -16,7 +16,7 @@
  *
  */
 
-package eu.alefzero.webdav;
+package com.owncloud.android.oc_framework.network.webdav;
 
 public interface OnDatatransferProgressListener {
     public void onTransferProgress(long progressRate);

+ 151 - 0
oc_framework/src/com/owncloud/android/oc_framework/network/webdav/OwnCloudClientFactory.java

@@ -0,0 +1,151 @@
+/* ownCloud Android client application
+ *   Copyright (C) 2012-2013 ownCloud Inc.
+ *
+ *   This program is free software: you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License version 2,
+ *   as published by the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package com.owncloud.android.oc_framework.network.webdav;
+
+import java.io.IOException;
+import java.security.GeneralSecurityException;
+
+import com.owncloud.android.oc_framework.accounts.AccountTypeUtils;
+import com.owncloud.android.oc_framework.accounts.AccountUtils;
+import com.owncloud.android.oc_framework.accounts.OwnCloudAccount;
+import com.owncloud.android.oc_framework.accounts.AccountUtils.AccountNotFoundException;
+import com.owncloud.android.oc_framework.network.NetworkUtils;
+
+import android.accounts.Account;
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerFuture;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
+import android.app.Activity;
+import android.content.Context;
+import android.net.Uri;
+import android.os.Bundle;
+import android.util.Log;
+
+public class OwnCloudClientFactory {
+    
+    final private static String TAG = OwnCloudClientFactory.class.getSimpleName();
+    
+    /** Default timeout for waiting data from the server */
+    public static final int DEFAULT_DATA_TIMEOUT = 60000;
+    
+    /** Default timeout for establishing a connection */
+    public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
+
+    
+    /**
+     * Creates a WebdavClient setup for an ownCloud account
+     * 
+     * Do not call this method from the main thread.
+     * 
+     * @param account                       The ownCloud account
+     * @param appContext                    Android application context
+     * @return                              A WebdavClient object ready to be used
+     * @throws AuthenticatorException       If the authenticator failed to get the authorization token for the account.
+     * @throws OperationCanceledException   If the authenticator operation was cancelled while getting the authorization token for the account. 
+     * @throws IOException                  If there was some I/O error while getting the authorization token for the account.
+     * @throws AccountNotFoundException     If 'account' is unknown for the AccountManager
+     */
+    public static WebdavClient createOwnCloudClient (Account account, Context appContext) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException {
+        //Log_OC.d(TAG, "Creating WebdavClient associated to " + account.name);
+       
+        Uri uri = Uri.parse(AccountUtils.constructFullURLForAccount(appContext, account));
+        AccountManager am = AccountManager.get(appContext);
+        boolean isOauth2 = am.getUserData(account, OwnCloudAccount.Constants.KEY_SUPPORTS_OAUTH2) != null;   // TODO avoid calling to getUserData here
+        boolean isSamlSso = am.getUserData(account, OwnCloudAccount.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
+        WebdavClient client = createOwnCloudClient(uri, appContext, !isSamlSso);
+        if (isOauth2) {    
+            String accessToken = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypeAccessToken(account.type), false);
+            client.setBearerCredentials(accessToken);   // TODO not assume that the access token is a bearer token
+        
+        } else if (isSamlSso) {    // TODO avoid a call to getUserData here
+            String accessToken = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type), false);
+            client.setSsoSessionCookie(accessToken);
+            
+        } else {
+            String username = account.name.substring(0, account.name.lastIndexOf('@'));
+            //String password = am.getPassword(account);
+            String password = am.blockingGetAuthToken(account, AccountTypeUtils.getAuthTokenTypePass(account.type), false);
+            client.setBasicCredentials(username, password);
+        }
+        
+        return client;
+    }
+    
+    
+    public static WebdavClient createOwnCloudClient (Account account, Context appContext, Activity currentActivity) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException {
+        Uri uri = Uri.parse(AccountUtils.constructFullURLForAccount(appContext, account));
+        AccountManager am = AccountManager.get(appContext);
+        boolean isOauth2 = am.getUserData(account, OwnCloudAccount.Constants.KEY_SUPPORTS_OAUTH2) != null;   // TODO avoid calling to getUserData here
+        boolean isSamlSso = am.getUserData(account, OwnCloudAccount.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null;
+        WebdavClient client = createOwnCloudClient(uri, appContext, !isSamlSso);
+        
+        if (isOauth2) {    // TODO avoid a call to getUserData here
+            AccountManagerFuture<Bundle> future =  am.getAuthToken(account,  AccountTypeUtils.getAuthTokenTypeAccessToken(account.type), null, currentActivity, null, null);
+            Bundle result = future.getResult();
+            String accessToken = result.getString(AccountManager.KEY_AUTHTOKEN);
+            if (accessToken == null) throw new AuthenticatorException("WTF!");
+            client.setBearerCredentials(accessToken);   // TODO not assume that the access token is a bearer token
+
+        } else if (isSamlSso) {    // TODO avoid a call to getUserData here
+            AccountManagerFuture<Bundle> future =  am.getAuthToken(account, AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type), null, currentActivity, null, null);
+            Bundle result = future.getResult();
+            String accessToken = result.getString(AccountManager.KEY_AUTHTOKEN);
+            if (accessToken == null) throw new AuthenticatorException("WTF!");
+            client.setSsoSessionCookie(accessToken);
+
+        } else {
+            String username = account.name.substring(0, account.name.lastIndexOf('@'));
+            //String password = am.getPassword(account);
+            //String password = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypePass(), false);
+            AccountManagerFuture<Bundle> future =  am.getAuthToken(account,  AccountTypeUtils.getAuthTokenTypePass(account.type), null, currentActivity, null, null);
+            Bundle result = future.getResult();
+            String password = result.getString(AccountManager.KEY_AUTHTOKEN);
+            client.setBasicCredentials(username, password);
+        }
+        
+        return client;
+    }
+    
+    /**
+     * Creates a WebdavClient to access a URL and sets the desired parameters for ownCloud client connections.
+     * 
+     * @param uri       URL to the ownCloud server
+     * @param context   Android context where the WebdavClient is being created.
+     * @return          A WebdavClient object ready to be used
+     */
+    public static WebdavClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) {
+        try {
+            NetworkUtils.registerAdvancedSslContext(true, context);
+        }  catch (GeneralSecurityException e) {
+            Log.e(TAG, "Advanced SSL Context could not be loaded. Default SSL management in the system will be used for HTTPS connections", e);
+            
+        } catch (IOException e) {
+            Log.e(TAG, "The local server truststore could not be read. Default SSL management in the system will be used for HTTPS connections", e);
+        }
+        
+        WebdavClient client = new WebdavClient(NetworkUtils.getMultiThreadedConnManager());
+        
+        client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
+        client.setBaseUri(uri);
+        client.setFollowRedirects(followRedirects);
+        
+        return client;
+    }
+    
+    
+}

+ 12 - 24
src/eu/alefzero/webdav/WebdavClient.java → oc_framework/src/com/owncloud/android/oc_framework/network/webdav/WebdavClient.java

@@ -16,7 +16,7 @@
  *
  */
 
-package eu.alefzero.webdav;
+package com.owncloud.android.oc_framework.network.webdav;
 
 import java.io.IOException;
 import java.io.InputStream;
@@ -41,14 +41,11 @@ import org.apache.commons.httpclient.params.HttpMethodParams;
 import org.apache.http.HttpStatus;
 import org.apache.http.params.CoreProtocolPNames;
 
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.MainApp;
-import com.owncloud.android.network.BearerAuthScheme;
-import com.owncloud.android.network.BearerCredentials;
-
-
+import com.owncloud.android.oc_framework.network.BearerAuthScheme;
+import com.owncloud.android.oc_framework.network.BearerCredentials;
 
 import android.net.Uri;
+import android.util.Log;
 
 public class WebdavClient extends HttpClient {
     private static final int MAX_REDIRECTIONS_COUNT = 3;
@@ -57,8 +54,7 @@ public class WebdavClient extends HttpClient {
     private Credentials mCredentials;
     private boolean mFollowRedirects;
     private String mSsoSessionCookie;
-    private String mAuthTokenType;
-    final private static String TAG = "WebdavClient";
+    final private static String TAG = WebdavClient.class.getSimpleName();
     public static final String USER_AGENT = "Android-ownCloud";
     
     static private byte[] sExhaustBuffer = new byte[1024];
@@ -68,12 +64,11 @@ public class WebdavClient extends HttpClient {
      */
     public WebdavClient(HttpConnectionManager connectionMgr) {
         super(connectionMgr);
-        Log_OC.d(TAG, "Creating WebdavClient");
+        Log.d(TAG, "Creating WebdavClient");
         getParams().setParameter(HttpMethodParams.USER_AGENT, USER_AGENT);
         getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
         mFollowRedirects = true;
         mSsoSessionCookie = null;
-        mAuthTokenType = MainApp.getAuthTokenTypePass();
     }
 
     public void setBearerCredentials(String accessToken) {
@@ -86,7 +81,6 @@ public class WebdavClient extends HttpClient {
         mCredentials = new BearerCredentials(accessToken);
         getState().setCredentials(AuthScope.ANY, mCredentials);
         mSsoSessionCookie = null;
-        mAuthTokenType = MainApp.getAuthTokenTypeAccessToken();
     }
 
     public void setBasicCredentials(String username, String password) {
@@ -98,7 +92,6 @@ public class WebdavClient extends HttpClient {
         mCredentials = new UsernamePasswordCredentials(username, password);
         getState().setCredentials(AuthScope.ANY, mCredentials);
         mSsoSessionCookie = null;
-        mAuthTokenType = MainApp.getAuthTokenTypePass();
     }
     
     public void setSsoSessionCookie(String accessToken) {
@@ -106,7 +99,6 @@ public class WebdavClient extends HttpClient {
         getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
         mSsoSessionCookie = accessToken;
         mCredentials = null;
-        mAuthTokenType = MainApp.getAuthTokenTypeSamlSessionCookie();
     }
     
     
@@ -122,7 +114,7 @@ public class WebdavClient extends HttpClient {
         HeadMethod head = new HeadMethod(mUri.toString() + WebdavUtils.encodePath(path));
         try {
             int status = executeMethod(head);
-            Log_OC.d(TAG, "HEAD to " + path + " finished with HTTP status " + status + ((status != HttpStatus.SC_OK)?"(FAIL)":""));
+            Log.d(TAG, "HEAD to " + path + " finished with HTTP status " + status + ((status != HttpStatus.SC_OK)?"(FAIL)":""));
             exhaustResponse(head.getResponseBodyAsStream());
             return (status == HttpStatus.SC_OK);
             
@@ -186,13 +178,13 @@ public class WebdavClient extends HttpClient {
             
             Header location = method.getResponseHeader("Location");
             if (location != null) {
-                Log_OC.d(TAG,  "Location to redirect: " + location.getValue());
+                Log.d(TAG,  "Location to redirect: " + location.getValue());
                 method.setURI(new URI(location.getValue(), true));
                 status = super.executeMethod(method);
                 redirectionsCount++;
                 
             } else {
-                Log_OC.d(TAG,  "No location to redirect!");
+                Log.d(TAG,  "No location to redirect!");
                 status = HttpStatus.SC_NOT_FOUND;
             }
         }
@@ -213,7 +205,7 @@ public class WebdavClient extends HttpClient {
                 responseBodyAsStream.close();
             
             } catch (IOException io) {
-                Log_OC.e(TAG, "Unexpected exception while exhausting not interesting HTTP response; will be IGNORED", io);
+                Log.e(TAG, "Unexpected exception while exhausting not interesting HTTP response; will be IGNORED", io);
             }
         }
     }
@@ -238,8 +230,8 @@ public class WebdavClient extends HttpClient {
         return mUri;
     }
 
-    public final Credentials getCredentials() {
-        return mCredentials;
+    public final Credentials getCredentials() {
+        return mCredentials;
     }
     
     public final String getSsoSessionCookie() {
@@ -250,8 +242,4 @@ public class WebdavClient extends HttpClient {
         mFollowRedirects = followRedirects;
     }
 
-    public String getAuthTokenType() {
-        return mAuthTokenType;
-    }
-
 }

+ 3 - 3
src/eu/alefzero/webdav/WebdavEntry.java → oc_framework/src/com/owncloud/android/oc_framework/network/webdav/WebdavEntry.java

@@ -14,7 +14,7 @@
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
-package eu.alefzero.webdav;
+package com.owncloud.android.oc_framework.network.webdav;
 
 import java.util.Date;
 
@@ -23,10 +23,10 @@ import org.apache.jackrabbit.webdav.property.DavProperty;
 import org.apache.jackrabbit.webdav.property.DavPropertyName;
 import org.apache.jackrabbit.webdav.property.DavPropertySet;
 
-import com.owncloud.android.Log_OC;
 
 
 import android.net.Uri;
+import android.util.Log;
 
 public class WebdavEntry {
     private String mName, mPath, mUri, mContentType, mEtag;
@@ -98,7 +98,7 @@ public class WebdavEntry {
             }
 
         } else {
-            Log_OC.e("WebdavEntry",
+            Log.e("WebdavEntry",
                     "General fuckup, no status for webdav response");
         }
     }

+ 1 - 1
src/eu/alefzero/webdav/WebdavUtils.java → oc_framework/src/com/owncloud/android/oc_framework/network/webdav/WebdavUtils.java

@@ -16,7 +16,7 @@
  *
  */
 
-package eu.alefzero.webdav;
+package com.owncloud.android.oc_framework.network.webdav;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;

+ 1 - 1
src/com/owncloud/android/operations/OnRemoteOperationListener.java → oc_framework/src/com/owncloud/android/oc_framework/operations/OnRemoteOperationListener.java

@@ -16,7 +16,7 @@
  *
  */
 
-package com.owncloud.android.operations;
+package com.owncloud.android.oc_framework.operations;
 
 public interface OnRemoteOperationListener {
 

+ 1 - 1
src/com/owncloud/android/operations/OperationCancelledException.java → oc_framework/src/com/owncloud/android/oc_framework/operations/OperationCancelledException.java

@@ -16,7 +16,7 @@
  *
  */
 
-package com.owncloud.android.operations;
+package com.owncloud.android.oc_framework.operations;
 
 public class OperationCancelledException extends Exception {
 

+ 15 - 15
src/com/owncloud/android/operations/RemoteOperation.java → oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperation.java

@@ -14,17 +14,17 @@
  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  */
-package com.owncloud.android.operations;
+package com.owncloud.android.oc_framework.operations;
 
 import java.io.IOException;
 
 import org.apache.commons.httpclient.Credentials;
 
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.MainApp;
-import com.owncloud.android.network.BearerCredentials;
-import com.owncloud.android.network.OwnCloudClientUtils;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.network.BearerCredentials;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
+
 
 
 import android.accounts.Account;
@@ -33,8 +33,8 @@ import android.accounts.AccountsException;
 import android.app.Activity;
 import android.content.Context;
 import android.os.Handler;
+import android.util.Log;
 
-import eu.alefzero.webdav.WebdavClient;
 
 /**
  * Operation which execution involves one or several interactions with an ownCloud server.
@@ -91,9 +91,9 @@ public abstract class RemoteOperation implements Runnable {
         mAccount = account;
         mContext = context.getApplicationContext();
         try {
-            mClient = OwnCloudClientUtils.createOwnCloudClient(mAccount, mContext);
+            mClient = OwnCloudClientFactory.createOwnCloudClient(mAccount, mContext);
         } catch (Exception e) {
-            Log_OC.e(TAG, "Error while trying to access to " + mAccount.name, e);
+            Log.e(TAG, "Error while trying to access to " + mAccount.name, e);
             return new RemoteOperationResult(e);
         }
         return run(mClient);
@@ -215,9 +215,9 @@ public abstract class RemoteOperation implements Runnable {
                 if (mClient == null) {
                     if (mAccount != null && mContext != null) {
                         if (mCallerActivity != null) {
-                            mClient = OwnCloudClientUtils.createOwnCloudClient(mAccount, mContext, mCallerActivity);
+                            mClient = OwnCloudClientFactory.createOwnCloudClient(mAccount, mContext, mCallerActivity);
                         } else {
-                            mClient = OwnCloudClientUtils.createOwnCloudClient(mAccount, mContext);
+                            mClient = OwnCloudClientFactory.createOwnCloudClient(mAccount, mContext);
                         }
                     } else {
                         throw new IllegalStateException("Trying to run a remote operation asynchronously with no client instance or account");
@@ -225,11 +225,11 @@ public abstract class RemoteOperation implements Runnable {
                 }
             
             } catch (IOException e) {
-                Log_OC.e(TAG, "Error while trying to access to " + mAccount.name, new AccountsException("I/O exception while trying to authorize the account", e));
+                Log.e(TAG, "Error while trying to access to " + mAccount.name, new AccountsException("I/O exception while trying to authorize the account", e));
                 result = new RemoteOperationResult(e);
             
             } catch (AccountsException e) {
-                Log_OC.e(TAG, "Error while trying to access to " + mAccount.name, e);
+                Log.e(TAG, "Error while trying to access to " + mAccount.name, e);
                 result = new RemoteOperationResult(e);
             }
     	
@@ -249,9 +249,9 @@ public abstract class RemoteOperation implements Runnable {
                     boolean bearerAuthorization = (cred != null && cred instanceof BearerCredentials);
                     boolean samlBasedSsoAuthorization = (cred == null && ssoSessionCookie != null);
                     if (bearerAuthorization) {
-                        am.invalidateAuthToken(MainApp.getAccountType(), ((BearerCredentials)cred).getAccessToken());
+                        am.invalidateAuthToken(mAccount.type, ((BearerCredentials)cred).getAccessToken());
                     } else if (samlBasedSsoAuthorization ) {
-                        am.invalidateAuthToken(MainApp.getAccountType(), ssoSessionCookie);
+                        am.invalidateAuthToken(mAccount.type, ssoSessionCookie);
                     } else {
                         am.clearPassword(mAccount);
                     }

+ 9 - 6
src/com/owncloud/android/operations/RemoteOperationResult.java → oc_framework/src/com/owncloud/android/oc_framework/operations/RemoteOperationResult.java

@@ -16,7 +16,7 @@
  *
  */
 
-package com.owncloud.android.operations;
+package com.owncloud.android.oc_framework.operations;
 
 import java.io.IOException;
 import java.io.Serializable;
@@ -33,12 +33,12 @@ import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.jackrabbit.webdav.DavException;
 
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
-import com.owncloud.android.network.CertificateCombinedException;
+import com.owncloud.android.oc_framework.accounts.AccountUtils.AccountNotFoundException;
+import com.owncloud.android.oc_framework.network.CertificateCombinedException;
 
 import android.accounts.Account;
 import android.accounts.AccountsException;
+import android.util.Log;
 
 
 /**
@@ -89,7 +89,8 @@ public class RemoteOperationResult implements Serializable {
         ACCOUNT_NOT_FOUND, 
         ACCOUNT_EXCEPTION, 
         ACCOUNT_NOT_NEW, 
-        ACCOUNT_NOT_THE_SAME
+        ACCOUNT_NOT_THE_SAME,
+        INVALID_CHARACTER_IN_NAME
     }
 
     private boolean mSuccess = false;
@@ -129,7 +130,7 @@ public class RemoteOperationResult implements Serializable {
                 break;
             default:
                 mCode = ResultCode.UNHANDLED_HTTP_CODE;
-                Log_OC.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode);
+                Log.d(TAG, "RemoteOperationResult has processed UNHANDLED_HTTP_CODE: " + httpCode);
             }
         }
     }
@@ -307,6 +308,8 @@ public class RemoteOperationResult implements Serializable {
 
         } else if (mCode == ResultCode.ACCOUNT_NOT_THE_SAME) {
             return "Authenticated with a different account than the one updating";
+        } else if (mCode == ResultCode.INVALID_CHARACTER_IN_NAME) {
+        	return "The file name contains an forbidden character";
         }
 
         return "Operation finished with HTTP status code " + mHttpCode + " (" + (isSuccess() ? "success" : "fail") + ")";

+ 94 - 0
oc_framework/src/com/owncloud/android/oc_framework/operations/remote/CreateRemoteFolderOperation.java

@@ -0,0 +1,94 @@
+package com.owncloud.android.oc_framework.operations.remote;
+
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
+
+import android.util.Log;
+
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.utils.FileUtils;
+
+
+
+/**
+ * Remote operation performing the creation of a new folder in the ownCloud server.
+ * 
+ * @author David A. Velasco 
+ * @author masensio
+ *
+ */
+public class CreateRemoteFolderOperation extends RemoteOperation {
+    
+    private static final String TAG = CreateRemoteFolderOperation.class.getSimpleName();
+
+    private static final int READ_TIMEOUT = 10000;
+    private static final int CONNECTION_TIMEOUT = 5000;
+    
+
+    protected String mRemotePath;
+    protected boolean mCreateFullPath;
+    
+    /**
+     * Constructor
+     * 
+     * @param remotePath            Full path to the new directory to create in the remote server.
+     * @param createFullPath        'True' means that all the ancestor folders should be created if don't exist yet.
+     */
+    public CreateRemoteFolderOperation(String remotePath, boolean createFullPath) {
+        mRemotePath = remotePath;
+        mCreateFullPath = createFullPath;
+    }
+
+    /**
+     * Performs the operation
+     * 
+     * @param   client      Client object to communicate with the remote ownCloud server.
+     */
+    @Override
+    protected RemoteOperationResult run(WebdavClient client) {
+        RemoteOperationResult result = null;
+        MkColMethod mkcol = null;
+        
+        boolean noInvalidChars = FileUtils.isValidPath(mRemotePath);
+        if (noInvalidChars) {
+        	try {
+        		mkcol = new MkColMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath));
+        		int status =  client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
+        		if (!mkcol.succeeded() && mkcol.getStatusCode() == HttpStatus.SC_CONFLICT && mCreateFullPath) {
+        			result = createParentFolder(FileUtils.getParentPath(mRemotePath), client);
+        			status = client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);    // second (and last) try
+        		}
+
+        		result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders());
+        		Log.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
+        		client.exhaustResponse(mkcol.getResponseBodyAsStream());
+
+        	} catch (Exception e) {
+        		result = new RemoteOperationResult(e);
+        		Log.e(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage(), e);
+
+        	} finally {
+        		if (mkcol != null)
+        			mkcol.releaseConnection();
+        	}
+        } else {
+        	result = new RemoteOperationResult(ResultCode.INVALID_CHARACTER_IN_NAME);
+        }
+        
+        return result;
+    }
+
+    
+    private RemoteOperationResult createParentFolder(String parentPath, WebdavClient client) {
+        RemoteOperation operation = new CreateRemoteFolderOperation(parentPath,
+                                                                mCreateFullPath);
+        return operation.execute(client);
+    }
+    
+   
+
+}

+ 52 - 0
oc_framework/src/com/owncloud/android/oc_framework/utils/FileUtils.java

@@ -0,0 +1,52 @@
+package com.owncloud.android.oc_framework.utils;
+
+import java.io.File;
+
+import android.util.Log;
+
+public class FileUtils {
+
+	public static final String PATH_SEPARATOR = "/";
+
+
+	public static String getParentPath(String remotePath) {
+		String parentPath = new File(remotePath).getParent();
+		parentPath = parentPath.endsWith(PATH_SEPARATOR) ? parentPath : parentPath + PATH_SEPARATOR;
+		return parentPath;
+	}
+	
+	/**
+	 * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , : , " , | , ? , *
+	 * @param fileName
+	 * @return
+	 */
+	public static boolean isValidName(String fileName) {
+		boolean result = true;
+		
+		Log.d("FileUtils", "fileName =======" + fileName);
+		if (fileName.contains(PATH_SEPARATOR) ||
+				fileName.contains("\\") || fileName.contains("<") || fileName.contains(">") ||
+				fileName.contains(":") || fileName.contains("\"") || fileName.contains("|") || 
+				fileName.contains("?") || fileName.contains("*")) {
+			result = false;
+		}
+		return result;
+	}
+	
+	/**
+	 * Validate the path to detect if contains any forbidden character: \ , < , > , : , " , | , ? , *
+	 * @param path
+	 * @return
+	 */
+	public static boolean isValidPath(String path) {
+		boolean result = true;
+		
+		Log.d("FileUtils", "path ....... " + path);
+		if (path.contains("\\") || path.contains("<") || path.contains(">") ||
+				path.contains(":") || path.contains("\"") || path.contains("|") || 
+				path.contains("?") || path.contains("*")) {
+			result = false;
+		}
+		return result;
+	}
+}

+ 1 - 1
src/com/owncloud/android/utils/OwnCloudVersion.java → oc_framework/src/com/owncloud/android/oc_framework/utils/OwnCloudVersion.java

@@ -16,7 +16,7 @@
  *
  */
 
-package com.owncloud.android.utils;
+package com.owncloud.android.oc_framework.utils;
 
 public class OwnCloudVersion implements Comparable<OwnCloudVersion> {
     public static final OwnCloudVersion owncloud_v1 = new OwnCloudVersion(

+ 2 - 1
project.properties

@@ -9,4 +9,5 @@
 
 # Project target.
 target=android-19
-android.library.reference.1=actionbarsherlock/library
+android.library.reference.1=actionbarsherlock\\library
+android.library.reference.2=oc_framework

+ 1 - 0
res/values/strings.xml

@@ -182,6 +182,7 @@
     <string name="sync_file_fail_msg">Remote file could not be checked</string>
     <string name="sync_file_nothing_to_do_msg">File contents already synchronized</string>
     <string name="create_dir_fail_msg">Directory could not be created</string>
+    <string name="filename_forbidden_characters">Forbidden characters: / \\ &lt; &gt; : " | ? *</string>
     <string name="wait_a_moment">Wait a moment</string>
     <string name="filedisplay_unexpected_bad_get_content">"Unexpected problem ; please select the file from a different app"</string>
     <string name="filedisplay_no_file_selected">No file was selected</string>

+ 1 - 0
setup_env.bat

@@ -1,6 +1,7 @@
 call git submodule init
 call git submodule update
 call android.bat update project -p actionbarsherlock\library -n ActionBarSherlock
+call android.bat update project -p oc_framework -n ownCloudFramework
 call android.bat update project -p .
 call android.bat update project -p oc_jb_workaround
 copy /Y third_party\android-support-library\android-support-v4.jar actionbarsherlock\library\libs\android-support-v4.jar

+ 1 - 0
setup_env.sh

@@ -3,6 +3,7 @@
 git submodule init
 git submodule update
 android update project -p actionbarsherlock/library -n ActionBarSherlock
+android update project -p oc_framework -n ownCloudFramework
 android update project -p .
 android update project -p oc_jb_workaround
 cp third_party/android-support-library/android-support-v4.jar actionbarsherlock/library/libs/android-support-v4.jar 

+ 0 - 24
src/com/owncloud/android/MainApp.java

@@ -57,30 +57,6 @@ public class MainApp extends Application {
         return getAppContext().getResources().getString(R.string.authority);
     }
     
-    //  From AccountAuthenticator
-    //  public static final String AUTH_TOKEN_TYPE_PASSWORD = "owncloud.password";
-    public static String getAuthTokenTypePass() {
-        return getAppContext().getResources().getString(R.string.account_type) + ".password";
-    }
-    
-    //  From AccountAuthenticator
-    //  public static final String AUTH_TOKEN_TYPE_ACCESS_TOKEN = "owncloud.oauth2.access_token";
-    public static String getAuthTokenTypeAccessToken() {
-        return getAppContext().getResources().getString(R.string.account_type) + ".oauth2.access_token";
-    }
-    
-    //  From AccountAuthenticator
-    //  public static final String AUTH_TOKEN_TYPE_REFRESH_TOKEN = "owncloud.oauth2.refresh_token";
-    public static String getAuthTokenTypeRefreshToken() {
-        return getAppContext().getResources().getString(R.string.account_type) + ".oauth2.refresh_token";
-    }
-    
-    //  From AccountAuthenticator
-    //  public static final String AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE = "owncloud.saml.web_sso.session_cookie";
-    public static String getAuthTokenTypeSamlSessionCookie() {
-        return getAppContext().getResources().getString(R.string.account_type) +  ".saml.web_sso.session_cookie";
-    }
-    
     //  From ProviderMeta 
     //  public static final String DB_FILE = "owncloud.db";
     public static String getDBFile() {

+ 7 - 35
src/com/owncloud/android/authentication/AccountAuthenticator.java

@@ -18,7 +18,6 @@
 
 package com.owncloud.android.authentication;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 
@@ -29,7 +28,8 @@ import android.os.Bundle;
 import android.os.Handler;
 import android.widget.Toast;
 
-
+import com.owncloud.android.oc_framework.accounts.AccountTypeUtils;
+import com.owncloud.android.utils.Log_OC;
 
 
 /**
@@ -53,34 +53,6 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
     public static final String KEY_LOGIN_OPTIONS = "loginOptions";
     public static final String KEY_ACCOUNT = "account";
     
-    /**
-     * Value under this key should handle path to webdav php script. Will be
-     * removed and usage should be replaced by combining
-     * {@link com.owncloud.android.authentication.AuthenticatorActivity.KEY_OC_BASE_URL} and
-     * {@link com.owncloud.android.utils.OwnCloudVersion}
-     * 
-     * @deprecated
-     */
-    public static final String KEY_OC_URL = "oc_url";
-    /**
-     * Version should be 3 numbers separated by dot so it can be parsed by
-     * {@link com.owncloud.android.utils.OwnCloudVersion}
-     */
-    public static final String KEY_OC_VERSION = "oc_version";
-    /**
-     * Base url should point to owncloud installation without trailing / ie:
-     * http://server/path or https://owncloud.server
-     */
-    public static final String KEY_OC_BASE_URL = "oc_base_url";
-    /**
-     * Flag signaling if the ownCloud server can be accessed with OAuth2 access tokens.
-     */
-    public static final String KEY_SUPPORTS_OAUTH2 = "oc_supports_oauth2";
-    /**
-     * Flag signaling if the ownCloud server can be accessed with session cookies from SAML-based web single-sign-on.
-     */
-    public static final String KEY_SUPPORTS_SAML_WEB_SSO = "oc_supports_saml_web_sso";
-    
     private static final String TAG = AccountAuthenticator.class.getSimpleName();
     
     private Context mContext;
@@ -204,7 +176,7 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
         /// check if required token is stored
         final AccountManager am = AccountManager.get(mContext);
         String accessToken;
-        if (authTokenType.equals(MainApp.getAuthTokenTypePass())) {
+        if (authTokenType.equals(AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType()))) {
             accessToken = am.getPassword(account);
         } else {
             accessToken = am.peekAuthToken(account, authTokenType);
@@ -285,10 +257,10 @@ public class AccountAuthenticator extends AbstractAccountAuthenticator {
     private void validateAuthTokenType(String authTokenType)
             throws UnsupportedAuthTokenTypeException {
         if (!authTokenType.equals(MainApp.getAuthTokenType()) &&
-            !authTokenType.equals(MainApp.getAuthTokenTypePass()) &&
-            !authTokenType.equals(MainApp.getAuthTokenTypeAccessToken()) &&
-            !authTokenType.equals(MainApp.getAuthTokenTypeRefreshToken()) &&
-            !authTokenType.equals(MainApp.getAuthTokenTypeSamlSessionCookie())) {
+            !authTokenType.equals(AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType())) &&
+            !authTokenType.equals(AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType())) &&
+            !authTokenType.equals(AccountTypeUtils.getAuthTokenTypeRefreshToken(MainApp.getAccountType())) &&
+            !authTokenType.equals(AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()))) {
             throw new UnsupportedAuthTokenTypeException();
         }
     }

+ 4 - 68
src/com/owncloud/android/authentication/AccountUtils.java

@@ -19,11 +19,11 @@
 package com.owncloud.android.authentication;
 
 import com.owncloud.android.MainApp;
-import com.owncloud.android.utils.OwnCloudVersion;
+import com.owncloud.android.oc_framework.accounts.AccountTypeUtils;
+import com.owncloud.android.oc_framework.utils.OwnCloudVersion;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
-import android.accounts.AccountsException;
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.preference.PreferenceManager;
@@ -126,30 +126,6 @@ public class AccountUtils {
         return result;
     }
 
-    /**
-     * 
-     * @param version version of owncloud
-     * @return webdav path for given OC version, null if OC version unknown
-     */
-    public static String getWebdavPath(OwnCloudVersion version, boolean supportsOAuth, boolean supportsSamlSso) {
-        if (version != null) {
-            if (supportsOAuth) {
-                return ODAV_PATH;
-            }
-            if (supportsSamlSso) {
-                return SAML_SSO_PATH;
-            }
-            if (version.compareTo(OwnCloudVersion.owncloud_v4) >= 0)
-                return WEBDAV_PATH_4_0;
-            if (version.compareTo(OwnCloudVersion.owncloud_v3) >= 0
-                    || version.compareTo(OwnCloudVersion.owncloud_v2) >= 0)
-                return WEBDAV_PATH_2_0;
-            if (version.compareTo(OwnCloudVersion.owncloud_v1) >= 0)
-                return WEBDAV_PATH_1_2;
-        }
-        return null;
-    }
-    
     /**
      * Returns the proper URL path to access the WebDAV interface of an ownCloud server,
      * according to its version and the authorization method used.
@@ -160,10 +136,10 @@ public class AccountUtils {
      */
     public static String getWebdavPath(OwnCloudVersion version, String authTokenType) {
         if (version != null) {
-            if (MainApp.getAuthTokenTypeAccessToken().equals(authTokenType)) {
+            if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(authTokenType)) {
                 return ODAV_PATH;
             }
-            if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(authTokenType)) {
+            if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(authTokenType)) {
                 return SAML_SSO_PATH;
             }
             if (version.compareTo(OwnCloudVersion.owncloud_v4) >= 0)
@@ -177,44 +153,4 @@ public class AccountUtils {
         return null;
     }
     
-    /**
-     * Constructs full url to host and webdav resource basing on host version
-     * @param context
-     * @param account
-     * @return url or null on failure
-     * @throws AccountNotFoundException     When 'account' is unknown for the AccountManager
-     */
-    public static String constructFullURLForAccount(Context context, Account account) throws AccountNotFoundException {
-        AccountManager ama = AccountManager.get(context);
-        String baseurl = ama.getUserData(account, AccountAuthenticator.KEY_OC_BASE_URL);
-        String strver  = ama.getUserData(account, AccountAuthenticator.KEY_OC_VERSION);
-        boolean supportsOAuth = (ama.getUserData(account, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null);
-        boolean supportsSamlSso = (ama.getUserData(account, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO) != null);
-        OwnCloudVersion ver = new OwnCloudVersion(strver);
-        String webdavpath = getWebdavPath(ver, supportsOAuth, supportsSamlSso);
-
-        if (baseurl == null || webdavpath == null) 
-            throw new AccountNotFoundException(account, "Account not found", null);
-        
-        return baseurl + webdavpath;
-    }
-    
-    
-    public static class AccountNotFoundException extends AccountsException {
-        
-        /** Generated - should be refreshed every time the class changes!! */
-        private static final long serialVersionUID = -9013287181793186830L;
-        
-        private Account mFailedAccount; 
-                
-        public AccountNotFoundException(Account failedAccount, String message, Throwable cause) {
-            super(message, cause);
-            mFailedAccount = failedAccount;
-        }
-        
-        public Account getFailedAccount() {
-            return mFailedAccount;
-        }
-    }
-
 }

+ 45 - 45
src/com/owncloud/android/authentication/AuthenticatorActivity.java

@@ -51,25 +51,25 @@ import android.widget.TextView;
 import android.widget.TextView.OnEditorActionListener;
 
 import com.actionbarsherlock.app.SherlockDialogFragment;
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.SsoWebViewClient.SsoWebViewClientListener;
-import com.owncloud.android.network.OwnCloudClientUtils;
+import com.owncloud.android.oc_framework.accounts.AccountTypeUtils;
+import com.owncloud.android.oc_framework.accounts.OwnCloudAccount;
+import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
 import com.owncloud.android.operations.ExistenceCheckOperation;
 import com.owncloud.android.operations.OAuth2GetAccessToken;
-import com.owncloud.android.operations.OnRemoteOperationListener;
+import com.owncloud.android.oc_framework.operations.OnRemoteOperationListener;
 import com.owncloud.android.operations.OwnCloudServerCheckOperation;
-import com.owncloud.android.operations.RemoteOperation;
-import com.owncloud.android.operations.RemoteOperationResult;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.ui.dialog.SamlWebViewDialog;
 import com.owncloud.android.ui.dialog.SslValidatorDialog;
 import com.owncloud.android.ui.dialog.SslValidatorDialog.OnSslValidatorListener;
-import com.owncloud.android.utils.OwnCloudVersion;
-
-
-import eu.alefzero.webdav.WebdavClient;
+import com.owncloud.android.utils.Log_OC;
+import com.owncloud.android.oc_framework.utils.OwnCloudVersion;
 
 /**
  * This Activity is used to add an ownCloud account to the App
@@ -236,11 +236,11 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             /// retrieve extras from intent
             mAccount = getIntent().getExtras().getParcelable(EXTRA_ACCOUNT);
             if (mAccount != null) {
-                String ocVersion = mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION);
+                String ocVersion = mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_VERSION);
                 if (ocVersion != null) {
                     mDiscoveredVersion = new OwnCloudVersion(ocVersion);
                 }
-                mHostBaseUrl = normalizeUrl(mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL));
+                mHostBaseUrl = normalizeUrl(mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_BASE_URL));
                 mHostUrlInput.setText(mHostBaseUrl);
                 String userName = mAccount.name.substring(0, mAccount.name.lastIndexOf('@'));
                 mUsernameInput.setText(userName);
@@ -279,7 +279,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mAccount = savedInstanceState.getParcelable(KEY_ACCOUNT);
             mAuthTokenType = savedInstanceState.getString(AccountAuthenticator.KEY_AUTH_TOKEN_TYPE);
             if (mAuthTokenType == null) {
-                mAuthTokenType =  MainApp.getAuthTokenTypePass();
+                mAuthTokenType =  AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());
                 
             }
 
@@ -317,7 +317,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         if (mServerIsChecked && !mServerIsValid && refreshButtonEnabled) showRefreshButton();
         mOkButton.setEnabled(mServerIsValid); // state not automatically recovered in configuration changes
 
-        if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) || 
+        if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType) || 
                 !AUTH_OPTIONAL.equals(getString(R.string.auth_method_oauth2))) {
             mOAuth2Check.setVisibility(View.GONE);
         }
@@ -369,7 +369,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             @Override
             public boolean onTouch(View view, MotionEvent event) {
                 if (event.getAction() == MotionEvent.ACTION_DOWN) {
-                    if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) &&
+                    if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType) &&
                             mHostUrlInput.hasFocus()) {
                         checkOcServer();
                     }
@@ -393,8 +393,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         if (mAuthTokenType == null) {    
             if (mAccount != null) {
                 /// same authentication method than the one used to create the account to update
-                oAuthRequired = (mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null);
-                samlWebSsoRequired = (mAccountMgr.getUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO) != null);
+                oAuthRequired = (mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_OAUTH2) != null);
+                samlWebSsoRequired = (mAccountMgr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null);
             
             } else {
                 /// use the one set in setup.xml
@@ -402,11 +402,11 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 samlWebSsoRequired = AUTH_ON.equals(getString(R.string.auth_method_saml_web_sso));            
             }
             if (oAuthRequired) {
-                mAuthTokenType = MainApp.getAuthTokenTypeAccessToken();
+                mAuthTokenType = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());
             } else if (samlWebSsoRequired) {
-                mAuthTokenType = MainApp.getAuthTokenTypeSamlSessionCookie();
+                mAuthTokenType = AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType());
             } else {
-                mAuthTokenType = MainApp.getAuthTokenTypePass();
+                mAuthTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());
             }
         }
     
@@ -415,7 +415,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mUsernameInput.setText(userName);
         }
         
-        mOAuth2Check.setChecked(MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType));
+        mOAuth2Check.setChecked(AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType));
         
     }
 
@@ -488,10 +488,10 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     protected void onResume() {
         super.onResume();
         if (mAction == ACTION_UPDATE_TOKEN && mJustCreated && getIntent().getBooleanExtra(EXTRA_ENFORCED_UPDATE, false)) {
-            if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) {
+            if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) {
                 //Toast.makeText(this, R.string.auth_expired_oauth_token_toast, Toast.LENGTH_LONG).show();
                 showAuthMessage(getString(R.string.auth_expired_oauth_token_toast));
-            } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {
+            } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {
                 //Toast.makeText(this, R.string.auth_expired_saml_sso_token_toast, Toast.LENGTH_LONG).show();
                 showAuthMessage(getString(R.string.auth_expired_saml_sso_token_toast));
             } else {
@@ -527,7 +527,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 getString(R.string.oauth2_grant_type),
                 queryParameters);
         //WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(getString(R.string.oauth2_url_endpoint_access)), getApplicationContext());
-        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mOAuthTokenEndpointText.getText().toString().trim()), getApplicationContext(), true);
+        WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mOAuthTokenEndpointText.getText().toString().trim()), getApplicationContext(), true);
         operation.execute(client, this, mHandler);
     }
 
@@ -591,7 +591,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mServerStatusIcon = R.drawable.progress_small;
             showServerStatus();
             mOcServerChkOperation = new  OwnCloudServerCheckOperation(uri, this);
-            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(uri), this, true);
+            WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(uri), this, true);
             mOperationThread = mOcServerChkOperation.execute(client, this, mHandler);
         } else {
             mServerStatusText = 0;
@@ -691,9 +691,9 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             return;
         }
 
-        if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) {
+        if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) {
             startOauthorization();
-        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) { 
+        } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) { 
             startSamlBasedFederatedSingleSignOnAuthorization();
         } else {
             checkBasicAuthorization();
@@ -718,7 +718,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 
         /// test credentials accessing the root folder
         mAuthCheckOperation = new  ExistenceCheckOperation("", this, false);
-        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);
+        WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);
         client.setBasicCredentials(username, password);
         mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);
     }
@@ -767,7 +767,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 
         /// test credentials accessing the root folder
         mAuthCheckOperation = new  ExistenceCheckOperation("", this, false);
-        WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false);
+        WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, false);
         mOperationThread = mAuthCheckOperation.execute(client, this, mHandler);
       
     }
@@ -787,7 +787,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             onGetOAuthAccessTokenFinish((OAuth2GetAccessToken)operation, result);
 
         } else if (operation instanceof ExistenceCheckOperation)  {
-            if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {
+            if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {
                 onSamlBasedFederatedSingleSignOnAuthorizationStart(operation, result);
                 
             } else {
@@ -1086,7 +1086,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             mAuthToken = ((OAuth2GetAccessToken)operation).getResultTokenMap().get(OAuth2Constants.KEY_ACCESS_TOKEN);
             Log_OC.d(TAG, "Got ACCESS TOKEN: " + mAuthToken);
             mAuthCheckOperation = new ExistenceCheckOperation("", this, false);
-            WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);
+            WebdavClient client = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(mHostBaseUrl + webdav_path), this, true);
             client.setBearerCredentials(mAuthToken);
             mAuthCheckOperation.execute(client, this, mHandler);
 
@@ -1172,12 +1172,12 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
         response.putString(AccountManager.KEY_ACCOUNT_NAME, mAccount.name);
         response.putString(AccountManager.KEY_ACCOUNT_TYPE, mAccount.type);
         
-        if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) { 
+        if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) { 
             response.putString(AccountManager.KEY_AUTHTOKEN, mAuthToken);
             // the next line is necessary; by now, notifications are calling directly to the AuthenticatorActivity to update, without AccountManager intervention
             mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
             
-        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {
+        } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {
             String username = getUserNameForSamlSso();
             if (!mUsernameInput.getText().toString().equals(username)) {
                 // fail - not a new account, but an existing one; disallow
@@ -1212,8 +1212,8 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      */
     private boolean createAccount() {
         /// create and save new ownCloud account
-        boolean isOAuth = MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType);
-        boolean isSaml =  MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType);
+        boolean isOAuth = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType);
+        boolean isSaml =  AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType);
 
         Uri uri = Uri.parse(mHostBaseUrl);
         String username = mUsernameInput.getText().toString().trim();
@@ -1265,12 +1265,12 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
                 mAccountMgr.setAuthToken(mAccount, mAuthTokenType, mAuthToken);
             }
             /// add user data to the new account; TODO probably can be done in the last parameter addAccountExplicitly, or in KEY_USERDATA
-            mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION,    mDiscoveredVersion.toString());
-            mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL,   mHostBaseUrl);
+            mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_VERSION,    mDiscoveredVersion.toString());
+            mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_BASE_URL,   mHostBaseUrl);
             if (isSaml) {
-                mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); 
+                mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_SAML_WEB_SSO, "TRUE"); 
             } else if (isOAuth) {
-                mAccountMgr.setUserData(mAccount, AccountAuthenticator.KEY_SUPPORTS_OAUTH2, "TRUE");  
+                mAccountMgr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_SUPPORTS_OAUTH2, "TRUE");  
             }
     
             setAccountAuthenticatorResult(intent.getExtras());
@@ -1482,9 +1482,9 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
     public void onCheckClick(View view) {
         CheckBox oAuth2Check = (CheckBox)view;
         if (oAuth2Check.isChecked()) {
-            mAuthTokenType = MainApp.getAuthTokenTypeAccessToken();
+            mAuthTokenType = AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType());
         } else {
-            mAuthTokenType = MainApp.getAuthTokenTypePass();
+            mAuthTokenType = AccountTypeUtils.getAuthTokenTypePass(MainApp.getAccountType());
         }
         adaptViewAccordingToAuthenticationMethod();
     }
@@ -1495,14 +1495,14 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
      * the current authorization method.
      */
     private void adaptViewAccordingToAuthenticationMethod () {
-        if (MainApp.getAuthTokenTypeAccessToken().equals(mAuthTokenType)) {
+        if (AccountTypeUtils.getAuthTokenTypeAccessToken(MainApp.getAccountType()).equals(mAuthTokenType)) {
             // OAuth 2 authorization
             mOAuthAuthEndpointText.setVisibility(View.VISIBLE);
             mOAuthTokenEndpointText.setVisibility(View.VISIBLE);
             mUsernameInput.setVisibility(View.GONE);
             mPasswordInput.setVisibility(View.GONE);
             
-        } else if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {
+        } else if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {
             // SAML-based web Single Sign On
             mOAuthAuthEndpointText.setVisibility(View.GONE);
             mOAuthTokenEndpointText.setVisibility(View.GONE);
@@ -1548,7 +1548,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
             }
             
         } else if (actionId == EditorInfo.IME_ACTION_NEXT && inputField != null && inputField.equals(mHostUrlInput)) {
-            if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType)) {
+            if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType)) {
                 checkOcServer();
             }
         }
@@ -1647,7 +1647,7 @@ implements  OnRemoteOperationListener, OnSslValidatorListener, OnFocusChangeList
 
     @Override
     public boolean onTouchEvent(MotionEvent event) {
-        if (MainApp.getAuthTokenTypeSamlSessionCookie().equals(mAuthTokenType) &&
+        if (AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(MainApp.getAccountType()).equals(mAuthTokenType) &&
                 mHostUrlInput.hasFocus() && event.getAction() == MotionEvent.ACTION_DOWN) {
             checkOcServer();
         }

+ 1 - 1
src/com/owncloud/android/authentication/SsoWebViewClient.java

@@ -19,7 +19,7 @@ package com.owncloud.android.authentication;
 
 import java.lang.ref.WeakReference;
 
-import com.owncloud.android.Log_OC;
+import com.owncloud.android.utils.Log_OC;
 
 
 import android.graphics.Bitmap;

+ 1 - 1
src/com/owncloud/android/datamodel/FileDataStorageManager.java

@@ -25,10 +25,10 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.Vector;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
 import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 
 
 import android.accounts.Account;

+ 1 - 1
src/com/owncloud/android/datamodel/OCFile.java

@@ -20,7 +20,7 @@ package com.owncloud.android.datamodel;
 
 import java.io.File;
 
-import com.owncloud.android.Log_OC;
+import com.owncloud.android.utils.Log_OC;
 
 
 import android.os.Parcel;

+ 1 - 1
src/com/owncloud/android/db/DbHandler.java

@@ -17,8 +17,8 @@
  */
 package com.owncloud.android.db;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.MainApp;
+import com.owncloud.android.utils.Log_OC;
 
 import android.content.ContentValues;
 import android.content.Context;

+ 1 - 1
src/com/owncloud/android/files/BootupBroadcastReceiver.java

@@ -18,8 +18,8 @@
 
 package com.owncloud.android.files;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.files.services.FileObserverService;
+import com.owncloud.android.utils.Log_OC;
 
 import android.content.BroadcastReceiver;
 import android.content.Context;

+ 1 - 1
src/com/owncloud/android/files/InstantUploadBroadcastReceiver.java

@@ -20,12 +20,12 @@ package com.owncloud.android.files;
 
 import java.io.File;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.authentication.AccountUtils;
 import com.owncloud.android.db.DbHandler;
 import com.owncloud.android.files.services.FileUploader;
 import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 
 
 import android.accounts.Account;

+ 3 - 3
src/com/owncloud/android/files/OwnCloudFileObserver.java

@@ -20,13 +20,13 @@ package com.owncloud.android.files;
 
 import java.io.File;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
 import com.owncloud.android.operations.SynchronizeFileOperation;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.ui.activity.ConflictsResolveActivity;
+import com.owncloud.android.utils.Log_OC;
 
 import android.accounts.Account;
 import android.content.Context;

+ 10 - 12
src/com/owncloud/android/files/services/FileDownloader.java

@@ -28,23 +28,22 @@ import java.util.Vector;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.AuthenticatorActivity;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.network.OwnCloudClientUtils;
+
+import com.owncloud.android.oc_framework.network.webdav.OnDatatransferProgressListener;
+import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
 import com.owncloud.android.operations.DownloadFileOperation;
-import com.owncloud.android.operations.RemoteOperationResult;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.preview.PreviewImageActivity;
 import com.owncloud.android.ui.preview.PreviewImageFragment;
-
-import eu.alefzero.webdav.OnDatatransferProgressListener;
-
+import com.owncloud.android.utils.Log_OC;
 
 import android.accounts.Account;
 import android.accounts.AccountsException;
@@ -62,8 +61,6 @@ import android.os.Message;
 import android.os.Process;
 import android.widget.RemoteViews;
 
-import eu.alefzero.webdav.WebdavClient;
-
 public class FileDownloader extends Service implements OnDatatransferProgressListener {
     
     public static final String EXTRA_ACCOUNT = "ACCOUNT";
@@ -355,7 +352,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                 if (mDownloadClient == null || !mLastAccount.equals(mCurrentDownload.getAccount())) {
                     mLastAccount = mCurrentDownload.getAccount();
                     mStorageManager = new FileDataStorageManager(mLastAccount, getContentResolver());
-                    mDownloadClient = OwnCloudClientUtils.createOwnCloudClient(mLastAccount, getApplicationContext());
+                    mDownloadClient = OwnCloudClientFactory.createOwnCloudClient(mLastAccount, getApplicationContext());
                 }
 
                 /// perform the download
@@ -476,7 +473,8 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
             boolean needsToUpdateCredentials = (downloadResult.getCode() == ResultCode.UNAUTHORIZED ||
                                                 // (downloadResult.isTemporalRedirection() && downloadResult.isIdPRedirection()
                                                   (downloadResult.isIdPRedirection()
-                                                        && MainApp.getAuthTokenTypeSamlSessionCookie().equals(mDownloadClient.getAuthTokenType())));
+                                                        && mDownloadClient.getCredentials() == null));
+                                                        //&& MainApp.getAuthTokenTypeSamlSessionCookie().equals(mDownloadClient.getAuthTokenType())));
             if (needsToUpdateCredentials) {
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);

+ 1 - 1
src/com/owncloud/android/files/services/FileObserverService.java

@@ -22,13 +22,13 @@ import java.io.File;
 import java.util.HashMap;
 import java.util.Map;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
 import com.owncloud.android.files.OwnCloudFileObserver;
 import com.owncloud.android.operations.SynchronizeFileOperation;
 import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 
 
 import android.accounts.Account;

+ 18 - 20
src/com/owncloud/android/files/services/FileUploader.java

@@ -33,7 +33,6 @@ import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.MainApp;
 import com.owncloud.android.R;
 import com.owncloud.android.authentication.AccountAuthenticator;
@@ -41,27 +40,27 @@ import com.owncloud.android.authentication.AuthenticatorActivity;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.db.DbHandler;
-import com.owncloud.android.network.OwnCloudClientUtils;
 import com.owncloud.android.operations.ChunkedUploadFileOperation;
 import com.owncloud.android.operations.CreateFolderOperation;
 import com.owncloud.android.operations.ExistenceCheckOperation;
-import com.owncloud.android.operations.RemoteOperation;
-import com.owncloud.android.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
 import com.owncloud.android.operations.UploadFileOperation;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.utils.OwnCloudVersion;
+import com.owncloud.android.oc_framework.network.webdav.OnDatatransferProgressListener;
+import com.owncloud.android.oc_framework.accounts.OwnCloudAccount;
+import com.owncloud.android.oc_framework.network.webdav.OwnCloudClientFactory;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.WebdavEntry;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
 import com.owncloud.android.ui.activity.FailedUploadActivity;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
 import com.owncloud.android.ui.activity.InstantUploadActivity;
 import com.owncloud.android.ui.preview.PreviewImageActivity;
 import com.owncloud.android.ui.preview.PreviewImageFragment;
-import com.owncloud.android.utils.OwnCloudVersion;
-
-
-import eu.alefzero.webdav.OnDatatransferProgressListener;
-import eu.alefzero.webdav.WebdavEntry;
-import eu.alefzero.webdav.WebdavUtils;
-
+import com.owncloud.android.utils.Log_OC;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
@@ -82,7 +81,6 @@ import android.webkit.MimeTypeMap;
 import android.widget.RemoteViews;
 
 
-import eu.alefzero.webdav.WebdavClient;
 
 public class FileUploader extends Service implements OnDatatransferProgressListener {
 
@@ -261,8 +259,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
             }
         }
 
-        OwnCloudVersion ocv = new OwnCloudVersion(AccountManager.get(this).getUserData(account,
-                AccountAuthenticator.KEY_OC_VERSION));
+        OwnCloudVersion ocv = new OwnCloudVersion(AccountManager.get(this).getUserData(account, OwnCloudAccount.Constants.KEY_OC_VERSION));
         boolean chunked = FileUploader.chunkedUploadIsSupported(ocv);
         AbstractList<String> requestedUploads = new Vector<String>();
         String uploadKey = null;
@@ -504,7 +501,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
                 if (mUploadClient == null || !mLastAccount.equals(mCurrentUpload.getAccount())) {
                     mLastAccount = mCurrentUpload.getAccount();
                     mStorageManager = new FileDataStorageManager(mLastAccount, getContentResolver());
-                    mUploadClient = OwnCloudClientUtils.createOwnCloudClient(mLastAccount, getApplicationContext());
+                    mUploadClient = OwnCloudClientFactory.createOwnCloudClient(mLastAccount, getApplicationContext());
                 }
                 
                 /// check the existence of the parent folder for the file to upload
@@ -567,9 +564,9 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         RemoteOperation operation = new ExistenceCheckOperation(pathToGrant, this, false);
         RemoteOperationResult result = operation.execute(mUploadClient);
         if (!result.isSuccess() && result.getCode() == ResultCode.FILE_NOT_FOUND && mCurrentUpload.isRemoteFolderToBeCreated()) {
-            operation = new CreateFolderOperation(  pathToGrant,
-                                                    true,
-                                                    mStorageManager    );
+            operation = new CreateFolderOperation( pathToGrant,
+                    true,
+                    mStorageManager    );
             result = operation.execute(mUploadClient);
         }
         if (result.isSuccess()) {
@@ -823,7 +820,8 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
             boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED ||
                     //(uploadResult.isTemporalRedirection() && uploadResult.isIdPRedirection() && 
                     (uploadResult.isIdPRedirection() &&
-                            MainApp.getAuthTokenTypeSamlSessionCookie().equals(mUploadClient.getAuthTokenType())));
+                            mUploadClient.getCredentials() == null));
+                            //MainApp.getAuthTokenTypeSamlSessionCookie().equals(mUploadClient.getAuthTokenType())));
             if (needsToUpdateCredentials) {
                 // let the user update credentials with one click
                 Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);

+ 1 - 1
src/com/owncloud/android/media/MediaService.java

@@ -37,11 +37,11 @@ import android.widget.Toast;
 
 import java.io.IOException;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.ui.activity.FileActivity;
 import com.owncloud.android.ui.activity.FileDisplayActivity;
+import com.owncloud.android.utils.Log_OC;
 
 
 /**

+ 1 - 1
src/com/owncloud/android/media/MediaServiceBinder.java

@@ -18,9 +18,9 @@
 package com.owncloud.android.media;
 
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.media.MediaService.State;
+import com.owncloud.android.utils.Log_OC;
 
 import android.accounts.Account;
 import android.content.Intent;

+ 0 - 285
src/com/owncloud/android/network/OwnCloudClientUtils.java

@@ -1,285 +0,0 @@
-/* ownCloud Android client application
- *   Copyright (C) 2012-2013 ownCloud Inc.
- *
- *   This program is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License version 2,
- *   as published by the Free Software Foundation.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package com.owncloud.android.network;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.GeneralSecurityException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateException;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.protocol.Protocol;
-import org.apache.http.conn.ssl.BrowserCompatHostnameVerifier;
-import org.apache.http.conn.ssl.X509HostnameVerifier;
-
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.MainApp;
-import com.owncloud.android.authentication.AccountAuthenticator;
-import com.owncloud.android.authentication.AccountUtils;
-import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
-
-
-import eu.alefzero.webdav.WebdavClient;
-
-import android.accounts.Account;
-import android.accounts.AccountManager;
-import android.accounts.AccountManagerFuture;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
-import android.app.Activity;
-import android.content.Context;
-import android.net.Uri;
-import android.os.Bundle;
-
-public class OwnCloudClientUtils {
-    
-    final private static String TAG = OwnCloudClientUtils.class.getSimpleName();
-    
-    /** Default timeout for waiting data from the server */
-    public static final int DEFAULT_DATA_TIMEOUT = 60000;
-    
-    /** Default timeout for establishing a connection */
-    public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
-
-    /** Connection manager for all the WebdavClients */
-    private static MultiThreadedHttpConnectionManager mConnManager = null;
-    
-    private static Protocol mDefaultHttpsProtocol = null;
-
-    private static AdvancedSslSocketFactory mAdvancedSslSocketFactory = null;
-
-    private static X509HostnameVerifier mHostnameVerifier = null;
-    
-    
-    /**
-     * Creates a WebdavClient setup for an ownCloud account
-     * 
-     * Do not call this method from the main thread.
-     * 
-     * @param account                       The ownCloud account
-     * @param appContext                    Android application context
-     * @return                              A WebdavClient object ready to be used
-     * @throws AuthenticatorException       If the authenticator failed to get the authorization token for the account.
-     * @throws OperationCanceledException   If the authenticator operation was cancelled while getting the authorization token for the account. 
-     * @throws IOException                  If there was some I/O error while getting the authorization token for the account.
-     * @throws AccountNotFoundException     If 'account' is unknown for the AccountManager
-     */
-    public static WebdavClient createOwnCloudClient (Account account, Context appContext) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException {
-        //Log_OC.d(TAG, "Creating WebdavClient associated to " + account.name);
-       
-        Uri uri = Uri.parse(AccountUtils.constructFullURLForAccount(appContext, account));
-        AccountManager am = AccountManager.get(appContext);
-        boolean isOauth2 = am.getUserData(account, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null;   // TODO avoid calling to getUserData here
-        boolean isSamlSso = am.getUserData(account, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO) != null;
-        WebdavClient client = createOwnCloudClient(uri, appContext, !isSamlSso);
-        if (isOauth2) {    
-            String accessToken = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypeAccessToken(), false);
-            client.setBearerCredentials(accessToken);   // TODO not assume that the access token is a bearer token
-        
-        } else if (isSamlSso) {    // TODO avoid a call to getUserData here
-            String accessToken = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypeSamlSessionCookie(), false);
-            client.setSsoSessionCookie(accessToken);
-            
-        } else {
-            String username = account.name.substring(0, account.name.lastIndexOf('@'));
-            //String password = am.getPassword(account);
-            String password = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypePass(), false);
-            client.setBasicCredentials(username, password);
-        }
-        
-        return client;
-    }
-    
-    
-    public static WebdavClient createOwnCloudClient (Account account, Context appContext, Activity currentActivity) throws OperationCanceledException, AuthenticatorException, IOException, AccountNotFoundException {
-        Uri uri = Uri.parse(AccountUtils.constructFullURLForAccount(appContext, account));
-        AccountManager am = AccountManager.get(appContext);
-        boolean isOauth2 = am.getUserData(account, AccountAuthenticator.KEY_SUPPORTS_OAUTH2) != null;   // TODO avoid calling to getUserData here
-        boolean isSamlSso = am.getUserData(account, AccountAuthenticator.KEY_SUPPORTS_SAML_WEB_SSO) != null;
-        WebdavClient client = createOwnCloudClient(uri, appContext, !isSamlSso);
-        
-        if (isOauth2) {    // TODO avoid a call to getUserData here
-            AccountManagerFuture<Bundle> future =  am.getAuthToken(account, MainApp.getAuthTokenTypeAccessToken(), null, currentActivity, null, null);
-            Bundle result = future.getResult();
-            String accessToken = result.getString(AccountManager.KEY_AUTHTOKEN);
-            if (accessToken == null) throw new AuthenticatorException("WTF!");
-            client.setBearerCredentials(accessToken);   // TODO not assume that the access token is a bearer token
-
-        } else if (isSamlSso) {    // TODO avoid a call to getUserData here
-            AccountManagerFuture<Bundle> future =  am.getAuthToken(account, MainApp.getAuthTokenTypeSamlSessionCookie(), null, currentActivity, null, null);
-            Bundle result = future.getResult();
-            String accessToken = result.getString(AccountManager.KEY_AUTHTOKEN);
-            if (accessToken == null) throw new AuthenticatorException("WTF!");
-            client.setSsoSessionCookie(accessToken);
-
-        } else {
-            String username = account.name.substring(0, account.name.lastIndexOf('@'));
-            //String password = am.getPassword(account);
-            //String password = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypePass(), false);
-            AccountManagerFuture<Bundle> future =  am.getAuthToken(account, MainApp.getAuthTokenTypePass(), null, currentActivity, null, null);
-            Bundle result = future.getResult();
-            String password = result.getString(AccountManager.KEY_AUTHTOKEN);
-            client.setBasicCredentials(username, password);
-        }
-        
-        return client;
-    }
-    
-    /**
-     * Creates a WebdavClient to access a URL and sets the desired parameters for ownCloud client connections.
-     * 
-     * @param uri       URL to the ownCloud server
-     * @param context   Android context where the WebdavClient is being created.
-     * @return          A WebdavClient object ready to be used
-     */
-    public static WebdavClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects) {
-        try {
-            registerAdvancedSslContext(true, context);
-        }  catch (GeneralSecurityException e) {
-            Log_OC.e(TAG, "Advanced SSL Context could not be loaded. Default SSL management in the system will be used for HTTPS connections", e);
-            
-        } catch (IOException e) {
-            Log_OC.e(TAG, "The local server truststore could not be read. Default SSL management in the system will be used for HTTPS connections", e);
-        }
-        
-        WebdavClient client = new WebdavClient(getMultiThreadedConnManager());
-        
-        client.setDefaultTimeouts(DEFAULT_DATA_TIMEOUT, DEFAULT_CONNECTION_TIMEOUT);
-        client.setBaseUri(uri);
-        client.setFollowRedirects(followRedirects);
-        
-        return client;
-    }
-    
-    
-    /**
-     * Registers or unregisters the proper components for advanced SSL handling.
-     * @throws IOException 
-     */
-    private static void registerAdvancedSslContext(boolean register, Context context) throws GeneralSecurityException, IOException {
-        Protocol pr = null;
-        try {
-            pr = Protocol.getProtocol("https");
-            if (pr != null && mDefaultHttpsProtocol == null) {
-                mDefaultHttpsProtocol = pr;
-            }
-        } catch (IllegalStateException e) {
-            // nothing to do here; really
-        }
-        boolean isRegistered = (pr != null && pr.getSocketFactory() instanceof AdvancedSslSocketFactory);
-        if (register && !isRegistered) {
-            Protocol.registerProtocol("https", new Protocol("https", getAdvancedSslSocketFactory(context), 443));
-            
-        } else if (!register && isRegistered) {
-            if (mDefaultHttpsProtocol != null) {
-                Protocol.registerProtocol("https", mDefaultHttpsProtocol);
-            }
-        }
-    }
-    
-    public static AdvancedSslSocketFactory getAdvancedSslSocketFactory(Context context) throws GeneralSecurityException, IOException {
-        if (mAdvancedSslSocketFactory  == null) {
-            KeyStore trustStore = getKnownServersStore(context);
-            AdvancedX509TrustManager trustMgr = new AdvancedX509TrustManager(trustStore);
-            TrustManager[] tms = new TrustManager[] { trustMgr };
-                
-            SSLContext sslContext = SSLContext.getInstance("TLS");
-            sslContext.init(null, tms, null);
-                    
-            mHostnameVerifier = new BrowserCompatHostnameVerifier();
-            mAdvancedSslSocketFactory = new AdvancedSslSocketFactory(sslContext, trustMgr, mHostnameVerifier);
-        }
-        return mAdvancedSslSocketFactory;
-    }
-
-
-    private static String LOCAL_TRUSTSTORE_FILENAME = "knownServers.bks";
-    
-    private static String LOCAL_TRUSTSTORE_PASSWORD = "password";
-
-    private static KeyStore mKnownServersStore = null;
-    
-    /**
-     * Returns the local store of reliable server certificates, explicitly accepted by the user.
-     * 
-     * Returns a KeyStore instance with empty content if the local store was never created.
-     * 
-     * Loads the store from the storage environment if needed.
-     * 
-     * @param context                       Android context where the operation is being performed.
-     * @return                              KeyStore instance with explicitly-accepted server certificates. 
-     * @throws KeyStoreException            When the KeyStore instance could not be created.
-     * @throws IOException                  When an existing local trust store could not be loaded.
-     * @throws NoSuchAlgorithmException     When the existing local trust store was saved with an unsupported algorithm.
-     * @throws CertificateException         When an exception occurred while loading the certificates from the local trust store.
-     */
-    private static KeyStore getKnownServersStore(Context context) throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
-        if (mKnownServersStore == null) {
-            //mKnownServersStore = KeyStore.getInstance("BKS");
-            mKnownServersStore = KeyStore.getInstance(KeyStore.getDefaultType());
-            File localTrustStoreFile = new File(context.getFilesDir(), LOCAL_TRUSTSTORE_FILENAME);
-            Log_OC.d(TAG, "Searching known-servers store at " + localTrustStoreFile.getAbsolutePath());
-            if (localTrustStoreFile.exists()) {
-                InputStream in = new FileInputStream(localTrustStoreFile);
-                try {
-                    mKnownServersStore.load(in, LOCAL_TRUSTSTORE_PASSWORD.toCharArray());
-                } finally {
-                    in.close();
-                }
-            } else {
-                mKnownServersStore.load(null, LOCAL_TRUSTSTORE_PASSWORD.toCharArray()); // necessary to initialize an empty KeyStore instance
-            }
-        }
-        return mKnownServersStore;
-    }
-    
-    
-    public static void addCertToKnownServersStore(Certificate cert, Context context) throws  KeyStoreException, NoSuchAlgorithmException, 
-                                                                                            CertificateException, IOException {
-        KeyStore knownServers = getKnownServersStore(context);
-        knownServers.setCertificateEntry(Integer.toString(cert.hashCode()), cert);
-        FileOutputStream fos = null;
-        try {
-            fos = context.openFileOutput(LOCAL_TRUSTSTORE_FILENAME, Context.MODE_PRIVATE);
-            knownServers.store(fos, LOCAL_TRUSTSTORE_PASSWORD.toCharArray());
-        } finally {
-            fos.close();
-        }
-    }
-    
-    
-    static private MultiThreadedHttpConnectionManager getMultiThreadedConnManager() {
-        if (mConnManager == null) {
-            mConnManager = new MultiThreadedHttpConnectionManager();
-            mConnManager.getParams().setDefaultMaxConnectionsPerHost(5);
-            mConnManager.getParams().setMaxTotalConnections(5);
-        }
-        return mConnManager;
-    }
-
-
-}

+ 5 - 5
src/com/owncloud/android/operations/ChunkedUploadFileOperation.java

@@ -27,16 +27,16 @@ import java.util.Random;
 import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.methods.PutMethod;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.network.ProgressiveDataTransferer;
+import com.owncloud.android.oc_framework.network.ProgressiveDataTransferer;
+import com.owncloud.android.oc_framework.network.webdav.ChunkFromFileChannelRequestEntity;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.utils.Log_OC;
 
 
 import android.accounts.Account;
 
-import eu.alefzero.webdav.ChunkFromFileChannelRequestEntity;
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavUtils;
 
 public class ChunkedUploadFileOperation extends UploadFileOperation {
     

+ 50 - 61
src/com/owncloud/android/operations/CreateFolderOperation.java

@@ -17,30 +17,27 @@
 
 package com.owncloud.android.operations;
 
-import java.io.File;
-
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
-
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.operations.remote.CreateRemoteFolderOperation;
+import com.owncloud.android.oc_framework.operations.OnRemoteOperationListener;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 
 
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavUtils;
-
 /**
- * Remote operation performing the creation of a new folder in the ownCloud server.
+ * Access to remote operation performing the creation of a new folder in the ownCloud server.
+ * Save the new folder in Database
  * 
  * @author David A. Velasco 
+ * @author masensio
  */
-public class CreateFolderOperation extends RemoteOperation {
+public class CreateFolderOperation extends RemoteOperation implements OnRemoteOperationListener{
     
     private static final String TAG = CreateFolderOperation.class.getSimpleName();
-
-    private static final int READ_TIMEOUT = 10000;
-    private static final int CONNECTION_TIMEOUT = 5000;
     
     protected String mRemotePath;
     protected boolean mCreateFullPath;
@@ -49,7 +46,6 @@ public class CreateFolderOperation extends RemoteOperation {
     /**
      * Constructor
      * 
-     * @param remotePath            Full path to the new directory to create in the remote server.
      * @param createFullPath        'True' means that all the ancestor folders should be created if don't exist yet.
      * @param storageManager        Reference to the local database corresponding to the account where the file is contained. 
      */
@@ -57,62 +53,55 @@ public class CreateFolderOperation extends RemoteOperation {
         mRemotePath = remotePath;
         mCreateFullPath = createFullPath;
         mStorageManager = storageManager;
+        
     }
-    
-    
-    /**
-     * Performs the operation
-     * 
-     * @param   client      Client object to communicate with the remote ownCloud server.
-     */
+
+
     @Override
     protected RemoteOperationResult run(WebdavClient client) {
-        RemoteOperationResult result = null;
-        MkColMethod mkcol = null;
-        try {
-            mkcol = new MkColMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath));
-            int status =  client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);
-            if (!mkcol.succeeded() && mkcol.getStatusCode() == HttpStatus.SC_CONFLICT && mCreateFullPath) {
-                result = createParentFolder(getParentPath(), client);
-                status = client.executeMethod(mkcol, READ_TIMEOUT, CONNECTION_TIMEOUT);    // second (and last) try
-            }
-            if (mkcol.succeeded()) {
-                // Save new directory in local database
-                OCFile newDir = new OCFile(mRemotePath);
-                newDir.setMimetype("DIR");
-                long parentId = mStorageManager.getFileByPath(getParentPath()).getFileId();
-                newDir.setParentId(parentId);
-                newDir.setModificationTimestamp(System.currentTimeMillis());
-                mStorageManager.saveFile(newDir);
-            }
-            result = new RemoteOperationResult(mkcol.succeeded(), status, mkcol.getResponseHeaders());
-            Log_OC.d(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage());
-            client.exhaustResponse(mkcol.getResponseBodyAsStream());
-                
-        } catch (Exception e) {
-            result = new RemoteOperationResult(e);
-            Log_OC.e(TAG, "Create directory " + mRemotePath + ": " + result.getLogMessage(), e);
-            
-        } finally {
-            if (mkcol != null)
-                mkcol.releaseConnection();
+        CreateRemoteFolderOperation operation = new CreateRemoteFolderOperation(mRemotePath, mCreateFullPath);
+        RemoteOperationResult result =  operation.execute(client);
+        
+        if (result.isSuccess()) {
+            saveFolderInDB();
+        } else {
+            Log_OC.e(TAG, mRemotePath + "hasn't been created");
         }
+        
         return result;
     }
 
-
-    private String getParentPath() {
-        String parentPath = new File(mRemotePath).getParent();
-        parentPath = parentPath.endsWith(OCFile.PATH_SEPARATOR) ? parentPath : parentPath + OCFile.PATH_SEPARATOR;
-        return parentPath;
+    @Override
+    public void onRemoteOperationFinish(RemoteOperation operation, RemoteOperationResult result) {
+        if (operation instanceof CreateRemoteFolderOperation) {
+            onCreateRemoteFolderOperationFinish((CreateRemoteFolderOperation)operation, result);
+        }
+    }
+    
+    
+    private void onCreateRemoteFolderOperationFinish(CreateRemoteFolderOperation operation, RemoteOperationResult result) {
+       if (result.isSuccess()) {
+           saveFolderInDB();
+       } else {
+           Log_OC.e(TAG, mRemotePath + "hasn't been created");
+       }
     }
 
     
-    private RemoteOperationResult createParentFolder(String parentPath, WebdavClient client) {
-        RemoteOperation operation = new CreateFolderOperation(  parentPath,
-                                                                mCreateFullPath,
-                                                                mStorageManager    );
-        return operation.execute(client);
+    /**
+     * Save new directory in local database
+     */
+    public void saveFolderInDB() {
+        OCFile newDir = new OCFile(mRemotePath);
+        newDir.setMimetype("DIR");
+        long parentId = mStorageManager.getFileByPath(FileStorageUtils.getParentPath(mRemotePath)).getFileId();
+        newDir.setParentId(parentId);
+        newDir.setModificationTimestamp(System.currentTimeMillis());
+        mStorageManager.saveFile(newDir);
+
+        Log_OC.d(TAG, "Create directory " + mRemotePath + " in Database");
+
     }
 
+
 }

+ 7 - 7
src/com/owncloud/android/operations/DownloadFileOperation.java

@@ -32,16 +32,16 @@ import org.apache.commons.httpclient.HttpException;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.http.HttpStatus;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.operations.RemoteOperation;
-import com.owncloud.android.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.network.webdav.OnDatatransferProgressListener;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.oc_framework.operations.OperationCancelledException;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
 import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 
-
-import eu.alefzero.webdav.OnDatatransferProgressListener;
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavUtils;
 import android.accounts.Account;
 import android.webkit.MimeTypeMap;
 

+ 5 - 4
src/com/owncloud/android/operations/ExistenceCheckOperation.java

@@ -20,11 +20,12 @@ package com.owncloud.android.operations;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.commons.httpclient.methods.HeadMethod;
 
-import com.owncloud.android.Log_OC;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.utils.Log_OC;
 
-
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavUtils;
 import android.content.Context;
 import android.net.ConnectivityManager;
 

+ 5 - 4
src/com/owncloud/android/operations/OAuth2GetAccessToken.java

@@ -8,13 +8,14 @@ import org.apache.commons.httpclient.NameValuePair;
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.authentication.OAuth2Constants;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.utils.Log_OC;
 
 
-import eu.alefzero.webdav.WebdavClient;
-
 public class OAuth2GetAccessToken extends RemoteOperation {
     
     private static final String TAG = OAuth2GetAccessToken.class.getSimpleName();

+ 5 - 4
src/com/owncloud/android/operations/OwnCloudServerCheckOperation.java

@@ -22,12 +22,13 @@ import org.apache.commons.httpclient.methods.GetMethod;
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.authentication.AccountUtils;
-import com.owncloud.android.utils.OwnCloudVersion;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.utils.OwnCloudVersion;
+import com.owncloud.android.utils.Log_OC;
 
-
-import eu.alefzero.webdav.WebdavClient;
 import android.content.Context;
 import android.net.ConnectivityManager;
 import android.net.Uri;

+ 5 - 4
src/com/owncloud/android/operations/RemoveFileOperation.java

@@ -20,14 +20,15 @@ package com.owncloud.android.operations;
 import org.apache.commons.httpclient.HttpStatus;
 import org.apache.jackrabbit.webdav.client.methods.DeleteMethod;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.utils.Log_OC;
 
 
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavUtils;
-
 /**
  * Remote operation performing the removal of a remote file or folder in the ownCloud server.
  * 

+ 6 - 4
src/com/owncloud/android/operations/RenameFileOperation.java

@@ -22,18 +22,20 @@ import java.io.IOException;
 
 import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 //import org.apache.jackrabbit.webdav.client.methods.MoveMethod;
 
 import android.accounts.Account;
 
 
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavUtils;
 
 /**
  * Remote operation performing the rename of a remote file (or folder?) in the ownCloud server.

+ 7 - 6
src/com/owncloud/android/operations/SynchronizeFileOperation.java

@@ -23,22 +23,23 @@ import org.apache.jackrabbit.webdav.DavConstants;
 import org.apache.jackrabbit.webdav.MultiStatus;
 import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileDownloader;
 import com.owncloud.android.files.services.FileUploader;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.WebdavEntry;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.utils.Log_OC;
 
 import android.accounts.Account;
 import android.content.Context;
 import android.content.Intent;
 
 
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavEntry;
-import eu.alefzero.webdav.WebdavUtils;
-
 public class SynchronizeFileOperation extends RemoteOperation {
 
     private String TAG = SynchronizeFileOperation.class.getSimpleName();

+ 7 - 5
src/com/owncloud/android/operations/SynchronizeFolderOperation.java

@@ -37,16 +37,18 @@ import android.accounts.Account;
 import android.content.Context;
 import android.content.Intent;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.datamodel.OCFile;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.WebdavEntry;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.syncadapter.FileSyncService;
 import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavEntry;
-import eu.alefzero.webdav.WebdavUtils;
 
 
 /**

+ 9 - 8
src/com/owncloud/android/operations/UpdateOCVersionOperation.java

@@ -22,19 +22,20 @@ import org.apache.commons.httpclient.methods.GetMethod;
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import com.owncloud.android.Log_OC;
-import com.owncloud.android.authentication.AccountAuthenticator;
 import com.owncloud.android.authentication.AccountUtils;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
-import com.owncloud.android.utils.OwnCloudVersion;
+import com.owncloud.android.oc_framework.accounts.OwnCloudAccount;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.utils.OwnCloudVersion;
+import com.owncloud.android.utils.Log_OC;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
 import android.content.Context;
 
 
-import eu.alefzero.webdav.WebdavClient;
-
 /**
  * Remote operation that checks the version of an ownCloud server and stores it locally
  * 
@@ -57,7 +58,7 @@ public class UpdateOCVersionOperation extends RemoteOperation {
     @Override
     protected RemoteOperationResult run(WebdavClient client) {
         AccountManager accountMngr = AccountManager.get(mContext); 
-        String statUrl = accountMngr.getUserData(mAccount, AccountAuthenticator.KEY_OC_BASE_URL);
+        String statUrl = accountMngr.getUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_BASE_URL);
         statUrl += AccountUtils.STATUS_PATH;
         RemoteOperationResult result = null;
         GetMethod get = null;
@@ -75,7 +76,7 @@ public class UpdateOCVersionOperation extends RemoteOperation {
                     if (json != null && json.getString("version") != null) {
                         OwnCloudVersion ocver = new OwnCloudVersion(json.getString("version"));
                         if (ocver.isVersionValid()) {
-                            accountMngr.setUserData(mAccount, AccountAuthenticator.KEY_OC_VERSION, ocver.toString());
+                            accountMngr.setUserData(mAccount, OwnCloudAccount.Constants.KEY_OC_VERSION, ocver.toString());
                             Log_OC.d(TAG, "Got new OC version " + ocver.toString());
                             result = new RemoteOperationResult(ResultCode.OK);
                             

+ 10 - 10
src/com/owncloud/android/operations/UploadFileOperation.java

@@ -32,23 +32,23 @@ import org.apache.commons.httpclient.methods.PutMethod;
 import org.apache.commons.httpclient.methods.RequestEntity;
 import org.apache.http.HttpStatus;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.datamodel.OCFile;
 import com.owncloud.android.files.services.FileUploader;
-import com.owncloud.android.network.ProgressiveDataTransferer;
-import com.owncloud.android.operations.RemoteOperation;
-import com.owncloud.android.operations.RemoteOperationResult;
-import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
+import com.owncloud.android.oc_framework.network.ProgressiveDataTransferer;
+import com.owncloud.android.oc_framework.network.webdav.FileRequestEntity;
+import com.owncloud.android.oc_framework.network.webdav.OnDatatransferProgressListener;
+import com.owncloud.android.oc_framework.network.webdav.WebdavClient;
+import com.owncloud.android.oc_framework.network.webdav.WebdavUtils;
+import com.owncloud.android.oc_framework.operations.OperationCancelledException;
+import com.owncloud.android.oc_framework.operations.RemoteOperation;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult;
+import com.owncloud.android.oc_framework.operations.RemoteOperationResult.ResultCode;
 import com.owncloud.android.utils.FileStorageUtils;
+import com.owncloud.android.utils.Log_OC;
 
 import android.accounts.Account;
 
 
-import eu.alefzero.webdav.FileRequestEntity;
-import eu.alefzero.webdav.OnDatatransferProgressListener;
-import eu.alefzero.webdav.WebdavClient;
-import eu.alefzero.webdav.WebdavUtils;
-
 /**
  * Remote operation performing the upload of a file to an ownCloud server
  * 

+ 1 - 1
src/com/owncloud/android/providers/FileContentProvider.java

@@ -21,11 +21,11 @@ package com.owncloud.android.providers;
 import java.util.ArrayList;
 import java.util.HashMap;
 
-import com.owncloud.android.Log_OC;
 import com.owncloud.android.R;
 import com.owncloud.android.datamodel.FileDataStorageManager;
 import com.owncloud.android.db.ProviderMeta;
 import com.owncloud.android.db.ProviderMeta.ProviderTableMeta;
+import com.owncloud.android.utils.Log_OC;
 
 
 

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно