Commit a7945373dad2c47677f2605f8a6ee98744fe15e7
1 parent
c3b9eff7
Exists in
master
and in
5 other branches
Ativação do SSL pelo diálogo não estava reajustando a URL
Showing
4 changed files
with
11 additions
and
385 deletions
Show diff stats
src/lib3270/host.c
src/lib3270/options.c
| ... | ... | @@ -83,6 +83,15 @@ LIB3270_EXPORT void lib3270_set_options(H3270 *hSession, LIB3270_OPTION opt) |
| 83 | 83 | { |
| 84 | 84 | CHECK_SESSION_HANDLE(hSession); |
| 85 | 85 | hSession->options = opt; |
| 86 | + | |
| 87 | + Replace(hSession->host.full, | |
| 88 | + lib3270_strdup_printf( | |
| 89 | + "%s%s:%s", | |
| 90 | + hSession->options&LIB3270_OPTION_SSL ? "tn3270s://" : "tn3270://", | |
| 91 | + hSession->host.current, | |
| 92 | + hSession->host.srvc | |
| 93 | + )); | |
| 94 | + | |
| 86 | 95 | } |
| 87 | 96 | |
| 88 | 97 | LIB3270_EXPORT unsigned short lib3270_get_color_type(H3270 *hSession) | ... | ... |
src/pw3270/hostdialog.c
| ... | ... | @@ -32,107 +32,6 @@ |
| 32 | 32 | |
| 33 | 33 | /*--[ Globals ]--------------------------------------------------------------------------------------*/ |
| 34 | 34 | |
| 35 | -/* | |
| 36 | - static const struct _host_type | |
| 37 | - { | |
| 38 | - const gchar * name; | |
| 39 | - const gchar * description; | |
| 40 | - LIB3270_OPTION option; | |
| 41 | - } host_type[] = | |
| 42 | - { | |
| 43 | - { "S390", N_( "IBM S/390" ), LIB3270_OPTION_S390 }, | |
| 44 | - { "AS400", N_( "IBM AS/400" ), LIB3270_OPTION_AS400 }, | |
| 45 | - { "TSO", N_( "Other (TSO)" ), LIB3270_OPTION_TSO }, | |
| 46 | - { "VM/CMS", N_( "Other (VM/CMS)" ), 0 } | |
| 47 | - }; | |
| 48 | - | |
| 49 | - static const struct _colortable | |
| 50 | - { | |
| 51 | - unsigned short colors; | |
| 52 | - const gchar * description; | |
| 53 | - } colortable[] = | |
| 54 | - { | |
| 55 | - { 16, N_( "16 colors" ) }, | |
| 56 | - { 8, N_( "8 colors" ) }, | |
| 57 | - { 2, N_( "Monochrome" ) }, | |
| 58 | - }; | |
| 59 | -*/ | |
| 60 | - | |
| 61 | -/*--[ Implement ]------------------------------------------------------------------------------------*/ | |
| 62 | - | |
| 63 | -/* | |
| 64 | - LIB3270_OPTION pw3270_options_by_hosttype(const gchar *systype) | |
| 65 | - { | |
| 66 | - int f; | |
| 67 | - | |
| 68 | - for(f=0;G_N_ELEMENTS(host_type);f++) | |
| 69 | - { | |
| 70 | - if(!g_ascii_strcasecmp(host_type[f].name,systype)) | |
| 71 | - return host_type[f].option; | |
| 72 | - } | |
| 73 | - | |
| 74 | - g_message("Unexpected system type: \"%s\"",systype); | |
| 75 | - return 0; | |
| 76 | - } | |
| 77 | - | |
| 78 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 79 | - static void set_row(int row, GtkWidget *widget, GtkGrid *container, const gchar *text) | |
| 80 | - { | |
| 81 | - GtkWidget *label = gtk_label_new_with_mnemonic(text); | |
| 82 | - | |
| 83 | - gtk_misc_set_alignment(GTK_MISC(label),0,0.5); | |
| 84 | - | |
| 85 | - gtk_grid_attach(container,label,0,row,1,1); | |
| 86 | - gtk_grid_attach(container,widget,1,row,1,1); | |
| 87 | - | |
| 88 | - gtk_label_set_mnemonic_widget(GTK_LABEL(label),widget); | |
| 89 | - } | |
| 90 | -#else | |
| 91 | - static void set_row(int row, GtkWidget *widget, GtkTable *container, const gchar *text) | |
| 92 | - { | |
| 93 | - GtkWidget *label = gtk_label_new_with_mnemonic(text); | |
| 94 | - | |
| 95 | - gtk_misc_set_alignment(GTK_MISC(label),0,0.5); | |
| 96 | - | |
| 97 | - gtk_table_attach(container,label,0,1,row,row+1,GTK_FILL,0,5,0); | |
| 98 | - gtk_table_attach(container,widget,1,2,row,row+1,GTK_FILL,0,0,0); | |
| 99 | - | |
| 100 | - gtk_label_set_mnemonic_widget(GTK_LABEL(label),widget); | |
| 101 | - } | |
| 102 | -#endif // GTK_CHECK_VERSION | |
| 103 | - | |
| 104 | - static void systype_changed(GtkComboBox *widget, int *iHostType) | |
| 105 | - { | |
| 106 | - GValue value = { 0, }; | |
| 107 | - GtkTreeIter iter; | |
| 108 | - | |
| 109 | - if(!gtk_combo_box_get_active_iter(widget,&iter)) | |
| 110 | - return; | |
| 111 | - | |
| 112 | - gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); | |
| 113 | - | |
| 114 | - *iHostType = g_value_get_int(&value); | |
| 115 | - | |
| 116 | - trace("Selected host type: %s",host_type[*iHostType].name); | |
| 117 | - | |
| 118 | - } | |
| 119 | - | |
| 120 | - static void color_changed(GtkComboBox *widget, int *iColorTable) | |
| 121 | - { | |
| 122 | - GValue value = { 0, }; | |
| 123 | - GtkTreeIter iter; | |
| 124 | - | |
| 125 | - if(!gtk_combo_box_get_active_iter(widget,&iter)) | |
| 126 | - return; | |
| 127 | - | |
| 128 | - gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); | |
| 129 | - | |
| 130 | - *iColorTable = g_value_get_int(&value); | |
| 131 | - | |
| 132 | - trace("Selected color type: %d",(int) colortable[*iColorTable].colors); | |
| 133 | - | |
| 134 | - } | |
| 135 | -*/ | |
| 136 | 35 | void hostname_action(GtkAction *action, GtkWidget *widget) |
| 137 | 36 | { |
| 138 | 37 | H3270 * hSession = v3270_get_session(widget); |
| ... | ... | @@ -147,288 +46,5 @@ |
| 147 | 46 | |
| 148 | 47 | v3270_select_host(widget); |
| 149 | 48 | |
| 150 | -/* | |
| 151 | - const gchar * title = g_object_get_data(G_OBJECT(action),"title"); | |
| 152 | - gchar * ptr; | |
| 153 | - gboolean again = TRUE; | |
| 154 | - int iHostType = 0; | |
| 155 | - int iColorTable = 0; | |
| 156 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 157 | - GtkGrid * grid = GTK_GRID(gtk_grid_new()); | |
| 158 | -#else | |
| 159 | - GtkTable * table = GTK_TABLE(gtk_table_new(3,4,FALSE)); | |
| 160 | -#endif // GTK_CHECK_VERSION | |
| 161 | - GtkEntry * host = GTK_ENTRY(gtk_entry_new()); | |
| 162 | - GtkEntry * port = GTK_ENTRY(gtk_entry_new()); | |
| 163 | - GtkToggleButton * sslcheck = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic( _( "_Secure connection" ) )); | |
| 164 | - GtkWidget * dialog = gtk_dialog_new_with_buttons( | |
| 165 | - gettext(title ? title : N_( "Select hostname" )), | |
| 166 | - GTK_WINDOW(gtk_widget_get_toplevel(widget)), | |
| 167 | - GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT, | |
| 168 | - GTK_STOCK_CONNECT, GTK_RESPONSE_ACCEPT, | |
| 169 | - GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, | |
| 170 | - NULL ); | |
| 171 | - | |
| 172 | - gtk_window_set_icon_name(GTK_WINDOW(dialog),GTK_STOCK_HOME); | |
| 173 | - gtk_entry_set_max_length(host,0xFF); | |
| 174 | - gtk_entry_set_width_chars(host,50); | |
| 175 | - | |
| 176 | - gtk_entry_set_max_length(port,6); | |
| 177 | - gtk_entry_set_width_chars(port,7); | |
| 178 | - | |
| 179 | - | |
| 180 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 181 | - | |
| 182 | - gtk_grid_set_column_spacing(grid,5); | |
| 183 | - gtk_grid_set_row_spacing(grid,3); | |
| 184 | - | |
| 185 | - { | |
| 186 | - // Host info - GtkGrid version | |
| 187 | - struct _line | |
| 188 | - { | |
| 189 | - const gchar * label; | |
| 190 | - GtkWidget * widget; | |
| 191 | - } line[] = | |
| 192 | - { | |
| 193 | - { N_( "_Hostname:" ), GTK_WIDGET(host) }, | |
| 194 | - { N_( "_Port:" ), GTK_WIDGET(port) } | |
| 195 | - }; | |
| 196 | - | |
| 197 | - int f; | |
| 198 | - int c = 0; | |
| 199 | - | |
| 200 | - for(f=0;f<G_N_ELEMENTS(line);f++) | |
| 201 | - { | |
| 202 | - GtkWidget * label = gtk_label_new_with_mnemonic( gettext(line[f].label) ); | |
| 203 | - gtk_label_set_mnemonic_widget(GTK_LABEL(label),line[f].widget); | |
| 204 | - | |
| 205 | - gtk_grid_attach(grid,label,c,0,1,1); | |
| 206 | - gtk_grid_attach(grid,line[f].widget,c+1,0,3,1); | |
| 207 | - c += 4; | |
| 208 | - } | |
| 209 | - | |
| 210 | - gtk_grid_attach_next_to(grid,GTK_WIDGET(sslcheck),GTK_WIDGET(host),GTK_POS_BOTTOM,1,1); | |
| 211 | - | |
| 212 | - } | |
| 213 | -#else | |
| 214 | - { | |
| 215 | - // Host info - GtkTable version | |
| 216 | - struct _line | |
| 217 | - { | |
| 218 | - const gchar * label; | |
| 219 | - GtkWidget * widget; | |
| 220 | - GtkAttachOptions xoptions; | |
| 221 | - } line[] = | |
| 222 | - { | |
| 223 | - { N_( "_Hostname:" ), GTK_WIDGET(host), GTK_EXPAND|GTK_FILL }, | |
| 224 | - { N_( "_Port:" ), GTK_WIDGET(port), GTK_FILL } | |
| 225 | - }; | |
| 226 | - | |
| 227 | - int f; | |
| 228 | - | |
| 229 | - for(f=0;f<G_N_ELEMENTS(line);f++) | |
| 230 | - { | |
| 231 | - int col = f*3; | |
| 232 | - | |
| 233 | - GtkWidget * label = gtk_label_new_with_mnemonic( gettext(line[f].label) ); | |
| 234 | - gtk_label_set_mnemonic_widget(GTK_LABEL(label),line[f].widget); | |
| 235 | - gtk_table_attach(table,label,col,col+1,0,1,0,0,2,2); | |
| 236 | - gtk_table_attach(table,line[f].widget,col+1,col+2,0,1,line[f].xoptions,0,2,2); | |
| 237 | - } | |
| 238 | - | |
| 239 | - gtk_table_attach(table,GTK_WIDGET(sslcheck),1,2,1,2,GTK_EXPAND|GTK_FILL,0,0,0); | |
| 240 | - } | |
| 241 | -#endif // GTK_CHECK_VERSION | |
| 242 | - | |
| 243 | - { | |
| 244 | - // Host options | |
| 245 | - const gchar * systype = g_object_get_data(G_OBJECT(action),"type"); | |
| 246 | - const gchar * colortype = g_object_get_data(G_OBJECT(action),"colors"); | |
| 247 | - | |
| 248 | - int row = 0; | |
| 249 | - GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options")); | |
| 250 | - | |
| 251 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 252 | - GtkGrid * container = GTK_GRID(gtk_grid_new()); | |
| 253 | - | |
| 254 | - gtk_grid_set_column_spacing(container,5); | |
| 255 | - gtk_grid_set_row_spacing(container,3); | |
| 256 | - | |
| 257 | -#else | |
| 258 | - GtkTable * container = GTK_TABLE(gtk_table_new(3,2,FALSE)); | |
| 259 | -#endif // GTK_CHECK_VERSION | |
| 260 | - | |
| 261 | - | |
| 262 | - if(!systype) | |
| 263 | - { | |
| 264 | - // No system type defined, ask user | |
| 265 | - gchar * str = get_string_from_config("host","systype",host_type[0].name); | |
| 266 | - GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); | |
| 267 | - GtkWidget * widget = gtk_combo_box_new_with_model(model); | |
| 268 | - GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | |
| 269 | - | |
| 270 | - int f; | |
| 271 | - | |
| 272 | - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE); | |
| 273 | - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL); | |
| 274 | - | |
| 275 | - for(f=0;f<G_N_ELEMENTS(host_type);f++) | |
| 276 | - { | |
| 277 | - GtkTreeIter iter; | |
| 278 | - | |
| 279 | - gtk_list_store_append((GtkListStore *) model,&iter); | |
| 280 | - gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(host_type[f].description), 1, f, -1); | |
| 281 | - | |
| 282 | - if(!g_ascii_strcasecmp(host_type[f].name,str)) | |
| 283 | - gtk_combo_box_set_active(GTK_COMBO_BOX(widget),iHostType=f); | |
| 284 | - } | |
| 285 | - | |
| 286 | - g_free(str); | |
| 287 | - | |
| 288 | - set_row(row++,widget,container,_( "System _type:" )); | |
| 289 | - | |
| 290 | - g_signal_connect(G_OBJECT(widget),"changed",G_CALLBACK(systype_changed),&iHostType); | |
| 291 | - | |
| 292 | - } | |
| 293 | - else | |
| 294 | - { | |
| 295 | - int f; | |
| 296 | - | |
| 297 | - iHostType = -1; | |
| 298 | - for(f=0;f<G_N_ELEMENTS(host_type);f++) | |
| 299 | - { | |
| 300 | - if(!g_ascii_strcasecmp(systype,host_type[f].name)) | |
| 301 | - { | |
| 302 | - g_message("Host set to %s (%s) by action property",host_type[f].name,host_type[f].description); | |
| 303 | - iHostType = f; | |
| 304 | - break; | |
| 305 | - } | |
| 306 | - } | |
| 307 | - | |
| 308 | - if(iHostType == -1) | |
| 309 | - { | |
| 310 | - iHostType = 0; | |
| 311 | - g_message("Unexpected host type \"%s\", using defaults",systype); | |
| 312 | - } | |
| 313 | - | |
| 314 | - } | |
| 315 | - | |
| 316 | - if(!colortype) | |
| 317 | - { | |
| 318 | - // NO colortype defined, ask user | |
| 319 | - unsigned short colors = (unsigned short) get_integer_from_config("host","colortype",16); | |
| 320 | - GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); | |
| 321 | - GtkWidget * widget = gtk_combo_box_new_with_model(model); | |
| 322 | - GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); | |
| 323 | - | |
| 324 | - int f; | |
| 325 | - | |
| 326 | - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE); | |
| 327 | - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget), renderer, "text", 0, NULL); | |
| 328 | - | |
| 329 | - for(f=0;f<G_N_ELEMENTS(colortable);f++) | |
| 330 | - { | |
| 331 | - GtkTreeIter iter; | |
| 332 | - | |
| 333 | - gtk_list_store_append((GtkListStore *) model,&iter); | |
| 334 | - gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(colortable[f].description), 1, (int) f, -1); | |
| 335 | - | |
| 336 | - if(colortable[f].colors == colors) | |
| 337 | - gtk_combo_box_set_active(GTK_COMBO_BOX(widget),iColorTable=f); | |
| 338 | - } | |
| 339 | - | |
| 340 | - set_row(row++,widget,container,_("_Color table:")); | |
| 341 | - | |
| 342 | - g_signal_connect(G_OBJECT(widget),"changed",G_CALLBACK(color_changed),&iColorTable); | |
| 343 | - | |
| 344 | - } | |
| 345 | - else | |
| 346 | - { | |
| 347 | - #warning TODO: Configurar tabela de cores de acordo com colortype | |
| 348 | - } | |
| 349 | - | |
| 350 | - gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(container)); | |
| 351 | - | |
| 352 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 353 | - gtk_grid_attach_next_to(grid,GTK_WIDGET(expander),GTK_WIDGET(sslcheck),GTK_POS_BOTTOM,1,1); | |
| 354 | -#else | |
| 355 | - gtk_table_attach(table,expander,1,2,2,3,GTK_EXPAND|GTK_FILL,0,0,0); | |
| 356 | -#endif // GTK_CHECK_VERSION | |
| 357 | - | |
| 358 | - } | |
| 359 | - | |
| 360 | -#if GTK_CHECK_VERSION(3,0,0) | |
| 361 | - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(grid),FALSE,FALSE,2); | |
| 362 | - gtk_widget_show_all(GTK_WIDGET(grid)); | |
| 363 | - gtk_container_set_border_width(GTK_CONTAINER(grid),5); | |
| 364 | -#else | |
| 365 | - gtk_container_set_border_width(GTK_CONTAINER(table),5); | |
| 366 | - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),GTK_WIDGET(table),FALSE,FALSE,2); | |
| 367 | - gtk_widget_show_all(GTK_WIDGET(table)); | |
| 368 | -#endif | |
| 369 | - | |
| 370 | - { | |
| 371 | - H3270 *hSession = v3270_get_session(widget); | |
| 372 | - gchar *uri = get_string_from_config("host","uri",""); | |
| 373 | - | |
| 374 | - if(uri && *uri) | |
| 375 | - lib3270_set_host(hSession,uri); | |
| 376 | - | |
| 377 | - g_free(uri); | |
| 378 | - | |
| 379 | - gtk_entry_set_text(host,lib3270_get_hostname(hSession)); | |
| 380 | - gtk_entry_set_text(port,lib3270_get_srvcname(hSession)); | |
| 381 | - gtk_toggle_button_set_active(sslcheck,(lib3270_get_options(hSession) & LIB3270_OPTION_SSL) ? TRUE : FALSE); | |
| 382 | - } | |
| 383 | - | |
| 384 | - | |
| 385 | - while(again) | |
| 386 | - { | |
| 387 | - gtk_widget_set_sensitive(dialog,TRUE); | |
| 388 | - switch(gtk_dialog_run(GTK_DIALOG(dialog))) | |
| 389 | - { | |
| 390 | - case GTK_RESPONSE_ACCEPT: | |
| 391 | - gtk_widget_set_sensitive(dialog,FALSE); | |
| 392 | - | |
| 393 | -#if GTK_CHECK_VERSION(2,18,0) | |
| 394 | - gtk_widget_set_visible(dialog,FALSE); | |
| 395 | -#else | |
| 396 | - gtk_widget_hide(dialog); | |
| 397 | -#endif | |
| 398 | - set_string_to_config("host","systype",host_type[iHostType].name); | |
| 399 | - set_integer_to_config("host","colortype",colortable[iColorTable].colors); | |
| 400 | - | |
| 401 | - v3270_set_session_color_type(widget,colortable[iColorTable].colors); | |
| 402 | - | |
| 403 | -// if(!lib3270_connect(v3270_get_session(widget),hostname,1)) | |
| 404 | - if(!lib3270_connect_host( v3270_get_session(widget), | |
| 405 | - gtk_entry_get_text(host), | |
| 406 | - gtk_entry_get_text(port), | |
| 407 | - host_type[iHostType].option | (gtk_toggle_button_get_active(sslcheck) ? LIB3270_OPTION_SSL : LIB3270_OPTION_DEFAULTS))) | |
| 408 | - { | |
| 409 | - again = FALSE; | |
| 410 | - } | |
| 411 | - else | |
| 412 | - { | |
| 413 | -#if GTK_CHECK_VERSION(2,18,0) | |
| 414 | - gtk_widget_set_visible(dialog,TRUE); | |
| 415 | -#else | |
| 416 | - gtk_widget_show(dialog); | |
| 417 | -#endif | |
| 418 | - } | |
| 419 | - | |
| 420 | -// g_free(hostname); | |
| 421 | - break; | |
| 422 | - | |
| 423 | - case GTK_RESPONSE_REJECT: | |
| 424 | - again = FALSE; | |
| 425 | - break; | |
| 426 | - } | |
| 427 | - } | |
| 428 | - | |
| 429 | - gtk_widget_destroy(dialog); | |
| 430 | - | |
| 431 | -// g_free(cfghost); | |
| 432 | -*/ | |
| 433 | 49 | } |
| 434 | 50 | ... | ... |
src/pw3270/v3270/hostselect.c
| ... | ... | @@ -433,6 +433,7 @@ LIB3270_EXPORT int v3270_host_select_apply(V3270HostSelectWidget *widget) |
| 433 | 433 | |
| 434 | 434 | lib3270_set_hostname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_HOSTNAME])); |
| 435 | 435 | lib3270_set_srvcname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_SRVCNAME])); |
| 436 | + | |
| 436 | 437 | lib3270_set_options(widget->hSession,widget->options); |
| 437 | 438 | |
| 438 | 439 | return lib3270_connect(widget->hSession,0); | ... | ... |