summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/irc/ircusercontact.h
blob: 3373fa9c7496b4e9e048034d25aef76509c7e79a (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
/*
    ircusercontact.h - IRC User Contact

    Copyright (c) 2002      by Nick Betcher <nbetcher@kde.org>
    Copyright (c) 2003      by Jason Keirstead <jason@keirstead.org

    Kopete    (c) 2002      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.                                   *
    *                                                                       *
    *************************************************************************
*/

#ifndef IRCUSERCONTACT_H
#define IRCUSERCONTACT_H

#include "kopetechatsessionmanager.h"
#include "irccontact.h"
#include "kopeteonlinestatus.h"

class QTimer;

class KActionCollection;
class KAction;
class KActionMenu;
class KCodecAction;

class IRCContactManager;
class IRCChannelContact;

struct IRCUserInfo
{
	QString userName;
	QString hostName;
	QString realName;
	QString serverName;
	QString serverInfo;
	QString flags;
	QStringList channels;
	unsigned long idle;
	bool isOperator;
	bool isIdentified;
	bool away;
	bool online;
	uint hops;
	QDateTime lastOnline;
	QTime lastUpdate;
};

/**
 * @author Jason Keirstead <jason@keirstead.org
 *
 * This class is the @ref Kopete::Contact object representing IRC Users, not channels.
 * It is derrived from IRCContact where much of its functionality is shared with @ref IRCChannelContact.
 */
class IRCUserContact : public IRCContact
{
	Q_OBJECT

public:
	// This class provides a Kopete::Contact for each user on the channel.
	IRCUserContact(IRCContactManager *, const QString &nickname, Kopete::MetaContact *mc);

	// Kopete::Contact stuff
	virtual QPtrList<KAction> *customContextMenuActions( Kopete::ChatSession *manager );
	virtual const QString caption() const;

	void setAway(bool isAway);

	QString formattedName() const;

	//Methods handled by the signal mapper
	void incomingUserIsAway(const QString &message );
	void userOnline();
	void newAction( const QString &from, const QString &action );
	void newWhoIsUser(const QString &username, const QString &hostname, const QString &realname);
	void newWhoIsServer(const QString &server, const QString &serverInfo);
	void newWhoIsOperator();
	void newWhoIsIdentified();
	void newWhoIsIdle(unsigned long seconds);
	void newWhoIsChannels(const QString &channel);
	void whoIsComplete();
	void whoWasComplete();
	void newWhoReply( const QString &channel, const QString &user, const QString &host,
		const QString &server, bool away, const QString &flags, uint hops,
		const QString &realName );

public slots:
	/** \brief Updates online status for channels based on current internal status.
	 */
	virtual void updateStatus();

	virtual void sendFile(const KURL &sourceURL, const QString&, unsigned int);

protected slots:
	virtual void privateMessage(IRCContact *from, IRCContact *to, const QString &message);

private slots:
	void slotOp();
	void slotDeop();
	void slotVoice();
	void slotDevoice();
	void slotCtcpPing();
	void slotCtcpVersion();
	void slotBanHost();
	void slotBanUserHost();
	void slotBanDomain();
	void slotBanUserDomain();
	void slotKick();
	void slotUserOffline();

	void slotBanHostOnce();
	void slotBanUserHostOnce();
	void slotBanDomainOnce();
	void slotBanUserDomainOnce();

	virtual void slotUserInfo();

	//This can't be handled by the contact manager since
	void slotIncomingModeChange(const QString &nick, const QString &channel, const QString &mode);

private:
	enum bitAdjustment { RemoveBits, AddBits };
	void adjustInternalOnlineStatusBits(IRCChannelContact *channel, unsigned statusAdjustment, bitAdjustment adj);

	void contactMode(const QString &mode);
	void updateInfo();

	KActionMenu *actionModeMenu;
	KActionMenu *actionCtcpMenu;
	KAction *actionKick;
	KActionMenu *actionBanMenu;
	KCodecAction *codecAction;
	Kopete::ChatSession *mActiveManager;
	QTimer *mOnlineTimer;
	IRCUserInfo mInfo;
};

#endif

// vim: set noet ts=4 sts=4 tw=4: