2 * jabbercontact.h - Base class for the Kopete Jabber protocol contact
4 * Copyright (c) 2002-2004 by Till Gerken <till@tantalo.net>
5 * Copyright (c) 2002 by Daniel Stone <dstone@kde.org>
7 * Kopete (c) by the Kopete developers <kopete-devel@kde.org>
9 * *************************************************************************
11 * * This program is free software; you can redistribute it and/or modify *
12 * * it under the terms of the GNU General Public License as published by *
13 * * the Free Software Foundation; either version 2 of the License, or *
14 * * (at your option) any later version. *
16 * *************************************************************************
19 #ifndef JABBERBASECONTACT_H
20 #define JABBERBASECONTACT_H
22 #include "kopetecontact.h"
28 class JabberTransport
;
29 namespace Kopete
{ class MetaContact
; }
30 namespace XMPP
{ class VCard
; }
32 class JabberBaseContact
: public Kopete::Contact
36 friend class JabberAccount
; /* Friends can touch each other's private parts. */
41 * @param legacyId is the contactId of the contact if != Jid
43 JabberBaseContact (const XMPP::RosterItem
&rosterItem
,
44 Kopete::Account
*account
, Kopete::MetaContact
* mc
,
45 const QString
&legacyId
=QString());
47 /********************************************************************
49 * Kopete::Contact reimplementation start
51 ********************************************************************/
54 * Return the protocol instance associated with this contact
56 JabberProtocol
*protocol ();
59 * Return the account instance associated with this contact
61 JabberAccount
*account () const { return m_account
; };
64 * return the transport if any, or null
66 JabberTransport
*transport();
69 * Return if the contact is reachable (this is true if the account
72 virtual bool isReachable ();
75 * Create custom context menu items for the contact
76 * FIXME: implement manager version here?
78 virtual QList
<KAction
*> *customContextMenuActions () = 0;
79 using Kopete::Contact::customContextMenuActions
;
84 virtual void serialize (QMap
< QString
, QString
> &serializedData
, QMap
< QString
, QString
> &addressBookData
);
87 * Update contact if a roster item has been
88 * received for it. (used during login)
90 void updateContact ( const XMPP::RosterItem
&item
);
93 * Deal with an incoming message for this contact.
95 virtual void handleIncomingMessage ( const XMPP::Message
&message
) = 0;
98 * Update the resource property of the
99 * contact, listing all available resources.
101 void updateResourceList ();
104 * Return current full address.
105 * Uses bestResource() if no presubscribed
108 QString
fullAddress ();
111 * Set the dontSync flag for this contact.
112 * If this flag is set, calls to @ref sync will
113 * be ignored. This is required if the contact
114 * has been moved between groups on the server
115 * after we logged in and we try to update our
116 * local contact list. Since libkopete can only
117 * handle one group update at a time, moving
118 * between groups requires to operations which
119 * each in turn would cause a call to sync(),
120 * overwriting the change that is being carried
121 * out. (besides causing unnecessary traffic)
122 * This is avoided by setting the dontSync flag
123 * while synchronizing the local copy.
125 void setDontSync ( bool flag
);
128 * Return the status of the dontSync flag.
129 * See @ref setDontSync for a full description.
134 * return the roster item of the contact.
135 * to get the jid, use rosterItem().jid().full() don't use contactId as it is not the same with transport
137 XMPP::RosterItem
rosterItem() const { return mRosterItem
; }
140 * Reads a vCard object and updates the contact's
141 * properties accordingly.
143 void setPropertiesFromVCard ( const XMPP::VCard
&vCard
);
146 * Set contact's client sends delivery event flag.
148 void setSendsDeliveredEvent( bool sends
) { mSendsDeliveredEvent
= sends
; }
151 * Return true if contact's client sends delivery event.
153 bool sendsDeliveredEvent() const { return mSendsDeliveredEvent
; }
158 * Retrieve a vCard for the contact
160 virtual void slotUserInfo ();
164 * Re-evaluate online status. Gets called
165 * whenever a resource is added, removed, or
166 * changed in the resource pool.
168 void reevaluateStatus ();
172 * Construct best address out of
173 * eventually preselected resource
174 * (due to subscription) and best
175 * available resource.
177 XMPP::Jid
bestAddress ();
180 * This will simply cache all
181 * relevant data for this contact.
183 XMPP::RosterItem mRosterItem
;
186 * Flag if contact's client sends delivery event.
188 bool mSendsDeliveredEvent
;
192 JabberAccount
*m_account
;
198 // vim: set noet ts=4 sts=4 sw=4: