/** * Copyright (C) 2011 Whisper Systems * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 . */ package org.thoughtcrime.securesms.database; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.util.Log; import ws.com.google.android.mms.pdu.CharacterSets; import ws.com.google.android.mms.pdu.EncodedStringValue; import ws.com.google.android.mms.pdu.PduHeaders; import java.io.UnsupportedEncodingException; public class MmsAddressDatabase extends Database { private static final String TABLE_NAME = "mms_addresses"; private static final String ID = "_id"; private static final String MMS_ID = "mms_id"; private static final String TYPE = "type"; private static final String ADDRESS = "address"; private static final String ADDRESS_CHARSET = "address_charset"; public static final String CREATE_TABLE = "CREATE TABLE " + TABLE_NAME + " (" + ID + " INTEGER PRIMARY KEY, " + MMS_ID + " INTEGER, " + TYPE + " INTEGER, " + ADDRESS + " TEXT, " + ADDRESS_CHARSET + " INTEGER);"; public MmsAddressDatabase(Context context, SQLiteOpenHelper databaseHelper) { super(context, databaseHelper); } private void insertAddress(long messageId, int type, EncodedStringValue address) { if (address != null) { SQLiteDatabase database = databaseHelper.getWritableDatabase(); ContentValues contentValues = new ContentValues(); contentValues.put(MMS_ID, messageId); contentValues.put(TYPE, type); contentValues.put(ADDRESS, toIsoString(address.getTextString())); contentValues.put(ADDRESS_CHARSET, address.getCharacterSet()); database.insert(TABLE_NAME, null, contentValues); } } private void insertAddress(long messageId, int type, EncodedStringValue[] addresses) { if (addresses != null) { for (int i=0;i