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 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 35 of file SessionDialogs.java.

Constructor & Destructor Documentation

◆ SessionDialogs()

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

Definition at line 61 of file SessionDialogs.java.

62 {
63 this.activity = activity;
64 this.cancelListener = cancelListener;
65
66 dlgVerifyCertificate = new AlertDialog.Builder(activity)
67 .setTitle(R.string.dlg_title_verify_certificate)
68 .setPositiveButton(android.R.string.yes,
69 (dialog, which) -> {
70 callbackDialogResult = true;
71 synchronized (dialog)
72 {
73 dialog.notify();
74 }
75 })
76 .setNegativeButton(android.R.string.no,
77 (dialog, which) -> {
78 callbackDialogResult = false;
79 notifyCancel();
80 synchronized (dialog)
81 {
82 dialog.notify();
83 }
84 })
85 .setCancelable(false)
86 .create();
87
88 userCredView = activity.getLayoutInflater().inflate(R.layout.credentials, null, true);
89 dlgUserCredentials = new AlertDialog.Builder(activity)
90 .setView(userCredView)
91 .setTitle(R.string.dlg_title_credentials)
92 .setPositiveButton(android.R.string.ok,
93 (dialog, which) -> {
94 callbackDialogResult = true;
95 synchronized (dialog)
96 {
97 dialog.notify();
98 }
99 })
100 .setNegativeButton(android.R.string.cancel,
101 (dialog, which) -> {
102 callbackDialogResult = false;
103 notifyCancel();
104 synchronized (dialog)
105 {
106 dialog.notify();
107 }
108 })
109 .setCancelable(false)
110 .create();
111 }

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 260 of file SessionDialogs.java.

261 {
262 if (progressDialog != null)
263 {
264 progressDialog.dismiss();
265 progressDialog = null;
266 }
267 }

◆ 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 117 of file SessionDialogs.java.

119 {
120 callbackDialogResult = false;
121
122 ((EditText)userCredView.findViewById(R.id.editTextUsername)).setText(username);
123 ((EditText)userCredView.findViewById(R.id.editTextDomain)).setText(domain);
124 ((EditText)userCredView.findViewById(R.id.editTextPassword)).setText(password);
125
126 showOnUiThread(dlgUserCredentials);
127
128 try
129 {
130 synchronized (dlgUserCredentials)
131 {
132 dlgUserCredentials.wait();
133 }
134 }
135 catch (InterruptedException e)
136 {
137 }
138
139 username.setLength(0);
140 domain.setLength(0);
141 password.setLength(0);
142
143 username.append(
144 ((EditText)userCredView.findViewById(R.id.editTextUsername)).getText().toString());
145 domain.append(
146 ((EditText)userCredView.findViewById(R.id.editTextDomain)).getText().toString());
147 password.append(
148 ((EditText)userCredView.findViewById(R.id.editTextPassword)).getText().toString());
149
150 return callbackDialogResult;
151 }

◆ 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 222 of file SessionDialogs.java.

223 {
225
226 int pad = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 24,
227 activity.getResources().getDisplayMetrics());
228 LinearLayout content = new LinearLayout(activity);
229 content.setOrientation(LinearLayout.HORIZONTAL);
230 content.setPadding(pad, pad, pad, pad);
231 content.setGravity(Gravity.CENTER_VERTICAL);
232
233 ProgressBar progressBar = new ProgressBar(activity);
234 progressBar.setIndeterminate(true);
235 content.addView(progressBar,
236 new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
237 ViewGroup.LayoutParams.WRAP_CONTENT));
238
239 TextView messageView = new TextView(activity);
240 messageView.setText(R.string.dlg_msg_connecting);
241 LinearLayout.LayoutParams textParams = new LinearLayout.LayoutParams(
242 ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
243 textParams.leftMargin = pad;
244 content.addView(messageView, textParams);
245
246 progressDialog = new AlertDialog.Builder(activity)
247 .setTitle(title)
248 .setView(content)
249 .setNegativeButton(android.R.string.cancel,
250 (dialog, which) -> {
251 if (listener != null)
252 listener.onConnectCancel();
253 })
254 .setCancelable(false)
255 .create();
256 progressDialog.show();
257 }

◆ 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 156 of file SessionDialogs.java.

158 {
159 String msg = activity.getResources().getString(R.string.dlg_msg_verify_certificate);
160 String type = "RDP-Server";
161 if ((flags & LibFreeRDP.VERIFY_CERT_FLAG_GATEWAY) != 0)
162 type = "RDP-Gateway";
163 if ((flags & LibFreeRDP.VERIFY_CERT_FLAG_REDIRECT) != 0)
164 type = "RDP-Redirect";
165 msg += "\n\n" + type + ": " + host + ":" + port;
166 msg += "\n\nSubject: " + subject + "\nIssuer: " + issuer;
167 if ((flags & LibFreeRDP.VERIFY_CERT_FLAG_FP_IS_PEM) != 0)
168 msg += "\nCertificate: " + fingerprint;
169 else
170 msg += "\nFingerprint: " + fingerprint;
171
172 return showVerifyDialog(msg);
173 }

◆ 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 178 of file SessionDialogs.java.

180 {
181 // The "changed" variant currently shows the same information as the
182 // regular verify dialog (matches prior behaviour).
183 return verifyCertificate(host, port, subject, issuer, fingerprint, flags);
184 }
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: