1 /* 2 * xmpp_discoitem.h 3 * Copyright (C) 2003 Justin Karneges 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public 16 * License along with this library; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 * 19 */ 20 21 #ifndef XMPP_DISCOITEM 22 #define XMPP_DISCOITEM 23 24 #include <QString> 25 #include <QCryptographicHash> 26 27 #include "xmpp/jid/jid.h" 28 #include "xmpp_features.h" 29 #include "xmpp_xdata.h" 30 #include "xmpp_agentitem.h" 31 32 namespace XMPP { 33 class DiscoItemPrivate; 34 35 class DiscoItem 36 { 37 public: 38 DiscoItem(); 39 ~DiscoItem(); 40 41 const Jid &jid() const; 42 const QString &node() const; 43 const QString &name() const; 44 45 void setJid(const Jid &); 46 void setName(const QString &); 47 void setNode(const QString &); 48 49 enum Action { 50 None = 0, 51 Remove, 52 Update 53 }; 54 55 Action action() const; 56 void setAction(Action); 57 58 const Features &features() const; 59 void setFeatures(const Features &); 60 61 struct Identity 62 { 63 QString category; 64 QString type; 65 QString lang; 66 QString name; 67 IdentityIdentity68 inline Identity() {} 69 inline Identity(const QString &categoty, const QString &type, 70 const QString &lang = QString(), const QString &name = QString()) : categoryIdentity71 category(categoty), type(type), lang(lang), name(name) {} 72 bool operator==(const Identity &other) const; 73 }; 74 75 typedef QList<Identity> Identities; 76 77 const Identities &identities() const; 78 void setIdentities(const Identities &); setIdentities(const Identity & id)79 inline void setIdentities(const Identity &id) { setIdentities(Identities() << id); } 80 81 const QList<XData> &extensions() const; 82 void setExtensions(const QList<XData> &extlist); 83 XData registeredExtension(const QString &ns) const; 84 85 // some useful helper functions 86 static Action string2action(QString s); 87 static QString action2string(Action a); 88 89 DiscoItem & operator= (const DiscoItem &); 90 DiscoItem(const DiscoItem &); 91 AgentItem()92 operator AgentItem() const { return toAgentItem(); } 93 AgentItem toAgentItem() const; 94 void fromAgentItem(const AgentItem &); 95 96 QString capsHash(QCryptographicHash::Algorithm algo) const; 97 98 static DiscoItem fromDiscoInfoResult(const QDomElement &x); 99 QDomElement toDiscoInfoResult(QDomDocument *doc) const; 100 101 private: 102 QSharedDataPointer<DiscoItemPrivate> d; 103 }; 104 105 bool operator<(const DiscoItem::Identity &a, const DiscoItem::Identity &b); 106 } 107 108 #endif 109