Vidalia 0.3.1
Signals | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Private Slots | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
Vidalia Class Reference

#include <Vidalia.h>

Inheritance diagram for Vidalia:

Signals

void running ()
 

Public Member Functions

 Vidalia (QStringList args, int &argc, char **argv)
 
 ~Vidalia ()
 
bool validateArguments (QString &errmsg)
 

Static Public Member Functions

static void showUsageMessageBox ()
 
static bool showUsage ()
 
static bool setLanguage (QString languageCode=QString())
 
static bool setStyle (QString styleKey=QString())
 
static QString language ()
 
static QString style ()
 
static QString version ()
 
static TorControltorControl ()
 
static QString dataDirectory ()
 
static QString defaultDataDirectory ()
 
static QString pidFile ()
 
static bool readPasswordFromStdin ()
 
static Log::LogMessage log (Log::LogLevel level, QString msg)
 
static int run ()
 
static void createShortcut (const QKeySequence &key, QWidget *sender, QObject *receiver, const char *slot)
 
static void createShortcut (const QString &key, QWidget *sender, QObject *receiver, const char *slot)
 
static bool retranslateUi (const QString &languageCode)
 

Static Protected Member Functions

static void removeAllTranslators ()
 

Private Slots

void onEventLoopStarted ()
 

Private Member Functions

void parseArguments (QStringList args)
 
bool argNeedsValue (QString argName)
 
void copyDefaultSettingsFile () const
 
void loadDefaultCaCertificates () const
 

Static Private Member Functions

static void qt_msg_handler (QtMsgType type, const char *msg)
 

Static Private Attributes

static QMap< QString, QString > _args
 
static QString _style
 
static QString _language
 
static TorControl_torControl = 0
 
static Log _log
 
static QList< QTranslator * > _translators
 

Detailed Description

Definition at line 46 of file Vidalia.h.

Constructor & Destructor Documentation

◆ Vidalia()

Vidalia::Vidalia ( QStringList  args,
int &  argc,
char **  argv 
)

Constructor.

Constructor. Parses the command-line arguments, resets Vidalia's configuration (if requested), and sets up the GUI style and language translation.

Definition at line 93 of file Vidalia.cpp.

References _args, _log, _torControl, ARG_GUISTYLE, ARG_LANGUAGE, ARG_LOGFILE, ARG_LOGLEVEL, ARG_RESET, copyDefaultSettingsFile(), dataDirectory(), loadDefaultCaCertificates(), Log::Off, Log::open(), parseArguments(), qt_msg_handler(), VSettings::reset(), setLanguage(), Log::setLogLevel(), setStyle(), VSettings::settingsFileExists(), Log::stringToLogLevel(), and vApp.

◆ ~Vidalia()

Vidalia::~Vidalia ( )

Destructor.

Destructor

Definition at line 149 of file Vidalia.cpp.

References _torControl.

Member Function Documentation

◆ argNeedsValue()

bool Vidalia::argNeedsValue ( QString  argName)
private

Returns true if the specified arguments wants a value.

Returns true if the specified argument expects a value.

Definition at line 228 of file Vidalia.cpp.

References ARG_DATADIR, ARG_GUISTYLE, ARG_LANGUAGE, ARG_LOGFILE, ARG_LOGLEVEL, and ARG_PIDFILE.

Referenced by parseArguments(), and validateArguments().

◆ copyDefaultSettingsFile()

void Vidalia::copyDefaultSettingsFile ( ) const
private

Copies a default settings file (if one exists) to Vidalia's data directory.

Definition at line 490 of file Vidalia.cpp.

References VSettings::settingsFile().

Referenced by Vidalia().

◆ createShortcut() [1/2]

void Vidalia::createShortcut ( const QKeySequence &  key,
QWidget *  sender,
QObject *  receiver,
const char *  slot 
)
static

Creates and binds a shortcut such that when key is pressed in sender's context, receiver's slot will be called.

Definition at line 402 of file Vidalia.cpp.

References connect().

Referenced by ConfigDialog::ConfigDialog(), MessageLog::createActions(), createShortcut(), HelpBrowser::HelpBrowser(), and NetViewer::NetViewer().

◆ createShortcut() [2/2]

void Vidalia::createShortcut ( const QString &  key,
QWidget *  sender,
QObject *  receiver,
const char *  slot 
)
static

Creates and binds a shortcut such that when key is pressed in sender's context, receiver's slot will be called.

Definition at line 412 of file Vidalia.cpp.

References createShortcut().

◆ dataDirectory()

QString Vidalia::dataDirectory ( )
static

Returns the location Vidalia uses for its data files.

Returns the directory Vidalia uses for its data files.

Definition at line 355 of file Vidalia.cpp.

References _args, ARG_DATADIR, and defaultDataDirectory().

Referenced by pidFile(), TorSettings::TorSettings(), UpdateProcess::updateRepositoryDir(), and Vidalia().

◆ defaultDataDirectory()

QString Vidalia::defaultDataDirectory ( )
static

Returns the default location of Vidalia's data directory.

Definition at line 365 of file Vidalia.cpp.

References win32_app_data_folder().

Referenced by dataDirectory().

◆ language()

static QString Vidalia::language ( )
inlinestatic

Returns the current language.

Definition at line 69 of file Vidalia.h.

References _language.

Referenced by HelpBrowser::language(), UpdatesAvailableDialog::loadPackagesTable(), and HelpTextBrowser::loadResource().

◆ loadDefaultCaCertificates()

void Vidalia::loadDefaultCaCertificates ( ) const
private

Clears the list of default CA certificates and adds only the ones Vidalia is interested in.

Definition at line 521 of file Vidalia.cpp.

References vWarn.

Referenced by Vidalia().

◆ log()

Log::LogMessage Vidalia::log ( Log::LogLevel  level,
QString  msg 
)
static

Writes msg with severity level to Vidalia's log.

Definition at line 394 of file Vidalia.cpp.

References _log, and Log::log().

◆ onEventLoopStarted

void Vidalia::onEventLoopStarted ( )
privateslot

Called when the application's main event loop has started. This method will emit the running() signal to indicate that the application's event loop is running.

Definition at line 167 of file Vidalia.cpp.

References running().

Referenced by run().

◆ parseArguments()

void Vidalia::parseArguments ( QStringList  args)
private

Parse the list of command-line arguments.

Parses the list of command-line arguments for their argument names and values.

Definition at line 241 of file Vidalia.cpp.

References _args, argNeedsValue(), and i().

Referenced by Vidalia().

◆ pidFile()

QString Vidalia::pidFile ( )
static

Returns the location of Vidalia's pid file.

Definition at line 378 of file Vidalia.cpp.

References _args, ARG_PIDFILE, and dataDirectory().

Referenced by main().

◆ qt_msg_handler()

void Vidalia::qt_msg_handler ( QtMsgType  type,
const char *  s 
)
staticprivate

Catches debugging messages from Qt and sends them to Vidalia's logs.

Catches debugging messages from Qt and sends them to Vidalia's logs. If Qt emits a QtFatalMsg, we will write the message to the log and then abort().

Definition at line 67 of file Vidalia.cpp.

References vDebug, vError, vNotice, and vWarn.

Referenced by Vidalia().

◆ readPasswordFromStdin()

bool Vidalia::readPasswordFromStdin ( )
static

Returns true if Vidalia should read the control password from stdin.

Definition at line 387 of file Vidalia.cpp.

References _args, and ARG_READ_PASSWORD_FROM_STDIN.

◆ removeAllTranslators()

void Vidalia::removeAllTranslators ( )
staticprotected

Removes all currently installed QTranslators.

Definition at line 419 of file Vidalia.cpp.

References _translators, and vInfo.

Referenced by retranslateUi().

◆ retranslateUi()

bool Vidalia::retranslateUi ( const QString &  languageCode)
static

Loads and installs all available translators for the specified languageCode. All currently installed QTranslator objects will be removed. Returns true if at least Vidalia's language file can be loaded for the given language. Otherwise, returns false and no change is made to the current translators.

Definition at line 430 of file Vidalia.cpp.

References _language, _translators, err(), LanguageSupport::isValidLanguageCode(), removeAllTranslators(), vApp, vNotice, and vWarn.

Referenced by AppearancePage::save(), and setLanguage().

◆ run()

int Vidalia::run ( )
static

Enters the main event loop and waits until exit() is called. The signal running() will be emitted when the event loop has started.

Definition at line 157 of file Vidalia.cpp.

References onEventLoopStarted(), and vApp.

Referenced by main().

◆ running

void Vidalia::running ( )
signal

Emitted when the application is running and the main event loop has started.

Referenced by onEventLoopStarted().

◆ setLanguage()

bool Vidalia::setLanguage ( QString  languageCode = QString())
static

Sets the current language.

Sets the translation Vidalia will use. If one was specified on the command-line, we will use that. Otherwise, we'll check to see if one was saved previously. If not, we'll default to one appropriate for the system locale.

Definition at line 318 of file Vidalia.cpp.

References _language, VidaliaSettings::getLanguageCode(), and retranslateUi().

Referenced by Vidalia().

◆ setStyle()

bool Vidalia::setStyle ( QString  styleKey = QString())
static

Sets the current GUI style.

Sets the GUI style Vidalia will use. If one was specified on the command-line, we will use that. Otherwise, we'll check to see if one was saved previously. If not, we'll default to one appropriate for the operating system.

Definition at line 338 of file Vidalia.cpp.

References _style, and VidaliaSettings::getInterfaceStyle().

Referenced by AppearancePage::save(), and Vidalia().

◆ showUsage()

bool Vidalia::showUsage ( )
static

Returns true if the user wants to see usage information.

Definition at line 187 of file Vidalia.cpp.

References _args, and ARG_HELP.

Referenced by main().

◆ showUsageMessageBox()

void Vidalia::showUsageMessageBox ( )
static

Displays usage information for command-line args.

Definition at line 194 of file Vidalia.cpp.

References ARG_DATADIR, ARG_GUISTYLE, ARG_HELP, ARG_LANGUAGE, ARG_LOGFILE, ARG_LOGLEVEL, ARG_PIDFILE, ARG_RESET, VMessageBox::information(), LanguageSupport::languageCodes(), Log::logLevels(), VMessageBox::Ok, tcol(), and trow().

Referenced by main().

◆ style()

static QString Vidalia::style ( )
inlinestatic

Returns the current GUI style.

Definition at line 71 of file Vidalia.h.

References _style.

Referenced by AppearancePage::load().

◆ torControl()

static TorControl * Vidalia::torControl ( )
inlinestatic

◆ validateArguments()

bool Vidalia::validateArguments ( QString &  errmsg)

Validates that all arguments were well-formed.

Verifies that all specified arguments were valid.

Definition at line 272 of file Vidalia.cpp.

References _args, _log, ARG_GUISTYLE, ARG_LANGUAGE, ARG_LOGFILE, ARG_LOGLEVEL, argNeedsValue(), Log::errorString(), Log::isOpen(), LanguageSupport::isValidLanguageCode(), and Log::logLevels().

Referenced by main().

◆ version()

static QString Vidalia::version ( )
inlinestatic

Returns Vidalia's application version.

Definition at line 73 of file Vidalia.h.

References VIDALIA_VERSION.

Referenced by AboutDialog::AboutDialog(), and main().

Member Data Documentation

◆ _args

QMap< QString, QString > Vidalia::_args
staticprivate

List of command-line arguments.

Definition at line 155 of file Vidalia.h.

Referenced by dataDirectory(), parseArguments(), pidFile(), readPasswordFromStdin(), showUsage(), validateArguments(), and Vidalia().

◆ _language

QString Vidalia::_language
staticprivate

The current language.

Definition at line 157 of file Vidalia.h.

Referenced by language(), retranslateUi(), and setLanguage().

◆ _log

Log Vidalia::_log
staticprivate

Logs debugging messages to file or stdout.

Definition at line 159 of file Vidalia.h.

Referenced by log(), validateArguments(), and Vidalia().

◆ _style

QString Vidalia::_style
staticprivate

The current GUI style.

Definition at line 156 of file Vidalia.h.

Referenced by setStyle(), and style().

◆ _torControl

TorControl * Vidalia::_torControl = 0
staticprivate

Vidalia's main TorControl object.

Main TorControl object.

Definition at line 158 of file Vidalia.h.

Referenced by torControl(), Vidalia(), and ~Vidalia().

◆ _translators

QList< QTranslator * > Vidalia::_translators
staticprivate

List of installed translators.

Definition at line 160 of file Vidalia.h.

Referenced by removeAllTranslators(), and retranslateUi().


The documentation for this class was generated from the following files: