TorEvents Class Reference

#include <torevents.h>

List of all members.

Public Types

 Unknown
 Bandwidth
 LogDebug
 LogInfo
 LogNotice
 LogWarn
 LogError
 CircuitStatus
 StreamStatus
 OrConnStatus
 NewDescriptor
 AddressMap
 GeneralStatus
 ClientStatus
 ServerStatus
enum  TorEvent {
  Unknown, Bandwidth, LogDebug, LogInfo,
  LogNotice, LogWarn, LogError, CircuitStatus,
  StreamStatus, OrConnStatus, NewDescriptor, AddressMap,
  GeneralStatus, ClientStatus, ServerStatus
}

Public Member Functions

 TorEvents ()
void add (TorEvent event, QObject *obj)
void remove (TorEvent event, QObject *obj)
bool contains (TorEvent event)
QList< TorEventeventList ()
void handleEvent (const ControlReply &reply)
void dispatch (TorEvent e, QEvent *event)

Static Public Member Functions

static QString toString (TorEvents::TorEvent e)
static TorEvent toTorEvent (LogEvent::Severity severity)

Private Member Functions

void handleBandwidthUpdate (const ReplyLine &line)
void handleCircuitStatus (const ReplyLine &line)
void handleStreamStatus (const ReplyLine &line)
void handleLogMessage (const ReplyLine &line)
void handleOrConnStatus (const ReplyLine &line)
void handleNewDescriptor (const ReplyLine &line)
void handleAddressMap (const ReplyLine &line)
void handleStatusEvent (TorEvent type, const ReplyLine &line)
void dispatchClientStatusEvent (tc::Severity severity, const QString &action, const QHash< QString, QString > &args)
void dispatchServerStatusEvent (tc::Severity severity, const QString &action, const QHash< QString, QString > &args)
void dispatchGeneralStatusEvent (tc::Severity severity, const QString &action, const QHash< QString, QString > &args)

Static Private Member Functions

static TorEvent parseEventType (const ReplyLine &line)
static TorEvent toTorEvent (const QString &event)

Private Attributes

QMultiHash< TorEvent, QObject * > _eventList


Detailed Description

Definition at line 36 of file torevents.h.


Member Enumeration Documentation

enum TorEvents::TorEvent

Asynchronous events sent from Tor to the controller

Enumerator:
Unknown 
Bandwidth 
LogDebug 
LogInfo 
LogNotice 
LogWarn 
LogError 
CircuitStatus 
StreamStatus 
OrConnStatus 
NewDescriptor 
AddressMap 
GeneralStatus 
ClientStatus 
ServerStatus 

Definition at line 42 of file torevents.h.


Constructor & Destructor Documentation

TorEvents::TorEvents (  ) 

Default Constructor

Definition at line 35 of file torevents.cpp.


Member Function Documentation

void TorEvents::add ( TorEvent  event,
QObject *  obj 
)

Adds an event and interested object to the event list

Definition at line 41 of file torevents.cpp.

References _eventList.

Referenced by TorControl::setEvent().

bool TorEvents::contains ( TorEvent  event  ) 

Returns true if an event has any registered handlers

Definition at line 64 of file torevents.cpp.

References _eventList.

void TorEvents::dispatch ( TorEvent  e,
QEvent *  event 
)

Dispatches a given event to all its handler targets.

Definition at line 81 of file torevents.cpp.

References _eventList.

Referenced by dispatchClientStatusEvent(), dispatchGeneralStatusEvent(), dispatchServerStatusEvent(), handleAddressMap(), handleBandwidthUpdate(), handleCircuitStatus(), handleLogMessage(), handleNewDescriptor(), handleOrConnStatus(), handleStreamStatus(), and TorControl::onLogStdout().

void TorEvents::dispatchClientStatusEvent ( tc::Severity  severity,
const QString &  action,
const QHash< QString, QString > &  args 
) [private]

Parses and posts a Tor client status event.

Definition at line 397 of file torevents.cpp.

References BootstrapStatus::actionFromString(), ClientStatusEvent::Bootstrap, ClientStatusEvent::CircuitEstablished, ClientStatus, dispatch(), BootstrapStatus::statusFromString(), ClientStatusEvent::statusFromString(), and tc::toConnectionStatusReason().

Referenced by handleStatusEvent().

void TorEvents::dispatchGeneralStatusEvent ( tc::Severity  severity,
const QString &  action,
const QHash< QString, QString > &  args 
) [private]

Parses and posts a general Tor status event.

Definition at line 446 of file torevents.cpp.

References GeneralStatusEvent::DangerousTorVersion, dispatch(), GeneralStatus, DangerousVersionEvent::reasonFromString(), and GeneralStatusEvent::statusFromString().

Referenced by handleStatusEvent().

void TorEvents::dispatchServerStatusEvent ( tc::Severity  severity,
const QString &  action,
const QHash< QString, QString > &  args 
) [private]

Parses and posts a Tor server status event.

Definition at line 429 of file torevents.cpp.

References dispatch(), ServerStatus, and ServerStatusEvent::statusFromString().

Referenced by handleStatusEvent().

QList< TorEvents::TorEvent > TorEvents::eventList (  ) 

Returns the list of events in which we're interested

Definition at line 74 of file torevents.cpp.

References _eventList.

Referenced by TorControl::setEvents().

void TorEvents::handleAddressMap ( const ReplyLine line  )  [private]

Handles a new or updated address map event.

Definition at line 350 of file torevents.cpp.

References CustomEventType::AddressMapEvent, DATE_FMT, dispatch(), and ReplyLine::getMessage().

Referenced by handleEvent().

void TorEvents::handleBandwidthUpdate ( const ReplyLine line  )  [private]

Handle a bandwidth update event

Definition at line 219 of file torevents.cpp.

References Bandwidth, CustomEventType::BandwidthEvent, dispatch(), and ReplyLine::getMessage().

Referenced by handleEvent().

void TorEvents::handleCircuitStatus ( const ReplyLine line  )  [private]

Handle a circuit status event

Definition at line 243 of file torevents.cpp.

References CustomEventType::CircuitEvent, CircuitStatus, dispatch(), ReplyLine::getMessage(), and i().

Referenced by handleEvent().

void TorEvents::handleEvent ( const ControlReply reply  ) 

Parses an event message and emits the proper signal

Definition at line 182 of file torevents.cpp.

References Bandwidth, CircuitStatus, ClientStatus, GeneralStatus, ControlReply::getLines(), handleAddressMap(), handleBandwidthUpdate(), handleCircuitStatus(), handleLogMessage(), handleNewDescriptor(), handleOrConnStatus(), handleStatusEvent(), handleStreamStatus(), LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, OrConnStatus, parseEventType(), ServerStatus, and StreamStatus.

void TorEvents::handleLogMessage ( const ReplyLine line  )  [private]

Handle a log message event

Definition at line 291 of file torevents.cpp.

References dispatch(), ReplyLine::getData(), ReplyLine::getMessage(), i(), CustomEventType::LogEvent, LogEvent::toSeverity(), and toTorEvent().

Referenced by handleEvent().

void TorEvents::handleNewDescriptor ( const ReplyLine line  )  [private]

Handles a new list of descriptors event.

Definition at line 332 of file torevents.cpp.

References dispatch(), ReplyLine::getMessage(), NewDescriptor, and CustomEventType::NewDescriptorEvent.

Referenced by handleEvent().

void TorEvents::handleOrConnStatus ( const ReplyLine line  )  [private]

Handle an OR connection status event.

Definition at line 317 of file torevents.cpp.

References dispatch(), ReplyLine::getMessage(), CustomEventType::OrConnEvent, OrConnStatus, and OrConnEvent::toStatus().

Referenced by handleEvent().

void TorEvents::handleStatusEvent ( TorEvent  type,
const ReplyLine line 
) [private]

Handles a Tor status event.

Definition at line 375 of file torevents.cpp.

References ClientStatus, dispatchClientStatusEvent(), dispatchGeneralStatusEvent(), dispatchServerStatusEvent(), ReplyLine::getMessage(), ServerStatus, string_parse_keyvals(), and tc::toSeverity().

Referenced by handleEvent().

void TorEvents::handleStreamStatus ( const ReplyLine line  )  [private]

Handle a stream status event

Definition at line 272 of file torevents.cpp.

References dispatch(), Stream::fromString(), ReplyLine::getMessage(), i(), CustomEventType::StreamEvent, and StreamStatus.

Referenced by handleEvent().

TorEvents::TorEvent TorEvents::parseEventType ( const ReplyLine line  )  [static, private]

Parses the event type from the event message

Definition at line 171 of file torevents.cpp.

References ReplyLine::getMessage(), i(), and toTorEvent().

Referenced by handleEvent().

void TorEvents::remove ( TorEvent  event,
QObject *  obj 
)

Removes obj from the list of target objects for event e.

Definition at line 50 of file torevents.cpp.

References _eventList, and i().

Referenced by TorControl::setEvent().

QString TorEvents::toString ( TorEvents::TorEvent  e  )  [static]

Converts an Event to a string

Definition at line 90 of file torevents.cpp.

References Bandwidth, CircuitStatus, ClientStatus, GeneralStatus, LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, OrConnStatus, ServerStatus, and StreamStatus.

Referenced by TorControl::setEvents().

TorEvents::TorEvent TorEvents::toTorEvent ( const QString &  event  )  [static, private]

Converts a string to an Event

Definition at line 131 of file torevents.cpp.

References Bandwidth, CircuitStatus, ClientStatus, GeneralStatus, LogDebug, LogError, LogInfo, LogNotice, LogWarn, NewDescriptor, OrConnStatus, ServerStatus, StreamStatus, and Unknown.

TorEvents::TorEvent TorEvents::toTorEvent ( LogEvent::Severity  severity  )  [static]

Converts a log severity to an event

Definition at line 115 of file torevents.cpp.

References LogEvent::Debug, LogEvent::Error, LogEvent::Info, LogDebug, LogError, LogInfo, LogNotice, LogWarn, LogEvent::Notice, Unknown, and LogEvent::Warn.

Referenced by handleLogMessage(), TorControl::onLogStdout(), and parseEventType().


Member Data Documentation

QMultiHash<TorEvent, QObject*> TorEvents::_eventList [private]

Stores a mapping of Tor events to a list of the objects interested in hearing about those events.

Definition at line 84 of file torevents.h.

Referenced by add(), contains(), dispatch(), eventList(), and remove().


The documentation for this class was generated from the following files:
Generated on Tue Jul 7 16:58:12 2009 for Vidalia by  doxygen 1.4.7