initial commit

This commit is contained in:
mikhail "synzr" 2025-12-25 01:37:49 +05:00
commit 9d20827c46
2469 changed files with 470994 additions and 0 deletions

View file

@ -0,0 +1,133 @@
/*
* im.h - XMPP "IM" library API
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_IM_H
#define XMPP_IM_H
#include <qdatetime.h>
//Added by qt3to4:
#include <QList>
#include "xmpp.h"
#include "xmpp_jid.h"
#include "xmpp_muc.h"
#include "xmpp_message.h"
#include "xmpp_chatstate.h"
#include "xmpp_status.h"
#include "xmpp_htmlelement.h"
#include "xmpp_features.h"
#include "xmpp_httpauthrequest.h"
#include "xmpp_url.h"
#include "xmpp_task.h"
#include "xmpp_resource.h"
#include "xmpp_resourcelist.h"
#include "xmpp_roster.h"
#include "xmpp_rosteritem.h"
#include "xmpp_liverosteritem.h"
#include "xmpp_liveroster.h"
#include "xmpp_rosterx.h"
#include "xmpp_xdata.h"
#include "xmpp_discoitem.h"
#include "xmpp_agentitem.h"
#include "xmpp_client.h"
#include "xmpp_address.h"
#include "xmpp_pubsubitem.h"
#include "xmpp_pubsubretraction.h"
namespace XMPP
{
typedef QMap<QString, QString> StringMap;
typedef QList<AgentItem> AgentList;
typedef QList<DiscoItem> DiscoList;
class FormField
{
public:
enum { username, nick, password, name, first, last, email, address, city, state, zip, phone, url, date, misc };
FormField(const QString &type="", const QString &value="");
~FormField();
int type() const;
QString fieldName() const;
QString realName() const;
bool isSecret() const;
const QString & value() const;
void setType(int);
bool setType(const QString &);
void setValue(const QString &);
private:
int tagNameToType(const QString &) const;
QString typeToTagName(int) const;
int v_type;
QString v_value;
class Private;
Private *d;
};
class Form : public QList<FormField>
{
public:
Form(const Jid &j="");
~Form();
Jid jid() const;
QString instructions() const;
QString key() const;
void setJid(const Jid &);
void setInstructions(const QString &);
void setKey(const QString &);
private:
Jid v_jid;
QString v_instructions, v_key;
class Private;
Private *d;
};
class SearchResult
{
public:
SearchResult(const Jid &jid="");
~SearchResult();
const Jid & jid() const;
const QString & nick() const;
const QString & first() const;
const QString & last() const;
const QString & email() const;
void setJid(const Jid &);
void setNick(const QString &);
void setFirst(const QString &);
void setLast(const QString &);
void setEmail(const QString &);
private:
Jid v_jid;
QString v_nick, v_first, v_last, v_email;
};
}
#endif

View file

@ -0,0 +1,235 @@
/*
* xmpp.h - XMPP "core" library API
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_H
#define XMPP_H
#include <QPair>
#include <qobject.h>
#include <qstring.h>
#include <qhostaddress.h>
#include <qstring.h>
#include <q3cstring.h>
#include <qxml.h>
#include <qdom.h>
#include "xmpp_jid.h"
#include "xmpp_stanza.h"
#include "xmpp_stream.h"
#include "xmpp_clientstream.h"
namespace QCA
{
class TLS;
};
#ifndef CS_XMPP
class ByteStream;
#endif
#include <QtCrypto> // For QCA::SASL::Params
namespace XMPP
{
// CS_IMPORT_BEGIN cutestuff/bytestream.h
#ifdef CS_XMPP
class ByteStream;
#endif
// CS_IMPORT_END
class Debug
{
public:
virtual ~Debug();
virtual void msg(const QString &)=0;
virtual void outgoingTag(const QString &)=0;
virtual void incomingTag(const QString &)=0;
virtual void outgoingXml(const QDomElement &)=0;
virtual void incomingXml(const QDomElement &)=0;
};
void setDebug(Debug *);
class Connector : public QObject
{
Q_OBJECT
public:
Connector(QObject *parent=0);
virtual ~Connector();
virtual void connectToServer(const QString &server)=0;
virtual ByteStream *stream() const=0;
virtual void done()=0;
bool useSSL() const;
bool havePeerAddress() const;
QHostAddress peerAddress() const;
Q_UINT16 peerPort() const;
signals:
void connected();
void error();
protected:
void setUseSSL(bool b);
void setPeerAddressNone();
void setPeerAddress(const QHostAddress &addr, Q_UINT16 port);
private:
bool ssl;
bool haveaddr;
QHostAddress addr;
Q_UINT16 port;
};
class AdvancedConnector : public Connector
{
Q_OBJECT
public:
enum Error { ErrConnectionRefused, ErrHostNotFound, ErrProxyConnect, ErrProxyNeg, ErrProxyAuth, ErrStream };
AdvancedConnector(QObject *parent=0);
virtual ~AdvancedConnector();
class Proxy
{
public:
enum { None, HttpConnect, HttpPoll, Socks };
Proxy();
~Proxy();
int type() const;
QString host() const;
Q_UINT16 port() const;
QString url() const;
QString user() const;
QString pass() const;
int pollInterval() const;
void setHttpConnect(const QString &host, Q_UINT16 port);
void setHttpPoll(const QString &host, Q_UINT16 port, const QString &url);
void setSocks(const QString &host, Q_UINT16 port);
void setUserPass(const QString &user, const QString &pass);
void setPollInterval(int secs);
private:
int t;
QString v_host, v_url;
Q_UINT16 v_port;
QString v_user, v_pass;
int v_poll;
};
void setProxy(const Proxy &proxy);
void setOptHostPort(const QString &host, Q_UINT16 port);
void setOptProbe(bool);
void setOptSSL(bool);
void changePollInterval(int secs);
void connectToServer(const QString &server);
ByteStream *stream() const;
void done();
int errorCode() const;
signals:
void srvLookup(const QString &server);
void srvResult(bool success);
void httpSyncStarted();
void httpSyncFinished();
private slots:
void dns_done();
void srv_done();
void bs_connected();
void bs_error(int);
void http_syncStarted();
void http_syncFinished();
private:
class Private;
Private *d;
void cleanup();
void do_resolve();
void do_connect();
void tryNextSrv();
};
class TLSHandler : public QObject
{
Q_OBJECT
public:
TLSHandler(QObject *parent=0);
virtual ~TLSHandler();
virtual void reset()=0;
virtual void startClient(const QString &host)=0;
virtual void write(const QByteArray &a)=0;
virtual void writeIncoming(const QByteArray &a)=0;
signals:
void success();
void fail();
void closed();
void readyRead(const QByteArray &a);
void readyReadOutgoing(const QByteArray &a, int plainBytes);
};
class QCATLSHandler : public TLSHandler
{
Q_OBJECT
public:
QCATLSHandler(QCA::TLS *parent);
~QCATLSHandler();
QCA::TLS *tls() const;
int tlsError() const;
void setXMPPCertCheck(bool enable);
bool XMPPCertCheck();
bool certMatchesHostname();
void reset();
void startClient(const QString &host);
void write(const QByteArray &a);
void writeIncoming(const QByteArray &a);
signals:
void tlsHandshaken();
public slots:
void continueAfterHandshake();
private slots:
void tls_handshaken();
void tls_readyRead();
void tls_readyReadOutgoing();
void tls_closed();
void tls_error();
private:
class Private;
Private *d;
};
};
#endif

View file

@ -0,0 +1,66 @@
/*
* Copyright (C) 2006 Remko Troncon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_ADDRESS_H
#define XMPP_ADDRESS_H
#include <QString>
#include "xmpp_jid.h"
class QDomElement;
namespace XMPP
{
class Address
{
public:
typedef enum { Unknown, To, Cc, Bcc, ReplyTo, ReplyRoom, NoReply, OriginalFrom, OriginalTo } Type;
Address(Type type = Unknown, const Jid& jid = Jid());
Address(const QDomElement&);
const Jid& jid() const;
const QString& uri() const;
const QString& node() const;
const QString& desc() const;
bool delivered() const;
Type type() const;
QDomElement toXml(Stanza&) const;
void fromXml(const QDomElement& t);
void setJid(const Jid &);
void setUri(const QString &);
void setNode(const QString &);
void setDesc(const QString &);
void setDelivered(bool);
void setType(Type);
private:
Jid v_jid;
QString v_uri, v_node, v_desc;
bool v_delivered;
Type v_type;
};
typedef QList<Address> AddressList;
};
#endif

View file

@ -0,0 +1,55 @@
/*
* xmpp_agentitem.h
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_AGENTITEM
#define XMPP_AGENTITEM
#include <QString>
#include "xmpp_jid.h"
#include "xmpp_features.h"
namespace XMPP {
class AgentItem
{
public:
AgentItem() { }
const Jid & jid() const { return v_jid; }
const QString & name() const { return v_name; }
const QString & category() const { return v_category; }
const QString & type() const { return v_type; }
const Features & features() const { return v_features; }
void setJid(const Jid &j) { v_jid = j; }
void setName(const QString &n) { v_name = n; }
void setCategory(const QString &c) { v_category = c; }
void setType(const QString &t) { v_type = t; }
void setFeatures(const Features &f) { v_features = f; }
private:
Jid v_jid;
QString v_name, v_category, v_type;
Features v_features;
};
}
#endif

View file

@ -0,0 +1,34 @@
/*
* Copyright (C) 2006 Remko Troncon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_CHATSTATE
#define XMPP_CHATSTATE
namespace XMPP {
typedef enum {
StateNone,
StateActive,
StateComposing,
StatePaused,
StateInactive,
StateGone
} ChatState;
}
#endif

View file

@ -0,0 +1,193 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_CLIENT_H
#define XMPP_CLIENT_H
#include <QObject>
#include <QStringList>
#include "xmpp_jid.h"
#include "xmpp_status.h"
#include "xmpp_discoitem.h"
class QString;
class QDomElement;
class QDomDocument;
namespace XMPP {
class ClientStream;
class Features;
class FileTransferManager;
class IBBManager;
class JidLinkManager;
class LiveRoster;
class LiveRosterItem;
class Message;
class Resource;
class ResourceList;
class Roster;
class RosterItem;
class S5BManager;
class Stream;
class Task;
}
namespace XMPP
{
class Client : public QObject
{
Q_OBJECT
public:
Client(QObject *parent=0);
~Client();
bool isActive() const;
void connectToServer(ClientStream *s, const Jid &j, bool auth=true);
void start(const QString &host, const QString &user, const QString &pass, const QString &resource);
void close(bool fast=false);
Stream & stream();
QString streamBaseNS() const;
const LiveRoster & roster() const;
const ResourceList & resourceList() const;
void send(const QDomElement &);
void send(const QString &);
QString host() const;
QString user() const;
QString pass() const;
QString resource() const;
Jid jid() const;
void rosterRequest();
void sendMessage(const Message &);
void sendSubscription(const Jid &, const QString &, const QString& nick = QString());
void setPresence(const Status &);
void debug(const QString &);
QString genUniqueId();
Task *rootTask();
QDomDocument *doc() const;
QString OSName() const;
QString timeZone() const;
int timeZoneOffset() const;
QString clientName() const;
QString clientVersion() const;
QString capsNode() const;
QString capsVersion() const;
QString capsExt() const;
void setOSName(const QString &);
void setTimeZone(const QString &, int);
void setClientName(const QString &);
void setClientVersion(const QString &);
void setCapsNode(const QString &);
void setCapsVersion(const QString &);
void setIdentity(DiscoItem::Identity);
DiscoItem::Identity identity();
void setFeatures(const Features& f);
const Features& features() const;
void addExtension(const QString& ext, const Features& f);
void removeExtension(const QString& ext);
const Features& extension(const QString& ext) const;
QStringList extensions() const;
S5BManager *s5bManager() const;
IBBManager *ibbManager() const;
JidLinkManager *jidLinkManager() const;
void setFileTransferEnabled(bool b);
FileTransferManager *fileTransferManager() const;
QString groupChatPassword(const QString& host, const QString& room) const;
bool groupChatJoin(const QString &host, const QString &room, const QString &nick, const QString& password = QString(), int maxchars = -1, int maxstanzas = -1, int seconds = -1, const Status& = Status());
void groupChatSetStatus(const QString &host, const QString &room, const Status &);
void groupChatChangeNick(const QString &host, const QString &room, const QString &nick, const Status &);
void groupChatLeave(const QString &host, const QString &room);
signals:
void activated();
void disconnected();
//void authFinished(bool, int, const QString &);
void rosterRequestFinished(bool, int, const QString &);
void rosterItemAdded(const RosterItem &);
void rosterItemUpdated(const RosterItem &);
void rosterItemRemoved(const RosterItem &);
void resourceAvailable(const Jid &, const Resource &);
void resourceUnavailable(const Jid &, const Resource &);
void presenceError(const Jid &, int, const QString &);
void subscription(const Jid &, const QString &, const QString &);
void messageReceived(const Message &);
void debugText(const QString &);
void xmlIncoming(const QString &);
void xmlOutgoing(const QString &);
void groupChatJoined(const Jid &);
void groupChatLeft(const Jid &);
void groupChatPresence(const Jid &, const Status &);
void groupChatError(const Jid &, int, const QString &);
void incomingJidLink();
void beginImportRoster();
void endImportRoster();
private slots:
//void streamConnected();
//void streamHandshaken();
//void streamError(const StreamError &);
//void streamSSLCertificateReady(const QSSLCert &);
//void streamCloseFinished();
void streamError(int);
void streamReadyRead();
void streamIncomingXml(const QString &);
void streamOutgoingXml(const QString &);
void slotRosterRequestFinished();
// basic daemons
void ppSubscription(const Jid &, const QString &, const QString&);
void ppPresence(const Jid &, const Status &);
void pmMessage(const Message &);
void prRoster(const Roster &);
void s5b_incomingReady();
void ibb_incomingReady();
public:
class GroupChat;
private:
void cleanup();
void distribute(const QDomElement &);
void importRoster(const Roster &);
void importRosterItem(const RosterItem &);
void updateSelfPresence(const Jid &, const Status &);
void updatePresence(LiveRosterItem *, const Jid &, const Status &);
class ClientPrivate;
ClientPrivate *d;
};
}
#endif

View file

@ -0,0 +1,202 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_CLIENTSTREAM_H
#define XMPP_CLIENTSTREAM_H
#include <QtCrypto>
#include "xmpp_stream.h"
class QByteArray;
class QString;
class QDomDocument;
class QDomElement;
class QObject;
class ByteStream;
class QHostAddress;
namespace XMPP
{
class TLSHandler;
class Connector;
class ClientStream : public Stream
{
Q_OBJECT
public:
enum Error {
ErrConnection = ErrCustom, // Connection error, ask Connector-subclass what's up
ErrNeg, // Negotiation error, see condition
ErrTLS, // TLS error, see condition
ErrAuth, // Auth error, see condition
ErrSecurityLayer, // broken SASL security layer
ErrBind // Resource binding error
};
enum Warning {
WarnOldVersion, // server uses older XMPP/Jabber "0.9" protocol
WarnNoTLS // there is no chance for TLS at this point
};
enum NegCond {
HostGone, // host no longer hosted
HostUnknown, // unknown host
RemoteConnectionFailed, // unable to connect to a required remote resource
SeeOtherHost, // a 'redirect', see errorText() for other host
UnsupportedVersion // unsupported XMPP version
};
enum TLSCond {
TLSStart, // server rejected STARTTLS
TLSFail // TLS failed, ask TLSHandler-subclass what's up
};
enum SecurityLayer {
LayerTLS,
LayerSASL
};
enum AuthCond {
GenericAuthError, // all-purpose "can't login" error
NoMech, // No appropriate auth mech available
BadProto, // Bad SASL auth protocol
BadServ, // Server failed mutual auth
EncryptionRequired, // can't use mech without TLS
InvalidAuthzid, // bad input JID
InvalidMech, // bad mechanism
InvalidRealm, // bad realm
MechTooWeak, // can't use mech with this authzid
NotAuthorized, // bad user, bad password, bad creditials
TemporaryAuthFailure // please try again later!
};
enum BindCond {
BindNotAllowed, // not allowed to bind a resource
BindConflict // resource in-use
};
enum AllowPlainType {
NoAllowPlain,
AllowPlain,
AllowPlainOverTLS
};
ClientStream(Connector *conn, TLSHandler *tlsHandler=0, QObject *parent=0);
ClientStream(const QString &host, const QString &defRealm, ByteStream *bs, QCA::TLS *tls=0, QObject *parent=0); // server
~ClientStream();
Jid jid() const;
void connectToServer(const Jid &jid, bool auth=true);
void accept(); // server
bool isActive() const;
bool isAuthenticated() const;
// login params
void setUsername(const QString &s);
void setPassword(const QString &s);
void setRealm(const QString &s);
void setAuthzid(const QString &s);
void continueAfterParams();
// SASL information
QString saslMechanism() const;
int saslSSF() const;
// binding
void setResourceBinding(bool);
// Language
void setLang(const QString&);
// security options (old protocol only uses the first !)
void setAllowPlain(AllowPlainType);
#ifdef YAPSI
void setAllowXFacebookPlatform(bool);
#endif
void setRequireMutualAuth(bool);
void setSSFRange(int low, int high);
void setOldOnly(bool);
void setSASLMechanism(const QString &s);
void setLocalAddr(const QHostAddress &addr, Q_UINT16 port);
// Compression
void setCompress(bool);
// reimplemented
QDomDocument & doc() const;
QString baseNS() const;
bool old() const;
void close();
bool stanzaAvailable() const;
Stanza read();
void write(const Stanza &s);
int errorCondition() const;
QString errorText() const;
QDomElement errorAppSpec() const;
// extra
void writeDirect(const QString &s);
void setNoopTime(int mills);
signals:
void connected();
void securityLayerActivated(int);
void needAuthParams(bool user, bool pass, bool realm);
void authenticated();
void warning(int);
void incomingXml(const QString &s);
void outgoingXml(const QString &s);
public slots:
void continueAfterWarning();
private slots:
void cr_connected();
void cr_error();
void bs_connectionClosed();
void bs_delayedCloseFinished();
void bs_error(int); // server only
void ss_readyRead();
void ss_bytesWritten(int);
void ss_tlsHandshaken();
void ss_tlsClosed();
void ss_error(int);
void sasl_clientFirstStep(bool, const QByteArray&);
void sasl_nextStep(const QByteArray &stepData);
void sasl_needParams(const QCA::SASL::Params&);
void sasl_authCheck(const QString &user, const QString &authzid);
void sasl_authenticated();
void sasl_error();
void doNoop();
void doReadyRead();
private:
class Private;
Private *d;
void reset(bool all=false);
void processNext();
int convertedSASLCond() const;
bool handleNeed();
void handleError();
void srvProcessNext();
};
}
#endif

View file

@ -0,0 +1,86 @@
/*
* xmpp_discoitem.h
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_DISCOITEM
#define XMPP_DISCOITEM
#include <QString>
#include "xmpp_jid.h"
#include "xmpp_features.h"
#include "xmpp_agentitem.h"
namespace XMPP {
class DiscoItem
{
public:
DiscoItem();
~DiscoItem();
const Jid &jid() const;
const QString &node() const;
const QString &name() const;
void setJid(const Jid &);
void setName(const QString &);
void setNode(const QString &);
enum Action {
None = 0,
Remove,
Update
};
Action action() const;
void setAction(Action);
const Features &features() const;
void setFeatures(const Features &);
struct Identity
{
QString category;
QString name;
QString type;
};
typedef QList<Identity> Identities;
const Identities &identities() const;
void setIdentities(const Identities &);
// some useful helper functions
static Action string2action(QString s);
static QString action2string(Action a);
DiscoItem & operator= (const DiscoItem &);
DiscoItem(const DiscoItem &);
operator AgentItem() const { return toAgentItem(); }
AgentItem toAgentItem() const;
void fromAgentItem(const AgentItem &);
private:
class Private;
Private *d;
};
}
#endif

View file

@ -0,0 +1,88 @@
/*
* xmpp_features.h
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_FEATURES_H
#define XMPP_FEATURES_H
#include <QStringList>
class QString;
namespace XMPP
{
class Features
{
public:
Features();
Features(const QStringList &);
Features(const QString &);
~Features();
QStringList list() const; // actual featurelist
void setList(const QStringList &);
void addFeature(const QString&);
// features
bool canRegister() const;
bool canSearch() const;
bool canMulticast() const;
bool canGroupchat() const;
bool canVoice() const;
bool canDisco() const;
bool canChatState() const;
bool canCommand() const;
bool isGateway() const;
bool haveVCard() const;
bool canMessageReceipts() const;
enum FeatureID {
FID_Invalid = -1,
FID_None,
FID_Register,
FID_Search,
FID_Groupchat,
FID_Disco,
FID_Gateway,
FID_VCard,
FID_AHCommand,
// private Psi actions
FID_Add
};
// useful functions
bool test(const QString &) const;
bool test(const QStringList &) const;
QString name() const;
static QString name(long id);
static QString name(const QString &feature);
long id() const;
static long id(const QString &feature);
static QString feature(long id);
class FeatureName;
private:
QStringList _list;
};
}
#endif

View file

@ -0,0 +1,46 @@
/*
* Copyright (C) 2006 Remko Troncon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_HTMLELEMENT_H
#define XMPP_HTMLELEMENT_H
#include <QDomElement>
class QString;
namespace XMPP
{
class HTMLElement
{
public:
HTMLElement();
HTMLElement(const QDomElement &body);
void setBody(const QDomElement &body);
const QDomElement& body() const;
QString toString(const QString &rootTagName = "body") const;
QString text() const;
private:
QDomDocument doc_;
QDomElement body_;
};
}
#endif

View file

@ -0,0 +1,57 @@
/*
* Copyright (C) 2006 Maciek Niedzielski
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_AUTHREQUEST_H
#define XMPP_AUTHREQUEST_H
#include <QString>
class QDomElement;
class QDomDocument;
namespace XMPP
{
class HttpAuthRequest
{
public:
HttpAuthRequest(const QString &m, const QString &u, const QString &i);
HttpAuthRequest(const QString &m = "", const QString &u = "");
HttpAuthRequest(const QDomElement &);
bool isEmpty() const;
void setMethod(const QString&);
void setUrl(const QString&);
void setId(const QString&);
QString method() const;
QString url() const;
QString id() const;
bool hasId() const;
QDomElement toXml(QDomDocument &) const;
bool fromXml(const QDomElement &);
static Stanza::Error denyError;
private:
QString method_, url_, id_;
bool hasId_;
};
}
#endif

View file

@ -0,0 +1,83 @@
/*
* xmpp_jid.h
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_JID_H
#define XMPP_JID_H
#include <QString>
namespace XMPP
{
class Jid
{
public:
Jid();
~Jid();
Jid(const QString &s);
Jid(const char *s);
Jid & operator=(const QString &s);
Jid & operator=(const char *s);
bool operator==(const Jid& other) const;
void set(const QString &s);
void set(const QString &domain, const QString &node, const QString &resource="");
void setDomain(const QString &s);
void setNode(const QString &s);
void setResource(const QString &s);
bool isNull() const { return null; }
const QString & domain() const { return d; }
const QString & node() const { return n; }
const QString & resource() const { return r; }
const QString & bare() const { return b; }
const QString & full() const { return f; }
Jid withNode(const QString &s) const;
Jid withResource(const QString &s) const;
bool isValid() const;
bool isEmpty() const;
bool compare(const Jid &a, bool compareRes=true) const;
static bool validDomain(const QString &s, QString *norm=0);
static bool validNode(const QString &s, QString *norm=0);
static bool validResource(const QString &s, QString *norm=0);
// TODO: kill these later
const QString & host() const { return d; }
const QString & user() const { return n; }
const QString & userHost() const { return b; }
private:
void reset();
void update();
QString f, b, d, n, r;
bool valid, null;
};
}
// TODO: doesn't seem to have any effect at all on gcc 4.2.3 / linux
uint qHash(const XMPP::Jid& jid);
#endif

View file

@ -0,0 +1,43 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_LIVEROSTER_H
#define XMPP_LIVEROSTER_H
#include <QList>
#include "xmpp_liverosteritem.h"
namespace XMPP
{
class Jid;
class LiveRoster : public QList<LiveRosterItem>
{
public:
LiveRoster();
~LiveRoster();
void flagAllForDelete();
LiveRoster::Iterator find(const Jid &, bool compareRes=true);
LiveRoster::ConstIterator find(const Jid &, bool compareRes=true) const;
};
}
#endif

View file

@ -0,0 +1,58 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_LIVEROSTERITEM_H
#define XMPP_LIVEROSTERITEM_H
#include "xmpp_status.h"
#include "xmpp_resourcelist.h"
#include "xmpp_rosteritem.h"
namespace XMPP
{
class LiveRosterItem : public RosterItem
{
public:
LiveRosterItem(const Jid &j="");
LiveRosterItem(const RosterItem &);
~LiveRosterItem();
void setRosterItem(const RosterItem &);
ResourceList & resourceList();
ResourceList::Iterator priority();
const ResourceList & resourceList() const;
ResourceList::ConstIterator priority() const;
bool isAvailable() const;
const Status & lastUnavailableStatus() const;
bool flagForDelete() const;
void setLastUnavailableStatus(const Status &);
void setFlagForDelete(bool);
private:
ResourceList v_resourceList;
Status v_lastUnavailableStatus;
bool v_flagForDelete;
};
}
#endif

View file

@ -0,0 +1,189 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_MESSAGE_H
#define XMPP_MESSAGE_H
#include "xmpp_stanza.h"
#include "xmpp_url.h"
#include "xmpp_chatstate.h"
#include "xmpp_receipts.h"
#include "xmpp_address.h"
#include "xmpp_rosterx.h"
#include "xmpp_muc.h"
class QString;
class QDateTime;
#ifdef YAPSI
class YaLastMail;
#endif
namespace XMPP {
class Jid;
class PubSubItem;
class PubSubRetraction;
class HTMLElement;
class HttpAuthRequest;
class XData;
typedef enum { OfflineEvent, DeliveredEvent, DisplayedEvent,
ComposingEvent, CancelEvent } MsgEvent;
class Message
{
public:
Message(const Jid &to="");
Message(const Message &from);
Message & operator=(const Message &from);
~Message();
Jid to() const;
Jid from() const;
QString id() const;
QString type() const;
QString lang() const;
QString subject(const QString &lang="") const;
QString body(const QString &lang="") const;
QString thread() const;
Stanza::Error error() const;
void setTo(const Jid &j);
void setFrom(const Jid &j);
void setId(const QString &s);
void setType(const QString &s);
void setLang(const QString &s);
void setSubject(const QString &s, const QString &lang="");
void setBody(const QString &s, const QString &lang="");
void setThread(const QString &s, bool send = false);
void setError(const Stanza::Error &err);
// JEP-0060
const QString& pubsubNode() const;
const QList<PubSubItem>& pubsubItems() const;
const QList<PubSubRetraction>& pubsubRetractions() const;
// JEP-0091
QDateTime timeStamp() const;
void setTimeStamp(const QDateTime &ts, bool send = false);
// JEP-0071
HTMLElement html(const QString &lang="") const;
void setHTML(const HTMLElement &s, const QString &lang="");
bool containsHTML() const;
// JEP-0066
UrlList urlList() const;
void urlAdd(const Url &u);
void urlsClear();
void setUrlList(const UrlList &list);
// JEP-0022
QString eventId() const;
void setEventId(const QString& id);
bool containsEvents() const;
bool containsEvent(MsgEvent e) const;
void addEvent(MsgEvent e);
// JEP-0085
ChatState chatState() const;
void setChatState(ChatState);
// XEP-0184
MessageReceipt messageReceipt() const;
void setMessageReceipt(MessageReceipt);
// JEP-0027
QString xencrypted() const;
void setXEncrypted(const QString &s);
// JEP-0033
AddressList addresses() const;
AddressList findAddresses(Address::Type t) const;
void addAddress(const Address &a);
void clearAddresses();
void setAddresses(const AddressList &list);
// JEP-144
const RosterExchangeItems& rosterExchangeItems() const;
void setRosterExchangeItems(const RosterExchangeItems&);
// JEP-172
void setNick(const QString&);
const QString& nick() const;
// JEP-0070
void setHttpAuthRequest(const HttpAuthRequest&);
HttpAuthRequest httpAuthRequest() const;
// JEP-0004
void setForm(const XData&);
const XData& getForm() const;
// JEP-xxxx Whiteboarding
void setWhiteboard(const QDomElement&);
const QDomElement& whiteboard() const;
// MUC
void setMUCStatus(int);
bool hasMUCStatus() const;
int mucStatus() const;
void addMUCInvite(const MUCInvite&);
const QList<MUCInvite>& mucInvites() const;
void setMUCDecline(const MUCDecline&);
const MUCDecline& mucDecline() const;
const QString& mucPassword() const;
void setMUCPassword(const QString&);
// Obsolete invitation
QString invite() const;
void setInvite(const QString &s);
// for compatibility. delete me later
bool spooled() const;
void setSpooled(bool);
bool wasEncrypted() const;
void setWasEncrypted(bool);
Stanza toStanza(Stream *stream) const;
bool fromStanza(const Stanza &s, int tzoffset);
#ifdef YAPSI
const YaLastMail& lastMailNotify() const;
void setLastMailNotify(const YaLastMail& lastMailNotify);
int spamFlag() const;
QString twin() const;
void setTwin(const QString& twin);
QString yaMessageId() const;
void setYaMessageId(const QString& yaMessageId);
int yaFlags() const;
void setYaFlags(int flags);
#endif
const QDomElement& getExtension(const QString& ns) const;
private:
class Private;
Private *d;
};
}
#endif

View file

@ -0,0 +1,137 @@
/*
* xmpp_muc.h
* Copyright (C) 2006 Remko Troncon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_MUC_H
#define XMPP_MUC_H
#include <QDomElement>
#include <QString>
#include "xmpp_jid.h"
namespace XMPP
{
class MUCItem
{
public:
enum Affiliation { UnknownAffiliation, Outcast, NoAffiliation, Member, Admin, Owner };
enum Role { UnknownRole, NoRole, Visitor, Participant, Moderator };
MUCItem(Role = UnknownRole, Affiliation = UnknownAffiliation);
MUCItem(const QDomElement&);
void setNick(const QString&);
void setJid(const Jid&);
void setAffiliation(Affiliation);
void setRole(Role);
void setActor(const Jid&);
void setReason(const QString&);
const QString& nick() const;
const Jid& jid() const;
Affiliation affiliation() const;
Role role() const;
const Jid& actor() const;
const QString& reason() const;
void fromXml(const QDomElement&);
QDomElement toXml(QDomDocument&);
bool operator==(const MUCItem& o);
private:
QString nick_;
Jid jid_, actor_;
Affiliation affiliation_;
Role role_;
QString reason_;
};
class MUCInvite
{
public:
MUCInvite();
MUCInvite(const QDomElement&);
MUCInvite(const Jid& to, const QString& reason = QString());
const Jid& to() const;
void setTo(const Jid&);
const Jid& from() const;
void setFrom(const Jid&);
const QString& reason() const;
void setReason(const QString&);
bool cont() const;
void setCont(bool);
void fromXml(const QDomElement&);
QDomElement toXml(QDomDocument&) const;
bool isNull() const;
private:
Jid to_, from_;
QString reason_, password_;
bool cont_;
};
class MUCDecline
{
public:
MUCDecline();
MUCDecline(const Jid& to, const QString& reason);
MUCDecline(const QDomElement&);
const Jid& to() const;
void setTo(const Jid&);
const Jid& from() const;
void setFrom(const Jid&);
const QString& reason() const;
void setReason(const QString&);
void fromXml(const QDomElement&);
QDomElement toXml(QDomDocument&) const;
bool isNull() const;
private:
Jid to_, from_;
QString reason_;
};
class MUCDestroy
{
public:
MUCDestroy();
MUCDestroy(const QDomElement&);
const Jid& jid() const;
void setJid(const Jid&);
const QString& reason() const;
void setReason(const QString&);
void fromXml(const QDomElement&);
QDomElement toXml(QDomDocument&) const;
private:
Jid jid_;
QString reason_;
};
}
#endif

View file

@ -0,0 +1,42 @@
/*
* Copyright (C) 2006 Remko Troncon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_PUBSUBITEM_H
#define XMPP_PUBSUBITEM_H
#include <QString>
#include <QDomElement>
namespace XMPP
{
class PubSubItem
{
public:
PubSubItem();
PubSubItem(const QString& id, const QDomElement& payload);
const QString& id() const;
const QDomElement& payload() const;
private:
QString id_;
QDomElement payload_;
};
}
#endif

View file

@ -0,0 +1,41 @@
/*
* Copyright (C) 2006 Remko Troncon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_PUBSUBRETRACTION_H
#define XMPP_PUBSUBRETRACTION_H
#include <QString>
#include <QDomElement>
namespace XMPP
{
class PubSubRetraction
{
public:
PubSubRetraction();
PubSubRetraction(const QString& id);
const QString& id() const;
private:
QString id_;
};
}
#endif

View file

@ -0,0 +1,32 @@
/*
* xmpp_receipts.h - XEP-0184 support helper file
* Copyright (C) 2007 Michail Pishchagin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_RECEIPTS_H
#define XMPP_RECEIPTS_H
namespace XMPP {
typedef enum {
ReceiptNone,
ReceiptRequest,
ReceiptReceived
} MessageReceipt;
}
#endif

View file

@ -0,0 +1,48 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_RESOURCE_H
#define XMPP_RESOURCE_H
#include <QString>
#include "xmpp_status.h"
namespace XMPP
{
class Resource
{
public:
Resource(const QString &name="", const Status &s=Status());
~Resource();
const QString & name() const;
int priority() const;
const Status & status() const;
void setName(const QString &);
void setStatus(const Status &);
private:
QString v_name;
Status v_status;
};
}
#endif

View file

@ -0,0 +1,45 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_RESOURCELIST_H
#define XMPP_RESOURCELIST_H
#include <QList>
#include "xmpp_resource.h"
class QString;
namespace XMPP
{
class ResourceList : public QList<Resource>
{
public:
ResourceList();
~ResourceList();
ResourceList::Iterator find(const QString &);
ResourceList::Iterator priority();
ResourceList::ConstIterator find(const QString &) const;
ResourceList::ConstIterator priority() const;
};
}
#endif

View file

@ -0,0 +1,47 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_ROSTER_H
#define XMPP_ROSTER_H
#include <QList>
#include "xmpp_rosteritem.h"
class QDomDocument;
class QDomElement;
namespace XMPP
{
class Jid;
class Roster : public QList<RosterItem>
{
public:
Roster();
~Roster();
Roster::Iterator find(const Jid &);
Roster::ConstIterator find(const Jid &) const;
private:
class RosterPrivate *d;
};
}
#endif

View file

@ -0,0 +1,82 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_ROSTERITEM_H
#define XMPP_ROSTERITEM_H
#include <QString>
#include <QStringList>
#include "xmpp_jid.h"
namespace XMPP
{
class Subscription
{
public:
enum SubType { None, To, From, Both, Remove };
Subscription(SubType type=None);
int type() const;
QString toString() const;
bool fromString(const QString &);
private:
SubType value;
};
class RosterItem
{
public:
RosterItem(const Jid &jid="");
virtual ~RosterItem();
const Jid & jid() const;
const QString & name() const;
const QStringList & groups() const;
const Subscription & subscription() const;
const QString & ask() const;
bool isPush() const;
bool inGroup(const QString &) const;
virtual void setJid(const Jid &);
void setName(const QString &);
void setGroups(const QStringList &);
void setSubscription(const Subscription &);
void setAsk(const QString &);
void setIsPush(bool);
bool addGroup(const QString &);
bool removeGroup(const QString &);
QDomElement toXml(QDomDocument *) const;
bool fromXml(const QDomElement &);
private:
Jid v_jid;
QString v_name;
QStringList v_groups;
Subscription v_subscription;
QString v_ask;
bool v_push;
};
}
#endif

View file

@ -0,0 +1,66 @@
/*
* rosterexchangeitem.h
* Copyright (C) 2003 Remko Troncon
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_ROSTERX_H
#define XMPP_ROSTERX_H
#include <QString>
#include <QStringList>
#include "xmpp_jid.h"
class QDomElement;
namespace XMPP
{
class Stanza;
class RosterExchangeItem
{
public:
enum Action { Add, Delete, Modify };
RosterExchangeItem(const Jid& jid, const QString& name = "", const QStringList& groups = QStringList(), Action = Add);
RosterExchangeItem(const QDomElement&);
const Jid& jid() const;
Action action() const;
const QString& name() const;
const QStringList& groups() const;
bool isNull() const;
void setJid(const Jid&);
void setAction(Action);
void setName(const QString&);
void setGroups(const QStringList&);
QDomElement toXml(Stanza&) const;
void fromXml(const QDomElement&);
private:
Jid jid_;
QString name_;
QStringList groups_;
Action action_;
};
typedef QList<RosterExchangeItem> RosterExchangeItems;
}
#endif

View file

@ -0,0 +1,138 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_STANZA_H
#define XMPP_STANZA_H
#include <QPair>
#include <QString>
#include <QDomElement>
class QDomDocument;
namespace XMPP
{
class Jid;
class Stream;
class Stanza
{
public:
enum Kind { Message, Presence, IQ };
Stanza();
Stanza(const Stanza &from);
Stanza & operator=(const Stanza &from);
virtual ~Stanza();
class Error
{
public:
enum ErrorType { Cancel = 1, Continue, Modify, Auth, Wait };
enum ErrorCond
{
BadRequest = 1,
Conflict,
FeatureNotImplemented,
Forbidden,
Gone,
InternalServerError,
ItemNotFound,
JidMalformed,
NotAcceptable,
NotAllowed,
NotAuthorized,
PaymentRequired,
RecipientUnavailable,
Redirect,
RegistrationRequired,
RemoteServerNotFound,
RemoteServerTimeout,
ResourceConstraint,
ServiceUnavailable,
SubscriptionRequired,
UndefinedCondition,
UnexpectedRequest
};
Error(int type=Cancel, int condition=UndefinedCondition, const QString &text="", const QDomElement &appSpec=QDomElement());
int type;
int condition;
QString text;
QDomElement appSpec;
int code() const;
bool fromCode(int code);
QPair<QString, QString> description() const;
QDomElement toXml(QDomDocument &doc, const QString &baseNS) const;
bool fromXml(const QDomElement &e, const QString &baseNS);
private:
class Private;
int originalCode;
};
bool isNull() const;
QDomElement element() const;
QString toString() const;
QDomDocument & doc() const;
QString baseNS() const;
QDomElement createElement(const QString &ns, const QString &tagName);
QDomElement createTextElement(const QString &ns, const QString &tagName, const QString &text);
void appendChild(const QDomElement &e);
Kind kind() const;
void setKind(Kind k);
Jid to() const;
Jid from() const;
QString id() const;
QString type() const;
QString lang() const;
void setTo(const Jid &j);
void setFrom(const Jid &j);
void setId(const QString &id);
void setType(const QString &type);
void setLang(const QString &lang);
#ifdef YAPSI
void setAttribute(const QString& name, const QString& value);
#endif
Error error() const;
void setError(const Error &err);
void clearError();
private:
friend class Stream;
Stanza(Stream *s, Kind k, const Jid &to, const QString &type, const QString &id);
Stanza(Stream *s, const QDomElement &e);
class Private;
Private *d;
};
}
#endif

View file

@ -0,0 +1,151 @@
/*
* xmpp_status.h
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_STATUS_H
#define XMPP_STATUS_H
#include <QString>
#include <QDateTime>
#include "xmpp_muc.h"
namespace XMPP
{
class Status
{
public:
enum Type {
Offline, Online, Away, XA, DND, Invisible, FFC
#ifdef YAPSI
, Blocked, Reconnecting, NotAuthorizedToSeeStatus
, GC_Active, GC_Inactive, GC_Favorited
#endif
};
Status(const QString &show="", const QString &status="", int priority=0, bool available=true);
Status(Type type, const QString& status="", int priority=0);
~Status();
int priority() const;
Type type() const;
QString typeString() const;
const QString & show() const;
const QString & status() const;
QDateTime timeStamp() const;
const QString & keyID() const;
bool isAvailable() const;
bool isAway() const;
bool isInvisible() const;
bool hasError() const;
int errorCode() const;
const QString & errorString() const;
const QString & xsigned() const;
const QString & songTitle() const;
const QString & capsNode() const;
const QString & capsVersion() const;
const QString & capsExt() const;
#ifdef YAPSI
const QString & notifyValue() const;
#endif
bool isMUC() const;
bool hasMUCItem() const;
const MUCItem & mucItem() const;
bool hasMUCDestroy() const;
const MUCDestroy & mucDestroy() const;
bool hasMUCStatus() const;
QList<int> getMUCStatuses() const;
int mucStatus() const;
const QString& mucPassword() const;
bool hasMUCHistory() const;
int mucHistoryMaxChars() const;
int mucHistoryMaxStanzas() const;
int mucHistorySeconds() const;
void setPriority(int);
void setType(Type);
void setType(QString);
void setShow(const QString &);
void setStatus(const QString &);
void setTimeStamp(const QDateTime &);
void setKeyID(const QString &);
void setIsAvailable(bool);
void setIsInvisible(bool);
void setError(int, const QString &);
void setCapsNode(const QString&);
void setCapsVersion(const QString&);
void setCapsExt(const QString&);
void setMUC();
void setMUCItem(const MUCItem&);
void setMUCDestroy(const MUCDestroy&);
void setMUCStatus(int);
void setMUCPassword(const QString&);
void setMUCHistory(int maxchars, int maxstanzas, int seconds);
void setXSigned(const QString &);
void setSongTitle(const QString &);
#ifdef YAPSI
void setNotifyValue(const QString &);
#endif
// JEP-153: VCard-based Avatars
const QString& photoHash() const;
void setPhotoHash(const QString&);
bool hasPhotoHash() const;
private:
int v_priority;
QString v_show, v_status, v_key;
QDateTime v_timeStamp;
bool v_isAvailable;
bool v_isInvisible;
QString v_photoHash;
bool v_hasPhotoHash;
QString v_xsigned;
// gabber song extension
QString v_songTitle;
QString v_capsNode, v_capsVersion, v_capsExt;
// MUC
bool v_isMUC, v_hasMUCItem, v_hasMUCDestroy;
MUCItem v_mucItem;
MUCDestroy v_mucDestroy;
int v_mucStatus;
QString v_mucPassword;
int v_mucHistoryMaxChars, v_mucHistoryMaxStanzas, v_mucHistorySeconds;
#ifdef YAPSI
QString v_notifyValue;
#endif
int ecode;
QString estr;
};
}
#include <QMetaType>
Q_DECLARE_METATYPE(XMPP::Status)
#endif

View file

@ -0,0 +1,81 @@
/*
* xmpp.h - XMPP "core" library API
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_STREAM_H
#define XMPP_STREAM_H
#include <QDomElement>
#include <QObject>
#include "xmpp_stanza.h"
#include "xmpp_jid.h"
class QDomDocument;
namespace XMPP
{
class Stream : public QObject
{
Q_OBJECT
public:
enum Error { ErrParse, ErrProtocol, ErrStream, ErrCustom = 10 };
enum StreamCond {
GenericStreamError,
Conflict,
ConnectionTimeout,
InternalServerError,
InvalidFrom,
InvalidXml,
PolicyViolation,
ResourceConstraint,
SystemShutdown
};
Stream(QObject *parent=0);
virtual ~Stream();
virtual QDomDocument & doc() const=0;
virtual QString baseNS() const=0;
virtual bool old() const=0;
virtual void close()=0;
virtual bool stanzaAvailable() const=0;
virtual Stanza read()=0;
virtual void write(const Stanza &s)=0;
virtual int errorCondition() const=0;
virtual QString errorText() const=0;
virtual QDomElement errorAppSpec() const=0;
Stanza createStanza(Stanza::Kind k, const Jid &to="", const QString &type="", const QString &id="");
Stanza createStanza(const QDomElement &e);
static QString xmlToString(const QDomElement &e, bool clip=false);
signals:
void connectionClosed();
void delayedCloseFinished();
void readyRead();
void stanzaWritten();
void error(int);
};
}
#endif

View file

@ -0,0 +1,82 @@
/*
* xmpp_task.h
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_TASK_H
#define XMPP_TASK_H
#include <QObject>
#include <QString>
class QDomDocument;
class QDomElement;
namespace XMPP {
class Client;
class Jid;
class Task : public QObject
{
Q_OBJECT
public:
enum { ErrDisc };
Task(Task *parent);
Task(Client *, bool isRoot);
virtual ~Task();
Task *parent() const;
Client *client() const;
QDomDocument *doc() const;
QString id() const;
bool success() const;
int statusCode() const;
const QString & statusString() const;
void go(bool autoDelete=false);
virtual bool take(const QDomElement &);
void safeDelete();
signals:
void finished();
protected:
virtual void onGo();
virtual void onDisconnect();
void send(const QDomElement &);
void setSuccess(int code=0, const QString &str="");
void setError(const QDomElement &);
void setError(int code=0, const QString &str="");
void debug(const char *, ...);
void debug(const QString &);
bool iqVerify(const QDomElement &x, const Jid &to, const QString &id, const QString &xmlns="");
private slots:
void clientDisconnected();
void done();
private:
void init();
class TaskPrivate;
TaskPrivate *d;
};
}
#endif

View file

@ -0,0 +1,49 @@
/*
* Copyright (C) 2003 Justin Karneges
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_URL
#define XMPP_URL
class QString;
namespace XMPP
{
class Url
{
public:
Url(const QString &url="", const QString &desc="");
Url(const Url &);
Url & operator=(const Url &);
~Url();
QString url() const;
QString desc() const;
void setUrl(const QString &);
void setDesc(const QString &);
private:
class Private;
Private *d;
};
typedef QList<Url> UrlList;
}
#endif

View file

@ -0,0 +1,158 @@
/*
* xmpp_xdata.h - a class for jabber:x:data forms
* Copyright (C) 2003-2004 Michail Pishchagin
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPPXDATA_H
#define XMPPXDATA_H
#include <QString>
#include <QMap>
#include <QList>
#include <QSharedDataPointer>
#include <QStringList>
class QDomElement;
class QDomDocument;
namespace XMPP {
class XData
{
public:
XData();
QString title() const;
void setTitle(const QString &);
QString instructions() const;
void setInstructions(const QString &);
enum Type {
Data_Form,
Data_Result,
Data_Submit,
Data_Cancel
};
Type type() const;
void setType(Type);
struct ReportField {
ReportField() { }
ReportField( QString _label, QString _name ) { label = _label; name = _name; }
QString label;
QString name;
};
const QList<ReportField> &report() const;
typedef QMap<QString, QString> ReportItem;
const QList<ReportItem> &reportItems() const;
void fromXml(const QDomElement &);
QDomElement toXml(QDomDocument *, bool submitForm = true) const;
bool isValid() const;
public:
class Field {
public:
Field();
~Field();
QString desc() const;
void setDesc(const QString &);
struct Option {
QString label;
QString value;
};
typedef QList<Option> OptionList;
OptionList options() const;
void setOptions(OptionList);
bool required() const;
void setRequired(bool);
QString label() const;
void setLabel(const QString &);
QString var() const;
void setVar(const QString &);
// generic value variable, because every possible Type
// can be converted to QStringList. Field_Single will
// use just one string in QStringList. Field_Boolean will
// use just one string, and that string will equal 0 or 1.
// and so on...
QStringList value() const;
void setValue(const QStringList &);
enum Type {
Field_Boolean,
Field_Fixed,
Field_Hidden,
Field_JidMulti,
Field_JidSingle,
Field_ListMulti,
Field_ListSingle,
Field_TextMulti,
Field_TextPrivate,
Field_TextSingle
};
Type type() const;
void setType(Type);
bool isValid() const;
void fromXml(const QDomElement &);
QDomElement toXml(QDomDocument *, bool submitForm = true) const;
private:
QString _desc, _label, _var;
QList<Option> _options;
bool _required;
Type _type;
QStringList _value;
};
typedef QList<Field> FieldList;
FieldList fields() const;
void setFields(const FieldList &);
void addField(XMPP::XData::Field::Type type, const QString& var, const QString& value);
private:
class Private : public QSharedData {
public:
Private();
QString title, instructions;
XData::Type type;
FieldList fields;
QList<ReportField> report;
QList<ReportItem> reportItems;
};
QSharedDataPointer<Private> d;
};
};
#endif

View file

@ -0,0 +1,68 @@
/*
* xmpp_yadatetime.h
* Copyright (C) 2009 Yandex LLC (Michail Pishchagin)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_YADATETIME_H
#define XMPP_YADATETIME_H
#include <QDateTime>
namespace XMPP {
class YaDateTime : public QDateTime
{
public:
YaDateTime();
YaDateTime(const QDateTime& dateTime);
YaDateTime(const YaDateTime& dateTime);
bool isNull() const;
int microsec() const;
void setMiscosec(int microsec);
YaDateTime& operator=(const YaDateTime &other);
bool operator==(const YaDateTime& other) const;
bool operator!=(const YaDateTime& other) const;
bool operator<(const YaDateTime& other) const;
bool operator<=(const YaDateTime& other) const;
bool operator>(const YaDateTime& other) const;
bool operator>=(const YaDateTime& other) const;
QString toYaTime_t() const;
static YaDateTime fromYaTime_t(const QString& str);
QString toYaIsoTime() const;
static YaDateTime fromYaIsoTime(const QString& str);
private:
int microsec_;
static int getMicrosec(const QString& str);
};
}; // namespace XMPP
uint qHash(const XMPP::YaDateTime& yaDateTime);
#include <QMetaType>
Q_DECLARE_METATYPE(XMPP::YaDateTime)
#endif

View file

@ -0,0 +1,48 @@
/*
* xmpp_yalastmail.h - storage class for new mail notifications
* Copyright (C) 2008 Yandex LLC (Michail Pishchagin)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef XMPP_YALASTMAIL_H
#define XMPP_YALASTMAIL_H
#include <QString>
#include <QDateTime>
class YaLastMail
{
public:
YaLastMail()
: from(QString())
, subject(QString())
, timeStamp(QDateTime())
, mid(QString())
{}
bool isNull() const
{
return from.isNull() && subject.isNull() && timeStamp.isNull() && mid.isNull();
}
QString from;
QString subject;
QDateTime timeStamp;
QString mid;
};
#endif