11 package com.freerdp.freerdpcore.services;
13 import android.content.ContentValues;
14 import android.database.Cursor;
15 import android.database.sqlite.SQLiteOpenHelper;
17 import com.freerdp.freerdpcore.domain.BookmarkBase;
18 import com.freerdp.freerdpcore.domain.ManualBookmark;
20 import java.util.ArrayList;
35 @Override
protected String getBookmarkTableName()
41 protected void addBookmarkSpecificColumns(
BookmarkBase bookmark, ContentValues columns)
44 columns.put(
BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME, bm.getHostname());
45 columns.put(
BookmarkDB.DB_KEY_BOOKMARK_PORT, bm.getPort());
48 columns.put(
BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE, bm.getEnableGatewaySettings());
49 columns.put(
BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME, bm.getGatewaySettings().getHostname());
50 columns.put(
BookmarkDB.DB_KEY_BOOKMARK_GW_PORT, bm.getGatewaySettings().getPort());
51 columns.put(
BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME, bm.getGatewaySettings().getUsername());
52 columns.put(
BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD, bm.getGatewaySettings().getPassword());
53 columns.put(
BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN, bm.getGatewaySettings().getDomain());
56 @Override
protected void addBookmarkSpecificColumns(ArrayList<String> columns)
58 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME);
60 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE);
61 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME);
62 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_GW_PORT);
63 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME);
64 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD);
65 columns.add(
BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN);
68 @Override
protected void readBookmarkSpecificColumns(
BookmarkBase bookmark, Cursor cursor)
72 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME)));
73 bm.setPort(cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_PORT)));
75 bm.setEnableGatewaySettings(
76 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_GW_ENABLE)) != 0);
77 readGatewaySettings(bm, cursor);
80 public BookmarkBase findByLabelOrHostname(String pattern)
82 if (pattern.length() == 0)
86 queryBookmarks(
BookmarkDB.DB_KEY_BOOKMARK_LABEL +
" = '" + pattern +
"' OR " +
87 BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME +
" = '" + pattern +
"'",
90 if (cursor.moveToFirst() && (cursor.getCount() > 0))
91 bookmark = getBookmarkFromCursor(cursor);
97 public ArrayList<BookmarkBase> findByLabelOrHostnameLike(String pattern)
100 queryBookmarks(
BookmarkDB.DB_KEY_BOOKMARK_LABEL +
" LIKE '%" + pattern +
"%' OR " +
101 BookmarkDB.DB_KEY_BOOKMARK_HOSTNAME +
" LIKE '%" + pattern +
"%'",
103 ArrayList<BookmarkBase> bookmarks =
new ArrayList<>(cursor.getCount());
105 if (cursor.moveToFirst() && (cursor.getCount() > 0))
109 bookmarks.add(getBookmarkFromCursor(cursor));
110 }
while (cursor.moveToNext());
117 private void readGatewaySettings(
ManualBookmark bookmark, Cursor cursor)
120 gatewaySettings.setHostname(
121 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_GW_HOSTNAME)));
122 gatewaySettings.setPort(
123 cursor.getInt(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_GW_PORT)));
124 gatewaySettings.setUsername(
125 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_GW_USERNAME)));
126 gatewaySettings.setPassword(
127 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_GW_PASSWORD)));
128 gatewaySettings.setDomain(
129 cursor.getString(cursor.getColumnIndex(
BookmarkDB.DB_KEY_BOOKMARK_GW_DOMAIN)));