diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-09-29 11:57:16 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-09-29 11:57:16 +0200 |
commit | 34fcdda53fa8ae1174909b62860534d2d874eb72 (patch) | |
tree | 50564c1d946ef1779567c67ad25a646b446a6403 /src/main/java/de/thedevstack/conversationsplus/persistance/MessageDatabaseAccess.java | |
parent | 297bed106efdfa619d700ae44ce047d7f2663c93 (diff) |
Implements FS#235: Deletion of remote files uploaded via httpupload
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/persistance/MessageDatabaseAccess.java')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/persistance/MessageDatabaseAccess.java | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/persistance/MessageDatabaseAccess.java b/src/main/java/de/thedevstack/conversationsplus/persistance/MessageDatabaseAccess.java deleted file mode 100644 index 7776174d..00000000 --- a/src/main/java/de/thedevstack/conversationsplus/persistance/MessageDatabaseAccess.java +++ /dev/null @@ -1,59 +0,0 @@ -package de.thedevstack.conversationsplus.persistance; - -import android.content.ContentValues; -import android.database.Cursor; -import android.database.sqlite.SQLiteDatabase; - -import de.thedevstack.android.logcat.Logging; -import de.thedevstack.conversationsplus.entities.Message; -import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException; -import de.thedevstack.conversationsplus.xmpp.jid.Jid; - -/** - * Created by steckbrief on 15.04.2016. - */ -public class MessageDatabaseAccess { - static final String TABLE_NAME_ADDITIONAL_PARAMETERS = "message_parameters"; - static final String COLUMN_NAME_MSG_PARAMS_HTTPUPLOAD = "httpupload"; - static final String COLUMN_NAME_MSG_PARAMS_MSGUUID = "message_uuid"; - static final String COLUMN_NAME_MSG_PARAMS_TREATASDOWNLOADABLE_DECISION = "treatasdownloadable_decision"; - - static final String TABLE_ADDITIONAL_PARAMETERS_CREATE_V0 = "CREATE TABLE " + MessageDatabaseAccess.TABLE_NAME_ADDITIONAL_PARAMETERS + " (" - + MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_MSGUUID + " TEXT, " - + MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_HTTPUPLOAD + " INTEGER DEFAULT 0, " - + MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_TREATASDOWNLOADABLE_DECISION + " TEXT DEFAULT 'NOT_DECIDED', " - + "FOREIGN KEY(" + MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_MSGUUID + ") REFERENCES " + Message.TABLENAME + "(" + Message.UUID + ") ON DELETE CASCADE)"; - - static ContentValues getAdditionalParametersContentValues(Message message) { - ContentValues additionalParameters = new ContentValues(); - additionalParameters.put(MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_MSGUUID, message.getUuid()); - additionalParameters.put(MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_HTTPUPLOAD, message.isHttpUploaded() ? 1 : 0); - additionalParameters.put(MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_TREATASDOWNLOADABLE_DECISION, message.treatAsDownloadable().name()); - - return additionalParameters; - } - - static void populateMessageParametersFromCursor(Cursor cursor, Message message) { - boolean isHttpUploaded = CursorHelper.getInt(cursor, COLUMN_NAME_MSG_PARAMS_HTTPUPLOAD) == 1; - message.setHttpUploaded(isHttpUploaded); - String downloadable = CursorHelper.getString(cursor, COLUMN_NAME_MSG_PARAMS_TREATASDOWNLOADABLE_DECISION); - Message.Decision treatAsDownloadable = Message.Decision.NOT_DECIDED; - try { - treatAsDownloadable = Message.Decision.valueOf(downloadable); - } catch (IllegalArgumentException e) { - // Should only happen if the database is corrupted, but to be on the save side catch it here - Logging.e("db.msg", "Unknown Decision for treatAsDownloadable found: '" + downloadable + "'"); - } - message.setTreatAsDownloadable(treatAsDownloadable); - } - - static void populateMessageParameters(SQLiteDatabase db, Message message) { - Cursor paramsCursor = db.query(MessageDatabaseAccess.TABLE_NAME_ADDITIONAL_PARAMETERS, - null, MessageDatabaseAccess.COLUMN_NAME_MSG_PARAMS_MSGUUID + "=?", - new String[] {message.getUuid()}, - null, null, null, null); - paramsCursor.moveToNext(); - MessageDatabaseAccess.populateMessageParametersFromCursor(paramsCursor, message); - paramsCursor.close(); - } -} |