From 07761742a5a104020c975f649bd188a950a4891c Mon Sep 17 00:00:00 2001 From: Manuel Traut Date: Tue, 18 Feb 2014 23:36:45 +0100 Subject: middleware/xmpp: add an example - this is a minimal qt client that can be used with a jabber/xmpp server - have a look at the README file for the test setup Signed-off-by: Manuel Traut --- frameworks/middleware/examples/xmpp/README | 28 +++++++++++++++++++++ frameworks/middleware/examples/xmpp/client.cpp | 24 ++++++++++++++++++ frameworks/middleware/examples/xmpp/myclient.cpp | 32 ++++++++++++++++++++++++ frameworks/middleware/examples/xmpp/myclient.h | 17 +++++++++++++ frameworks/middleware/examples/xmpp/xmpp.pro | 15 +++++++++++ 5 files changed, 116 insertions(+) create mode 100644 frameworks/middleware/examples/xmpp/README create mode 100644 frameworks/middleware/examples/xmpp/client.cpp create mode 100644 frameworks/middleware/examples/xmpp/myclient.cpp create mode 100644 frameworks/middleware/examples/xmpp/myclient.h create mode 100644 frameworks/middleware/examples/xmpp/xmpp.pro diff --git a/frameworks/middleware/examples/xmpp/README b/frameworks/middleware/examples/xmpp/README new file mode 100644 index 0000000..ef147ce --- /dev/null +++ b/frameworks/middleware/examples/xmpp/README @@ -0,0 +1,28 @@ +a) apt-get install libqxmpp-dev psi ejabberd + +b) edit /etc/ejabberd/ejabberd.cfg to allow inband registration: + + --8<--- + %% No username can be registered via in-band registration: + %% To enable in-band registration, replace 'deny' with 'allow' + % (note that if you remove mod_register from modules list then users will not + % be able to change their password as well as register). + % This setting is default because it's more safe. + {access, register, [{allow, all}]}. + --8<--- + +c) start psi and configure it to use 'localhost' as server and create two + accounts: : + qtapp:test + +d) login with and qtapp, add both accounts to their contact list, + and try to send messages. logoff the qtapp account. + +e) build the qt client application and start it: + +qmake +make +./client + +f) the qtapp account needs now to be online in psi, write a messagte to qtapp + the message should be displayed in the commandline diff --git a/frameworks/middleware/examples/xmpp/client.cpp b/frameworks/middleware/examples/xmpp/client.cpp new file mode 100644 index 0000000..9390438 --- /dev/null +++ b/frameworks/middleware/examples/xmpp/client.cpp @@ -0,0 +1,24 @@ +/* +* Copyright (C) 2008-2010 Manjeet Dahiya +* +* Author: +* Manjeet Dahiya +* modified 2014 by Manuel Traut +*/ + +#include + +//#include + +#include "myclient.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + // QXmppLogger::getLogger()->setLoggingType(QXmppLogger::StdoutLogging); + + MyClient client; + client.connectToServer("qtapp@localhost", "test"); + + return a.exec(); +} diff --git a/frameworks/middleware/examples/xmpp/myclient.cpp b/frameworks/middleware/examples/xmpp/myclient.cpp new file mode 100644 index 0000000..fa28603 --- /dev/null +++ b/frameworks/middleware/examples/xmpp/myclient.cpp @@ -0,0 +1,32 @@ +/* +* Copyright (C) 2008-2010 Manjeet Dahiya +* +* Author: +* Manjeet Dahiya +* +* modified 2014 by Manuel Traut +*/ + +#include +#include + +#include "myclient.h" + +MyClient::MyClient() : QXmppClient() +{ + bool check = connect(this, + SIGNAL(messageReceived(QXmppMessage)), + SLOT(message_rx(QXmppMessage))); + Q_ASSERT(check); + Q_UNUSED(check); +} + +MyClient::~MyClient() { ; } + +void MyClient::message_rx(const QXmppMessage& message) +{ + QString from = message.from(); + QString msg = message.body(); + std::cout< + +class MyClient : public QXmppClient +{ + Q_OBJECT +public: + MyClient(); + ~MyClient(); + +public slots: + void message_rx(const QXmppMessage&); +}; + +#endif diff --git a/frameworks/middleware/examples/xmpp/xmpp.pro b/frameworks/middleware/examples/xmpp/xmpp.pro new file mode 100644 index 0000000..7f0be00 --- /dev/null +++ b/frameworks/middleware/examples/xmpp/xmpp.pro @@ -0,0 +1,15 @@ +###################################################################### +# Automatically generated by qmake (2.01a) Tue Feb 18 19:47:09 2014 +###################################################################### + +TEMPLATE = app +TARGET = client +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += client.cpp myclient.cpp +HEADERS += myclient.h + +QT += network +LIBS += -lqxmpp -- cgit v1.2.3