Commit 6a308188fb74a6b619d488275fe824d2df9214c5

Authored by Perry Werneck
1 parent 7bff2b66
Exists in master and in 1 other branch develop

Updating SSL options.

src/dialogs/hostselect.c
@@ -63,13 +63,18 @@ @@ -63,13 +63,18 @@
63 GtkVBox parent; 63 GtkVBox parent;
64 #endif // GTK_CHECK_VERSION 64 #endif // GTK_CHECK_VERSION
65 65
66 - LIB3270_OPTION options; /**< Connect option */ 66 + LIB3270_HOST_TYPE type; /**< @brief Connect option */
67 67
68 - GtkEntry * entry[ENTRY_COUNT]; /**< Entry fields for host & service name */  
69 - GtkToggleButton * ssl; /**< SSL Connection? */  
70 - GtkComboBox * combo[G_N_ELEMENTS(comboLabel)]; /**< Model & Color combobox */  
71 - unsigned short colors; /**< Number of colors */  
72 - H3270 * hSession; /**< lib3270's session handle */ 68 + struct
  69 + {
  70 + GtkEntry * entry[ENTRY_COUNT]; /**< @brief Entry fields for host & service name */
  71 + GtkToggleButton * ssl; /**< @brief SSL Connection? */
  72 + GtkComboBox * combo[G_N_ELEMENTS(comboLabel)]; /**< @brief Model & Color combobox */
  73 +
  74 + } input;
  75 +
  76 + unsigned short colors; /**< @brief Number of colors */
  77 + H3270 * hSession; /**< @brief lib3270's session handle */
73 78
74 }; 79 };
75 80
@@ -93,18 +98,13 @@ @@ -93,18 +98,13 @@
93 98
94 static void V3270HostSelectWidget_class_init(G_GNUC_UNUSED V3270HostSelectWidgetClass *klass) 99 static void V3270HostSelectWidget_class_init(G_GNUC_UNUSED V3270HostSelectWidgetClass *klass)
95 { 100 {
96 -#if GTK_CHECK_VERSION(3,0,0)  
97 -#else  
98 -#endif // GTK_CHECK_VERSION  
99 } 101 }
100 102
  103 +/*
101 static void toggle_ssl(GtkToggleButton *button, V3270HostSelectWidget *dialog) 104 static void toggle_ssl(GtkToggleButton *button, V3270HostSelectWidget *dialog)
102 { 105 {
103 - if(gtk_toggle_button_get_active(button))  
104 - dialog->options |= LIB3270_OPTION_SSL;  
105 - else  
106 - dialog->options &= ~LIB3270_OPTION_SSL;  
107 } 106 }
  107 +*/
108 108
109 static void systype_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog) 109 static void systype_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog)
110 { 110 {
@@ -116,8 +116,7 @@ static void systype_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog) @@ -116,8 +116,7 @@ static void systype_changed(GtkComboBox *widget, V3270HostSelectWidget *dialog)
116 116
117 gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value); 117 gtk_tree_model_get_value(gtk_combo_box_get_model(widget),&iter,1,&value);
118 118
119 - dialog->options &= ~(LIB3270_OPTION_HOST_TYPE);  
120 - dialog->options |= g_value_get_int(&value); 119 + dialog->type = g_value_get_int(&value);
121 120
122 } 121 }
123 122
@@ -155,18 +154,19 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) @@ -155,18 +154,19 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
155 154
156 for(f=0;f<ENTRY_COUNT;f++) 155 for(f=0;f<ENTRY_COUNT;f++)
157 { 156 {
158 - widget->entry[f] = GTK_ENTRY(gtk_entry_new()); 157 + widget->input.entry[f] = GTK_ENTRY(gtk_entry_new());
159 gtk_misc_set_alignment(GTK_MISC(label[f]),0,0.5); 158 gtk_misc_set_alignment(GTK_MISC(label[f]),0,0.5);
160 - gtk_label_set_mnemonic_widget(GTK_LABEL(label[f]),GTK_WIDGET(widget->entry[f])); 159 + gtk_label_set_mnemonic_widget(GTK_LABEL(label[f]),GTK_WIDGET(widget->input.entry[f]));
161 } 160 }
162 161
163 - gtk_widget_set_tooltip_text(GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),_("Address or name of the host to connect.") );  
164 - gtk_widget_set_tooltip_text(GTK_WIDGET(widget->entry[ENTRY_SRVCNAME]),_("Port or service name (empty for \"telnet\").") ); 162 + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.entry[ENTRY_HOSTNAME]),_("Address or name of the host to connect.") );
  163 + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.entry[ENTRY_SRVCNAME]),_("Port or service name (empty for \"telnet\").") );
165 164
166 // SSL checkbox 165 // SSL checkbox
167 - widget->ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." )));  
168 - gtk_widget_set_tooltip_text(GTK_WIDGET(widget->ssl),_( "Check for SSL secure connection." ));  
169 - g_signal_connect(G_OBJECT(widget->ssl),"toggled",G_CALLBACK(toggle_ssl),widget); 166 + widget->input.ssl = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_mnemonic(_( "_Secure connection." )));
  167 + gtk_widget_set_tooltip_text(GTK_WIDGET(widget->input.ssl),_( "Check for SSL secure connection." ));
  168 +
  169 + //g_signal_connect(G_OBJECT(widget->input.ssl),"toggled",G_CALLBACK(toggle_ssl),widget);
170 170
171 // Extended options 171 // Extended options
172 GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options")); 172 GtkWidget * expander = gtk_expander_new_with_mnemonic(_( "_Host options"));
@@ -176,20 +176,20 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) @@ -176,20 +176,20 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
176 GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); 176 GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT);
177 GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); 177 GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
178 178
179 - widget->combo[0] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model)); 179 + widget->input.combo[0] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model));
180 180
181 - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->combo[0]), renderer, TRUE);  
182 - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->combo[0]), renderer, "text", 0, NULL); 181 + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->input.combo[0]), renderer, TRUE);
  182 + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->input.combo[0]), renderer, "text", 0, NULL);
183 183
184 - const LIB3270_OPTION_ENTRY *entry = lib3270_get_option_list(); 184 + const LIB3270_HOST_TYPE_ENTRY *entry = lib3270_get_option_list();
185 for(f=0;entry[f].name != NULL;f++) 185 for(f=0;entry[f].name != NULL;f++)
186 { 186 {
187 GtkTreeIter iter; 187 GtkTreeIter iter;
188 gtk_list_store_append((GtkListStore *) model,&iter); 188 gtk_list_store_append((GtkListStore *) model,&iter);
189 - gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(entry[f].description), 1, entry[f].option, -1); 189 + gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(entry[f].description), 1, entry[f].type, -1);
190 } 190 }
191 191
192 - g_signal_connect(G_OBJECT(widget->combo[0]),"changed",G_CALLBACK(systype_changed),widget); 192 + g_signal_connect(G_OBJECT(widget->input.combo[0]),"changed",G_CALLBACK(systype_changed),widget);
193 193
194 } 194 }
195 195
@@ -198,10 +198,10 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) @@ -198,10 +198,10 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
198 GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT); 198 GtkTreeModel * model = (GtkTreeModel *) gtk_list_store_new(2,G_TYPE_STRING,G_TYPE_INT);
199 GtkCellRenderer * renderer = gtk_cell_renderer_text_new(); 199 GtkCellRenderer * renderer = gtk_cell_renderer_text_new();
200 200
201 - widget->combo[1] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model)); 201 + widget->input.combo[1] = GTK_COMBO_BOX(gtk_combo_box_new_with_model(model));
202 202
203 - gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->combo[1]), renderer, TRUE);  
204 - gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->combo[1]), renderer, "text", 0, NULL); 203 + gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget->input.combo[1]), renderer, TRUE);
  204 + gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(widget->input.combo[1]), renderer, "text", 0, NULL);
205 205
206 for(f=0;f< (int) G_N_ELEMENTS(colortable);f++) 206 for(f=0;f< (int) G_N_ELEMENTS(colortable);f++)
207 { 207 {
@@ -210,22 +210,22 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) @@ -210,22 +210,22 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
210 gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(colortable[f].description), 1, colortable[f].colors, -1); 210 gtk_list_store_set((GtkListStore *) model, &iter, 0, gettext(colortable[f].description), 1, colortable[f].colors, -1);
211 } 211 }
212 212
213 - g_signal_connect(G_OBJECT(widget->combo[1]),"changed",G_CALLBACK(colortable_changed),widget); 213 + g_signal_connect(G_OBJECT(widget->input.combo[1]),"changed",G_CALLBACK(colortable_changed),widget);
214 214
215 } 215 }
216 216
217 - gtk_entry_set_max_length(widget->entry[ENTRY_HOSTNAME],0xFF);  
218 - gtk_entry_set_width_chars(widget->entry[ENTRY_HOSTNAME],50); 217 + gtk_entry_set_max_length(widget->input.entry[ENTRY_HOSTNAME],0xFF);
  218 + gtk_entry_set_width_chars(widget->input.entry[ENTRY_HOSTNAME],50);
219 219
220 - gtk_entry_set_max_length(widget->entry[ENTRY_SRVCNAME],6);  
221 - gtk_entry_set_width_chars(widget->entry[ENTRY_SRVCNAME],7); 220 + gtk_entry_set_max_length(widget->input.entry[ENTRY_SRVCNAME],6);
  221 + gtk_entry_set_width_chars(widget->input.entry[ENTRY_SRVCNAME],7);
222 222
223 #if GTK_CHECK_VERSION(3,0,0) 223 #if GTK_CHECK_VERSION(3,0,0)
224 224
225 - gtk_entry_set_placeholder_text(widget->entry[ENTRY_SRVCNAME],"telnet"); 225 + gtk_entry_set_placeholder_text(widget->input.entry[ENTRY_SRVCNAME],"telnet");
226 226
227 - gtk_widget_set_hexpand(GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),TRUE);  
228 - gtk_widget_set_hexpand(GTK_WIDGET(widget->ssl),TRUE); 227 + gtk_widget_set_hexpand(GTK_WIDGET(widget->input.entry[ENTRY_HOSTNAME]),TRUE);
  228 + gtk_widget_set_hexpand(GTK_WIDGET(widget->input.ssl),TRUE);
229 gtk_widget_set_hexpand(GTK_WIDGET(expander),TRUE); 229 gtk_widget_set_hexpand(GTK_WIDGET(expander),TRUE);
230 230
231 gtk_grid_set_row_homogeneous(grid,FALSE); 231 gtk_grid_set_row_homogeneous(grid,FALSE);
@@ -234,12 +234,12 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) @@ -234,12 +234,12 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
234 gtk_grid_set_row_spacing(grid,5); 234 gtk_grid_set_row_spacing(grid,5);
235 235
236 gtk_grid_attach(grid,label[ENTRY_HOSTNAME],0,0,1,1); 236 gtk_grid_attach(grid,label[ENTRY_HOSTNAME],0,0,1,1);
237 - gtk_grid_attach(grid,GTK_WIDGET(widget->entry[ENTRY_HOSTNAME]),1,0,3,1); 237 + gtk_grid_attach(grid,GTK_WIDGET(widget->input.entry[ENTRY_HOSTNAME]),1,0,3,1);
238 238
239 gtk_grid_attach(grid,label[ENTRY_SRVCNAME],4,0,1,1); 239 gtk_grid_attach(grid,label[ENTRY_SRVCNAME],4,0,1,1);
240 - gtk_grid_attach(grid,GTK_WIDGET(widget->entry[ENTRY_SRVCNAME]),5,0,1,1); 240 + gtk_grid_attach(grid,GTK_WIDGET(widget->input.entry[ENTRY_SRVCNAME]),5,0,1,1);
241 241
242 - gtk_grid_attach(grid,GTK_WIDGET(widget->ssl),1,1,3,1); 242 + gtk_grid_attach(grid,GTK_WIDGET(widget->input.ssl),1,1,3,1);
243 243
244 244
245 // Host options 245 // Host options
@@ -253,7 +253,7 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget) @@ -253,7 +253,7 @@ static void V3270HostSelectWidget_init(V3270HostSelectWidget *widget)
253 GtkWidget *label = gtk_label_new_with_mnemonic(gettext(comboLabel[f])); 253 GtkWidget *label = gtk_label_new_with_mnemonic(gettext(comboLabel[f]));
254 gtk_misc_set_alignment(GTK_MISC(label),0,0.5); 254 gtk_misc_set_alignment(GTK_MISC(label),0,0.5);
255 gtk_grid_attach(opt,label,0,f+1,1,1); 255 gtk_grid_attach(opt,label,0,f+1,1,1);
256 - gtk_grid_attach(opt,GTK_WIDGET(widget->combo[f]),1,f+1,2,1); 256 + gtk_grid_attach(opt,GTK_WIDGET(widget->input.combo[f]),1,f+1,2,1);
257 } 257 }
258 258
259 gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(opt)); 259 gtk_container_add(GTK_CONTAINER(expander),GTK_WIDGET(opt));
@@ -318,16 +318,16 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget, @@ -318,16 +318,16 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget,
318 318
319 widget->hSession = v3270_get_session(session); 319 widget->hSession = v3270_get_session(session);
320 320
321 - gtk_entry_set_text(widget->entry[ENTRY_HOSTNAME],lib3270_get_hostname(widget->hSession));  
322 - gtk_entry_set_text(widget->entry[ENTRY_SRVCNAME],lib3270_get_srvcname(widget->hSession)); 321 + gtk_entry_set_text(widget->input.entry[ENTRY_HOSTNAME],lib3270_get_hostname(widget->hSession));
  322 + gtk_entry_set_text(widget->input.entry[ENTRY_SRVCNAME],lib3270_get_srvcname(widget->hSession));
323 323
324 - LIB3270_OPTION opt = lib3270_get_options(widget->hSession); 324 + LIB3270_HOST_TYPE type = lib3270_get_host_type(widget->hSession);
325 325
326 - gtk_toggle_button_set_active(widget->ssl,(opt & LIB3270_OPTION_SSL) != 0); 326 + gtk_toggle_button_set_active(widget->input.ssl,lib3270_get_secure_host(widget->hSession) != 0);
327 327
328 // Set host type 328 // Set host type
329 { 329 {
330 - GtkTreeModel * model = gtk_combo_box_get_model(widget->combo[0]); 330 + GtkTreeModel * model = gtk_combo_box_get_model(widget->input.combo[0]);
331 GtkTreeIter iter; 331 GtkTreeIter iter;
332 332
333 if(gtk_tree_model_get_iter_first(model,&iter)) 333 if(gtk_tree_model_get_iter_first(model,&iter))
@@ -338,9 +338,9 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget, @@ -338,9 +338,9 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget,
338 338
339 gtk_tree_model_get_value(model,&iter,1,&value); 339 gtk_tree_model_get_value(model,&iter,1,&value);
340 340
341 - if(g_value_get_int(&value) == (int) (opt&LIB3270_OPTION_HOST_TYPE)) 341 + if(g_value_get_int(&value) == (int) type)
342 { 342 {
343 - gtk_combo_box_set_active_iter(widget->combo[0],&iter); 343 + gtk_combo_box_set_active_iter(widget->input.combo[0],&iter);
344 break; 344 break;
345 } 345 }
346 346
@@ -350,7 +350,7 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget, @@ -350,7 +350,7 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget,
350 350
351 // Set color type 351 // Set color type
352 { 352 {
353 - GtkTreeModel * model = gtk_combo_box_get_model(widget->combo[1]); 353 + GtkTreeModel * model = gtk_combo_box_get_model(widget->input.combo[1]);
354 GtkTreeIter iter; 354 GtkTreeIter iter;
355 int colors = (int) lib3270_get_color_type(widget->hSession); 355 int colors = (int) lib3270_get_color_type(widget->hSession);
356 356
@@ -366,7 +366,7 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget, @@ -366,7 +366,7 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget,
366 366
367 if(g_value_get_int(&value) == colors) 367 if(g_value_get_int(&value) == colors)
368 { 368 {
369 - gtk_combo_box_set_active_iter(widget->combo[1],&iter); 369 + gtk_combo_box_set_active_iter(widget->input.combo[1],&iter);
370 break; 370 break;
371 } 371 }
372 372
@@ -375,7 +375,8 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget, @@ -375,7 +375,8 @@ LIB3270_EXPORT void v3270_host_select_set_session(V3270HostSelectWidget *widget,
375 } 375 }
376 376
377 // Just in case 377 // Just in case
378 - widget->options = opt; 378 + widget->type = type;
  379 +
379 } 380 }
380 381
381 LIB3270_EXPORT void v3270_select_host(GtkWidget *widget) 382 LIB3270_EXPORT void v3270_select_host(GtkWidget *widget)
@@ -432,11 +433,11 @@ int v3270_host_select_apply(V3270HostSelectWidget *widget) @@ -432,11 +433,11 @@ int v3270_host_select_apply(V3270HostSelectWidget *widget)
432 { 433 {
433 g_return_val_if_fail(GTK_IS_V3270HostSelectWidget(widget),0); 434 g_return_val_if_fail(GTK_IS_V3270HostSelectWidget(widget),0);
434 435
435 - lib3270_set_hostname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_HOSTNAME]));  
436 - lib3270_set_srvcname(widget->hSession,gtk_entry_get_text(widget->entry[ENTRY_SRVCNAME])); 436 + lib3270_set_hostname(widget->hSession,gtk_entry_get_text(widget->input.entry[ENTRY_HOSTNAME]));
  437 + lib3270_set_srvcname(widget->hSession,gtk_entry_get_text(widget->input.entry[ENTRY_SRVCNAME]));
437 438
438 - lib3270_set_options(widget->hSession,widget->options); 439 + lib3270_set_host_type(widget->hSession,widget->type);
439 440
440 - return lib3270_connect(widget->hSession,0); 441 + return lib3270_reconnect(widget->hSession,0);
441 } 442 }
442 443
src/include/v3270.h
@@ -178,7 +178,7 @@ @@ -178,7 +178,7 @@
178 H3270 * v3270_get_session(GtkWidget *widget); 178 H3270 * v3270_get_session(GtkWidget *widget);
179 gboolean v3270_is_connected(GtkWidget *widget); 179 gboolean v3270_is_connected(GtkWidget *widget);
180 180
181 - int v3270_connect(GtkWidget *widget); 181 + int v3270_reconnect(GtkWidget *widget);
182 void v3270_disconnect(GtkWidget *widget); 182 void v3270_disconnect(GtkWidget *widget);
183 183
184 int v3270_set_host_charset(GtkWidget *widget, const gchar *name); 184 int v3270_set_host_charset(GtkWidget *widget, const gchar *name);
@@ -239,14 +239,18 @@ @@ -239,14 +239,18 @@
239 void v3270_set_session_name(GtkWidget *widget, const gchar *name); 239 void v3270_set_session_name(GtkWidget *widget, const gchar *name);
240 int v3270_set_script(GtkWidget *widget, const gchar id, gboolean on); 240 int v3270_set_script(GtkWidget *widget, const gchar id, gboolean on);
241 void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on); 241 void v3270_set_scaled_fonts(GtkWidget *widget, gboolean on);
242 - void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options);  
243 int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype); 242 int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype);
244 - int v3270_set_host_type(GtkWidget *widget, const char *name); 243 +
  244 + int v3270_set_host_type(GtkWidget *widget, LIB3270_HOST_TYPE type);
  245 + int v3270_set_host_type_by_name(GtkWidget *widget, const char *name);
  246 +
245 void v3270_set_url(GtkWidget *widget, const gchar *uri); 247 void v3270_set_url(GtkWidget *widget, const gchar *uri);
246 const gchar * v3270_get_hostname(GtkWidget *widget); 248 const gchar * v3270_get_hostname(GtkWidget *widget);
247 const char * v3270_get_luname(GtkWidget *widget); 249 const char * v3270_get_luname(GtkWidget *widget);
248 GtkWidget * v3270_get_default_widget(void); 250 GtkWidget * v3270_get_default_widget(void);
249 251
  252 + void v3270_set_session_host_type(GtkWidget *widget, LIB3270_HOST_TYPE);
  253 +
250 void v3270_remap_from_xml(GtkWidget *widget, const gchar *path); 254 void v3270_remap_from_xml(GtkWidget *widget, const gchar *path);
251 255
252 // Keyboard & Mouse special actions 256 // Keyboard & Mouse special actions
src/v3270/iocallback.c
@@ -35,8 +35,8 @@ static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag, @@ -35,8 +35,8 @@ static void * static_AddSource(H3270 *session, int fd, LIB3270_IO_FLAG flag,
35 static void static_RemoveSource(H3270 *session, void *id); 35 static void static_RemoveSource(H3270 *session, void *id);
36 static void static_SetSourceState(H3270 *session, void *id, int enabled); 36 static void static_SetSourceState(H3270 *session, void *id, int enabled);
37 37
38 -static void * static_AddTimeOut(H3270 *session, unsigned long interval_ms, void (*proc)(H3270 *session));  
39 -static void static_RemoveTimeOut(H3270 *session, void * timer); 38 +static void * static_AddTimer(H3270 *session, unsigned long interval_ms, int (*proc)(H3270 *session));
  39 +static void static_RemoveTimer(H3270 *session, void * timer);
40 static int static_Sleep(H3270 *hSession, int seconds); 40 static int static_Sleep(H3270 *hSession, int seconds);
41 static int static_RunPendingEvents(H3270 *hSession, int wait); 41 static int static_RunPendingEvents(H3270 *hSession, int wait);
42 42
@@ -46,7 +46,7 @@ static int static_RunPendingEvents(H3270 *hSession, int wait); @@ -46,7 +46,7 @@ static int static_RunPendingEvents(H3270 *hSession, int wait);
46 { 46 {
47 unsigned char remove; 47 unsigned char remove;
48 void * userdata; 48 void * userdata;
49 - void (*call)(H3270 *session); 49 + int (*call)(H3270 *session);
50 H3270 * session; 50 H3270 * session;
51 } TIMER; 51 } TIMER;
52 52
@@ -71,11 +71,12 @@ static void static_SetSourceState(G_GNUC_UNUSED H3270 *session, G_GNUC_UNUSED vo @@ -71,11 +71,12 @@ static void static_SetSourceState(G_GNUC_UNUSED H3270 *session, G_GNUC_UNUSED vo
71 static gboolean do_timer(TIMER *t) 71 static gboolean do_timer(TIMER *t)
72 { 72 {
73 if(!t->remove) 73 if(!t->remove)
74 - t->call(t->session); 74 + return t->call(t->session) != 0;
  75 +
75 return FALSE; 76 return FALSE;
76 } 77 }
77 78
78 -static void * static_AddTimeOut(H3270 *session, unsigned long interval, void (*call)(H3270 *session)) 79 +static void * static_AddTimer(H3270 *session, unsigned long interval, int (*call)(H3270 *session))
79 { 80 {
80 TIMER *t = g_malloc0(sizeof(TIMER)); 81 TIMER *t = g_malloc0(sizeof(TIMER));
81 82
@@ -87,23 +88,11 @@ static void * static_AddTimeOut(H3270 *session, unsigned long interval, void (*c @@ -87,23 +88,11 @@ static void * static_AddTimeOut(H3270 *session, unsigned long interval, void (*c
87 return t; 88 return t;
88 } 89 }
89 90
90 -static void static_RemoveTimeOut(G_GNUC_UNUSED H3270 *session, void * timer) 91 +static void static_RemoveTimer(G_GNUC_UNUSED H3270 *session, void * timer)
91 { 92 {
92 ((TIMER *) timer)->remove++; 93 ((TIMER *) timer)->remove++;
93 } 94 }
94 95
95 -/*  
96 -struct bgParameter  
97 -{  
98 - gboolean running;  
99 - H3270 *session;  
100 - int rc;  
101 - int(*callback)(H3270 *session, void *);  
102 - void *parm;  
103 -  
104 -};  
105 -*/  
106 -  
107 static int static_Sleep(G_GNUC_UNUSED H3270 *hSession, int seconds) 96 static int static_Sleep(G_GNUC_UNUSED H3270 *hSession, int seconds)
108 { 97 {
109 time_t end = time(0) + seconds; 98 time_t end = time(0) + seconds;
@@ -182,8 +171,8 @@ void v3270_register_io_handlers(G_GNUC_UNUSED v3270Class *cls) @@ -182,8 +171,8 @@ void v3270_register_io_handlers(G_GNUC_UNUSED v3270Class *cls)
182 { 171 {
183 sizeof(LIB3270_IO_CONTROLLER), 172 sizeof(LIB3270_IO_CONTROLLER),
184 173
185 - static_AddTimeOut,  
186 - static_RemoveTimeOut, 174 + static_AddTimer,
  175 + static_RemoveTimer,
187 176
188 static_AddSource, 177 static_AddSource,
189 static_RemoveSource, 178 static_RemoveSource,
src/v3270/widget.c
@@ -1503,11 +1503,11 @@ LIB3270_EXPORT H3270 * v3270_get_session(GtkWidget *widget) @@ -1503,11 +1503,11 @@ LIB3270_EXPORT H3270 * v3270_get_session(GtkWidget *widget)
1503 return GTK_V3270(widget)->host; 1503 return GTK_V3270(widget)->host;
1504 } 1504 }
1505 1505
1506 -LIB3270_EXPORT int v3270_connect(GtkWidget *widget) 1506 +LIB3270_EXPORT int v3270_reconnect(GtkWidget *widget)
1507 { 1507 {
1508 g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL); 1508 g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL);
1509 1509
1510 - return lib3270_connect(GTK_V3270(widget)->host,0); 1510 + return lib3270_reconnect(GTK_V3270(widget)->host,0);
1511 } 1511 }
1512 1512
1513 static gboolean notify_focus(GtkWidget *widget, GdkEventFocus *event) 1513 static gboolean notify_focus(GtkWidget *widget, GdkEventFocus *event)
@@ -1546,7 +1546,7 @@ static void v3270_activate(GtkWidget *widget) @@ -1546,7 +1546,7 @@ static void v3270_activate(GtkWidget *widget)
1546 if(lib3270_connected(terminal->host)) 1546 if(lib3270_connected(terminal->host))
1547 lib3270_enter(terminal->host); 1547 lib3270_enter(terminal->host);
1548 else if(lib3270_get_hostname(terminal->host)) 1548 else if(lib3270_get_hostname(terminal->host))
1549 - v3270_connect(widget); 1549 + v3270_reconnect(widget);
1550 else 1550 else
1551 g_warning("Terminal widget %p activated without connection or valid hostname",terminal); 1551 g_warning("Terminal widget %p activated without connection or valid hostname",terminal);
1552 } 1552 }
@@ -1657,24 +1657,25 @@ LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name) @@ -1657,24 +1657,25 @@ LIB3270_EXPORT void v3270_set_session_name(GtkWidget *widget, const gchar *name)
1657 GTK_V3270(widget)->session_name = g_strdup(name); 1657 GTK_V3270(widget)->session_name = g_strdup(name);
1658 } 1658 }
1659 1659
1660 -LIB3270_EXPORT void v3270_set_session_options(GtkWidget *widget, LIB3270_OPTION options) 1660 +LIB3270_EXPORT int v3270_set_host_type(GtkWidget *widget, LIB3270_HOST_TYPE type)
1661 { 1661 {
1662 - g_return_if_fail(GTK_IS_V3270(widget));  
1663 - lib3270_set_options(GTK_V3270(widget)->host,options); 1662 + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL);
  1663 + return lib3270_set_host_type(GTK_V3270(widget)->host, type);
1664 } 1664 }
1665 1665
1666 -LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype) 1666 +LIB3270_EXPORT int v3270_set_host_type_by_name(GtkWidget *widget, const char *name)
1667 { 1667 {
1668 - g_return_val_if_fail(GTK_IS_V3270(widget),EFAULT);  
1669 - return lib3270_set_color_type(GTK_V3270(widget)->host,colortype); 1668 + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL);
  1669 + return lib3270_set_host_type_by_name(GTK_V3270(widget)->host,name);
1670 } 1670 }
1671 1671
1672 -LIB3270_EXPORT int v3270_set_host_type(GtkWidget *widget, const char *name) 1672 +LIB3270_EXPORT int v3270_set_session_color_type(GtkWidget *widget, unsigned short colortype)
1673 { 1673 {
1674 - g_return_val_if_fail(GTK_IS_V3270(widget),EFAULT);  
1675 - return lib3270_set_host_type(GTK_V3270(widget)->host,name); 1674 + g_return_val_if_fail(GTK_IS_V3270(widget),EINVAL);
  1675 + return lib3270_set_color_type(GTK_V3270(widget)->host,colortype);
1676 } 1676 }
1677 1677
  1678 +
1678 LIB3270_EXPORT unsigned short v3270_get_session_color_type(GtkWidget *widget) 1679 LIB3270_EXPORT unsigned short v3270_get_session_color_type(GtkWidget *widget)
1679 { 1680 {
1680 g_return_val_if_fail(GTK_IS_V3270(widget),-1); 1681 g_return_val_if_fail(GTK_IS_V3270(widget),-1);