diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-14 14:36:59 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-09-14 14:36:59 +0200 |
| commit | 575a9d9d860f5417b0173ff6dc3ed41cfef0bbaf (patch) | |
| tree | 489d79c60a144af79b2927ac14755b7473b7fbaa /examples/example_4_callHandling | |
| parent | 425cb7d2ec6a92cbb5d67d7fb9e1fdae918bc267 (diff) | |
| download | qxmpp-575a9d9d860f5417b0173ff6dc3ed41cfef0bbaf.tar.gz | |
fix example
Diffstat (limited to 'examples/example_4_callHandling')
| -rw-r--r-- | examples/example_4_callHandling/example_4_callHandling.cpp (renamed from examples/example_4_callHandling/xmppClient.cpp) | 41 | ||||
| -rw-r--r-- | examples/example_4_callHandling/example_4_callHandling.h (renamed from examples/example_4_callHandling/xmppClient.h) | 2 | ||||
| -rw-r--r-- | examples/example_4_callHandling/example_4_callHandling.pro | 5 | ||||
| -rw-r--r-- | examples/example_4_callHandling/main.cpp | 49 |
4 files changed, 39 insertions, 58 deletions
diff --git a/examples/example_4_callHandling/xmppClient.cpp b/examples/example_4_callHandling/example_4_callHandling.cpp index b49024ba..b73c9caa 100644 --- a/examples/example_4_callHandling/xmppClient.cpp +++ b/examples/example_4_callHandling/example_4_callHandling.cpp @@ -22,8 +22,12 @@ * */ +#include <cstdlib> +#include <cstdio> + #include <QAudioInput> #include <QAudioOutput> +#include <QCoreApplication> #include <QDebug> #include "QXmppCallManager.h" @@ -31,7 +35,7 @@ #include "QXmppRtpChannel.h" #include "QXmppUtils.h" -#include "xmppClient.h" +#include "example_4_callHandling.h" xmppClient::xmppClient(QObject *parent) : QXmppClient(parent) @@ -49,6 +53,11 @@ xmppClient::xmppClient(QObject *parent) Q_ASSERT(check); } +void xmppClient::setRecipient(const QString &recipient) +{ + m_recipient = recipient; +} + /// The audio mode of a call changed. void xmppClient::slotAudioModeChanged(QIODevice::OpenMode mode) @@ -121,12 +130,10 @@ void xmppClient::slotCallStateChanged(QXmppCall::State state) void xmppClient::slotPresenceReceived(const QXmppPresence &presence) { - const QLatin1String recipient("qxmpp.test2@gmail.com"); - - // if we are the recipient, or if the presence is not from the recipient, + // if we don't have a recipient, or if the presence is not from the recipient, // do nothing - if (jidToBareJid(configuration().jid()) == recipient || - jidToBareJid(presence.from()) != recipient || + if (m_recipient.isEmpty() || + QXmppUtils::jidToBareJid(presence.from()) != m_recipient || presence.type() != QXmppPresence::Available) return; @@ -143,3 +150,25 @@ void xmppClient::slotPresenceReceived(const QXmppPresence &presence) Q_ASSERT(check); } +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + // we want one argument : "send" or "receive" + if (argc != 2 || (strcmp(argv[1], "send") && strcmp(argv[1], "receive"))) + { + fprintf(stderr, "Usage: %s send|receive\n", argv[0]); + return EXIT_FAILURE; + } + + xmppClient client; + client.logger()->setLoggingType(QXmppLogger::StdoutLogging); + if (!strcmp(argv[1], "send")) { + client.setRecipient("qxmpp.test2@qxmpp.org"); + client.connectToServer("qxmpp.test1@qxmpp.org", "qxmpp123"); + } else { + client.connectToServer("qxmpp.test2@qxmpp.org", "qxmpp456"); + } + + return a.exec(); +} diff --git a/examples/example_4_callHandling/xmppClient.h b/examples/example_4_callHandling/example_4_callHandling.h index b65816c4..788d932c 100644 --- a/examples/example_4_callHandling/xmppClient.h +++ b/examples/example_4_callHandling/example_4_callHandling.h @@ -34,6 +34,7 @@ class xmppClient : public QXmppClient public: xmppClient(QObject *parent = 0); + void setRecipient(const QString &recipient); private slots: void slotAudioModeChanged(QIODevice::OpenMode mode); @@ -43,6 +44,7 @@ private slots: private: QXmppCallManager *callManager; + QString m_recipient; }; #endif // IBBCLIENT_H diff --git a/examples/example_4_callHandling/example_4_callHandling.pro b/examples/example_4_callHandling/example_4_callHandling.pro index 1da3b529..039455ef 100644 --- a/examples/example_4_callHandling/example_4_callHandling.pro +++ b/examples/example_4_callHandling/example_4_callHandling.pro @@ -5,10 +5,9 @@ MOBILITY += multimedia TARGET = example_4_callHandling -SOURCES += main.cpp \ - xmppClient.cpp +SOURCES += example_4_callHandling.cpp -HEADERS += xmppClient.h +HEADERS += example_4_callHandling.h # Symbian packaging rules symbian { diff --git a/examples/example_4_callHandling/main.cpp b/examples/example_4_callHandling/main.cpp deleted file mode 100644 index d1e4bfa5..00000000 --- a/examples/example_4_callHandling/main.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2008-2012 The 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 <cstdlib> -#include <cstdio> - -#include <QCoreApplication> - -#include "QXmppLogger.h" -#include "xmppClient.h" - -int main(int argc, char *argv[]) -{ - QCoreApplication a(argc, argv); - - QXmppLogger::getLogger()->setLoggingType(QXmppLogger::StdoutLogging); - - // we want one argument : "send" or "receive" - if (argc != 2 || (strcmp(argv[1], "send") && strcmp(argv[1], "receive"))) - { - fprintf(stderr, "Usage: callClient send|receive\n"); - return EXIT_FAILURE; - } - const QString username = (!strcmp(argv[1], "send")) ? QLatin1String("qxmpp.test1") : QLatin1String("qxmpp.test2"); - - xmppClient client; - client.connectToServer(username + "@gmail.com", "qxmpp123"); - return a.exec(); -} |
