00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026 #include <liberdm/connectionMgrConstants.h>
00027
00028 #include "connectionMgrLog.h"
00029 #include "connectScan.h"
00030 #include "connectPing.h"
00031 #include "connectScreenData.h"
00032 #include "connectBackground.h"
00033 #include "connectionMgr.h"
00034
00035 static void connect_background_scan_networks_done(void);
00036
00037 void connect_background_restore_scan_ctxt(void)
00038 {
00039 scanContext_t *ctxt;
00040 connection_t networkType;
00041 char *ssidList;
00042
00043 CN_LOGPRINTF("entry");
00044
00045 ctxt = cmgr_get_scan_ctxt();
00046 if (ctxt)
00047 {
00048 connect_scan_ctxt_set_mode(ctxt, backgroundScan_e);
00049 networkType = connect_data_get_network_type();
00050 connect_scan_ctxt_set_network_type(ctxt, networkType);
00051 connect_scan_ctxt_set_done_callbacks(ctxt,
00052 connect_data_init_network_profiles,
00053 connect_background_scan_networks_done);
00054 ssidList = connect_data_get_hidden_ssid_list();
00055 connect_scan_ctxt_set_ssidlist(ctxt, ssidList ? ssidList : "");
00056 g_free(ssidList);
00057 }
00058 }
00059
00060 void connect_background_restore_ping_ctxt(void)
00061 {
00062 pingContext_t *ctxt;
00063 cmgrConnectType_t connectType;
00064
00065 CN_LOGPRINTF("entry");
00066
00067 ctxt = cmgr_get_ping_ctxt();
00068 if (ctxt)
00069 {
00070 connect_ping_ctxt_set_mode(ctxt, backgroundPing_e);
00071 connectType = connect_data_get_connect_type();
00072 connect_ping_ctxt_set_connect_type(ctxt, connectType);
00073
00074 connect_ping_ctxt_set_done_callbacks(ctxt,
00075 connect_background_on_connected,
00076 connect_background_on_failed_all);
00077
00078 connect_ping_ctxt_set_get_initial_profile(ctxt,
00079 connect_background_get_initial_profile);
00080
00081 connect_ping_ctxt_set_access_network_profiles_callbacks(ctxt,
00082 connect_data_get_n_network_profiles,
00083 connect_data_get_network_profile,
00084 connect_data_select_next_regprofile);
00085 }
00086 }
00087
00088 static void connect_background_scan_networks_done(void)
00089 {
00090 int nProfiles;
00091 pingContext_t *ctxt;
00092
00093 CN_LOGPRINTF("entry");
00094
00095 nProfiles = connect_data_get_n_network_profiles();
00096 if (nProfiles > 0)
00097 {
00098 connect_background_restore_ping_ctxt();
00099 ctxt = cmgr_get_ping_ctxt();
00100 connect_ping_select_initial_profile(ctxt);
00101 connect_ping(ctxt, FALSE);
00102 }
00103 }
00104
00105 int connect_background_get_initial_profile(void)
00106 {
00107 gint regIndex, profileIndex = 0;
00108
00109
00110 regIndex = connect_data_get_last_connected_profile();
00111 CN_LOGPRINTF ("last connected profile [%d]", regIndex);
00112
00113 if (main_get_use_last_connected () && regIndex >= 0)
00114 {
00115
00116 profileIndex = connect_data_get_profile_index(regIndex);
00117 CN_LOGPRINTF("regIndex[%d]-->profileIndex[%d]",
00118 regIndex, profileIndex);
00119 if (profileIndex == -1)
00120 {
00121 profileIndex = 0;
00122 }
00123 }
00124 return profileIndex;
00125 }
00126
00127 void connect_background_on_connected(int profileIndex)
00128 {
00129 int regIndex = -1;
00130
00131
00132 if (profileIndex != -1)
00133 {
00134 regIndex = connect_data_get_reg_index(profileIndex);
00135 if (regIndex != -1)
00136 {
00137 connect_data_set_last_connected_profile(regIndex);
00138 }
00139 }
00140
00141
00142 main_start_child_process();
00143 }
00144
00145 void connect_background_on_failed_all(void)
00146 {
00147 CN_LOGPRINTF("It's background connection, exit.");
00148 main_quit();
00149 }
00150