diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-02-08 12:33:41 +0000 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-02-08 12:33:41 +0000 |
| commit | 21acd67e9b65bea87902032b12709675905aa922 (patch) | |
| tree | ed5ae9066b10400c4fe6e67dfaf2f4c37a09c32e /src/QXmppVersionManager.cpp | |
| parent | cea7ae1e702b82d2d0d0a851de1aae58270b14f6 (diff) | |
| download | qxmpp-21acd67e9b65bea87902032b12709675905aa922.tar.gz | |
start moving client-specific code
Diffstat (limited to 'src/QXmppVersionManager.cpp')
| -rw-r--r-- | src/QXmppVersionManager.cpp | 159 |
1 files changed, 0 insertions, 159 deletions
diff --git a/src/QXmppVersionManager.cpp b/src/QXmppVersionManager.cpp deleted file mode 100644 index b6f81794..00000000 --- a/src/QXmppVersionManager.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (C) 2008-2011 The QXmpp developers - * - * Author: - * Manjeet Dahiya - * - * 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 <QCoreApplication> -#include <QDomElement> - -#include "QXmppClient.h" -#include "QXmppConstants.h" -#include "QXmppGlobal.h" -#include "QXmppVersionManager.h" -#include "QXmppVersionIq.h" - -QXmppVersionManager::QXmppVersionManager() : QXmppClientExtension(), - m_clientName(qApp->applicationName()), - m_clientVersion(qApp->applicationVersion()) -{ - if(m_clientName.isEmpty()) - m_clientName = "Based on QXmpp"; - -#if defined(Q_OS_LINUX) - m_clientOs = QString::fromLatin1("Linux"); -#elif defined(Q_OS_MAC) - m_clientOs = QString::fromLatin1("Mac OS"); -#elif defined(Q_OS_SYMBIAN) - m_clientOs = QString::fromLatin1("Symbian"); -#elif defined(Q_OS_WIN) - m_clientOs = QString::fromLatin1("Windows"); -#endif - - if(m_clientVersion.isEmpty()) - m_clientVersion = QXmppVersion(); -} - -QStringList QXmppVersionManager::discoveryFeatures() const -{ - // XEP-0092: Software Version - return QStringList() << ns_version; -} - -bool QXmppVersionManager::handleStanza(const QDomElement &element) -{ - if (element.tagName() == "iq" && QXmppVersionIq::isVersionIq(element)) - { - QXmppVersionIq versionIq; - versionIq.parse(element); - - if(versionIq.type() == QXmppIq::Get) - { - // respond to query - QXmppVersionIq responseIq; - responseIq.setType(QXmppIq::Result); - responseIq.setId(versionIq.id()); - responseIq.setTo(versionIq.from()); - - responseIq.setName(clientName()); - responseIq.setVersion(clientVersion()); - responseIq.setOs(clientOs()); - - client()->sendPacket(responseIq); - } - - emit versionReceived(versionIq); - return true; - } - - return false; -} - -/// Request version information from the specified XMPP entity. -/// -/// \param jid - -QString QXmppVersionManager::requestVersion(const QString& jid) -{ - QXmppVersionIq request; - request.setType(QXmppIq::Get); - request.setTo(jid); - if(client()->sendPacket(request)) - return request.id(); - else - return QString(); -} - -/// Sets the local XMPP client's name. -/// -/// \param name - -void QXmppVersionManager::setClientName(const QString& name) -{ - m_clientName = name; -} - -/// Sets the local XMPP client's version. -/// -/// \param version - -void QXmppVersionManager::setClientVersion(const QString& version) -{ - m_clientVersion = version; -} - -/// Sets the local XMPP client's operating system. -/// -/// \param os - -void QXmppVersionManager::setClientOs(const QString& os) -{ - m_clientOs = os; -} - -/// Returns the local XMPP client's name. -/// -/// By default this is set to the QApplication::applicationName(), or -/// "Based on QXmpp" if not specified. - -QString QXmppVersionManager::clientName() const -{ - return m_clientName; -} - -/// Returns the local XMPP client's version. -/// -/// By default this is set to QApplication::applicationVersion(), or -/// QXmpp's version if not specified. - -QString QXmppVersionManager::clientVersion() const -{ - return m_clientVersion; -} - -/// Returns the local XMPP client's operating system. -/// -/// By default this is "Linux", "Mac OS", "Symbian" or "Windows" depending -/// on the platform QXmpp was compiled for. - -QString QXmppVersionManager::clientOs() const -{ - return m_clientOs; -} |
