00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00027 #include <unistd.h>
00028 #include <string.h>
00029
00030 #include <gtk/gtk.h>
00031 #include <gdk/gdkkeysyms.h>
00032
00033 #include <liberdm/connectionMgrConstants.h>
00034 #include <libergtk/ergtk.h>
00035 #include <liberipc/eripctoolbar.h>
00036
00037 #include "connectionMgrLog.h"
00038 #include "displayStatus.h"
00039 #include "background.h"
00040 #include "gtkSettingItem.h"
00041 #include "gtkInfoItem.h"
00042 #include "gtkProfileEntry.h"
00043 #include "gtkProfileGroup.h"
00044 #include "widgetUtils.h"
00045 #include "connectScreenData.h"
00046 #include "connectionMgr.h"
00047 #include "connectScreen.h"
00048 #include "connectScreenOptions.h"
00049 #include "connectScreenProfiles.h"
00050 #include "connectPing.h"
00051 #include "connectScan.h"
00052 #include "connectBackground.h"
00053 #include "editScreenData.h"
00054 #include "editScreen.h"
00055 #include "modemUtils.h"
00056 #include "erbusy.h"
00057 #include "pagebar.h"
00058 #include "toolbar.h"
00059 #include "languages.h"
00060
00061
00062 static GtkWidget *g_connect_profiles = NULL;
00063
00064
00065 static GtkWidget *g_known_profiles = NULL;
00066
00067
00068 static GtkWidget *g_profile_editor = NULL;
00069 static bkWdtLabelButton *g_label_button = NULL;
00070
00071
00072 static GtkWidget* g_info = NULL;
00073
00074
00075 static GtkWidget *create_known_profiles (void);
00076 static GtkWidget *create_profile_editor (void);
00077 static GtkWidget *create_info(void);
00078
00079
00080 static gboolean on_profile_entry_button_press(GtkProfileGroup* profileGroup,
00081 guint profileIndex,
00082 gboolean active);
00083
00084 static void on_profile_editor_toggled (GtkWidget* button,
00085 GdkEventButton * event,
00086 gpointer data);
00087
00088 static gboolean delay_profile_entry_selected(gpointer data);
00089 static void connect_profiles_reset_active_reg_index(void);
00090 static gboolean connect_profiles_start_fillin_profile(void);
00091 static gboolean on_delay_start_fillin_profile(gpointer data);
00092 static void connect_profiles_update_new_profile(void);
00093 static gboolean delayed_on_profile_editor_toggled(gpointer data);
00094 static void connect_profiles_on_failed_all(void);
00095
00097
00099
00100
00101
00102
00103
00104
00105
00106
00107 GtkWidget *connect_profiles_create (void)
00108 {
00109 CN_LOGPRINTF ("entry");
00110
00111 GtkWidget* vbox;
00112 GtkWidget* itemNetworks;
00113 GtkWidget* itemNewProfile;
00114 GtkWidget* itemInfo;
00115
00116
00117 vbox = gtk_vbox_new(FALSE, VBOX_SPACING);
00118 gtk_widget_show(vbox);
00119 g_connect_profiles = vbox;
00120
00121
00122 itemNetworks = create_known_profiles();
00123 gtk_box_pack_start(GTK_BOX(vbox), itemNetworks, FALSE, FALSE, 0);
00124 gtk_widget_show(itemNetworks);
00125
00126
00127 itemNewProfile = create_profile_editor();
00128 gtk_box_pack_start(GTK_BOX(vbox), itemNewProfile, FALSE, FALSE, 0);
00129 gtk_widget_show(itemNewProfile);
00130
00131
00132 itemInfo = create_info();
00133 gtk_box_pack_start(GTK_BOX(vbox), itemInfo, FALSE, FALSE, 0);
00134 gtk_widget_show(itemInfo);
00135
00136 return g_connect_profiles;
00137 }
00138
00139
00140
00141
00142 static GtkWidget *create_known_profiles (void)
00143 {
00144 GtkWidget* item;
00145
00146
00147 item = gtk_profile_group_new(MAX_PROFILES_PER_PAGE, connectMode_e);
00148 gtk_profile_group_show_dialup(GTK_PROFILE_GROUP(item), FALSE);
00149 gtk_profile_group_callback_on_buttons_press(GTK_PROFILE_GROUP(item),
00150 on_profile_entry_button_press, NULL);
00151 g_known_profiles = item;
00152
00153 return item;
00154 }
00155
00156
00157
00158
00159 static GtkWidget *create_profile_editor (void)
00160 {
00161 GtkWidget *item;
00162 bkWdtLabelButton *widget;
00163 GtkToggleButton *button;
00164
00165
00166 item = gtk_settingitem_new("");
00167
00168
00169 widget = bk_wdt_label_button_new(1, FALSE, 0, 1);
00170 gtk_settingitem_add_details(GTK_SETTINGITEM(item), widget->background);
00171
00172
00173 button = widget->details->buttonList[0];
00174 g_signal_connect(G_OBJECT(button), "toggled",
00175 G_CALLBACK(on_profile_editor_toggled), 0);
00176
00177
00178 gtk_widget_show(widget->background);
00179
00180
00181 g_profile_editor = item;
00182 g_label_button = widget;
00183
00184
00185 return item;
00186 }
00187
00188
00189
00190
00191 static GtkWidget *create_info(void)
00192 {
00193 GtkWidget* item;
00194
00195 item = gtk_infoitem_new(FALSE);
00196 g_info = item;
00197 return item;
00198 }
00199
00201
00203 void connect_profiles_set_text (void)
00204 {
00205 GtkProfileGroup *profileGroup;
00206 GtkWidget *widget;
00207
00208 CN_LOGPRINTF ("entry");
00209
00210 if (g_known_profiles)
00211 {
00212 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00213 gtk_profile_group_set_dialup_text(profileGroup,
00214 _("Signal strength of network:"));
00215 }
00216
00217 if (g_profile_editor)
00218 {
00219 gtk_settingitem_set_header_text(GTK_SETTINGITEM(g_profile_editor),
00220 _("Setup a network profile"));
00221 }
00222
00223 if (g_label_button)
00224 {
00225 widget = g_label_button->details->label;
00226 gtk_label_set_text (GTK_LABEL(widget),
00227 _("You can create or edit a network profile "
00228 "by clicking the button below."));
00229
00230 widget = GTK_WIDGET(g_label_button->details->buttonList[0]);
00231 gtk_button_set_label (GTK_BUTTON(widget), _("Profile editor"));
00232 }
00233 }
00234
00236
00238 static void connect_profiles_update_info(void)
00239 {
00240 connection_t networkType;
00241 char* cpTitle = NULL, *cpDetails = NULL;
00242 char* cpInfo = NULL;
00243 GtkProfileGroup *profileGroup;
00244
00245 networkType = connect_data_get_network_type();
00246 switch(networkType)
00247 {
00248 case wired_t:
00249 cpTitle = _("Available wired networks");
00250 cpDetails = _("No wired profiles exist, "
00251 "please use the button below "
00252 "to create a profile.");
00253 cpInfo = _("You need to connect your travel hub "
00254 "and ethernet cable "
00255 "to your iLiad.\n"
00256 "The default profile uses DHCP and no proxy.");
00257 break;
00258 case dialup_t:
00259 cpTitle = _("Available dial-up networks");
00260 cpDetails = _("No dial-up profiles exist, "
00261 "please use the button below "
00262 "to create a profile.");
00263 cpInfo = _("In order to use a dial-up network, "
00264 "you need a CF modem.\n"
00265 "Bluetooth dial-up connections "
00266 "are not yet supported.");
00267 break;
00268 case wireless_t:
00269 cpTitle = _("Available wireless networks");
00270 cpDetails = _("No wireless profiles exist, "
00271 "please use the button below "
00272 "to create a profile.");
00273 cpInfo = _("When the access point is secured with "
00274 "an encryption key,"
00275 " click on the corresponding network button "
00276 "to open the configuration screen.\n"
00277 "By clicking the 'Profile editor' button "
00278 "you can create a network profile"
00279 " for a non broadcasting (hidden) access point.");
00280 break;
00281 default:
00282 CN_WARNPRINTF("Invalid network type[%d].", networkType);
00283 break;
00284 }
00285
00286
00287 if (g_known_profiles)
00288 {
00289 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00290
00291 gtk_profile_group_set_header_text(profileGroup, cpTitle);
00292
00293 if (connect_data_get_n_network_profiles())
00294 {
00295 gtk_profile_group_set_info_text(profileGroup,
00296 _("Accept the automatic search "
00297 "or select the network of your choice."));
00298 }
00299 else
00300 {
00301 gtk_profile_group_set_info_text(profileGroup, cpDetails);
00302 }
00303 }
00304
00305 if (g_info)
00306 {
00307 gtk_infoitem_set_text(GTK_INFOITEM(g_info), cpInfo);
00308 }
00309 }
00310
00311 void connect_profiles_display (void)
00312 {
00313 CN_LOGPRINTF ("entry");
00314
00315 GtkProfileGroup *profileGroup;
00316 const networkProfile_t *settings;
00317 int i, profileIndex;
00318 int nProfiles, nDisplayed;
00319 int quality;
00320 GtkToggleButton *button;
00321
00322 connect_profiles_update_info();
00323
00324
00325 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00326
00327
00328 switch (connect_data_get_network_type())
00329 {
00330 case wired_t:
00331 case wireless_t:
00332 gtk_profile_group_show_dialup(profileGroup, FALSE);
00333 break;
00334 case dialup_t:
00335 quality = get_modem_signal_strength() * 100 / 32;
00336 gtk_profile_group_set_dialup_signal_image(profileGroup, quality);
00337 gtk_profile_group_show_dialup(profileGroup, TRUE);
00338 break;
00339 default:
00340 break;
00341 }
00342
00343
00344 nProfiles = connect_data_get_n_network_profiles();
00345 nDisplayed = ((nProfiles < MAX_PROFILES_PER_PAGE) ? nProfiles: MAX_PROFILES_PER_PAGE);
00346
00347 if (nDisplayed > 0)
00348 {
00349 for (i = 0; i < nDisplayed; i++)
00350 {
00351 settings = connect_data_get_network_profile(i);
00352 gtk_profile_group_display_settings(profileGroup, i,
00353 settings, TRUE);
00354 }
00355 }
00356 gtk_profile_group_show_profile_entries(profileGroup, nDisplayed);
00357
00358
00359 profileIndex = gtk_profile_group_get_selected_profile_index(profileGroup);
00360 if (profileIndex != -1)
00361 {
00362 gtk_profile_group_unselect_profile(profileGroup, profileIndex);
00363 }
00364
00365
00366 if (g_label_button)
00367 {
00368 button = g_label_button->details->buttonList[0];
00369 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
00370 }
00371 }
00372
00373 void connect_profiles_select_profile(int profileIndex)
00374 {
00375 CN_LOGPRINTF("entry");
00376
00377 GtkProfileGroup* profileGroup;
00378
00379 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00380 gtk_profile_group_select_profile(profileGroup, profileIndex);
00381 display_update_request_screen_refresh(STATUS_ITEM_CHANGE,
00382 WAVEFORM_TYPING);
00383 }
00384
00385 void connect_profiles_unselect_profile (void)
00386 {
00387 CN_LOGPRINTF ("entry");
00388
00389 GtkProfileGroup *profileGroup;
00390 gint profileIndex;
00391
00392 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00393 profileIndex = gtk_profile_group_get_selected_profile_index(profileGroup);
00394 if (profileIndex != -1)
00395 {
00396 gtk_profile_group_unselect_profile(profileGroup, profileIndex);
00397 }
00398 }
00399
00400 void connect_profiles_update_status(int profileIndex, pingStatus_t status)
00401 {
00402 CN_LOGPRINTF("entry");
00403
00404 int nProfiles;
00405 GtkProfileGroup* profileGroup;
00406 gchar* text;
00407 gboolean flashing = FALSE;
00408
00409 nProfiles = connect_data_get_n_network_profiles();
00410 if ((profileIndex >= 0) && (profileIndex < nProfiles))
00411 {
00412 switch (status)
00413 {
00414 case pingSucceeded_e:
00415 text = _("Connected");
00416 break;
00417 case pingFailed_e:
00418 case pingFailedPCShare_e:
00419 case pingFailedNetwork_e:
00420 text = _("Unsuccessful");
00421 break;
00422 case pingSkipped_e:
00423 text = _("Skipped");
00424 break;
00425 case pingNeedKey_e:
00426 text = _("Security key required");
00427 break;
00428 case pingAborted_e:
00429 text = _("Aborted");
00430 break;
00431 case pingAborting_e:
00432 text = _("Aborting...");
00433 flashing = TRUE;
00434 break;
00435 case pingConnecting_e:
00436 text = _("Connecting...");
00437 flashing = TRUE;
00438 break;
00439 default:
00440 text = "";
00441 break;
00442 }
00443
00444 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00445 gtk_profile_group_set_status_text(profileGroup, profileIndex,
00446 text, flashing);
00447 display_update_request_screen_refresh (STATUS_ITEM_CHANGE,
00448 WAVEFORM_TYPING);
00449 }
00450 }
00451
00452 void connect_profiles_display_settings(int profileIndex,
00453 gboolean resetStatus)
00454 {
00455 GtkProfileGroup *profileGroup;
00456 const networkProfile_t *settings;
00457 int max, nProfiles, nDisplayed;
00458
00459 CN_LOGPRINTF("entry profileIndex[%d]", profileIndex);
00460
00461 max = MAX_PROFILES_PER_PAGE;
00462 nProfiles = connect_data_get_n_network_profiles();
00463 nDisplayed = ((nProfiles < max) ? nProfiles: max);
00464 if (nDisplayed > 0)
00465 {
00466 if ((profileIndex >= 0) && (profileIndex < nDisplayed))
00467 {
00468 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00469 settings = connect_data_get_network_profile(profileIndex);
00470 gtk_profile_group_display_settings(profileGroup, profileIndex,
00471 settings, resetStatus);
00472 display_update_request_screen_refresh(STATUS_ITEM_CHANGE,
00473 WAVEFORM_TYPING);
00474 }
00475 }
00476 }
00477
00479
00481
00482
00483
00484
00485
00486
00487
00488
00489 static gboolean on_profile_entry_button_press(GtkProfileGroup* profileGroup,
00490 guint profileIndex,
00491 gboolean active)
00492 {
00493 pingContext_t* ctxt;
00494 gint pingingProfileIndex;
00495
00496 CN_LOGPRINTF("entry");
00497
00498 g_return_val_if_fail(IS_GTK_PROFILE_GROUP(profileGroup), FALSE);
00499 g_return_val_if_fail (profileIndex != -1, FALSE);
00500
00501 ctxt = cmgr_get_ping_ctxt();
00502 if (connect_ping_freeze_ui(ctxt))
00503 {
00504 CN_WARNPRINTF("Please wait when freezing UI...");
00505 return TRUE;
00506 }
00507
00508
00509 if (active)
00510 {
00511 pingingProfileIndex = connect_ping_get_pinging_profile_index(ctxt);
00512 if (profileIndex == pingingProfileIndex)
00513 {
00514 CN_LOGPRINTF("button-press-event happens "
00515 "on the current pinging button[%d]",
00516 pingingProfileIndex);
00517
00518
00519 return TRUE;
00520 }
00521 else
00522 {
00523 return FALSE;
00524 }
00525 }
00526 else
00527 {
00528
00529 connect_ping_abort(ctxt);
00530
00531
00532 g_timeout_add(200,
00533 delay_profile_entry_selected,
00534 (gpointer)profileIndex);
00535
00536
00537
00538 return TRUE;
00539 }
00540 }
00541
00542 static gboolean delay_profile_entry_selected(gpointer data)
00543 {
00544 pingContext_t* ctxt;
00545 guint profileIndex = (guint)data;
00546
00547 ctxt = cmgr_get_ping_ctxt();
00548 if (connect_ping_freeze_ui(ctxt))
00549 {
00550 CN_WARNPRINTF("call me later...");
00551 return TRUE;
00552 }
00553
00554 connect_profiles_reset_active_reg_index();
00555
00556
00557 connect_ping_set_pinging_profile_index_start(ctxt, profileIndex);
00558
00559
00560 connect_ping_set_selected_profile_index(ctxt, profileIndex);
00561
00562
00563 connect_profiles_select_profile(profileIndex);
00564
00565 if (!connect_profiles_start_fillin_profile())
00566 {
00567
00568 connect_profiles_restore_ping_ctxt();
00569 connect_ping(ctxt, TRUE);
00570 }
00571
00572 return FALSE;
00573 }
00574
00575 static void connect_profiles_reset_active_reg_index(void)
00576 {
00577 int i, nProfiles;
00578 networkProfile_t* settings = NULL;
00579
00580 nProfiles = connect_data_get_n_network_profiles();
00581 for (i = 0; i < nProfiles; i++)
00582 {
00583 settings = (networkProfile_t*)connect_data_get_network_profile(i);
00584 g_return_if_fail(settings != NULL);
00585 if (settings->nRegProfiles > 0
00586 && settings->regSettingsList
00587 && settings->regIndexList
00588 && ((settings->nActiveIndex > 0)
00589 && (settings->nActiveIndex < settings->nRegProfiles)))
00590 {
00591 settings->nActiveIndex = 0;
00592 connect_profiles_display_settings(i, FALSE);
00593 }
00594 }
00595 }
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605 static gboolean connect_profiles_start_fillin_profile(void)
00606 {
00607 pingContext_t *ctxt;
00608 gint profileIndex;
00609 const networkProfile_t* settings;
00610 regNetworkProfile_t *regSettings;
00611 connection_t networkType;
00612 gboolean needEdit = FALSE;
00613 GtkProfileGroup *profileGroup;
00614
00615 CN_LOGPRINTF("entry");
00616
00617 ctxt = cmgr_get_ping_ctxt();
00618 profileIndex = connect_ping_get_selected_profile_index(ctxt);
00619 g_return_val_if_fail(profileIndex != -1, FALSE);
00620
00621 settings = connect_data_get_network_profile(profileIndex);
00622 g_return_val_if_fail(settings != NULL, FALSE);
00623
00624 if ( (settings->nRegProfiles == 0) && settings->scanSettings)
00625 {
00626 if (settings->scanSettings->encryption == encr_none_t)
00627 {
00628 CN_LOGPRINTF("The %dth profile needs to save before ping.",
00629 profileIndex);
00630 if (!connect_data_reach_max_profiles())
00631 {
00632
00633 edit_set_mode(editModeConnectCreate_e);
00634
00635 regSettings = network_spec_to_reg_network(settings->scanSettings);
00636
00637
00638 networkType = regSettings->connection;
00639 edit_data_set_network_type(networkType);
00640
00641
00642 edit_data_init_network_profiles();
00643
00644
00645 edit_set_wizard_mode(TRUE);
00646
00647
00648 edit_set_network_settings(regSettings);
00649
00650
00651 edit_save_profile();
00652
00653
00654 connect_profiles_update_new_profile();
00655
00656 erRegFreeNetworkProfile(regSettings);
00657 }
00658 }
00659 else
00660 {
00661 CN_LOGPRINTF("The %dth profile needs encryption key.",
00662 profileIndex);
00663
00664 if (!connect_data_reach_max_profiles())
00665 {
00666 needEdit = TRUE;
00667
00668 profileGroup = GTK_PROFILE_GROUP(g_known_profiles);
00669 gtk_profile_group_set_status_text(profileGroup,
00670 profileIndex,
00671 _("Open network profile..."),
00672 FALSE);
00673 display_update_request_screen_refresh(STATUS_ITEM_CHANGE,
00674 WAVEFORM_TYPING);
00675
00676 g_timeout_add(500,
00677 on_delay_start_fillin_profile,
00678 (gpointer)settings);
00679 }
00680 }
00681 }
00682
00683 return needEdit;
00684 }
00685
00686 static gboolean on_delay_start_fillin_profile(gpointer data)
00687 {
00688 networkProfile_t* settings;
00689 regNetworkProfile_t* regSettings;
00690 connection_t networkType;
00691
00692 settings = (networkProfile_t*)data;
00693 if (settings)
00694 {
00695 CN_LOGPRINTF("Opening the profile editor...");
00696
00697 cmgr_set_screen_mode(cmgrScreenEdit_e);
00698
00699
00700 edit_set_mode(editModeConnectFillIn_e);
00701
00702 regSettings = network_spec_to_reg_network(settings->scanSettings);
00703
00704
00705 networkType = regSettings->connection;
00706 edit_data_set_network_type(networkType);
00707
00708
00709 edit_data_init_network_profiles();
00710
00711
00712 edit_set_wizard_mode(TRUE);
00713 edit_set_back_overview(FALSE);
00714
00715
00716 edit_set_network_settings(regSettings);
00717
00718
00719 edit_goto_page(editScreenWirelessExt_e);
00720
00721 erRegFreeNetworkProfile(regSettings);
00722 regSettings = NULL;
00723 }
00724
00725 return FALSE;
00726 }
00727
00728 static void connect_profiles_update_new_profile(void)
00729 {
00730 networkProfile_t *settings;
00731 pingContext_t *ctxt;
00732 gint profileIndex;
00733
00734 CN_LOGPRINTF("entry");
00735
00736 ctxt = cmgr_get_ping_ctxt();
00737 profileIndex = connect_ping_get_selected_profile_index(ctxt);
00738 g_return_if_fail(profileIndex != -1);
00739
00740 settings = (networkProfile_t*)connect_data_get_network_profile(profileIndex);
00741 g_return_if_fail(settings != NULL);
00742
00743 if ( (settings->nRegProfiles == 0) && settings->scanSettings)
00744 {
00745 connect_data_update_network_profile_with_last(settings);
00746 }
00747 }
00748
00749 static void on_profile_editor_toggled (GtkWidget* button,
00750 GdkEventButton * event,
00751 gpointer data)
00752 {
00753 gboolean active;
00754 pingContext_t* ctxt;
00755
00756 CN_LOGPRINTF("entry");
00757
00758
00759 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));
00760 ctxt = cmgr_get_ping_ctxt();
00761
00762 if (connect_ping_freeze_ui(ctxt))
00763 {
00764 CN_WARNPRINTF("Please wait when freezing UI...");
00765 if (active)
00766 {
00767 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), FALSE);
00768 }
00769 return;
00770 }
00771
00772 if (active)
00773 {
00774
00775 connect_ping_abort(ctxt);
00776
00777
00778 g_timeout_add(500, delayed_on_profile_editor_toggled, data);
00779 }
00780 }
00781
00782 static gboolean delayed_on_profile_editor_toggled(gpointer data)
00783 {
00784 pingContext_t* ctxt;
00785 connection_t networkType;
00786
00787 erbusy_blink();
00788
00789 ctxt = cmgr_get_ping_ctxt();
00790 if (connect_ping_freeze_ui(ctxt))
00791 {
00792 CN_LOGPRINTF("call me later...");
00793 return TRUE;
00794 }
00795
00796
00797 cmgr_set_screen_mode(cmgrScreenEdit_e);
00798
00799
00800 edit_set_mode(editModeConnectNormal_e);
00801
00802
00803 networkType = connect_data_get_network_type();
00804 edit_data_set_network_type(networkType);
00805
00806
00807 edit_data_init_network_profiles();
00808
00809
00810 edit_goto_page(editScreenProfiles_e);
00811
00812
00813 display_update_request_screen_refresh(MAIN_WINDOW_EXPOSE_LEVEL,
00814 WAVEFORM_FULLSCREEN);
00815
00816 return FALSE;
00817 }
00818
00820
00822 gboolean on_connect_profiles_keypress (GdkEventKey * event)
00823 {
00824 pingContext_t *ctxt;
00825 gboolean ret = FALSE;
00826
00827 CN_LOGPRINTF ("entry");
00828
00829 switch (event->keyval)
00830 {
00831 case GDK_Return:
00832
00833 ret = TRUE;
00834 break;
00835
00836 case GDK_F5:
00837
00838
00839 ctxt = cmgr_get_ping_ctxt();
00840 connect_ping_abort(ctxt);
00841 cmgr_up_page();
00842 ret = TRUE;
00843 break;
00844
00845 case GDK_Down:
00846 case GDK_Up:
00847 case GDK_Page_Down:
00848 case GDK_Page_Up:
00849 default:
00850 erbusy_off();
00851 }
00852
00853 return ret;
00854 }
00855
00857
00859 static gboolean on_delay_back_page(gpointer data)
00860 {
00861 pingContext_t *ctxt;
00862
00863 CN_LOGPRINTF("entry");
00864
00865 ctxt = cmgr_get_ping_ctxt();
00866 if (connect_ping_freeze_ui(ctxt))
00867 {
00868 CN_WARNPRINTF("call me later...");
00869 return TRUE;
00870 }
00871
00872 toolbar_setIconState(iconID_back, iconState_selected);
00873 cmgr_add_on_toolbar_sync_action(cmgr_back_page);
00874 toolbar_synchronise();
00875
00876 return FALSE;
00877 }
00878
00879 void on_connect_profiles_icon_clicked(int iconID, int iconState)
00880 {
00881 pingContext_t *ctxt;
00882
00883 CN_LOGPRINTF("entry iconID[%d] iconState[%d]", iconID, iconState);
00884
00885 switch (iconID)
00886 {
00887 case iconID_back:
00888 if (iconState == iconState_normal)
00889 {
00890 ctxt = cmgr_get_ping_ctxt();
00891 if (connect_ping_freeze_ui(ctxt))
00892 {
00893 CN_WARNPRINTF("Please wait when freezing UI...");
00894 return;
00895 }
00896
00897
00898 connect_ping_abort(ctxt);
00899
00900
00901 g_timeout_add(200, on_delay_back_page, NULL);
00902 }
00903 break;
00904 default:
00905 break;
00906 }
00907 }
00908
00910
00912 void connect_profiles_restore_ping_ctxt(void)
00913 {
00914 pingContext_t *ctxt;
00915 cmgrConnectType_t connectType;
00916
00917 CN_LOGPRINTF("entry");
00918
00919 ctxt = cmgr_get_ping_ctxt();
00920 if (ctxt)
00921 {
00922 connect_ping_ctxt_set_mode(ctxt, connectPing_e);
00923
00924 connectType = connect_data_get_connect_type();
00925 connect_ping_ctxt_set_connect_type(ctxt, connectType);
00926
00927 connect_ping_ctxt_set_done_callbacks(ctxt,
00928 connect_background_on_connected,
00929 connect_profiles_on_failed_all);
00930
00931 connect_ping_ctxt_set_get_initial_profile(ctxt,
00932 connect_background_get_initial_profile);
00933
00934 connect_ping_ctxt_set_access_network_profiles_callbacks(ctxt,
00935 connect_data_get_n_network_profiles,
00936 connect_data_get_network_profile,
00937 connect_data_select_next_regprofile);
00938
00939 connect_ping_ctxt_set_ui_callbacks(ctxt,
00940 connect_profiles_update_status,
00941 connect_profiles_display_settings,
00942 connect_profiles_select_profile,
00943 connect_profiles_unselect_profile);
00944 }
00945 }
00946
00947 static void connect_profiles_on_failed_all(void)
00948 {
00949 connect_profiles_unselect_profile();
00950
00951 if (main_get_connect_after_reboot())
00952 {
00953 CN_LOGPRINTF("It's connection after rebooting, exit.");
00954 main_quit();
00955 }
00956 }
00957