Commit 56e3b8230aa287c20335b036f269db5cecb98d50
1 parent
16e7c1d4
Exists in
master
and in
1 other branch
Ajuste no tratamento de hostname para o novo formato de conexão
Showing
1 changed file
with
80 additions
and
6 deletions
Show diff stats
widget.c
... | ... | @@ -57,6 +57,15 @@ |
57 | 57 | #define CONTENTS_WIDTH(terminal) (cols * terminal->metrics.width) |
58 | 58 | #define CONTENTS_HEIGHT(terminal) (((rows+1) * terminal->metrics.spacing)+OIA_TOP_MARGIN+2) |
59 | 59 | |
60 | +/** | |
61 | + * SECTION: v3270 | |
62 | + * @title: Virtual 3270 widget | |
63 | + * @short_description: The virtual 3270 terminal widget. | |
64 | + * | |
65 | + * Common functions for interact with the 3270 virtual terminal widget. | |
66 | + * | |
67 | + */ | |
68 | + | |
60 | 69 | /*--[ Widget definition ]----------------------------------------------------------------------------*/ |
61 | 70 | |
62 | 71 | G_DEFINE_TYPE(v3270, v3270, GTK_TYPE_WIDGET); |
... | ... | @@ -721,7 +730,7 @@ static void update_connect(H3270 *session, unsigned char connected) |
721 | 730 | if(connected) |
722 | 731 | { |
723 | 732 | widget->cursor.show |= 2; |
724 | - g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_CONNECTED], 0, session->full_current_host); | |
733 | + g_signal_emit(GTK_WIDGET(widget), v3270_widget_signal[SIGNAL_CONNECTED], 0, session->host.full); | |
725 | 734 | } |
726 | 735 | else |
727 | 736 | { |
... | ... | @@ -1380,18 +1389,71 @@ H3270 * v3270_get_session(GtkWidget *widget) |
1380 | 1389 | return GTK_V3270(widget)->host; |
1381 | 1390 | } |
1382 | 1391 | |
1383 | -int v3270_connect(GtkWidget *widget, const gchar *host) | |
1392 | +int v3270_connect(GtkWidget *widget, const gchar *uri) | |
1384 | 1393 | { |
1385 | 1394 | v3270 * terminal; |
1386 | 1395 | int rc = -1; |
1387 | 1396 | |
1388 | - trace("%s widget=%p host=%p",__FUNCTION__,widget,host); | |
1397 | + trace("%s widget=%p host=%p",__FUNCTION__,widget,uri); | |
1389 | 1398 | |
1390 | 1399 | g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); |
1391 | 1400 | |
1392 | 1401 | terminal = GTK_V3270(widget); |
1393 | 1402 | |
1394 | - rc = lib3270_connect(terminal->host,host,0); | |
1403 | +#ifdef DEBUG | |
1404 | + if(uri) | |
1405 | + { | |
1406 | + LIB3270_CONNECT_OPTION opt = LIB3270_CONNECT_OPTION_DEFAULTS; | |
1407 | + gchar * scheme = g_uri_unescape_string(uri,NULL); | |
1408 | + gchar * hostname = strchr(scheme,':'); | |
1409 | + gchar * srvc; | |
1410 | + gchar * query; | |
1411 | + | |
1412 | + if(hostname) | |
1413 | + { | |
1414 | + *(hostname++) = 0; | |
1415 | + | |
1416 | + while(*hostname && !g_ascii_isalnum(*hostname)) | |
1417 | + hostname++; | |
1418 | + | |
1419 | + if(*hostname) | |
1420 | + { | |
1421 | + if( ! (g_ascii_strcasecmp(scheme,"l") && g_ascii_strcasecmp(scheme,"ssl")) ) | |
1422 | + opt |= LIB3270_CONNECT_OPTION_SSL; | |
1423 | + | |
1424 | + srvc = strchr(hostname,':'); | |
1425 | + if(srvc) | |
1426 | + { | |
1427 | + *(srvc++) = 0; | |
1428 | + query = strchr(srvc,'?'); | |
1429 | + if(query) | |
1430 | + *(query++) = 0; | |
1431 | + else | |
1432 | + query = ""; | |
1433 | + } | |
1434 | + else | |
1435 | + { | |
1436 | + srvc = "telnet"; | |
1437 | + } | |
1438 | + | |
1439 | + rc = lib3270_connect_host(terminal->host,hostname,srvc,opt); | |
1440 | + | |
1441 | + } | |
1442 | + | |
1443 | + } | |
1444 | + | |
1445 | + | |
1446 | + g_free(scheme); | |
1447 | + | |
1448 | + } | |
1449 | + else | |
1450 | + { | |
1451 | + rc = lib3270_connect(terminal->host,uri,0); | |
1452 | + } | |
1453 | + | |
1454 | +#else | |
1455 | + rc = lib3270_connect(terminal->host,uri,0); | |
1456 | +#endif // DEBUG | |
1395 | 1457 | |
1396 | 1458 | trace("%s exits with rc=%d (%s)",__FUNCTION__,rc,strerror(rc)); |
1397 | 1459 | |
... | ... | @@ -1476,11 +1538,23 @@ gboolean v3270_get_toggle(GtkWidget *widget, LIB3270_TOGGLE ix) |
1476 | 1538 | return FALSE; |
1477 | 1539 | } |
1478 | 1540 | |
1479 | -void v3270_set_host(GtkWidget *widget, const gchar *uri) | |
1541 | +/** | |
1542 | + * v3270_set_host: | |
1543 | + * | |
1544 | + * @widget: V3270 widget. | |
1545 | + * @uri: a valid tn3270 URL. | |
1546 | + * | |
1547 | + * Set the default URL for the tn3270e host. | |
1548 | + * | |
1549 | + * Returns: The lib3270 processed string as an internal constant. | |
1550 | + * | |
1551 | + * Since: 5.0 | |
1552 | + **/ | |
1553 | +const gchar * v3270_set_host(GtkWidget *widget, const gchar *uri) | |
1480 | 1554 | { |
1481 | 1555 | g_return_if_fail(GTK_IS_V3270(widget)); |
1482 | 1556 | g_return_if_fail(uri != NULL); |
1483 | - lib3270_set_host(GTK_V3270(widget)->host,uri); | |
1557 | + return lib3270_set_host(GTK_V3270(widget)->host,uri); | |
1484 | 1558 | } |
1485 | 1559 | |
1486 | 1560 | const gchar * v3270_get_host(GtkWidget *widget) | ... | ... |