connectionMgr/inc/connectScreenData.h File Reference

connectionMgr - connect screen data handling More...

#include <glib.h>
#include <liberregxml/erregapi.h>
#include "commonData.h"
#include "scanThread.h"

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void connect_data_init (void)
void connect_data_destroy (void)
gboolean connect_data_store (void)
gint connect_data_get_last_connected_profile (void)
gboolean connect_data_set_last_connected_profile (gint regIndex)
cmgrConnectType_t connect_data_get_connect_type (void)
gboolean connect_data_set_connect_type (cmgrConnectType_t type)
connection_t connect_data_get_network_type (void)
gboolean connect_data_set_network_type (connection_t type)
gboolean connect_data_get_ac_wlan (void)
void connect_data_update_last_connected_profile_after_delete (gint delRegIndex)
const regPCProfile_tconnect_data_get_pcsharedata (void)
gchar * connect_data_get_ecd_url (void)
void connect_data_init_network_profiles (connection_t networkType, network_spec_t *pScanNetworks, int nScanNetworks)
void connect_data_destroy_network_profiles (void)
int connect_data_get_n_network_profiles (void)
const networkProfile_tconnect_data_get_network_profile (int profileIndex)
int connect_data_get_profile_index (int regIndex)
int connect_data_get_reg_index (int profileIndex)
gboolean connect_data_reach_max_profiles (void)
void connect_data_update_network_profile_with_last (networkProfile_t *pNetwork)
regNetworkProfile_tnetwork_spec_to_reg_network (network_spec_t *scanSettings)
char * connect_data_get_hidden_ssid_list (void)
gboolean connect_data_select_next_regprofile (int profileIndex)


Detailed Description

connectionMgr - connect screen data handling

Copyright (C) 2007 iRex Technologies BV.

Definition in file connectScreenData.h.


Function Documentation

void connect_data_destroy ( void   ) 

Definition at line 76 of file connectScreenData.c.

00077 {
00078     CN_LOGPRINTF("entry");
00079 }

void connect_data_destroy_network_profiles ( void   ) 

Definition at line 516 of file connectScreenData.c.

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 }

Here is the call graph for this function:

gboolean connect_data_get_ac_wlan ( void   ) 

Definition at line 399 of file connectScreenData.c.

00400 {
00401     CN_LOGPRINTF("ret=%d", g_ac_wlan);
00402     return g_ac_wlan;
00403 }

cmgrConnectType_t connect_data_get_connect_type ( void   ) 

Definition at line 349 of file connectScreenData.c.

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 }

Here is the call graph for this function:

gchar* connect_data_get_ecd_url ( void   ) 

Definition at line 472 of file connectScreenData.c.

00473 {
00474     CN_LOGPRINTF("entry");
00475 
00476     return g_strdup(REDIRECT_URL);
00477 }

char* connect_data_get_hidden_ssid_list ( void   ) 

Definition at line 801 of file connectScreenData.c.

00802 {
00803     char*    ssidList;
00804     int      len;
00805     gboolean first;
00806     int      i, nRegNetworks;
00807     const regNetworkProfile_t* pRegNetwork; 
00808 
00809     // get how many profiles in the registry
00810     nRegNetworks = common_data_get_n_profiles();
00811 
00812     // get the len of ssidList
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                 // the number of spaces for the seperator
00827                 len++;
00828             }
00829             // add the length of each ssid 
00830             len += strlen(pRegNetwork->wirelessSettings->SSID);
00831             first = FALSE;
00832         }
00833     }
00834     // for the '\0'
00835     len += 1; 
00836     
00837     // malloc the memory
00838     ssidList = g_new0(char, len);
00839     g_return_val_if_fail(ssidList != NULL, 0);
00840 
00841     first = TRUE;
00842     // set the value of ssidList
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                 // append the seperator
00855                 strcat(ssidList, " ");
00856             }
00857 
00858             // append each ssid
00859             strcat(ssidList, pRegNetwork->wirelessSettings->SSID);
00860 
00861             first = FALSE;
00862         }
00863     }
00864 
00865     CN_LOGPRINTF("return ssidList=%s", ssidList);
00866     return ssidList;
00867 }

Here is the call graph for this function:

gint connect_data_get_last_connected_profile ( void   ) 

Definition at line 279 of file connectScreenData.c.

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             ; // ignore
00308     }
00309 
00310     CN_LOGPRINTF("Return [%d]", regIndex);
00311     return regIndex;
00312 }

Here is the call graph for this function:

int connect_data_get_n_network_profiles ( void   ) 

Definition at line 526 of file connectScreenData.c.

00527 {
00528     CN_LOGPRINTF("entry [%d]", g_n_network_profiles);
00529 
00530     return g_n_network_profiles;
00531 }

const networkProfile_t* connect_data_get_network_profile ( int  profileIndex  ) 

Definition at line 533 of file connectScreenData.c.

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 }

connection_t connect_data_get_network_type ( void   ) 

Definition at line 381 of file connectScreenData.c.

00382 {
00383     CN_LOGPRINTF("ret=%d", g_network_type);
00384     return g_network_type;
00385 }

const regPCProfile_t* connect_data_get_pcsharedata ( void   ) 

Definition at line 459 of file connectScreenData.c.

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 }

Here is the call graph for this function:

int connect_data_get_profile_index ( int  regIndex  ) 

Definition at line 703 of file connectScreenData.c.

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 }

Here is the call graph for this function:

int connect_data_get_reg_index ( int  profileIndex  ) 

Definition at line 714 of file connectScreenData.c.

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 }

Here is the call graph for this function:

void connect_data_init ( void   ) 

Definition at line 66 of file connectScreenData.c.

Here is the call graph for this function:

void connect_data_init_network_profiles ( connection_t  networkType,
network_spec_t pScanNetworks,
int  nScanNetworks 
)

Definition at line 490 of file connectScreenData.c.

00493 {
00494     CN_LOGPRINTF("entry networkType[%d]pScanNetworks[%p]nScanNetworks[%d]",
00495                   networkType, pScanNetworks, nScanNetworks);
00496  
00497      // empty the old results
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 }

Here is the call graph for this function:

gboolean connect_data_reach_max_profiles ( void   ) 

Definition at line 726 of file connectScreenData.c.

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 }

Here is the call graph for this function:

gboolean connect_data_select_next_regprofile ( int  profileIndex  ) 

Definition at line 869 of file connectScreenData.c.

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 }

Here is the call graph for this function:

gboolean connect_data_set_connect_type ( cmgrConnectType_t  type  ) 

Definition at line 363 of file connectScreenData.c.

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 }

Here is the call graph for this function:

gboolean connect_data_set_last_connected_profile ( gint  regIndex  ) 

Definition at line 314 of file connectScreenData.c.

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             ; // ignore
00343     }
00344 
00345     CN_LOGPRINTF("Return [%d]", retVal);
00346     return retVal;
00347 }

Here is the call graph for this function:

gboolean connect_data_set_network_type ( connection_t  type  ) 

Definition at line 387 of file connectScreenData.c.

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 }

gboolean connect_data_store ( void   ) 

Definition at line 81 of file connectScreenData.c.

00082 {
00083     gboolean ret = TRUE;  // TRUE = ok, so far
00084 
00085     if (main_get_connect_type() == cmgrConnectUnknown_e)
00086     {
00087         // connect type NOT enforced by command line: save connect type
00088         ret = connect_data_save_last_connect();
00089     }
00090     else
00091     {
00092         // connect type enforced by command line option: do NOT save
00093     }
00094 
00095     CN_LOGPRINTF("ret=%d", ret);
00096     return ret;
00097 }

Here is the call graph for this function:

void connect_data_update_last_connected_profile_after_delete ( gint  delRegIndex  ) 

Definition at line 406 of file connectScreenData.c.

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         // update the last connected profile to ids
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         // update the last connected profile to pc
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 }

Here is the call graph for this function:

void connect_data_update_network_profile_with_last ( networkProfile_t pNetwork  ) 

Definition at line 749 of file connectScreenData.c.

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     // regIndexList
00766     pNetwork->regIndexList = g_new0(int, 1);
00767     pNetwork->regIndexList[0] = nRegProfiles - 1;
00768     // regSettingsList 
00769     pNetwork->regSettingsList = g_new0(regNetworkProfile_t*, 1);
00770     pNetwork->regSettingsList[0] = erRegDupNetworkProfile(pRegNetwork); 
00771     // nActiveIndex
00772     pNetwork->nActiveIndex = 0;
00773 }

Here is the call graph for this function:

regNetworkProfile_t* network_spec_to_reg_network ( network_spec_t scanSettings  ) 

Definition at line 775 of file connectScreenData.c.

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 }


Generated on Sun Dec 14 17:15:31 2008 by  doxygen 1.5.6