|
@@ -73,6 +73,7 @@ public class FileContentProvider extends ContentProvider {
|
|
private static final int SYNCED_FOLDERS = 7;
|
|
private static final int SYNCED_FOLDERS = 7;
|
|
private static final int EXTERNAL_LINKS = 8;
|
|
private static final int EXTERNAL_LINKS = 8;
|
|
private static final int ARBITRARY_DATA = 9;
|
|
private static final int ARBITRARY_DATA = 9;
|
|
|
|
+ private static final int VIRTUAL = 10;
|
|
|
|
|
|
private static final String TAG = FileContentProvider.class.getSimpleName();
|
|
private static final String TAG = FileContentProvider.class.getSimpleName();
|
|
|
|
|
|
@@ -205,6 +206,9 @@ public class FileContentProvider extends ContentProvider {
|
|
case ARBITRARY_DATA:
|
|
case ARBITRARY_DATA:
|
|
count = db.delete(ProviderTableMeta.ARBITRARY_DATA_TABLE_NAME, where, whereArgs);
|
|
count = db.delete(ProviderTableMeta.ARBITRARY_DATA_TABLE_NAME, where, whereArgs);
|
|
break;
|
|
break;
|
|
|
|
+ case VIRTUAL:
|
|
|
|
+ count = db.delete(ProviderTableMeta.VIRTUAL_TABLE_NAME, where, whereArgs);
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
//Log_OC.e(TAG, "Unknown uri " + uri);
|
|
//Log_OC.e(TAG, "Unknown uri " + uri);
|
|
throw new IllegalArgumentException("Unknown uri: " + uri.toString());
|
|
throw new IllegalArgumentException("Unknown uri: " + uri.toString());
|
|
@@ -350,7 +354,17 @@ public class FileContentProvider extends ContentProvider {
|
|
|
|
|
|
}
|
|
}
|
|
return insertedArbitraryDataUri;
|
|
return insertedArbitraryDataUri;
|
|
|
|
+ case VIRTUAL:
|
|
|
|
+ Uri insertedVirtualUri;
|
|
|
|
+ long virtualId = db.insert(ProviderTableMeta.VIRTUAL_TABLE_NAME, null, values);
|
|
|
|
+
|
|
|
|
+ if (virtualId > 0) {
|
|
|
|
+ insertedVirtualUri = ContentUris.withAppendedId(ProviderTableMeta.CONTENT_URI_VIRTUAL, virtualId);
|
|
|
|
+ } else {
|
|
|
|
+ throw new SQLException("ERROR " + uri);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ return insertedVirtualUri;
|
|
default:
|
|
default:
|
|
throw new IllegalArgumentException("Unknown uri id: " + uri);
|
|
throw new IllegalArgumentException("Unknown uri id: " + uri);
|
|
}
|
|
}
|
|
@@ -402,6 +416,7 @@ public class FileContentProvider extends ContentProvider {
|
|
mUriMatcher.addURI(authority, "synced_folders", SYNCED_FOLDERS);
|
|
mUriMatcher.addURI(authority, "synced_folders", SYNCED_FOLDERS);
|
|
mUriMatcher.addURI(authority, "external_links", EXTERNAL_LINKS);
|
|
mUriMatcher.addURI(authority, "external_links", EXTERNAL_LINKS);
|
|
mUriMatcher.addURI(authority, "arbitrary_data", ARBITRARY_DATA);
|
|
mUriMatcher.addURI(authority, "arbitrary_data", ARBITRARY_DATA);
|
|
|
|
+ mUriMatcher.addURI(authority, "virtual", VIRTUAL);
|
|
|
|
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -497,6 +512,12 @@ public class FileContentProvider extends ContentProvider {
|
|
+ uri.getPathSegments().get(1));
|
|
+ uri.getPathSegments().get(1));
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
|
|
+ case VIRTUAL:
|
|
|
|
+ sqlQuery.setTables(ProviderTableMeta.VIRTUAL_TABLE_NAME);
|
|
|
|
+ if (uri.getPathSegments().size() > 1) {
|
|
|
|
+ sqlQuery.appendWhere(ProviderTableMeta._ID + "=" + uri.getPathSegments().get(1));
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
throw new IllegalArgumentException("Unknown uri id: " + uri);
|
|
throw new IllegalArgumentException("Unknown uri id: " + uri);
|
|
}
|
|
}
|
|
@@ -522,6 +543,9 @@ public class FileContentProvider extends ContentProvider {
|
|
case ARBITRARY_DATA:
|
|
case ARBITRARY_DATA:
|
|
order = ProviderTableMeta.ARBITRARY_DATA_CLOUD_ID;
|
|
order = ProviderTableMeta.ARBITRARY_DATA_CLOUD_ID;
|
|
break;
|
|
break;
|
|
|
|
+ case VIRTUAL:
|
|
|
|
+ order = ProviderTableMeta.VIRTUAL_TYPE;
|
|
|
|
+ break;
|
|
default: // Files
|
|
default: // Files
|
|
order = ProviderTableMeta.FILE_DEFAULT_SORT_ORDER;
|
|
order = ProviderTableMeta.FILE_DEFAULT_SORT_ORDER;
|
|
break;
|
|
break;
|
|
@@ -635,6 +659,9 @@ public class FileContentProvider extends ContentProvider {
|
|
|
|
|
|
// Create arbitrary data table
|
|
// Create arbitrary data table
|
|
createArbitraryData(db);
|
|
createArbitraryData(db);
|
|
|
|
+
|
|
|
|
+ // Create virtual table
|
|
|
|
+ createVirtualTable(db);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -957,11 +984,13 @@ public class FileContentProvider extends ContentProvider {
|
|
db.beginTransaction();
|
|
db.beginTransaction();
|
|
try {
|
|
try {
|
|
createArbitraryData(db);
|
|
createArbitraryData(db);
|
|
|
|
+ createVirtualTable(db);
|
|
upgraded = true;
|
|
upgraded = true;
|
|
db.setTransactionSuccessful();
|
|
db.setTransactionSuccessful();
|
|
} finally {
|
|
} finally {
|
|
db.endTransaction();
|
|
db.endTransaction();
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
if (!upgraded) {
|
|
if (!upgraded) {
|
|
@@ -1047,7 +1076,7 @@ public class FileContentProvider extends ContentProvider {
|
|
+ ProviderTableMeta.CAPABILITIES_FILES_UNDELETE + INTEGER // boolean
|
|
+ ProviderTableMeta.CAPABILITIES_FILES_UNDELETE + INTEGER // boolean
|
|
+ ProviderTableMeta.CAPABILITIES_FILES_VERSIONING + INTEGER // boolean
|
|
+ ProviderTableMeta.CAPABILITIES_FILES_VERSIONING + INTEGER // boolean
|
|
+ ProviderTableMeta.CAPABILITIES_FILES_DROP + INTEGER // boolean
|
|
+ ProviderTableMeta.CAPABILITIES_FILES_DROP + INTEGER // boolean
|
|
- + ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS + " INTEGER );" ); // boolean
|
|
|
|
|
|
+ + ProviderTableMeta.CAPABILITIES_EXTERNAL_LINKS + " INTEGER );"); // boolean
|
|
}
|
|
}
|
|
|
|
|
|
private void createUploadsTable(SQLiteDatabase db) {
|
|
private void createUploadsTable(SQLiteDatabase db) {
|
|
@@ -1113,6 +1142,14 @@ public class FileContentProvider extends ContentProvider {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void createVirtualTable(SQLiteDatabase db) {
|
|
|
|
+ db.execSQL("CREATE TABLE " + ProviderTableMeta.VIRTUAL_TABLE_NAME + "("
|
|
|
|
+ + ProviderTableMeta._ID + " INTEGER PRIMARY KEY, " // id
|
|
|
|
+ + ProviderTableMeta.VIRTUAL_TYPE + " TEXT, " // type
|
|
|
|
+ + ProviderTableMeta.VIRTUAL_OCFILE_ID + " INTEGER )" // file id
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Version 10 of database does not modify its scheme. It coincides with the upgrade of the ownCloud account names
|
|
* Version 10 of database does not modify its scheme. It coincides with the upgrade of the ownCloud account names
|
|
* structure to include in it the path to the server instance. Updating the account names and path to local files
|
|
* structure to include in it the path to the server instance. Updating the account names and path to local files
|
|
@@ -1120,7 +1157,7 @@ public class FileContentProvider extends ContentProvider {
|
|
*
|
|
*
|
|
* See {@link com.owncloud.android.authentication.AccountUtils#updateAccountVersion(android.content.Context)}
|
|
* See {@link com.owncloud.android.authentication.AccountUtils#updateAccountVersion(android.content.Context)}
|
|
*
|
|
*
|
|
- * @param db Database where table of files is included.
|
|
|
|
|
|
+ * @param db Database where table of files is included.
|
|
*/
|
|
*/
|
|
private void updateAccountName(SQLiteDatabase db) {
|
|
private void updateAccountName(SQLiteDatabase db) {
|
|
Log_OC.d(SQL, "THREAD: " + Thread.currentThread().getName());
|
|
Log_OC.d(SQL, "THREAD: " + Thread.currentThread().getName());
|
|
@@ -1177,9 +1214,9 @@ public class FileContentProvider extends ContentProvider {
|
|
* Rename the local ownCloud folder of one account to match the a rename of the account itself. Updates the
|
|
* Rename the local ownCloud folder of one account to match the a rename of the account itself. Updates the
|
|
* table of files in database so that the paths to the local files keep being the same.
|
|
* table of files in database so that the paths to the local files keep being the same.
|
|
*
|
|
*
|
|
- * @param db Database where table of files is included.
|
|
|
|
- * @param newAccountName New name for the target OC account.
|
|
|
|
- * @param oldAccountName Old name of the target OC account.
|
|
|
|
|
|
+ * @param db Database where table of files is included.
|
|
|
|
+ * @param newAccountName New name for the target OC account.
|
|
|
|
+ * @param oldAccountName Old name of the target OC account.
|
|
*/
|
|
*/
|
|
private void updateDownloadedFiles(SQLiteDatabase db, String newAccountName,
|
|
private void updateDownloadedFiles(SQLiteDatabase db, String newAccountName,
|
|
String oldAccountName) {
|
|
String oldAccountName) {
|