summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/irc/ircsignalhandler.cpp
blob: 5bfab0ccbdb98d3c19dfce7f34560570c0a5d538 (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

/*
    ircsignalhandler.cpp - Maps signals from the IRC engine to contacts

    Copyright (c) 2004      by Jason Keirstead <jason@keirstead.org>

    Kopete    (c) 2002-2003 by the Kopete developers <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * 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 option) any later version.                                   *
    *                                                                       *
    *************************************************************************
*/

#include "ircusercontact.h"
#include "ircchannelcontact.h"
#include "ircsignalhandler.h"

#include "kircengine.h"

IRCSignalHandler::IRCSignalHandler(IRCContactManager *m)
	: QObject(m),
	  manager(m)
{
	KIRC::Engine *m_engine = static_cast<IRCAccount*>( manager->mySelf()->account() )->engine();

	//Channel Connections to ourself
	QObject::connect(m_engine, SIGNAL(incomingNamesList(const QString &, const QStringList &)),
		this, SLOT(slotNamesList(const QString &, const QStringList &)));

	QObject::connect(m_engine, SIGNAL(incomingEndOfNames(const QString &)),
		this, SLOT(slotEndOfNames(const QString &)));

	QObject::connect(m_engine, SIGNAL(incomingTopicUser(const QString &, const QString &, const QDateTime &)),
		this, SLOT(slotTopicUser(const QString&,const QString&,const QDateTime&)));

	//Channel String mappings
	map<IRCChannelContact>( m, SIGNAL(incomingFailedChankey(const QString &)),
		&IRCChannelContact::failedChankey );

	map<IRCChannelContact>( m, SIGNAL(incomingFailedChanFull(const QString &)),
		&IRCChannelContact::failedChanInvite );

	map<IRCChannelContact>( m, SIGNAL(incomingFailedChanInvite(const QString &)),
		&IRCChannelContact::failedChanInvite );

	map<IRCChannelContact>( m, SIGNAL(incomingFailedChanBanned(const QString &)),
		&IRCChannelContact::failedChanBanned );

	mapSingle<IRCChannelContact>( m, SIGNAL(incomingJoinedChannel(const QString &, const QString &)),
		&IRCChannelContact::userJoinedChannel );

	mapSingle<IRCChannelContact>( m, SIGNAL(incomingExistingTopic(const QString &, const QString &)),
		&IRCChannelContact::channelTopic );

	mapSingle<IRCChannelContact>( m, SIGNAL(incomingChannelHomePage(const QString &, const QString &)),
		&IRCChannelContact::channelHomePage );

	mapDouble<IRCChannelContact>( m,
		SIGNAL(incomingPartedChannel(const QString &, const QString &,const QString &)),
		&IRCChannelContact::userPartedChannel );

	mapDouble<IRCChannelContact>( m,
		SIGNAL(incomingTopicChange(const QString &, const QString &,const QString &)),
		&IRCChannelContact::topicChanged );

	mapDouble<IRCChannelContact>( m,
		SIGNAL(incomingChannelModeChange(const QString &, const QString &,const QString &)),
		&IRCChannelContact::incomingModeChange );

	mapDouble<IRCChannelContact>( m,
		SIGNAL(incomingChannelMode(const QString &, const QString &,const QString &)),
		&IRCChannelContact::incomingChannelMode );

	mapTriple<IRCChannelContact>( m,
		SIGNAL(incomingKick(const QString &, const QString &,const QString &,const QString &)),
		&IRCChannelContact::userKicked );

	//User connections to ourself
	QObject::connect(m_engine, SIGNAL(incomingWhoIsIdle(const QString &, unsigned long )),
			this, SLOT(slotNewWhoIsIdle(const QString &, unsigned long )));

	QObject::connect(m_engine, SIGNAL(incomingWhoReply(const QString &, const QString &, const QString &,
		const QString &, const QString &, bool, const QString &, uint, const QString & )),
		this, SLOT( slotNewWhoReply(const QString &, const QString &, const QString &, const QString &,
		const QString &, bool, const QString &, uint, const QString &)));

	//User signal mappings
	map<IRCUserContact>( m, SIGNAL(incomingUserOnline( const QString & )), &IRCUserContact::userOnline );

	map<IRCUserContact>( m, SIGNAL(incomingWhoIsOperator( const QString & )), &IRCUserContact::newWhoIsOperator );

	map<IRCUserContact>( m, SIGNAL(incomingWhoIsIdentified( const QString & )), &IRCUserContact::newWhoIsIdentified );

	map<IRCUserContact>( m, SIGNAL(incomingEndOfWhois( const QString & )), &IRCUserContact::whoIsComplete );

	map<IRCUserContact>( m, SIGNAL(incomingEndOfWhoWas( const QString & )), &IRCUserContact::whoWasComplete );

	mapSingle<IRCUserContact>( m, SIGNAL(incomingUserIsAway( const QString &, const QString & )),
		&IRCUserContact::incomingUserIsAway );

	mapSingle<IRCUserContact>( m, SIGNAL(incomingWhoIsChannels( const QString &, const QString & )),
		&IRCUserContact::newWhoIsChannels );

	mapDouble<IRCUserContact>( m,
		SIGNAL(incomingWhoIsServer(const QString &, const QString &, const QString &)),
		&IRCUserContact::newWhoIsServer );

	mapDouble<IRCUserContact>( m,
		SIGNAL(incomingPrivAction(const QString &, const QString &, const QString &)),
		&IRCUserContact::newAction );

	mapDouble<IRCChannelContact>( m,
		SIGNAL(incomingAction(const QString &, const QString &, const QString &)),
		&IRCChannelContact::newAction );

	mapTriple<IRCUserContact>( m,
		SIGNAL(incomingWhoIsUser(const QString &, const QString &, const QString &, const QString &)),
		&IRCUserContact::newWhoIsUser );

	mapTriple<IRCUserContact>( m,
		SIGNAL(incomingWhoWasUser(const QString &, const QString &, const QString &, const QString &)),
		&IRCUserContact::newWhoIsUser );
}

IRCSignalHandler::~IRCSignalHandler()
{
	//Delete our mapping pointers
	for( QValueList<IRCSignalMappingBase*>::iterator it = mappings.begin(); it != mappings.end(); ++it )
		delete *it;
}

void IRCSignalHandler::slotNamesList( const QString &chan, const QStringList &list )
{
	IRCChannelContact *c = manager->existChannel( chan );
	if( c )
		c->namesList( list );
}

void IRCSignalHandler::slotEndOfNames( const QString &chan )
{
	IRCChannelContact *c = manager->existChannel( chan );
	if ( c )
		c->endOfNames();
}

void IRCSignalHandler::slotTopicUser(const QString &chan, const QString &user,const QDateTime &time)
{
	IRCChannelContact *c = manager->existChannel( chan );
	if( c )
		c->topicUser( user, time );
}

void IRCSignalHandler::slotNewWhoIsIdle(const QString &nick, unsigned long val )
{
	IRCUserContact *c = manager->findUser( nick );
	if( c )
		c->newWhoIsIdle( val );
}

void IRCSignalHandler::slotNewWhoReply(const QString &nick, const QString &arg1, const QString &arg2,
	const QString &arg3, const QString &arg4, bool arg5, const QString &arg6, uint arg7, const QString &arg8 )
{
	IRCUserContact *c = manager->findUser( nick );
	if( c )
		c->newWhoReply( arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 );
}

#include "ircsignalhandler.moc"