KVIrc  4.9.2
DeveloperAPIs
KviConsoleWindow.h
Go to the documentation of this file.
1 #ifndef _KVI_CONSOLE_H_
2 #define _KVI_CONSOLE_H_
3 //=============================================================================
4 //
5 // File : KviConsoleWindow.h
6 // Creation date : Sun Jun 25 2000 15:00:20 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26 
27 #include "kvi_settings.h"
28 #include "KviIrcConnection.h"
29 #include "KviIrcConnectionTarget.h"
30 #include "KviWindow.h"
31 #include "KviIrcSocket.h"
32 #include "KviIrcServer.h"
33 #include "KviCString.h"
34 #include "KviIrcContext.h"
35 #include "KviPointerList.h"
36 #include "KviUserListView.h"
37 #include "KviThemedComboBox.h"
38 
39 #include <time.h>
40 
41 #include <QToolButton>
42 
43 class QToolBar;
44 
45 class KviAvatar;
46 class KviDnsResolver;
47 class KviIrcUserDataBase;
48 class KviIrcUserEntry;
49 class KviIrcServer;
50 class KviIrcNetwork;
51 class KviProxy;
52 class KviUserListView;
54 class KviRegisteredUser;
56 
57 #ifdef COMPILE_ON_WINDOWS
58 // windoze wants it to compile QList<KviChannelWindow> and QList<KviQueryWindow>
59 #include "KviChannelWindow.h"
60 #include "KviQueryWindow.h"
61 #else
62 class KviChannelWindow;
63 class KviQueryWindow;
64 #endif
65 
66 //=================================================================================================
67 //
68 // The console window
69 //
70 //=================================================================================================
71 
72 #define KVI_CONSOLE_FLAG_FIRSTINAPP 1
73 #define KVI_CONSOLE_FLAG_FIRSTINFRAME 2
74 
76 {
77  friend class KviMainWindow;
78  friend class KviIrcSocket;
79  friend class KviChannelWindow;
80  friend class KviQueryWindow;
81  friend class KviIrcContext;
82  Q_OBJECT
83 protected:
84  KviConsoleWindow(int iFlags);
85 
86 public:
88 
89 protected:
90  int m_iFlags; // FIXME: make this a KviWindow property ?
91  // UI
95  QString m_szStatusString; // nick (flags) on server | not connected
99  QList<int> m_SplitterSizesList;
100 
101 protected:
102  // UI
103  virtual QPixmap * myIconPtr();
104  virtual void fillCaptionBuffers();
105  virtual void resizeEvent(QResizeEvent * e);
106  virtual void closeEvent(QCloseEvent * e);
107  virtual void getBaseLogFileName(QString & buffer);
108  virtual void getWindowListTipText(QString & buffer);
109  virtual QSize sizeHint() const;
110  virtual void applyOptions();
111  virtual void triggerCreationEvents();
112  void fillStatusString();
113  //void socketError(int iError);
114  //void socketStateChange();
115  //void registerLinkMonitor(KviIrcSocketMonitor * m);
116  //void unregisterLinkMonitor(KviIrcSocketMonitor * m);
117  virtual void loadProperties(KviConfigurationFile * cfg);
118  virtual void saveProperties(KviConfigurationFile * cfg);
119 
120  void destroyConnection();
121  // internal helper for applyHighlighting
122  int triggerOnHighlight(KviWindow * wnd, int type, const QString & nick, const QString & user, const QString & host, const QString & szMsg, const QString & trigger);
123 
124  void showNotifyList(bool bShow, bool bIgnoreSizeChange = false);
125  static int getSmartColorHashForNick(QString * szNick);
126 
127 public:
128  KviIrcContext * context() { return m_pContext; };
129 
130  // UI
131  inline KviUserListView * notifyListView() { return m_pNotifyListView; };
132  inline int selectedCount();
133 
134  //
135  // State
136  //
137  inline KviIrcContext::State state() { return context()->state(); };
138 
139  // these should disappear!
140  inline bool isConnected() { return context()->isConnected(); };
141  inline bool isIPv6Connection();
142  inline bool isNotConnected();
143  bool connectionInProgress();
144  //
145  // This connection info
146  //
147  inline QString currentNetworkName();
148  KviAvatar * currentAvatar();
149  //
150  // IRC Context wide helpers (connection related)
151  //
152  void getUserTipText(const QString & nick, KviIrcUserEntry * e, QString & buffer);
154  {
155  NoWindowFlashing = 1, // has meaning only if NoHighlighting is NOT given, otherwise it is implied
156  NoNotifier = 2, // has meaning only if NoHighlighitng is NOT given, otherwise it is implied
157  NoHighlighting = 4,
158  NoNotifications = 7 // this is 1|2|4 implies NoWindowFlashing and NoNotifier
159  };
160  void outputPrivmsg(KviWindow * wnd, int type, const QString & nick,
161  const QString & user, const QString & host, const QString & msg, int iFlags = 0, const QString & prefix = QString(), const QString & suffix = QString(), const QDateTime & datetime = QDateTime());
162  // this applies highlighting to the specified message
163  // and triggers the OnHighlight event.
164  // it returns KVI_OUT_HIGHLIGHT if highlighting was applied
165  // and -1 if OnHighlight called halt
166  // otherwise it returns <type>
167  int applyHighlighting(KviWindow * wnd, int type, const QString & nick, const QString & user, const QString & host, const QString & szMsg);
168  // Avatar helpers (conneciton related)
169  void resetAvatarForMatchingUsers(KviRegisteredUser * u);
170  // this should be protected at least
171  void avatarChangedUpdateWindows(const QString & nick, const QString & textLine);
172  void avatarChanged(KviAvatar * avatar, const QString & nick, const QString & user, const QString & host, const QString & textLine);
173  KviAvatar * setAvatar(const QString & nick, const QString & user, const QString & host, const QString & szLocalPath, const QString & szName);
174  void checkDefaultAvatar(KviIrcUserEntry * e, const QString & nick, const QString & user, const QString & host);
175  void setAvatarFromOptions();
176 
177  // This returns the default avatar for the current KVIrc user
178  // if he has chosen a valid avatar in the options dialog
179  // otherwise returns 0.
180  // The avatar is allocated with new and must be deleted
181  // when no longer needed.
182  KviAvatar * defaultAvatarFromOptions();
183 
184  void terminateConnectionRequest(bool bForce = false, const char * quitMsg = 0);
185 
186  // Status string (usermode + nick) (connection related too)
187  inline const QString & statusString() { return m_szStatusString; };
188 
189  KviWindow * activeWindow();
190  // User db, connection related
191  void completeChannel(const QString & word, KviPointerList<QString> * matches);
192  void completeServer(const QString & word, KviPointerList<QString> * matches);
193  void connectionAttached();
194  void connectionDetached();
195 
201  void addHighlightedChannel(const QString & szChan);
202 
208  void removeHighlightedChannel(const QString & szChan);
209 
215  bool isHighlightedChannel(const QString & szChan) { return m_pTmpHighLightedChannels->contains(szChan, Qt::CaseInsensitive); };
216 
217 public slots:
218  void updateUri();
219  void executeInternalCommand(int index);
220  void recentUrlsChanged();
221 protected slots:
222  void ircUriChanged(const QString &);
223  void toggleNotifyView();
224  void textViewRightClicked();
225 };
226 
228 {
230 }
231 
233 {
235  return connection()->target()->server()->isIPv6();
236 }
237 
239 {
240  return (context()->state() == KviIrcContext::Idle);
241 }
242 
244 {
245  return (connection() ? connection()->currentNetworkName() : QString());
246 }
247 
248 #endif //_KVI_CONSOLE_H_
KviIrcContext * context()
Definition: KviWindow.cpp:1372
bool isHighlightedChannel(const QString &szChan)
Returns true if the channel is highlighted.
Definition: KviConsoleWindow.h:215
bool isIPv6() const
Returns true if the server uses IPv6.
Definition: KviIrcServer.h:277
KviIrcConnection * connection()
Returns the current IRC connection (if any)
Definition: KviWindow.cpp:1365
Definition: KviMainWindow.h:60
Definition: KviConsoleWindow.h:75
virtual void saveProperties(KviConfigurationFile *pCfg)
Definition: KviWindow.cpp:562
The class which manages the irc servers.
Definition: KviIrcServer.h:51
bool isNotConnected()
Definition: KviConsoleWindow.h:238
#define KVIRC_API
Definition: kvi_settings.h:128
virtual void closeEvent(QCloseEvent *pEvent)
Definition: KviWindow.cpp:858
User list view management.
void destroyConnection()
Definition: KviIrcContext.cpp:343
Query widget: abstraction of an IRC query.
int selectedCount()
Returns the number of selected entries in the userlist.
Definition: KviUserListView.h:349
virtual void loadProperties(KviConfigurationFile *pCfg)
Definition: KviWindow.cpp:588
QString currentNetworkName()
Definition: KviConsoleWindow.h:243
bool isConnected()
Definition: KviIrcContext.h:119
KviIrcContext * m_pContext
Definition: KviConsoleWindow.h:98
Definition: KviConfigurationFile.h:48
Definition: KviRegisteredUser.h:35
Definition: KviNotifyList.h:41
KviThemedComboBox * m_pAddressEdit
Definition: KviConsoleWindow.h:94
Definition: KviProxy.h:37
KviUserListView * notifyListView()
Definition: KviConsoleWindow.h:131
QString type()
Definition: KviRuntimeInfo.cpp:646
#define e
Definition: detector.cpp:69
OutputPrivmsgFlags
Definition: KviConsoleWindow.h:153
The class which manages a query.
Definition: KviQueryWindow.h:49
Network handling class.
Definition: KviIrcNetwork.h:47
virtual QPixmap * myIconPtr()
Definition: KviWindow.cpp:619
An abstraction of a connection to an IRC server.
Definition: KviThemedComboBox.h:33
Avatar class.
Definition: KviAvatar.h:52
virtual void applyOptions()
Definition: KviWindow.cpp:1129
State
Definition: KviIrcContext.h:74
QList< int > m_SplitterSizesList
Definition: KviConsoleWindow.h:99
virtual void fillCaptionBuffers()
Definition: KviWindow.cpp:624
Definition: KviWindowToolWidget.h:47
virtual void triggerCreationEvents()
Definition: KviWindow.h:437
The KviDnsResolver class.
Definition: KviDnsResolver.h:93
#define KVI_ASSERT(__condition__)
GNUC
Definition: kvi_debug.h:138
KviIrcConnectionTarget * target()
Returns the target of this connection.
Definition: KviIrcConnection.h:209
virtual void getWindowListTipText(QString &szBuffer)
Definition: KviWindow.h:348
QString m_szStatusString
Definition: KviConsoleWindow.h:95
KviWindowToolPageButton * m_pNotifyViewButton
Definition: KviConsoleWindow.h:93
C++ Template based double linked pointer list class.
Base class for all windows in KVIrc.
Definition: KviWindow.h:74
Lower stack protocol for IRC connection.
KviIrcServer * server()
Definition: KviIrcConnectionTarget.h:56
A class to handle the entries of the user database.
Definition: KviIrcUserEntry.h:45
const QString & statusString()
Definition: KviConsoleWindow.h:187
The class which manages the user database.
Definition: KviIrcUserDataBase.h:45
QStringList * m_pTmpHighLightedChannels
Definition: KviConsoleWindow.h:97
Contains the KviWindow class.
#define u
Definition: detector.cpp:85
virtual void getBaseLogFileName(QString &szBuffer)
Definition: KviWindow.cpp:557
KviIrcContext * context()
Definition: KviConsoleWindow.h:128
Irc server handling.
Definition: KviIrcContext.h:76
Channel widget: abstraction of an IRC channel.
QString m_szOwnSmartColor
Definition: KviConsoleWindow.h:96
bool isConnected()
Definition: KviConsoleWindow.h:140
void terminateConnectionRequest(bool bForce, const QString &szQuitMessage=QString(), bool bSimulateUnexpectedDisconnect=false)
Definition: KviIrcContext.cpp:859
This file contains compile time settings.
KviUserListView * m_pNotifyListView
Definition: KviConsoleWindow.h:92
User list view management class.
Definition: KviUserListView.h:226
Definition: KviIrcContext.h:58
This class is the lowest level of the KVIrc networking stack.
Definition: KviIrcSocket.h:71
friend class KviConsoleWindow
Definition: KviIrcContext.h:60
int selectedCount()
Definition: KviConsoleWindow.h:227
KviIrcContext::State state()
Definition: KviConsoleWindow.h:137
int m_iFlags
Definition: KviConsoleWindow.h:90
State state()
Definition: KviIrcContext.h:118
bool isIPv6Connection()
Definition: KviConsoleWindow.h:232
The class which manages a channel.
Definition: KviChannelWindow.h:113