comparison src/com/five_ten_sg/connectbot/util/HostDatabase.java @ 238:bd803721f94a

remove unused update preference; add host preference for fixed screen size
author Carl Byington <carl@five-ten-sg.com>
date Mon, 14 Jul 2014 09:42:20 -0700
parents dfdbc75cd45f
children 8b68dfb283d2
comparison
equal deleted inserted replaced
237:f9b1a07c0e96 238:bd803721f94a
44 public class HostDatabase extends RobustSQLiteOpenHelper { 44 public class HostDatabase extends RobustSQLiteOpenHelper {
45 45
46 public final static String TAG = "ConnectBot.HostDatabase"; 46 public final static String TAG = "ConnectBot.HostDatabase";
47 47
48 public final static String DB_NAME = "hosts"; 48 public final static String DB_NAME = "hosts";
49 public final static int DB_VERSION = 27; 49 public final static int DB_VERSION = 28;
50 50
51 public final static String TABLE_HOSTS = "hosts"; 51 public final static String TABLE_HOSTS = "hosts";
52 public final static String FIELD_HOST_NICKNAME = "nickname"; 52 public final static String FIELD_HOST_NICKNAME = "nickname";
53 public final static String FIELD_HOST_PROTOCOL = "protocol"; 53 public final static String FIELD_HOST_PROTOCOL = "protocol";
54 public final static String FIELD_HOST_USERNAME = "username"; 54 public final static String FIELD_HOST_USERNAME = "username";
63 public final static String FIELD_HOST_POSTLOGIN = "postlogin"; 63 public final static String FIELD_HOST_POSTLOGIN = "postlogin";
64 public final static String FIELD_HOST_PUBKEYID = "pubkeyid"; 64 public final static String FIELD_HOST_PUBKEYID = "pubkeyid";
65 public final static String FIELD_HOST_WANTSESSION = "wantsession"; 65 public final static String FIELD_HOST_WANTSESSION = "wantsession";
66 public final static String FIELD_HOST_DELKEY = "delkey"; 66 public final static String FIELD_HOST_DELKEY = "delkey";
67 public final static String FIELD_HOST_FONTSIZE = "fontsize"; 67 public final static String FIELD_HOST_FONTSIZE = "fontsize";
68 public final static String FIELD_HOST_FIXEDSIZE = "fixed_size";
69 public final static String FIELD_HOST_FIXEDWIDTH = "fixed_width";
70 public final static String FIELD_HOST_FIXEDHEIGHT = "fixed_height";
68 public final static String FIELD_HOST_COMPRESSION = "compression"; 71 public final static String FIELD_HOST_COMPRESSION = "compression";
69 public final static String FIELD_HOST_HTTPPROXY = "httpproxy"; 72 public final static String FIELD_HOST_HTTPPROXY = "httpproxy";
70 public final static String FIELD_HOST_ENCODING = "encoding"; 73 public final static String FIELD_HOST_ENCODING = "encoding";
71 public final static String FIELD_HOST_STAYCONNECTED = "stayconnected"; 74 public final static String FIELD_HOST_STAYCONNECTED = "stayconnected";
72 public final static String FIELD_HOST_WANTX11FORWARD = "wantx11forward"; 75 public final static String FIELD_HOST_WANTX11FORWARD = "wantx11forward";
176 + FIELD_HOST_USEAUTHAGENT + " TEXT, " 179 + FIELD_HOST_USEAUTHAGENT + " TEXT, "
177 + FIELD_HOST_POSTLOGIN + " TEXT, " 180 + FIELD_HOST_POSTLOGIN + " TEXT, "
178 + FIELD_HOST_PUBKEYID + " INTEGER DEFAULT " + PUBKEYID_ANY + ", " 181 + FIELD_HOST_PUBKEYID + " INTEGER DEFAULT " + PUBKEYID_ANY + ", "
179 + FIELD_HOST_DELKEY + " TEXT DEFAULT '" + DELKEY_DEL + "', " 182 + FIELD_HOST_DELKEY + " TEXT DEFAULT '" + DELKEY_DEL + "', "
180 + FIELD_HOST_FONTSIZE + " REAL, " 183 + FIELD_HOST_FONTSIZE + " REAL, "
184 + FIELD_HOST_FIXEDSIZE + " TEXT DEFAULT '" + Boolean.toString(false) + "', "
185 + FIELD_HOST_FIXEDWIDTH + " INTEGER, "
186 + FIELD_HOST_FIXEDHEIGHT + " INTEGER, "
181 + FIELD_HOST_WANTSESSION + " TEXT DEFAULT '" + Boolean.toString(true) + "', " 187 + FIELD_HOST_WANTSESSION + " TEXT DEFAULT '" + Boolean.toString(true) + "', "
182 + FIELD_HOST_COMPRESSION + " TEXT DEFAULT '" + Boolean.toString(false) + "', " 188 + FIELD_HOST_COMPRESSION + " TEXT DEFAULT '" + Boolean.toString(false) + "', "
183 + FIELD_HOST_HTTPPROXY + " TEXT, " 189 + FIELD_HOST_HTTPPROXY + " TEXT, "
184 + FIELD_HOST_ENCODING + " TEXT DEFAULT '" + ENCODING_DEFAULT + "', " 190 + FIELD_HOST_ENCODING + " TEXT DEFAULT '" + ENCODING_DEFAULT + "', "
185 + FIELD_HOST_STAYCONNECTED + " TEXT, " 191 + FIELD_HOST_STAYCONNECTED + " TEXT, "
213 db.execSQL(CREATE_TABLE_COLOR_DEFAULTS_INDEX); 219 db.execSQL(CREATE_TABLE_COLOR_DEFAULTS_INDEX);
214 } 220 }
215 221
216 @Override 222 @Override
217 public void onRobustUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) throws SQLiteException { 223 public void onRobustUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) throws SQLiteException {
218 // Versions of the database before the Android Market release will be 224 // Versions of the database before 510ConnectBot will be shot without warning.
219 // shot without warning. 225 if (oldVersion < 24) {
220 if (oldVersion <= 9) {
221 db.execSQL("DROP TABLE IF EXISTS " + TABLE_HOSTS); 226 db.execSQL("DROP TABLE IF EXISTS " + TABLE_HOSTS);
222 onCreate(db); 227 onCreate(db);
223 return; 228 return;
224 } 229 }
225 230
226 switch (oldVersion) { 231 switch (oldVersion) {
227 case 10:
228 db.execSQL("ALTER TABLE " + TABLE_HOSTS
229 + " ADD COLUMN " + FIELD_HOST_PUBKEYID + " INTEGER DEFAULT " + PUBKEYID_ANY);
230
231 case 11:
232 db.execSQL("CREATE TABLE " + TABLE_PORTFORWARDS
233 + " (_id INTEGER PRIMARY KEY, "
234 + FIELD_PORTFORWARD_HOSTID + " INTEGER, "
235 + FIELD_PORTFORWARD_NICKNAME + " TEXT, "
236 + FIELD_PORTFORWARD_TYPE + " TEXT NOT NULL DEFAULT " + PORTFORWARD_LOCAL + ", "
237 + FIELD_PORTFORWARD_SOURCEPORT + " INTEGER NOT NULL DEFAULT 8080, "
238 + FIELD_PORTFORWARD_DESTADDR + " TEXT, "
239 + FIELD_PORTFORWARD_DESTPORT + " INTEGER)");
240
241 case 12:
242 db.execSQL("ALTER TABLE " + TABLE_HOSTS
243 + " ADD COLUMN " + FIELD_HOST_WANTSESSION + " TEXT DEFAULT '" + Boolean.toString(true) + "'");
244
245 case 13:
246 db.execSQL("ALTER TABLE " + TABLE_HOSTS
247 + " ADD COLUMN " + FIELD_HOST_COMPRESSION + " TEXT DEFAULT '" + Boolean.toString(false) + "'");
248
249 case 14:
250 db.execSQL("ALTER TABLE " + TABLE_HOSTS
251 + " ADD COLUMN " + FIELD_HOST_ENCODING + " TEXT DEFAULT '" + ENCODING_DEFAULT + "'");
252
253 case 15:
254 db.execSQL("ALTER TABLE " + TABLE_HOSTS
255 + " ADD COLUMN " + FIELD_HOST_PROTOCOL + " TEXT DEFAULT 'ssh'");
256
257 case 16:
258 db.execSQL("ALTER TABLE " + TABLE_HOSTS
259 + " ADD COLUMN " + FIELD_HOST_DELKEY + " TEXT DEFAULT '" + DELKEY_DEL + "'");
260
261 case 17:
262 db.execSQL("CREATE INDEX " + TABLE_PORTFORWARDS + FIELD_PORTFORWARD_HOSTID + "index ON "
263 + TABLE_PORTFORWARDS + " (" + FIELD_PORTFORWARD_HOSTID + ");");
264 // Add colors
265 db.execSQL("CREATE TABLE " + TABLE_COLORS
266 + " (_id INTEGER PRIMARY KEY, "
267 + FIELD_COLOR_NUMBER + " INTEGER, "
268 + FIELD_COLOR_VALUE + " INTEGER, "
269 + FIELD_COLOR_SCHEME + " INTEGER)");
270 db.execSQL("CREATE INDEX " + TABLE_COLORS + FIELD_COLOR_SCHEME + "index ON "
271 + TABLE_COLORS + " (" + FIELD_COLOR_SCHEME + ");");
272
273 case 18:
274 db.execSQL("ALTER TABLE " + TABLE_HOSTS
275 + " ADD COLUMN " + FIELD_HOST_USEAUTHAGENT + " TEXT DEFAULT '" + AUTHAGENT_NO + "'");
276
277 case 19:
278 db.execSQL("ALTER TABLE " + TABLE_HOSTS
279 + " ADD COLUMN " + FIELD_HOST_STAYCONNECTED + " TEXT");
280
281 case 20:
282 db.execSQL("ALTER TABLE " + TABLE_HOSTS
283 + " ADD COLUMN " + FIELD_HOST_FONTSIZE + " REAL");
284
285 case 21:
286 db.execSQL("DROP TABLE " + TABLE_COLOR_DEFAULTS);
287 db.execSQL(CREATE_TABLE_COLOR_DEFAULTS);
288 db.execSQL(CREATE_TABLE_COLOR_DEFAULTS_INDEX);
289
290 case 22:
291 db.execSQL("ALTER TABLE " + TABLE_HOSTS
292 + " ADD COLUMN " + FIELD_HOST_WANTX11FORWARD + " TEXT DEFAULT '" + Boolean.toString(false) + "'");
293 db.execSQL("ALTER TABLE " + TABLE_HOSTS
294 + " ADD COLUMN " + FIELD_HOST_X11HOST + " TEXT DEFAULT '" + X11HOST_DEFAULT + "'");
295 db.execSQL("ALTER TABLE " + TABLE_HOSTS
296 + " ADD COLUMN " + FIELD_HOST_X11PORT + " INTEGER DEFAULT " + X11PORT_DEFAULT);
297
298 case 23:
299 db.execSQL("ALTER TABLE " + TABLE_HOSTS
300 + " ADD COLUMN " + FIELD_HOST_HTTPPROXY + " TEXT");
301
302 case 24: 232 case 24:
303 db.execSQL("ALTER TABLE " + TABLE_HOSTS 233 db.execSQL("ALTER TABLE " + TABLE_HOSTS
304 + " ADD COLUMN " + FIELD_HOST_MONITOR + " TEXT"); 234 + " ADD COLUMN " + FIELD_HOST_MONITOR + " TEXT");
305 235
306 case 25: 236 case 25:
314 + " ADD COLUMN " + FIELD_HOST_LIBRARY5250 + " TEXT"); 244 + " ADD COLUMN " + FIELD_HOST_LIBRARY5250 + " TEXT");
315 db.execSQL("ALTER TABLE " + TABLE_HOSTS 245 db.execSQL("ALTER TABLE " + TABLE_HOSTS
316 + " ADD COLUMN " + FIELD_HOST_MENU5250 + " TEXT"); 246 + " ADD COLUMN " + FIELD_HOST_MENU5250 + " TEXT");
317 db.execSQL("ALTER TABLE " + TABLE_HOSTS 247 db.execSQL("ALTER TABLE " + TABLE_HOSTS
318 + " ADD COLUMN " + FIELD_HOST_PROGRAM5250 + " TEXT"); 248 + " ADD COLUMN " + FIELD_HOST_PROGRAM5250 + " TEXT");
249
250 case 27:
251 db.execSQL("ALTER TABLE " + TABLE_HOSTS
252 + " ADD COLUMN " + FIELD_HOST_FIXEDSIZE + " TEXT DEFAULT '" + Boolean.toString(false) + "'");
253 db.execSQL("ALTER TABLE " + TABLE_HOSTS
254 + " ADD COLUMN " + FIELD_HOST_FIXEDWIDTH + " INTEGER");
255 db.execSQL("ALTER TABLE " + TABLE_HOSTS
256 + " ADD COLUMN " + FIELD_HOST_FIXEDHEIGHT + " INTEGER");
319 } 257 }
320 } 258 }
321 259
322 /** 260 /**
323 * Touch a specific host to update its "last connected" field. 261 * Touch a specific host to update its "last connected" field.
420 COL_POSTLOGIN = c.getColumnIndexOrThrow(FIELD_HOST_POSTLOGIN), 358 COL_POSTLOGIN = c.getColumnIndexOrThrow(FIELD_HOST_POSTLOGIN),
421 COL_PUBKEYID = c.getColumnIndexOrThrow(FIELD_HOST_PUBKEYID), 359 COL_PUBKEYID = c.getColumnIndexOrThrow(FIELD_HOST_PUBKEYID),
422 COL_WANTSESSION = c.getColumnIndexOrThrow(FIELD_HOST_WANTSESSION), 360 COL_WANTSESSION = c.getColumnIndexOrThrow(FIELD_HOST_WANTSESSION),
423 COL_DELKEY = c.getColumnIndexOrThrow(FIELD_HOST_DELKEY), 361 COL_DELKEY = c.getColumnIndexOrThrow(FIELD_HOST_DELKEY),
424 COL_FONTSIZE = c.getColumnIndexOrThrow(FIELD_HOST_FONTSIZE), 362 COL_FONTSIZE = c.getColumnIndexOrThrow(FIELD_HOST_FONTSIZE),
363 COL_FIXEDSIZE = c.getColumnIndexOrThrow(FIELD_HOST_FIXEDSIZE),
364 COL_FIXEDWIDTH = c.getColumnIndexOrThrow(FIELD_HOST_FIXEDWIDTH),
365 COL_FIXEDHEIGHT = c.getColumnIndexOrThrow(FIELD_HOST_FIXEDHEIGHT),
425 COL_COMPRESSION = c.getColumnIndexOrThrow(FIELD_HOST_COMPRESSION), 366 COL_COMPRESSION = c.getColumnIndexOrThrow(FIELD_HOST_COMPRESSION),
426 COL_HTTPPROXY = c.getColumnIndexOrThrow(FIELD_HOST_HTTPPROXY), 367 COL_HTTPPROXY = c.getColumnIndexOrThrow(FIELD_HOST_HTTPPROXY),
427 COL_ENCODING = c.getColumnIndexOrThrow(FIELD_HOST_ENCODING), 368 COL_ENCODING = c.getColumnIndexOrThrow(FIELD_HOST_ENCODING),
428 COL_STAYCONNECTED = c.getColumnIndexOrThrow(FIELD_HOST_STAYCONNECTED), 369 COL_STAYCONNECTED = c.getColumnIndexOrThrow(FIELD_HOST_STAYCONNECTED),
429 COL_WANTX11FORWARD = c.getColumnIndexOrThrow(FIELD_HOST_WANTX11FORWARD), 370 COL_WANTX11FORWARD = c.getColumnIndexOrThrow(FIELD_HOST_WANTX11FORWARD),
448 host.setColor(c.getString(COL_COLOR)); 389 host.setColor(c.getString(COL_COLOR));
449 host.setUseKeys(Boolean.valueOf(c.getString(COL_USEKEYS))); 390 host.setUseKeys(Boolean.valueOf(c.getString(COL_USEKEYS)));
450 host.setUseAuthAgent(c.getString(COL_USEAUTHAGENT)); 391 host.setUseAuthAgent(c.getString(COL_USEAUTHAGENT));
451 host.setPostLogin(c.getString(COL_POSTLOGIN)); 392 host.setPostLogin(c.getString(COL_POSTLOGIN));
452 host.setPubkeyId(c.getLong(COL_PUBKEYID)); 393 host.setPubkeyId(c.getLong(COL_PUBKEYID));
453 host.setWantSession(Boolean.valueOf(c.getString(COL_WANTSESSION)));
454 host.setDelKey(c.getString(COL_DELKEY)); 394 host.setDelKey(c.getString(COL_DELKEY));
455 host.setFontSize(c.getFloat(COL_FONTSIZE)); 395 host.setFontSize(c.getFloat(COL_FONTSIZE));
396 host.setFixedSize(Boolean.valueOf(c.getString(COL_FIXEDSIZE)));
397 host.setFixedWidth(c.getLong(COL_FIXEDWIDTH));
398 host.setFixedHeight(c.getLong(COL_FIXEDHEIGHT));
399 host.setWantSession(Boolean.valueOf(c.getString(COL_WANTSESSION)));
456 host.setCompression(Boolean.valueOf(c.getString(COL_COMPRESSION))); 400 host.setCompression(Boolean.valueOf(c.getString(COL_COMPRESSION)));
457 host.setHttpproxy(c.getString(COL_HTTPPROXY)); 401 host.setHttpproxy(c.getString(COL_HTTPPROXY));
458 host.setEncoding(c.getString(COL_ENCODING)); 402 host.setEncoding(c.getString(COL_ENCODING));
459 host.setStayConnected(Boolean.valueOf(c.getString(COL_STAYCONNECTED))); 403 host.setStayConnected(Boolean.valueOf(c.getString(COL_STAYCONNECTED)));
460 host.setWantX11Forward(Boolean.valueOf(c.getString(COL_WANTX11FORWARD))); 404 host.setWantX11Forward(Boolean.valueOf(c.getString(COL_WANTX11FORWARD)));