diff options
| author | Ian Geiser <ian.geiser@gmail.com> | 2009-11-08 19:44:16 +0000 |
|---|---|---|
| committer | Ian Geiser <ian.geiser@gmail.com> | 2009-11-08 19:44:16 +0000 |
| commit | 89e052995997c9a372d7deee6a9d31e100e10533 (patch) | |
| tree | 5970f1d5ea427d474b2679fb8788d6e8762e21ca /example/example_4_ibbTransferTarget | |
| parent | ac76758dc1859f360dc34f2c7872c96349f75524 (diff) | |
| download | qxmpp-89e052995997c9a372d7deee6a9d31e100e10533.tar.gz | |
Added better examples for in band byte transfers
Diffstat (limited to 'example/example_4_ibbTransferTarget')
5 files changed, 170 insertions, 0 deletions
diff --git a/example/example_4_ibbTransferTarget/README b/example/example_4_ibbTransferTarget/README new file mode 100644 index 00000000..4c3ac681 --- /dev/null +++ b/example/example_4_ibbTransferTarget/README @@ -0,0 +1,5 @@ +This is a very simple bot which echoes the message sent to it. + +Run this example, send it a message from a friend of this bot. You will recieve the message back. + +This example shows how to receive and send messages. diff --git a/example/example_4_ibbTransferTarget/example_4_ibbTransferTarget.pro b/example/example_4_ibbTransferTarget/example_4_ibbTransferTarget.pro new file mode 100644 index 00000000..7fcac6b6 --- /dev/null +++ b/example/example_4_ibbTransferTarget/example_4_ibbTransferTarget.pro @@ -0,0 +1,21 @@ +TEMPLATE = app + +TARGET = example_4_ibbTransferTarget + +SOURCES += main.cpp \ + ibbTransferTarget.cpp + +HEADERS += ibbTransferTarget.h + +INCLUDEPATH += ../../source + +QT += network xml +CONFIG += console debug_and_release + +CONFIG(debug, debug|release) { + LIBS += -L../../source/debug -lQXmppClient_d + } else { + LIBS += -L../../source/release -lQXmppClient + } + +OTHER_FILES += README diff --git a/example/example_4_ibbTransferTarget/ibbTransferTarget.cpp b/example/example_4_ibbTransferTarget/ibbTransferTarget.cpp new file mode 100644 index 00000000..c09efaac --- /dev/null +++ b/example/example_4_ibbTransferTarget/ibbTransferTarget.cpp @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2008-2009 QXmpp Developers + * + * Author: + * Ian Reinhart Geiser + * + * 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 "ibbTransferTarget.h" +#include "QXmppMessage.h" +#include "QXmppIbbTransferManager.h" +#include <QBuffer> +#include <qdebug.h> + +IbbTransferTarget::IbbTransferTarget(QObject *parent) + : QXmppClient(parent) +{ + bool check = connect(getIbbTransferManager(), SIGNAL(byteStreamRequestReceived(QString,QString)), + this, SLOT(openReceived(QString,QString))); + Q_ASSERT(check); + + check = connect(getIbbTransferManager(), SIGNAL(byteStreamClosed(QString,QString)), + this, SLOT(closeReceived(QString,QString))); + Q_ASSERT(check); + + m_buffer = new QBuffer(this); + m_buffer->open(QIODevice::WriteOnly); +} + +IbbTransferTarget::~IbbTransferTarget() +{ +} + +void IbbTransferTarget::openReceived( const QString &sid, const QString& from) +{ + qDebug() << "Got open byte stream request from" << from; + getIbbTransferManager()->acceptByteStreamRequest(sid, m_buffer); +} + +void IbbTransferTarget::closeReceived( const QString& sid, const QString& reason) +{ + qDebug() << "Stream done:" << m_buffer->data(); +} diff --git a/example/example_4_ibbTransferTarget/ibbTransferTarget.h b/example/example_4_ibbTransferTarget/ibbTransferTarget.h new file mode 100644 index 00000000..fb2cb308 --- /dev/null +++ b/example/example_4_ibbTransferTarget/ibbTransferTarget.h @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2008-2009 QXmpp Developers + * + * Author: + * Ian Reinhart Geiser + * + * 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 IBBTRANSFERTARGET_H +#define IBBTRANSFERTARGET_H + +#include "QXmppClient.h" + +class QBuffer; +class IbbTransferTarget : public QXmppClient +{ + Q_OBJECT + +public: + IbbTransferTarget(QObject *parent = 0); + ~IbbTransferTarget(); + +public slots: + void openReceived( const QString&, const QString& ); + void closeReceived( const QString&, const QString& ); +private: + QBuffer *m_buffer; +}; + +#endif // IBBTRANSFERTARGET_H diff --git a/example/example_4_ibbTransferTarget/main.cpp b/example/example_4_ibbTransferTarget/main.cpp new file mode 100644 index 00000000..5cf19ade --- /dev/null +++ b/example/example_4_ibbTransferTarget/main.cpp @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2008-2009 QXmpp Developers + * + * Author: + * Ian Reinhart Geiser + * + * 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 <QtCore/QCoreApplication> +#include "ibbTransferTarget.h" +#include "QXmppLogger.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + QXmppLogger::getLogger()->setLoggingType(QXmppLogger::STDOUT); + + IbbTransferTarget client; + client.getConfiguration().setUseSASLAuthentication( false ); + client.connectToServer("jabber.geiseri.com", "client", "Passw0rd", "geiseri.com"); + return a.exec(); +} |
