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

Constructor & Destructor Documentation

◆ SessionDialogs()

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

Definition at line 62 of file SessionDialogs.java.

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

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

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

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

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

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

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

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

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

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

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