Commit 34c10b16bba26a1470f04fcaed39c4a6d76ff5b4
1 parent
2e080203
Exists in
master
and in
1 other branch
Incluindo tooltip com estado da conexão SSL
Showing
4 changed files
with
493 additions
and
4 deletions
Show diff stats
private.h
... | ... | @@ -38,12 +38,11 @@ |
38 | 38 | #include <glib/gi18n.h> |
39 | 39 | |
40 | 40 | #ifndef V3270_H_INCLUDED |
41 | - #include <lib3270/v3270.h> | |
41 | + #include <pw3270/v3270.h> | |
42 | 42 | #endif |
43 | 43 | |
44 | 44 | G_BEGIN_DECLS |
45 | 45 | |
46 | - | |
47 | 46 | struct _v3270Class |
48 | 47 | { |
49 | 48 | GtkWidgetClass parent_class; |
... | ... | @@ -121,6 +120,14 @@ G_BEGIN_DECLS |
121 | 120 | guint top; |
122 | 121 | }; |
123 | 122 | |
123 | + struct v3270_ssl_status_msg | |
124 | + { | |
125 | + long id; | |
126 | + const gchar * icon; | |
127 | + const gchar * text; | |
128 | + const gchar * message; | |
129 | + }; | |
130 | + | |
124 | 131 | /*--[ Widget data ]----------------------------------------------------------------------------------*/ |
125 | 132 | |
126 | 133 | struct _v3270 |
... | ... | @@ -201,6 +208,7 @@ G_BEGIN_DECLS |
201 | 208 | G_GNUC_INTERNAL guint v3270_widget_signal[LAST_SIGNAL]; |
202 | 209 | G_GNUC_INTERNAL GdkCursor * v3270_cursor[V3270_CURSOR_COUNT]; |
203 | 210 | |
211 | + | |
204 | 212 | /*--[ Prototipes ]-----------------------------------------------------------------------------------*/ |
205 | 213 | |
206 | 214 | const GtkWidgetClass * v3270_get_parent_class(void); |
... | ... | @@ -270,4 +278,7 @@ void v3270_emit_popup(v3270 *widget, int baddr, GdkEventButton *event); |
270 | 278 | gint v3270_get_offset_at_point(v3270 *widget, gint x, gint y); |
271 | 279 | gboolean v3270_scroll_event(GtkWidget *widget, GdkEventScroll *event); |
272 | 280 | |
281 | +G_GNUC_INTERNAL const struct v3270_ssl_status_msg * v3270_get_ssl_status_msg(GtkWidget *widget); | |
282 | + | |
283 | + | |
273 | 284 | G_END_DECLS | ... | ... |
... | ... | @@ -0,0 +1,424 @@ |
1 | +/* | |
2 | + * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin | |
19 | + * St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | + * | |
21 | + * Este programa está nomeado como secoruty.c e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) | |
27 | + * | |
28 | + */ | |
29 | + | |
30 | + #include <gtk/gtk.h> | |
31 | + #include "private.h" | |
32 | + | |
33 | + #if defined(HAVE_LIBSSL) | |
34 | + #include <openssl/ssl.h> | |
35 | + #include <openssl/err.h> | |
36 | + #endif | |
37 | + | |
38 | + | |
39 | +/*--[ Globals ]--------------------------------------------------------------------------------------*/ | |
40 | + | |
41 | + static const struct v3270_ssl_status_msg ssl_status_msg[] = | |
42 | + { | |
43 | + // http://www.openssl.org/docs/apps/verify.html | |
44 | + { | |
45 | + X509_V_OK, | |
46 | + GTK_STOCK_DIALOG_AUTHENTICATION, | |
47 | + N_( "Secure connection was successful." ), | |
48 | + N_( "This connection is secure and signed." ) | |
49 | + }, | |
50 | + | |
51 | + { | |
52 | + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT, | |
53 | + GTK_STOCK_DIALOG_ERROR, | |
54 | + N_( "Unable to get issuer certificate" ), | |
55 | + N_( "The issuer certificate of a looked up certificate could not be found. This normally means the list of trusted certificates is not complete." ), | |
56 | + }, | |
57 | + | |
58 | + { | |
59 | + X509_V_ERR_UNABLE_TO_GET_CRL, | |
60 | + GTK_STOCK_DIALOG_ERROR, | |
61 | + N_( "Unable to get certificate CRL" ), | |
62 | + N_( "The CRL of a certificate could not be found." ), | |
63 | + }, | |
64 | + | |
65 | + { | |
66 | + X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE, | |
67 | + GTK_STOCK_DIALOG_ERROR, | |
68 | + N_( "Unable to decrypt certificate's signature" ), | |
69 | + N_( "The certificate signature could not be decrypted. This means that the actual signature value could not be determined rather than it not matching the expected value, this is only meaningful for RSA keys." ), | |
70 | + }, | |
71 | + | |
72 | + { | |
73 | + X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE, | |
74 | + GTK_STOCK_DIALOG_ERROR, | |
75 | + N_( "Unable to decrypt CRL's signature" ), | |
76 | + N_( "The CRL signature could not be decrypted: this means that the actual signature value could not be determined rather than it not matching the expected value. Unused." ), | |
77 | + }, | |
78 | + | |
79 | + { | |
80 | + X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY, | |
81 | + GTK_STOCK_DIALOG_ERROR, | |
82 | + N_( "Unable to decode issuer public key" ), | |
83 | + N_( "The public key in the certificate SubjectPublicKeyInfo could not be read." ), | |
84 | + }, | |
85 | + | |
86 | + { | |
87 | + X509_V_ERR_CERT_SIGNATURE_FAILURE, | |
88 | + GTK_STOCK_DIALOG_ERROR, | |
89 | + N_( "Certificate signature failure" ), | |
90 | + N_( "The signature of the certificate is invalid." ), | |
91 | + }, | |
92 | + | |
93 | + { | |
94 | + X509_V_ERR_CRL_SIGNATURE_FAILURE, | |
95 | + GTK_STOCK_DIALOG_ERROR, | |
96 | + N_( "CRL signature failure" ), | |
97 | + N_( "The signature of the certificate is invalid." ), | |
98 | + }, | |
99 | + | |
100 | + { | |
101 | + X509_V_ERR_CERT_NOT_YET_VALID, | |
102 | + GTK_STOCK_DIALOG_WARNING, | |
103 | + N_( "Certificate is not yet valid" ), | |
104 | + N_( "The certificate is not yet valid: the notBefore date is after the current time." ), | |
105 | + }, | |
106 | + | |
107 | + { | |
108 | + X509_V_ERR_CERT_HAS_EXPIRED, | |
109 | + GTK_STOCK_DIALOG_ERROR, | |
110 | + N_( "Certificate has expired" ), | |
111 | + N_( "The certificate has expired: that is the notAfter date is before the current time." ), | |
112 | + }, | |
113 | + | |
114 | + { | |
115 | + X509_V_ERR_CRL_NOT_YET_VALID, | |
116 | + GTK_STOCK_DIALOG_WARNING, | |
117 | + N_( "CRL is not yet valid" ), | |
118 | + N_( "The CRL is not yet valid." ), | |
119 | + }, | |
120 | + | |
121 | + { | |
122 | + X509_V_ERR_CRL_HAS_EXPIRED, | |
123 | + GTK_STOCK_DIALOG_ERROR, | |
124 | + N_( "CRL has expired" ), | |
125 | + N_( "The CRL has expired." ), | |
126 | + }, | |
127 | + | |
128 | + { | |
129 | + X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD, | |
130 | + GTK_STOCK_DIALOG_ERROR, | |
131 | + N_( "Format error in certificate's notBefore field" ), | |
132 | + N_( "The certificate notBefore field contains an invalid time." ), | |
133 | + }, | |
134 | + | |
135 | + { | |
136 | + X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD, | |
137 | + GTK_STOCK_DIALOG_ERROR, | |
138 | + N_( "Format error in certificate's notAfter field" ), | |
139 | + N_( "The certificate notAfter field contains an invalid time." ), | |
140 | + }, | |
141 | + | |
142 | + { | |
143 | + X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD, | |
144 | + GTK_STOCK_DIALOG_ERROR, | |
145 | + N_( "Format error in CRL's lastUpdate field" ), | |
146 | + N_( "The CRL lastUpdate field contains an invalid time." ), | |
147 | + }, | |
148 | + | |
149 | + { | |
150 | + X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD, | |
151 | + GTK_STOCK_DIALOG_ERROR, | |
152 | + N_( "Format error in CRL's nextUpdate field" ), | |
153 | + N_( "The CRL nextUpdate field contains an invalid time." ), | |
154 | + }, | |
155 | + | |
156 | + { | |
157 | + X509_V_ERR_OUT_OF_MEM, | |
158 | + GTK_STOCK_DIALOG_ERROR, | |
159 | + N_( "Out of memory" ), | |
160 | + N_( "An error occurred trying to allocate memory. This should never happen." ), | |
161 | + }, | |
162 | + | |
163 | + { | |
164 | + X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT, | |
165 | + GTK_STOCK_DIALOG_WARNING, | |
166 | + N_( "Self signed certificate" ), | |
167 | + N_( "The passed certificate is self signed and the same certificate cannot be found in the list of trusted certificates." ), | |
168 | + }, | |
169 | + | |
170 | + { | |
171 | + X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN, | |
172 | + GTK_STOCK_DIALOG_WARNING, | |
173 | + N_( "Self signed certificate in certificate chain" ), | |
174 | + N_( "The certificate chain could be built up using the untrusted certificates but the root could not be found locally." ), | |
175 | + }, | |
176 | + | |
177 | + { | |
178 | + X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY, | |
179 | + GTK_STOCK_DIALOG_WARNING, | |
180 | + N_( "Unable to get local issuer certificate" ), | |
181 | + N_( "The issuer certificate could not be found: this occurs if the issuer certificate of an untrusted certificate cannot be found." ), | |
182 | + }, | |
183 | + | |
184 | + { | |
185 | + X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE, | |
186 | + GTK_STOCK_DIALOG_ERROR, | |
187 | + N_( "Unable to verify the first certificate" ), | |
188 | + N_( "No signatures could be verified because the chain contains only one certificate and it is not self signed." ), | |
189 | + }, | |
190 | + | |
191 | + { | |
192 | + X509_V_ERR_CERT_REVOKED, | |
193 | + GTK_STOCK_DIALOG_ERROR, | |
194 | + N_( "Certificate revoked" ), | |
195 | + N_( "The certificate has been revoked." ), | |
196 | + }, | |
197 | + | |
198 | + { | |
199 | + X509_V_ERR_INVALID_CA, | |
200 | + GTK_STOCK_DIALOG_ERROR, | |
201 | + N_( "Invalid CA certificate" ), | |
202 | + N_( "A CA certificate is invalid. Either it is not a CA or its extensions are not consistent with the supplied purpose." ), | |
203 | + }, | |
204 | + | |
205 | + { | |
206 | + X509_V_ERR_PATH_LENGTH_EXCEEDED, | |
207 | + GTK_STOCK_DIALOG_ERROR, | |
208 | + N_( "Path length constraint exceeded" ), | |
209 | + N_( "The basicConstraints pathlength parameter has been exceeded." ), | |
210 | + }, | |
211 | + | |
212 | + { | |
213 | + X509_V_ERR_INVALID_PURPOSE, | |
214 | + GTK_STOCK_DIALOG_ERROR, | |
215 | + N_( "Unsupported certificate purpose" ), | |
216 | + N_( "The supplied certificate cannot be used for the specified purpose." ), | |
217 | + }, | |
218 | + | |
219 | + { | |
220 | + X509_V_ERR_CERT_UNTRUSTED, | |
221 | + GTK_STOCK_DIALOG_WARNING, | |
222 | + N_( "Certificate not trusted" ), | |
223 | + N_( "The root CA is not marked as trusted for the specified purpose." ), | |
224 | + }, | |
225 | + | |
226 | + { | |
227 | + X509_V_ERR_CERT_REJECTED, | |
228 | + GTK_STOCK_DIALOG_ERROR, | |
229 | + N_( "Certificate rejected" ), | |
230 | + N_( "The root CA is marked to reject the specified purpose." ), | |
231 | + }, | |
232 | + | |
233 | + { | |
234 | + X509_V_ERR_SUBJECT_ISSUER_MISMATCH, | |
235 | + GTK_STOCK_DIALOG_ERROR, | |
236 | + N_( "Subject issuer mismatch" ), | |
237 | + N_( "The current candidate issuer certificate was rejected because its subject name did not match the issuer name of the current certificate. Only displayed when the -issuer_checks option is set." ), | |
238 | + }, | |
239 | + | |
240 | + { | |
241 | + X509_V_ERR_AKID_SKID_MISMATCH, | |
242 | + GTK_STOCK_DIALOG_ERROR, | |
243 | + N_( "Authority and subject key identifier mismatch" ), | |
244 | + N_( "The current candidate issuer certificate was rejected because its subject key identifier was present and did not match the authority key identifier current certificate. Only displayed when the -issuer_checks option is set." ), | |
245 | + }, | |
246 | + | |
247 | + { | |
248 | + X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH, | |
249 | + GTK_STOCK_DIALOG_ERROR, | |
250 | + N_( "Authority and issuer serial number mismatch" ), | |
251 | + N_( "The current candidate issuer certificate was rejected because its issuer name and serial number was present and did not match the authority key identifier of the current certificate. Only displayed when the -issuer_checks option is set." ), | |
252 | + }, | |
253 | + | |
254 | + { | |
255 | + X509_V_ERR_KEYUSAGE_NO_CERTSIGN, | |
256 | + GTK_STOCK_DIALOG_ERROR, | |
257 | + N_( "Key usage does not include certificate signing" ), | |
258 | + N_( "The current candidate issuer certificate was rejected because its keyUsage extension does not permit certificate signing." ), | |
259 | + }, | |
260 | + | |
261 | + { | |
262 | + 0, | |
263 | + NULL, | |
264 | + NULL, | |
265 | + NULL | |
266 | + } | |
267 | + | |
268 | + }; | |
269 | + | |
270 | +/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
271 | + | |
272 | + G_GNUC_INTERNAL const struct v3270_ssl_status_msg * v3270_get_ssl_status_msg(GtkWidget *widget) | |
273 | + { | |
274 | +#ifdef HAVE_LIBSSL | |
275 | + int f; | |
276 | + long id = lib3270_get_SSL_verify_result(GTK_V3270(widget)->host); | |
277 | + | |
278 | + for(f=0;ssl_status_msg[f].text;f++) | |
279 | + { | |
280 | + if(ssl_status_msg[f].id == id) | |
281 | + return ssl_status_msg+f; | |
282 | + } | |
283 | +#endif // HAVE_LIBSSL | |
284 | + return NULL; | |
285 | + } | |
286 | + | |
287 | + LIB3270_EXPORT const gchar * v3270_get_ssl_status_icon(GtkWidget *widget) | |
288 | + { | |
289 | + g_return_val_if_fail(GTK_IS_V3270(widget),""); | |
290 | + | |
291 | + if(lib3270_get_secure(GTK_V3270(widget)->host) == LIB3270_SSL_UNSECURE) | |
292 | + return GTK_STOCK_DIALOG_INFO; | |
293 | + | |
294 | + | |
295 | +#ifdef HAVE_LIBSSL | |
296 | + if(lib3270_get_secure(GTK_V3270(widget)->host) != LIB3270_SSL_UNSECURE) | |
297 | + { | |
298 | + const struct v3270_ssl_status_msg *info = v3270_get_ssl_status_msg(widget); | |
299 | + if(info) | |
300 | + return info->icon; | |
301 | + } | |
302 | +#endif // HAVE_LIBSSL | |
303 | + | |
304 | + return GTK_STOCK_DIALOG_ERROR; | |
305 | + | |
306 | + } | |
307 | + | |
308 | + LIB3270_EXPORT const gchar * v3270_get_ssl_status_text(GtkWidget *widget) | |
309 | + { | |
310 | + g_return_val_if_fail(GTK_IS_V3270(widget),""); | |
311 | + | |
312 | + if(lib3270_get_secure(GTK_V3270(widget)->host) == LIB3270_SSL_UNSECURE) | |
313 | + return v3270_get_host(widget); | |
314 | + | |
315 | +#ifdef HAVE_LIBSSL | |
316 | + if(lib3270_get_secure(GTK_V3270(widget)->host) != LIB3270_SSL_UNSECURE) | |
317 | + { | |
318 | + const struct v3270_ssl_status_msg *info = v3270_get_ssl_status_msg(widget); | |
319 | + if(info) | |
320 | + return info->text; | |
321 | + } | |
322 | +#endif // HAVE_LIBSSL | |
323 | + return v3270_get_host(widget); | |
324 | + } | |
325 | + | |
326 | + LIB3270_EXPORT const gchar * v3270_get_ssl_status_message(GtkWidget *widget) | |
327 | + { | |
328 | + g_return_val_if_fail(GTK_IS_V3270(widget),""); | |
329 | + | |
330 | + if(lib3270_get_secure(GTK_V3270(widget)->host) == LIB3270_SSL_UNSECURE) | |
331 | + return _( "The connection is insecure" ); | |
332 | + | |
333 | +#ifdef HAVE_LIBSSL | |
334 | + if(lib3270_get_secure(GTK_V3270(widget)->host) != LIB3270_SSL_UNSECURE) | |
335 | + { | |
336 | + const struct v3270_ssl_status_msg *info = v3270_get_ssl_status_msg(widget); | |
337 | + if(info) | |
338 | + return info->message; | |
339 | + } | |
340 | +#endif // HAVE_LIBSSL | |
341 | + | |
342 | + return _( "Unexpected or unknown security status"); | |
343 | + } | |
344 | + | |
345 | + LIB3270_EXPORT void v3270_popup_security_dialog(GtkWidget *widget) | |
346 | + { | |
347 | + GtkWidget * dialog; | |
348 | + | |
349 | + g_return_if_fail(GTK_IS_V3270(widget)); | |
350 | + | |
351 | + gdk_window_set_cursor(gtk_widget_get_window(widget),v3270_cursor[GTK_V3270(widget)->pointer]); | |
352 | + | |
353 | + | |
354 | +#ifdef HAVE_LIBSSL | |
355 | + if(lib3270_get_secure(GTK_V3270(widget)->host) == LIB3270_SSL_UNSECURE) | |
356 | +#endif // HAVE_LIBSSL | |
357 | + { | |
358 | + // Connection is insecure, show simple dialog with host and info | |
359 | + | |
360 | + dialog = gtk_message_dialog_new( | |
361 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
362 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
363 | + GTK_MESSAGE_INFO, | |
364 | + GTK_BUTTONS_CLOSE, | |
365 | + v3270_get_host(widget) | |
366 | + ); | |
367 | + | |
368 | + gtk_message_dialog_format_secondary_markup( | |
369 | + GTK_MESSAGE_DIALOG(dialog), | |
370 | + "%s", _( "<b>Identity not verified</b>\nThe connection is insecure" )); | |
371 | + | |
372 | + } | |
373 | +#ifdef HAVE_LIBSSL | |
374 | + else | |
375 | + { | |
376 | + long id = lib3270_get_SSL_verify_result(GTK_V3270(widget)->host); | |
377 | + const gchar * title = N_( "Unexpected SSL error"); | |
378 | + const gchar * text = NULL; | |
379 | + const gchar * icon = GTK_STOCK_DIALOG_ERROR; | |
380 | + int f; | |
381 | + | |
382 | + for(f=0;ssl_status_msg[f].text;f++) | |
383 | + { | |
384 | + if(ssl_status_msg[f].id == id) | |
385 | + { | |
386 | + title = ssl_status_msg[f].text; | |
387 | + icon = ssl_status_msg[f].icon; | |
388 | + text = ssl_status_msg[f].message; | |
389 | + break; | |
390 | + } | |
391 | + } | |
392 | + | |
393 | + dialog = gtk_message_dialog_new( | |
394 | + GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
395 | + GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
396 | + GTK_MESSAGE_OTHER, | |
397 | + GTK_BUTTONS_CLOSE, | |
398 | + "%s",gettext(title) | |
399 | + ); | |
400 | + | |
401 | + gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(dialog),gtk_image_new_from_stock(icon,GTK_ICON_SIZE_DIALOG)); | |
402 | + | |
403 | + if(text) | |
404 | + { | |
405 | + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),text); | |
406 | + } | |
407 | + else | |
408 | + { | |
409 | + gchar *str = g_strdup_printf( _( "Unexpected SSL error <b>%ld</b>" ),id); | |
410 | + gtk_message_dialog_format_secondary_markup(GTK_MESSAGE_DIALOG(dialog),text); | |
411 | + g_free(str); | |
412 | + } | |
413 | + | |
414 | + } | |
415 | +#endif // HAVE_LIBSSL | |
416 | + | |
417 | + gtk_window_set_title(GTK_WINDOW(dialog),_("About security")); | |
418 | + | |
419 | + gtk_widget_show_all(GTK_WIDGET(dialog)); | |
420 | + gtk_dialog_run(GTK_DIALOG(dialog)); | |
421 | + gtk_widget_destroy(GTK_WIDGET(dialog)); | |
422 | + | |
423 | + | |
424 | + } | ... | ... |
sources.mak
... | ... | @@ -26,5 +26,6 @@ |
26 | 26 | # kraucer@bb.com.br (Kraucer Fernandes Mazuco) |
27 | 27 | # |
28 | 28 | |
29 | -V3270_SRC=marshal.c widget.c oia.c iocallback.c keyboard.c draw.c mouse.c selection.c accessible.c | |
29 | +V3270_SRC=marshal.c widget.c oia.c iocallback.c keyboard.c draw.c mouse.c selection.c \ | |
30 | + accessible.c security.c | |
30 | 31 | ... | ... |
widget.c
... | ... | @@ -273,6 +273,57 @@ void v3270_popup_message(GtkWidget *widget, LIB3270_NOTIFY type , const gchar *t |
273 | 273 | trace("%s ends",__FUNCTION__); |
274 | 274 | } |
275 | 275 | |
276 | +gboolean v3270_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_tooltip, GtkTooltip *tooltip) | |
277 | +{ | |
278 | +/* | |
279 | + if(!lib3270_connected(GTK_V3270(widget)->host)) | |
280 | + { | |
281 | + gtk_tooltip_set_text(tooltip,_( "Disconnected" ) ); | |
282 | + return TRUE; | |
283 | + } | |
284 | +*/ | |
285 | + | |
286 | + if(y >= GTK_V3270(widget)->oia_rect->y) | |
287 | + { | |
288 | + GdkRectangle *rect = GTK_V3270(widget)->oia_rect; | |
289 | + | |
290 | + if(x >= rect[V3270_OIA_SSL].x && x <= (rect[V3270_OIA_SSL].x + rect[V3270_OIA_SSL].width)) | |
291 | + { | |
292 | + if(!lib3270_connected(GTK_V3270(widget)->host)) | |
293 | + { | |
294 | + gtk_tooltip_set_icon_from_stock(tooltip,GTK_STOCK_DISCONNECT,GTK_ICON_SIZE_MENU); | |
295 | + gtk_tooltip_set_markup(tooltip,_( "<b>Disconnected from host</b>\nNo security info" ) ); | |
296 | + } | |
297 | + else if(lib3270_get_secure(GTK_V3270(widget)->host) == LIB3270_SSL_UNSECURE) | |
298 | + { | |
299 | + gtk_tooltip_set_icon_from_stock(tooltip,GTK_STOCK_INFO,GTK_ICON_SIZE_MENU); | |
300 | + gtk_tooltip_set_markup(tooltip,_( "Connection is insecure" ) ); | |
301 | + } | |
302 | + else | |
303 | + { | |
304 | + const struct v3270_ssl_status_msg *msg = v3270_get_ssl_status_msg(widget); | |
305 | + | |
306 | + if(msg) | |
307 | + { | |
308 | + gtk_tooltip_set_icon_from_stock(tooltip,msg->icon,GTK_ICON_SIZE_MENU); | |
309 | + gtk_tooltip_set_markup(tooltip,msg->text); | |
310 | + } | |
311 | + else | |
312 | + { | |
313 | + gchar *text = g_strdup_printf(_("<b>Unexpected SSL status %ld</b>\nSecurity status is undefined"),lib3270_get_SSL_verify_result(GTK_V3270(widget)->host)); | |
314 | + gtk_tooltip_set_icon_from_stock(tooltip,GTK_STOCK_DIALOG_ERROR,GTK_ICON_SIZE_MENU); | |
315 | + gtk_tooltip_set_markup(tooltip,text); | |
316 | + g_free(text); | |
317 | + } | |
318 | + } | |
319 | + | |
320 | + return TRUE; | |
321 | + } | |
322 | + | |
323 | + } | |
324 | + return FALSE; | |
325 | +} | |
326 | + | |
276 | 327 | static void v3270_class_init(v3270Class *klass) |
277 | 328 | { |
278 | 329 | GObjectClass * gobject_class = G_OBJECT_CLASS(klass); |
... | ... | @@ -295,6 +346,7 @@ static void v3270_class_init(v3270Class *klass) |
295 | 346 | widget_class->motion_notify_event = v3270_motion_notify_event; |
296 | 347 | widget_class->popup_menu = v3270_popup_menu; |
297 | 348 | widget_class->scroll_event = v3270_scroll_event; |
349 | + widget_class->query_tooltip = v3270_query_tooltip; | |
298 | 350 | |
299 | 351 | /* Accessibility support */ |
300 | 352 | widget_class->get_accessible = v3270_get_accessible; |
... | ... | @@ -851,8 +903,9 @@ static void v3270_init(v3270 *widget) |
851 | 903 | GTK_WIDGET_SET_FLAGS(GTK_WIDGET(widget),(GTK_CAN_DEFAULT|GTK_CAN_FOCUS)); |
852 | 904 | #endif // GTK(2,18) |
853 | 905 | |
854 | - // Setup events | |
906 | + // Setup widget | |
855 | 907 | gtk_widget_add_events(GTK_WIDGET(widget),GDK_KEY_PRESS_MASK|GDK_KEY_RELEASE_MASK|GDK_BUTTON_PRESS_MASK|GDK_BUTTON_MOTION_MASK|GDK_BUTTON_RELEASE_MASK|GDK_POINTER_MOTION_MASK|GDK_ENTER_NOTIFY_MASK|GDK_SCROLL_MASK); |
908 | + gtk_widget_set_has_tooltip(GTK_WIDGET(widget),TRUE); | |
856 | 909 | |
857 | 910 | trace("%s",__FUNCTION__); |
858 | 911 | } | ... | ... |