UPNPControl Class Reference

#include <upnpcontrol.h>

List of all members.

Public Types

enum  UPNPError {
  Success, NoUPNPDevicesFound, NoValidIGDsFound, WSAStartupFailed,
  AddPortMappingFailed, GetPortMappingFailed, DeletePortMappingFailed, UnknownError
}
enum  UPNPState {
  IdleState, ErrorState, DiscoverState, UpdatingORPortState,
  UpdatingDirPortState, ForwardingCompleteState
}

Signals

void stateChanged (UPNPControl::UPNPState state)
void error (UPNPControl::UPNPError error)

Public Member Functions

void getDesiredState (quint16 *desiredDirPort, quint16 *desiredOrPort)
void setDesiredState (quint16 desiredDirPort, quint16 desiredOrPort)
UPNPError error () const
QString errorString () const
int discoverTimeout () const

Static Public Member Functions

static UPNPControlinstance ()
static void cleanup ()

Protected Member Functions

 UPNPControl ()
 ~UPNPControl ()
void setError (UPNPError error)
void setState (UPNPState state)

Private Attributes

quint16 _forwardedORPort
quint16 _forwardedDirPort
QMutex * _mutex
UPNPError _error
UPNPState _state
UPNPControlThread_controlThread

Static Private Attributes

static UPNPControl_instance = 0

Friends

class UPNPControlThread

Detailed Description

Definition at line 27 of file upnpcontrol.h.


Member Enumeration Documentation

UPnP-related error values.

Enumerator:
Success 
NoUPNPDevicesFound 
NoValidIGDsFound 
WSAStartupFailed 
AddPortMappingFailed 
GetPortMappingFailed 
DeletePortMappingFailed 
UnknownError 

Definition at line 33 of file upnpcontrol.h.

UPnP port forwarding state.

Enumerator:
IdleState 
ErrorState 
DiscoverState 
UpdatingORPortState 
UpdatingDirPortState 
ForwardingCompleteState 

Definition at line 44 of file upnpcontrol.h.


Constructor & Destructor Documentation

UPNPControl::UPNPControl (  )  [protected]

Constructor. Initializes and starts a thread in which all blocking UPnP operations will be performed.

Definition at line 43 of file upnpcontrol.cpp.

References _controlThread, _error, _forwardedDirPort, _forwardedORPort, _mutex, _state, IdleState, UnknownError, and UPNPControlThread.

Referenced by instance().

UPNPControl::~UPNPControl (  )  [protected]

Destructor. cleanup() should be called before the object is destroyed.

Destructor. cleanup() should be called before the object is destroyed.

See also:
cleanup()

Definition at line 60 of file upnpcontrol.cpp.

References _controlThread, and _mutex.


Member Function Documentation

void UPNPControl::cleanup (  )  [static]

Terminates the UPnP control thread and frees memory allocated to this object's singleton instance.

Definition at line 69 of file upnpcontrol.cpp.

References _controlThread, _instance, and UPNPControlThread::stop().

Referenced by ServerSettings::cleanupPortForwarding().

int UPNPControl::discoverTimeout (  )  const

Returns the number of milliseconds to wait for devices to respond when attempting to discover UPnP-enabled IGDs.

Definition at line 161 of file upnpcontrol.cpp.

References UPNPControlThread::UPNPCONTROL_DISCOVER_TIMEOUT.

Referenced by UPNPTestDialog::UPNPTestDialog().

void UPNPControl::error ( UPNPControl::UPNPError  error  )  [signal]

Emitted when a UPnP error occurs.

UPNPControl::UPNPError UPNPControl::error (  )  const

Returns the type of error that occurred last.

Definition at line 126 of file upnpcontrol.cpp.

References _error, and _mutex.

Referenced by errorString(), and setError().

QString UPNPControl::errorString (  )  const

Returns a QString describing the type of error that occurred last.

Definition at line 134 of file upnpcontrol.cpp.

References AddPortMappingFailed, DeletePortMappingFailed, error(), GetPortMappingFailed, NoUPNPDevicesFound, NoValidIGDsFound, Success, and WSAStartupFailed.

void UPNPControl::getDesiredState ( quint16 *  desiredDirPort,
quint16 *  desiredOrPort 
)

Sets desiredDirPort and desiredOrPort to the currently forwarded DirPort and ORPort values.

Definition at line 79 of file upnpcontrol.cpp.

References _forwardedDirPort, _forwardedORPort, and _mutex.

Referenced by UPNPControlThread::configurePorts(), and UPNPTestDialog::UPNPTestDialog().

UPNPControl * UPNPControl::instance (  )  [static]
void UPNPControl::setDesiredState ( quint16  desiredDirPort,
quint16  desiredOrPort 
)

Sets the desired DirPort and ORPort port mappings to desiredDirPort and desiredOrPort, respectively.

Definition at line 90 of file upnpcontrol.cpp.

References _controlThread, _forwardedDirPort, _forwardedORPort, _mutex, and UPNPControlThread::wakeup().

Referenced by ServerSettings::configurePortForwarding(), UPNPTestDialog::setVisible(), and UPNPTestDialog::startTest().

void UPNPControl::setError ( UPNPError  upnpError  )  [protected]

Sets the most recent UPnP-related error to error and emits the error() signal.

See also:
error

Sets the most recent UPnP-related error to error and emits the error() signal.

Definition at line 103 of file upnpcontrol.cpp.

References _error, _mutex, and error().

Referenced by UPNPControlThread::configurePorts().

void UPNPControl::setState ( UPNPState  state  )  [protected]

Sets the current UPnP state to state and emits the stateChanged() signal.

See also:
stateChanged

Sets the current UPnP state to state and emits the stateChanged() signal.

Definition at line 115 of file upnpcontrol.cpp.

References _mutex, _state, and stateChanged().

Referenced by UPNPControlThread::configurePorts(), UPNPControlThread::initializeUPNP(), and UPNPControlThread::run().

void UPNPControl::stateChanged ( UPNPControl::UPNPState  state  )  [signal]

Emitted when the UPnP control thread status changes.

Referenced by setState().


Friends And Related Function Documentation

friend class UPNPControlThread [friend]

Definition at line 109 of file upnpcontrol.h.

Referenced by UPNPControl().


Member Data Documentation

Thread used for UPnP operations.

Definition at line 110 of file upnpcontrol.h.

Referenced by cleanup(), instance(), setDesiredState(), UPNPControl(), and ~UPNPControl().

Most recent UPNP error.

Definition at line 106 of file upnpcontrol.h.

Referenced by error(), setError(), and UPNPControl().

quint16 UPNPControl::_forwardedDirPort [private]

Currently forwarded DirPort.

Definition at line 104 of file upnpcontrol.h.

Referenced by getDesiredState(), setDesiredState(), and UPNPControl().

quint16 UPNPControl::_forwardedORPort [private]

Currently forwarded ORPort.

Definition at line 103 of file upnpcontrol.h.

Referenced by getDesiredState(), setDesiredState(), and UPNPControl().

UPNPControl * UPNPControl::_instance = 0 [static, private]

UPNPControl singleton instance.

Definition at line 101 of file upnpcontrol.h.

Referenced by cleanup(), and instance().

QMutex* UPNPControl::_mutex [private]

Mutex around variables shared with UPNPControlThread.

Definition at line 105 of file upnpcontrol.h.

Referenced by error(), getDesiredState(), setDesiredState(), setError(), setState(), UPNPControl(), and ~UPNPControl().

Current UPNP status.

Definition at line 107 of file upnpcontrol.h.

Referenced by setState(), and UPNPControl().


The documentation for this class was generated from the following files:

Generated on Wed Dec 23 21:06:56 2009 for Vidalia by  doxygen 1.6.1