Vidalia  0.2.21
Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
UPNPControl Class Reference

#include <UPNPControl.h>

Inheritance diagram for UPNPControl:

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 26 of file UPNPControl.h.

Member Enumeration Documentation

UPnP-related error values.

Enumerator:
Success 
NoUPNPDevicesFound 
NoValidIGDsFound 
WSAStartupFailed 
AddPortMappingFailed 
GetPortMappingFailed 
DeletePortMappingFailed 
UnknownError 

Definition at line 32 of file UPNPControl.h.

UPnP port forwarding state.

Enumerator:
IdleState 
ErrorState 
DiscoverState 
UpdatingORPortState 
UpdatingDirPortState 
ForwardingCompleteState 

Definition at line 43 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 42 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 59 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 68 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 160 of file UPNPControl.cpp.

References UPNPControlThread::UPNPCONTROL_DISCOVER_TIMEOUT.

Referenced by UPNPTestDialog::UPNPTestDialog().

UPNPControl::UPNPError UPNPControl::error ( ) const

Returns the type of error that occurred last.

Definition at line 125 of file UPNPControl.cpp.

References _error, and _mutex.

Referenced by errorString(), and setError().

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

Emitted when a UPnP error occurs.

QString UPNPControl::errorString ( ) const

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

Definition at line 133 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 78 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 89 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 102 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 114 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 108 of file UPNPControl.h.

Referenced by UPNPControl().

Member Data Documentation

UPNPControlThread* UPNPControl::_controlThread
private

Thread used for UPnP operations.

Definition at line 109 of file UPNPControl.h.

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

UPNPError UPNPControl::_error
private

Most recent UPNP error.

Definition at line 105 of file UPNPControl.h.

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

quint16 UPNPControl::_forwardedDirPort
private

Currently forwarded DirPort.

Definition at line 103 of file UPNPControl.h.

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

quint16 UPNPControl::_forwardedORPort
private

Currently forwarded ORPort.

Definition at line 102 of file UPNPControl.h.

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

UPNPControl * UPNPControl::_instance = 0
staticprivate

UPNPControl singleton instance.

Definition at line 100 of file UPNPControl.h.

Referenced by cleanup(), and instance().

QMutex* UPNPControl::_mutex
private

Mutex around variables shared with UPNPControlThread.

Definition at line 104 of file UPNPControl.h.

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

UPNPState UPNPControl::_state
private

Current UPNP status.

Definition at line 106 of file UPNPControl.h.

Referenced by setState(), and UPNPControl().


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