summaryrefslogtreecommitdiffstats
path: root/src/kvirc/ui/kvi_console.h
blob: a32ae7ffb38c3877ec012b974bf7f90232ce603f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#ifndef _KVI_CONSOLE_H_
#define _KVI_CONSOLE_H_
//=============================================================================
//
//   File : kvi_console.h
//   Creation date : Sun Jun 25 2000 15:00:20 by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 1999-2000 Szymon Stefanek (pragma at kvirc dot net)
//
//   This program is FREE software. You can redistribute it and/or
//   modify it under the terms of the GNU General Public License
//   as published by the Free Software Foundation; either version 2
//   of the License, or (at your opinion) any later version.
//
//   This program is distributed in the HOPE that it will be USEFUL,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//   See the GNU General Public License for more details.
//
//   You should have received a copy of the GNU General Public License
//   along with this program. If not, write to the Free Software Foundation,
//   Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
//=============================================================================

#include "kvi_settings.h"
#include "kvi_ircconnection.h"
#include "kvi_window.h"
#include "kvi_ircsocket.h"
#include "kvi_string.h"
#include "kvi_irccontext.h"

#include "kvi_pointerlist.h"

#include <time.h>
#include <tqcombobox.h>


class TQToolBar;
class TQToolButton;

class KviAvatar;
class KviDns;
class KviIrcUserDataBase;
class KviIrcUserEntry;
class KviIrcServer;
class KviIrcNetwork;
class KviProxy;
#ifndef COMPILE_ON_WINDOWS
	class KviChannel;
	class KviQuery;
#else
	// windoze wants it to compile TQList<KviChannel> and TQList<KviQuery>
	#include "kvi_channel.h"
	#include "kvi_query.h"
#endif
class KviUserListView;
class KviNotifyListManager;
class KviRegisteredUser;
class KviWindowToolPageButton;



//=================================================================================================
//
// The console window
//
//=================================================================================================

#define KVI_CONSOLE_FLAG_FIRSTINAPP 1
#define KVI_CONSOLE_FLAG_FIRSTINFRAME 2


class KVIRC_API KviConsole : public KviWindow
{
	friend class KviFrame;
	friend class KviIrcSocket;
	friend class KviChannel;
	friend class KviQuery;
	friend class KviIrcContext;
	Q_OBJECT
  TQ_OBJECT
protected:
	KviConsole(KviFrame * lpFrm,int iFlags);
public:
	~KviConsole();
protected:
	int                                m_iFlags; // FIXME: make this a KviWindow property ?
	// UI
	KviUserListView                  * m_pNotifyListView;
	KviWindowToolPageButton          * m_pNotifyViewButton;
	TQComboBox						 * m_pAddressEdit;
	TQString                            m_szStatusString; // nick (flags) on server | not connected
protected:
	// UI
	virtual TQPixmap * myIconPtr();
	virtual void fillCaptionBuffers();
	virtual void resizeEvent(TQResizeEvent *e);
	virtual void closeEvent(TQCloseEvent *e);
	virtual void getBaseLogFileName(TQString &buffer);
	virtual void getTaskBarTipText(TQString &buffer);
	virtual void fillContextPopup(KviTalPopupMenu * p);
	virtual TQSize sizeHint() const;
	virtual void applyOptions();
	virtual void triggerCreationEvents();
	void fillStatusString();
	//void socketError(int iError);
	//void socketStateChange();
	//void registerLinkMonitor(KviIrcSocketMonitor * m);
	//void unregisterLinkMonitor(KviIrcSocketMonitor * m);
	virtual void loadProperties(KviConfig * cfg);
	virtual void saveProperties(KviConfig * cfg);
	
	void destroyConnection();
	// internal helper for applyHighlighting
	int triggerOnHighlight(KviWindow *wnd,int type,const TQString &nick,const TQString &user,const TQString &host,const TQString &szMsg,const TQString &trigger);
	
	void showNotifyList(bool bShow);

public:
	// UI
	KviUserListView * notifyListView(){ return m_pNotifyListView; };
	int selectedCount();


	//
	// State
	//
	KviIrcContext::State state(){ return context()->state(); };
	KVI_DEPRECATED KviIrcContext * ircContext(){ return context(); };
	unsigned int ircContextId() KVI_DEPRECATED;
	//
	// Sock state
	//
	KviIrcSocket * socket() KVI_DEPRECATED;
	
	// these should disappear!
	bool isConnected(){ return context()->isConnected(); };
	bool isIpV6Connection();
	bool isNotConnected();
	bool connectionInProgress();
	//
	// This connection info
	//
	TQString currentNetworkName();
	KviAvatar * currentAvatar();
	//
	// IRC Context wide helpers (connection related)
	//
	void getUserTipText(const TQString &nick,KviIrcUserEntry *e,TQString &buffer);
	enum OutputPrivmsgFlags {
		NoWindowFlashing = 1, // has meaning only if NoHighlighting is NOT given, otherwise it is implied
		NoNotifier = 2, // has meaning only if NoHighlighitng is NOT given, otherwise it is implied
		NoHighlighting = 4,
		NoNotifications = 7 // this is 1|2|4 implies NoWindowFlashing and NoNotifier
	};
	void outputPrivmsg(KviWindow *wnd,int type,const TQString &nick,
		const TQString &user,const TQString &host,const TQString &msg,int iFlags = 0,const TQString &prefix = TQString(),const TQString &suffix = TQString());
	// this applies highlighting to the specified message
	// and triggers the OnHighlight event.
	// it returns KVI_OUT_HIGHLIGHT if highlighting was applied
	// and -1 if OnHighlight called halt
	// otherwise it returns <type>
	int applyHighlighting(KviWindow *wnd,int type,const TQString &nick,const TQString &user,const TQString &host,const TQString &szMsg);
	// Avatar helpers (conneciton related)
	void resetAvatarForMatchingUsers(KviRegisteredUser * u);
	// this should be protected at least
	void avatarChangedUpdateWindows(const TQString &nick,const TQString &textLine);
	void avatarChanged(KviAvatar * avatar,const TQString &nick,const TQString &user,const TQString &host,const TQString &textLine);
	KviAvatar * setAvatar(const TQString &nick,const TQString &user,const TQString &host,const TQString &szLocalPath,const TQString &szName);
	void checkDefaultAvatar(KviIrcUserEntry *e,const TQString &nick,const TQString &user,const TQString &host);
	void setAvatarFromOptions();
	
	// This returns the default avatar for the current KVIrc user
	// if he has choosen a valid avatar in the options dialog
	// otherwise returns 0.
	// The avatar is allocated with new and must be deleted
	// when no longer needed.
	KviAvatar * defaultAvatarFromOptions();

	void terminateConnectionRequest(bool bForce = false,const char * quitMsg = 0);

	// Status string (usermode + nick) (connection related too)
	const TQString & statusString(){ return m_szStatusString; };
	
	// forwarders from KviIrcConnection
	KVI_DEPRECATED KviPointerList<KviChannel> * channelList(){ return connection() ? connection()->channelList() : 0; };
	KVI_DEPRECATED KviPointerList<KviQuery> * queryList(){ return connection() ? connection()->queryList() : 0; };
	KVI_DEPRECATED unsigned int channelCount(){ return (connection() ? connection()->channelList()->count() : 0); };
	KVI_DEPRECATED unsigned int queryCount(){ return (connection() ? connection()->queryList()->count() : 0); };
	
	// Window management
	//KVI_DEPRECATED KviChannel * findChannel(const char * name){ return connection() ? connection()->findChannel(name) : 0; };
	//KVI_DEPRECATED KviQuery * findQuery(const char * nick){ return connection() ? connection()->findQuery(nick) : 0; };

	KviWindow * activeWindow();
	// User db, connection related
	void completeChannel(const TQString &word,KviPointerList<TQString> * matches);
	void completeServer(const TQString &word,KviPointerList<TQString> * matches);
	void connectionAttached();
	void connectionDetached();
public slots:
	void updateUri();
	void executeInternalCommand(int index);
	void recentUrlsChanged();
protected slots:
	void ircUriChanged(const TQString & );
	void toggleNotifyView();
	void textViewRightClicked();
};

#endif //_KVI_CONSOLE_H_