00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "config.h"
00029 #include <string.h>
00030 #include <gtk/gtk.h>
00031
00032 #include <liberdm/connectionMgrConstants.h>
00033 #include <liberdm/display.h>
00034 #include <liberregxml/erregapi.h>
00035 #include <libergtk/ergtk.h>
00036
00037 #include "connectionMgrLog.h"
00038 #include "displayStatus.h"
00039 #include "erbusy.h"
00040 #include "background.h"
00041 #include "connectionMgr.h"
00042 #include "gtkSettingItem.h"
00043 #include "gtkInfoItem.h"
00044 #include "gtkProfileEntry.h"
00045 #include "widgetUtils.h"
00046 #include "connectScreen.h"
00047 #include "connectScreenData.h"
00048 #include "editScreen.h"
00049 #include "editScreenOverview.h"
00050 #include "editScreenWireless.h"
00051 #include "editScreenWirelessExt.h"
00052 #include "commonData.h"
00053 #include "connectPing.h"
00054 #include "connectBackground.h"
00055 #include "languages.h"
00056
00057 typedef enum
00058 {
00059 inputEncrKey_e = 0,
00060 wrongEncrKey_e,
00061 advancedSettings_e,
00062 pcshareSettings_e,
00063 wlanExtConnecting_e,
00064 wlanExtConnected_e,
00065 wlanExtAborting_e,
00066 wlanExtAborted_e,
00067 undefWlanExtStatus_e
00068 }wlanExtStatus_t;
00069
00070 static GtkWidget *g_wireless_ext = NULL;
00071
00072 static bkProfileEntry *g_profile_entry = NULL;
00073
00074 static GtkWidget *g_ssid_name = NULL;
00075 static GtkWidget *g_ssid_value = NULL;
00076 static GtkWidget *g_encrtype_name = NULL;
00077 static GtkWidget *g_encrtype_value = NULL;
00078 static wdtLabelEntry *g_encrkey = NULL;
00079
00080 static bkWdtLabelButton *g_advanced = NULL;
00081
00082 static GtkWidget *g_info = NULL;
00083
00084 static char *g_old_encrkey = NULL;
00085
00086 static GtkWidget *create_encrypt(void);
00087
00088 static void edit_wireless_ext_update_status(pingStatus_t status);
00089
00090 static void edit_wireless_ext_set_profile(const regNetworkProfile_t *settings);
00091 static void edit_wireless_ext_set_ssid(const char* ssid);
00092 static void edit_wireless_ext_set_encrtype(wireless_encr_type_t encrtype);
00093 static void edit_wireless_ext_set_encrkey(const char* encrkey);
00094
00095 static const char* edit_wireless_ext_get_ssid(void);
00096 static wireless_encr_type_t edit_wireless_ext_get_encrtype(void);
00097 static const char* edit_wireless_ext_get_encrkey(void);
00098
00099 static void edit_wireless_ext_backup_network_settings(void);
00100
00101 static void on_connect(GtkToggleButton *button, gpointer data);
00102 static void on_advanced(GtkToggleButton *button, gpointer data);
00103
00104 static gboolean delayed_deactive_button(gpointer data);
00105
00106 static void edit_wireless_ext_restore_ping_ctxt(void);
00107 static void on_connected(int profileIndex);
00108 static void on_failed(void);
00109 static void ui_update_status(int profileIndex, pingStatus_t status);
00110 static void ui_display_settings(int profileIndex, gboolean resetStatus);
00111 static void ui_select_profile(int profileIndex);
00112 static void ui_unselect_all_profile(void);
00113
00114 static void edit_wireless_ext_freeze_ui(gboolean freeze);
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 GtkWidget *edit_wireless_ext_create(void)
00125 {
00126 GtkWidget *item;
00127 GtkWidget *vbox;
00128 bkProfileEntry *profileEntry;
00129 GtkWidget *encrypt;
00130 bkWdtLabelButton *advanced;
00131 GtkWidget *info;
00132 GtkWidget *widget;
00133
00134 CN_LOGPRINTF("entry");
00135
00136
00137 item = gtk_settingitem_new("");
00138
00139
00140 vbox =gtk_vbox_new(FALSE, VBOX_SPACING);
00141 gtk_settingitem_add_details(GTK_SETTINGITEM(item), vbox);
00142
00143
00144 profileEntry = bk_profile_entry_new();
00145 gtk_box_pack_start(GTK_BOX(vbox), profileEntry->background,
00146 FALSE, FALSE, 0);
00147
00148
00149 encrypt = create_encrypt();
00150 gtk_box_pack_start(GTK_BOX(vbox), encrypt, FALSE, FALSE, 0);
00151
00152
00153 advanced = bk_wdt_label_button_new(1, FALSE, 0, 1);
00154 gtk_box_pack_start(GTK_BOX(vbox), advanced->background,
00155 FALSE, FALSE, 0);
00156
00157
00158 info = gtk_infoitem_new(FALSE);
00159 gtk_box_pack_start(GTK_BOX(vbox), info, FALSE, FALSE, 0);
00160
00161
00162 widget = GTK_WIDGET(advanced->details->buttonList[0]);
00163 g_signal_connect_after(G_OBJECT(widget), "toggled",
00164 G_CALLBACK(on_advanced), NULL);
00165
00166
00167 gtk_widget_show(item);
00168 gtk_widget_show(vbox);
00169 gtk_widget_show(profileEntry->background);
00170 gtk_widget_show(encrypt);
00171 gtk_widget_show(advanced->background);
00172 gtk_widget_show(info);
00173
00174
00175 g_wireless_ext = item;
00176 g_profile_entry = profileEntry;
00177 g_advanced = advanced;
00178 g_info = info;
00179
00180
00181 return item;
00182 }
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 static GtkWidget *create_encrypt(void)
00196 {
00197 GtkWidget *background;
00198 GtkWidget *alignment;
00199 GtkWidget *vbox;
00200 GtkWidget *subvbox;
00201 GtkWidget *hbox;
00202 GtkWidget *ssidName;
00203 GtkWidget *ssidValue;
00204 GtkWidget *encrtypeName;
00205 GtkWidget *encrtypeValue;
00206 wdtLabelEntry *encrkey;
00207 GtkWidget *widget;
00208
00209 CN_LOGPRINTF("entry");
00210
00211
00212 background = gtk_event_box_new();
00213 gtk_widget_set_name(background, "bk_grey_666_168");
00214 gtk_widget_set_size_request(background,
00215 BK_666_168_WIDTH, BK_666_168_HEIGHT);
00216
00217
00218 alignment = gtk_alignment_new(0.0, 0.0, 0.0, 0.0);
00219 gtk_alignment_set_padding(GTK_ALIGNMENT(alignment),
00220 PADDING_TOP * 2,
00221 PADDING_BOTTOM * 2,
00222 PADDING_LEFT,
00223 PADDING_RIGHT);
00224 gtk_container_add(GTK_CONTAINER(background), alignment);
00225
00226
00227 vbox = gtk_vbox_new(FALSE, VBOX_SPACING * 3);
00228 gtk_container_add(GTK_CONTAINER(alignment), vbox);
00229
00230
00231 subvbox = gtk_vbox_new(FALSE, VBOX_SPACING);
00232 gtk_box_pack_start(GTK_BOX(vbox), subvbox, FALSE, FALSE, 0);
00233
00234
00235 hbox = gtk_hbox_new(FALSE, HBOX_SPACING);
00236 gtk_box_pack_start(GTK_BOX(subvbox), hbox, FALSE, FALSE, 0);
00237
00238
00239 ssidName = gtk_label_new("");
00240 gtk_widget_set_name(ssidName, "info_label");
00241 gtk_box_pack_start(GTK_BOX(hbox), ssidName, FALSE, FALSE, 0);
00242
00243
00244 ssidValue = gtk_label_new("");
00245 gtk_widget_set_name(ssidValue, "info_label");
00246 gtk_box_pack_start(GTK_BOX(hbox), ssidValue, FALSE, FALSE, 0);
00247
00248
00249 hbox = gtk_hbox_new(FALSE, HBOX_SPACING);
00250 gtk_box_pack_start(GTK_BOX(subvbox), hbox, FALSE, FALSE, 0);
00251
00252
00253 encrtypeName = gtk_label_new("");
00254 gtk_widget_set_name(encrtypeName, "info_label");
00255 gtk_box_pack_start(GTK_BOX(hbox), encrtypeName, FALSE, FALSE, 0);
00256
00257
00258 encrtypeValue = gtk_label_new("");
00259 gtk_widget_set_name(encrtypeValue, "info_label");
00260 gtk_box_pack_start(GTK_BOX(hbox), encrtypeValue, FALSE, FALSE, 0);
00261
00262
00263 encrkey = wdt_label_entry_new(string_e);
00264 gtk_entry_set_visibility(GTK_ENTRY(encrkey->entry), FALSE);
00265 gtk_box_pack_start(GTK_BOX(vbox), encrkey->parent, FALSE, FALSE, 0);
00266
00267
00268 widget = encrkey->button;
00269 g_signal_connect_after(G_OBJECT(widget), "toggled",
00270 G_CALLBACK(on_connect), NULL);
00271
00272
00273 gtk_widget_show(alignment);
00274 gtk_widget_show(vbox);
00275 gtk_widget_show_all(subvbox);
00276 gtk_widget_show(encrkey->parent);
00277 gtk_widget_grab_focus(encrkey->entry);
00278
00279
00280 g_ssid_name = ssidName;
00281 g_ssid_value = ssidValue;
00282 g_encrtype_name = encrtypeName;
00283 g_encrtype_value = encrtypeValue;
00284 g_encrkey = encrkey;
00285
00286
00287 return background;
00288 }
00289
00290 static void edit_wireless_ext_show_widgets(wlanExtStatus_t mode)
00291 {
00292 CN_LOGPRINTF("entry mode[%d]", mode);
00293
00294 g_return_if_fail(g_advanced != NULL);
00295
00296 switch (mode)
00297 {
00298 case advancedSettings_e:
00299 gtk_widget_show(g_advanced->background);
00300 break;
00301 default:
00302 gtk_widget_hide(g_advanced->background);
00303 break;
00304 }
00305 }
00306
00307 void edit_wireless_ext_set_text(void)
00308 {
00309 GtkWidget *widget;
00310
00311 CN_LOGPRINTF("entry");
00312
00313 if (g_wireless_ext)
00314 {
00315 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_wireless_ext),
00316 _("Network profile"));
00317 }
00318
00319 if (g_ssid_name)
00320 {
00321 gtk_label_set_text(GTK_LABEL(g_ssid_name), _("Network name (SSID):"));
00322 }
00323
00324 if (g_encrtype_name)
00325 {
00326 gtk_label_set_text(GTK_LABEL(g_encrtype_name), _("Security type:"));
00327 }
00328
00329 if (g_encrkey)
00330 {
00331 widget = g_encrkey->label;
00332 gtk_label_set_text(GTK_LABEL(widget),
00333 _("Enter the security key / passphrase:"));
00334
00335 widget = g_encrkey->button;
00336 gtk_button_set_label(GTK_BUTTON(widget), _("Connect"));
00337 }
00338
00339 if (g_advanced)
00340 {
00341 widget = g_advanced->details->label;
00342 gtk_label_set_text(GTK_LABEL(widget),
00343 _("Click the button for advanced settings."));
00344 widget = GTK_WIDGET(g_advanced->details->buttonList[0]);
00345 gtk_button_set_label(GTK_BUTTON(widget), _("Advanced settings"));
00346 }
00347 }
00348
00349 static void edit_wireless_ext_update_info_text(wlanExtStatus_t status)
00350 {
00351 g_return_if_fail(g_info != NULL);
00352
00353 CN_LOGPRINTF("entry");
00354
00355 switch (status)
00356 {
00357 case inputEncrKey_e:
00358 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00359 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00360 _("If you do not know the security key "
00361 "for this access point. "
00362 "Please ask your network administrator."));
00363 break;
00364 case wrongEncrKey_e:
00365 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconFailed_e);
00366 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00367 _("Connection failed: Cannot connect to "
00368 "the access point.\n"
00369 "Check that the security key is correct "
00370 "and for WPA check "
00371 "that your router is set to PSK-TKIP mode. "
00372 "If you do not know the settings "
00373 "for this access point, "
00374 "please ask your network administrator."));
00375 break;
00376 case advancedSettings_e:
00377 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconFailed_e);
00378
00379 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00380 _("Connection failed: Cannot connect to the internet "
00381 "or iDS.\n"
00382 "Click on 'Advanced settings' "
00383 "to set a proxy server.\n"
00384 "Please ask your network administrator "
00385 "if you do not know the correct settings "
00386 "for this network."));
00387 break;
00388 case pcshareSettings_e:
00389 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconFailed_e);
00390 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00391 _("Connection failed: Cannot connect "
00392 "to your computer.\n"
00393 "Please check the 'Settings for Computer Connection' "
00394 "in the iLiad Settings menu."));
00395 break;
00396 case wlanExtConnecting_e:
00397 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00398 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00399 _("The iLiad is trying "
00400 "to connect to the server."));
00401 break;
00402 case wlanExtConnected_e:
00403 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconOk_e);
00404 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00405 _("Connection to the server "
00406 "has been established."));
00407 break;
00408 case wlanExtAborting_e:
00409 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00410 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00411 _("The iLiad is aborting the connection."));
00412 break;
00413 case wlanExtAborted_e:
00414 gtk_infoitem_set_icon(GTK_INFOITEM(g_info), iconInfo_e);
00415 gtk_infoitem_set_text(GTK_INFOITEM(g_info),
00416 _("The connection has been aborted."));
00417 break;
00418 default:
00419 break;
00420 }
00421 }
00422
00423 void edit_wireless_ext_update_status(pingStatus_t status)
00424 {
00425 CN_LOGPRINTF("entry");
00426
00427 bk_profile_entry_update_status(g_profile_entry, status);
00428 }
00429
00430 void edit_wireless_ext_set_network_settings(const regNetworkProfile_t *settings)
00431 {
00432 const char *ssid = NULL;
00433 wireless_encr_type_t encrtype = encr_undefined_t;
00434 const char *encrkey = NULL;
00435 regWirelessSetting_t *wirelessSettings = NULL;
00436
00437 CN_LOGPRINTF("entry");
00438
00439 g_return_if_fail(settings != NULL);
00440 g_return_if_fail(settings->connection == wireless_t);
00441
00442 wirelessSettings = settings->wirelessSettings;
00443 if (wirelessSettings)
00444 {
00445 ssid = wirelessSettings->SSID;
00446 encrtype = wirelessSettings->encrType;
00447 encrkey = wirelessSettings->encrKey;
00448 }
00449
00450 edit_wireless_ext_set_profile(settings);
00451 edit_wireless_ext_set_ssid(ssid);
00452 edit_wireless_ext_set_encrtype(encrtype);
00453 edit_wireless_ext_set_encrkey(encrkey);
00454
00455 edit_wireless_ext_show_widgets(inputEncrKey_e);
00456 edit_wireless_ext_update_info_text(inputEncrKey_e);
00457
00458 edit_wireless_ext_backup_network_settings();
00459 }
00460
00461 static void edit_wireless_ext_set_profile(const regNetworkProfile_t *settings)
00462 {
00463 CN_LOGPRINTF("entry");
00464
00465 bk_profile_entry_display(g_profile_entry, settings);
00466 }
00467
00468 static void edit_wireless_ext_set_ssid(const char *ssid)
00469 {
00470 CN_LOGPRINTF("entry");
00471
00472 if (g_ssid_value)
00473 {
00474 gtk_label_set_text(GTK_LABEL(g_ssid_value), ssid ? ssid : "");
00475 }
00476 }
00477
00478 static void edit_wireless_ext_set_encrtype(wireless_encr_type_t encrtype)
00479 {
00480 char *text;
00481
00482 CN_LOGPRINTF("entry");
00483
00484 if (g_encrtype_value)
00485 {
00486 switch (encrtype)
00487 {
00488 case encr_wep_t:
00489 text = "WEP";
00490 break;
00491 case encr_wpa_t:
00492 text = "WPA";
00493 break;
00494 case encr_none_t:
00495 default:
00496 text = "NONE";
00497 break;
00498 }
00499 gtk_label_set_text(GTK_LABEL(g_encrtype_value), text);
00500 }
00501 }
00502
00503 static void edit_wireless_ext_set_encrkey(const char* encrkey)
00504 {
00505 GtkWidget *widget;
00506
00507 CN_LOGPRINTF("entry");
00508
00509 if (g_encrkey)
00510 {
00511 widget = g_encrkey->entry;
00512 gtk_entry_set_text(GTK_ENTRY(widget), encrkey);
00513 }
00514 }
00515
00516 void edit_wireless_ext_get_network_settings(regNetworkProfile_t *settings)
00517 {
00518 regWirelessSetting_t *wirelessSettings;
00519 const char *ssid = NULL;
00520 const char *encrkey = NULL;
00521
00522 CN_LOGPRINTF("entry");
00523
00524 g_return_if_fail(settings != NULL);
00525 g_return_if_fail(settings->connection == wireless_t);
00526
00527 wirelessSettings = settings->wirelessSettings;
00528
00529 ssid = edit_wireless_ext_get_ssid();
00530 encrkey = edit_wireless_ext_get_encrkey();
00531
00532 if (wirelessSettings)
00533 {
00534 g_free(wirelessSettings->SSID);
00535 g_free(wirelessSettings->encrKey);
00536 g_free(wirelessSettings);
00537 wirelessSettings = NULL;
00538 settings->wirelessSettings = NULL;
00539 }
00540
00541 if (settings->connection == wireless_t)
00542 {
00543 wirelessSettings = g_new0(regWirelessSetting_t, 1);
00544 g_assert(wirelessSettings != NULL);
00545 wirelessSettings->SSID = g_strdup(ssid);
00546 wirelessSettings->encrType = edit_wireless_ext_get_encrtype();
00547 wirelessSettings->encrKey = g_strdup(encrkey);
00548
00549 wirelessSettings->broadcast = TRUE;
00550 settings->wirelessSettings = wirelessSettings;
00551 }
00552 }
00553
00554 static const char *edit_wireless_ext_get_ssid(void)
00555 {
00556 const char *ssid = NULL;
00557
00558 CN_LOGPRINTF("entry");
00559 if (g_ssid_value)
00560 {
00561 ssid = gtk_label_get_text(GTK_LABEL(g_ssid_value));
00562 }
00563
00564 CN_LOGPRINTF("return ssid=%s", ssid);
00565 return ssid;
00566 }
00567
00568 static wireless_encr_type_t edit_wireless_ext_get_encrtype(void)
00569 {
00570 const char *value = NULL;
00571 wireless_encr_type_t encrtype = encr_undefined_t;
00572
00573 CN_LOGPRINTF("entry");
00574
00575 if (g_encrtype_value)
00576 {
00577 value = gtk_label_get_text(GTK_LABEL(g_encrtype_value));
00578 if (value)
00579 {
00580 if (strcmp(value, "NONE") == 0)
00581 {
00582 encrtype = encr_none_t;
00583 }
00584 else if (strcmp(value, "WEP") == 0)
00585 {
00586 encrtype = encr_wep_t;
00587 }
00588 else if (strcmp(value, "WPA") == 0)
00589 {
00590 encrtype = encr_wpa_t;
00591 }
00592 }
00593 }
00594
00595 CN_LOGPRINTF("return encrtype=%d", encrtype);
00596 return encrtype;
00597 }
00598
00599 static const char *edit_wireless_ext_get_encrkey(void)
00600 {
00601 const char *encrkey = NULL;
00602 GtkWidget *widget;
00603
00604 CN_LOGPRINTF("entry");
00605
00606 if (g_encrkey)
00607 {
00608 widget = g_encrkey->entry;
00609 encrkey = gtk_entry_get_text(GTK_ENTRY(widget));
00610 }
00611
00612 CN_LOGPRINTF("return encrkey=%s", encrkey);
00613 return encrkey;
00614 }
00615
00616 gboolean edit_wireless_ext_check_network_settings(void)
00617 {
00618 gboolean valid = TRUE;
00619
00620 CN_LOGPRINTF("entry");
00621 if (!ergtk_entry_check_field(ERGTK_ENTRY(g_encrkey->entry)))
00622 {
00623 valid = FALSE;
00624 }
00625
00626 return valid;
00627 }
00628
00629 static void edit_wireless_ext_backup_network_settings(void)
00630 {
00631 const char *encrkey;
00632
00633 CN_LOGPRINTF("entry");
00634
00635 g_free(g_old_encrkey);
00636
00637 encrkey = edit_wireless_ext_get_encrkey();
00638 g_old_encrkey = g_strdup(encrkey);
00639 }
00640
00641 void edit_wireless_ext_restore_network_settings(void)
00642 {
00643 CN_LOGPRINTF("entry");
00644
00645 edit_wireless_ext_set_encrkey(g_old_encrkey);
00646 }
00647
00648 static gboolean on_delayed_connect(gpointer data)
00649 {
00650 gboolean valid;
00651 pingContext_t *ctxt;
00652 GtkToggleButton *button;
00653
00654 erbusy_blink();
00655
00656 valid = edit_wireless_ext_check_network_settings();
00657 if (valid)
00658 {
00659 edit_wireless_ext_freeze_ui(TRUE);
00660
00661 edit_wireless_ext_restore_ping_ctxt();
00662
00663 ctxt = cmgr_get_ping_ctxt();
00664 connect_ping_select_initial_profile(ctxt);
00665 connect_ping(ctxt, TRUE);
00666 }
00667 else
00668 {
00669 button = GTK_TOGGLE_BUTTON(data);
00670 gtk_toggle_button_set_active(button, FALSE);
00671 }
00672
00673 return FALSE;
00674 }
00675
00676 static void on_connect(GtkToggleButton* button, gpointer data)
00677 {
00678 gboolean active;
00679
00680 CN_LOGPRINTF("entry");
00681
00682 active = gtk_toggle_button_get_active(button);
00683 if (active)
00684 {
00685 g_timeout_add(500, on_delayed_connect, (gpointer)button);
00686 }
00687 }
00688
00689 static gboolean on_delayed_advanced(gpointer data)
00690 {
00691 gboolean valid;
00692 GtkToggleButton *button;
00693
00694 erbusy_blink();
00695
00696 valid = edit_wireless_ext_check_network_settings();
00697 if (valid)
00698 {
00699 edit_wireless_ext_backup_network_settings();
00700
00701 edit_goto_page(editScreenOverview_e);
00702 edit_overview_update_info_text(inputProxy_e);
00703 }
00704
00705 button = GTK_TOGGLE_BUTTON(data);
00706 gtk_toggle_button_set_active(button, FALSE);
00707
00708 return FALSE;
00709 }
00710
00711 static void on_advanced(GtkToggleButton* button, gpointer data)
00712 {
00713 gboolean active;
00714
00715 CN_LOGPRINTF("entry");
00716
00717 active = gtk_toggle_button_get_active(button);
00718 if (active)
00719 {
00720 g_timeout_add(500, on_delayed_advanced, button);
00721 }
00722 }
00723
00724 static gboolean delayed_deactive_button(gpointer data)
00725 {
00726 GtkToggleButton *button = GTK_TOGGLE_BUTTON(data);
00727
00728 if (button)
00729 {
00730 gtk_toggle_button_set_active(button, FALSE);
00731 }
00732
00733 return FALSE;
00734 }
00735
00737
00739 static void edit_wireless_ext_restore_ping_ctxt(void)
00740 {
00741 pingContext_t *ctxt;
00742 cmgrConnectType_t connectType;
00743
00744 CN_LOGPRINTF("entry");
00745
00746 ctxt = cmgr_get_ping_ctxt();
00747 if (ctxt)
00748 {
00749
00750 connect_ping_ctxt_set_mode(ctxt, editPing_e);
00751 connectType = connect_data_get_connect_type();
00752 connect_ping_ctxt_set_connect_type(ctxt, connectType);
00753
00754
00755 connect_ping_ctxt_set_done_callbacks(ctxt, on_connected, on_failed);
00756
00757
00758 connect_ping_ctxt_set_get_initial_profile(ctxt,
00759 edit_get_initial_profile);
00760 connect_ping_ctxt_set_access_network_profiles_callbacks(ctxt,
00761 edit_get_n_network_profiles,
00762 edit_get_network_profile,
00763 edit_select_next_regprofile);
00764
00765
00766 connect_ping_ctxt_set_ui_callbacks(ctxt,
00767 ui_update_status,
00768 ui_display_settings,
00769 ui_select_profile,
00770 ui_unselect_all_profile);
00771 }
00772 }
00773
00774 static void on_connected(int profileIndex)
00775 {
00776 GtkToggleButton *button;
00777
00778 CN_LOGPRINTF("entry");
00779
00780 edit_save_profile();
00781
00782 edit_on_connected();
00783
00784 edit_wireless_ext_freeze_ui(FALSE);
00785
00786 if (g_encrkey)
00787 {
00788 button = GTK_TOGGLE_BUTTON(g_encrkey->button);
00789 g_timeout_add(500, delayed_deactive_button, button);
00790 }
00791 }
00792
00793 static void on_failed(void)
00794 {
00795 GtkToggleButton *button;
00796
00797 CN_LOGPRINTF("entry");
00798
00799 edit_wireless_ext_freeze_ui(FALSE);
00800
00801 if (g_encrkey)
00802 {
00803 button = GTK_TOGGLE_BUTTON(g_encrkey->button);
00804 gtk_toggle_button_set_active(button, FALSE);
00805 }
00806 }
00807
00808 static void ui_update_status(int profileIndex, pingStatus_t status)
00809 {
00810 wlanExtStatus_t state;
00811
00812 CN_LOGPRINTF("entry");
00813
00814 edit_wireless_ext_update_status(status);
00815
00816 switch (status)
00817 {
00818 case pingSucceeded_e:
00819 state = wlanExtConnected_e;
00820 break;
00821 case pingFailed_e:
00822 state = advancedSettings_e;
00823 break;
00824 case pingFailedPCShare_e:
00825 state = pcshareSettings_e;
00826 break;
00827 case pingFailedNetwork_e:
00828 state = wrongEncrKey_e;
00829 break;
00830 case pingConnecting_e:
00831 state = wlanExtConnecting_e;
00832 break;
00833 case pingAborting_e:
00834 state = wlanExtAborting_e;
00835 break;
00836 case pingAborted_e:
00837 state = wlanExtAborted_e;
00838 on_failed();
00839 break;
00840 default:
00841 state = undefWlanExtStatus_e;
00842 break;
00843 }
00844
00845 edit_wireless_ext_show_widgets(state);
00846 edit_wireless_ext_update_info_text(state);
00847
00848 display_update_request_screen_refresh (STATUS_ITEM_CHANGE,
00849 WAVEFORM_TYPING);
00850 }
00851
00852 static void ui_display_settings(int profileIndex, gboolean resetStatus)
00853 {
00854 CN_LOGPRINTF("entry");
00855
00856 }
00857
00858 static void ui_select_profile(int profileIndex)
00859 {
00860 GtkProfileEntry *profileEntry;
00861
00862 CN_LOGPRINTF("entry");
00863
00864 if (g_profile_entry)
00865 {
00866 profileEntry = GTK_PROFILE_ENTRY(g_profile_entry->details);
00867 gtk_profile_entry_set_buttons_active(profileEntry, TRUE, FALSE);
00868
00869 display_update_request_screen_refresh (STATUS_ITEM_CHANGE,
00870 WAVEFORM_TYPING);
00871 }
00872 }
00873
00874 static void ui_unselect_all_profile(void)
00875 {
00876 GtkProfileEntry *profileEntry;
00877
00878 CN_LOGPRINTF("entry");
00879
00880 if (g_profile_entry)
00881 {
00882 profileEntry = GTK_PROFILE_ENTRY(g_profile_entry->details);
00883 gtk_profile_entry_set_buttons_active(profileEntry, FALSE, FALSE);
00884
00885 display_update_request_screen_refresh(STATUS_ITEM_CHANGE,
00886 WAVEFORM_TYPING);
00887 }
00888 }
00889
00890
00892
00894 gboolean on_edit_wireless_ext_keypress(GdkEventKey *event)
00895 {
00896 pingContext_t *ctxt;
00897 GtkToggleButton *button;
00898 gboolean ret = FALSE;
00899
00900 CN_LOGPRINTF("entry");
00901
00902 ctxt = cmgr_get_ping_ctxt();
00903 switch (event->keyval)
00904 {
00905 case GDK_Return:
00906
00907 if (!connect_ping_in_pinging(ctxt))
00908 {
00909
00910 if (g_encrkey)
00911 {
00912 button = GTK_TOGGLE_BUTTON(g_encrkey->button);
00913 gtk_toggle_button_set_active(button, TRUE);
00914 }
00915 ret = TRUE;
00916 }
00917 break;
00918
00919 case GDK_F5:
00920
00921
00922 connect_ping_abort(ctxt);
00923 cmgr_up_page();
00924 ret = TRUE;
00925 break;
00926 default:
00927 erbusy_off();
00928 break;
00929 }
00930
00931 return ret;
00932 }
00933
00935
00937
00938 static void edit_wireless_ext_freeze_ui(gboolean freeze)
00939 {
00940 gboolean sensitive;
00941 GtkWidget *widget;
00942
00943 CN_LOGPRINTF("entry[%d]", freeze);
00944
00945 sensitive = !freeze;
00946
00947
00948 widget = g_encrkey->entry;
00949 gtk_widget_set_sensitive(widget, sensitive);
00950
00951
00952 widget = g_encrkey->button;
00953 gtk_widget_set_sensitive(widget, sensitive);
00954
00955
00956 widget = GTK_WIDGET(g_advanced->details->buttonList[0]);
00957 gtk_widget_set_sensitive(widget, sensitive);
00958 }
00959