aboutsummaryrefslogtreecommitdiff
path: root/examples/example_8_server
diff options
context:
space:
mode:
authorJeremy Lainé <jeremy.laine@m4x.org>2010-08-23 13:48:08 +0000
committerJeremy Lainé <jeremy.laine@m4x.org>2010-08-23 13:48:08 +0000
commit0c1166055f618f150e9489c1fa21ea564702b72e (patch)
tree565b35f7a28445d4056c55460468b7065d087559 /examples/example_8_server
parentae6b93fc56d8084fb5a0dfea62d540003cfc97d9 (diff)
downloadqxmpp-0c1166055f618f150e9489c1fa21ea564702b72e.tar.gz
improve server example
Diffstat (limited to 'examples/example_8_server')
-rw-r--r--examples/example_8_server/example_8_server.pro5
-rw-r--r--examples/example_8_server/main.cpp36
-rw-r--r--examples/example_8_server/xmppServer.cpp29
-rw-r--r--examples/example_8_server/xmppServer.h31
4 files changed, 35 insertions, 66 deletions
diff --git a/examples/example_8_server/example_8_server.pro b/examples/example_8_server/example_8_server.pro
index b3a84029..d8013ef5 100644
--- a/examples/example_8_server/example_8_server.pro
+++ b/examples/example_8_server/example_8_server.pro
@@ -2,7 +2,4 @@ include(../examples.pri)
TARGET = example_8_server
-SOURCES += main.cpp \
- xmppServer.cpp
-
-HEADERS += xmppServer.h
+SOURCES += main.cpp
diff --git a/examples/example_8_server/main.cpp b/examples/example_8_server/main.cpp
index ad826007..46a7a279 100644
--- a/examples/example_8_server/main.cpp
+++ b/examples/example_8_server/main.cpp
@@ -24,14 +24,46 @@
#include <QtCore/QCoreApplication>
#include "QXmppLogger.h"
-#include "xmppServer.h"
+#include "QXmppIncomingClient.h"
+#include "QXmppServer.h"
+
+#define USERNAME "qxmpp.test1"
+#define PASSWORD "qxmpp123"
+
+class passwordChecker : public QXmppPasswordChecker
+{
+ /// Checks that the given credentials are valid.
+ bool check(const QString &username, const QString &password)
+ {
+ return (username == USERNAME && password == PASSWORD);
+ };
+
+ /// Retrieves the password for the given username.
+ bool get(const QString &username, QString &password)
+ {
+ if (username == USERNAME)
+ {
+ password = PASSWORD;
+ return true;
+ } else {
+ return false;
+ }
+ };
+};
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
+
+ QXmppLogger logger;
+ logger.setLoggingType(QXmppLogger::StdoutLogging);
- xmppServer server;
+ passwordChecker checker;
+
+ QXmppServer server;
server.setDomain("example.com");
+ server.setLogger(&logger);
+ server.setPasswordChecker(&checker);
server.listenForClients();
return a.exec();
}
diff --git a/examples/example_8_server/xmppServer.cpp b/examples/example_8_server/xmppServer.cpp
deleted file mode 100644
index 3d594673..00000000
--- a/examples/example_8_server/xmppServer.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2008-2010 The QXmpp developers
- *
- * Author:
- * 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 "xmppServer.h"
-
-void xmppServer::handleStanza(QXmppStream*, const QDomElement&)
-{
-}
-
diff --git a/examples/example_8_server/xmppServer.h b/examples/example_8_server/xmppServer.h
deleted file mode 100644
index 4da66b81..00000000
--- a/examples/example_8_server/xmppServer.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2008-2010 The QXmpp developers
- *
- * Author:
- * 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 "QXmppServer.h"
-
-class xmppServer : public QXmppServer
-{
-private:
- void handleStanza(QXmppStream*, const QDomElement&);
-};
-