FreeRDP
Loading...
Searching...
No Matches
com.freerdp.freerdpcore.presentation.SessionDialogs Class Reference

Data Structures

interface  OnConnectCancelListener
 
interface  OnUserCancelListener
 

Public Member Functions

 SessionDialogs (Activity activity, OnUserCancelListener cancelListener)
 
boolean promptCredentials (StringBuilder username, StringBuilder domain, StringBuilder password)
 
int verifyCertificate (String host, long port, String subject, String issuer, String fingerprint, long flags)
 
int verifyChangedCertificate (String host, long port, String subject, String issuer, String fingerprint, long flags)
 
void showExperimentalBlocked (String featureName)
 
void showProgress (String title, final OnConnectCancelListener listener)
 
void dismissProgress ()
 

Detailed Description

Owns every dialog that the FreeRDP session may need: the connect-progress spinner, the credentials prompt, and the certificate verification dialogs. The auth/verify methods block the calling (background) thread until the user dismisses the dialog on the UI thread.

Definition at line 37 of file SessionDialogs.java.

Constructor & Destructor Documentation

◆ SessionDialogs()

com.freerdp.freerdpcore.presentation.SessionDialogs.SessionDialogs ( Activity  activity,
OnUserCancelListener  cancelListener 
)
inline

Definition at line 64 of file SessionDialogs.java.

65 {
66 this.activity = activity;
67 this.cancelListener = cancelListener;
68
69 dlgVerifyCertificate = new AlertDialog.Builder(activity)
70 .setTitle(R.string.dlg_title_verify_certificate)
71 .setPositiveButton(android.R.string.yes,
72 (dialog, which) -> {
73 callbackDialogResult = true;
74 synchronized (dialog)
75 {
76 dialog.notify();
77 }
78 })
79 .setNegativeButton(android.R.string.no,
80 (dialog, which) -> {
81 callbackDialogResult = false;
82 notifyCancel();
83 synchronized (dialog)
84 {
85 dialog.notify();
86 }
87 })
88 .setCancelable(false)
89 .create();
90
91 userCredView = activity.getLayoutInflater().inflate(R.layout.credentials, null, true);
92 dlgUserCredentials = new AlertDialog.Builder(activity)
93 .setView(userCredView)
94 .setTitle(R.string.dlg_title_credentials)
95 .setPositiveButton(android.R.string.ok,
96 (dialog, which) -> {
97 callbackDialogResult = true;
98 synchronized (dialog)
99 {
100 dialog.notify();
101 }
102 })
103 .setNegativeButton(android.R.string.cancel,
104 (dialog, which) -> {
105 callbackDialogResult = false;
106 notifyCancel();
107 synchronized (dialog)
108 {
109 dialog.notify();
110 }
111 })
112 .setCancelable(false)
113 .create();
114
115 dlgExperimental = new AlertDialog.Builder(activity)
116 .setTitle(R.string.dlg_title_experimental_feature)
117 .setPositiveButton(R.string.menu_app_settings,
118 (dialog, which) -> {
119 openExperimentalSettings();
120 synchronized (dialog)
121 {
122 dialog.notify();
123 }
124 })
125 .setNegativeButton(android.R.string.cancel,
126 (dialog, which) -> {
127 notifyCancel();
128 synchronized (dialog)
129 {
130 dialog.notify();
131 }
132 })
133 .setCancelable(false)
134 .create();
135 }

Member Function Documentation

◆ dismissProgress()

void com.freerdp.freerdpcore.presentation.SessionDialogs.dismissProgress ( )
inline

Dismisses the connect-progress dialog if it is currently shown.

Definition at line 309 of file SessionDialogs.java.

310 {
311 if (progressDialog != null)
312 {
313 progressDialog.dismiss();
314 progressDialog = null;
315 }
316 }

◆ promptCredentials()

boolean com.freerdp.freerdpcore.presentation.SessionDialogs.promptCredentials ( StringBuilder  username,
StringBuilder  domain,
StringBuilder  password 
)
inline

Shows the credentials dialog and blocks until the user dismisses it. On OK the buffers are overwritten with the entered values.

Definition at line 141 of file SessionDialogs.java.

143 {
144 callbackDialogResult = false;
145
146 ((EditText)userCredView.findViewById(R.id.editTextUsername)).setText(username);
147 ((EditText)userCredView.findViewById(R.id.editTextDomain)).setText(domain);
148 ((EditText)userCredView.findViewById(R.id.editTextPassword)).setText(password);
149
150 showOnUiThread(dlgUserCredentials);
151
152 try
153 {
154 synchronized (dlgUserCredentials)
155 {
156 dlgUserCredentials.wait();
157 }
158 }
159 catch (InterruptedException e)
160 {
161 }
162
163 username.setLength(0);
164 domain.setLength(0);
165 password.setLength(0);
166
167 username.append(
168 ((EditText)userCredView.findViewById(R.id.editTextUsername)).getText().toString());
169 domain.append(
170 ((EditText)userCredView.findViewById(R.id.editTextDomain)).getText().toString());
171 password.append(
172 ((EditText)userCredView.findViewById(R.id.editTextPassword)).getText().toString());
173
174 return callbackDialogResult;
175 }

◆ showExperimentalBlocked()

void com.freerdp.freerdpcore.presentation.SessionDialogs.showExperimentalBlocked ( String  featureName)
inline

Shows an "experimental feature" notice and blocks the calling thread until dismissed.

Definition at line 211 of file SessionDialogs.java.

212 {
213 dlgExperimental.setMessage(
214 activity.getString(R.string.dlg_msg_experimental_feature, featureName));
215
216 showOnUiThread(dlgExperimental);
217
218 try
219 {
220 synchronized (dlgExperimental)
221 {
222 dlgExperimental.wait();
223 }
224 }
225 catch (InterruptedException e)
226 {
227 }
228 }

◆ showProgress()

void com.freerdp.freerdpcore.presentation.SessionDialogs.showProgress ( String  title,
final OnConnectCancelListener  listener 
)
inline

Builds and shows a non-blocking connect-progress dialog. Subsequent calls replace any previously shown progress dialog.

Definition at line 271 of file SessionDialogs.java.

272 {
274
275 int pad = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24,
276 activity.getResources().getDisplayMetrics());
277 LinearLayout content = new LinearLayout(activity);
278 content.setOrientation(LinearLayout.HORIZONTAL);
279 content.setPadding(pad, pad, pad, pad);
280 content.setGravity(Gravity.CENTER_VERTICAL);
281
282 ProgressBar progressBar = new ProgressBar(activity);
283 progressBar.setIndeterminate(true);
284 content.addView(progressBar,
285 new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
286 ViewGroup.LayoutParams.WRAP_CONTENT));
287
288 TextView messageView = new TextView(activity);
289 messageView.setText(R.string.dlg_msg_connecting);
290 LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(
291 ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
292 textParams.leftMargin = pad;
293 content.addView(messageView, textParams);
294
295 progressDialog = new AlertDialog.Builder(activity)
296 .setTitle(title)
297 .setView(content)
298 .setNegativeButton(android.R.string.cancel,
299 (dialog, which) -> {
300 if (listener != null)
301 listener.onConnectCancel();
302 })
303 .setCancelable(false)
304 .create();
305 progressDialog.show();
306 }

◆ verifyCertificate()

int com.freerdp.freerdpcore.presentation.SessionDialogs.verifyCertificate ( String  host,
long  port,
String  subject,
String  issuer,
String  fingerprint,
long  flags 
)
inline

Shows the certificate verification dialog. Returns 1 if accepted, 0 otherwise.

Definition at line 180 of file SessionDialogs.java.

182 {
183 String msg = activity.getResources().getString(R.string.dlg_msg_verify_certificate);
184 String type = "RDP-Server";
185 if ((flags & LibFreeRDP.VERIFY_CERT_FLAG_GATEWAY) != 0)
186 type = "RDP-Gateway";
187 if ((flags & LibFreeRDP.VERIFY_CERT_FLAG_REDIRECT) != 0)
188 type = "RDP-Redirect";
189 msg += "\n\n" + type + ": " + host + ":" + port;
190 msg += "\n\nSubject: " + subject + "\nIssuer: " + issuer;
191 if ((flags & LibFreeRDP.VERIFY_CERT_FLAG_FP_IS_PEM) != 0)
192 msg += "\nCertificate: " + fingerprint;
193 else
194 msg += "\nFingerprint: " + fingerprint;
195
196 return showVerifyDialog(msg);
197 }

◆ verifyChangedCertificate()

int com.freerdp.freerdpcore.presentation.SessionDialogs.verifyChangedCertificate ( String  host,
long  port,
String  subject,
String  issuer,
String  fingerprint,
long  flags 
)
inline

Shows the certificate-changed verification dialog. Returns 1 if accepted, 0 otherwise.

Definition at line 202 of file SessionDialogs.java.

204 {
205 // The "changed" variant currently shows the same information as the
206 // regular verify dialog (matches prior behaviour).
207 return verifyCertificate(host, port, subject, issuer, fingerprint, flags);
208 }
int verifyCertificate(String host, long port, String subject, String issuer, String fingerprint, long flags)

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