From 4bea8072aa0e21c0fce2c56e87a5e06cd71d7bd0 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Mon, 23 Aug 2010 08:15:31 +0000 Subject: rename QXmppBind to QXmppBindIq --- src/QXmppBind.cpp | 94 --------------------------------------------- src/QXmppBind.h | 62 ------------------------------ src/QXmppBindIq.cpp | 85 ++++++++++++++++++++++++++++++++++++++++ src/QXmppBindIq.h | 56 +++++++++++++++++++++++++++ src/QXmppIncomingClient.cpp | 16 ++++---- src/QXmppOutgoingClient.cpp | 8 ++-- src/src.pro | 4 +- 7 files changed, 156 insertions(+), 169 deletions(-) delete mode 100644 src/QXmppBind.cpp delete mode 100644 src/QXmppBind.h create mode 100644 src/QXmppBindIq.cpp create mode 100644 src/QXmppBindIq.h (limited to 'src') diff --git a/src/QXmppBind.cpp b/src/QXmppBind.cpp deleted file mode 100644 index c75698b0..00000000 --- a/src/QXmppBind.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2008-2010 The QXmpp developers - * - * Authors: - * Manjeet Dahiya - * 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 -#include -#include - -#include "QXmppBind.h" -#include "QXmppUtils.h" -#include "QXmppConstants.h" - -QXmppBind::QXmppBind() -{ -} - -QXmppBind::QXmppBind(QXmppIq::Type type) - : QXmppIq(type) -{ -} - -QString QXmppBind::jid() const -{ - return m_jid; -} - -QString QXmppBind::resource() const -{ - return m_resource; -} - -void QXmppBind::setJid(const QString& str) -{ - m_jid = str; -} - -void QXmppBind::setResource(const QString& str) -{ - m_resource = str; -} - -bool QXmppBind::isBind(const QDomElement &element) -{ - QDomElement bindElement = element.firstChildElement("bind"); - return (bindElement.namespaceURI() == ns_bind); -} - -void QXmppBind::parseElementFromChild(const QDomElement &element) -{ - QDomElement bindElement = element.firstChildElement("bind"); - m_jid = bindElement.firstChildElement("jid").text(); - m_resource = bindElement.firstChildElement("resource").text(); -} - -void QXmppBind::toXmlElementFromChild(QXmlStreamWriter *writer) const -{ - writer->writeStartElement("bind"); - helperToXmlAddAttribute(writer, "xmlns", ns_bind); - if (!m_jid.isEmpty()) - helperToXmlAddTextElement(writer, "jid", m_jid); - if (!m_resource.isEmpty()) - helperToXmlAddTextElement(writer, "resource", m_resource); - writer->writeEndElement(); -} - -QString QXmppBind::getJid() const -{ - return m_jid; -} - -QString QXmppBind::getResource() const -{ - return m_resource; -} diff --git a/src/QXmppBind.h b/src/QXmppBind.h deleted file mode 100644 index a485576f..00000000 --- a/src/QXmppBind.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (C) 2008-2010 The QXmpp developers - * - * Authors: - * Manjeet Dahiya - * 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 QXMPPBIND_H -#define QXMPPBIND_H - -#include "QXmppIq.h" - -class QXmppBind : public QXmppIq -{ -public: - QXmppBind(); - QXmppBind(QXmppIq::Type type); - - QString jid() const; - QString resource() const; - - void setJid(const QString&); - void setResource(const QString&); - - static bool isBind(const QDomElement &element); - - // deprecated accessors, use the form without "get" instead - /// \cond - QString Q_DECL_DEPRECATED getJid() const; - QString Q_DECL_DEPRECATED getResource() const; - /// \endcond - -protected: - /// \cond - void parseElementFromChild(const QDomElement &element); - void toXmlElementFromChild(QXmlStreamWriter *writer) const; - /// \endcond - -private: - QString m_jid; - QString m_resource; -}; - -#endif // QXMPPBIND_H diff --git a/src/QXmppBindIq.cpp b/src/QXmppBindIq.cpp new file mode 100644 index 00000000..759e9cbf --- /dev/null +++ b/src/QXmppBindIq.cpp @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2008-2010 The QXmpp developers + * + * Authors: + * Manjeet Dahiya + * 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 +#include +#include + +#include "QXmppBindIq.h" +#include "QXmppUtils.h" +#include "QXmppConstants.h" + +QXmppBindIq::QXmppBindIq() +{ +} + +QXmppBindIq::QXmppBindIq(QXmppIq::Type type) + : QXmppIq(type) +{ +} + +QString QXmppBindIq::jid() const +{ + return m_jid; +} + +QString QXmppBindIq::resource() const +{ + return m_resource; +} + +void QXmppBindIq::setJid(const QString& str) +{ + m_jid = str; +} + +void QXmppBindIq::setResource(const QString& str) +{ + m_resource = str; +} + +bool QXmppBindIq::isBindIq(const QDomElement &element) +{ + QDomElement bindElement = element.firstChildElement("bind"); + return (bindElement.namespaceURI() == ns_bind); +} + +void QXmppBindIq::parseElementFromChild(const QDomElement &element) +{ + QDomElement bindElement = element.firstChildElement("bind"); + m_jid = bindElement.firstChildElement("jid").text(); + m_resource = bindElement.firstChildElement("resource").text(); +} + +void QXmppBindIq::toXmlElementFromChild(QXmlStreamWriter *writer) const +{ + writer->writeStartElement("bind"); + helperToXmlAddAttribute(writer, "xmlns", ns_bind); + if (!m_jid.isEmpty()) + helperToXmlAddTextElement(writer, "jid", m_jid); + if (!m_resource.isEmpty()) + helperToXmlAddTextElement(writer, "resource", m_resource); + writer->writeEndElement(); +} + diff --git a/src/QXmppBindIq.h b/src/QXmppBindIq.h new file mode 100644 index 00000000..5794c66a --- /dev/null +++ b/src/QXmppBindIq.h @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2008-2010 The QXmpp developers + * + * Authors: + * Manjeet Dahiya + * 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 QXMPPBINDIQ_H +#define QXMPPBINDIQ_H + +#include "QXmppIq.h" + +class QXmppBindIq : public QXmppIq +{ +public: + QXmppBindIq(); + QXmppBindIq(QXmppIq::Type type); + + QString jid() const; + QString resource() const; + + void setJid(const QString&); + void setResource(const QString&); + + static bool isBindIq(const QDomElement &element); + +protected: + /// \cond + void parseElementFromChild(const QDomElement &element); + void toXmlElementFromChild(QXmlStreamWriter *writer) const; + /// \endcond + +private: + QString m_jid; + QString m_resource; +}; + +#endif // QXMPPBIND_H diff --git a/src/QXmppIncomingClient.cpp b/src/QXmppIncomingClient.cpp index 1211bc18..1e9cd3e5 100644 --- a/src/QXmppIncomingClient.cpp +++ b/src/QXmppIncomingClient.cpp @@ -26,7 +26,7 @@ #include #include -#include "QXmppBind.h" +#include "QXmppBindIq.h" #include "QXmppConstants.h" #include "QXmppMessage.h" #include "QXmppSessionIq.h" @@ -256,13 +256,14 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) if (nodeRecv.tagName() == "iq") { const QString type = nodeRecv.attribute("type"); - if (QXmppBind::isBind(nodeRecv) && type == "set") + if (QXmppBindIq::isBindIq(nodeRecv) && type == "set") { - QXmppBind bindSet; + QXmppBindIq bindSet; bindSet.parse(nodeRecv); d->resource = bindSet.resource(); - QXmppBind bindResult(QXmppIq::Result); + QXmppBindIq bindResult; + bindResult.setType(QXmppIq::Result); bindResult.setId(bindSet.id()); bindResult.setJid(jid()); sendPacket(bindResult); @@ -270,12 +271,13 @@ void QXmppIncomingClient::handleStanza(const QDomElement &nodeRecv) // bound emit connected(); } - else if (QXmppSession::isSession(nodeRecv) && type == "set") + else if (QXmppSessionIq::isSessionIq(nodeRecv) && type == "set") { - QXmppSession sessionSet; + QXmppSessionIq sessionSet; sessionSet.parse(nodeRecv); - QXmppSession sessionResult(QXmppIq::Result); + QXmppSessionIq sessionResult; + sessionResult.setType(QXmppIq::Result); sessionResult.setId(sessionSet.id()); sendPacket(sessionResult); } diff --git a/src/QXmppOutgoingClient.cpp b/src/QXmppOutgoingClient.cpp index 83f8f895..a1125a84 100644 --- a/src/QXmppOutgoingClient.cpp +++ b/src/QXmppOutgoingClient.cpp @@ -38,7 +38,7 @@ // IQ types #include "QXmppArchiveIq.h" -#include "QXmppBind.h" +#include "QXmppBindIq.h" #include "QXmppByteStreamIq.h" #include "QXmppDiscoveryIq.h" #include "QXmppIbbIq.h" @@ -312,7 +312,7 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv) // check whether bind is available if (features.isBindAvailable()) { - QXmppBind bind(QXmppIq::Set); + QXmppBindIq bind(QXmppIq::Set); bind.setResource(configuration().resource()); d->bindId = bind.id(); sendPacket(bind); @@ -396,9 +396,9 @@ void QXmppOutgoingClient::handleStanza(const QDomElement &nodeRecv) d->sessionStarted = true; emit connected(); } - else if(QXmppBind::isBind(nodeRecv) && id == d->bindId) + else if(QXmppBindIq::isBindIq(nodeRecv) && id == d->bindId) { - QXmppBind bind; + QXmppBindIq bind; bind.parse(nodeRecv); // bind result diff --git a/src/src.pro b/src/src.pro index b9c652c3..b14412c9 100644 --- a/src/src.pro +++ b/src/src.pro @@ -21,7 +21,7 @@ DESTDIR = $$QXMPP_LIBRARY_DIR HEADERS += QXmppUtils.h \ QXmppArchiveIq.h \ QXmppArchiveManager.h \ - QXmppBind.h \ + QXmppBindIq.h \ QXmppByteStreamIq.h \ QXmppCallManager.h \ QXmppClient.h \ @@ -70,7 +70,7 @@ HEADERS += QXmppUtils.h \ SOURCES += QXmppUtils.cpp \ QXmppArchiveIq.cpp \ QXmppArchiveManager.cpp \ - QXmppBind.cpp \ + QXmppBindIq.cpp \ QXmppByteStreamIq.cpp \ QXmppCallManager.cpp \ QXmppClient.cpp \ -- cgit v1.2.3