File indexing completed on 2024-06-23 04:03:37
0001 /* 0002 * xmpp.h - XMPP "core" library API 0003 * Copyright (C) 2003 Justin Karneges 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Lesser General Public 0007 * License as published by the Free Software Foundation; either 0008 * either version 2 0009 of the License, or (at your option) any later version.1 of the License, or (at your option) any later version. 0010 * 0011 * This library is distributed in the hope that it will be useful, 0012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0014 * Lesser General Public License for more details. 0015 * 0016 * You should have received a copy of the GNU Lesser General Public 0017 * License along with this library; if not, write to the Free Software 0018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 0019 * 0020 */ 0021 0022 #ifndef XMPP_STREAM_H 0023 #define XMPP_STREAM_H 0024 0025 #include <QDomElement> 0026 #include <QObject> 0027 0028 #include "xmpp_stanza.h" 0029 #include "xmpp/jid/jid.h" 0030 0031 class QDomDocument; 0032 0033 namespace XMPP 0034 { 0035 class Stream : public QObject 0036 { 0037 Q_OBJECT 0038 public: 0039 enum Error { ErrParse, ErrProtocol, ErrStream, ErrCustom = 10 }; 0040 enum StreamCond { 0041 GenericStreamError, 0042 Conflict, 0043 ConnectionTimeout, 0044 InternalServerError, 0045 InvalidFrom, 0046 InvalidXml, 0047 PolicyViolation, 0048 ResourceConstraint, 0049 SystemShutdown 0050 }; 0051 0052 Stream(QObject *parent=0); 0053 ~Stream() override; 0054 0055 virtual QDomDocument & doc() const=0; 0056 virtual QString baseNS() const=0; 0057 virtual bool old() const=0; 0058 0059 virtual void close()=0; 0060 virtual bool stanzaAvailable() const=0; 0061 virtual Stanza read()=0; 0062 virtual void write(const Stanza &s)=0; 0063 0064 virtual int errorCondition() const=0; 0065 virtual QString errorText() const=0; 0066 virtual QDomElement errorAppSpec() const=0; 0067 0068 Stanza createStanza(Stanza::Kind k, const Jid &to="", const QString &type="", const QString &id=""); 0069 Stanza createStanza(const QDomElement &e); 0070 0071 static QString xmlToString(const QDomElement &e, bool clip=false); 0072 0073 signals: 0074 void connectionClosed(); 0075 void delayedCloseFinished(); 0076 void readyRead(); 0077 void stanzaWritten(); 0078 void error(int); 0079 }; 0080 } 0081 0082 #endif