aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorIan Geiser <ian.geiser@gmail.com>2009-11-08 19:44:16 +0000
committerIan Geiser <ian.geiser@gmail.com>2009-11-08 19:44:16 +0000
commit89e052995997c9a372d7deee6a9d31e100e10533 (patch)
tree5970f1d5ea427d474b2679fb8788d6e8762e21ca /example
parentac76758dc1859f360dc34f2c7872c96349f75524 (diff)
downloadqxmpp-89e052995997c9a372d7deee6a9d31e100e10533.tar.gz
Added better examples for in band byte transfers
Diffstat (limited to 'example')
-rw-r--r--example/example.pro3
-rw-r--r--example/example_3_ibbTransferSource/example_3_ibbTransfer.pro0
-rw-r--r--example/example_3_ibbTransferSource/example_3_ibbTransferSource.pro (renamed from example/example_3_ibbTransfer/example_3_ibbTransfer.pro)2
-rw-r--r--example/example_3_ibbTransferSource/ibbClient.cpp (renamed from example/example_3_ibbTransfer/ibbClient.cpp)4
-rw-r--r--example/example_3_ibbTransferSource/ibbClient.h (renamed from example/example_3_ibbTransfer/ibbClient.h)4
-rw-r--r--example/example_3_ibbTransferSource/main.cpp (renamed from example/example_3_ibbTransfer/main.cpp)4
-rw-r--r--example/example_4_ibbTransferTarget/README5
-rw-r--r--example/example_4_ibbTransferTarget/example_4_ibbTransferTarget.pro21
-rw-r--r--example/example_4_ibbTransferTarget/ibbTransferTarget.cpp59
-rw-r--r--example/example_4_ibbTransferTarget/ibbTransferTarget.h46
-rw-r--r--example/example_4_ibbTransferTarget/main.cpp39
11 files changed, 179 insertions, 8 deletions
diff --git a/example/example.pro b/example/example.pro
index 40dae002..365b12ff 100644
--- a/example/example.pro
+++ b/example/example.pro
@@ -3,5 +3,6 @@ TEMPLATE = subdirs
SUBDIRS = example_0_connected\
example_1_echoClient\
example_2_rosterHandling\
- example_3_ibbTransfer
+ example_3_ibbTransferSource\
+ example_4_ibbTransferTarget
diff --git a/example/example_3_ibbTransferSource/example_3_ibbTransfer.pro b/example/example_3_ibbTransferSource/example_3_ibbTransfer.pro
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/example/example_3_ibbTransferSource/example_3_ibbTransfer.pro
diff --git a/example/example_3_ibbTransfer/example_3_ibbTransfer.pro b/example/example_3_ibbTransferSource/example_3_ibbTransferSource.pro
index 82821cdc..0777c6c0 100644
--- a/example/example_3_ibbTransfer/example_3_ibbTransfer.pro
+++ b/example/example_3_ibbTransferSource/example_3_ibbTransferSource.pro
@@ -1,6 +1,6 @@
TEMPLATE = app
-TARGET = example_2_ibbTransfer
+TARGET = example_3_ibbTransferSource
SOURCES += main.cpp \
ibbClient.cpp
diff --git a/example/example_3_ibbTransfer/ibbClient.cpp b/example/example_3_ibbTransferSource/ibbClient.cpp
index b80a216d..bb13b87c 100644
--- a/example/example_3_ibbTransfer/ibbClient.cpp
+++ b/example/example_3_ibbTransferSource/ibbClient.cpp
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2008-2009 Manjeet Dahiya
+ * Copyright (C) 2008-2009 QXmpp Developers
*
* Author:
- * Manjeet Dahiya
+ * Ian Reinhart Geiser
*
* Source:
* http://code.google.com/p/qxmpp
diff --git a/example/example_3_ibbTransfer/ibbClient.h b/example/example_3_ibbTransferSource/ibbClient.h
index 2c75d942..0a674d05 100644
--- a/example/example_3_ibbTransfer/ibbClient.h
+++ b/example/example_3_ibbTransferSource/ibbClient.h
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2008-2009 Manjeet Dahiya
+ * Copyright (C) 2008-2009 QXmpp Developers
*
* Author:
- * Manjeet Dahiya
+ * Ian Reinhart Geiser
*
* Source:
* http://code.google.com/p/qxmpp
diff --git a/example/example_3_ibbTransfer/main.cpp b/example/example_3_ibbTransferSource/main.cpp
index 73474b95..b42dff1c 100644
--- a/example/example_3_ibbTransfer/main.cpp
+++ b/example/example_3_ibbTransferSource/main.cpp
@@ -1,8 +1,8 @@
/*
- * Copyright (C) 2008-2009 Manjeet Dahiya
+ * Copyright (C) 2008-2009 QXmpp Developers
*
* Author:
- * Manjeet Dahiya
+ * Ian Reinhart Geiser
*
* Source:
* http://code.google.com/p/qxmpp
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();
+}