2 /* Copyright (C) 2006 - 2014 Jan Kundrát <jkt@flaska.net>
4 This file is part of the Trojita Qt IMAP e-mail client,
5 http://trojita.flaska.net/
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of
10 the License or (at your option) version 3 or any later version
11 accepted by the membership of KDE e.V. (or its successor approved
12 by the membership of KDE e.V.), which shall act as a proxy
13 defined in Section 14 of version 3 of the license.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef GUI_PROTOCOLLOGGERWIDGET_H
25 #define GUI_PROTOCOLLOGGERWIDGET_H
29 #include "Common/FileLogger.h"
30 #include "Common/RingBuffer.h"
31 #include "Imap/ConnectionState.h"
44 /** @short Widget (etc) for a single connection */
45 struct ConnectionLog
{
47 QPlainTextEdit
*widget
;
48 Common::RingBuffer
<Common::LogMessage
> buffer
;
52 /** @short Protocol chat logger
54 A widget used for displaying a log of textual communication between
55 the client and the IMAP mail server.
57 class ProtocolLoggerWidget
: public QWidget
61 explicit ProtocolLoggerWidget(QWidget
*parent
= 0);
62 virtual ~ProtocolLoggerWidget();
65 /** @short An IMAP model wants to log something */
66 void slotImapLogged(uint parserId
, Common::LogMessage message
);
68 void onConnectionClosed(uint parserId
, Imap::ConnectionState state
);
70 /** @short Enable/disable persistent logging */
71 void slotSetPersistentLogging(const bool enabled
);
74 /** @short A tab is requested to close */
75 void closeTab(int index
);
76 /** @short Clear all logs */
77 void clearLogDisplay();
79 /** @short Copy contents of all buffers into the GUI widgets */
83 void persistentLoggingChanged(const bool active
);
87 QMap
<uint
, ConnectionLog
> logs
;
88 QPushButton
*clearAll
;
90 QTimer
*delayedDisplay
;
91 Common::FileLogger
*m_fileLogger
;
93 /** @short Return (possibly newly created) logger widget for a given parser */
94 QPlainTextEdit
*getLogger(const uint parserId
);
96 /** @short Dump the log bufer contents to the GUI widget */
97 void flushToWidget(const uint parserId
, Common::RingBuffer
<Common::LogMessage
> &buf
);
99 virtual void showEvent(QShowEvent
*e
);
100 virtual void hideEvent(QHideEvent
*e
);
105 #endif // GUI_PROTOCOLLOGGERWIDGET_H