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 #include "config.h"
00021 #include "VidaliaSettings.h"
00022 #include "Log.h"
00023 #include "TorControl.h"
00024
00025 #include <QApplication>
00026 #include <QMap>
00027 #include <QList>
00028 #include <QString>
00029 #include <QKeySequence>
00030
00031 #if defined(Q_OS_WIN)
00032 #include <windows.h>
00033 #include "win32.h"
00034 #endif
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 bool validateArguments(QString &errmsg);
00058
00059 static void showUsageMessageBox();
00060
00061 static bool showUsage();
00062
00063
00064 static bool setLanguage(QString languageCode = QString());
00065
00066 static bool setStyle(QString styleKey = QString());
00067
00068
00069 static QString language() { return _language; }
00070
00071 static QString style() { return _style; }
00072
00073 static QString version() { return VIDALIA_VERSION; }
00074
00075
00076 static TorControl* torControl() { return _torControl; }
00077
00078
00079 static QString dataDirectory();
00080
00081 static QString defaultDataDirectory();
00082
00083
00084 static QString pidFile();
00085
00086
00087
00088 static bool readPasswordFromStdin();
00089
00090
00091 static Log::LogMessage log(Log::LogLevel level, QString msg);
00092
00093
00094
00095 static int run();
00096
00097
00098
00099 static void createShortcut(const QKeySequence &key, QWidget *sender,
00100 QObject *receiver, const char *slot);
00101
00102
00103
00104 static void createShortcut(const QString &key, QWidget *sender,
00105 QObject *receiver, const char *slot);
00106
00107
00108
00109
00110
00111
00112
00113 static bool retranslateUi(const QString &languageCode);
00114
00115 signals:
00116
00117
00118 void running();
00119
00120 protected:
00121 #if defined(Q_OS_WIN)
00122
00123 bool winEventFilter(MSG *msg, long *result);
00124 #endif
00125
00126
00127 static void removeAllTranslators();
00128
00129 private slots:
00130
00131
00132
00133 void onEventLoopStarted();
00134
00135 private:
00136
00137
00138 static void qt_msg_handler(QtMsgType type, const char *msg);
00139
00140
00141 void parseArguments(QStringList args);
00142
00143 bool argNeedsValue(QString argName);
00144
00145
00146
00147
00148 void copyDefaultSettingsFile() const;
00149
00150
00151
00152
00153 void loadDefaultCaCertificates() const;
00154
00155 static QMap<QString, QString> _args;
00156 static QString _style;
00157 static QString _language;
00158 static TorControl* _torControl;
00159 static Log _log;
00160 static QList<QTranslator *> _translators;
00161 };
00162
00163 #endif
00164