vidalia.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 _VIDALIA_H
00018 #define _VIDALIA_H
00019
00020 #if defined(Q_OS_WIN)
00021 #include <windows.h>
00022 #include <win32.h>
00023 #endif
00024
00025 #include <QApplication>
00026 #include <QMap>
00027 #include <QString>
00028 #include <QKeySequence>
00029
00030 #include <log.h>
00031 #include <vidaliasettings.h>
00032 #include <torcontrol.h>
00033
00034 #include "config.h"
00035
00036
00037 #define vApp ((Vidalia *)qApp)
00038
00039 #define vDebug(fmt) (vApp->log(Log::Debug, (fmt)))
00040 #define vInfo(fmt) (vApp->log(Log::Info, (fmt)))
00041 #define vNotice(fmt) (vApp->log(Log::Notice, (fmt)))
00042 #define vWarn(fmt) (vApp->log(Log::Warn, (fmt)))
00043 #define vError(fmt) (vApp->log(Log::Error, (fmt)))
00044
00045
00046 class Vidalia : public QApplication
00047 {
00048 Q_OBJECT
00049
00050 public:
00051
00052 Vidalia(QStringList args, int &argc, char **argv);
00053
00054 ~Vidalia();
00055
00056
00057 static QMap<QString, QString> arguments() { return _args; }
00058
00059 static bool validateArguments(QString &errmsg);
00060
00061 static void showUsageMessageBox();
00062
00063 static bool showUsage();
00064
00065
00066 static bool setLanguage(QString languageCode = QString());
00067
00068 static bool setStyle(QString styleKey = QString());
00069
00070
00071 static QString language() { return _language; }
00072
00073 static QString style() { return _style; }
00074
00075 static QString version() { return VIDALIA_VERSION; }
00076
00077
00078 static TorControl* torControl() { return _torControl; }
00079
00080
00081 static QString dataDirectory();
00082
00083 static QString defaultDataDirectory();
00084
00085
00086 static QString pidFile();
00087
00088
00089 static Log::LogMessage log(Log::LogLevel level, QString msg);
00090
00091
00092
00093 static int run();
00094
00095
00096
00097 static void createShortcut(const QKeySequence &key, QWidget *sender,
00098 QObject *receiver, const char *slot);
00099
00100
00101
00102 static void createShortcut(const QString &key, QWidget *sender,
00103 QObject *receiver, const char *slot);
00104
00105 signals:
00106
00107
00108 void running();
00109
00110 void shutdown();
00111
00112 protected:
00113 #if defined(Q_OS_WIN)
00114
00115 bool winEventFilter(MSG *msg, long *result);
00116 #endif
00117
00118 private slots:
00119
00120
00121
00122 void onEventLoopStarted();
00123
00124 private:
00125
00126
00127 static void qt_msg_handler(QtMsgType type, const char *msg);
00128
00129
00130 void parseArguments(QStringList args);
00131
00132 bool argNeedsValue(QString argName);
00133
00134 static QMap<QString, QString> _args;
00135 static QString _style;
00136 static QString _language;
00137 static TorControl* _torControl;
00138 static Log _log;
00139 };
00140
00141 #endif
00142