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