class CWLANPlugin

WLAN specific implementation of the PeerHood plugin interface.

Inheritance:


Public Methods

[more] CWLANPlugin()
Default constructor, sets the internal variables to their default values.
[more]bool TestConnection(unsigned int aFd, unsigned int aBytes)
Tests TCP connection for incoming data.
[more]bool LoadParameter(std::string& aParameter)
Loads a parameter from the configuration file.
[more]bool Start()
Starts the plugin's inquiry routine.
[more]void Stop()
Stops the plugin's inquiry routine.
[more]bool Listen()
Starts the plugin's inquiry listen routine.
[more]void UnListen()
Stops the plugin's inquiry listen routine.
[more]const std::string& GetName()
Returns plugin's unique id string.
[more]void UpdateState()
Updates the state
[more]void RegisterListener(MAbstractListener* aListener)
Register a new listener for this plugin
[more]void SetState(bool aActive)
Change the state of the plugin
[more]void TriggerShutdown()
Set to shut down - not used
[more]void LoadListeners()
Loads all listeners for this plugin
[more]void* ThreadStarter(void* aArguments)
Starts plugin's main (inquiry) thread.
[more]void* ListenStarter(void* aArguments)
Starts plugin's inquiry listen thread.
[more]void* AdvertStarter(void* aArguments)
Starts plugin's advertising thread.
[more]void InquiryThread()
Plugin's main thread that performs WLAN inquiry at certain intervals.
[more]void ListenThread()
Plugin's inquiry thread that listens WLAN inquiries.
[more]bool AddDevice(const std::string& aDeviceName)
Checks if the found device is new (i.e. not detected before).
[more]bool MakeOlder()
Increases each device's timestamp by one and checks is some of them exceeds the limit.
[more]bool Advert()
Starts advertazing the PeerHood service by providing a lookup service.
[more]bool Unadvert()
Removes the PeerHood tag from the lookup service.
[more]bool HasPeerHood(const std::string& aAddress, int* aPSM)
Checks if the PeerHood tag can be found from remote device's lookup service
[more]bool FetchInformation(CDaemonDevice* aDevice)
Fetch the required information from other device
[more]bool FetchDeviceInfo(CDaemonDevice* aDevice, CTCPConnection* connection)
Fetch services from the remote device
[more]bool FetchServices(CDaemonDevice* aDevice)
Fecthes a list of services available on the given remote device.
[more]bool FetchServices(CDaemonDevice* aDevice, CTCPConnection* connection)
Fetch services from the remote device
[more]bool FetchPrototypes(CDaemonDevice* aDevice, CTCPConnection* connection)
Fetch prototypes from the remote device
[more]void RemoveListeners()
Clear list of listers


Inherited from MAbstractPlugin:


Inherited from MAbstractStateConverter:

Public Methods

ovirtual void SetAdapter(const std::string& aInterface, int aId)


Documentation

This class is WLAN specific implementation of the PeerHood plugin interface. Other PeerHood capable devices are located using implemented lookup service

o CWLANPlugin()
Default constructor, sets the internal variables to their default values. This method loads WLAN interface, monitoring and service checking interval variables fro configuration file.

Returns:
none

obool TestConnection(unsigned int aFd, unsigned int aBytes)
Tests TCP connection using ioctl. This method checks how manyt bytes there are available for reading. This checking is necessary because MSG_WAITALL flag is used for reading.

Parameters:
aFd - Socket filedescriptor which is checked
aBytes - How many bytes are expected to be available
Returns:
false if there is not enough bytes pending

obool LoadParameter(std::string& aParameter)
Loads a parameter from the configuration file. If the requested parameter is found then the argument <code>aParameter</code> is replaced with parameter's value.

Parameters:
aParameter - Parameter's name.
Returns:
true if the requested parameter was found

obool Start()
Starts the plugin's inquiry routine. After this method is called the plugin starts to monitor its environment and tries to locate nearby PeerHood-capable devices. Whenever a change in the neighborhood status is detected the plugin will update the device & service database . This plugin uses protocol defined by virtual peerhood for WLAN devices to locate PeerHood-capable devices in the neighborhood.

Returns:
boolean telling if the plugin could be started

ovoid Stop()
Stops the plugin's inquiry routine. After this call is handled the plugin will stop monitoring the environment. This means that daemon's device & service database will be deprecated as the time passes.

Returns:
none

obool Listen()
Starts the plugin's inquiry listen routine.

Returns:
boolean telling if the plugin could be started

ovoid UnListen()
Stops the plugin's inquiry routine.

Returns:
none

oconst std::string& GetName()
Returns plugin's unique id string. The id of this plugin is 'wlan-base'.

Returns:
plugin's unique id string ('wlan-base')

ovoid UpdateState()
Checks messages for every listener that is registered into this plugin.

ovoid RegisterListener(MAbstractListener* aListener)
Adds a listener into the internal list of listener. Used by listeners only.

Parameters:
MAbstractlistener - * aListener Reference to the listener that is added

ovoid SetState(bool aActive)
Sets new state for plugin (or no changes if there is no need)

Parameters:
aActive - new state (true = active, false = passive)

ovoid TriggerShutdown()
Not used - does nothing

ovoid LoadListeners()
Uses the ListenerFactory for listener creation. When listeners have been created (listeners automatically register themselves to the object that asked to create them) they are commanded to connect to their sources and to check the initial state.

ovoid* ThreadStarter(void* aArguments)
Starts plugin's main (inquiry) thread. This dummy function is required because C++ doesn't allow non-static member functions to be started as a thread. This function just calls plugin instance's real inquiry function.

Parameters:
aArguments - Pointer to the currently running instance.
Returns:
always NULL

ovoid* ListenStarter(void* aArguments)
Starts plugin's inquiry listen thread. This dummy function is required because C++ doesn't allow non-static member functions to be started as a thread. This function just calls plugin instance's real inquiry function.

Parameters:
aArguments - Pointer to the currently running instance.
Returns:
always NULL

ovoid* AdvertStarter(void* aArguments)
Starts plugin's advertising thread. This dummy function is required because C++ doesn't allow non-static member functions to be started as a thread. This function just calls plugin instance's real advertising function.

Parameters:
aArguments - Pointer to the currently running instance.
Returns:
always NULL

ovoid InquiryThread()
Plugin's main thread that performs WLAN inquiry at certain intervals. All found devices are stored to the DeviceStorage shared with all plugins and the PeerHood Daemon. Inquiry is performed in two-phases: First inquiring device broadcastst HELLO -message using specific UDP port. Other devices are listening to this port and send a reply back. Inquiring device receives these replies using ListeningThread and adds devices to database.

ovoid ListenThread()
Plugin's inquiry thread that listen WLAN inquiries. This thread listens for UDP broadcast and unicast traffic using specific ports. If someone sends UDP broadcast thread sends unicast back. If someone sends unicast, thread adds the device into it's databse.

Returns:
none

obool AddDevice(const std::string& aDeviceName)
Checks if the found device is new (i.e. not detected before). If this is the case then it is added to plugin's internal device list and the common device & service database should be updated later on. There two kinds of counters for device: timestamp is used for to mark "old" devices and lastchecked is for performing service checking on specific interval. timestamp is zerod every time when device is found. If timestamp reaches specific value device is erased. If device is seen, lastchecked value is decreased. If lastchecked reaches zero, device services are checked.

Parameters:
aDeviceName - The name of the device to be added.
Returns:
true if the checked device is new

obool MakeOlder()
Increases each device's timestamp value by one and checks if some of them exceeds the limit defined byt KEEP_ALIVE_STAMP. In that case the "old" device is removed from the internal device list so the common device & service database should be updated. 4 *
Returns:
true if some device was removed from the internal device list

obool Advert()
Starts advertazing the PeerHood service by providing a lookup service.Other WLAN- enabled PeerHood devices will look PeerHood service from this well-known lookup service when they try to locate the surrounding PeerHood devices. If this function fails other devices are not capable of detecting PeerHood on this device.

Returns:
true if the advertising was started successfully

obool Unadvert()
Removes the PeerHood tag from the lookup service. After this function is invoked, other devices are not able to detect the existence of the PeerHood service on this machine.

Returns:
true if the advertising was ended succesfully

obool HasPeerHood(const std::string& aAddress, int* aPSM)
Checks if the PeerHood tag can be found from remote device's lookup service. If the tag if found then the remote device is assumed to be PeerHood-capable without any further checking.

Parameters:
aAddress - The address of the remote device.
aPSM - On return contains the PSM of the remote address if PeerHood is found, otherwise -1.
Returns:
true if the PeerHood tag was found on remote device's lookup service

obool FetchInformation(CDaemonDevice* aDevice)
Returns:
true if all information is successfully fetched

obool FetchDeviceInfo(CDaemonDevice* aDevice, CTCPConnection* connection)
Fetch services from remote device and add them to the list of this daemon device

Returns:
true if all information is successfully fetched

obool FetchServices(CDaemonDevice* aDevice)
Fetches a list of services available on the given remote device. This is done by establishing a new connection to the remote device using address information given in the parameter <code>aDevice</code> and invoking the service list request on the remote device. Founded services are added to the device.

Parameters:
aDevice - The device whose service list should be fetched.
Returns:
none

obool FetchServices(CDaemonDevice* aDevice, CTCPConnection* connection)
Fetch services from remote device and add them to the list of this daemon device

Returns:
true if all information is successfully fetched

obool FetchPrototypes(CDaemonDevice* aDevice, CTCPConnection* connection)
Fetch prototypes from remote device and add them to the list of this daemon device

Returns:
true if all information is successfully fetched

ovoid RemoveListeners()
Removes all listeners from the listener list. Called when this object is destroyed. Listeners are loaded only once!


This class has no child classes.
See Also:
MAbstractPlugin

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.