00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026 #include "config.h"
00027 #include <string.h>
00028
00029 #include <gtk/gtk.h>
00030
00031 #include <liberdm/connectionMgrConstants.h>
00032 #include <liberregxml/erregapi.h>
00033 #include <libergtk/ergtk.h>
00034
00035 #include "connectionMgrLog.h"
00036 #include "displayStatus.h"
00037 #include "erbusy.h"
00038 #include "connectionMgr.h"
00039 #include "gtkSettingItem.h"
00040 #include "gtkInfoItem.h"
00041 #include "gtkProfileEntry.h"
00042 #include "widgetUtils.h"
00043 #include "commonData.h"
00044 #include "connectScreenData.h"
00045 #include "editScreenData.h"
00046 #include "editScreen.h"
00047 #include "editScreenOverview.h"
00048 #include "editScreenWireless.h"
00049 #include "editScreenWirelessExt.h"
00050 #include "editScreenDialup.h"
00051 #include "editScreenStatic.h"
00052 #include "editScreenProxy.h"
00053 #include "connectPing.h"
00054 #include "connectBackground.h"
00055 #include "connectionMgr.h"
00056 #include "background.h"
00057 #include "languages.h"
00058
00059 static GtkWidget *g_overview = NULL;
00060
00061 static bkProfileEntry *g_profile_entry = NULL;
00062 static bkWdtLabelButton *g_address = NULL;
00063 static bkWdtLabelButton *g_proxy = NULL;
00064 static bkWdtLabelEntry *g_profilename = NULL;
00065 static bkWdtLabelButton *g_buttons = NULL;
00066
00067 static GtkWidget *g_info = NULL;
00068
00069 static ip_address_mode_t edit_overview_get_address(void);
00070 static gboolean edit_overview_get_proxy(void);
00071 static const char *edit_overview_get_profilename(void);
00072
00073 static gboolean on_delayed_edit_goto_page(gpointer new_page);
00074 static gboolean delayed_deactive_button(gpointer data);
00075
00076 static gboolean on_button_press(GtkWidget *button,
00077 GdkEventButton *event,
00078 gpointer data);
00079 static gboolean on_profile_entry_button_press(GtkWidget *widget,
00080 GdkEventButton *event,
00081 gpointer data);
00082 static void on_ip_address_mode_update(GtkWidget *selection,
00083 gpointer button,
00084 gpointer data);
00085 static void on_proxy_onoff_update(GtkWidget *selection,
00086 gpointer button,
00087 gpointer data);
00088 static void on_profilename_changed(GtkEntry *widget, gpointer data);
00089 static void on_buttons_update(GtkWidget *selection,
00090 gpointer button,
00091 gpointer data);
00092
00093 static void on_test(void);
00094 static void on_save(void);
00095 static void on_saveconnect(void);
00096
00097 static void edit_overview_restore_ping_ctxt(gboolean toTest);
00098 static void on_test_connected(int profileIndex);
00099 static void on_test_failed(void);
00100 static void on_connected(int profileIndex);
00101 static void on_failed(void);
00102 static void ui_test_update_status(int profileIndex, pingStatus_t status);
00103 static void ui_update_status(int profileIndex, pingStatus_t status);
00104 static void ui_display_settings(int profileIndex, gboolean resetStatus);
00105 static void ui_select_profile(int profileIndex);
00106 static void ui_unselect_all_profile(void);
00107
00108 static void edit_overview_freeze_ui(gboolean freeze);
00109
00111
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 GtkWidget* edit_overview_create(void)
00124 {
00125 GtkWidget *item;
00126 GtkWidget *vbox;
00127 bkProfileEntry *profileEntry;
00128 bkWdtLabelButton *ipAddressMode;
00129 bkWdtLabelButton *proxyOnOff;
00130 bkWdtLabelEntry *profileName;
00131 bkWdtLabelButton *buttons;
00132 GtkWidget *info;
00133 GtkWidget *widget;
00134
00135 CN_LOGPRINTF("entry");
00136
00137
00138 item = gtk_settingitem_new("");
00139
00140
00141 vbox = gtk_vbox_new(FALSE, VBOX_SPACING);
00142 gtk_settingitem_add_details(GTK_SETTINGITEM(item), vbox);
00143
00144
00145 profileEntry = bk_profile_entry_new();
00146 gtk_box_pack_start(GTK_BOX(vbox), profileEntry->background,
00147 FALSE, FALSE, 0);
00148
00149
00150 ipAddressMode = bk_wdt_label_button_new(2, FALSE, 1, 1);
00151 gtk_box_pack_start(GTK_BOX(vbox), ipAddressMode->background,
00152 FALSE, FALSE, 0);
00153
00154
00155 proxyOnOff = bk_wdt_label_button_new(2, FALSE, 1, 1);
00156 gtk_box_pack_start(GTK_BOX(vbox), proxyOnOff->background,
00157 FALSE, FALSE, 0);
00158
00159
00160 profileName = bk_wdt_label_entry_new(string_e);
00161 gtk_box_pack_start(GTK_BOX(vbox), profileName->background,
00162 FALSE, FALSE, 0);
00163
00164
00165 buttons = bk_wdt_label_button_new(3, FALSE, 0, 1);
00166 gtk_box_pack_start(GTK_BOX(vbox), buttons->background,
00167 FALSE, FALSE, 0);
00168
00169
00170 info = gtk_infoitem_new(FALSE);
00171 gtk_box_pack_start(GTK_BOX(vbox), info, FALSE, FALSE, 0);
00172
00173
00174 widget = profileEntry->background;
00175 g_signal_connect(G_OBJECT(widget), "button-press-event",
00176 G_CALLBACK(on_button_press), (gpointer)inputDetails_e);
00177 widget = ipAddressMode->background;
00178 g_signal_connect(G_OBJECT(widget), "button-press-event",
00179 G_CALLBACK(on_button_press), (gpointer)inputAddress_e);
00180 widget = proxyOnOff->background;
00181 g_signal_connect(G_OBJECT(widget), "button-press-event",
00182 G_CALLBACK(on_button_press), (gpointer)inputProxy_e);
00183 widget = profileName->background;
00184 g_signal_connect(G_OBJECT(widget), "button-press-event",
00185 G_CALLBACK(on_button_press), (gpointer)inputProfileName_e);
00186
00187 widget = gtk_profile_entry_get_namebutton(GTK_PROFILE_ENTRY(profileEntry->details));
00188 g_signal_connect(G_OBJECT(widget), "button-press-event",
00189 G_CALLBACK(on_profile_entry_button_press), NULL);
00190
00191 widget = ipAddressMode->details->selection;
00192 g_signal_connect(G_OBJECT(widget), "selection-update",
00193 G_CALLBACK(on_ip_address_mode_update), NULL);
00194
00195 widget = proxyOnOff->details->selection;
00196 g_signal_connect(G_OBJECT(widget), "selection-update",
00197 G_CALLBACK(on_proxy_onoff_update), NULL);
00198
00199 widget = profileName->details->entry;
00200 g_signal_connect_after(G_OBJECT(widget), "changed-stable",
00201 G_CALLBACK(on_profilename_changed), NULL);
00202
00203 widget = buttons->details->selection;
00204 g_signal_connect(G_OBJECT(widget), "selection-update",
00205 G_CALLBACK(on_buttons_update), NULL);
00206
00207
00208 gtk_widget_show(item);
00209 gtk_widget_show(vbox);
00210 gtk_widget_show(profileEntry->background);
00211 gtk_widget_show(ipAddressMode->background);
00212 gtk_widget_show(proxyOnOff->background);
00213 gtk_widget_show(profileName->background);
00214 gtk_widget_hide(profileName->details->button);
00215 gtk_widget_grab_focus(profileName->details->entry);
00216 gtk_widget_show(buttons->background);
00217 gtk_widget_show(info);
00218
00219
00220 g_overview = item;
00221 g_profile_entry = profileEntry;
00222 g_address = ipAddressMode;
00223 g_proxy = proxyOnOff;
00224 g_profilename = profileName;
00225 g_buttons = buttons;
00226 g_info = info;
00227
00228 CN_LOGPRINTF("done");
00229
00230
00231 return item;
00232 }
00233
00235
00237 void edit_overview_set_text(void)
00238 {
00239 CN_LOGPRINTF("entry");
00240
00241 GtkWidget *widget;
00242
00243 if (g_overview)
00244 {
00245 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_overview),
00246 _("Network profile"));
00247 }
00248
00249 if (g_address)
00250 {
00251 widget = g_address->details->label;
00252 gtk_label_set_text(GTK_LABEL(widget),
00253 _("Select how your iLiad gets a network address."));
00254
00255 widget = GTK_WIDGET(g_address->details->buttonList[0]);
00256 gtk_button_set_label(GTK_BUTTON(widget), _("Automatic"));
00257
00258 widget = GTK_WIDGET(g_address->details->buttonList[1]);
00259 gtk_button_set_label(GTK_BUTTON(widget), _("Static"));
00260 }
00261
00262 if (g_proxy)
00263 {
00264 widget = g_proxy->details->label;
00265 gtk_label_set_text(GTK_LABEL(widget),
00266 _("Select if there is a proxy server present."));
00267
00268 widget = GTK_WIDGET(g_proxy->details->buttonList[0]);
00269 gtk_button_set_label(GTK_BUTTON(widget), _("No proxy"));
00270
00271 widget = GTK_WIDGET(g_proxy->details->buttonList[1]);
00272 gtk_button_set_label(GTK_BUTTON(widget), _("Proxy"));
00273 }
00274
00275 if (g_profilename)
00276 {
00277 widget = g_profilename->details->label;
00278 gtk_label_set_text(GTK_LABEL(widget),
00279 _("You can personalize the profile name."));
00280 }
00281
00282 if (g_buttons)
00283 {
00284 widget = g_buttons->details->label;
00285 gtk_label_set_text(GTK_LABEL(widget),
00286 _("Select an action for this profile."));
00287
00288 widget = GTK_WIDGET(g_buttons->details->buttonList[0]);
00289 gtk_button_set_label(GTK_BUTTON(widget), _("Test"));
00290
00291 widget = GTK_WIDGET(g_buttons->details->buttonList[1]);
00292 gtk_button_set_label(GTK_BUTTON(widget), _("Save"));
00293
00294 widget = GTK_WIDGET(g_buttons->details->buttonList[2]);
00295 gtk_button_set_label(GTK_BUTTON(widget), _("Save & Connect"));
00296 }
00297
00298 edit_overview_update_info_text(inputDetails_e);
00299 }
00300
00301 void edit_overview_update_info_text(overviewStatus_t status)
00302 {
00303 CN_LOGPRINTF("entry");
00304
00305 g_return_if_fail(g_info != NULL);
00306
00307 switch (status)
00308 {
00309 case inputDetails_e:
00310 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00311 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00312 _("A wireless or dial-up network requires "
00313 "specific settings.\n"
00314 "Hint: You can fill in the details "
00315 "for them by clicking the profile entry."));
00316 break;
00317 case inputAddress_e:
00318 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00319 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00320 _("An automatic network address requires a DHCP server "
00321 "to be present "
00322 "in your network. A static network address requires "
00323 "specific settings.\n"
00324 "Hint: If you are not sure, select 'Automatic' "
00325 "and 'No proxy'."));
00326 break;
00327 case inputProxy_e:
00328 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00329 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00330 _("A proxy server regulates internet traffic "
00331 "and is usually installed "
00332 "in company networks, "
00333 "this requires additional settings.\n"
00334 "Hint: If you are not sure, select 'No proxy'."));
00335 break;
00336 case inputProfileName_e:
00337 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00338 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00339 _("If you personalize the profile name, "
00340 "it will be easy to recognize "
00341 "in the iLiad's network profile list."));
00342 break;
00343 case toSaveConnect_e:
00344 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00345 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00346 _("The profile has been saved. "
00347 "The iLiad is trying to connect to the server."));
00348 break;
00349 case toSave_e:
00350 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00351 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00352 _("The profile will be saved."));
00353 break;
00354 case testing_e:
00355 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00356 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00357 _("The iLiad is testing your network profile "
00358 "and is trying to make a connection to the server."));
00359 break;
00360 case testAborting_e:
00361 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00362 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00363 _("The iLiad is aborting the test."));
00364 break;
00365 case testAborted_e:
00366 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00367 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00368 _("The test has been aborted."));
00369 break;
00370 case testSucceeded_e:
00371 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconOk_e);
00372 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00373 _("Connection to the server "
00374 "has been established correctly.\n"
00375 "Press the 'Save & Connect' button "
00376 "to create a connection."));
00377 break;
00378 case testFailed_e:
00379 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconFailed_e);
00380 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00381 _("Connection to the server "
00382 "can not be established correctly."));
00383 break;
00384 case connecting_e:
00385 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00386 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00387 _("The iLiad is trying to connect to the server."));
00388 break;
00389 case connectAborting_e:
00390 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00391 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00392 _("The iLiad is aborting the connection."));
00393 break;
00394 case connectAborted_e:
00395 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00396 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00397 _("The connection has been aborted."));
00398 break;
00399 case connectSucceeded_e:
00400 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconOk_e);
00401 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00402 _("Connection to the server established."));
00403 break;
00404 case connectFailed_e:
00405 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconFailed_e);
00406 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00407 _("Connection to the server "
00408 "can not be established correctly."));
00409 break;
00410 default:
00411 break;
00412 }
00413 }
00414
00415 void edit_overview_update_profile(void)
00416 {
00417 regNetworkProfile_t *settings;
00418
00419 CN_LOGPRINTF("entry");
00420
00421 settings = edit_get_network_settings();
00422 edit_overview_set_profile(settings);
00423 erRegFreeNetworkProfile(settings);
00424 }
00425
00426
00427 void edit_overview_show_profilename(void)
00428 {
00429 connection_t networkType;
00430
00431 CN_LOGPRINTF("entry");
00432
00433 g_return_if_fail(g_profilename != NULL);
00434
00435 networkType = edit_data_get_network_type();
00436 switch (networkType)
00437 {
00438 case wireless_t:
00439 case dialup_t:
00440 gtk_widget_hide(g_profilename->background);
00441 break;
00442 case wired_t:
00443 default:
00444 gtk_widget_show(g_profilename->background);
00445 break;
00446 }
00447 }
00448
00449 void edit_overview_enable_save_button(gboolean enable)
00450 {
00451 GtkWidget *widget;
00452
00453 CN_LOGPRINTF("entry %d", enable);
00454
00455 if (g_buttons)
00456 {
00457 widget = GTK_WIDGET(g_buttons->details->buttonList[1]);
00458 gtk_widget_set_sensitive(widget, enable);
00459 }
00460 }
00461
00463
00465 void edit_overview_set_network_settings(const regNetworkProfile_t*settings)
00466 {
00467 CN_LOGPRINTF("entry");
00468
00469 g_return_if_fail(settings != NULL);
00470
00471 edit_overview_set_profile(settings);
00472 edit_overview_set_address(settings->addressMode);
00473 edit_overview_set_proxy(settings->proxy);
00474 edit_overview_set_profilename(settings->name);
00475 }
00476
00477 void edit_overview_set_profile(const regNetworkProfile_t* settings)
00478 {
00479 connection_t mode;
00480 GtkWidget *widget;
00481
00482 CN_LOGPRINTF("entry");
00483
00484 g_return_if_fail(settings != NULL);
00485
00486
00487 mode = settings->connection;
00488 switch (mode)
00489 {
00490 case wired_t:
00491
00492 if (g_address)
00493 {
00494 widget = GTK_WIDGET(g_address->details->buttonList[1]);
00495 gtk_widget_set_sensitive(widget, TRUE);
00496 }
00497 break;
00498 case wireless_t:
00499 case dialup_t:
00500
00501 if (g_address)
00502 {
00503 widget = GTK_WIDGET(g_address->details->buttonList[0]);
00504 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget),
00505 TRUE);
00506
00507 widget = GTK_WIDGET(g_address->details->buttonList[1]);
00508 gtk_widget_set_sensitive(widget, FALSE);
00509 }
00510 break;
00511 case connection_undefined_t:
00512 default:
00513 CN_ERRORPRINTF("Illegal wired mode [%d]", mode);
00514 g_assert_not_reached();
00515 }
00516
00517 bk_profile_entry_display(g_profile_entry, settings);
00518 }
00519
00520 void edit_overview_set_address(const ip_address_mode_t addressMode)
00521 {
00522 GtkWidget *widget;
00523
00524 CN_LOGPRINTF("entry");
00525
00526 g_return_if_fail(g_address != NULL);
00527
00528 switch (addressMode)
00529 {
00530 case dhcp_t:
00531 case ip_address_mode_undefined_t:
00532 widget = GTK_WIDGET(g_address->details->buttonList[0]);
00533 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
00534 break;
00535 case static_t:
00536 widget = GTK_WIDGET(g_address->details->buttonList[1]);
00537 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
00538 break;
00539 default:
00540 CN_ERRORPRINTF("Illegal dhcp mode [%d]", addressMode);
00541 g_assert_not_reached();
00542 }
00543 }
00544
00545 void edit_overview_set_proxy(const gboolean use_proxy)
00546 {
00547 GtkWidget *widget;
00548
00549 CN_LOGPRINTF("entry: use_proxy [%d]", use_proxy);
00550
00551 g_return_if_fail(g_proxy != NULL);
00552
00553 if (use_proxy == FALSE)
00554 {
00555 widget = GTK_WIDGET(g_proxy->details->buttonList[0]);
00556 }
00557 else
00558 {
00559 widget = GTK_WIDGET(g_proxy->details->buttonList[1]);
00560 }
00561
00562 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
00563 }
00564
00565 void edit_overview_set_profilename(const gchar* profilename)
00566 {
00567 GtkWidget *widget;
00568 connection_t networkType;
00569 editMode_t mode;
00570
00571 CN_LOGPRINTF("entry profilename[%s]", profilename);
00572
00573 networkType = edit_data_get_network_type();
00574 switch (networkType)
00575 {
00576 case wired_t:
00577 if (g_profilename)
00578 {
00579 widget = g_profilename->details->entry;
00580 gtk_entry_set_text(GTK_ENTRY(widget),
00581 profilename ? profilename : "");
00582 }
00583 break;
00584 case wireless_t:
00585 mode = edit_get_mode();
00586 if (mode == editModeConnectFillIn_e)
00587 {
00588 if (g_profilename)
00589 {
00590 widget = g_profilename->details->entry;
00591 gtk_entry_set_text(GTK_ENTRY(widget),
00592 profilename ? profilename : "");
00593 }
00594 }
00595 else
00596 {
00597 edit_wireless_set_profilename(profilename);
00598 }
00599 break;
00600 case dialup_t:
00601 edit_dialup_set_profilename(profilename);
00602 break;
00603 default:
00604 break;
00605 }
00606 }
00607
00608 void edit_overview_get_network_settings(regNetworkProfile_t* settings)
00609 {
00610 const gchar *profilename;
00611
00612 CN_LOGPRINTF("entry");
00613
00614 g_return_if_fail(settings != NULL);
00615
00616
00617 settings->connection = edit_data_get_network_type();
00618
00619
00620 settings->addressMode = edit_overview_get_address();
00621
00622
00623 settings->proxy = edit_overview_get_proxy();
00624
00625
00626 profilename = edit_overview_get_profilename();
00627 g_free(settings->name);
00628 settings->name = g_strdup(profilename);
00629 }
00630
00631 static ip_address_mode_t edit_overview_get_address(void)
00632 {
00633 GtkWidget *widget;
00634 erGtkSelectionGroup *item;
00635 int nsel;
00636 ip_address_mode_t mode;
00637
00638 CN_LOGPRINTF("entry");
00639
00640 g_return_val_if_fail(g_address != NULL, dhcp_t);
00641
00642 widget = g_address->details->selection;
00643 item = ERGTK_SELECTION_GROUP(widget);
00644
00645 ergtk_selection_group_get_selected_buttons(item, &nsel, 1);
00646 if (nsel == 0)
00647 {
00648 mode = dhcp_t;
00649 }
00650 else
00651 {
00652 mode = static_t;
00653 }
00654
00655 CN_LOGPRINTF("return mode=%d", mode);
00656 return mode;
00657 }
00658
00659 static gboolean edit_overview_get_proxy(void)
00660 {
00661 GtkWidget *widget;
00662 erGtkSelectionGroup *item;
00663 int nsel;
00664 gboolean useproxy;
00665
00666 CN_LOGPRINTF("entry");
00667
00668 g_return_val_if_fail(g_proxy != NULL, FALSE);
00669
00670 widget = g_proxy->details->selection;
00671 item = ERGTK_SELECTION_GROUP(widget);
00672
00673 ergtk_selection_group_get_selected_buttons(item, &nsel, 1);
00674 if (nsel == 0)
00675 {
00676 useproxy = FALSE;
00677 }
00678 else
00679 {
00680 useproxy = TRUE;
00681 }
00682
00683 CN_LOGPRINTF("return useproxy=%d", useproxy);
00684 return useproxy;
00685 }
00686
00687 static const char *edit_overview_get_profilename(void)
00688 {
00689 GtkWidget *widget;
00690 const char *profilename = NULL;
00691 connection_t networkType;
00692 editMode_t mode;
00693
00694 CN_LOGPRINTF("entry");
00695
00696 networkType = edit_data_get_network_type();
00697 switch (networkType)
00698 {
00699 case wired_t:
00700 if (g_profilename)
00701 {
00702 widget = g_profilename->details->entry;
00703 profilename = gtk_entry_get_text(GTK_ENTRY(widget));
00704 }
00705 break;
00706 case wireless_t:
00707 mode = edit_get_mode();
00708 if (mode == editModeConnectFillIn_e)
00709 {
00710 if (g_profilename)
00711 {
00712 widget = g_profilename->details->entry;
00713 profilename = gtk_entry_get_text(GTK_ENTRY(widget));
00714 }
00715 }
00716 else
00717 {
00718 profilename = edit_wireless_get_profilename();
00719 }
00720 break;
00721 case dialup_t:
00722 profilename = edit_dialup_get_profilename();
00723 break;
00724 default:
00725 break;
00726 }
00727
00728 CN_LOGPRINTF("return profilename=%s", profilename);
00729 return profilename;
00730 }
00731
00732 gboolean edit_overview_check_network_settings(void)
00733 {
00734 editMode_t mode;
00735 connection_t networkType;
00736 ip_address_mode_t address;
00737 gboolean useproxy;
00738 erGtkEntry *profilename;
00739 gboolean valid = TRUE;
00740
00741 CN_LOGPRINTF("entry");
00742
00743 networkType = edit_data_get_network_type();
00744 address = edit_overview_get_address();
00745 useproxy = edit_overview_get_proxy();
00746 profilename = ERGTK_ENTRY(g_profilename->details->entry);
00747
00748 switch (networkType)
00749 {
00750 case wired_t:
00751 if ((address < 0) || (address >= ip_address_mode_undefined_t)
00752 || (!ergtk_entry_check_field(profilename)))
00753 {
00754 valid = FALSE;
00755 }
00756 break;
00757 case wireless_t:
00758 mode = edit_get_mode();
00759 if (mode == editModeConnectFillIn_e)
00760 {
00761 valid = edit_wireless_ext_check_network_settings();
00762 }
00763 else
00764 {
00765 valid = edit_wireless_check_network_settings();
00766 }
00767 break;
00768 case dialup_t:
00769 valid = edit_dialup_check_network_settings();
00770 break;
00771 default:
00772 CN_ERRORPRINTF("unknown networkType[%d]", networkType);
00773 g_assert_not_reached();
00774 break;
00775 }
00776 g_return_val_if_fail(valid == TRUE, valid);
00777
00778
00779 if (address == static_t)
00780 {
00781 valid = edit_static_check_network_settings();
00782 }
00783 g_return_val_if_fail(valid == TRUE, valid);
00784
00785
00786 if (useproxy)
00787 {
00788 valid = edit_proxy_check_network_settings();
00789 }
00790 g_return_val_if_fail(valid == TRUE, valid);
00791
00792 return valid;
00793 }
00794
00796
00798 static gboolean on_button_press(GtkWidget* button,
00799 GdkEventButton* event,
00800 gpointer data)
00801 {
00802 overviewStatus_t status = (overviewStatus_t)data;
00803
00804 CN_LOGPRINTF("entry");
00805
00806 edit_overview_update_info_text(status);
00807
00808 display_update_request_screen_refresh (STATUS_ITEM_CHANGE,
00809 WAVEFORM_TYPING);
00810
00811 return FALSE;
00812 }
00813
00814 static gboolean on_profile_entry_button_press(GtkWidget *widget,
00815 GdkEventButton *event,
00816 gpointer data)
00817 {
00818 CN_LOGPRINTF("entry");
00819
00820 GtkToggleButton *button;
00821 gboolean active;
00822 connection_t networktype;
00823 editMode_t mode;
00824
00825 button = GTK_TOGGLE_BUTTON(widget);
00826 active = gtk_toggle_button_get_active(button);
00827 if (!active)
00828 {
00829 if (!edit_get_in_set_network_settings())
00830 {
00831 erbusy_blink();
00832
00833 networktype = edit_data_get_network_type();
00834 switch (networktype)
00835 {
00836 case wired_t:
00837
00838 break;
00839 case wireless_t:
00840 edit_set_back_overview(TRUE);
00841
00842 mode = edit_get_mode();
00843 if (mode == editModeConnectFillIn_e)
00844 {
00845 g_timeout_add(500,
00846 on_delayed_edit_goto_page,
00847 (gpointer)(editScreenWirelessExt_e + 1));
00848
00849 }
00850 else
00851 {
00852 g_timeout_add(500,
00853 on_delayed_edit_goto_page,
00854 (gpointer)(editScreenWireless_e + 1));
00855 }
00856 break;
00857 case dialup_t:
00858 edit_set_back_overview(TRUE);
00859
00860 g_timeout_add(500,
00861 on_delayed_edit_goto_page,
00862 (gpointer)(editScreenDialup_e + 1));
00863 break;
00864 default:
00865 break;
00866 }
00867 }
00868
00869
00870 g_timeout_add(500, delayed_deactive_button, button);
00871 }
00872
00873 edit_overview_update_info_text(inputDetails_e);
00874
00875 return FALSE;
00876 }
00877
00878
00879 static gboolean on_delayed_edit_goto_page(gpointer new_page)
00880 {
00881 erbusy_blink();
00882
00883
00884 on_edit_goto_page((guint)new_page);
00885
00886
00887 return FALSE;
00888 }
00889
00890 static gboolean delayed_deactive_button(gpointer data)
00891 {
00892 GtkToggleButton *button = GTK_TOGGLE_BUTTON(data);
00893
00894 if (button)
00895 {
00896 gtk_toggle_button_set_active(button, FALSE);
00897 }
00898
00899 return FALSE;
00900 }
00901
00902 static void on_ip_address_mode_update(GtkWidget* selection,
00903 gpointer button,
00904 gpointer data)
00905 {
00906
00907 gboolean active;
00908 int nsel;
00909 erGtkSelectionGroup *sel;
00910 const char *profilename;
00911
00912 CN_LOGPRINTF("entry");
00913
00914 g_return_if_fail(g_address != NULL);
00915
00916 active = gtk_toggle_button_get_active(button);
00917 if (active)
00918 {
00919 if (!edit_get_in_set_network_settings())
00920 {
00921 sel = ERGTK_SELECTION_GROUP(selection);
00922 ergtk_selection_group_get_selected_buttons(sel, &nsel, 1);
00923 if (nsel == 1)
00924 {
00925 erbusy_blink();
00926
00927
00928
00929 profilename = edit_overview_get_profilename();
00930 edit_static_set_title(profilename);
00931
00932 g_timeout_add(500,
00933 on_delayed_edit_goto_page,
00934 (gpointer)(editScreenStatic_e + 1));
00935 }
00936 }
00937 }
00938 edit_overview_update_info_text(inputAddress_e);
00939 }
00940
00941 static void on_proxy_onoff_update(GtkWidget* selection,
00942 gpointer button,
00943 gpointer data)
00944 {
00945
00946 gboolean active;
00947 int nsel;
00948 erGtkSelectionGroup *sel;
00949 const char* profilename;
00950
00951 CN_LOGPRINTF("entry");
00952
00953 g_return_if_fail(g_proxy != NULL);
00954
00955 active = gtk_toggle_button_get_active(button);
00956 if (active)
00957 {
00958 if (!edit_get_in_set_network_settings())
00959 {
00960 sel = ERGTK_SELECTION_GROUP(selection);
00961 ergtk_selection_group_get_selected_buttons(sel, &nsel, 1);
00962 if (nsel == 1)
00963 {
00964 erbusy_blink();
00965
00966
00967
00968 profilename = edit_overview_get_profilename();
00969 edit_proxy_set_title(profilename);
00970
00971 g_timeout_add(500,
00972 on_delayed_edit_goto_page,
00973 (gpointer)(editScreenProxy_e + 1));
00974 }
00975 }
00976 }
00977
00978 edit_overview_update_info_text(inputProxy_e);
00979 }
00980
00981 static void on_profilename_changed(GtkEntry* widget, gpointer data)
00982 {
00983 CN_LOGPRINTF("entry");
00984
00985 if (!edit_get_in_set_network_settings())
00986 {
00987
00988 edit_overview_update_profile();
00989
00990
00991 edit_overview_update_info_text(inputProfileName_e);
00992 }
00993 }
00994
00995 static void on_buttons_update(GtkWidget* selection, gpointer button, gpointer data)
00996 {
00997 gboolean active;
00998 gboolean valid;
00999 int nsel;
01000 erGtkSelectionGroup *widget;
01001 gboolean toDeactive = TRUE;
01002
01003 CN_LOGPRINTF("entry");
01004
01005 active = gtk_toggle_button_get_active(button);
01006 valid = edit_overview_check_network_settings();
01007 if (active && valid)
01008 {
01009 widget = ERGTK_SELECTION_GROUP(g_buttons->details->selection);
01010 ergtk_selection_group_get_selected_buttons(widget, &nsel, 1);
01011 switch (nsel)
01012 {
01013 case 0:
01014
01015 on_test();
01016 toDeactive = FALSE;
01017 break;
01018 case 1:
01019
01020 on_save();
01021 toDeactive = FALSE;
01022 break;
01023 case 2:
01024
01025 on_saveconnect();
01026 toDeactive = FALSE;
01027 break;
01028 default:
01029 break;
01030 }
01031 }
01032
01033 if (active && toDeactive)
01034 {
01035 g_timeout_add(500, delayed_deactive_button, button);
01036 }
01037 }
01038
01039
01040 static void on_test(void)
01041 {
01042 pingContext_t *ctxt;
01043
01044 CN_LOGPRINTF("entry");
01045
01046 edit_overview_freeze_ui(TRUE);
01047
01048 edit_overview_restore_ping_ctxt(TRUE);
01049
01050 ctxt = cmgr_get_ping_ctxt();
01051 connect_ping_select_initial_profile(ctxt);
01052 connect_ping(ctxt, TRUE);
01053 }
01054
01055 static gboolean on_delayed_save(gpointer data)
01056 {
01057 GtkToggleButton *button;
01058
01059 erbusy_blink();
01060
01061 edit_save_profile();
01062
01063 edit_goto_page(editScreenProfiles_e);
01064
01065
01066 if (g_buttons)
01067 {
01068 button = g_buttons->details->buttonList[1];
01069 gtk_toggle_button_set_active(button, FALSE);
01070 }
01071
01072 return FALSE;
01073 }
01074
01075
01076 static void on_save(void)
01077 {
01078 CN_LOGPRINTF("entry");
01079
01080 edit_overview_update_info_text(toSave_e);
01081
01082 g_timeout_add(500, on_delayed_save, NULL);
01083 }
01084
01085 static gboolean on_delayed_saveconnect(gpointer data)
01086 {
01087 pingContext_t *ctxt;
01088
01089 erbusy_blink();
01090
01091 edit_overview_freeze_ui(TRUE);
01092
01093 edit_overview_restore_ping_ctxt(FALSE);
01094
01095 ctxt = cmgr_get_ping_ctxt();
01096 connect_ping_select_initial_profile(ctxt);
01097 connect_ping(ctxt, TRUE);
01098
01099 return FALSE;
01100 }
01101
01102
01103 static void on_saveconnect(void)
01104 {
01105 CN_LOGPRINTF("entry");
01106
01107 edit_overview_update_info_text(toSaveConnect_e);
01108
01109 g_timeout_add(500, on_delayed_saveconnect, NULL);
01110 }
01111
01112 void edit_overview_click_test(void)
01113 {
01114 GtkWidget *widget;
01115
01116 CN_LOGPRINTF("entry");
01117
01118 if (g_buttons)
01119 {
01120 widget = GTK_WIDGET(g_buttons->details->buttonList[0]);
01121 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
01122 }
01123 }
01124
01125 void edit_overview_click_save(void)
01126 {
01127 GtkWidget *widget;
01128
01129 CN_LOGPRINTF("entry");
01130
01131 if (g_buttons)
01132 {
01133 widget = GTK_WIDGET(g_buttons->details->buttonList[1]);
01134 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
01135 }
01136 }
01137
01138 void edit_overview_click_saveconnect(void)
01139 {
01140 GtkWidget *widget;
01141
01142 CN_LOGPRINTF("entry");
01143
01144 if (g_buttons)
01145 {
01146 widget = GTK_WIDGET(g_buttons->details->buttonList[2]);
01147 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
01148 }
01149 }
01150
01152
01154 static void edit_overview_restore_ping_ctxt(gboolean toTest)
01155 {
01156 pingContext_t *ctxt;
01157 cmgrConnectType_t connectType;
01158
01159 CN_LOGPRINTF("entry");
01160
01161 ctxt = cmgr_get_ping_ctxt();
01162
01163 if (ctxt)
01164 {
01165
01166 connect_ping_ctxt_set_mode(ctxt, editPing_e);
01167 connectType = connect_data_get_connect_type();
01168 connect_ping_ctxt_set_connect_type(ctxt, connectType);
01169
01170
01171 if (toTest)
01172 {
01173 connect_ping_ctxt_set_done_callbacks(ctxt,
01174 on_test_connected, on_test_failed);
01175 }
01176 else
01177 {
01178 connect_ping_ctxt_set_done_callbacks(ctxt,
01179 on_connected, on_failed);
01180 }
01181
01182
01183 connect_ping_ctxt_set_get_initial_profile(ctxt,
01184 edit_get_initial_profile);
01185 connect_ping_ctxt_set_access_network_profiles_callbacks(ctxt,
01186 edit_get_n_network_profiles,
01187 edit_get_network_profile,
01188 edit_select_next_regprofile);
01189
01190
01191 if (toTest)
01192 {
01193 connect_ping_ctxt_set_ui_callbacks(ctxt,
01194 ui_test_update_status,
01195 ui_display_settings,
01196 ui_select_profile,
01197 ui_unselect_all_profile);
01198
01199 }
01200 else
01201 {
01202 connect_ping_ctxt_set_ui_callbacks(ctxt,
01203 ui_update_status,
01204 ui_display_settings,
01205 ui_select_profile,
01206 ui_unselect_all_profile);
01207 }
01208 }
01209 }
01210
01211 static void deactive_button(void)
01212 {
01213 erGtkSelectionGroup *item;
01214 int nsel;
01215 GtkToggleButton *button;
01216
01217
01218 if (g_buttons)
01219 {
01220 item = ERGTK_SELECTION_GROUP(g_buttons->details->selection);
01221 ergtk_selection_group_get_selected_buttons(item, &nsel, 1);
01222 if ((nsel >= 0) && (nsel <= 2))
01223 {
01224 button = g_buttons->details->buttonList[nsel];
01225 g_timeout_add(500, delayed_deactive_button, button);
01226 }
01227 }
01228 }
01229
01230 static void on_test_connected(int profileIndex)
01231 {
01232 CN_LOGPRINTF("entry");
01233
01234 edit_overview_freeze_ui(FALSE);
01235
01236 deactive_button();
01237 }
01238
01239 static void on_test_failed(void)
01240 {
01241 CN_LOGPRINTF("entry");
01242
01243 edit_overview_freeze_ui(FALSE);
01244
01245 deactive_button();
01246 }
01247
01248 static void on_connected(int profileIndex)
01249 {
01250 CN_LOGPRINTF("entry");
01251
01252 edit_save_profile();
01253
01254 edit_overview_freeze_ui(FALSE);
01255
01256 deactive_button();
01257
01258 edit_on_connected();
01259 }
01260
01261 static void on_failed(void)
01262 {
01263 CN_LOGPRINTF("entry");
01264
01265 edit_overview_freeze_ui(FALSE);
01266
01267 deactive_button();
01268 }
01269
01270 static void ui_test_update_status(int profileIndex, pingStatus_t status)
01271 {
01272 overviewStatus_t state;
01273
01274 CN_LOGPRINTF("entry");
01275
01276 bk_profile_entry_update_status(g_profile_entry, status);
01277
01278 switch (status)
01279 {
01280 case pingSucceeded_e:
01281 state = testSucceeded_e;
01282 break;
01283 case pingFailed_e:
01284 case pingFailedPCShare_e:
01285 case pingFailedNetwork_e:
01286 state = testFailed_e;
01287 break;
01288 case pingConnecting_e:
01289 state = testing_e;
01290 break;
01291 case pingAborting_e:
01292 state = testAborting_e;
01293 break;
01294 case pingAborted_e:
01295 state = testAborted_e;
01296 on_failed();
01297 break;
01298 default:
01299 state = undefinedStatus_e;
01300 break;
01301 }
01302
01303 edit_overview_update_info_text(state);
01304
01305 display_update_request_screen_refresh (STATUS_ITEM_CHANGE,
01306 WAVEFORM_TYPING);
01307 }
01308
01309 static void ui_update_status(int profileIndex, pingStatus_t status)
01310 {
01311 overviewStatus_t state;
01312
01313 CN_LOGPRINTF("entry");
01314
01315 bk_profile_entry_update_status(g_profile_entry, status);
01316
01317 switch (status)
01318 {
01319 case pingSucceeded_e:
01320 state = connectSucceeded_e;
01321 break;
01322 case pingFailed_e:
01323 case pingFailedPCShare_e:
01324 case pingFailedNetwork_e:
01325 state = connectFailed_e;
01326 break;
01327 case pingConnecting_e:
01328 state = connecting_e;
01329 break;
01330 case pingAborting_e:
01331 state = connectAborting_e;
01332 break;
01333 case pingAborted_e:
01334 state = connectAborted_e;
01335 on_failed();
01336 break;
01337 default:
01338 state = undefinedStatus_e;
01339 break;
01340 }
01341
01342 edit_overview_update_info_text(state);
01343
01344 display_update_request_screen_refresh (STATUS_ITEM_CHANGE,
01345 WAVEFORM_TYPING);
01346 }
01347
01348 static void ui_display_settings(int profileIndex, gboolean resetStatus)
01349 {
01350 CN_LOGPRINTF("entry");
01351
01352 }
01353
01354 static void ui_select_profile(int profileIndex)
01355 {
01356 GtkProfileEntry *profileEntry;
01357
01358 CN_LOGPRINTF("entry");
01359
01360 if (g_profile_entry)
01361 {
01362 profileEntry = GTK_PROFILE_ENTRY(g_profile_entry->details);
01363 gtk_profile_entry_set_buttons_active(profileEntry, TRUE, FALSE);
01364
01365 display_update_request_screen_refresh (STATUS_ITEM_CHANGE,
01366 WAVEFORM_TYPING);
01367 }
01368 }
01369
01370 static void ui_unselect_all_profile(void)
01371 {
01372 GtkProfileEntry *profileEntry;
01373
01374 CN_LOGPRINTF("entry");
01375
01376 if (g_profile_entry)
01377 {
01378 profileEntry = GTK_PROFILE_ENTRY(g_profile_entry->details);
01379 gtk_profile_entry_set_buttons_active(profileEntry, FALSE, FALSE);
01380
01381 display_update_request_screen_refresh(STATUS_ITEM_CHANGE,
01382 WAVEFORM_TYPING);
01383 }
01384 }
01385
01387
01389
01390 gboolean on_edit_overview_keypress(GdkEventKey *event)
01391 {
01392 pingContext_t *ctxt;
01393 gboolean ret = FALSE;
01394
01395 CN_LOGPRINTF("entry");
01396
01397 ctxt = cmgr_get_ping_ctxt();
01398
01399 switch (event->keyval)
01400 {
01401 case GDK_Return:
01402
01403 if (!connect_ping_in_pinging(ctxt))
01404 {
01405
01406 edit_overview_click_saveconnect();
01407 ret = TRUE;
01408 }
01409 break;
01410
01411 case GDK_F5:
01412
01413
01414 connect_ping_abort(ctxt);
01415 cmgr_up_page();
01416 ret = TRUE;
01417 break;
01418
01419 default:
01420 erbusy_off();
01421 }
01422
01423 return ret;
01424 }
01425
01427
01429
01430
01431
01432
01433
01434
01435
01436 static void edit_overview_freeze_ui(gboolean freeze)
01437 {
01438 GtkProfileEntry *item;
01439 editMode_t mode;
01440 connection_t networkType;
01441 gboolean sensitive;
01442 GtkWidget *widget;
01443
01444 CN_LOGPRINTF("entry[%d]", freeze);
01445
01446 sensitive = !freeze;
01447
01448
01449 item = GTK_PROFILE_ENTRY(g_profile_entry->details);
01450 widget = gtk_profile_entry_get_namebutton(item);
01451 gtk_widget_set_sensitive(widget, sensitive);
01452
01453
01454 widget = GTK_WIDGET(g_address->details->buttonList[0]);
01455 gtk_widget_set_sensitive(widget, sensitive);
01456
01457 widget = GTK_WIDGET(g_address->details->buttonList[1]);
01458 gtk_widget_set_sensitive(widget, sensitive);
01459
01460
01461 widget = GTK_WIDGET(g_proxy->details->buttonList[0]);
01462 gtk_widget_set_sensitive(widget, sensitive);
01463
01464 widget = GTK_WIDGET(g_proxy->details->buttonList[1]);
01465 gtk_widget_set_sensitive(widget, sensitive);
01466
01467
01468 widget = g_profilename->details->entry;
01469 gtk_widget_set_sensitive(widget, sensitive);
01470
01471
01472 widget = GTK_WIDGET(g_buttons->details->buttonList[0]);
01473 gtk_widget_set_sensitive(widget, sensitive);
01474
01475 widget = GTK_WIDGET(g_buttons->details->buttonList[1]);
01476 gtk_widget_set_sensitive(widget, sensitive);
01477
01478 widget = GTK_WIDGET(g_buttons->details->buttonList[2]);
01479 gtk_widget_set_sensitive(widget, sensitive);
01480
01481 if (sensitive)
01482 {
01483
01484
01485 networkType = edit_data_get_network_type();
01486 if ((networkType == wireless_t)
01487 || (networkType == dialup_t))
01488 {
01489 widget = GTK_WIDGET(g_address->details->buttonList[1]);
01490 gtk_widget_set_sensitive(widget, FALSE);
01491 }
01492
01493
01494 mode = edit_get_mode();
01495 if ((mode == editModeConnectFillIn_e)
01496 || (mode == editModeConnectCreate_e)
01497 || (mode == editModeConnectNormal_e))
01498 {
01499 edit_overview_enable_save_button(FALSE);
01500 }
01501 }
01502 }
01503