torevents.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _TOREVENTS_H
00018 #define _TOREVENTS_H
00019
00020 #include <QObject>
00021 #include <QMultiHash>
00022 #include <QList>
00023
00024 #include "eventtype.h"
00025 #include "logevent.h"
00026 #include "bandwidthevent.h"
00027 #include "circuitevent.h"
00028 #include "streamevent.h"
00029 #include "orconnevent.h"
00030 #include "newdescriptorevent.h"
00031 #include "addressmapevent.h"
00032 #include "statusevent.h"
00033 #include "controlreply.h"
00034
00035
00036 class TorEvents : public QObject
00037 {
00038 Q_OBJECT
00039
00040 public:
00041
00042 enum TorEvent {
00043 Unknown,
00044 Bandwidth,
00045 LogDebug, LogInfo, LogNotice, LogWarn, LogError,
00046 CircuitStatus,
00047 StreamStatus,
00048 OrConnStatus,
00049 NewDescriptor,
00050 AddressMap,
00051 GeneralStatus,
00052 ClientStatus,
00053 ServerStatus
00054 };
00055
00056
00057 TorEvents();
00058
00059
00060 void add(TorEvent event, QObject *obj);
00061
00062
00063 void remove(TorEvent event, QObject *obj);
00064
00065 bool contains(TorEvent event);
00066
00067 QList<TorEvent> eventList();
00068
00069
00070 void handleEvent(const ControlReply &reply);
00071
00072
00073 void dispatch(TorEvent e, QEvent *event);
00074
00075
00076 static QString toString(TorEvents::TorEvent e);
00077
00078 static TorEvent toTorEvent(LogEvent::Severity severity);
00079
00080
00081 private:
00082
00083
00084 QMultiHash<TorEvent, QObject*> _eventList;
00085
00086
00087 static TorEvent parseEventType(const ReplyLine &line);
00088
00089 static TorEvent toTorEvent(const QString &event);
00090
00091
00092 void handleBandwidthUpdate(const ReplyLine &line);
00093
00094 void handleCircuitStatus(const ReplyLine &line);
00095
00096 void handleStreamStatus(const ReplyLine &line);
00097
00098 void handleLogMessage(const ReplyLine &line);
00099
00100 void handleOrConnStatus(const ReplyLine &line);
00101
00102 void handleNewDescriptor(const ReplyLine &line);
00103
00104 void handleAddressMap(const ReplyLine &line);
00105
00106 void handleStatusEvent(TorEvent type, const ReplyLine &line);
00107
00108
00109 void dispatchClientStatusEvent(tc::Severity severity,
00110 const QString &action,
00111 const QHash<QString,QString> &args);
00112
00113 void dispatchServerStatusEvent(tc::Severity severity,
00114 const QString &action,
00115 const QHash<QString,QString> &args);
00116
00117 void dispatchGeneralStatusEvent(tc::Severity severity,
00118 const QString &action,
00119 const QHash<QString,QString> &args);
00120 };
00121
00122 #endif
00123