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
|
/*
irccontact.h - IRC Contact
Copyright (c) 2005 by Tommi Rantala <[email protected]>
Copyright (c) 2003-2004 by Michel Hermier <[email protected]>
Copyright (c) 2003 by Jason Keirstead <[email protected]>
Copyright (c) 2002 by Nick Betcher <[email protected]>
Kopete (c) 2002-2005 by the Kopete developers <[email protected]>
*************************************************************************
* *
* 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 IRCCONTACT_H
#define IRCCONTACT_H
#include "kircengine.h"
#include "kircentity.h"
#include "kopetecontact.h"
#include "kopetemessage.h"
#include <tqptrlist.h>
#include <tqmap.h>
class IRCProtocol;
class IRCAccount;
class IRCContactManager;
namespace KIRC
{
class Engine;
}
namespace Kopete
{
class ChatSession;
class MetaContact;
}
class KopeteView;
class QTextCodec;
/**
* @author Jason Keirstead <[email protected]>
* @author Michel Hermier <[email protected]>
*
* This class is the base class for @ref IRCUserContact and @ref IRCChannelContact.
* Common routines and signal connections that are required for both types of
* contacts reside here, to avoid code duplication between these two classes.
*/
class IRCContact
: public Kopete::Contact
{
Q_OBJECT
public:
IRCContact(IRCAccount *account, KIRC::EntityPtr entity, Kopete::MetaContact *metac, const TQString& icon = TQString::null);
IRCContact(IRCContactManager *contactManager, const TQString &nick, Kopete::MetaContact *metac, const TQString& icon = TQString::null);
virtual ~IRCContact();
IRCAccount *ircAccount() const;
KIRC::Engine *kircEngine() const;
/**
* Sets the nickname of this contact. The nickname is distinct from the displayName
* in case trackNameChanges is disabled.
*/
void setNickName(const TQString &nickname);
/**
* Returns the nickname / channel name
*/
const TQString &nickName() const { return m_nickName; }
/**
* This function attempts to find the nickname specified within the current chat
* session. Returns a pointer to that IRCUserContact, or 0L if the user does not
* exist in this session. More useful for channels. Calling IRCChannelContact::locateUser()
* for example tells you if a user is in a certain channel.
*/
Kopete::Contact *locateUser( const TQString &nickName );
virtual bool isReachable();
/**
* return true if the contact is in a chat. false if the contact is in no chats
* that loop over all manager, and checks the presence of the user
*/
bool isChatting( const Kopete::ChatSession *avoid = 0L ) const;
virtual const TQString caption() const;
// virtual const TQString formatedName() const;
virtual Kopete::ChatSession *manager(Kopete::Contact::CanCreateFlags = Kopete::Contact::CannotCreate);
virtual void appendMessage( Kopete::Message & );
const TQTextCodec *codec();
KopeteView *view();
/**
* We serialise the contactId and the server group in 'contactId'
* so that other IRC programs reading this from KAddressBook have a chance of figuring
* which server the contact relates to
*/
virtual void serialize( TQMap<TQString, TQString> &serializedData, TQMap<TQString, TQString> &addressBookData );
signals:
void destroyed(IRCContact *self);
public slots:
void setCodec( const TQTextCodec *codec );
virtual void updateStatus();
protected slots:
virtual void slotSendMsg(Kopete::Message &message, Kopete::ChatSession *);
TQStringList sendMessage( const TQString &msg );
virtual void chatSessionDestroyed();
void slotNewNickChange( const TQString &oldnickname, const TQString &newnickname);
void slotUserDisconnected( const TQString &nickname, const TQString &reason);
virtual void deleteContact();
virtual void privateMessage(IRCContact *from, IRCContact *to, const TQString &message);
virtual void initConversation() {};
void receivedMessage( KIRC::Engine::ServerMessageType type,
const KIRC::EntityPtr &from,
const KIRC::EntityPtrList &to,
const TQString &msg);
protected:
KIRC::EntityPtr m_entity;
TQString m_nickName;
Kopete::ChatSession *m_chatSession;
TQPtrList<Kopete::Contact> mMyself;
Kopete::Message::MessageDirection execDir;
};
#endif
|