connectionMgr/inc/connectScan.h File Reference

connectionMgr - for wireless, using scanThread to scan the networks for the others, get the networks from registry More...

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

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

Go to the source code of this file.

Classes

struct  scanContext_t

Typedefs

typedef void scan_done_t (connection_t type, network_spec_t *pNetworks, int nNetworks)
typedef void scan_done_after_t (void)

Enumerations

enum  scanMode_t { backgroundScan_e = 0, connectScan_e, editScan_e, undefScanMode_e }
enum  scanStatus_t {
  scanRunning_e = 0, rescanNeed_e, scanOk_e, scanAborting_e,
  undefScanStatus_e
}

Functions

scanContext_tconnect_scan_ctxt_new (void)
void connect_scan_ctxt_set_mode (scanContext_t *ctxt, scanMode_t mode)
void connect_scan_ctxt_set_network_type (scanContext_t *ctxt, connection_t networkType)
void connect_scan_ctxt_set_done_callbacks (scanContext_t *ctxt, scan_done_t *scan_done, scan_done_after_t *scan_done_after)
void connect_scan_ctxt_set_ssidlist (scanContext_t *ctxt, gchar *ssidList)
void connect_scan_ctxt_set_max_networks (scanContext_t *ctxt, int maxNetworks)
void connect_scan_ctxt_destory (scanContext_t *ctxt)
void connect_scan (scanContext_t *ctxt, gboolean delay)
void connect_scan_abort (scanContext_t *ctxt)
gboolean connect_scan_freeze_ui (scanContext_t *ctxt)


Detailed Description

connectionMgr - for wireless, using scanThread to scan the networks for the others, get the networks from registry

Copyright (C) 2007 iRex Technologies BV.

Definition in file connectScan.h.


Typedef Documentation

typedef void scan_done_after_t(void)

Definition at line 56 of file connectScan.h.

typedef void scan_done_t(connection_t type, network_spec_t *pNetworks, int nNetworks)

Definition at line 53 of file connectScan.h.


Enumeration Type Documentation

enum scanMode_t

Enumerator:
backgroundScan_e 
connectScan_e 
editScan_e 
undefScanMode_e 

Definition at line 36 of file connectScan.h.

00037 {
00038     backgroundScan_e = 0,
00039     connectScan_e,
00040     editScan_e,
00041     undefScanMode_e
00042 }scanMode_t;

Enumerator:
scanRunning_e 
rescanNeed_e 
scanOk_e 
scanAborting_e 
undefScanStatus_e 

Definition at line 44 of file connectScan.h.

00045 {
00046     scanRunning_e = 0,
00047     rescanNeed_e,       // no results returned, probably need to rescan
00048     scanOk_e,           // results returned
00049     scanAborting_e,
00050     undefScanStatus_e
00051 }scanStatus_t;


Function Documentation

void connect_scan ( scanContext_t ctxt,
gboolean  delay 
)

Definition at line 226 of file connectScan.c.

00227 {
00228     scanMode_t   mode;
00229     connection_t type;
00230 
00231     CN_LOGPRINTF("entry");
00232 
00233     g_return_if_fail(ctxt != NULL);
00234     
00235     mode = ctxt->mode;
00236     type = ctxt->networkType;
00237     if ((mode < 0) || (mode >= undefScanMode_e) 
00238         || (type < 0) || (type >= connection_undefined_t))
00239     {
00240         CN_ERRORPRINTF("Invalid arguments: mode[%d] type[%d]", mode, type);
00241         return;
00242     }
00243 
00244     if (ctxt->scanNetworks)
00245     {
00246         CN_WARNPRINTF("Please wait while scanning");
00247         return;
00248     }
00249 
00250     if (delay)
00251     {
00252         if (ctxt->scanTimeoutId > 0)
00253         {
00254             CN_LOGPRINTF("remove the old timeout function for scaning");
00255             g_source_remove(ctxt->scanTimeoutId);
00256             ctxt->scanTimeoutId = 0;
00257         }
00258 
00259         // begin to scan after 5s timeout
00260         if (ctxt->networkType == wireless_t)
00261         {
00262             ctxt->scanTimeoutId = g_timeout_add(200, 
00263                                                 connect_scan_start, 
00264                                                 (gpointer)ctxt);
00265         }
00266         else
00267         {
00268             ctxt->scanTimeoutId = g_timeout_add(5000, 
00269                                                 connect_scan_start, 
00270                                                 (gpointer)ctxt);
00271         }
00272     }
00273     else
00274     {
00275         connect_scan_start((gpointer)ctxt);
00276     }
00277 }

Here is the call graph for this function:

void connect_scan_abort ( scanContext_t ctxt  ) 

Definition at line 377 of file connectScan.c.

00378 {
00379     CN_LOGPRINTF("entry");
00380 
00381     g_return_if_fail(ctxt != NULL);
00382 
00383     if (ctxt->scanNetworks)
00384     {
00385         CN_WARNPRINTF("Abort scanning...");
00386 
00387         if (ctxt->mode != backgroundScan_e)
00388         {
00389             erbusy_blink();
00390         }
00391 
00392         if (ctxt->networkType == wireless_t)
00393         {
00394             // stop the scan thread
00395             scanThread_stop();
00396 
00397             // wait for scanThread done
00398             ctxt->scanAborting = TRUE;
00399             g_timeout_add(200, delay_connect_scan_abort, (gpointer)ctxt);
00400         }
00401         else
00402         {
00403             // set the flag back to FALSE
00404             ctxt->scanNetworks = FALSE;
00405         }
00406 
00407         if (ctxt->mode != backgroundScan_e)
00408         {
00409             erbusy_off();
00410         }
00411     }
00412 }

Here is the call graph for this function:

void connect_scan_ctxt_destory ( scanContext_t ctxt  ) 

Definition at line 143 of file connectScan.c.

00144 {
00145     if (ctxt)
00146     {
00147         if (ctxt->scanParms)
00148         {
00149             /*
00150             if (ctxt->scanParms->scanStatus)
00151             {
00152                 gtk_widget_destroy(ctxt->scanParms->scanStatus);
00153             }
00154             */
00155            
00156             if (ctxt->scanParms->ssid)
00157             {
00158                 g_free(ctxt->scanParms->ssid);
00159             }
00160         }
00161 
00162         connect_scan_ctxt_destory_results(ctxt);
00163 
00164         g_free(ctxt->scanParms);
00165         g_free(ctxt);
00166     }
00167 }

Here is the call graph for this function:

scanContext_t* connect_scan_ctxt_new ( void   ) 

Definition at line 49 of file connectScan.c.

00050 {
00051     scanContext_t* ctxt;
00052     GtkWidget* scanStatus;
00053 
00054     ctxt = g_new0(scanContext_t, 1);
00055     g_assert(ctxt != NULL);
00056 
00057     // initilize the scanParams
00058     ctxt->scanParms = g_new0(scan_thread_parms, 1);
00059     g_assert(ctxt->scanParms != NULL);
00060 
00061     scanStatus = gtk_label_new("scan-idle");
00062     g_signal_connect(scanStatus, "notify", 
00063             G_CALLBACK(on_scan_status_changed), ctxt);
00064     ctxt->scanParms->scanStatus = scanStatus;
00065 
00066     // set the default values
00067     connect_scan_ctxt_set_mode(ctxt, undefScanMode_e);
00068     connect_scan_ctxt_set_network_type(ctxt, connection_undefined_t);
00069     connect_scan_ctxt_set_done_callbacks(ctxt, NULL, NULL);
00070 
00071     connect_scan_ctxt_set_ssidlist(ctxt, "");
00072     connect_scan_ctxt_set_max_networks(ctxt, MAX_PROFILES_PER_PAGE);
00073 
00074     // the other values are set to be NULL or zero implicitly by g_new0
00075 
00076     return ctxt;
00077 }

Here is the call graph for this function:

void connect_scan_ctxt_set_done_callbacks ( scanContext_t ctxt,
scan_done_t scan_done,
scan_done_after_t scan_done_after 
)

Definition at line 96 of file connectScan.c.

00099 {
00100     if (ctxt)
00101     {
00102         ctxt->scan_done = scan_done;
00103         ctxt->scan_done_after = scan_done_after;
00104     }
00105 }

void connect_scan_ctxt_set_max_networks ( scanContext_t ctxt,
int  maxNetworks 
)

Definition at line 119 of file connectScan.c.

00121 {
00122     network_spec_t *networks, *pNetwork;
00123     int             i;
00124 
00125     if (ctxt && ctxt->scanParms && (maxNetworks > 0))
00126     {
00127         // destory the old memory for networks
00128         connect_scan_ctxt_destory_results(ctxt);
00129 
00130         // malloc the new memory for networks
00131         networks = g_new0(network_spec_t, maxNetworks);
00132         g_assert(networks != NULL);
00133         for (i = 0; i < maxNetworks; i++)
00134         {
00135             pNetwork = &networks[i];
00136             pNetwork->encryption = encr_none_t;
00137         }
00138         ctxt->scanParms->networks = networks;
00139         ctxt->scanParms->networks_num = maxNetworks;
00140     }
00141 }

Here is the call graph for this function:

void connect_scan_ctxt_set_mode ( scanContext_t ctxt,
scanMode_t  mode 
)

Definition at line 79 of file connectScan.c.

00080 {
00081     if (ctxt && (mode >= 0) && (mode < undefScanMode_e))
00082     {
00083         ctxt->mode = mode;
00084     }
00085 }

void connect_scan_ctxt_set_network_type ( scanContext_t ctxt,
connection_t  networkType 
)

Definition at line 87 of file connectScan.c.

00089 {
00090     if (ctxt && (networkType >= 0) && (networkType < connection_undefined_t))
00091     {
00092         ctxt->networkType = networkType;
00093     }
00094 }

void connect_scan_ctxt_set_ssidlist ( scanContext_t ctxt,
gchar *  ssidList 
)

Definition at line 107 of file connectScan.c.

00108 {
00109     if (ctxt && ctxt->scanParms && ssidList)
00110     {
00111         if (ctxt->scanParms->ssid)
00112         {
00113             g_free(ctxt->scanParms->ssid);
00114         }
00115         ctxt->scanParms->ssid = g_strdup(ssidList);
00116     }
00117 }

gboolean connect_scan_freeze_ui ( scanContext_t ctxt  ) 

Definition at line 343 of file connectScan.c.

00344 {
00345     g_return_val_if_fail(ctxt != NULL, FALSE);
00346 
00347     CN_LOGPRINTF("return freeze = %d", ctxt->scanAborting);
00348     return ctxt->scanAborting;
00349 }


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