FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.presentation.SessionViewModel Class Reference
Inheritance diagram for com.freerdp.freerdpcore.presentation.SessionViewModel:
Collaboration diagram for com.freerdp.freerdpcore.presentation.SessionViewModel:

Data Structures

enum  ConnectionState
 

Public Member Functions

 SessionViewModel (@NonNull Application application)
 
LiveData< ConnectionStategetState ()
 
void register (long instance)
 
void unregister ()
 
void loadBookmarkById (long bookmarkId, @NonNull Consumer< BookmarkBase > callback)
 
void recordQuickConnectHistory (@NonNull String hostname)
 

Protected Member Functions

void onCleared ()
 

Detailed Description

Definition at line 33 of file SessionViewModel.java.


Data Structure Documentation

◆ com::freerdp::freerdpcore::presentation::SessionViewModel::ConnectionState

enum com::freerdp::freerdpcore::presentation::SessionViewModel::ConnectionState

Definition at line 35 of file SessionViewModel.java.

Enumerator
CONNECTED
CONNECTING
DISCONNECTED
FAILED
IDLE

Constructor & Destructor Documentation

◆ SessionViewModel()

com.freerdp.freerdpcore.presentation.SessionViewModel.SessionViewModel ( @NonNull Application  application)
inline

Definition at line 53 of file SessionViewModel.java.

54 {
55 super(application);
56 manualBookmarkGateway =
57 new ManualBookmarkGateway(AppDatabase.getInstance(application).bookmarkDao());
58 quickConnectHistoryGateway =
59 new QuickConnectHistoryGateway(HistoryDatabase.getInstance(application).historyDao());
60 }

Member Function Documentation

◆ getState()

LiveData< ConnectionState > com.freerdp.freerdpcore.presentation.SessionViewModel.getState ( )
inline

Definition at line 62 of file SessionViewModel.java.

63 {
64 return state;
65 }

◆ loadBookmarkById()

void com.freerdp.freerdpcore.presentation.SessionViewModel.loadBookmarkById ( long  bookmarkId,
@NonNull Consumer< BookmarkBase >  callback 
)
inline

Loads a bookmark by id off the UI thread and delivers the result on the main thread.

Definition at line 102 of file SessionViewModel.java.

103 {
104 executor.execute(() -> {
105 final BookmarkBase bookmark = manualBookmarkGateway.findById(bookmarkId);
106 mainHandler.post(() -> callback.accept(bookmark));
107 });
108 }

◆ onCleared()

void com.freerdp.freerdpcore.presentation.SessionViewModel.onCleared ( )
inlineprotected

Definition at line 121 of file SessionViewModel.java.

122 {
123 unregister();
124 executor.shutdown();
125 super.onCleared();
126 }

◆ recordQuickConnectHistory()

void com.freerdp.freerdpcore.presentation.SessionViewModel.recordQuickConnectHistory ( @NonNull String  hostname)
inline

Inserts the given hostname into quick-connect history off the UI thread (no-op on duplicate).

Definition at line 113 of file SessionViewModel.java.

114 {
115 executor.execute(() -> {
116 if (!quickConnectHistoryGateway.historyItemExists(hostname))
117 quickConnectHistoryGateway.addHistoryItem(hostname);
118 });
119 }

◆ register()

void com.freerdp.freerdpcore.presentation.SessionViewModel.register ( long  instance)
inline

Definition at line 67 of file SessionViewModel.java.

68 {
69 unregister();
70 registeredInstance = instance;
71 state.setValue(ConnectionState.CONNECTING);
72 GlobalApp.registerSessionListener(instance, new GlobalApp.SessionEventListener() {
73 @Override public void onConnectionSuccess()
74 {
75 state.setValue(ConnectionState.CONNECTED);
76 }
77
78 @Override public void onConnectionFailure()
79 {
80 state.setValue(ConnectionState.FAILED);
81 }
82
83 @Override public void onDisconnected()
84 {
85 state.setValue(ConnectionState.DISCONNECTED);
86 }
87 });
88 }

◆ unregister()

void com.freerdp.freerdpcore.presentation.SessionViewModel.unregister ( )
inline

Definition at line 90 of file SessionViewModel.java.

91 {
92 if (registeredInstance != 0)
93 {
94 GlobalApp.unregisterSessionListener(registeredInstance);
95 registeredInstance = 0;
96 }
97 }

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