Make SSL work again for CoreConnection
[quassel.git] / src / qtui / mainwin.h
1 /***************************************************************************
2  *   Copyright (C) 2005-09 by the Quassel Project                          *
3  *   devel@quassel-irc.org                                                 *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) version 3.                                           *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
19  ***************************************************************************/
20
21 #ifndef MAINWIN_H_
22 #define MAINWIN_H_
23
24 #ifdef HAVE_KDE
25 #  include <KMainWindow>
26 #else
27 #  include <QMainWindow>
28 #endif
29
30 #ifdef Q_WS_WIN
31 #  include <windows.h>
32 #endif
33
34 #include <QSystemTrayIcon>
35
36 #include "qtui.h"
37 #include "titlesetter.h"
38 #include "uisettings.h"
39
40 class ActionCollection;
41 class BufferHotListFilter;
42 class BufferView;
43 class BufferViewConfig;
44 class ClientBufferViewConfig;
45 class CoreAccount;
46 class CoreConnectionStatusWidget;
47 class BufferViewDock;
48 class BufferWidget;
49 class InputWidget;
50 class MsgProcessorStatusWidget;
51 class NickListWidget;
52 class SystemTray;
53
54 class QMenu;
55 class QLabel;
56 class QToolBar;
57
58 class KHelpMenu;
59
60 //!\brief The main window of Quassel's QtUi.
61 class MainWin
62 #ifdef HAVE_KDE
63 : public KMainWindow {
64 #else
65 : public QMainWindow {
66 #endif
67   Q_OBJECT
68
69   public:
70     MainWin(QWidget *parent = 0);
71     virtual ~MainWin();
72
73     void init();
74
75     void addBufferView(ClientBufferViewConfig *config);
76     BufferView *allBuffersView() const;
77
78     BufferWidget *bufferWidget() const { return _bufferWidget; }
79
80     inline SystemTray *systemTray() const;
81
82     bool event(QEvent *event);
83
84     static void flagRemoteCoreOnly(QObject *object) { object->setProperty("REMOTE_CORE_ONLY", true); }
85     static bool isRemoteCoreOnly(QObject *object) { return object->property("REMOTE_CORE_ONLY").toBool(); }
86
87     void saveStateToSettings(UiSettings &);
88     void restoreStateFromSettings(UiSettings &);
89
90   public slots:
91     void showStatusBarMessage(const QString &message);
92
93     void toggleMinimizedToTray();
94
95     //! Bring window to front and focus it
96     void forceActivated();
97
98     //! Quit application
99     void quit();
100
101   protected:
102     void closeEvent(QCloseEvent *event);
103     void changeEvent(QEvent *event);
104     void moveEvent(QMoveEvent *event);
105     void resizeEvent(QResizeEvent *event);
106
107   protected slots:
108     void connectedToCore();
109     void setConnectedState();
110     void updateLagIndicator(int lag = -1);
111     void disconnectedFromCore();
112     void setDisconnectedState();
113
114   private slots:
115     void addBufferView(int bufferViewConfigId);
116     void awayLogDestroyed();
117     void removeBufferView(int bufferViewConfigId);
118     void currentBufferChanged(BufferId);
119     void messagesInserted(const QModelIndex &parent, int start, int end);
120     void showAboutDlg();
121     void showChannelList(NetworkId netId = NetworkId());
122     void showCoreConnectionDlg();
123     void showCoreInfoDlg();
124     void showAwayLog();
125     void showSettingsDlg();
126     void showNotificationsDlg();
127     void showIgnoreList(QString newRule = QString());
128 #ifdef HAVE_KDE
129     void showShortcutsDlg();
130 #endif
131     void startInternalCore();
132     void userAuthenticationRequired(CoreAccount *, bool *valid, const QString &errorMessage);
133     void handleNoSslInClient(bool *accepted);
134     void handleNoSslInCore(bool *accepted);
135 #ifdef HAVE_SSL
136     void handleSslErrors(const QSslSocket *socket, bool *accepted, bool *permanently);
137 #endif
138
139     void on_actionConfigureNetworks_triggered();
140     void on_actionConfigureViews_triggered();
141     void on_actionLockLayout_toggled(bool lock);
142     void on_jumpHotBuffer_triggered();
143     void on_actionDebugNetworkModel_triggered();
144     void on_actionDebugBufferViewOverlay_triggered();
145     void on_actionDebugMessageModel_triggered();
146     void on_actionDebugHotList_triggered();
147     void on_actionDebugLog_triggered();
148
149     void clientNetworkCreated(NetworkId);
150     void clientNetworkRemoved(NetworkId);
151     void clientNetworkUpdated();
152     void connectOrDisconnectFromNet();
153
154     void saveMenuBarStatus(bool enabled);
155     void saveStatusBarStatus(bool enabled);
156
157     void loadLayout();
158     void saveLayout();
159
160     void bufferViewToggled(bool enabled);
161
162   signals:
163     void connectToCore(const QVariantMap &connInfo);
164     void disconnectFromCore();
165
166   private:
167 #ifdef HAVE_KDE
168     KHelpMenu *_kHelpMenu;
169 #endif
170
171     QLabel *coreLagLabel;
172     QLabel *sslLabel;
173     MsgProcessorStatusWidget *_msgProcessorStatusWidget;
174     CoreConnectionStatusWidget *_coreConnectionStatusWidget;
175
176     TitleSetter _titleSetter;
177
178     void setupActions();
179     void setupBufferWidget();
180     void setupMenus();
181     void setupNickWidget();
182     void setupChatMonitor();
183     void setupInputWidget();
184     void setupTopicWidget();
185     void setupStatusBar();
186     void setupSystray();
187     void setupTitleSetter();
188     void setupToolBars();
189     void setupHotList();
190
191     void updateIcon();
192     void enableMenus();
193
194     void hideToTray();
195
196     SystemTray *_systemTray;
197
198     QList<BufferViewDock *> _bufferViews;
199     BufferWidget *_bufferWidget;
200     NickListWidget *_nickListWidget;
201     InputWidget *_inputWidget;
202
203     QMenu *_fileMenu, *_networksMenu, *_viewMenu, *_bufferViewsMenu, *_settingsMenu, *_helpMenu, *_helpDebugMenu;
204     QMenu *_toolbarMenu;
205     QToolBar *_mainToolBar, *_chatViewToolBar, *_nickToolBar;
206
207     QWidget *_awayLog;
208
209     bool _layoutLoaded;
210
211     QSize _normalSize; //!< Size of the non-maximized window
212     QPoint _normalPos; //!< Position of the non-maximized window
213
214 #ifdef Q_WS_WIN
215     DWORD dwTickCount;
216 #endif
217
218     BufferHotListFilter *_bufferHotList;
219
220     friend class QtUi;
221 };
222
223 SystemTray *MainWin::systemTray() const {
224   return _systemTray;
225 }
226
227 #endif