FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
com.freerdp.freerdpcore.services.QuickConnectHistoryGateway Class Reference

Public Member Functions

 QuickConnectHistoryGateway (SQLiteOpenHelper historyDB)
 
ArrayList< BookmarkBase > findHistory (String filter)
 
void addHistoryItem (String item)
 
boolean historyItemExists (String item)
 
void removeHistoryItem (String hostname)
 

Detailed Description

Definition at line 25 of file QuickConnectHistoryGateway.java.

Constructor & Destructor Documentation

◆ QuickConnectHistoryGateway()

com.freerdp.freerdpcore.services.QuickConnectHistoryGateway.QuickConnectHistoryGateway ( SQLiteOpenHelper  historyDB)
inline

Definition at line 30 of file QuickConnectHistoryGateway.java.

31 {
32 this.historyDB = historyDB;
33 }

Member Function Documentation

◆ addHistoryItem()

void com.freerdp.freerdpcore.services.QuickConnectHistoryGateway.addHistoryItem ( String  item)
inline

Definition at line 64 of file QuickConnectHistoryGateway.java.

65 {
66 String insertHistoryItem = "INSERT OR REPLACE INTO " + HistoryDB.QUICK_CONNECT_TABLE_NAME +
67 " (" + HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + ", " +
68 HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP + ") VALUES('" +
69 item + "', datetime('now'))";
70 SQLiteDatabase db = getWritableDatabase();
71 try
72 {
73 db.execSQL(insertHistoryItem);
74 }
75 catch (SQLException e)
76 {
77 Log.v(TAG, e.toString());
78 }
79 }

◆ findHistory()

ArrayList< BookmarkBase > com.freerdp.freerdpcore.services.QuickConnectHistoryGateway.findHistory ( String  filter)
inline

Definition at line 35 of file QuickConnectHistoryGateway.java.

36 {
37 String[] column = { HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM };
38
39 SQLiteDatabase db = getReadableDatabase();
40 String selection =
41 (filter.length() > 0)
42 ? (HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " LIKE '%" + filter + "%'")
43 : null;
44 Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column, selection, null, null,
45 null, HistoryDB.QUICK_CONNECT_TABLE_COL_TIMESTAMP);
46
47 ArrayList<BookmarkBase> result = new ArrayList<>(cursor.getCount());
48 if (cursor.moveToFirst())
49 {
50 do
51 {
52 String hostname =
53 cursor.getString(cursor.getColumnIndex(HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM));
54 QuickConnectBookmark bookmark = new QuickConnectBookmark();
55 bookmark.setLabel(hostname);
56 bookmark.setHostname(hostname);
57 result.add(bookmark);
58 } while (cursor.moveToNext());
59 }
60 cursor.close();
61 return result;
62 }

◆ historyItemExists()

boolean com.freerdp.freerdpcore.services.QuickConnectHistoryGateway.historyItemExists ( String  item)
inline

Definition at line 81 of file QuickConnectHistoryGateway.java.

82 {
83 String[] column = { HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM };
84 SQLiteDatabase db = getReadableDatabase();
85 Cursor cursor = db.query(HistoryDB.QUICK_CONNECT_TABLE_NAME, column,
86 HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + item + "'", null,
87 null, null, null);
88 boolean exists = (cursor.getCount() == 1);
89 cursor.close();
90 return exists;
91 }

◆ removeHistoryItem()

void com.freerdp.freerdpcore.services.QuickConnectHistoryGateway.removeHistoryItem ( String  hostname)
inline

Definition at line 93 of file QuickConnectHistoryGateway.java.

94 {
95 SQLiteDatabase db = getWritableDatabase();
96 db.delete(HistoryDB.QUICK_CONNECT_TABLE_NAME,
97 HistoryDB.QUICK_CONNECT_TABLE_COL_ITEM + " = '" + hostname + "'", null);
98 }

The documentation for this class was generated from the following file: