00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file messagelog.h 00013 ** \version $Id: messagelog.h 2922 2008-08-03 01:19:40Z edmanm $ 00014 ** \brief Displays log messages and message log settings 00015 */ 00016 00017 #ifndef _MESSAGELOG_H 00018 #define _MESSAGELOG_H 00019 00020 #include <QMainWindow> 00021 #include <QStringList> 00022 #include <QResizeEvent> 00023 #include <torcontrol.h> 00024 #include <vidaliasettings.h> 00025 #include <vidaliawindow.h> 00026 00027 #include "logfile.h" 00028 #include "logtreeitem.h" 00029 #include "ui_messagelog.h" 00030 00031 00032 class MessageLog : public VidaliaWindow 00033 { 00034 Q_OBJECT 00035 00036 public: 00037 /** Default constructor **/ 00038 MessageLog(QWidget *parent = 0, Qt::WFlags flags = 0); 00039 /** Default destructor **/ 00040 ~MessageLog(); 00041 00042 protected: 00043 /** Called to deliver custom event types */ 00044 void customEvent(QEvent *event); 00045 00046 private slots: 00047 /** Called when the user triggers the save all action **/ 00048 void saveAll(); 00049 /** Called when the user triggers save selected action **/ 00050 void saveSelected(); 00051 /** Called when the user triggers the copy action **/ 00052 void copy(); 00053 /** Called when the user triggers the find action. This will search 00054 * through all currently displayed log entries for text specified by the 00055 * user, highlighting the entries that contain a match. */ 00056 void find(); 00057 /** Called when user saves settings **/ 00058 void saveSettings(); 00059 /** Called when user cancels changed settings **/ 00060 void cancelChanges(); 00061 /** Called when the user clicks "Browse" to select a new log file. */ 00062 void browse(); 00063 /** Called when the user clicks "Help" to see help info about the log. */ 00064 void help(); 00065 00066 private: 00067 /** Create and bind actions to events **/ 00068 void createActions(); 00069 /** Set Tool Tips for various widgets **/ 00070 void setToolTips(); 00071 /** Loads the saved Message Log settings **/ 00072 void loadSettings(); 00073 /** Registers the current message filter with Tor */ 00074 void registerLogEvents(); 00075 /** Saves the given list of items to a file */ 00076 void save(QStringList messages); 00077 /** Adds the passed message to the message log as the specified type **/ 00078 void log(LogEvent::Severity, QString msg); 00079 /** Rotates the log file based on the filename and the current logging status. */ 00080 bool rotateLogFile(QString filename); 00081 00082 /** A pointer to a TorControl object, used to register for log events */ 00083 TorControl* _torControl; 00084 /** A VidaliaSettings object that handles getting/saving settings **/ 00085 VidaliaSettings* _settings; 00086 /** Stores the current message filter */ 00087 uint _filter; 00088 /** Set to true if we will log all messages to a file. */ 00089 bool _enableLogging; 00090 /* The log file used to store log messages. */ 00091 LogFile _logFile; 00092 00093 /** Qt Designer generatated QObject **/ 00094 Ui::MessageLog ui; 00095 }; 00096 00097 #endif 00098