vidalia.h

Go to the documentation of this file.
00001 /****************************************************************
00002  *  Vidalia is distributed under the following license:
00003  *
00004  *  Copyright (C) 2006,  Matt Edman, Justin Hipple
00005  *
00006  *  This program is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU General Public License
00008  *  as published by the Free Software Foundation; either version 2
00009  *  of the License, or (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019  *  Boston, MA  02110-1301, USA.
00020  ****************************************************************/
00021 
00022 /**
00023  * \file vidalia.h
00024  * \version $Id: vidalia.h 1270 2006-10-03 20:29:32Z edmanm $
00025  * \brief Main Vidalia QApplication object
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 <gui/help/browser/helpbrowser.h>
00041 #include <config/vidaliasettings.h>
00042 #include <control/torcontrol.h>
00043 
00044 /** Vidalia's version string */
00045 #define VIDALIA_VERSION    "0.0.8"
00046 
00047 
00048 class Vidalia : public QApplication
00049 {
00050   Q_OBJECT
00051 
00052 public:
00053   /** Constructor. */
00054   Vidalia(QStringList args, int &argc, char **argv);
00055   /** Destructor. */
00056   ~Vidalia();
00057 
00058   /** Return the map of command-line arguments and values. */
00059   static QMap<QString, QString> arguments() { return _args; }
00060   /** Validates that all arguments were well-formed. */
00061   bool validateArguments(QString &errmsg);
00062   /** Prints usage information to the given text stream. */
00063   void printUsage(QString errmsg = QString());
00064 
00065   /** Sets the current language. */
00066   static bool setLanguage(QString languageCode = QString());
00067   /** Sets the current GUI style. */
00068   static bool setStyle(QString styleKey = QString());
00069   /** Shows the specified help topic, or the default if empty. */
00070   static void help(QString topic = QString());
00071 
00072   /** Returns the current language. */
00073   static QString language() { return _language; }
00074   /** Returns the current GUI style. */
00075   static QString style() { return _style; }
00076   /** Returns Vidalia's application version. */
00077   static QString version() { return VIDALIA_VERSION; }
00078 
00079   /** Returns Vidalia's main TorControl object. */
00080   static TorControl* torControl() { return _torControl; }
00081   
00082   /** Returns the location Vidalia uses for its data files. */
00083   static QString dataDirectory();
00084   /** Returns the default location of Vidalia's data directory. */
00085   static QString defaultDataDirectory();
00086   
00087   /** Returns the location of Vidalia's pid file. */
00088   static QString pidFile();
00089   
00090 signals:
00091   /** Signals that the application needs to shutdown now. */
00092   void shutdown();
00093 
00094 protected:
00095 #if defined(Q_OS_WIN)
00096   /** Filters Windows events, looking for events of interest */
00097   bool winEventFilter(MSG *msg, long *result);
00098 #endif
00099 
00100 private:
00101   /** Parse the list of command-line arguments. */
00102   void parseArguments(QStringList args);
00103   /** Returns true if the specified arguments wants a value. */
00104   bool argNeedsValue(QString argName);
00105 
00106   static QMap<QString, QString> _args; /**< List of command-line arguments.  */
00107   static QString _style;               /**< The current GUI style.           */
00108   static QString _language;            /**< The current language.            */
00109   static VidaliaSettings _settings;    /**< Vidalia's configurable settings. */
00110 
00111   static TorControl* _torControl;      /**< Vidalia's main TorControl object.*/
00112   static HelpBrowser* _help;           /**< Vidalia's configurable settings. */
00113 };
00114 
00115 #endif
00116 

Generated on Mon Oct 23 20:08:16 2006 for Vidalia by  doxygen 1.5.0