connectionMgr/inc/scanThread.h File Reference

Scan for available wireless networks. More...

#include <gtk/gtk.h>
#include <glib.h>
#include <liberregxml/erregapi.h>

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

Go to the source code of this file.

Classes

struct  network_spec_t
struct  scan_thread_parms

Enumerations

enum  scan_status_t { SCAN_IDLE = 0, SCAN_RUNNING, SCAN_ABORTING, SCAN_UNDEFINED }

Functions

gboolean scanThread_start (scan_thread_parms *scan_parms)
gboolean scanThread_stop (void)
gboolean scanThread_wait (int timeout_sec)
gboolean scanThread_stopped (void)
void free_network_spec (network_spec_t *pNetwork)
network_spec_tdup_network_spec (network_spec_t *pNetwork)


Detailed Description

Scan for available wireless networks.

Copyright (C) 2007 iRex Technologies BV.

Definition in file scanThread.h.


Enumeration Type Documentation

Enumerator:
SCAN_IDLE 
SCAN_RUNNING 
SCAN_ABORTING 
SCAN_UNDEFINED 

Definition at line 33 of file scanThread.h.

00034         {
00035             SCAN_IDLE = 0, // scan-thread not running
00036             SCAN_RUNNING,  // scan-thread started and connecting to server
00037             SCAN_ABORTING, // scan-thread running but not wanted anymore
00038             SCAN_UNDEFINED
00039         } scan_status_t;


Function Documentation

network_spec_t* dup_network_spec ( network_spec_t pNetwork  ) 

Definition at line 437 of file scanThread.c.

00438 {
00439     network_spec_t *pDupNetwork = NULL;
00440     if (pNetwork)
00441     {
00442         pDupNetwork = g_new0(network_spec_t, 1);
00443         if (pDupNetwork)
00444         {
00445             pDupNetwork->ssid = g_strdup(pNetwork->ssid);
00446             pDupNetwork->encryption = pNetwork->encryption;
00447             pDupNetwork->quality = pNetwork->quality;
00448         }
00449     }
00450     return pDupNetwork;
00451 }

void free_network_spec ( network_spec_t pNetwork  ) 

Definition at line 428 of file scanThread.c.

00429 {
00430     if (pNetwork)
00431     {
00432         g_free(pNetwork->ssid);
00433         g_free(pNetwork);
00434     }
00435 }

gboolean scanThread_start ( scan_thread_parms scan_parms  ) 

Definition at line 236 of file scanThread.c.

00237 {
00238     GThread* thread = NULL;
00239     GError*  error = NULL;
00240 
00241     CN_LOGPRINTF("entry");
00242     if (g_scan_thread)
00243     {
00244         CN_ERRORPRINTF("scan thread already running");
00245         return FALSE;
00246     }
00247 
00248     // create the scan thread
00249     g_scan_abort = FALSE;
00250     thread = g_thread_create(scanThread, scan_parms, FALSE, &error);
00251     if (error != NULL)
00252     {
00253         CN_ERRORPRINTF("Failed to create scan thread - %s [%d]", 
00254                        error->message, error->code);
00255         g_free(error);
00256         error = NULL;
00257     }
00258     else
00259     {
00260         g_scan_thread = thread;
00261     }
00262 
00263     return TRUE;
00264 }

Here is the call graph for this function:

gboolean scanThread_stop ( void   ) 

Definition at line 267 of file scanThread.c.

00268 {
00269     CN_LOGPRINTF("entry");
00270 
00271     if (g_scan_thread)
00272     {
00273         // stop the scan thread
00274         g_scan_abort = TRUE;
00275 
00276         return TRUE;
00277     }
00278     else
00279     {
00280         CN_ERRORPRINTF("scan thread not running");
00281         return FALSE;
00282     }
00283 }

gboolean scanThread_stopped ( void   ) 

Definition at line 309 of file scanThread.c.

00310 {
00311     CN_LOGPRINTF("entry");
00312 
00313     if (g_scan_thread)
00314     {
00315         return FALSE;
00316     }
00317     else
00318     {
00319         return TRUE;
00320     }
00321 }

gboolean scanThread_wait ( int  timeout_sec  ) 

Definition at line 286 of file scanThread.c.

00287 {
00288     int max_ticks = 2 * timeout_sec;
00289 
00290     CN_LOGPRINTF("entry");
00291     if (g_scan_thread)
00292     {
00293         // sorry don't like busy-wait, 
00294         // but g_thread_join has no timeout option
00295         while (g_scan_thread  &&  --max_ticks >= 0)
00296         {
00297             g_usleep(500*1000L);
00298         }
00299 
00300         return TRUE;
00301     }
00302     else
00303     {
00304         CN_ERRORPRINTF("scan thread not running");
00305         return FALSE;
00306     }
00307 }


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