aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-09-15 03:02:05 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-09-15 03:02:05 +0200
commit3cd54581c33b20a9bfa55f767b245fc6e56e83ef (patch)
tree21719051a67fde85715640c3af8ceaea0d413694 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider
parent3814ae7d53a22ba89f1e39d7a4661016f76cf8c8 (diff)
downloadopen-keychain-3cd54581c33b20a9bfa55f767b245fc6e56e83ef.tar.gz
open-keychain-3cd54581c33b20a9bfa55f767b245fc6e56e83ef.tar.bz2
open-keychain-3cd54581c33b20a9bfa55f767b245fc6e56e83ef.zip
mime: create more general InputDataOperation, which for now and does basic mime parsing
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java22
1 files changed, 15 insertions, 7 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java
index 7e9b24989..67f2c36bc 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/provider/TemporaryStorageProvider.java
@@ -67,8 +67,8 @@ public class TemporaryStorageProvider extends ContentProvider {
private static final String COLUMN_NAME = "name";
private static final String COLUMN_TIME = "time";
private static final String COLUMN_TYPE = "mimetype";
- public static final String CONTENT_AUTHORITY = Constants.TEMPSTORAGE_AUTHORITY;
- private static final Uri BASE_URI = Uri.parse("content://" + CONTENT_AUTHORITY);
+ public static final String AUTHORITY = Constants.TEMPSTORAGE_AUTHORITY;
+ public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
private static final int DB_VERSION = 3;
private static File cacheDir;
@@ -77,18 +77,18 @@ public class TemporaryStorageProvider extends ContentProvider {
ContentValues contentValues = new ContentValues();
contentValues.put(COLUMN_NAME, targetName);
contentValues.put(COLUMN_TYPE, mimeType);
- return context.getContentResolver().insert(BASE_URI, contentValues);
+ return context.getContentResolver().insert(CONTENT_URI, contentValues);
}
public static Uri createFile(Context context, String targetName) {
ContentValues contentValues = new ContentValues();
contentValues.put(COLUMN_NAME, targetName);
- return context.getContentResolver().insert(BASE_URI, contentValues);
+ return context.getContentResolver().insert(CONTENT_URI, contentValues);
}
public static Uri createFile(Context context) {
ContentValues contentValues = new ContentValues();
- return context.getContentResolver().insert(BASE_URI, contentValues);
+ return context.getContentResolver().insert(CONTENT_URI, contentValues);
}
public static int setMimeType(Context context, Uri uri, String mimetype) {
@@ -98,7 +98,7 @@ public class TemporaryStorageProvider extends ContentProvider {
}
public static int cleanUp(Context context) {
- return context.getContentResolver().delete(BASE_URI, COLUMN_TIME + "< ?",
+ return context.getContentResolver().delete(CONTENT_URI, COLUMN_TIME + "< ?",
new String[]{Long.toString(System.currentTimeMillis() - Constants.TEMPFILE_TTL)});
}
@@ -163,12 +163,19 @@ public class TemporaryStorageProvider extends ContentProvider {
throw new SecurityException("Listing temporary files is not allowed, only querying single files.");
}
+ Log.d(Constants.TAG, "being asked for file " + uri);
+
File file;
try {
file = getFile(uri);
+ if (file.exists()) {
+ Log.e(Constants.TAG, "already exists");
+ }
} catch (FileNotFoundException e) {
+ Log.e(Constants.TAG, "file not found!");
return null;
}
+
Cursor fileName = db.getReadableDatabase().query(TABLE_FILES, new String[]{COLUMN_NAME}, COLUMN_ID + "=?",
new String[]{uri.getLastPathSegment()}, null, null, null);
if (fileName != null) {
@@ -236,7 +243,7 @@ public class TemporaryStorageProvider extends ContentProvider {
Log.e(Constants.TAG, "File creation failed!");
return null;
}
- return Uri.withAppendedPath(BASE_URI, uuid);
+ return Uri.withAppendedPath(CONTENT_URI, uuid);
}
@Override
@@ -274,6 +281,7 @@ public class TemporaryStorageProvider extends ContentProvider {
@Override
public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
+ Log.d(Constants.TAG, "openFile");
return openFileHelper(uri, mode);
}