Show invite menu in wlm chat window immediately
[kdenetwork.git] / kopete / protocols / jabber / jabberbasecontact.h
blobde287eb47d6d9ddd6e06a83eb7d9222df42d6b07
1 /*
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 * *************************************************************************
10 * * *
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. *
15 * * *
16 * *************************************************************************
19 #ifndef JABBERBASECONTACT_H
20 #define JABBERBASECONTACT_H
22 #include "kopetecontact.h"
23 #include "xmpp.h"
24 #include "im.h"
26 class JabberProtocol;
27 class JabberAccount;
28 class JabberTransport;
29 namespace Kopete { class MetaContact; }
30 namespace XMPP { class VCard; }
32 class JabberBaseContact : public Kopete::Contact
35 Q_OBJECT
36 friend class JabberAccount; /* Friends can touch each other's private parts. */
38 public:
40 /**
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 ********************************************************************/
53 /**
54 * Return the protocol instance associated with this contact
56 JabberProtocol *protocol ();
58 /**
59 * Return the account instance associated with this contact
61 JabberAccount *account () const { return m_account; };
63 /**
64 * return the transport if any, or null
66 JabberTransport *transport();
68 /**
69 * Return if the contact is reachable (this is true if the account
70 * is online)
72 virtual bool isReachable ();
74 /**
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;
81 /**
82 * Serialize contact
84 virtual void serialize (QMap < QString, QString > &serializedData, QMap < QString, QString > &addressBookData);
86 /**
87 * Update contact if a roster item has been
88 * received for it. (used during login)
90 void updateContact ( const XMPP::RosterItem &item );
92 /**
93 * Deal with an incoming message for this contact.
95 virtual void handleIncomingMessage ( const XMPP::Message &message ) = 0;
97 /**
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
106 * address exists.
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.
131 bool dontSync ();
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; }
155 public slots:
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 ();
170 protected:
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;
190 private:
191 bool mDontSync;
192 JabberAccount *m_account;
196 #endif
198 // vim: set noet ts=4 sts=4 sw=4: