aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-02-24 08:32:11 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-02-24 08:32:11 +0000
commit738cb6fa77f12fd1c07702cbfeca789da2c32065 (patch)
treed2eea298be57cad5d82573cb2a71bad8742dba4d /source
parent29831463891fee701f7b0b66342eb4bb46f58a12 (diff)
downloadqxmpp-738cb6fa77f12fd1c07702cbfeca789da2c32065.tar.gz
add QXmppStreamInitiationIq for XEP-0095
Diffstat (limited to 'source')
-rw-r--r--source/QXmppStreamInitiationIq.cpp111
-rw-r--r--source/QXmppStreamInitiationIq.h65
-rw-r--r--source/source.pro2
3 files changed, 178 insertions, 0 deletions
diff --git a/source/QXmppStreamInitiationIq.cpp b/source/QXmppStreamInitiationIq.cpp
new file mode 100644
index 00000000..26891f0d
--- /dev/null
+++ b/source/QXmppStreamInitiationIq.cpp
@@ -0,0 +1,111 @@
+/*
+ * Copyright (C) 2010 Bolloré telecom
+ *
+ * Author:
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * 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.
+ *
+ */
+
+#include <QDomElement>
+
+#include "QXmppConstants.h"
+#include "QXmppStreamInitiationIq.h"
+#include "QXmppUtils.h"
+
+QString QXmppStreamInitiationIq::getMimeType() const
+{
+ return m_mimeType;
+}
+
+void QXmppStreamInitiationIq::setMimeType(const QString &mimeType)
+{
+ m_mimeType = mimeType;
+}
+
+QXmppStreamInitiationIq::Profile QXmppStreamInitiationIq::getProfile() const
+{
+ return m_profile;
+}
+
+void QXmppStreamInitiationIq::setProfile(QXmppStreamInitiationIq::Profile profile)
+{
+ m_profile = profile;
+}
+
+QXmppElementList QXmppStreamInitiationIq::getSiItems() const
+{
+ return m_siItems;
+}
+
+QString QXmppStreamInitiationIq::getSiId() const
+{
+ return m_siId;
+}
+
+void QXmppStreamInitiationIq::setSiId(const QString &id)
+{
+ m_siId = id;
+}
+
+void QXmppStreamInitiationIq::setSiItems(const QXmppElementList &items)
+{
+ m_siItems = items;
+}
+
+bool QXmppStreamInitiationIq::isStreamInitiationIq(QDomElement &element)
+{
+ QDomElement siElement = element.firstChildElement("si");
+ return (siElement.namespaceURI() == ns_stream_initiation);
+}
+
+void QXmppStreamInitiationIq::parse(QDomElement &element)
+{
+ setId(element.attribute("id"));
+ setFrom(element.attribute("from"));
+ setTo(element.attribute("to"));
+ setTypeFromStr(element.attribute("type"));
+
+ QDomElement siElement = element.firstChildElement("si");
+ m_siId = siElement.attribute("id");
+ m_mimeType = siElement.attribute("mime-type");
+ if (siElement.attribute("profile") == ns_stream_initiation_file_transfer)
+ m_profile = FileTransfer;
+ else
+ m_profile = None;
+
+ QDomElement itemElement = siElement.firstChildElement();
+ while (!itemElement.isNull())
+ {
+ m_siItems.append(QXmppElement(itemElement));
+ itemElement = itemElement.nextSiblingElement();
+ }
+}
+
+void QXmppStreamInitiationIq::toXmlElementFromChild(QXmlStreamWriter *writer) const
+{
+ writer->writeStartElement("si");
+ helperToXmlAddAttribute(writer, "xmlns", ns_stream_initiation);
+ helperToXmlAddAttribute(writer, "id", m_siId);
+ helperToXmlAddAttribute(writer, "mime-type", m_mimeType);
+ if (m_profile == FileTransfer)
+ helperToXmlAddAttribute(writer, "profile", ns_stream_initiation_file_transfer);
+ foreach (const QXmppElement &item, m_siItems)
+ item.toXml(writer);
+ writer->writeEndElement();
+}
+
diff --git a/source/QXmppStreamInitiationIq.h b/source/QXmppStreamInitiationIq.h
new file mode 100644
index 00000000..a784bea9
--- /dev/null
+++ b/source/QXmppStreamInitiationIq.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2010 Bolloré telecom
+ *
+ * Author:
+ * Jeremy Lainé
+ *
+ * Source:
+ * http://code.google.com/p/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * 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.
+ *
+ */
+
+#ifndef QXMPPSTREAMINITIATIONIQ_H
+#define QXMPPSTREAMINITIATIONIQ_H
+
+#include <QDateTime>
+
+#include "QXmppIq.h"
+
+class QDomElement;
+class QXmlStreamWriter;
+
+class QXmppStreamInitiationIq : public QXmppIq
+{
+public:
+ enum Profile {
+ None = 0,
+ FileTransfer,
+ };
+
+ QString getMimeType() const;
+ void setMimeType(const QString &mimeType);
+
+ QXmppStreamInitiationIq::Profile getProfile() const;
+ void setProfile(QXmppStreamInitiationIq::Profile profile);
+
+ QString getSiId() const;
+ void setSiId(const QString &id);
+
+ QXmppElementList getSiItems() const;
+ void setSiItems(const QXmppElementList &items);
+
+ void parse(QDomElement &element);
+ void toXmlElementFromChild(QXmlStreamWriter *writer) const;
+ static bool isStreamInitiationIq(QDomElement &element);
+
+private:
+ QString m_mimeType;
+ Profile m_profile;
+ QString m_siId;
+ QXmppElementList m_siItems;
+};
+
+#endif
diff --git a/source/source.pro b/source/source.pro
index a3cbe019..6708f670 100644
--- a/source/source.pro
+++ b/source/source.pro
@@ -32,6 +32,7 @@ HEADERS += QXmppUtils.h \
QXmppSession.h \
QXmppStanza.h \
QXmppStream.h \
+ QXmppStreamInitiationIq.h \
QXmppLogger.h \
QXmppReconnectionManager.h \
QXmppVCardManager.h \
@@ -67,6 +68,7 @@ SOURCES += QXmppUtils.cpp \
QXmppSession.cpp \
QXmppStanza.cpp \
QXmppStream.cpp \
+ QXmppStreamInitiationIq.cpp \
QXmppLogger.cpp \
QXmppReconnectionManager.cpp \
QXmppVCardManager.cpp \