summaryrefslogtreecommitdiffstats
path: root/src/kvirc/kernel/kvi_notifylist.h
blob: 8484f3f7a6863bd5bf75bf307422ba5623f17d83 (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
#ifndef _KVI_NOTIFYLIST_H_
#define _KVI_NOTIFYLIST_H_

//=============================================================================
//
//   File : kvi_notifylist.h
//   Creation date : Fri Oct 27 2000 23:39:09 CEST by Szymon Stefanek
//
//   This file is part of the KVirc irc client distribution
//   Copyright (C) 2000-2004 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 <qobject.h>
#include "kvi_pointerlist.h"
#include "kvi_pointerhashtable.h"
#include <qtimer.h>

#include "kvi_qstring.h"

class KviConsole;
class KviIrcMessage;
class KviIrcMask;
class KviIrcConnection;

class KVIRC_API KviNotifyListManager : public QObject
{
	friend class KviConsole;
	friend class KviConnectionInfo;
	friend class KviServerParser;
	friend class KviIrcConnection;
	Q_OBJECT
protected:
	KviNotifyListManager(KviIrcConnection * pConnection);
	~KviNotifyListManager();
protected:
	KviConsole       * m_pConsole;
	KviIrcConnection * m_pConnection;
protected:
	virtual void start();
	virtual void stop();
	virtual bool handleUserhost(KviIrcMessage * msg);
	virtual bool handleIsOn(KviIrcMessage * msg);
	virtual bool handleWatchReply(KviIrcMessage *msg);
	void notifyOnLine(const QString &nick,const QString &user = QString::null,const QString &host = QString::null,const QString &szReason = QString::null,bool bJoin=true);
	void notifyOffLine(const QString &nick,const QString &user = QString::null,const QString &host = QString::null,const QString &szReason = QString::null);
public:
	KviConsole * console(){ return m_pConsole;  };
};

class KVIRC_API KviIsOnNotifyListManager : public KviNotifyListManager
{
	friend class KviConsole;
	friend class KviServerParser;
	friend class KviIrcConnection;
	Q_OBJECT
protected:
	KviIsOnNotifyListManager(KviIrcConnection * pConnection);
	~KviIsOnNotifyListManager();
private:
	KviPointerHashTable<QString,QString>      * m_pRegUserDict;            // dict notifystring->reguser name
	KviPointerList<QString> * m_pNotifyList;                  // list of notifystring (total)
	KviPointerList<QString> * m_pIsOnList;                    // list of notifystring (one session)
	QString               m_szIsOnString;                 // m_pIsOnList in form of a string
	KviPointerList<QString> * m_pOnlineList;                  //
	KviPointerList<QString> * m_pUserhostList;
	QString               m_szUserhostString;
	bool                  m_bExpectingIsOn;
	bool                  m_bExpectingUserhost;
	QTimer              * m_pDelayedIsOnTimer;
	QTimer              * m_pDelayedNotifyTimer;
	QTimer              * m_pDelayedUserhostTimer;
	bool                  m_bRunning;
protected:
	virtual void start();
	virtual void stop();
	virtual bool handleUserhost(KviIrcMessage *msg);
	virtual bool handleIsOn(KviIrcMessage *msg);
private:
	void delayedNotifySession();
	void delayedIsOnSession();
	void delayedUserhostSession();
private slots:
	void newNotifySession();
	void newIsOnSession();
	void newUserhostSession();

	void buildRegUserDict();
	void buildIsOnList();
	void buildUserhostList();
	void buildNotifyList();
	void sendIsOn();
	void sendUserhost();
	bool doMatchUser(const QString &notifyString,const KviIrcMask & mask);

};


class KVIRC_API KviStupidNotifyListManager : public KviNotifyListManager
{
	friend class KviConsole;
	friend class KviServerParser;
	friend class KviIrcConnection;
	Q_OBJECT
protected:
	KviStupidNotifyListManager(KviIrcConnection * pConnection);
	~KviStupidNotifyListManager();
protected:
	KviPointerList<QString> * m_pNickList;
	QString m_szLastIsOnMsg;
	int m_iNextNickToCheck;
	int m_iRestartTimer;
protected:
	virtual void start();
	virtual void stop();
	virtual bool handleIsOn(KviIrcMessage *msg);
protected:
	virtual void timerEvent(QTimerEvent *e);
private:
	void buildNickList();
	void sendIsOn();
};

class KVIRC_API KviWatchNotifyListManager : public KviNotifyListManager
{
	friend class KviConsole;
	friend class KviServerParser;
	friend class KviIrcConnection;
	Q_OBJECT
public:
	KviWatchNotifyListManager(KviIrcConnection * pConnection);
	~KviWatchNotifyListManager();
protected:
	KviPointerHashTable<QString,QString> * m_pRegUserDict;            // dict notifystring->reguser name
protected:
	void buildRegUserDict();
	virtual void start();
	virtual void stop();
	virtual bool handleWatchReply(KviIrcMessage *msg);
	bool doMatchUser(KviIrcMessage *msg,const QString &notifyString,const KviIrcMask & mask);

};

#endif //_KVI_NOTIFYLIST_H_