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 messagelog.h 00024 * \version $Id: messagelog.h 1563 2006-12-26 06:06:04Z edmanm $ 00025 * \brief Displays log messages and message log settings 00026 */ 00027 00028 #ifndef _MESSAGELOG_H 00029 #define _MESSAGELOG_H 00030 00031 #include <QMainWindow> 00032 #include <QStringList> 00033 #include <QResizeEvent> 00034 #include <control/torcontrol.h> 00035 #include <config/vidaliasettings.h> 00036 #include <gui/common/vidaliawindow.h> 00037 00038 #include "logfile.h" 00039 #include "logtreeitem.h" 00040 #include "ui_messagelog.h" 00041 00042 00043 class MessageLog : public VidaliaWindow 00044 { 00045 Q_OBJECT 00046 00047 public: 00048 /** Default constructor **/ 00049 MessageLog(QWidget *parent = 0, Qt::WFlags flags = 0); 00050 /** Default destructor **/ 00051 ~MessageLog(); 00052 00053 protected: 00054 /** Called to deliver custom event types */ 00055 void customEvent(QEvent *event); 00056 00057 private slots: 00058 /** Called when the user triggers the save all action **/ 00059 void saveAll(); 00060 /** Called when the user triggers save selected action **/ 00061 void saveSelected(); 00062 /** Called when the user triggers the copy action **/ 00063 void copy(); 00064 /** Called when the user triggers the find action. This will search 00065 * through all currently displayed log entries for text specified by the 00066 * user, highlighting the entries that contain a match. */ 00067 void find(); 00068 /** Called when user saves settings **/ 00069 void saveSettings(); 00070 /** Called when user cancels changed settings **/ 00071 void cancelChanges(); 00072 /** Called when the user clicks "Browse" to select a new log file. */ 00073 void browse(); 00074 /** Called when the user clicks "Help" to see help info about the log. */ 00075 void help(); 00076 00077 protected: 00078 /** Responds to the user resizing the message log. */ 00079 void resizeEvent(QResizeEvent *event); 00080 00081 private: 00082 /** Create and bind actions to events **/ 00083 void createActions(); 00084 /** Set Tool Tips for various widgets **/ 00085 void setToolTips(); 00086 /** Loads the saved Message Log settings **/ 00087 void loadSettings(); 00088 /** Registers the current message filter with Tor */ 00089 void registerLogEvents(); 00090 /** Saves the given list of items to a file */ 00091 void save(QStringList messages); 00092 /** Adds the passed message to the message log as the specified type **/ 00093 void log(LogEvent::Severity, QString msg); 00094 /** Rotates the log file based on the filename and the current logging status. */ 00095 bool rotateLogFile(QString filename); 00096 00097 /** A pointer to a TorControl object, used to register for log events */ 00098 TorControl* _torControl; 00099 /** A VidaliaSettings object that handles getting/saving settings **/ 00100 VidaliaSettings* _settings; 00101 /** Stores the current message filter */ 00102 uint _filter; 00103 /** Set to true if we will log all messages to a file. */ 00104 bool _enableLogging; 00105 /* The log file used to store log messages. */ 00106 LogFile _logFile; 00107 00108 /** Qt Designer generatated QObject **/ 00109 Ui::MessageLog ui; 00110 }; 00111 00112 #endif 00113