00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026 #include <unistd.h>
00027 #include <stdlib.h>
00028 #include <string.h>
00029
00030 #include "connectionMgrLog.h"
00031 #include "connectionMgr.h"
00032 #include "connectScreenData.h"
00033
00034
00035 static gint g_last_connected_profile_ids = 0;
00036 static gint g_last_connected_profile_ids_stored = 0;
00037 static gint g_last_connected_profile_pc = 0;
00038 static gint g_last_connected_profile_pc_stored = 0;
00039 static cmgrConnectType_t g_background_connect_type = cmgrConnectIDS_e;
00040 static cmgrConnectType_t g_manual_connect_type = cmgrConnectUnknown_e;
00041 static cmgrConnectType_t g_manual_connect_type_stored = cmgrConnectUnknown_e;
00042 static connection_t g_network_type = connection_undefined_t;
00043
00044 static gboolean g_ac_wlan = TRUE;
00045
00046
00047 static networkProfile_t* g_network_profiles = NULL;
00048 static int g_n_network_profiles = 0;
00049
00050
00051 static gboolean connect_data_read_last_connect(void);
00052 static gboolean connect_data_save_last_connect(void);
00053 static gboolean connect_data_read_auto_connect(void);
00054 static gboolean connect_data_read_ac_wlan(void);
00055
00056 static void connect_data_calc_last_network_type(void);
00057
00058 static void get_wireless_profiles(network_spec_t* pScanNetworks,
00059 int nScanNetworks);
00060 static int get_regindices_by_ssid(const char* ssid, int** indexList);
00061 static int compare_wireless_profiles(const void * p1, const void * p2);
00062
00064
00066 void connect_data_init(void)
00067 {
00068 CN_LOGPRINTF("entry");
00069
00070 connect_data_read_last_connect();
00071 connect_data_read_auto_connect();
00072 connect_data_read_ac_wlan();
00073 connect_data_calc_last_network_type();
00074 }
00075
00076 void connect_data_destroy(void)
00077 {
00078 CN_LOGPRINTF("entry");
00079 }
00080
00081 gboolean connect_data_store(void)
00082 {
00083 gboolean ret = TRUE;
00084
00085 if (main_get_connect_type() == cmgrConnectUnknown_e)
00086 {
00087
00088 ret = connect_data_save_last_connect();
00089 }
00090 else
00091 {
00092
00093 }
00094
00095 CN_LOGPRINTF("ret=%d", ret);
00096 return ret;
00097 }
00098
00100
00102 static gboolean connect_data_read_auto_connect(void)
00103 {
00104 CN_LOGPRINTF("entry");
00105
00106 regAutoConnect_t* autoconnect;
00107
00108
00109 if (main_get_background())
00110 {
00111 autoconnect = erRegGetAutoConnect();
00112 if (autoconnect)
00113 {
00114 if (autoconnect->backgroundConnectTo >= 1)
00115 {
00116 g_background_connect_type = cmgrConnectPCShare_e;
00117 }
00118 erRegFreeAutoConnect(autoconnect);
00119 }
00120 }
00121
00122 return TRUE;
00123 }
00124
00125 static gboolean connect_data_read_ac_wlan(void)
00126 {
00127 CN_LOGPRINTF("entry");
00128
00129 g_ac_wlan = erRegGetAutoConnectWlan();
00130
00131 return TRUE;
00132 }
00133
00135
00136
00138 static gboolean connect_data_read_last_connect(void)
00139 {
00140 CN_LOGPRINTF("entry");
00141
00142 regLastConnect_t* theLastConnect = NULL;
00143 gboolean ret = TRUE;
00144
00145
00146
00147 theLastConnect = erRegGetLastConnect();
00148 if (theLastConnect)
00149 {
00150
00151 g_last_connected_profile_ids = theLastConnect->profileConnectedIDS;
00152 g_last_connected_profile_pc = theLastConnect->profileConnectedPC;
00153
00154 if (ids_t == theLastConnect->manualConnectType)
00155 {
00156 g_manual_connect_type = cmgrConnectIDS_e;
00157 }
00158 else if (pc_t == theLastConnect->manualConnectType)
00159 {
00160 g_manual_connect_type = cmgrConnectPCShare_e;
00161 }
00162 else
00163 {
00164 g_manual_connect_type = cmgrConnectUnknown_e;
00165 }
00166
00167 erRegFreeLastConnect(theLastConnect);
00168 }
00169 else
00170 {
00171 CN_LOGPRINTF("erRegGetLastConnect returns NULL");
00172 g_last_connected_profile_ids = -1;
00173 g_last_connected_profile_pc = -1;
00174 g_manual_connect_type = cmgrConnectUnknown_e;
00175 g_network_type = connection_undefined_t;
00176 }
00177
00178 g_last_connected_profile_ids_stored = g_last_connected_profile_ids;
00179 g_last_connected_profile_pc_stored = g_last_connected_profile_pc;
00180 g_manual_connect_type_stored = g_manual_connect_type;
00181
00182 CN_LOGPRINTF("leave: return [%d]", ret);
00183 return ret;
00184 }
00185
00186
00187 static void connect_data_calc_last_network_type(void)
00188 {
00189 int index = -1;
00190 connection_t networkType = wireless_t;
00191 const regNetworkProfile_t* pRegNetwork;
00192
00193
00194 switch ( connect_data_get_connect_type() )
00195 {
00196 case cmgrConnectIDS_e:
00197 index = g_last_connected_profile_ids;
00198 break;
00199 case cmgrConnectPCShare_e:
00200 index = g_last_connected_profile_pc;
00201 break;
00202 default:
00203 break;
00204 }
00205
00206 if (index != -1)
00207 {
00208 pRegNetwork = common_data_get_profiledata(index);
00209 if (pRegNetwork)
00210 {
00211 networkType = pRegNetwork->connection;
00212 }
00213 }
00214
00215 if (main_get_wifi_disabled() && networkType == wireless_t )
00216 {
00217
00218 networkType = wired_t;
00219 }
00220
00221 if (main_get_dialup_disabled() && networkType == dialup_t )
00222 {
00223
00224 networkType = wired_t;
00225 }
00226
00227 CN_LOGPRINTF("g_network_type[%d]", networkType);
00228 g_network_type = networkType;
00229 }
00230
00231 static gboolean connect_data_save_last_connect(void)
00232 {
00233 CN_LOGPRINTF("entry");
00234
00235 gboolean ret = FALSE;
00236 regLastConnect_t theLastConnect;
00237
00238 if (g_last_connected_profile_ids != g_last_connected_profile_ids_stored
00239 || g_last_connected_profile_pc != g_last_connected_profile_pc_stored
00240 || g_manual_connect_type != g_manual_connect_type_stored)
00241 {
00242 prepare_registry_write();
00243
00244
00245 theLastConnect.profileConnectedIDS = g_last_connected_profile_ids;
00246 theLastConnect.profileConnectedPC = g_last_connected_profile_pc;
00247 if (g_manual_connect_type == cmgrConnectIDS_e)
00248 {
00249 theLastConnect.manualConnectType = ids_t;
00250 }
00251 else if (g_manual_connect_type == cmgrConnectPCShare_e)
00252 {
00253 theLastConnect.manualConnectType = pc_t;
00254 }
00255 else
00256 {
00257 theLastConnect.manualConnectType = ids_t;
00258 }
00259
00260 ret = erRegSetLastConnect(&theLastConnect);
00261 if (ret)
00262 {
00263
00264 g_last_connected_profile_ids_stored = g_last_connected_profile_ids;
00265 g_last_connected_profile_pc_stored = g_last_connected_profile_pc;
00266 g_manual_connect_type_stored = g_manual_connect_type;
00267 }
00268
00269 do_registry_write();
00270 }
00271
00272 return ret;
00273 }
00274
00276
00277
00279 gint connect_data_get_last_connected_profile(void)
00280 {
00281 CN_LOGPRINTF("entry");
00282
00283 gint regIndex = -1;
00284 guint nRegNetworks;
00285
00286 nRegNetworks = common_data_get_n_profiles();
00287
00288 switch ( connect_data_get_connect_type() )
00289 {
00290 case cmgrConnectIDS_e:
00291 if ( g_last_connected_profile_ids >= 0
00292 && g_last_connected_profile_ids < nRegNetworks)
00293 {
00294 regIndex = g_last_connected_profile_ids;
00295 }
00296 break;
00297
00298 case cmgrConnectPCShare_e:
00299 if ( g_last_connected_profile_pc >= 0
00300 && g_last_connected_profile_pc < nRegNetworks)
00301 {
00302 regIndex = g_last_connected_profile_pc;
00303 }
00304 break;
00305
00306 default:
00307 ;
00308 }
00309
00310 CN_LOGPRINTF("Return [%d]", regIndex);
00311 return regIndex;
00312 }
00313
00314 gboolean connect_data_set_last_connected_profile(gint regIndex)
00315 {
00316 guint nRegNetworks;
00317 gboolean retVal = FALSE;
00318
00319 CN_LOGPRINTF("entry: regIndex [%d]", regIndex);
00320
00321 nRegNetworks = common_data_get_n_profiles();
00322
00323 switch ( connect_data_get_connect_type() )
00324 {
00325 case cmgrConnectIDS_e:
00326 if (regIndex >= 0 && regIndex < nRegNetworks)
00327 {
00328 g_last_connected_profile_ids = regIndex;
00329 retVal = TRUE;
00330 }
00331 break;
00332
00333 case cmgrConnectPCShare_e:
00334 if (regIndex >= 0 && regIndex < nRegNetworks)
00335 {
00336 g_last_connected_profile_pc = regIndex;
00337 retVal = TRUE;
00338 }
00339 break;
00340
00341 default:
00342 ;
00343 }
00344
00345 CN_LOGPRINTF("Return [%d]", retVal);
00346 return retVal;
00347 }
00348
00349 cmgrConnectType_t connect_data_get_connect_type(void)
00350 {
00351 CN_LOGPRINTF("entry");
00352
00353 if ( main_get_background() )
00354 {
00355 return g_background_connect_type;
00356 }
00357 else
00358 {
00359 return g_manual_connect_type;
00360 }
00361 }
00362
00363 gboolean connect_data_set_connect_type(cmgrConnectType_t type)
00364 {
00365 CN_LOGPRINTF("entry: type [%d]", type);
00366
00367 g_return_val_if_fail((type >= 0 && type < cmgrConnectUndef_e),
00368 FALSE);
00369
00370 if ( main_get_background() )
00371 {
00372 g_background_connect_type = type;
00373 }
00374 else
00375 {
00376 g_manual_connect_type = type;
00377 }
00378 return TRUE;
00379 }
00380
00381 connection_t connect_data_get_network_type(void)
00382 {
00383 CN_LOGPRINTF("ret=%d", g_network_type);
00384 return g_network_type;
00385 }
00386
00387 gboolean connect_data_set_network_type(connection_t type)
00388 {
00389 CN_LOGPRINTF("entry type[%d]", type);
00390
00391 g_return_val_if_fail((type >= 0 && type < connection_undefined_t),
00392 FALSE);
00393
00394 g_network_type = type;
00395
00396 return TRUE;
00397 }
00398
00399 gboolean connect_data_get_ac_wlan(void)
00400 {
00401 CN_LOGPRINTF("ret=%d", g_ac_wlan);
00402 return g_ac_wlan;
00403 }
00404
00405
00406 void connect_data_update_last_connected_profile_after_delete(gint delRegIndex)
00407 {
00408 guint nRegNetworks;
00409
00410 CN_LOGPRINTF("entry: delRegIndex [%d]", delRegIndex);
00411
00412 nRegNetworks = common_data_get_n_profiles();
00413 if (delRegIndex >= 0 && delRegIndex <= nRegNetworks)
00414 {
00415 CN_LOGPRINTF("before update: last_connected_profile_ids[%d]",
00416 g_last_connected_profile_ids);
00417
00418 CN_LOGPRINTF("before update: last_connected_profile_pc[%d]",
00419 g_last_connected_profile_pc);
00420
00421
00422 if (g_last_connected_profile_ids != -1)
00423 {
00424 if (delRegIndex < g_last_connected_profile_ids)
00425 {
00426 g_last_connected_profile_ids--;
00427 }
00428 else if (delRegIndex == g_last_connected_profile_ids)
00429 {
00430 g_last_connected_profile_ids = -1;
00431 }
00432 }
00433
00434
00435 if (g_last_connected_profile_pc != -1)
00436 {
00437 if (delRegIndex < g_last_connected_profile_pc)
00438 {
00439 g_last_connected_profile_pc--;
00440 }
00441 else if (delRegIndex == g_last_connected_profile_pc)
00442 {
00443 g_last_connected_profile_pc = -1;
00444 }
00445 }
00446
00447 CN_LOGPRINTF("after update: last_connected_profile_pc[%d]",
00448 g_last_connected_profile_pc);
00449
00450 CN_LOGPRINTF("after update: last_connected_profile_ids[%d]",
00451 g_last_connected_profile_ids);
00452
00453 }
00454 }
00455
00457
00459 const regPCProfile_t* connect_data_get_pcsharedata(void)
00460 {
00461 CN_LOGPRINTF("entry");
00462
00463 const regPCProfile_t* ret = common_data_get_pcsharedata(0);
00464
00465 CN_LOGPRINTF("return ret [%p]", ret);
00466
00467 return ret;
00468 }
00470
00472 gchar* connect_data_get_ecd_url(void)
00473 {
00474 CN_LOGPRINTF("entry");
00475
00476 return g_strdup(REDIRECT_URL);
00477 }
00478
00480
00481
00482
00483
00484
00485
00486
00487
00488
00490 void connect_data_init_network_profiles(connection_t networkType,
00491 network_spec_t* pScanNetworks,
00492 int nScanNetworks)
00493 {
00494 CN_LOGPRINTF("entry networkType[%d]pScanNetworks[%p]nScanNetworks[%d]",
00495 networkType, pScanNetworks, nScanNetworks);
00496
00497
00498 connect_data_destroy_network_profiles();
00499
00500 switch (networkType)
00501 {
00502 case wireless_t:
00503 get_wireless_profiles(pScanNetworks, nScanNetworks);
00504 break;
00505 case wired_t:
00506 case dialup_t:
00507 g_n_network_profiles = common_data_init_network_profiles(networkType,
00508 &g_network_profiles);
00509 break;
00510 default:
00511 CN_WARNPRINTF("unknown networkType[%d]", networkType);
00512 break;
00513 }
00514 }
00515
00516 void connect_data_destroy_network_profiles(void)
00517 {
00518 CN_LOGPRINTF("entry");
00519
00520 common_data_destroy_network_profiles(g_network_profiles,
00521 g_n_network_profiles);
00522 g_network_profiles = NULL;
00523 g_n_network_profiles = 0;
00524 }
00525
00526 int connect_data_get_n_network_profiles(void)
00527 {
00528 CN_LOGPRINTF("entry [%d]", g_n_network_profiles);
00529
00530 return g_n_network_profiles;
00531 }
00532
00533 const networkProfile_t* connect_data_get_network_profile(int profileIndex)
00534 {
00535 CN_LOGPRINTF("entry profileIndex[%d]", profileIndex);
00536
00537 networkProfile_t* ret = NULL;
00538
00539 g_return_val_if_fail(g_network_profiles != NULL, NULL);
00540 g_return_val_if_fail(profileIndex < g_n_network_profiles, NULL);
00541
00542 ret = &g_network_profiles[profileIndex];
00543
00544 CN_LOGPRINTF("ret=%p", ret);
00545
00546 return ret;
00547 }
00548
00549 static void get_wireless_profiles(network_spec_t* pScanNetworks,
00550 int nScanNetworks)
00551 {
00552 int i, j, regIndex;
00553 const regNetworkProfile_t* pRegNetwork;
00554 networkProfile_t* pNetwork;
00555
00556 CN_LOGPRINTF("pScanNetworks[%p], nScanNetworks[%d]",
00557 pScanNetworks, nScanNetworks);
00558
00559
00560 if ((pScanNetworks == NULL) || (nScanNetworks == 0))
00561 {
00562 CN_WARNPRINTF("No wireless network profiles scanned "
00563 "automatically. ");
00564
00565
00566 g_n_network_profiles = 0;
00567 g_network_profiles = NULL;
00568 }
00569 else if ((common_data_get_n_profiles() == 0))
00570 {
00571 CN_WARNPRINTF("No any network profiles in the registry.");
00572
00573 g_n_network_profiles = nScanNetworks;
00574 g_network_profiles = g_new0(networkProfile_t, nScanNetworks);
00575 g_return_if_fail(g_network_profiles != NULL);
00576
00577 for (i = 0; i < nScanNetworks; i++)
00578 {
00579 pNetwork = &g_network_profiles[i];
00580 pNetwork->scanSettings = dup_network_spec(&pScanNetworks[i]);
00581 pNetwork->regSettingsList = NULL;
00582 pNetwork->regIndexList = NULL;
00583 pNetwork->nRegProfiles = 0;
00584 pNetwork->nActiveIndex = -1;
00585 }
00586 }
00587 else
00588 {
00589 CN_LOGPRINTF("Found profiles in registry "
00590 "and profiles scanned automatically.");
00591
00592 g_n_network_profiles = nScanNetworks;
00593 g_network_profiles = g_new0(networkProfile_t, nScanNetworks);
00594 g_return_if_fail(g_network_profiles != NULL);
00595
00596 for (i = 0; i < nScanNetworks; i++)
00597 {
00598 pNetwork = &g_network_profiles[i];
00599 pNetwork->scanSettings = dup_network_spec(&pScanNetworks[i]);
00600 pNetwork->nRegProfiles = get_regindices_by_ssid(pScanNetworks[i].ssid,
00601 &pNetwork->regIndexList);
00602 if (pNetwork->nRegProfiles > 0)
00603 {
00604 pNetwork->regSettingsList = g_new0(regNetworkProfile_t*,
00605 pNetwork->nRegProfiles);
00606 g_return_if_fail(pNetwork->regSettingsList != NULL);
00607
00608 for (j = 0; j < pNetwork->nRegProfiles; j++)
00609 {
00610 regIndex = pNetwork->regIndexList[j];
00611 pRegNetwork = common_data_get_profiledata(regIndex);
00612 pNetwork->regSettingsList[j] = erRegDupNetworkProfile(pRegNetwork);
00613 }
00614 pNetwork->nActiveIndex = 0;
00615 }
00616 else
00617 {
00618 pNetwork->regSettingsList = NULL;
00619 pNetwork->regIndexList = NULL;
00620 pNetwork->nRegProfiles = 0;
00621 pNetwork->nActiveIndex = -1;
00622 }
00623 }
00624
00625
00626 qsort(g_network_profiles, g_n_network_profiles,
00627 sizeof(networkProfile_t), compare_wireless_profiles);
00628 }
00629 }
00630
00631
00632
00633 static int get_regindices_by_ssid(const char* ssid, int** indexList)
00634 {
00635 CN_LOGPRINTF("entry ssid=%s", ssid);
00636
00637 const regNetworkProfile_t* pRegNetwork;
00638 int nRegNetworks;
00639 int i;
00640 int counter = 0;
00641 int *regIndices = NULL;
00642
00643 nRegNetworks = common_data_get_n_profiles();
00644
00645 for (i = 0; i < nRegNetworks; i++)
00646 {
00647 pRegNetwork = common_data_get_profiledata(i);
00648 if (pRegNetwork
00649 && pRegNetwork->wirelessSettings
00650 && pRegNetwork->wirelessSettings->SSID
00651 && ssid
00652 && !strcmp(pRegNetwork->wirelessSettings->SSID, ssid))
00653 {
00654 counter++;
00655 }
00656 }
00657
00658 if (counter > 0)
00659 {
00660
00661 regIndices = g_new0(int, counter);
00662 g_return_val_if_fail(regIndices != NULL, 0);
00663
00664
00665 counter = 0;
00666 for (i = 0; i < nRegNetworks; i++)
00667 {
00668 pRegNetwork = common_data_get_profiledata(i);
00669 if (pRegNetwork
00670 && pRegNetwork->wirelessSettings
00671 && pRegNetwork->wirelessSettings->SSID
00672 && ssid
00673 && !strcmp(pRegNetwork->wirelessSettings->SSID, ssid))
00674 {
00675 regIndices[counter] = i;
00676 counter++;
00677 }
00678 }
00679 }
00680
00681 CN_LOGPRINTF("leave: counter=%d, regIndices=%p", counter, regIndices);
00682 *indexList = regIndices;
00683 return counter;
00684 }
00685
00686
00687 static int compare_wireless_profiles(const void * p1, const void * p2)
00688 {
00689 networkProfile_t *pNetwork1, * pNetwork2;
00690 int ret = 0;
00691
00692 pNetwork1 = (networkProfile_t*)p1;
00693 pNetwork2 = (networkProfile_t*)p2;
00694
00695 ret = (pNetwork1->nRegProfiles - pNetwork2->nRegProfiles);
00696 CN_LOGPRINTF("ret=%d", ret);
00697
00698 ret = 0 - ret;
00699 return ret;
00700 }
00701
00702
00703 int connect_data_get_profile_index(int regIndex)
00704 {
00705 int profileIndex = -1;
00706
00707 profileIndex = common_data_get_profile_index(g_network_profiles,
00708 g_n_network_profiles,
00709 regIndex);
00710
00711 return profileIndex;
00712 }
00713
00714 int connect_data_get_reg_index(int profileIndex)
00715 {
00716 CN_LOGPRINTF("entry profileIndex[%d]", profileIndex);
00717
00718 int regIndex = -1;
00719
00720 regIndex = common_data_get_reg_index(g_network_profiles,
00721 g_n_network_profiles,
00722 profileIndex);
00723 return regIndex;
00724 }
00725
00726 gboolean connect_data_reach_max_profiles(void)
00727 {
00728 CN_LOGPRINTF("entry");
00729
00730 connection_t networkType;
00731 gboolean reachMax = FALSE;
00732
00733 networkType = connect_data_get_network_type();
00734 if ( ((networkType == wired_t)
00735 && common_data_reach_max_profiles(wired_t))
00736 || ((networkType == wireless_t)
00737 && common_data_reach_max_profiles(wireless_t))
00738 || ((networkType == dialup_t)
00739 && common_data_reach_max_profiles(dialup_t)) )
00740 {
00741 reachMax = TRUE;
00742 }
00743
00744 CN_LOGPRINTF("return reachMax=%d", reachMax);
00745 return reachMax;
00746 }
00747
00748
00749 void connect_data_update_network_profile_with_last(networkProfile_t* pNetwork)
00750 {
00751 CN_LOGPRINTF("entry pNetwork[%p]", pNetwork);
00752
00753 int nRegProfiles;
00754 const regNetworkProfile_t* pRegNetwork;
00755
00756 g_return_if_fail(pNetwork != NULL);
00757
00758 nRegProfiles = common_data_get_n_profiles();
00759 g_return_if_fail(nRegProfiles > 0);
00760
00761 pRegNetwork = common_data_get_profiledata(nRegProfiles-1);
00762 g_return_if_fail(pRegNetwork != NULL);
00763
00764 pNetwork->nRegProfiles = 1;
00765
00766 pNetwork->regIndexList = g_new0(int, 1);
00767 pNetwork->regIndexList[0] = nRegProfiles - 1;
00768
00769 pNetwork->regSettingsList = g_new0(regNetworkProfile_t*, 1);
00770 pNetwork->regSettingsList[0] = erRegDupNetworkProfile(pRegNetwork);
00771
00772 pNetwork->nActiveIndex = 0;
00773 }
00774
00775 regNetworkProfile_t* network_spec_to_reg_network(network_spec_t* scanSettings)
00776 {
00777 regNetworkProfile_t* regSettings = NULL;
00778
00779 if (scanSettings)
00780 {
00781 regSettings = g_new0(regNetworkProfile_t, 1);
00782 if (regSettings)
00783 {
00784 regSettings->name = g_strdup(scanSettings->ssid);
00785 regSettings->connection = wireless_t;
00786 regSettings->proxy = FALSE;
00787 regSettings->addressMode = dhcp_t;
00788 regSettings->wirelessSettings = g_new0(regWirelessSetting_t, 1);
00789 regSettings->wirelessSettings->SSID = g_strdup(scanSettings->ssid);
00790 regSettings->wirelessSettings->encrType = scanSettings->encryption;
00791 regSettings->wirelessSettings->encrKey = g_strdup("");
00792 regSettings->dialupSettings = NULL;
00793 regSettings->proxySettings = NULL;
00794 regSettings->ipSettings = NULL;
00795 }
00796 }
00797
00798 return regSettings;
00799 }
00800
00801 char* connect_data_get_hidden_ssid_list(void)
00802 {
00803 char* ssidList;
00804 int len;
00805 gboolean first;
00806 int i, nRegNetworks;
00807 const regNetworkProfile_t* pRegNetwork;
00808
00809
00810 nRegNetworks = common_data_get_n_profiles();
00811
00812
00813 len = 0;
00814 first = TRUE;
00815 for (i = 0; i < nRegNetworks; i++)
00816 {
00817 pRegNetwork = common_data_get_profiledata(i);
00818 if (pRegNetwork
00819 && pRegNetwork->connection == wireless_t
00820 && pRegNetwork->wirelessSettings
00821 && (pRegNetwork->wirelessSettings->broadcast == FALSE)
00822 && pRegNetwork->wirelessSettings->SSID)
00823 {
00824 if (!first)
00825 {
00826
00827 len++;
00828 }
00829
00830 len += strlen(pRegNetwork->wirelessSettings->SSID);
00831 first = FALSE;
00832 }
00833 }
00834
00835 len += 1;
00836
00837
00838 ssidList = g_new0(char, len);
00839 g_return_val_if_fail(ssidList != NULL, 0);
00840
00841 first = TRUE;
00842
00843 for (i = 0; i < nRegNetworks; i++)
00844 {
00845 pRegNetwork = common_data_get_profiledata(i);
00846 if (pRegNetwork
00847 && pRegNetwork->connection == wireless_t
00848 && pRegNetwork->wirelessSettings
00849 && (pRegNetwork->wirelessSettings->broadcast == FALSE)
00850 && pRegNetwork->wirelessSettings->SSID)
00851 {
00852 if (!first)
00853 {
00854
00855 strcat(ssidList, " ");
00856 }
00857
00858
00859 strcat(ssidList, pRegNetwork->wirelessSettings->SSID);
00860
00861 first = FALSE;
00862 }
00863 }
00864
00865 CN_LOGPRINTF("return ssidList=%s", ssidList);
00866 return ssidList;
00867 }
00868
00869 gboolean connect_data_select_next_regprofile(int profileIndex)
00870 {
00871 networkProfile_t *pNetwork;
00872 gboolean selected = FALSE;
00873
00874 pNetwork = (networkProfile_t*)connect_data_get_network_profile(profileIndex);
00875 if (pNetwork
00876 && pNetwork->nRegProfiles > 0
00877 && (pNetwork->nActiveIndex >= 0
00878 && pNetwork->nActiveIndex < pNetwork->nRegProfiles))
00879 {
00880 if ((pNetwork->nActiveIndex+1) < pNetwork->nRegProfiles)
00881 {
00882 pNetwork->nActiveIndex += 1;
00883 selected = TRUE;
00884 }
00885 }
00886
00887 return selected;
00888 }
00889