2 jabbercapabilitiesmanager.h - Manage entity capabilities(JEP-0115) pool.
4 Copyright (c) 2006 by Michaël Larouche <larouche@kde.org>
5 Copyright 2006 by Tommi Rantala <tommi.rantala@cs.helsinki.fi>
7 Kopete (c) 2001-2006 by the Kopete developers <kopete-devel@kde.org>
9 Imported from caps.cpp from Psi:
10 Copyright (C) 2005 Remko Troncon
12 *************************************************************************
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
19 *************************************************************************
21 #ifndef JABBERCAPABILITIESMANAGER_H
22 #define JABBERCAPABILITIESMANAGER_H
28 #include <QStringList>
29 #include <QDomElement>
39 * @brief Manage Jabber entity capabilities (JEP-0115)
40 * @author Michaël Larouche <larouche@kde.org>
41 * @author Remko Troncon
43 class JabberCapabilitiesManager
: public QObject
50 JabberCapabilitiesManager();
51 ~JabberCapabilitiesManager();
54 * Load cached information from local file.
56 void loadCachedInformation();
59 * Check if the jid support Entity capabitilies.
60 * @param jid JID to check.
61 * @return true if the jid support entity capabitilies.
63 bool capabilitiesEnabled(const Jid
& jid
) const;
66 * Remove account from manager.
68 void removeAccount(JabberAccount
*account
);
71 * Return the features supported for the JID.
73 XMPP::Features
features(const Jid
& jid
) const;
75 * Return the client name for the current JID.
77 QString
clientName(const Jid
& jid
) const;
79 * Return the client version for the current JID.
81 QString
clientVersion(const Jid
& jid
) const;
84 void capabilitiesChanged(const XMPP::Jid
&jid
);
88 * Update if necessary the capabities for the JID passed in args.
89 * Caps are received in Presence messages so that's why we are
90 * passing a XMPP::Status object.
92 * @param jid JID that capabilities was updated.
93 * @param status The XMPP::Status that contain the caps.
95 void updateCapabilities(JabberAccount
*account
, const XMPP::Jid
&jid
, const XMPP::Status
&status
);
99 * @brief Called when a reply to disco#info request was received.
100 * If the result was successful, the resulting features are recorded in the
101 * features database for the requested node, and all the affected jids are
102 * put in the queue for update notification.
103 * If the result was unsuccessful, another jid with the same capabilities is
104 * selected and sent a disco#info query.
106 void discoRequestFinished();
110 * @brief Sends a disco#info request to a given node of a jid through an account.
111 * When the request is finished, the discoRequestFinished() slot is called.
113 * @param account The account through which to send the disco request.
114 * @param jid The target entity's JID
115 * @param node The target disco#info node
117 void requestDiscoInfo(JabberAccount
*account
, const Jid
& jid
, const QString
& node
);
120 * Save capabilities information to disk.
122 void saveInformation();
125 typedef QList
<Capabilities
> CapabilitiesList
;
127 * @brief A class representing an entity capability specification.
128 * An entity capability is a combination of a node, a version, and a set of
135 * Default constructor.
139 * Define capabilities.
140 * @param node the node
141 * @param version the version
142 * @param extensions the list of extensions (separated by spaces)
144 Capabilities(const QString
&node
, const QString
&version
, const QString
&extensions
);
146 * Returns the node of the capabilities specification.
148 const QString
& node() const;
150 * @brief Returns the version of the capabilities specification.
152 const QString
& version() const;
154 * @brief Returns the extensions of the capabilities specification.
156 const QString
& extensions() const;
158 * \brief Flattens the caps specification into the set of 'simple' specifications.
159 * A 'simple' specification is a specification with exactly one extension,
160 * or with the version number as the extension.
162 * Example: A caps specification with node=http://psi-im.org, version=0.10,
163 * and ext='achat vchat' would be expanded into the following list of specs:
164 * node=http://psi-im.org, ver=0.10, ext=0.10
165 * node=http://psi-im.org, ver=0.10, ext=achat
166 * node=http://psi-im.org, ver=0.10, ext=vchat
168 CapabilitiesList
flatten() const;
170 bool operator==(const Capabilities
&) const;
171 bool operator!=(const Capabilities
&) const;
172 bool operator<(const Capabilities
&) const;
175 QString m_node
, m_version
, m_extensions
;
178 class CapabilitiesInformation
181 CapabilitiesInformation();
182 const QStringList
& features() const;
183 const DiscoItem::Identities
& identities() const;
184 QStringList
jids() const;
185 bool discovered() const;
186 int pendingRequests() const;
189 void removeAccount(JabberAccount
* acc
);
190 void removeJid(const Jid
&);
191 void addJid(const Jid
&, JabberAccount
*);
192 QPair
<Jid
,JabberAccount
*> nextJid(const Jid
&, const Task
*);
194 void setDiscovered(bool);
195 void setPendingRequests(int);
196 void setIdentities(const DiscoItem::Identities
&);
197 void setFeatures(const QStringList
&);
199 QDomElement
toXml(QDomDocument
*) const;
200 void fromXml(const QDomElement
&);
203 void updateLastSeen();
207 int m_pendingRequests
;
208 QStringList m_features
;
209 DiscoItem::Identities m_identities
;
211 typedef QList
<QPair
<QString
, JabberAccount
*> > JidList
;