2
* xmpp_features.cpp - XMPP entity features
3
* Copyright (C) 2003 Justin Karneges
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#include <QCoreApplication>
24
#include <QStringList>
26
#include "xmpp_features.h"
34
Features::Features(const QStringList &l)
39
Features::Features(const QString &str)
51
QStringList Features::list() const
56
void Features::setList(const QStringList &l)
61
void Features::addFeature(const QString& s)
66
bool Features::test(const QStringList &ns) const
68
QStringList::ConstIterator it = ns.begin();
69
for ( ; it != ns.end(); ++it) {
70
if ( _list.contains( *it )) {
77
#define FID_MULTICAST "http://jabber.org/protocol/address"
78
bool Features::canMulticast() const
86
#define FID_AHCOMMAND "http://jabber.org/protocol/commands"
87
bool Features::canCommand() const
95
#define FID_REGISTER "jabber:iq:register"
96
bool Features::canRegister() const
104
#define FID_SEARCH "jabber:iq:search"
105
bool Features::canSearch() const
113
#define FID_GROUPCHAT "jabber:iq:conference"
114
bool Features::canGroupchat() const
117
ns << "http://jabber.org/protocol/muc";
123
#define FID_VOICE "http://www.google.com/xmpp/protocol/voice/v1"
124
bool Features::canVoice() const
132
#define FID_GATEWAY "jabber:iq:gateway"
133
bool Features::isGateway() const
141
#define FID_DISCO "http://jabber.org/protocol/disco"
142
bool Features::canDisco() const
146
ns << "http://jabber.org/protocol/disco#info";
147
ns << "http://jabber.org/protocol/disco#items";
152
#define FID_CHATSTATE "http://jabber.org/protocol/chatstates"
153
bool Features::canChatState() const
161
#define FID_VCARD "vcard-temp"
162
bool Features::haveVCard() const
170
// custom Psi acitons
171
#define FID_ADD "psi:add"
173
class Features::FeatureName : public QObject
179
: QObject(QCoreApplication::instance())
181
id2s[FID_Invalid] = tr("ERROR: Incorrect usage of Features class");
182
id2s[FID_None] = tr("None");
183
id2s[FID_Register] = tr("Register");
184
id2s[FID_Search] = tr("Search");
185
id2s[FID_Groupchat] = tr("Groupchat");
186
id2s[FID_Gateway] = tr("Gateway");
187
id2s[FID_Disco] = tr("Service Discovery");
188
id2s[FID_VCard] = tr("VCard");
189
id2s[FID_AHCommand] = tr("Execute command");
191
// custom Psi actions
192
id2s[FID_Add] = tr("Add to roster");
194
// compute reverse map
195
//QMap<QString, long>::Iterator it = id2s.begin();
196
//for ( ; it != id2s.end(); ++it)
197
// s2id[it.data()] = it.key();
199
id2f[FID_Register] = FID_REGISTER;
200
id2f[FID_Search] = FID_SEARCH;
201
id2f[FID_Groupchat] = FID_GROUPCHAT;
202
id2f[FID_Gateway] = FID_GATEWAY;
203
id2f[FID_Disco] = FID_DISCO;
204
id2f[FID_VCard] = FID_VCARD;
205
id2f[FID_AHCommand] = FID_AHCOMMAND;
207
// custom Psi actions
208
id2f[FID_Add] = FID_ADD;
211
//QMap<QString, long> s2id;
212
QMap<long, QString> id2s;
213
QMap<long, QString> id2f;
216
static Features::FeatureName *featureName = 0;
218
long Features::id() const
220
if ( _list.count() > 1 )
222
else if ( canRegister() )
224
else if ( canSearch() )
226
else if ( canGroupchat() )
227
return FID_Groupchat;
228
else if ( isGateway() )
230
else if ( canDisco() )
232
else if ( haveVCard() )
234
else if ( canCommand() )
235
return FID_AHCommand;
236
else if ( test(QStringList(FID_ADD)) )
242
long Features::id(const QString &feature)
248
QString Features::feature(long id)
251
featureName = new FeatureName();
253
return featureName->id2f[id];
256
QString Features::name(long id)
259
featureName = new FeatureName();
261
return featureName->id2s[id];
264
QString Features::name() const
269
QString Features::name(const QString &feature)
272
return f.name(f.id());
275
#include "xmpp_features.moc"