11 package com.freerdp.freerdpcore.services;
13 import android.content.ContentValues;
14 import android.database.Cursor;
15 import android.database.sqlite.SQLiteDatabase;
16 import android.database.sqlite.SQLiteException;
17 import android.database.sqlite.SQLiteOpenHelper;
18 import android.database.sqlite.SQLiteQueryBuilder;
19 import android.util.Log;
21 import com.freerdp.freerdpcore.domain.BookmarkBase;
23 import java.util.ArrayList;
27 private final static String TAG =
"BookmarkBaseGateway";
28 private SQLiteOpenHelper bookmarkDB;
30 private static final String JOIN_PREFIX =
"join_";
31 private static final String KEY_BOOKMARK_ID =
"bookmarkId";
32 private static final String KEY_SCREEN_COLORS =
"screenColors";
33 private static final String KEY_SCREEN_COLORS_3G =
"screenColors3G";
34 private static final String KEY_SCREEN_RESOLUTION =
"screenResolution";
35 private static final String KEY_SCREEN_RESOLUTION_3G =
"screenResolution3G";
36 private static final String KEY_SCREEN_WIDTH =
"screenWidth";
37 private static final String KEY_SCREEN_WIDTH_3G =
"screenWidth3G";
38 private static final String KEY_SCREEN_HEIGHT =
"screenHeight";
39 private static final String KEY_SCREEN_HEIGHT_3G =
"screenHeight3G";
41 private static final String KEY_PERFORMANCE_RFX =
"performanceRemoteFX";
42 private static final String KEY_PERFORMANCE_RFX_3G =
"performanceRemoteFX3G";
43 private static final String KEY_PERFORMANCE_GFX =
"performanceGfx";
44 private static final String KEY_PERFORMANCE_GFX_3G =
"performanceGfx3G";
45 private static final String KEY_PERFORMANCE_H264 =
"performanceGfxH264";
46 private static final String KEY_PERFORMANCE_H264_3G =
"performanceGfxH2643G";
47 private static final String KEY_PERFORMANCE_WALLPAPER =
"performanceWallpaper";
48 private static final String KEY_PERFORMANCE_WALLPAPER_3G =
"performanceWallpaper3G";
49 private static final String KEY_PERFORMANCE_THEME =
"performanceTheming";
50 private static final String KEY_PERFORMANCE_THEME_3G =
"performanceTheming3G";
52 private static final String KEY_PERFORMANCE_DRAG =
"performanceFullWindowDrag";
53 private static final String KEY_PERFORMANCE_DRAG_3G =
"performanceFullWindowDrag3G";
54 private static final String KEY_PERFORMANCE_MENU_ANIMATIONS =
"performanceMenuAnimations";
55 private static final String KEY_PERFORMANCE_MENU_ANIMATIONS_3G =
"performanceMenuAnimations3G";
56 private static final String KEY_PERFORMANCE_FONTS =
"performanceFontSmoothing";
57 private static final String KEY_PERFORMANCE_FONTS_3G =
"performanceFontSmoothing3G";
58 private static final String KEY_PERFORMANCE_COMPOSITION =
"performanceDesktopComposition";
59 private static final String KEY_PERFORMANCE_COMPOSITION_3G =
"performanceDesktopComposition3G";
63 this.bookmarkDB = bookmarkDB;
68 protected abstract String getBookmarkTableName();
70 protected abstract void addBookmarkSpecificColumns(ArrayList<String> columns);
72 protected abstract void addBookmarkSpecificColumns(
BookmarkBase bookmark,
73 ContentValues columns);
75 protected abstract void readBookmarkSpecificColumns(
BookmarkBase bookmark, Cursor cursor);
80 SQLiteDatabase db = getWritableDatabase();
81 db.beginTransaction();
84 ContentValues values =
new ContentValues();
85 values.put(
BookmarkDB.DB_KEY_BOOKMARK_LABEL, bookmark.getLabel());
86 values.put(
BookmarkDB.DB_KEY_BOOKMARK_USERNAME, bookmark.getUsername());
87 values.put(
BookmarkDB.DB_KEY_BOOKMARK_PASSWORD, bookmark.getPassword());
88 values.put(
BookmarkDB.DB_KEY_BOOKMARK_DOMAIN, bookmark.getDomain());
90 rowid = insertScreenSettings(db, bookmark.getScreenSettings());
91 values.put(
BookmarkDB.DB_KEY_SCREEN_SETTINGS, rowid);
92 rowid = insertPerformanceFlags(db, bookmark.getPerformanceFlags());
93 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS, rowid);
96 values.put(
BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE,
97 bookmark.getAdvancedSettings().getEnable3GSettings());
99 rowid = insertScreenSettings(db, bookmark.getAdvancedSettings().getScreen3G());
100 values.put(
BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G, rowid);
101 rowid = insertPerformanceFlags(db, bookmark.getAdvancedSettings().getPerformance3G());
102 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G, rowid);
103 values.put(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD,
104 bookmark.getAdvancedSettings().getRedirectSDCard());
105 values.put(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND,
106 bookmark.getAdvancedSettings().getRedirectSound());
107 values.put(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE,
108 bookmark.getAdvancedSettings().getRedirectMicrophone());
109 values.put(
BookmarkDB.DB_KEY_BOOKMARK_SECURITY,
110 bookmark.getAdvancedSettings().getSecurity());
111 values.put(
BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE,
112 bookmark.getAdvancedSettings().getConsoleMode());
113 values.put(
BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM,
114 bookmark.getAdvancedSettings().getRemoteProgram());
115 values.put(
BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR,
116 bookmark.getAdvancedSettings().getWorkDir());
118 values.put(
BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL,
119 bookmark.getDebugSettings().getAsyncChannel());
120 values.put(
BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE,
121 bookmark.getDebugSettings().getAsyncUpdate());
122 values.put(
BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL,
123 bookmark.getDebugSettings().getDebugLevel());
126 addBookmarkSpecificColumns(bookmark, values);
129 db.insertOrThrow(getBookmarkTableName(),
null, values);
130 db.setTransactionSuccessful();
137 SQLiteDatabase db = getWritableDatabase();
138 db.beginTransaction();
141 ContentValues values =
new ContentValues();
142 values.put(
BookmarkDB.DB_KEY_BOOKMARK_LABEL, bookmark.getLabel());
143 values.put(
BookmarkDB.DB_KEY_BOOKMARK_USERNAME, bookmark.getUsername());
144 values.put(
BookmarkDB.DB_KEY_BOOKMARK_PASSWORD, bookmark.getPassword());
145 values.put(
BookmarkDB.DB_KEY_BOOKMARK_DOMAIN, bookmark.getDomain());
147 updateScreenSettings(db, bookmark);
148 updatePerformanceFlags(db, bookmark);
151 values.put(
BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE,
152 bookmark.getAdvancedSettings().getEnable3GSettings());
154 updateScreenSettings3G(db, bookmark);
155 updatePerformanceFlags3G(db, bookmark);
156 values.put(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD,
157 bookmark.getAdvancedSettings().getRedirectSDCard());
158 values.put(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND,
159 bookmark.getAdvancedSettings().getRedirectSound());
160 values.put(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE,
161 bookmark.getAdvancedSettings().getRedirectMicrophone());
162 values.put(
BookmarkDB.DB_KEY_BOOKMARK_SECURITY,
163 bookmark.getAdvancedSettings().getSecurity());
164 values.put(
BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE,
165 bookmark.getAdvancedSettings().getConsoleMode());
166 values.put(
BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM,
167 bookmark.getAdvancedSettings().getRemoteProgram());
168 values.put(
BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR,
169 bookmark.getAdvancedSettings().getWorkDir());
171 values.put(
BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL,
172 bookmark.getDebugSettings().getAsyncChannel());
173 values.put(
BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE,
174 bookmark.getDebugSettings().getAsyncUpdate());
175 values.put(
BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL,
176 bookmark.getDebugSettings().getDebugLevel());
178 addBookmarkSpecificColumns(bookmark, values);
181 boolean res = (db.update(getBookmarkTableName(), values,
182 BookmarkDB.ID +
" = " + bookmark.getId(),
null) == 1);
185 db.setTransactionSuccessful();
191 public void delete(
long id)
193 SQLiteDatabase db = getWritableDatabase();
194 db.delete(getBookmarkTableName(),
BookmarkDB.ID +
" = " +
id,
null);
200 queryBookmarks(getBookmarkTableName() +
"." +
BookmarkDB.ID +
" = " +
id,
null);
201 if (cursor.getCount() == 0)
207 cursor.moveToFirst();
215 Cursor cursor = queryBookmarks(
BookmarkDB.DB_KEY_BOOKMARK_LABEL +
" = '" + label +
"'",
217 if (cursor.getCount() > 1)
218 Log.e(TAG,
"More than one bookmark with the same label found!");
221 if (cursor.moveToFirst() && (cursor.getCount() > 0))
222 bookmark = getBookmarkFromCursor(cursor);
228 public ArrayList<BookmarkBase> findByLabelLike(String pattern)
231 queryBookmarks(
BookmarkDB.DB_KEY_BOOKMARK_LABEL +
" LIKE '%" + pattern +
"%'",
233 ArrayList<BookmarkBase> bookmarks =
new ArrayList<>(cursor.getCount());
235 if (cursor.moveToFirst() && (cursor.getCount() > 0))
239 bookmarks.add(getBookmarkFromCursor(cursor));
240 }
while (cursor.moveToNext());
247 public ArrayList<BookmarkBase> findAll()
249 Cursor cursor = queryBookmarks(
null,
BookmarkDB.DB_KEY_BOOKMARK_LABEL);
250 final int count = cursor.getCount();
251 ArrayList<BookmarkBase> bookmarks =
new ArrayList<>(count);
253 if (cursor.moveToFirst() && (count > 0))
257 bookmarks.add(getBookmarkFromCursor(cursor));
258 }
while (cursor.moveToNext());
265 protected Cursor queryBookmarks(String whereClause, String orderBy)
269 final String tables =
271 JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS +
" ON " + JOIN_PREFIX +
273 "." +
BookmarkDB.DB_KEY_SCREEN_SETTINGS +
" INNER JOIN " +
274 BookmarkDB.DB_TABLE_PERFORMANCE +
" AS " + JOIN_PREFIX +
275 BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
" ON " + JOIN_PREFIX +
277 "." +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
" INNER JOIN " +
278 BookmarkDB.DB_TABLE_SCREEN +
" AS " + JOIN_PREFIX +
279 BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G +
" ON " + JOIN_PREFIX +
281 "." +
BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G +
" INNER JOIN " +
282 BookmarkDB.DB_TABLE_PERFORMANCE +
" AS " + JOIN_PREFIX +
283 BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
" ON " + JOIN_PREFIX +
284 BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." + ID +
" = " +
288 ArrayList<String> columns =
new ArrayList<>();
289 addBookmarkColumns(columns);
290 addScreenSettingsColumns(columns);
291 addPerformanceFlagsColumns(columns);
292 addScreenSettings3GColumns(columns);
293 addPerformanceFlags3GColumns(columns);
295 String[] cols =
new String[columns.size()];
296 columns.toArray(cols);
298 SQLiteDatabase db = getReadableDatabase();
299 final String query = SQLiteQueryBuilder.buildQueryString(
false, tables, cols, whereClause,
300 null,
null, orderBy,
null);
301 return db.rawQuery(query,
null);
304 private void addBookmarkColumns(ArrayList<String> columns)
306 columns.add(getBookmarkTableName() +
"." +
BookmarkDB.ID +
" " + KEY_BOOKMARK_ID);
307 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_LABEL);
308 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_USERNAME);
309 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_PASSWORD);
310 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_DOMAIN);
313 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE);
314 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD);
315 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND);
316 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE);
317 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_SECURITY);
318 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE);
319 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM);
320 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR);
323 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL);
324 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL);
325 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE);
327 addBookmarkSpecificColumns(columns);
330 private void addScreenSettingsColumns(ArrayList<String> columns)
332 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS +
"." +
333 BookmarkDB.DB_KEY_SCREEN_COLORS +
" as " + KEY_SCREEN_COLORS);
334 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS +
"." +
335 BookmarkDB.DB_KEY_SCREEN_RESOLUTION +
" as " + KEY_SCREEN_RESOLUTION);
336 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS +
"." +
337 BookmarkDB.DB_KEY_SCREEN_WIDTH +
" as " + KEY_SCREEN_WIDTH);
338 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS +
"." +
339 BookmarkDB.DB_KEY_SCREEN_HEIGHT +
" as " + KEY_SCREEN_HEIGHT);
342 private void addPerformanceFlagsColumns(ArrayList<String> columns)
344 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
345 BookmarkDB.DB_KEY_PERFORMANCE_RFX +
" as " + KEY_PERFORMANCE_RFX);
346 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
347 BookmarkDB.DB_KEY_PERFORMANCE_GFX +
" as " + KEY_PERFORMANCE_GFX);
348 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
349 BookmarkDB.DB_KEY_PERFORMANCE_H264 +
" as " + KEY_PERFORMANCE_H264);
350 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
351 BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER +
" as " + KEY_PERFORMANCE_WALLPAPER);
352 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
353 BookmarkDB.DB_KEY_PERFORMANCE_THEME +
" as " + KEY_PERFORMANCE_THEME);
354 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
355 BookmarkDB.DB_KEY_PERFORMANCE_DRAG +
" as " + KEY_PERFORMANCE_DRAG);
356 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
357 BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS +
" as " +
358 KEY_PERFORMANCE_MENU_ANIMATIONS);
359 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
360 BookmarkDB.DB_KEY_PERFORMANCE_FONTS +
" as " + KEY_PERFORMANCE_FONTS);
361 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
"." +
362 BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION +
" " + KEY_PERFORMANCE_COMPOSITION);
365 private void addScreenSettings3GColumns(ArrayList<String> columns)
367 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G +
"." +
368 BookmarkDB.DB_KEY_SCREEN_COLORS +
" as " + KEY_SCREEN_COLORS_3G);
369 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G +
"." +
370 BookmarkDB.DB_KEY_SCREEN_RESOLUTION +
" as " + KEY_SCREEN_RESOLUTION_3G);
371 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G +
"." +
372 BookmarkDB.DB_KEY_SCREEN_WIDTH +
" as " + KEY_SCREEN_WIDTH_3G);
373 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G +
"." +
374 BookmarkDB.DB_KEY_SCREEN_HEIGHT +
" as " + KEY_SCREEN_HEIGHT_3G);
377 private void addPerformanceFlags3GColumns(ArrayList<String> columns)
379 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
380 BookmarkDB.DB_KEY_PERFORMANCE_RFX +
" as " + KEY_PERFORMANCE_RFX_3G);
381 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
382 BookmarkDB.DB_KEY_PERFORMANCE_GFX +
" as " + KEY_PERFORMANCE_GFX_3G);
383 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
384 BookmarkDB.DB_KEY_PERFORMANCE_H264 +
" as " + KEY_PERFORMANCE_H264_3G);
385 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
386 BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER +
" as " +
387 KEY_PERFORMANCE_WALLPAPER_3G);
388 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
389 BookmarkDB.DB_KEY_PERFORMANCE_THEME +
" as " + KEY_PERFORMANCE_THEME_3G);
390 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
391 BookmarkDB.DB_KEY_PERFORMANCE_DRAG +
" as " + KEY_PERFORMANCE_DRAG_3G);
392 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
393 BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS +
" as " +
394 KEY_PERFORMANCE_MENU_ANIMATIONS_3G);
395 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
396 BookmarkDB.DB_KEY_PERFORMANCE_FONTS +
" as " + KEY_PERFORMANCE_FONTS_3G);
397 columns.add(JOIN_PREFIX +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
"." +
398 BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION +
" " +
399 KEY_PERFORMANCE_COMPOSITION_3G);
402 protected BookmarkBase getBookmarkFromCursor(Cursor cursor)
405 bookmark.setId(cursor.getLong(cursor.getColumnIndex(KEY_BOOKMARK_ID)));
407 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_LABEL)));
408 bookmark.setUsername(
409 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_USERNAME)));
410 bookmark.setPassword(
411 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_PASSWORD)));
413 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_DOMAIN)));
414 readScreenSettings(bookmark, cursor);
415 readPerformanceFlags(bookmark, cursor);
418 bookmark.getAdvancedSettings().setEnable3GSettings(
419 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_3G_ENABLE)) != 0);
420 readScreenSettings3G(bookmark, cursor);
421 readPerformanceFlags3G(bookmark, cursor);
422 bookmark.getAdvancedSettings().setRedirectSDCard(
423 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SDCARD)) != 0);
424 bookmark.getAdvancedSettings().setRedirectSound(
425 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_SOUND)));
426 bookmark.getAdvancedSettings().setRedirectMicrophone(
427 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_REDIRECT_MICROPHONE)) !=
429 bookmark.getAdvancedSettings().setSecurity(
430 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_SECURITY)));
431 bookmark.getAdvancedSettings().setConsoleMode(
432 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_CONSOLE_MODE)) != 0);
433 bookmark.getAdvancedSettings().setRemoteProgram(
434 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_REMOTE_PROGRAM)));
435 bookmark.getAdvancedSettings().setWorkDir(
436 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_WORK_DIR)));
438 bookmark.getDebugSettings().setAsyncChannel(
439 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_ASYNC_CHANNEL)) == 1);
440 bookmark.getDebugSettings().setAsyncUpdate(
441 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_ASYNC_UPDATE)) == 1);
442 bookmark.getDebugSettings().setDebugLevel(
443 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_DEBUG_LEVEL)));
445 readBookmarkSpecificColumns(bookmark, cursor);
450 private void readScreenSettings(
BookmarkBase bookmark, Cursor cursor)
453 screenSettings.setColors(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_COLORS)));
454 screenSettings.setResolution(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_RESOLUTION)));
455 screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_WIDTH)));
456 screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_HEIGHT)));
459 private void readPerformanceFlags(
BookmarkBase bookmark, Cursor cursor)
462 perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_RFX)) != 0);
463 perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_GFX)) != 0);
464 perfFlags.setH264(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_H264)) != 0);
465 perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_WALLPAPER)) !=
467 perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_THEME)) != 0);
468 perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_DRAG)) !=
470 perfFlags.setMenuAnimations(
471 cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_MENU_ANIMATIONS)) != 0);
472 perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_FONTS)) !=
474 perfFlags.setDesktopComposition(
475 cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_COMPOSITION)) != 0);
478 private void readScreenSettings3G(
BookmarkBase bookmark, Cursor cursor)
481 screenSettings.setColors(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_COLORS_3G)));
482 screenSettings.setResolution(
483 cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_RESOLUTION_3G)));
484 screenSettings.setWidth(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_WIDTH_3G)));
485 screenSettings.setHeight(cursor.getInt(cursor.getColumnIndex(KEY_SCREEN_HEIGHT_3G)));
488 private void readPerformanceFlags3G(
BookmarkBase bookmark, Cursor cursor)
491 perfFlags.setRemoteFX(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_RFX_3G)) != 0);
492 perfFlags.setGfx(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_GFX_3G)) != 0);
493 perfFlags.setH264(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_H264_3G)) != 0);
494 perfFlags.setWallpaper(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_WALLPAPER_3G)) !=
496 perfFlags.setTheming(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_THEME_3G)) != 0);
497 perfFlags.setFullWindowDrag(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_DRAG_3G)) !=
499 perfFlags.setMenuAnimations(
500 cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_MENU_ANIMATIONS_3G)) != 0);
501 perfFlags.setFontSmoothing(cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_FONTS_3G)) !=
503 perfFlags.setDesktopComposition(
504 cursor.getInt(cursor.getColumnIndex(KEY_PERFORMANCE_COMPOSITION_3G)) != 0);
508 ContentValues values)
510 values.put(
BookmarkDB.DB_KEY_SCREEN_COLORS, settings.getColors());
511 values.put(
BookmarkDB.DB_KEY_SCREEN_RESOLUTION, settings.getResolution());
512 values.put(
BookmarkDB.DB_KEY_SCREEN_WIDTH, settings.getWidth());
513 values.put(
BookmarkDB.DB_KEY_SCREEN_HEIGHT, settings.getHeight());
517 ContentValues values)
519 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_RFX, perfFlags.getRemoteFX());
520 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_GFX, perfFlags.getGfx());
521 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_H264, perfFlags.getH264());
522 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_WALLPAPER, perfFlags.getWallpaper());
523 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_THEME, perfFlags.getTheming());
524 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_DRAG, perfFlags.getFullWindowDrag());
525 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_MENU_ANIMATIONS, perfFlags.getMenuAnimations());
526 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_FONTS, perfFlags.getFontSmoothing());
527 values.put(
BookmarkDB.DB_KEY_PERFORMANCE_COMPOSITION, perfFlags.getDesktopComposition());
532 ContentValues values =
new ContentValues();
533 fillScreenSettingsContentValues(settings, values);
534 return db.insertOrThrow(
BookmarkDB.DB_TABLE_SCREEN,
null, values);
537 private boolean updateScreenSettings(SQLiteDatabase db,
BookmarkBase bookmark)
539 ContentValues values =
new ContentValues();
540 fillScreenSettingsContentValues(bookmark.getScreenSettings(), values);
542 +
"(SELECT " +
BookmarkDB.DB_KEY_SCREEN_SETTINGS +
" FROM " +
543 getBookmarkTableName() +
" WHERE " +
BookmarkDB.ID +
" = " +
544 bookmark.getId() +
");";
545 return (db.update(
BookmarkDB.DB_TABLE_SCREEN, values, whereClause,
null) == 1);
548 private boolean updateScreenSettings3G(SQLiteDatabase db,
BookmarkBase bookmark)
550 ContentValues values =
new ContentValues();
551 fillScreenSettingsContentValues(bookmark.getAdvancedSettings().getScreen3G(), values);
553 +
"(SELECT " +
BookmarkDB.DB_KEY_SCREEN_SETTINGS_3G +
" FROM " +
554 getBookmarkTableName() +
" WHERE " +
BookmarkDB.ID +
" = " +
555 bookmark.getId() +
");";
556 return (db.update(
BookmarkDB.DB_TABLE_SCREEN, values, whereClause,
null) == 1);
561 ContentValues values =
new ContentValues();
562 fillPerformanceFlagsContentValues(perfFlags, values);
563 return db.insertOrThrow(
BookmarkDB.DB_TABLE_PERFORMANCE,
null, values);
566 private boolean updatePerformanceFlags(SQLiteDatabase db,
BookmarkBase bookmark)
568 ContentValues values =
new ContentValues();
569 fillPerformanceFlagsContentValues(bookmark.getPerformanceFlags(), values);
571 +
"(SELECT " +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS +
" FROM " +
572 getBookmarkTableName() +
" WHERE " +
BookmarkDB.ID +
" = " +
573 bookmark.getId() +
");";
574 return (db.update(
BookmarkDB.DB_TABLE_PERFORMANCE, values, whereClause,
null) == 1);
577 private boolean updatePerformanceFlags3G(SQLiteDatabase db,
BookmarkBase bookmark)
579 ContentValues values =
new ContentValues();
580 fillPerformanceFlagsContentValues(bookmark.getAdvancedSettings().getPerformance3G(),
583 +
"(SELECT " +
BookmarkDB.DB_KEY_PERFORMANCE_FLAGS_3G +
" FROM " +
584 getBookmarkTableName() +
" WHERE " +
BookmarkDB.ID +
" = " +
585 bookmark.getId() +
");";
586 return (db.update(
BookmarkDB.DB_TABLE_PERFORMANCE, values, whereClause,
null) == 1);
592 private SQLiteDatabase getWritableDatabase()
594 return bookmarkDB.getWritableDatabase();
597 private SQLiteDatabase getReadableDatabase()
602 db = bookmarkDB.getReadableDatabase();
604 catch (SQLiteException e)
606 db = bookmarkDB.getWritableDatabase();