summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Zanetti <michael.zanetti@nokia.com>2011-12-09 15:27:12 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-23 15:57:18 +0100
commitebd7a5d2935b5ab9dd7910dfb104a9e0c0819677 (patch)
tree2bc160feb75abdf72d29591efe301c55ba9b3132
parentf54bd71301325f7e5681be49d81823986f5cbfcd (diff)
added documentation and examples
Change-Id: Ia99e5f8f9579c189379bce1a22de3d58b12ce5fc Reviewed-by: Alex <alex.blasche@nokia.com> Sanity-Review: Alex <alex.blasche@nokia.com>
-rw-r--r--.gitignore1
-rw-r--r--demos/bttennis/board.cpp250
-rw-r--r--demos/bttennis/board.h126
-rw-r--r--demos/bttennis/bttennis.pro36
-rw-r--r--demos/bttennis/connect.pngbin0 -> 11074 bytes
-rw-r--r--demos/bttennis/controller.cpp263
-rw-r--r--demos/bttennis/controller.h100
-rw-r--r--demos/bttennis/handover.cpp130
-rw-r--r--demos/bttennis/handover.h94
-rw-r--r--demos/bttennis/main.cpp63
-rw-r--r--demos/bttennis/tennis.cpp424
-rw-r--r--demos/bttennis/tennis.h140
-rw-r--r--demos/bttennis/tennis.qrc5
-rw-r--r--demos/bttennis/tennis.ui57
-rw-r--r--demos/bttennis/tennisclient.cpp200
-rw-r--r--demos/bttennis/tennisclient.h102
-rw-r--r--demos/bttennis/tennisserver.cpp306
-rw-r--r--demos/bttennis/tennisserver.h106
-rw-r--r--demos/bttennis/tennisview.cpp69
-rw-r--r--demos/bttennis/tennisview.h69
-rw-r--r--doc/compat.qdocconf31
-rw-r--r--doc/doc.pri14
-rw-r--r--doc/macros.qdocconf43
-rw-r--r--doc/qt-cpp-ignore.qdocconf106
-rw-r--r--doc/qt-defines.qdocconf18
-rw-r--r--doc/qt5-dita.qdocconf22
-rw-r--r--doc/qt5.qdocconf76
-rw-r--r--doc/src/connectivity.qdoc89
-rw-r--r--doc/src/examples.qdoc81
-rw-r--r--doc/src/examples/annotatedurl.qdoc37
-rw-r--r--doc/src/examples/bluetoothtransferplugin.qdoc46
-rw-r--r--doc/src/examples/btchat.qdoc191
-rw-r--r--doc/src/examples/btfiletransfer.qdoc37
-rw-r--r--doc/src/examples/btscanner.qdoc36
-rw-r--r--doc/src/examples/bttennis.qdoc37
-rw-r--r--doc/src/examples/ndefeditor.qdoc36
-rw-r--r--doc/src/examples/poster.qdoc38
-rw-r--r--doc/src/images/annotatedurl.pngbin0 -> 34341 bytes
-rw-r--r--doc/src/images/btchat-example.pngbin0 -> 6527 bytes
-rw-r--r--doc/src/images/btfiletransfer-example.pngbin0 -> 44606 bytes
-rw-r--r--doc/src/images/btscanner-example.pngbin0 -> 76746 bytes
-rw-r--r--doc/src/images/bttennis-example.pngbin0 -> 4890 bytes
-rw-r--r--doc/src/images/ndefeditor.pngbin0 -> 24500 bytes
-rw-r--r--doc/src/images/qml-poster-example.pngbin0 -> 54257 bytes
-rw-r--r--doc/src/index.qdoc41
-rw-r--r--doc/src/snippets/connectivity.pro21
-rw-r--r--doc/src/snippets/devicediscovery.cpp77
-rw-r--r--doc/src/snippets/foorecord.cpp115
-rw-r--r--doc/src/snippets/foorecord.h69
-rw-r--r--doc/src/snippets/main.cpp46
-rw-r--r--doc/src/snippets/nfc.cpp74
-rw-r--r--doc/src/snippets/servicediscovery.cpp78
-rw-r--r--doc/style/style.css137
-rw-r--r--examples/annotatedurl/annotatedurl.cpp119
-rw-r--r--examples/annotatedurl/annotatedurl.h73
-rw-r--r--examples/annotatedurl/annotatedurl.pro18
-rw-r--r--examples/annotatedurl/main.cpp80
-rw-r--r--examples/annotatedurl/mainwindow.cpp72
-rw-r--r--examples/annotatedurl/mainwindow.h70
-rw-r--r--examples/annotatedurl/mainwindow.ui61
-rw-r--r--examples/bluetoothtransferplugin/bluetoothtransfer.cpp55
-rw-r--r--examples/bluetoothtransferplugin/bluetoothtransfer.h57
-rw-r--r--examples/bluetoothtransferplugin/bluetoothtransferplugin.cpp54
-rw-r--r--examples/bluetoothtransferplugin/bluetoothtransferplugin.h57
-rw-r--r--examples/bluetoothtransferplugin/bluetoothtransferplugin.pro16
-rw-r--r--examples/bluetoothtransferplugin/bluetoothtransferservice.xml13
-rw-r--r--examples/btchat/btchat.pro27
-rw-r--r--examples/btchat/chat.cpp179
-rw-r--r--examples/btchat/chat.h90
-rw-r--r--examples/btchat/chat.ui76
-rw-r--r--examples/btchat/chatclient.cpp108
-rw-r--r--examples/btchat/chatclient.h83
-rw-r--r--examples/btchat/chatserver.cpp182
-rw-r--r--examples/btchat/chatserver.h88
-rw-r--r--examples/btchat/main.cpp62
-rw-r--r--examples/btchat/remoteselector.cpp146
-rw-r--r--examples/btchat/remoteselector.h85
-rw-r--r--examples/btchat/remoteselector.ui38
-rw-r--r--examples/btfiletransfer/btfiletransfer.pro34
-rw-r--r--examples/btfiletransfer/btfiletransfer.qrc6
-rw-r--r--examples/btfiletransfer/busy.gifbin0 -> 847 bytes
-rw-r--r--examples/btfiletransfer/main.cpp62
-rw-r--r--examples/btfiletransfer/pairing.gifbin0 -> 3951 bytes
-rw-r--r--examples/btfiletransfer/pindisplay.cpp69
-rw-r--r--examples/btfiletransfer/pindisplay.h67
-rw-r--r--examples/btfiletransfer/pindisplay.ui89
-rw-r--r--examples/btfiletransfer/progress.cpp97
-rw-r--r--examples/btfiletransfer/progress.h78
-rw-r--r--examples/btfiletransfer/progress.ui55
-rw-r--r--examples/btfiletransfer/remoteselector.cpp372
-rw-r--r--examples/btfiletransfer/remoteselector.h108
-rw-r--r--examples/btfiletransfer/remoteselector.ui214
-rw-r--r--examples/btscanner/btscanner.pro21
-rw-r--r--examples/btscanner/device.cpp211
-rw-r--r--examples/btscanner/device.h85
-rw-r--r--examples/btscanner/device.ui121
-rw-r--r--examples/btscanner/main.cpp57
-rw-r--r--examples/btscanner/service.cpp87
-rw-r--r--examples/btscanner/service.h74
-rw-r--r--examples/btscanner/service.ui76
-rw-r--r--examples/ndefeditor/main.cpp56
-rw-r--r--examples/ndefeditor/mainwindow.cpp361
-rw-r--r--examples/ndefeditor/mainwindow.h107
-rw-r--r--examples/ndefeditor/mainwindow.ui225
-rw-r--r--examples/ndefeditor/mimeimagerecordeditor.cpp139
-rw-r--r--examples/ndefeditor/mimeimagerecordeditor.h76
-rw-r--r--examples/ndefeditor/mimeimagerecordeditor.ui83
-rw-r--r--examples/ndefeditor/ndefeditor.pro28
-rw-r--r--examples/ndefeditor/textrecord.ui21
-rw-r--r--examples/ndefeditor/textrecordeditor.cpp83
-rw-r--r--examples/ndefeditor/textrecordeditor.h69
-rw-r--r--examples/ndefeditor/textrecordeditor.ui101
-rw-r--r--examples/ndefeditor/urirecordeditor.cpp70
-rw-r--r--examples/ndefeditor/urirecordeditor.h70
-rw-r--r--examples/ndefeditor/urirecordeditor.ui45
-rw-r--r--examples/poster/poster.pro13
-rw-r--r--examples/poster/poster.qml186
-rw-r--r--examples/poster/poster.qrc6
-rw-r--r--examples/poster/qmlposter.cpp62
-rw-r--r--examples/scanner/qmlscanner.cpp64
-rw-r--r--examples/scanner/scanner.pro11
-rw-r--r--examples/scanner/scanner.qml251
-rw-r--r--examples/scanner/scanner.qrc5
-rw-r--r--qtconnectivity.pro2
-rw-r--r--src/bluetooth/qbluetooth.cpp3
-rw-r--r--src/bluetooth/qbluetoothaddress.cpp3
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent.cpp5
-rw-r--r--src/bluetooth/qbluetoothdeviceinfo.cpp3
-rw-r--r--src/bluetooth/qbluetoothglobal.h2
-rw-r--r--src/bluetooth/qbluetoothlocaldevice.cpp3
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent.cpp5
-rw-r--r--src/bluetooth/qbluetoothserviceinfo.cpp7
-rw-r--r--src/bluetooth/qbluetoothsocket.cpp3
-rw-r--r--src/bluetooth/qbluetoothtransfermanager.cpp3
-rw-r--r--src/bluetooth/qbluetoothtransferreply.cpp9
-rw-r--r--src/bluetooth/qbluetoothtransferrequest.cpp3
-rw-r--r--src/bluetooth/qbluetoothuuid.cpp5
-rw-r--r--src/bluetooth/ql2capserver.cpp3
-rw-r--r--src/bluetooth/qrfcommserver.cpp3
-rw-r--r--src/bluetooth/symbian/bluetoothlinkmanagerdevicediscoverer.cpp3
-rw-r--r--src/bluetooth/symbian/bluetoothsymbianpairingadapter.cpp2
-rw-r--r--src/bluetooth/symbian/bluetoothsymbianregistryadapter.cpp2
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp6
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothservice.cpp8
-rw-r--r--src/imports/bluetooth/qdeclarativebluetoothsocket.cpp6
-rw-r--r--src/imports/nfc/qdeclarativendeffilter.cpp6
-rw-r--r--src/imports/nfc/qdeclarativendefmimerecord.cpp4
-rw-r--r--src/imports/nfc/qdeclarativendeftextrecord.cpp6
-rw-r--r--src/imports/nfc/qdeclarativendefurirecord.cpp6
-rw-r--r--src/imports/nfc/qdeclarativenearfield.cpp6
-rw-r--r--src/imports/nfc/qdeclarativenearfieldsocket.cpp6
-rw-r--r--src/nfc/qdeclarativendefrecord.cpp11
-rw-r--r--src/nfc/qllcpserver.cpp6
-rw-r--r--src/nfc/qllcpsocket.cpp3
-rw-r--r--src/nfc/qndeffilter.cpp3
-rw-r--r--src/nfc/qndefmessage.cpp3
-rw-r--r--src/nfc/qndefnfctextrecord.cpp3
-rw-r--r--src/nfc/qndefnfcurirecord.cpp3
-rw-r--r--src/nfc/qndefrecord.cpp7
-rw-r--r--src/nfc/qnearfieldmanager.cpp106
-rw-r--r--src/nfc/qnearfieldmanager_symbian.cpp2
-rw-r--r--src/nfc/qnearfieldtagtype1.cpp3
-rw-r--r--src/nfc/qnearfieldtagtype1_symbian.cpp2
-rw-r--r--src/nfc/qnearfieldtagtype2.cpp3
-rw-r--r--src/nfc/qnearfieldtagtype3.cpp3
-rw-r--r--src/nfc/qnearfieldtagtype4.cpp3
-rw-r--r--src/nfc/qnearfieldtarget.cpp3
-rw-r--r--src/nfc/qnfcglobal.h2
-rw-r--r--src/nfc/symbian/nearfieldmanager_symbian.cpp3
-rw-r--r--src/nfc/symbian/nearfieldtag_symbian.cpp3
-rw-r--r--src/nfc/symbian/nearfieldtargetfactory_symbian.cpp3
-rw-r--r--tests/btclient/btclient.c4
172 files changed, 10248 insertions, 215 deletions
diff --git a/.gitignore b/.gitignore
index a776b863..0adc89fc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@
*.pro.shared
qtbluetoothversion.h
qtnfcversion.h
+*~
diff --git a/demos/bttennis/board.cpp b/demos/bttennis/board.cpp
new file mode 100644
index 00000000..81128657
--- /dev/null
+++ b/demos/bttennis/board.cpp
@@ -0,0 +1,250 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "board.h"
+
+#include <QGraphicsItem>
+#include <QGraphicsScene>
+#include <QDebug>
+#include <QTextDocument>
+#include <QFontMetrics>
+#include <QPropertyAnimation>
+
+const QColor fg = Qt::white;
+const QColor bg = Qt::black;
+
+Board::Board(QWidget *parent) :
+ QGraphicsView(parent)
+{
+ scene = new QGraphicsScene(QRect(0, 0, 640, 360), this);
+
+ scene->setBackgroundBrush(QBrush(bg));
+
+ ball = scene->addRect(-6, -6, 12, 12, QPen(Qt::SolidLine), QBrush(fg));
+ ball->setPos(Width/2-6, Height/2-6);
+
+ // why is y -1...otherwise we have a gap...
+ topWall = scene->addRect(0, -1, Width, 12, QPen(Qt::SolidLine), QBrush(fg));
+ bottomWall = scene->addRect(0, Height-12, Width, 12, QPen(Qt::SolidLine), QBrush(fg));
+
+ leftPaddle = scene->addRect(0, 12, 12, Paddle, QPen(Qt::SolidLine), QBrush(fg));
+ rightPaddle = scene->addRect(Width-12, 12, 12, Paddle, QPen(Qt::SolidLine), QBrush(fg));
+
+ QPen p;
+ p.setWidth(2);
+ p.setStyle(Qt::DotLine);
+ p.setBrush(QBrush(fg));
+ scene->addLine(Width/2, 0, Width/2, Height, p);
+
+ QFont f;
+ f.setStyleHint(QFont::OldEnglish);
+ f.setPixelSize(50);
+ f.setBold(true);
+ leftScore = scene->addText(QString("0"), f);
+ leftScore->setDefaultTextColor(fg);
+// leftScore->setPos(120, 50);
+
+ rightScore = scene->addText(QString("0"), f);
+// rightScore->setPos(Width-140, 50);
+ rightScore->setDefaultTextColor(fg);
+ setScore(0, 0);
+
+ f.setPixelSize(25);
+ status = scene->addText(QString(), f);
+ status->setDefaultTextColor(fg);
+
+ ball->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ leftPaddle->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+ rightPaddle->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+
+ icon.load(QString(":/icons/connect.png"));
+ icon = icon.scaled(100, 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
+ qDebug() << "icon" << icon.isNull();
+ connectIcon = scene->addPixmap(icon);
+ connectIcon->setPos(440,200);
+ connectIcon->setAcceptTouchEvents(true);
+ connectIcon->setTransformOriginPoint(50,50);
+ connectIcon->setTransformationMode(Qt::SmoothTransformation);
+
+ connectAnimation = new QPropertyAnimation(this, "connectRotation");
+ connectAnimation->setDuration(1000);
+ connectAnimation->setLoopCount(-1);
+ connectAnimation->setStartValue(0);
+ connectAnimation->setEndValue(360);
+
+ setCacheMode(QGraphicsView::CacheBackground);
+ setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
+
+// connect(scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(sceneChanged(QList<QRectF>)));
+
+}
+void Board::setBall(int x, int y)
+{
+ ball->setPos(x, y);
+ checkBall(x, y);
+}
+
+void Board::setLeftPaddle(int y)
+{
+ leftPaddle->setPos(0, y);
+}
+
+void Board::setRightPaddle(int y)
+{
+ rightPaddle->setPos(0, y);
+}
+
+void Board::sceneChanged(const QList<QRectF> &region)
+{
+ Q_UNUSED(region);
+
+ QList<QGraphicsItem *>items = scene->collidingItems(ball);
+ while (!items.empty()) {
+ QGraphicsItem *i = items.takeFirst();
+ if (i == topWall)
+ emit ballCollision(Top);
+ if (i == bottomWall)
+ emit ballCollision(Bottom);
+ if (i == leftPaddle)
+ emit ballCollision(Left);
+ if (i == rightPaddle)
+ emit ballCollision(Right);
+ }
+
+}
+
+void Board::checkBall(int x, int y)
+{
+ int ly = leftPaddle->y();
+ int ry = rightPaddle->y();
+
+ if (x > 646)
+ emit scored(Right);
+ else if (x < -6)
+ emit scored(Left);
+
+ if (y < 18)
+ emit ballCollision(Top);
+ else if (y > 360-18)
+ emit ballCollision(Bottom);
+
+ if ((x < 18) &&
+ (y > ly-6) &&
+ (y < ly+Paddle+6))
+ emit ballCollision(Left);
+
+ if ((x > 640-18) &&
+ (y > ry-6) &&
+ (y < ry+Paddle+6))
+ emit ballCollision(Right);
+}
+
+void Board::setScore(int l, int r)
+{
+ QString left = QString("%1").arg(l);
+ QString right = QString("%1").arg(r);
+ leftScore->document()->setPlainText(left);
+ rightScore->document()->setPlainText(right);
+ QFontMetrics fm(leftScore->font());
+ leftScore->setPos(Width/4 - fm.width(left)/2, 50);
+ rightScore->setPos(3*Width/4 - fm.width(right)/2, 50);
+
+}
+
+void Board::setStatus(QString text, int opacity_start, int opacity_end)
+{
+
+ status->document()->setPlainText(text);
+ status->setPos(24, Height-25-25);
+ QPropertyAnimation *a = new QPropertyAnimation(status, "opacity");
+ a->setDuration(2000);
+ a->setStartValue(opacity_start/100.0);
+ a->setEndValue(opacity_end/100.0);
+ a->start(QAbstractAnimation::DeleteWhenStopped);
+}
+
+void Board::setConnectRotation(int rot)
+{
+ connectIcon->setRotation(rot);
+// QTransform t;
+// t.rotate(rot);
+// connectIcon->setPixmap(icon.scaled(100, 100).transformed(t, Qt::SmoothTransformation));
+}
+
+void Board::setConnectOpacity(qreal op)
+{
+ connectIcon->setOpacity(op);
+}
+
+void Board::animateConnect(bool start)
+{
+ if (start) {
+ connectAnimation->start();
+ }
+ else {
+ connectAnimation->stop();
+ QPropertyAnimation *a = new QPropertyAnimation(this, "connectRotation");
+// qDebug() << "currentTime" << connectAnimation->currentLoopTime() << "rotation" << connectAnimation->currentValue();
+ a->setDuration(connectAnimation->currentLoopTime()/2);
+ a->setStartValue(connectAnimation->currentValue().toInt( ));
+ a->setEndValue(0);
+// a->setDirection(QAbstractAnimation::Backward);
+ a->start(QAbstractAnimation::DeleteWhenStopped);
+ }
+}
+
+
+void Board::fadeConnect(bool out)
+{
+ qreal start = 100.0;
+ qreal end = 0.0;
+
+ if (!out) {
+ start = 0.0;
+ end = 100.0;
+ }
+
+ QPropertyAnimation *a = new QPropertyAnimation(this, "connectOpacity");
+ a->setDuration(2000);
+ a->setStartValue(start);
+ a->setEndValue(end);
+ a->start(QAbstractAnimation::DeleteWhenStopped);
+}
diff --git a/demos/bttennis/board.h b/demos/bttennis/board.h
new file mode 100644
index 00000000..d6baa765
--- /dev/null
+++ b/demos/bttennis/board.h
@@ -0,0 +1,126 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BOARD_H
+#define BOARD_H
+
+#include <QObject>
+#include <QGraphicsScene>
+#include <QGraphicsView>
+#include <QGraphicsPixmapItem>
+#include <QPixmap>
+#include <QPropertyAnimation>
+
+class Board : public QGraphicsView
+{
+ Q_OBJECT
+ Q_PROPERTY(int connectRotation READ connectRotation WRITE setConnectRotation)
+ Q_PROPERTY(qreal connectOpacity READ connectOpacity WRITE setConnectOpacity)
+public:
+ explicit Board(QWidget *parent = 0);
+
+ enum Edge {
+ Top = 1,
+ Bottom,
+ Left,
+ Right
+ };
+
+ enum BoardSize {
+ Width = 640,
+ Height = 360,
+ Paddle = 50
+ };
+
+
+ QGraphicsScene *getScene() {
+ return scene;
+ }
+
+ int connectRotation(){
+ return connectIcon->rotation();
+ }
+
+ qreal connectOpacity(){
+ return connectIcon->opacity();
+ }
+
+ void setConnectRotation(int rot);
+ void setConnectOpacity(qreal op);
+
+signals:
+ void ballCollision(Board::Edge pos);
+ void scored(Board::Edge pos);
+
+public slots:
+ void setBall(int x, int y);
+ void setLeftPaddle(int y);
+ void setRightPaddle(int y);
+ void setScore(int l, int r);
+
+ void setStatus(QString text, int opacity_start, int opacity_end);
+
+ void sceneChanged(const QList<QRectF> &region);
+
+ void animateConnect(bool start = true);
+ void fadeConnect(bool out = true);
+
+private:
+ QGraphicsScene *scene;
+ QGraphicsRectItem *ball;
+ QGraphicsRectItem *topWall;
+ QGraphicsRectItem *bottomWall;
+ QGraphicsRectItem *leftPaddle;
+ QGraphicsRectItem *rightPaddle;
+
+ QGraphicsTextItem *leftScore;
+ QGraphicsTextItem *rightScore;
+
+ QGraphicsTextItem *status;
+
+ QPixmap icon;
+ QGraphicsPixmapItem *connectIcon;
+ QPropertyAnimation *connectAnimation;
+
+ void checkBall(int x, int y);
+};
+
+#endif // BOARD_H
diff --git a/demos/bttennis/bttennis.pro b/demos/bttennis/bttennis.pro
new file mode 100644
index 00000000..0532a029
--- /dev/null
+++ b/demos/bttennis/bttennis.pro
@@ -0,0 +1,36 @@
+TARGET = bttennis
+
+INCLUDEPATH += \
+ ../../src/connectivity/bluetooth \
+ ../../src/connectivity/nfc
+
+DEPENDPATH += \
+ ../../src/connectivity/bluetooth \
+ ../../src/connectivity/nfc
+
+QT += bluetooth nfc widgets
+
+SOURCES = \
+ main.cpp \
+ board.cpp \
+ tennis.cpp \
+ controller.cpp \
+ tennisserver.cpp \
+ tennisclient.cpp \
+ tennisview.cpp \
+ handover.cpp
+
+HEADERS = \
+ board.h \
+ tennis.h \
+ controller.h \
+ tennisserver.h \
+ tennisclient.h \
+ tennisview.h \
+ handover.h
+
+FORMS = \
+ tennis.ui
+
+RESOURCES += \
+ tennis.qrc
diff --git a/demos/bttennis/connect.png b/demos/bttennis/connect.png
new file mode 100644
index 00000000..70b64c6c
--- /dev/null
+++ b/demos/bttennis/connect.png
Binary files differ
diff --git a/demos/bttennis/controller.cpp b/demos/bttennis/controller.cpp
new file mode 100644
index 00000000..954470ff
--- /dev/null
+++ b/demos/bttennis/controller.cpp
@@ -0,0 +1,263 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "controller.h"
+
+#include <QDateTime>
+#include <QDebug>
+
+#define FRAME_RATE 60
+
+Controller::Controller(QObject *parent) :
+ QObject(parent), timer(new QTimer), elapsed(new QTime), score_left(0), score_right(0),
+ col_x(0), col_y(0),
+ rightPaddleForce(0), leftPaddleForce(0),
+ rightPaddleLast(0), leftPaddleLast(0),
+ rightPowerUp(0), leftPowerUp(0)
+{
+
+ qsrand(QDateTime::currentDateTime().time().msec());
+
+
+ timer->setInterval(1000/FRAME_RATE);
+// timer->setInterval(0);
+ connect(timer, SIGNAL(timeout()), SLOT(tick()));
+ srand(QDateTime::currentDateTime().time().msec());
+
+ fpscntr = new QTime;
+ frames = 0;
+
+ timer->start();
+ restart_ball();
+}
+
+void Controller::tick()
+{
+ if (col_x)
+ col_x--;
+ if (col_y)
+ col_y--;
+
+// frames++;
+// if (fpscntr->elapsed() > 1000){
+// int f = frames/(fpscntr->elapsed()/1000.0);
+// emit fps(QString("FPS %1").arg(f));
+// frames = 0;
+// fpscntr->restart();
+// }
+
+ int msec = elapsed->elapsed();
+ elapsed->restart();
+
+ ball_x += speed_x*msec/1000;
+ ball_y += speed_y*msec/1000;
+
+
+ const int decay = 5;
+
+ if (leftPaddleForce > decay)
+ leftPaddleForce-=decay;
+ else if (leftPaddleForce < -decay)
+ leftPaddleForce+=decay;
+ if (rightPaddleForce > decay)
+ rightPaddleForce-=decay;
+ else if (rightPaddleForce < -decay)
+ rightPaddleForce+=decay;
+
+ if (rightPaddleForce <= decay)
+ rightPowerUp++;
+
+ if (leftPaddleForce <= decay)
+ leftPowerUp++;
+
+
+// ttf++;
+// if (msec > 1000/FRAME_RATE+2 || msec < 1000/FRAME_RATE-2)
+// dev++;
+
+// if (!(i++%120)) {
+// qDebug() << "powerUp: " << leftPowerUp << rightPowerUp << leftPaddleForce << rightPaddleForce << speed_x*msec/1000 << speed_y*msec/1000 << msec << dev;
+// ttf = dev =0;
+// }
+
+ emit moveBall(ball_x, ball_y);
+}
+
+
+static inline int paddle_boost(int force){
+ if (force > 30)
+ return -3*FRAME_RATE;
+ else if (force > 20)
+ return -2*FRAME_RATE;
+ else if (force > 6)
+ return -1*FRAME_RATE;
+ else if (force < -30)
+ return 3*FRAME_RATE;
+ else if (force < -20)
+ return 2*FRAME_RATE;
+ else if (force < -6)
+ return 1*FRAME_RATE;
+ return 0;
+}
+
+void Controller::ballCollision(Board::Edge pos)
+{
+
+ if ((pos == Board::Top || pos == Board::Bottom) && !col_y) {
+ speed_y *= -1;
+ col_y = 10;
+ }
+
+ if (pos == Board::Left && !col_x) {
+ speed_x *= -1;
+ speed_y += paddle_boost(leftPaddleForce);
+ col_x = 10;
+
+ if (leftPowerUp > 75 && speed_x < 8*FRAME_RATE){
+ speed_x *= 2;
+ leftPowerUp = 0;
+ }
+ }
+ else if (pos == Board::Right && !col_x) {
+ speed_x *= -1;
+ speed_y += paddle_boost(rightPaddleForce);
+ col_x = 10;
+
+ if (rightPowerUp > 75 && speed_x > -8*FRAME_RATE){
+ speed_x *= 2;
+ rightPowerUp = 0;
+ }
+
+ }
+// tick();
+// QMetaObject::invokeMethod(this, "moveBall", Qt::QueuedConnection, Q_ARG(int, ball_x), Q_ARG(int, ball_y));
+// emit moveBall(ball_x, ball_y);
+
+}
+
+void Controller::scored(Board::Edge pos)
+{
+ if (!timer->isActive())
+ return;
+
+ if (pos == Board::Left)
+ emit score(score_left, ++score_right);
+ else if (pos == Board::Right)
+ emit score(++score_left, score_right);
+
+ restart_ball();
+}
+
+void Controller::restart_ball()
+{
+ if (!timer->isActive())
+ return;
+
+ elapsed->start();
+
+ ball_x = Board::Width/2;
+ ball_y = Board::Height/2;
+
+// ball_y = (qrand()%(Board::Height/2))+Board::Height/4;
+ ball_y = (qrand()%(Board::Height-48))+24;
+
+ // Speed in in pixels/second
+
+ const int max = 4*FRAME_RATE;
+ const int min_x = 2*FRAME_RATE;
+ const int min_y = 1.5*FRAME_RATE;
+
+
+ speed_y = min_y+qrand()%(max-min_y);
+ if (speed_y%2)
+ speed_y *= -1;
+
+
+ speed_x = min_x+qrand()%(max-min_y);
+ if (speed_x%2)
+ speed_x *= -1;
+
+ leftPowerUp = rightPowerUp = 0;
+
+ emit moveBall(ball_x, ball_y);
+}
+
+
+void Controller::resetBoard()
+{
+ if (!timer->isActive())
+ return;
+
+ score_left = score_right = 0;
+ restart_ball();
+}
+
+void Controller::stop()
+{
+ timer->stop();
+}
+
+void Controller::start()
+{
+ timer->start();
+ fpscntr->restart();
+ frames = 0;
+}
+
+void Controller::moveLeftPaddle(int y)
+{
+ leftPaddleForce += leftPaddleLast-y;
+ leftPaddleLast = y;
+ leftPowerUp = 0;
+}
+
+void Controller::moveRightPaddle(int y)
+{
+ rightPaddleForce += rightPaddleLast-y;
+ rightPaddleLast =y;
+ rightPowerUp = 0;
+}
+
+void Controller::refresh()
+{
+ emit moveBall(ball_x, ball_y);
+ emit score(score_left, score_right);
+}
diff --git a/demos/bttennis/controller.h b/demos/bttennis/controller.h
new file mode 100644
index 00000000..8f966e29
--- /dev/null
+++ b/demos/bttennis/controller.h
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CONTROLLER_H
+#define CONTROLLER_H
+
+#include <QObject>
+#include <QTimer>
+#include <QTime>
+#include "board.h"
+
+class Controller : public QObject
+{
+ Q_OBJECT
+public:
+ explicit Controller(QObject *parent = 0);
+
+signals:
+ void moveBall(int x, int y);
+ void score(int left, int right);
+ void fps(const QString &str);
+
+public slots:
+ void ballCollision(Board::Edge pos);
+ void scored(Board::Edge pos);
+ void resetBoard();
+ void refresh();
+
+ void moveLeftPaddle(int y);
+ void moveRightPaddle(int y);
+
+ void tick();
+
+ void start();
+ void stop();
+
+private:
+ QTimer *timer;
+ QTime *elapsed;
+ QTime *fpscntr;
+ int frames;
+ int ball_x;
+ int speed_x;
+ int ball_y;
+ int speed_y;
+ int score_left;
+ int score_right;
+ int col_x;
+ int col_y;
+
+ int rightPaddleForce;
+ int leftPaddleForce;
+ int rightPaddleLast;
+ int leftPaddleLast;
+ int rightPowerUp;
+ int leftPowerUp;
+
+ void restart_ball();
+
+};
+
+#endif // CONTROLLER_H
diff --git a/demos/bttennis/handover.cpp b/demos/bttennis/handover.cpp
new file mode 100644
index 00000000..1e0bf042
--- /dev/null
+++ b/demos/bttennis/handover.cpp
@@ -0,0 +1,130 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "handover.h"
+
+#include <qnearfieldmanager.h>
+#include <qllcpserver.h>
+#include <qllcpsocket.h>
+#include <qbluetoothlocaldevice.h>
+
+#include <QtCore/QStringList>
+
+static const QLatin1String tennisUri("urn:nfc:sn:com.nokia.qtnfc.tennis");
+
+Handover::Handover(quint16 serverPort, QObject *parent)
+: QObject(parent), m_server(new QLlcpServer(this)),
+ m_client(new QLlcpSocket(this)), m_remote(0), m_serverPort(0), m_localServerPort(serverPort)
+{
+ connect(m_server, SIGNAL(newConnection()), this, SLOT(handleNewConnection()));
+ m_server->listen(tennisUri);
+
+ connect(m_client, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
+ connect(m_client, SIGNAL(readyRead()), this, SLOT(readBluetoothService()));
+
+ m_client->connectToService(0, tennisUri);
+}
+
+Handover::~Handover()
+{
+}
+
+QBluetoothAddress Handover::bluetoothAddress() const
+{
+ return m_address;
+}
+
+quint16 Handover::serverPort() const
+{
+ return m_serverPort;
+}
+
+void Handover::handleNewConnection()
+{
+ if (m_remote)
+ m_remote->deleteLater();
+
+ m_remote = m_server->nextPendingConnection();
+
+ connect(m_remote, SIGNAL(disconnected()), this, SLOT(remoteDisconnected()));
+
+ sendBluetoothService();
+}
+
+void Handover::remoteDisconnected()
+{
+ m_remote->deleteLater();
+ m_remote = 0;
+}
+
+void Handover::clientDisconnected()
+{
+ m_client->connectToService(0, tennisUri);
+}
+
+void Handover::readBluetoothService()
+{
+ QByteArray rawData = m_client->readAll();
+ QString data = QString::fromUtf8(rawData.constData(), rawData.size());
+ QStringList split = data.split(QLatin1Char(' '));
+
+ QBluetoothAddress address = QBluetoothAddress(split.at(0));
+ quint16 port = split.at(1).toUInt();
+
+ QBluetoothLocalDevice localDevice;
+ QBluetoothAddress localAddress = localDevice.address();
+
+ if (localAddress < address) {
+ m_address = address;
+ m_serverPort = port;
+ emit bluetoothServiceChanged();
+ }
+}
+
+void Handover::sendBluetoothService()
+{
+ QBluetoothLocalDevice localDevice;
+ const QString data = localDevice.address().toString() + QLatin1Char(' ') +
+ QString::number(m_localServerPort);
+
+ m_remote->write(data.toUtf8());
+}
+
diff --git a/demos/bttennis/handover.h b/demos/bttennis/handover.h
new file mode 100644
index 00000000..885b6284
--- /dev/null
+++ b/demos/bttennis/handover.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HANDOVER_H
+#define HANDOVER_H
+
+#include <QtCore/QObject>
+
+#include <qbluetoothaddress.h>
+#include <qbluetoothuuid.h>
+#include <qnfcglobal.h>
+
+QTNFC_BEGIN_NAMESPACE
+class QNearFieldManager;
+class QNearFieldTarget;
+class QLlcpServer;
+class QLlcpSocket;
+QTNFC_END_NAMESPACE
+
+QTNFC_USE_NAMESPACE
+QTBLUETOOTH_USE_NAMESPACE
+
+class Handover : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit Handover(quint16 serverPort, QObject *parent = 0);
+ ~Handover();
+
+ QBluetoothAddress bluetoothAddress() const;
+ quint16 serverPort() const;
+
+private slots:
+ void handleNewConnection();
+ void remoteDisconnected();
+
+ void clientDisconnected();
+
+ void readBluetoothService();
+ void sendBluetoothService();
+
+signals:
+ void bluetoothServiceChanged();
+
+private:
+ QLlcpServer *m_server;
+ QLlcpSocket *m_client;
+ QLlcpSocket *m_remote;
+
+ QBluetoothAddress m_address;
+ quint16 m_serverPort;
+ quint16 m_localServerPort;
+};
+
+#endif // HANDOVER_H
diff --git a/demos/bttennis/main.cpp b/demos/bttennis/main.cpp
new file mode 100644
index 00000000..ffb08329
--- /dev/null
+++ b/demos/bttennis/main.cpp
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tennis.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Tennis d;
+ QObject::connect(&d, SIGNAL(accepted()), &app, SLOT(quit()));
+
+#if defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN)
+ d.showFullScreen();
+#else
+ d.show();
+#endif
+
+ app.exec();
+
+ return 0;
+}
+
diff --git a/demos/bttennis/tennis.cpp b/demos/bttennis/tennis.cpp
new file mode 100644
index 00000000..57b872e8
--- /dev/null
+++ b/demos/bttennis/tennis.cpp
@@ -0,0 +1,424 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tennis.h"
+
+#include <QTimer>
+#include <QKeyEvent>
+#include <QMouseEvent>
+
+#include <QDebug>
+
+#include <QSettings>
+#include <QEvent>
+#include <QResizeEvent>
+
+#include "tennisserver.h"
+#include "tennisclient.h"
+#include "handover.h"
+
+#include <qbluetooth.h>
+#include <qbluetoothdeviceinfo.h>
+#include <qbluetoothsocket.h>
+#include <qbluetoothservicediscoveryagent.h>
+#include <qbluetoothlocaldevice.h>
+
+#include <qnearfieldmanager.h>
+#include <qllcpserver.h>
+#include <qllcpsocket.h>
+
+Tennis::Tennis(QWidget *parent)
+: QDialog(parent), ui(new Ui_Tennis), board(new Board), controller(new Controller), socket(0),
+ m_discoveryAgent(new QBluetoothServiceDiscoveryAgent), m_handover(0)
+{
+ // start Bluetooth if not started
+ QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
+ device->powerOn();
+ delete device;
+ device = 0;
+
+ //! [Construct UI]
+ ui->setupUi(this);
+
+ isClient = false;
+ isConnected = false;
+ quickDiscovery = true;
+
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ setWindowState(Qt::WindowMaximized);
+#endif
+
+ ui->pongView->setScene(board->getScene());
+
+ connect(ui->pongView, SIGNAL(mouseMove(int, int)), this, SLOT(mouseMove(int, int)));
+ ui->pongView->setMouseTracking(false);
+
+ connect(board, SIGNAL(ballCollision(Board::Edge)), controller, SLOT(ballCollision(Board::Edge)));
+ connect(board, SIGNAL(scored(Board::Edge)), controller, SLOT(scored(Board::Edge)));
+ connect(controller, SIGNAL(moveBall(int,int)), board, SLOT(setBall(int,int)));
+ connect(this, SIGNAL(moveLeftPaddle(int)), board, SLOT(setLeftPaddle(int)));
+ connect(this, SIGNAL(moveRightPaddle(int)), board, SLOT(setRightPaddle(int)));
+ connect(controller, SIGNAL(score(int,int)), board, SLOT(setScore(int,int)));
+ connect(controller, SIGNAL(fps(const QString&)), this, SLOT(fps(const QString&)));
+
+ setFocusPolicy(Qt::WheelFocus);
+
+ paddle_pos = (Board::Height-12)/2-Board::Paddle/2;
+ endPaddlePos = paddle_pos;
+
+ emit moveLeftPaddle(paddle_pos);
+ board->setRightPaddle(paddle_pos);
+
+ server = new TennisServer(this);
+
+ connect(controller, SIGNAL(moveBall(int,int)), server, SLOT(moveBall(int,int)));
+ connect(controller, SIGNAL(score(int,int)), server, SLOT(score(int,int)));
+ connect(this, SIGNAL(moveLeftPaddle(int)), server, SLOT(moveLeftPaddle(int)));
+ connect(server, SIGNAL(clientConnected(QString)), this, SLOT(serverConnected(QString)));
+ connect(server, SIGNAL(clientDisconnected(QString)), this, SLOT(serverDisconnected()));
+ connect(server, SIGNAL(moveRightPaddle(int)), board, SLOT(setRightPaddle(int)));
+ connect(server, SIGNAL(lag(int)), this, SLOT(lagReport(int)));
+
+ connect(server, SIGNAL(clientConnected(QString)), controller, SLOT(refresh()));
+
+ server->startServer();
+
+ client = new TennisClient(this);
+
+ connect(client, SIGNAL(moveBall(int,int)), board, SLOT(setBall(int,int)));
+ connect(client, SIGNAL(moveLeftPaddle(int)), board, SLOT(setLeftPaddle(int)));
+ connect(client, SIGNAL(connected(QString)), this, SLOT(clientConnected(QString)));
+ connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
+ connect(this, SIGNAL(moveRightPaddle(int)), client, SLOT(moveRightPaddle(int)));
+ connect(client, SIGNAL(score(int,int)), board, SLOT(setScore(int,int)));
+ connect(client, SIGNAL(lag(int)), this, SLOT(lagReport(int)));
+
+ connect(this, SIGNAL(moveLeftPaddle(int)), controller, SLOT(moveLeftPaddle(int)));
+ connect(this, SIGNAL(moveRightPaddle(int)), controller, SLOT(moveRightPaddle(int)));
+ connect(server, SIGNAL(moveRightPaddle(int)), controller, SLOT(moveRightPaddle(int)));
+
+
+// ui->pongView->setBackgroundBrush(QBrush(Qt::white));
+ ui->pongView->setCacheMode(QGraphicsView::CacheBackground);
+
+ QNearFieldManager nearFieldManager;
+ if (nearFieldManager.isAvailable()) {
+ m_handover = new Handover(server->serverPort(), this);
+ connect(m_handover, SIGNAL(bluetoothServiceChanged()), this, SLOT(nearFieldHandover()));
+
+ connect(m_discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
+ this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
+ connect(m_discoveryAgent, SIGNAL(finished()), this, SLOT(discoveryFinished()));
+ }
+
+
+ m_discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid));
+
+
+ QString address;
+ QString port;
+ QStringList args = QCoreApplication::arguments();
+ if (args.length() >= 2){
+ address = args.at(1);
+ if (args.length() >= 3){
+ port = args.at(2);
+ }
+ }
+
+ if (address.isEmpty()){
+ QSettings settings("QtDF", "bttennis");
+ address = settings.value("lastclient").toString();
+ }
+
+ if (!address.isEmpty()){
+ qDebug() << "Connect to" << address << port;
+ QBluetoothDeviceInfo device = QBluetoothDeviceInfo(QBluetoothAddress(address), "", QBluetoothDeviceInfo::ComputerDevice);
+ QBluetoothServiceInfo service;
+ if (!port.isEmpty()) {
+ QBluetoothServiceInfo::Sequence protocolDescriptorList;
+ QBluetoothServiceInfo::Sequence protocol;
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap))
+ << QVariant::fromValue(port.toUShort());
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ service.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
+ protocolDescriptorList);
+ qDebug() << "port" << port.toUShort() << service.protocolServiceMultiplexer();
+ }
+ else {
+ service.setServiceUuid(QBluetoothUuid(serviceUuid));
+ }
+ service.setDevice(device);
+ client->startClient(service);
+ board->setStatus("Connecting", 100, 25);
+ } else if (nearFieldManager.isAvailable()) {
+ board->setStatus(tr("Touch to play"), 100, 25);
+ }
+
+ setEnabled(true);
+
+ paddleAnimation = new QPropertyAnimation(this, "paddlePos", this);
+ paddleAnimation->setEasingCurve(QEasingCurve::InOutQuad);
+
+ ui->pongView->installEventFilter(this);
+
+}
+
+Tennis::~Tennis()
+{
+}
+
+void Tennis::keyPressEvent(QKeyEvent *event)
+{
+ if (event->matches(QKeySequence::MoveToNextLine)) {
+ moveDown();
+ }
+ else if (event->matches(QKeySequence::MoveToPreviousLine)){
+ moveUp();
+ }
+}
+
+void Tennis::wheelEvent(QWheelEvent *event)
+{
+ if (event->delta() > 0){
+ moveUp();
+ }
+ else {
+ moveDown();
+ }
+}
+
+void Tennis::moveUp(int px)
+{
+ endPaddlePos -= px;
+ if (endPaddlePos <= 0)
+ endPaddlePos = 0;
+ move(endPaddlePos);
+}
+
+void Tennis::moveDown(int px)
+{
+ endPaddlePos += px;
+ if (endPaddlePos > Board::Height-Board::Paddle-24)
+ endPaddlePos = Board::Height-Board::Paddle-24;
+ move(endPaddlePos);
+
+}
+
+void Tennis::move(int px)
+{
+ int distance = abs(paddle_pos - endPaddlePos);
+
+ paddleAnimation->stop();
+ paddleAnimation->setStartValue(paddle_pos);
+ paddleAnimation->setEndValue(px);
+ paddleAnimation->setDuration((1000*distance)/350);
+ paddleAnimation->start();
+}
+
+void Tennis::setPaddlePos(int p)
+{
+ paddle_pos = p;
+ if (isClient)
+ emit moveRightPaddle(paddle_pos);
+ else
+ emit moveLeftPaddle(paddle_pos);
+}
+
+
+void Tennis::mouseMove(int x, int y)
+{
+ if (isConnected == false){
+ // look for clicks in the bt connect icon
+ if (x > 440 && x < 540 && y > 200 && y < 300) {
+ qDebug() << "Got connect click!";
+ if (m_discoveryAgent->isActive()) {
+ qDebug() << "stopping!";
+ m_discoveryAgent->stop();
+ board->animateConnect(false);
+ }
+ else {
+ qDebug() << "starting!";
+ startDiscovery();
+ }
+ }
+
+ }
+ y-=12+Board::Paddle/2;
+ if (y <= 0)
+ y = 0;
+ else if (y > Board::Height-Board::Paddle-24)
+ y = Board::Height-Board::Paddle-24;
+
+ endPaddlePos = y;
+ move(y);
+}
+
+void Tennis::clientConnected(const QString &name)
+{
+ board->setStatus("Connected to " + name, 100, 0);
+ controller->stop();
+ server->stopServer();
+ isClient = true;
+ isConnected = true;
+ board->animateConnect(false);
+ board->fadeConnect(true);
+ emit moveRightPaddle(paddle_pos);
+}
+
+void Tennis::clientDisconnected()
+{
+ board->setStatus("Disconnect", 100, 25);
+ controller->start();
+ server->startServer();
+ client->stopClient();
+ isClient = false;
+ isConnected = false;
+ discoveryFinished();
+}
+
+void Tennis::serverConnected(const QString &name)
+{
+ board->setStatus("Server for " + name, 100, 0);
+ m_discoveryAgent->stop();
+ isConnected = true;
+ board->animateConnect(false);
+ board->fadeConnect(true);
+ emit moveLeftPaddle(paddle_pos);
+}
+
+void Tennis::serverDisconnected()
+{
+ board->setStatus("Disconnected", 100, 25);
+ isConnected = false;
+ discoveryFinished();
+}
+
+void Tennis::serviceDiscovered(const QBluetoothServiceInfo &serviceInfo)
+{
+ qDebug() << "***** Discovered! " << serviceInfo.device().name() << serviceInfo.serviceName() << serviceInfo.serviceUuid();
+ qDebug() << "Found one!" << serviceInfo.protocolServiceMultiplexer();
+ m_discoveryAgent->stop();
+ client->startClient(serviceInfo);
+ QSettings settings("QtDF", "bttennis");
+ settings.setValue("lastclient", serviceInfo.device().address().toString());
+}
+
+void Tennis::discoveryFinished()
+{
+ if (!m_discoveryAgent->isActive()) {
+ if (!isConnected) {
+ board->setStatus("Waiting", 100, 25);
+ // QTimer::singleShot(60000, this, SLOT(startDiscovery()));
+ board->animateConnect(false);
+ board->fadeConnect(false);
+ }
+ }
+}
+
+void Tennis::startDiscovery()
+{
+ qDebug() << "startDiscovery() called";
+ if (!isConnected) {
+ qDebug() << "Scanning!";
+ board->setStatus("Scanning", 100, 25);
+ board->fadeConnect(false);
+ board->animateConnect(true);
+ m_discoveryAgent->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
+// if (quickDiscovery)
+// m_discoveryAgent->start(QBluetoothServiceDiscoveryAgent::MinimalDiscovery);
+// else
+// m_discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery);
+// quickDiscovery = !quickDiscovery;
+ }
+ else {
+ qDebug() << "Stop scanning!";
+ board->setStatus("", 0, 0);
+ board->animateConnect(false);
+ board->fadeConnect(true);
+ }
+}
+
+void Tennis::resizeEvent(QResizeEvent *re)
+{
+ if (re->oldSize().height() > 0){
+ qreal x, y;
+ x = (re->size().width())/qreal(re->oldSize().width());
+ y = (re->size().height())/qreal(re->oldSize().height());
+ ui->pongView->scale(x, y);
+ }
+ ui->pongView->resize(re->size());
+}
+
+void Tennis::lagReport(int ms)
+{
+ if (ms > 250){
+ board->setStatus(QString("Caution Lag %1ms").arg(ms), 100, 0);
+ }
+}
+
+void Tennis::nearFieldHandover()
+{
+ qDebug() << "Connecting to NFC provided address" << m_handover->bluetoothAddress().toString();
+
+ QBluetoothDeviceInfo device = QBluetoothDeviceInfo(m_handover->bluetoothAddress(), QString(),
+ QBluetoothDeviceInfo::ComputerDevice);
+
+ QBluetoothServiceInfo service;
+ service.setServiceUuid(QBluetoothUuid(serviceUuid));
+ service.setDevice(device);
+
+ QBluetoothServiceInfo::Sequence protocolDescriptorList;
+ QBluetoothServiceInfo::Sequence protocol;
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap))
+ << QVariant::fromValue(m_handover->serverPort());
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ service.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
+ protocolDescriptorList);
+
+ client->startClient(service);
+ board->setStatus(tr("Connecting: %1 %2").arg(m_handover->bluetoothAddress().toString()).arg(m_handover->serverPort()), 100, 25);
+}
+
+void Tennis::fps(const QString &f)
+{
+ board->setStatus(f, 100, 100);
+}
+
diff --git a/demos/bttennis/tennis.h b/demos/bttennis/tennis.h
new file mode 100644
index 00000000..6286a0cf
--- /dev/null
+++ b/demos/bttennis/tennis.h
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui_tennis.h"
+
+#include <QDialog>
+
+#include <QResizeEvent>
+#include <QMoveEvent>
+#include <QPropertyAnimation>
+#include <qbluetoothserviceinfo.h>
+#include <qbluetoothsocket.h>
+#include <qbluetoothdevicediscoveryagent.h>
+
+#include "board.h"
+#include "controller.h"
+
+#include <QDebug>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QBluetoothServiceDiscoveryAgent;
+QTBLUETOOTH_END_NAMESPACE
+
+QTBLUETOOTH_USE_NAMESPACE
+
+static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c9");
+
+class TennisServer;
+class TennisClient;
+class Handover;
+
+//! [declaration]
+class Tennis : public QDialog
+{
+ Q_OBJECT
+ Q_PROPERTY(int paddlePos READ paddlePos WRITE setPaddlePos)
+
+public:
+ Tennis(QWidget *parent = 0);
+ ~Tennis();
+
+ int paddlePos() { return paddle_pos; }
+ void setPaddlePos(int p);
+
+signals:
+ void moveLeftPaddle(int y);
+ void moveRightPaddle(int y);
+
+protected:
+ void wheelEvent ( QWheelEvent * event );
+ void keyPressEvent ( QKeyEvent * event );
+ void resizeEvent(QResizeEvent *);
+
+private slots:
+ void serverConnected(const QString &name);
+ void serverDisconnected();
+
+ void clientConnected(const QString &name);
+ void clientDisconnected();
+
+ void serviceDiscovered(const QBluetoothServiceInfo &serviceInfo);
+ void discoveryFinished();
+
+ void startDiscovery();
+
+ void mouseMove(int x, int y);
+
+ void lagReport(int ms);
+
+ void nearFieldHandover();
+
+ void fps(const QString &f);
+
+private:
+
+ void moveUp(int px = 10);
+ void moveDown(int px = 10);
+
+ void move(int px);
+
+ Ui_Tennis *ui;
+
+ Board *board;
+ Controller *controller;
+
+ int paddle_pos;
+ int endPaddlePos;
+
+ bool isClient;
+ bool isConnected;
+ bool quickDiscovery;
+
+ QBluetoothSocket *socket;
+ TennisServer *server;
+ TennisClient *client;
+
+ QPropertyAnimation *paddleAnimation;
+
+ QBluetoothServiceDiscoveryAgent *m_discoveryAgent;
+ Handover *m_handover;
+};
+//! [declaration]
diff --git a/demos/bttennis/tennis.qrc b/demos/bttennis/tennis.qrc
new file mode 100644
index 00000000..12aa7464
--- /dev/null
+++ b/demos/bttennis/tennis.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/icons">
+ <file>connect.png</file>
+ </qresource>
+</RCC>
diff --git a/demos/bttennis/tennis.ui b/demos/bttennis/tennis.ui
new file mode 100644
index 00000000..d6625fa8
--- /dev/null
+++ b/demos/bttennis/tennis.ui
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Tennis</class>
+ <widget class="QDialog" name="Tennis">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>640</width>
+ <height>360</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Bluetooth Tennis</string>
+ </property>
+ <widget class="TennisView" name="pongView">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>640</width>
+ <height>366</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>TennisView</class>
+ <extends>QGraphicsView</extends>
+ <header>tennisview.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/demos/bttennis/tennisclient.cpp b/demos/bttennis/tennisclient.cpp
new file mode 100644
index 00000000..ae7e5ceb
--- /dev/null
+++ b/demos/bttennis/tennisclient.cpp
@@ -0,0 +1,200 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tennisclient.h"
+
+#include <qbluetoothsocket.h>
+
+#include <QtCore/QDataStream>
+#include <QtCore/QByteArray>
+
+#include <QtCore/QStringList>
+
+TennisClient::TennisClient(QObject *parent)
+: QObject(parent), socket(0), stream(0), elapsed(new QTime), lagTimeout(0)
+{
+ lagTimer.setInterval(1000);
+ connect(&lagTimer, SIGNAL(timeout()), this, SLOT(sendEcho()));
+}
+
+TennisClient::~TennisClient()
+{
+ stopClient();
+}
+
+//! [startClient]
+void TennisClient::startClient(const QBluetoothServiceInfo &remoteService)
+{
+ if (socket)
+ return;
+
+ serviceInfo = remoteService;
+
+ // Connect to service
+ socket = new QBluetoothSocket(QBluetoothSocket::L2capSocket);
+ qDebug() << "Create socket";
+ socket->connectToService(remoteService);
+ qDebug() << "ConnecttoService done";
+
+ connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
+ connect(socket, SIGNAL(connected()), this, SLOT(connected()));
+ connect(socket, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
+ connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
+ connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(error(QBluetoothSocket::SocketError)));
+
+ lagTimer.start();
+}
+//! [startClient]
+
+//! [stopClient]
+void TennisClient::stopClient()
+{
+ if (socket == 0) // already stopped
+ return;
+
+ qDebug() << Q_FUNC_INFO << "closing client!";
+
+ lagTimer.stop();
+
+ delete stream;
+ stream = 0;
+
+ socket->deleteLater();
+ socket = 0;
+}
+//! [stopClient]
+
+//! [socketDisconnected]
+void TennisClient::socketDisconnected()
+{
+ qDebug() << "Got socketDisconnected";
+ stopClient();
+}
+//! [socketDisconnected]
+
+//! [readSocket]
+void TennisClient::readSocket()
+{
+ if (!socket)
+ return;
+
+ while (socket->bytesAvailable()) {
+ QString str;
+
+ *stream >> str;
+
+ QStringList args = str.split(QChar(' '));
+ QString s = args.takeFirst();
+
+ if (s == "m" && args.count() == 2) {
+ emit moveBall(args.at(0).toInt(), args.at(1).toInt());
+ }
+ else if (s == "s" && args.count() == 2){
+ emit score(args.at(0).toInt(), args.at(1).toInt());
+ }
+ else if (s == "l" && args.count() == 1){
+ emit moveLeftPaddle(args.at(0).toInt());
+ }
+ else if (s == "e"){ // echo
+ QByteArray b;
+ QDataStream s(&b, QIODevice::WriteOnly);
+ s << str;
+ socket->write(b);
+ }
+ else if (s == "E"){
+ lagTimeout = 0;
+ QTime then = QTime::fromString(args.at(0), "hh:mm:ss.zzz");
+ if (then.isValid()) {
+ emit lag(then.msecsTo(QTime::currentTime()));
+// qDebug() << "RTT: " << then.msecsTo(QTime::currentTime()) << "ms";
+ }
+ }
+ else {
+ qDebug() << Q_FUNC_INFO << "Unknown command" << str;
+ }
+ }
+}
+//! [readSocket]
+
+//! [moveRightPaddle]
+void TennisClient::moveRightPaddle(int y)
+{
+ int msec = elapsed->elapsed();
+
+ if (stream && msec > 50) {
+ QByteArray b;
+ QDataStream s(&b, QIODevice::WriteOnly);
+ s << QString("r %1").arg(y);
+ socket->write(b);
+ elapsed->restart();
+ }
+}
+//! [moveRightPaddle]
+
+//! [connected]
+void TennisClient::connected()
+{
+ stream = new QDataStream(socket);
+ emit connected(socket->peerName());
+}
+//! [connected]
+
+void TennisClient::error(QBluetoothSocket::SocketError err)
+{
+ qDebug() << "Got socket error" <<Q_FUNC_INFO << "error" << err;
+ emit disconnected();
+}
+
+void TennisClient::sendEcho()
+{
+ if (lagTimeout) {
+ lagTimeout--;
+ return;
+ }
+
+ if (stream) {
+ QByteArray b;
+ QDataStream s(&b, QIODevice::WriteOnly);
+ s << QString("E %1").arg(QTime::currentTime().toString("hh:mm:ss.zzz"));
+ socket->write(b);
+ lagTimeout = 10;
+ }
+}
diff --git a/demos/bttennis/tennisclient.h b/demos/bttennis/tennisclient.h
new file mode 100644
index 00000000..a5d95200
--- /dev/null
+++ b/demos/bttennis/tennisclient.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CHATCLIENT_H
+#define CHATCLIENT_H
+
+#include <qbluetoothserviceinfo.h>
+#include <qbluetoothsocket.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QTime>
+#include <QtCore/QTimer>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QBluetoothSocket;
+QTBLUETOOTH_END_NAMESPACE
+
+class QDataStream;
+
+QTBLUETOOTH_USE_NAMESPACE
+
+//! [declaration]
+class TennisClient : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit TennisClient(QObject *parent = 0);
+ ~TennisClient();
+
+ void startClient(const QBluetoothServiceInfo &remoteService);
+ void stopClient();
+
+public slots:
+ void moveRightPaddle(int y);
+ void error(QBluetoothSocket::SocketError);
+
+signals:
+ void moveBall(int x, int y);
+ void score(int left, int right);
+ void moveLeftPaddle(int y);
+
+ void connected(const QString &name);
+ void disconnected();
+
+ void lag(int ms);
+
+private slots:
+ void readSocket();
+ void connected();
+ void sendEcho();
+ void socketDisconnected();
+
+private:
+ QBluetoothSocket *socket;
+ QDataStream *stream;
+ QBluetoothServiceInfo serviceInfo;
+ QTime *elapsed;
+ QTimer lagTimer;
+ int lagTimeout;
+};
+//! [declaration]
+
+#endif // CHATCLIENT_H
diff --git a/demos/bttennis/tennisserver.cpp b/demos/bttennis/tennisserver.cpp
new file mode 100644
index 00000000..4982bb87
--- /dev/null
+++ b/demos/bttennis/tennisserver.cpp
@@ -0,0 +1,306 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "tennisserver.h"
+#include "tennis.h"
+
+#include <ql2capserver.h>
+#include <qbluetoothsocket.h>
+
+#include <QDebug>
+
+TennisServer::TennisServer(QObject *parent)
+: QObject(parent), l2capServer(0), clientSocket(0), stream(0), lagReplyTimeout(0)
+{
+ elapsed.start();
+ ballElapsed.start();
+ lagTimer.setInterval(1000);
+ connect(&lagTimer, SIGNAL(timeout()), this, SLOT(sendEcho()));
+}
+
+TennisServer::~TennisServer()
+{
+ if (stream){
+ QByteArray b;
+ QDataStream s(&b, QIODevice::WriteOnly);
+ s << QString("D");
+ clientSocket->write(b);
+ }
+
+ stopServer();
+}
+
+void TennisServer::startServer()
+{
+ if (l2capServer)
+ return;
+
+ //! [Create the server]
+ l2capServer = new QL2capServer(this);
+ connect(l2capServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
+ l2capServer->listen();
+ //! [Create the server]
+
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
+
+ //! [Class ServiceClass must contain at least 1 entry]
+ QBluetoothServiceInfo::Sequence classId;
+// classId << QVariant::fromValue(QBluetoothUuid(serviceUuid));
+ classId << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::SerialPort));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
+ //! [Class ServiceClass must contain at least 1 entry]
+
+
+ //! [Service name, description and provider]
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Example Tennis Server"));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,
+ tr("Example bluetooth tennis server"));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("Nokia, QtDF"));
+ //! [Service name, description and provider]
+
+ //! [Service UUID set]
+ serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));
+ //! [Service UUID set]
+
+ //! [Service Discoverability]
+ serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
+ QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+ //! [Service Discoverability]
+
+
+ //! [Protocol descriptor list]
+ QBluetoothServiceInfo::Sequence protocolDescriptorList;
+ QBluetoothServiceInfo::Sequence protocol;
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap))
+ << QVariant::fromValue(quint16(l2capServer->serverPort()));
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
+ protocolDescriptorList);
+ //! [Protocol descriptor list]
+
+ //! [Register service]
+ serviceInfo.registerService();
+ //! [Register service]
+
+}
+
+//! [stopServer]
+void TennisServer::stopServer()
+{
+ qDebug() <<Q_FUNC_INFO;
+ // Unregister service
+ serviceInfo.unregisterService();
+
+ delete stream;
+ stream = 0;
+
+ // Close sockets
+ delete clientSocket;
+ clientSocket = 0;
+
+ // Close server
+ delete l2capServer;
+ l2capServer = 0;
+}
+//! [stopServer]
+
+quint16 TennisServer::serverPort() const
+{
+ return l2capServer->serverPort();
+}
+
+//! [moveBall]
+void TennisServer::moveBall(int x, int y)
+{
+ int msec = ballElapsed.elapsed();
+
+ if (stream && msec > 30){
+ QByteArray b;
+ QDataStream s(&b, QIODevice::WriteOnly);
+ s << QString("m %1 %2").arg(x).arg(y);
+ //s << QLatin1String("m") << x << y;
+ clientSocket->write(b);
+ ballElapsed.restart();
+ }
+}
+//! [moveBall]
+
+void TennisServer::score(int left, int right)
+{
+ if (stream){
+ QByteArray b;
+ QDataStream s(&b, QIODevice::WriteOnly);
+ s << QString("s %1 %2").arg(left).arg(right);
+// s << QChar('s') << left << right;
+ clientSocket->write(b);
+ }
+}
+
+void TennisServer::moveLeftPaddle(int y)
+{
+
+ int msec = elapsed.elapsed();
+
+ if (stream && msec > 50) {
+ QByteArray b;
+ QDataStream s(&b, QIODevice::WriteOnly);
+ s << QString("l %1").arg(y);
+// s << QChar('l') << y;
+ clientSocket->write(b);
+ elapsed.restart();
+ }
+}
+
+void TennisServer::readSocket()
+{
+ if (!clientSocket)
+ return;
+
+ while (clientSocket->bytesAvailable()) {
+
+ QString str;
+ *stream >> str;
+ QStringList args = str.split(QChar(' '));
+ QString s = args.takeFirst();
+
+ if (s == "r" && args.count() == 1){
+ emit moveRightPaddle(args.at(0).toInt());
+ }
+ else if (s == "e" && args.count() == 1){
+ lagReplyTimeout = 0;
+ QTime then = QTime::fromString(args.at(0), "hh:mm:ss.zzz");
+ if (then.isValid()) {
+ emit lag(then.msecsTo(QTime::currentTime()));
+// qDebug() << "RTT: " << then.msecsTo(QTime::currentTime()) << "ms";
+ }
+ }
+ else if (s == "E"){
+ QByteArray b;
+ QDataStream st(&b, QIODevice::WriteOnly);
+ st << str;
+ clientSocket->write(b);
+ }
+ else if (s == "D"){
+ qDebug() << Q_FUNC_INFO << "closing!";
+ clientSocket->deleteLater();
+ clientSocket = 0;
+ }
+ else {
+ qDebug() << Q_FUNC_INFO << "Unknown command" << str;
+ }
+ }
+}
+
+//! [clientConnected]
+void TennisServer::clientConnected()
+{
+ qDebug() << Q_FUNC_INFO << "connect";
+
+ QBluetoothSocket *socket = l2capServer->nextPendingConnection();
+ if (!socket)
+ return;
+
+ if (clientSocket){
+ qDebug() << Q_FUNC_INFO << "Closing socket!";
+ delete socket;
+ return;
+ }
+
+ connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
+ connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
+ connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socketError(QBluetoothSocket::SocketError)));
+
+ stream = new QDataStream(socket);
+
+ clientSocket = socket;
+
+ qDebug() << Q_FUNC_INFO << "started";
+
+ emit clientConnected(clientSocket->peerName());
+ lagTimer.start();
+}
+//! [clientConnected]
+
+void TennisServer::socketError(QBluetoothSocket::SocketError err)
+{
+ qDebug() << Q_FUNC_INFO << err;
+}
+
+//! [sendEcho]
+void TennisServer::sendEcho()
+{
+ if (lagReplyTimeout) {
+ lagReplyTimeout--;
+ return;
+ }
+
+ if (stream) {
+ QByteArray b;
+ QDataStream s(&b, QIODevice::WriteOnly);
+ s << QString("e %1").arg(QTime::currentTime().toString("hh:mm:ss.zzz"));
+ clientSocket->write(b);
+ lagReplyTimeout = 10;
+ }
+}
+//! [sendEcho]
+
+//! [clientDisconnected]
+void TennisServer::clientDisconnected()
+{
+ qDebug() << Q_FUNC_INFO << "client closing!";
+
+ lagTimer.stop();
+ lagReplyTimeout = 0;
+ QBluetoothSocket *socket = qobject_cast<QBluetoothSocket *>(sender());
+ if (!socket)
+ return;
+
+ emit clientDisconnected(socket->peerName());
+
+ clientSocket->deleteLater();
+ clientSocket = 0;
+ delete stream;
+ stream = 0;
+
+// socket->deleteLater();
+}
+//! [clientDisconnected]
+
diff --git a/demos/bttennis/tennisserver.h b/demos/bttennis/tennisserver.h
new file mode 100644
index 00000000..4786a760
--- /dev/null
+++ b/demos/bttennis/tennisserver.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TENNISSERVER_H
+#define TENNISSERVER_H
+
+#include <qbluetoothserviceinfo.h>
+#include <qbluetoothsocket.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QList>
+#include <QtCore/QDataStream>
+#include <QtCore/QTime>
+#include <QtCore/QTimer>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QL2capServer;
+class QBluetoothSocket;
+class QBluetoothServiceInfo;
+QTBLUETOOTH_END_NAMESPACE
+
+QTBLUETOOTH_USE_NAMESPACE
+
+//! [declaration]
+class TennisServer : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit TennisServer(QObject *parent = 0);
+ ~TennisServer();
+
+ void startServer();
+ void stopServer();
+
+ quint16 serverPort() const;
+
+public slots:
+ void moveBall(int x, int y);
+ void score(int left, int right);
+ void moveLeftPaddle(int y);
+
+signals:
+ void moveRightPaddle(int y);
+ void clientDisconnected(const QString &name);
+ void clientConnected(const QString &name);
+ void lag(int ms);
+
+private slots:
+ void clientConnected();
+ void clientDisconnected();
+ void readSocket();
+ void sendEcho();
+ void socketError(QBluetoothSocket::SocketError err);
+
+private:
+ QL2capServer *l2capServer;
+ QBluetoothServiceInfo serviceInfo;
+ QBluetoothSocket *clientSocket;
+ QDataStream *stream;
+ QTime elapsed;
+ QTime ballElapsed;
+ QTimer lagTimer;
+ int lagReplyTimeout;
+};
+//! [declaration]
+
+#endif // CHATSERVER_H
diff --git a/demos/bttennis/tennisview.cpp b/demos/bttennis/tennisview.cpp
new file mode 100644
index 00000000..a51b388b
--- /dev/null
+++ b/demos/bttennis/tennisview.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include "tennisview.h"
+
+#include <QMouseEvent>
+
+TennisView::TennisView(QWidget *parent) :
+ QGraphicsView(parent)
+{
+}
+
+void TennisView::mousePressEvent(QMouseEvent *event)
+{
+ QPointF p = mapToScene(event->x(), event->y());
+ emit mousePress(p.x(), p.y());
+ emit mouseMove(p.x(), p.y());
+ last_y = p.y();
+}
+
+void TennisView::mouseMoveEvent(QMouseEvent *event)
+{
+ if (event->buttons()) {
+ QPointF p = mapToScene(event->x(), event->y());
+ if (10 < abs(last_y - event->y())) {
+// emit mouseMove(p.x(), p.y());
+ last_y = p.y();
+ }
+ }
+}
diff --git a/demos/bttennis/tennisview.h b/demos/bttennis/tennisview.h
new file mode 100644
index 00000000..0c02b7b3
--- /dev/null
+++ b/demos/bttennis/tennisview.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef TENNISVIEW_H
+#define TENNISVIEW_H
+
+#include <QGraphicsView>
+
+class TennisView : public QGraphicsView
+{
+ Q_OBJECT
+public:
+ explicit TennisView(QWidget *parent = 0);
+
+signals:
+ void mouseMove(int x, int y);
+ void mousePress(int x, int y);
+
+public slots:
+
+protected:
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *ev);
+
+private:
+ int last_y;
+
+};
+
+#endif // TENNISVIEW_H
diff --git a/doc/compat.qdocconf b/doc/compat.qdocconf
new file mode 100644
index 00000000..0b59629e
--- /dev/null
+++ b/doc/compat.qdocconf
@@ -0,0 +1,31 @@
+alias.i = e
+alias.include = input
+
+macro.0 = "\\\\0"
+macro.b = "\\\\b"
+macro.n = "\\\\n"
+macro.r = "\\\\r"
+macro.i = "\\o"
+macro.i11 = "\\o{1,1}"
+macro.i12 = "\\o{1,2}"
+macro.i13 = "\\o{1,3}"
+macro.i14 = "\\o{1,4}"
+macro.i15 = "\\o{1,5}"
+macro.i16 = "\\o{1,6}"
+macro.i17 = "\\o{1,7}"
+macro.i18 = "\\o{1,8}"
+macro.i19 = "\\o{1,9}"
+macro.i21 = "\\o{2,1}"
+macro.i31 = "\\o{3,1}"
+macro.i41 = "\\o{4,1}"
+macro.i51 = "\\o{5,1}"
+macro.i61 = "\\o{6,1}"
+macro.i71 = "\\o{7,1}"
+macro.i81 = "\\o{8,1}"
+macro.i91 = "\\o{9,1}"
+macro.img = "\\image"
+macro.endquote = "\\endquotation"
+macro.relatesto = "\\relates"
+
+spurious = "Missing comma in .*" \
+ "Missing pattern .*"
diff --git a/doc/doc.pri b/doc/doc.pri
new file mode 100644
index 00000000..459e9baa
--- /dev/null
+++ b/doc/doc.pri
@@ -0,0 +1,14 @@
+OTHER_FILES += \
+ $$PWD/qt5.qdocconf \
+ $$PWD/qt5-dita.qdocconf
+
+docs_target.target = docs
+docs_target.commands = qdoc3 $$PWD/qt5.qdocconf
+
+ditadocs_target.target = ditadocs
+ditadocs_target.commands = qdoc3 $$PWD/qt5-dita.qdocconf
+
+QMAKE_EXTRA_TARGETS = docs_target ditadocs_target
+QMAKE_CLEAN += \
+ "-r $$PWD/html" \
+ "-r $$PWD/ditaxml"
diff --git a/doc/macros.qdocconf b/doc/macros.qdocconf
new file mode 100644
index 00000000..ca458c15
--- /dev/null
+++ b/doc/macros.qdocconf
@@ -0,0 +1,43 @@
+macro.aacute.HTML = "&aacute;"
+macro.Aring.HTML = "&Aring;"
+macro.aring.HTML = "&aring;"
+macro.Auml.HTML = "&Auml;"
+macro.author = "\\bold{Author:}"
+macro.br.HTML = "<br />"
+macro.BR.HTML = "<br />"
+macro.copyright.HTML = "&copy;"
+macro.eacute.HTML = "&eacute;"
+macro.gui = "\\bold"
+macro.hr.HTML = "<hr />"
+macro.iacute.HTML = "&iacute;"
+macro.key = "\\bold"
+macro.menu = "\\bold"
+macro.note = "\\bold{Note:}"
+macro.oslash.HTML = "&oslash;"
+macro.ouml.HTML = "&ouml;"
+macro.QA = "Qt Assistant"
+macro.QC = "Creator"
+macro.QD = "Qt Designer"
+macro.QL = "Qt Linguist"
+macro.QMLD = "Qt Quick Designer"
+macro.QQV = "Qt QML Viewer"
+macro.QSDK = "Qt SDK"
+#macro.qtcversion = $QTC_VERSION
+macro.qtcversion = "0.0"
+macro.param = "\\e"
+macro.raisedaster.HTML = "<sup>*</sup>"
+macro.rarrow.HTML = "&rarr;"
+macro.reg.HTML = "<sup>&reg;</sup>"
+macro.return = "Returns"
+macro.starslash = "\\c{*/}"
+macro.begincomment = "\\c{/*}"
+macro.endcomment = "\\c{*/}"
+macro.uuml.HTML = "&uuml;"
+macro.mdash.HTML = "&mdash;"
+macro.pi.HTML = "&Pi;"
+
+macro.beginfloatleft.HTML = "<div style=\"float: left; margin-right: 2em\">"
+macro.beginfloatright.HTML = "<div style=\"float: right; margin-left: 2em\">"
+macro.endfloat.HTML = "</div>"
+macro.clearfloat.HTML = "<br style=\"clear: both\" />"
+macro.emptyspan.HTML = "<span></span>"
diff --git a/doc/qt-cpp-ignore.qdocconf b/doc/qt-cpp-ignore.qdocconf
new file mode 100644
index 00000000..edc7c7c1
--- /dev/null
+++ b/doc/qt-cpp-ignore.qdocconf
@@ -0,0 +1,106 @@
+Cpp.ignoretokens = QAXFACTORY_EXPORT \
+ QDESIGNER_COMPONENTS_LIBRARY \
+ QDESIGNER_EXTENSION_LIBRARY \
+ QDESIGNER_SDK_LIBRARY \
+ QDESIGNER_SHARED_LIBRARY \
+ QDESIGNER_UILIB_LIBRARY \
+ QM_EXPORT_CANVAS \
+ QM_EXPORT_DNS \
+ QM_EXPORT_DOM \
+ QM_EXPORT_FTP \
+ QM_EXPORT_HTTP \
+ QM_EXPORT_ICONVIEW \
+ QM_EXPORT_NETWORK \
+ QM_EXPORT_OPENGL \
+ QM_EXPORT_OPENVG \
+ QM_EXPORT_SQL \
+ QM_EXPORT_TABLE \
+ QM_EXPORT_WORKSPACE \
+ QM_EXPORT_XML \
+ QT_ASCII_CAST_WARN \
+ QT_ASCII_CAST_WARN_CONSTRUCTOR \
+ QT_BEGIN_HEADER \
+ QT_DESIGNER_STATIC \
+ QT_END_HEADER \
+ QT_FASTCALL \
+ QT_WIDGET_PLUGIN_EXPORT \
+ Q_COMPAT_EXPORT \
+ Q_CORE_EXPORT \
+ Q_CORE_EXPORT_INLINE \
+ Q_EXPLICIT \
+ Q_EXPORT \
+ Q_EXPORT_CODECS_CN \
+ Q_EXPORT_CODECS_JP \
+ Q_EXPORT_CODECS_KR \
+ Q_EXPORT_PLUGIN \
+ Q_GFX_INLINE \
+ Q_AUTOTEST_EXPORT \
+ Q_GUI_EXPORT \
+ Q_GUI_EXPORT_INLINE \
+ Q_GUI_EXPORT_STYLE_CDE \
+ Q_GUI_EXPORT_STYLE_COMPACT \
+ Q_GUI_EXPORT_STYLE_MAC \
+ Q_GUI_EXPORT_STYLE_MOTIF \
+ Q_GUI_EXPORT_STYLE_MOTIFPLUS \
+ Q_GUI_EXPORT_STYLE_PLATINUM \
+ Q_GUI_EXPORT_STYLE_POCKETPC \
+ Q_GUI_EXPORT_STYLE_SGI \
+ Q_GUI_EXPORT_STYLE_WINDOWS \
+ Q_GUI_EXPORT_STYLE_WINDOWSXP \
+ QHELP_EXPORT \
+ Q_INLINE_TEMPLATE \
+ Q_INTERNAL_WIN_NO_THROW \
+ Q_LOCATION_EXPORT \
+ Q_NETWORK_EXPORT \
+ Q_OPENGL_EXPORT \
+ Q_OPENVG_EXPORT \
+ Q_OUTOFLINE_TEMPLATE \
+ Q_SQL_EXPORT \
+ Q_SVG_EXPORT \
+ Q_SCRIPT_EXPORT \
+ Q_SCRIPTTOOLS_EXPORT \
+ Q_TESTLIB_EXPORT \
+ Q_TYPENAME \
+ Q_XML_EXPORT \
+ Q_XMLSTREAM_EXPORT \
+ Q_XMLPATTERNS_EXPORT \
+ QDBUS_EXPORT \
+ Q_DBUS_EXPORT \
+ QT_BEGIN_NAMESPACE \
+ QT_BEGIN_INCLUDE_NAMESPACE \
+ QT_END_NAMESPACE \
+ QT_END_INCLUDE_NAMESPACE \
+ QTNFC_BEGIN_NAMESPACE \
+ QTNFC_END_NAMESPACE \
+ Q_NFC_EXPORT \
+ QTBLUETOOTH_BEGIN_NAMESPACE \
+ QTBLUETOOTH_END_NAMESPACE \
+ Q_BLUETOOTH_EXPORT \
+ PHONON_EXPORT \
+ Q_DECLARATIVE_EXPORT \
+ Q_GADGET \
+ QWEBKIT_EXPORT \
+ Q_INVOKABLE \
+ Q_DECL_CONSTEXPR
+Cpp.ignoredirectives = Q_DECLARE_HANDLE \
+ Q_DECLARE_INTERFACE \
+ Q_DECLARE_METATYPE \
+ Q_DECLARE_OPERATORS_FOR_FLAGS \
+ Q_DECLARE_PRIVATE \
+ Q_DECLARE_PUBLIC \
+ Q_DECLARE_SHARED \
+ Q_DECLARE_TR_FUNCTIONS \
+ Q_DECLARE_TYPEINFO \
+ Q_DISABLE_COPY \
+ QT_FORWARD_DECLARE_CLASS \
+ Q_DUMMY_COMPARISON_OPERATOR \
+ Q_ENUMS \
+ Q_FLAGS \
+ Q_INTERFACES \
+ __attribute__ \
+ K_DECLARE_PRIVATE \
+ PHONON_OBJECT \
+ PHONON_HEIR \
+ Q_PRIVATE_PROPERTY \
+ Q_DECLARE_PRIVATE_D \
+ Q_CLASSINFO
diff --git a/doc/qt-defines.qdocconf b/doc/qt-defines.qdocconf
new file mode 100644
index 00000000..aaf935ac
--- /dev/null
+++ b/doc/qt-defines.qdocconf
@@ -0,0 +1,18 @@
+defines = Q_QDOC \
+ QT_.*_SUPPORT \
+ QT_.*_LIB \
+ QT_COMPAT \
+ QT_KEYPAD_NAVIGATION \
+ QT_NO_EGL \
+ QT3_SUPPORT \
+ Q_WS_.* \
+ Q_OS_.* \
+ Q_BYTE_ORDER \
+ QT_DEPRECATED \
+ Q_NO_USING_KEYWORD \
+ __cplusplus \
+ Q_COMPILER_INITIALIZER_LISTS
+
+versionsym = QT_VERSION_STR
+
+codeindent = 1
diff --git a/doc/qt5-dita.qdocconf b/doc/qt5-dita.qdocconf
new file mode 100644
index 00000000..e6f24dc3
--- /dev/null
+++ b/doc/qt5-dita.qdocconf
@@ -0,0 +1,22 @@
+# Name of the project.
+project = qtconnectivity
+
+# Directories in which to search for files to document and images.
+# By default set to the root directory of the project for sources
+# and headers and qdoc will therefore generate output for each file.
+# Images should be placed in <rootdir>/dic/images and examples in
+# <rootdir>/examples.
+# Paths are relative to the location of this file.
+exampledirs += .
+headerdirs += ..
+sourcedirs += ..
+
+
+
+#Do not change the variables after this line unless you know what you are doing.
+
+outputdir = ditaxml
+outputformats = DITAXML
+
+sources.fileextensions = "*.cpp *.qdoc *.mm *.qml"
+headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx"
diff --git a/doc/qt5.qdocconf b/doc/qt5.qdocconf
new file mode 100644
index 00000000..138a7948
--- /dev/null
+++ b/doc/qt5.qdocconf
@@ -0,0 +1,76 @@
+# Name of the project.
+project = qtconnectivity
+
+include(qt-cpp-ignore.qdocconf)
+include(qt-defines.qdocconf)
+include(compat.qdocconf)
+include(macros.qdocconf)
+
+# Directories in which to search for files to document and images.
+# By default set to the root directory of the project for sources
+# and headers and qdoc will therefore generate output for each file.
+# Images should be placed in <rootdir>/dic/images and examples in
+# <rootdir>/examples.
+# Paths are relative to the location of this file.
+exampledirs += ../examples/ ../demos/
+headerdirs += ..
+imagedirs += src/images
+sourcedirs += ..
+excludedirs += ../tests
+
+# The following parameters are for creating a qhp file, the qhelpgenerator
+# program can convert the qhp file into a qch file which can be opened in
+# Qt Assistant and/or Qt Creator.
+
+# Defines the name of the project. You cannot use operators (+, =, -) in
+# the name. Properties for this project are set using a qhp.<projectname>.property
+# format.
+qhp.projects = qtconnectivity
+
+# Sets the name of the output qhp file.
+qhp.qtconnectivity.file = qtconnectivity.qhp
+
+# Namespace for the output file. This namespace is used to distinguish between
+# different documentation files in Creator/Assistant. Normal format for MP
+# projects should be: com.nokia.mp.<projectname>.version with version being
+# a number containing a major, minor and revision element. E.g. version 1.0
+# becomes 100.
+qhp.qtconnectivity.namespace = com.nokia.mp.qtconnectivity.100
+
+# Title for the package, will be the main title for the package in
+# Assistant/Creator.
+qhp.qtconnectivity.indexTitle = Qt Local Connectivity Reference Documentation
+
+# Extra files to add to the output which are not linked to from anywhere
+# using a qdoc \l command.
+qhp.qtconnectivity.extraFiles = style/style.css \
+ index.html
+
+# Only update the name of the project for the next variables.
+qhp.qtconnectivity.virtualFolder = qdoc
+qhp.qtconnectivity.subprojects = classes
+qhp.qtconnectivity.subprojects.classes.title = Classes
+qhp.qtconnectivity.subprojects.classes.selectors = class fake:headerfile
+qhp.qtconnectivity.subprojects.classes.sortPages = true
+
+
+
+# Do NOT change the variables after this line unless you know what you are doing.
+
+outputdir = html
+outputformats = HTML
+
+examples.fileextensions = "*.cpp *.h *.js *.svg *.xml *.ui *.qml"
+examples.imageextensions = "*.png *.jpeg *.jpg *.gif *.mng"
+headers.fileextensions = "*.h *.ch *.h++ *.hh *.hpp *.hxx"
+sources.fileextensions = "*.cpp *.qdoc *.mm *.qml"
+
+HTML.nobreadcrumbs = "true"
+
+HTML.templatedir = .
+HTML.stylesheets = style/style.css
+
+HTML.headerstyles = " <link rel=\"stylesheet\" type=\"text/css\" href=\"style/style.css\" />\n"
+HTML.endheader = "</head>\n<body>\n"
+
+HTML.footer = "<div class=\"footer\">Copyright (c) 2011 Nokia Corporation and/or its subsidiaries. All rights reserved.</div>\n"
diff --git a/doc/src/connectivity.qdoc b/doc/src/connectivity.qdoc
new file mode 100644
index 00000000..12f06727
--- /dev/null
+++ b/doc/src/connectivity.qdoc
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\title Qt5 Local Connectivity Reference Documentation
+\page connectivity.html
+\brief The Local Connectivity APIs facilitates communication with local devices.
+
+\tableofcontents
+
+\section1 Overview
+
+The Qt local connectivity addon APIs provides a set of APIs for communicating with local devices.
+
+The current version of the local connectivity APIs includes support for Bluetooth and Near Field
+Communication (NFC) technologies. Bluetooth is a short-range (less than 100 meters) wireless
+technology. It has a reasonably high data transfer rate of 2.1 Mbit/s, which makes it ideal for
+transfering data between devices.
+
+The Bluetooth API provides classes for controlling the local Bluetooth device, discovering devices
+in the local vacinity, discovering services provided by those devices, publishing services and both
+server and client sockets for L2CAP and RFCOMM protocols.
+
+NFC is an extremely short-range (approx. 1 centimeter) wireless techonology and has a maximum
+transfer rate of 424 kbit/s. NFC is ideal for transfer small packets of data when two devices are
+touched together.
+
+The NFC API provides APIs for interacting with NFC Forum Tags and NFC Forum Devices, including
+target detection and loss, registering NDEF message handlers, reading and writing NDEF messages to
+NFC Forum Tags, send tag specific commands. The API also provides client and server LLCP sockets.
+
+\section1 Known Issues and Limitations
+
+\section2 NFC
+
+The NFC API is only supported on Maemo6 and Symbian^3 and the Qt Simulator. On Symbian^3 the API is
+fully functional. On the Qt Simulator only target detection and loss and tag access are support. On
+Maemo6 the following features are \bold NOT supported:
+
+\list
+ \o Connectionless LLCP sockets (both client and server).
+ \o Tag type specific access.
+\endlist
+
+
+\section1 Examples
+
+To get started with the local connectivity APIs see
+\list
+ \o \l{Qt Local Connectivity Examples}{Examples}
+\endlist
+
+\section1 The local connectivity APIs
+
+\section2 Bluetooth C++ Classes
+\annotatedlist connectivity-bluetooth
+\section2 Bluetooth Qt Quick Elements
+\annotatedlist bluetooth-qml
+
+\section2 NFC C++ Classes
+\annotatedlist connectivity-nfc
+\section2 NFC Qt Quick Elements
+\annotatedlist nfc-qml
+
+*/
diff --git a/doc/src/examples.qdoc b/doc/src/examples.qdoc
new file mode 100644
index 00000000..e50b03e7
--- /dev/null
+++ b/doc/src/examples.qdoc
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \page all-examples.html
+ \title Qt Local Connectivity Examples
+
+ The local connectivity APIs are structured in two submodules. These are QtBluetooth and QtNfc. There are a variety of examples that cover the entire range of the the local connectivity api's. You will find them in their own documentation but are also accessible from here.
+
+ \section2 Bluetooth
+ \table 80%
+ \header
+ \o Example
+ \o Description
+ \row
+ \o \l{btchat}{Bluetooth Chat}
+ \o A chat server and client using bluetooth.
+ \row
+ \o \l{bttennis}{Bluetooth Tennis}
+ \o The classic game of \l {http://en.wikipedia.org/wiki/Pong}{Pong}. Supports multiplayer
+ over Bluetooth and touch-to-play functionality on devices that support NFC.
+ \row
+ \o \l{btfiletransfer}{Bluetooth File Transfer}
+ \o Transfer files between Bluetooth devices.
+ \row
+ \o \l{btscanner}{Bluetooth Scanner}
+ \o Scan for Bluetooth devices.
+ \row
+ \o \l{bttennis}{QML Bluetooth Tennis}
+ \o The tennis game using a QML interface to the Bluetooth API. It must connect to an
+ instance of the C++ \l{bttennis}{Bluetooth Tennis} game to play.
+ \row
+ \o \l{btscanner}{QML Bluetooth Scanner}
+ \o A QML implementation of the Bluetooth device scanner.
+ \endtable
+
+ \section2 NFC
+
+ \table 80%
+ \header
+ \o Example
+ \o Description
+ \row
+ \o \l{annotatedurl}{NFC Annotated URL}
+ \o Displays URL along with caption text and an image from from an NFC tag containing a
+ specially formated NDEF message.
+ \row
+ \o \l{ndefeditor}{NDEF Editor}
+ \o Create NDEF messages using the NDEF records supported by the Connectivity API and save
+ them to supported NFC Forum tags.
+ \row
+ \o \l{poster}{QML Poster}
+ \o A QML implementation of the NFC Annotated URL example.
+c \endtable
+
+*/
+
diff --git a/doc/src/examples/annotatedurl.qdoc b/doc/src/examples/annotatedurl.qdoc
new file mode 100644
index 00000000..e2b29dbd
--- /dev/null
+++ b/doc/src/examples/annotatedurl.qdoc
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\example annotatedurl
+\title Annotated URL Example
+
+The Annotated URL example displays the contents of specifically formated NDEF messages read from
+an NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record and one
+or more localized Text records.
+
+\image annotatedurl.png
+*/
diff --git a/doc/src/examples/bluetoothtransferplugin.qdoc b/doc/src/examples/bluetoothtransferplugin.qdoc
new file mode 100644
index 00000000..461b59b0
--- /dev/null
+++ b/doc/src/examples/bluetoothtransferplugin.qdoc
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example bluetoothtransferplugin
+ \title Bluetooth Transfer Plugin Example
+
+ This example shows how to write a service plugin for the \l{Qt Service Framework}{Service Framework}.
+
+ \section1 Registering the Service
+ The service can be registered by using the function \l{QServiceManager::}{addService()}, this takes a path to the XML file that describes the service, \i{bluetoothtransferservice.xml}.
+
+ \section1 Writing the Plugin
+ To implement a plugin it is necessary to create a new plugin class derived from QObject and QServicePluginInterface. The function QServicePluginInterface::createInstance() is implemented to return the appropriate instantiated object based on the interface name passed into the function. Since there is only one interface name for this example there is no test involved, so we can simply create the object implementing the service and return its pointer.
+
+ \snippet ../examples/bluetoothtransferplugin/bluetoothtransferplugin.cpp createinstance
+
+ The implementation of the service BluetoothTransfer is simply a test function for this example. The BluetoothTransfer class is very simple, with only an empty constructor and the sendFile() function
+
+ \snippet ../examples/bluetoothtransferplugin/bluetoothtransfer.cpp sendFile
+
+*/
diff --git a/doc/src/examples/btchat.qdoc b/doc/src/examples/btchat.qdoc
new file mode 100644
index 00000000..cda8e95a
--- /dev/null
+++ b/doc/src/examples/btchat.qdoc
@@ -0,0 +1,191 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example btchat
+ \title Bluetooth Chat Example
+
+ The Bluetooth Chat example shows how to use the Qt Connectivity Bluetooth API to communicate
+ with another application on a remote device using Bluetooth.
+
+ \image btchat-example.png
+
+ The Bluetooth Chat example implements a simple chat program between multiple parties. The
+ application always acts as both a server and a client eliminating the need to determine who
+ should connect to whom.
+
+ \section1 Chat Server
+
+ The chat server is implemented by the ChatServer class. The ChatServer class is declared as:
+
+ \snippet ../examples/btchat/chatserver.h declaration
+
+ The first thing the chat server needs to do is create an instance of QRfcommServer to listen
+ for incoming Bluetooth connections. Our clientConnected() slot will be called whenever a new
+ connection is created.
+
+ \snippet ../examples/btchat/chatserver.cpp Create the server
+
+ The chat server is only useful if others know that it is there. To enable other devices to
+ discover it a record describing the service needs to be published in the systems SDP (Service
+ Discovery Protocol) database. The QBluetoothServiceInfo class encapsulates a service record.
+
+ We will publish a service record that contains some textural descriptions of the services, a
+ UUID that uniquely identifies the service, the discoverability attribute and connection
+ parameters.
+
+ The textural description of the service is stored in the ServiceName, ServiceDescription and
+ ServiceProvider attributes.
+
+ \snippet ../examples/btchat/chatserver.cpp Service name, description and provider
+
+ Bluetooth uses UUIDs as unique identifiers. Our chat service is uses a randomly generated
+ UUID.
+
+ \snippet ../examples/btchat/chatserver.cpp Service UUID
+ \snippet ../examples/btchat/chatserver.cpp Service UUID set
+
+ A Bluetooth service is only discoverable if it is in the PublicBrowseGroup.
+
+ \snippet ../examples/btchat/chatserver.cpp Service Discoverability
+
+ The ProtocolDescriptorList attribute is used to publish the connection parameters that the
+ remote device requires to connect to our service. Here we specify that the Rfcomm protocol is
+ used and set the port number to port that our rfcommServer instance is listening to.
+
+ \snippet ../examples/btchat/chatserver.cpp Protocol descriptor list
+
+ Finally we register the service record with the system.
+
+ \snippet ../examples/btchat/chatserver.cpp Register service
+
+ As mentioned earlier incoming connections are handled in the clientConnected() slot. In this
+ slot we get a pointer a QBluetoothSocket representing the next pending connection connect up
+ slots to the readyRead() and disconnected() signals and emit a signal to notify others that a
+ new client has connected.
+
+ \snippet ../examples/btchat/chatserver.cpp clientConnected
+
+ The readSocket() slot is called whenever data is ready to be read from a client socket. The
+ slot reads individual lines from the socket converts them from UTF-8 and emits the
+ messageReceived() signal.
+
+ \snippet ../examples/btchat/chatserver.cpp readSocket
+
+ The clientDisconnected() slot is called whenever a client disconnects from the service. The
+ slot emits a signal to notify others that a client has disconnected and deletes the socket.
+
+ \snippet ../examples/btchat/chatserver.cpp clientDisconnected
+
+ The sendMessage() slot is used to send a message to all connected clients. The message is
+ converted into UTF-8 and appended with a newline before being sent to all clients.
+
+ \snippet ../examples/btchat/chatserver.cpp sendMessage
+
+ When the chat server is stop the service record is removed from the system SDP database, all
+ connected client sockets are deleted and the QRfcommServer instance is deleted.
+
+ \snippet ../examples/btchat/chatserver.cpp stopServer
+
+ \section1 Chat Client
+
+ The chat client is implemented by the ChatClient class. The ChatClient class is declared as:
+
+ \snippet ../examples/btchat/chatclient.h declaration
+
+ The client creates a new QBluetoothSocket and connects to the remote service described by the
+ \i remoteService parameter. Slots are connected to the sockets readyRead(), connected() and
+ disconnected() signals.
+
+ \snippet ../examples/btchat/chatclient.cpp startClient
+
+ On sucessfull socket connection we emit a signal to notify other.
+
+ \snippet ../examples/btchat/chatclient.cpp connected
+
+ Similarily to the chat server the readSocket() slot is called when data is available from the
+ socket. Lines are read individually and converted from UTF-8. The messageReceived() signal
+ is emitted.
+
+ \snippet ../examples/btchat/chatclient.cpp readSocket
+
+ The sendMessage() slot is used to send a message to the remote device. The message is
+ converted to UTF-8 and a newline appended.
+
+ \snippet ../examples/btchat/chatclient.cpp sendMessage
+
+ To disconnect from the remote chat service the QBluetoothSocket instance is deleted.
+
+ \snippet ../examples/btchat/chatclient.cpp stopClient
+
+ \section1 Chat Dialog
+
+ The main window of this example is the chat dialog, implemented in the Chat class. This class
+ displays a chat session between a single ChatServer and zero or more ChatClients. The Chat
+ class is declared as:
+
+ \snippet ../examples/btchat/chat.h declaration
+
+ First we construct the user interface
+
+ \snippet ../examples/btchat/chat.cpp Construct UI
+
+ We create an instance of the ChatServer and respond to its clientConnected(),
+ clientDiconnected() and messageReceived() signals.
+
+ \snippet ../examples/btchat/chat.cpp Create Chat Server
+
+ In response to the clientConnected() and clientDisconnected() signals of the ChatServer we
+ display the typical "foo has joined chat." and "foo has left." messages in the chat session.
+
+ \snippet ../examples/btchat/chat.cpp clientConnected clientDisconnected
+
+ Incoming messages from clients connected to the ChatServer are handled in the showMessage()
+ slot. The message text tagged with the remote device name is displayed in the chat session.
+
+ \snippet ../examples/btchat/chat.cpp showMessage
+
+ In response to the connect button being clicked the application starts service discovery and
+ presents a list of discovered chat services on remote devices. A ChatClient for the service
+ selected by the user.
+
+ \snippet ../examples/btchat/chat.cpp Connect to remote service
+
+ In reponse to connected() signals from ChatClient we display the a "Joined chat with foo."
+ message in the chat session.
+
+ \snippet ../examples/btchat/chat.cpp connected
+
+ Messages are sent to all remote devices via the ChatServer and ChatClient instances by emitting
+ the sendMessage() signal.
+
+ \snippet ../examples/btchat/chat.cpp sendClicked
+
+ We need to clean up ChatClient instances when the remote device forces a disconnect.
+
+ \snippet ../examples/btchat/chat.cpp clientDisconnected
+*/
diff --git a/doc/src/examples/btfiletransfer.qdoc b/doc/src/examples/btfiletransfer.qdoc
new file mode 100644
index 00000000..b0cf137c
--- /dev/null
+++ b/doc/src/examples/btfiletransfer.qdoc
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example btfiletransfer
+ \title Bluetooth File Transfer Example
+
+ The Bluetooth File Transfer example is an application to transfer files
+ via a bluetooth connection.
+
+ \image btfiletransfer-example.png
+
+*/
diff --git a/doc/src/examples/btscanner.qdoc b/doc/src/examples/btscanner.qdoc
new file mode 100644
index 00000000..a178d6af
--- /dev/null
+++ b/doc/src/examples/btscanner.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example btscanner
+ \title Bluetooth Scanner Example
+
+ An example of how to locate Bluetooth devices.
+
+ \image btscanner-example.png
+
+*/
diff --git a/doc/src/examples/bttennis.qdoc b/doc/src/examples/bttennis.qdoc
new file mode 100644
index 00000000..dff8a614
--- /dev/null
+++ b/doc/src/examples/bttennis.qdoc
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \example bttennis
+ \title Bluetooth Tennis Example
+
+ The Bluetooth Tennis example shows how to use the Qt Connectivity Bluetooth API
+ to implement real-time data transfer for interactive applications.
+
+ \image bttennis-example.png
+
+*/
diff --git a/doc/src/examples/ndefeditor.qdoc b/doc/src/examples/ndefeditor.qdoc
new file mode 100644
index 00000000..d0b4a858
--- /dev/null
+++ b/doc/src/examples/ndefeditor.qdoc
@@ -0,0 +1,36 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\example ndefeditor
+\title NDEF Editor Example
+
+The NDEF Editor example reads and writes NDEF messages to NFC Forum Tags. NDEF messages can be
+composed by adding records of supported types.
+
+\image ndefeditor.png
+*/
diff --git a/doc/src/examples/poster.qdoc b/doc/src/examples/poster.qdoc
new file mode 100644
index 00000000..bd745336
--- /dev/null
+++ b/doc/src/examples/poster.qdoc
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\example poster
+\title QML Poster Example
+
+The QML Poster example displays the contents of specifically formated NDEF messages read from an
+NFC Tag. The NDEF message should contain a URI record, an optional image/* MIME record and one
+or more localized Text records.
+
+\image qml-poster-example.png
+
+*/
diff --git a/doc/src/images/annotatedurl.png b/doc/src/images/annotatedurl.png
new file mode 100644
index 00000000..71739f50
--- /dev/null
+++ b/doc/src/images/annotatedurl.png
Binary files differ
diff --git a/doc/src/images/btchat-example.png b/doc/src/images/btchat-example.png
new file mode 100644
index 00000000..762d49cb
--- /dev/null
+++ b/doc/src/images/btchat-example.png
Binary files differ
diff --git a/doc/src/images/btfiletransfer-example.png b/doc/src/images/btfiletransfer-example.png
new file mode 100644
index 00000000..f98241d6
--- /dev/null
+++ b/doc/src/images/btfiletransfer-example.png
Binary files differ
diff --git a/doc/src/images/btscanner-example.png b/doc/src/images/btscanner-example.png
new file mode 100644
index 00000000..04fe9f3c
--- /dev/null
+++ b/doc/src/images/btscanner-example.png
Binary files differ
diff --git a/doc/src/images/bttennis-example.png b/doc/src/images/bttennis-example.png
new file mode 100644
index 00000000..53a5486b
--- /dev/null
+++ b/doc/src/images/bttennis-example.png
Binary files differ
diff --git a/doc/src/images/ndefeditor.png b/doc/src/images/ndefeditor.png
new file mode 100644
index 00000000..0334dadf
--- /dev/null
+++ b/doc/src/images/ndefeditor.png
Binary files differ
diff --git a/doc/src/images/qml-poster-example.png b/doc/src/images/qml-poster-example.png
new file mode 100644
index 00000000..ab01a31f
--- /dev/null
+++ b/doc/src/images/qml-poster-example.png
Binary files differ
diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc
new file mode 100644
index 00000000..2468b3ae
--- /dev/null
+++ b/doc/src/index.qdoc
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt local connectivty modules.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of
+** this file.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms
+** and conditions contained in a signed written agreement between you
+** and Nokia.
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\title Overview
+\page index.html
+
+
+C++ classes in this project:
+
+\generatelist annotatedclasses
+
+QML classes in this project:
+
+\generatelist qmlclasses
+
+*/
diff --git a/doc/src/snippets/connectivity.pro b/doc/src/snippets/connectivity.pro
new file mode 100644
index 00000000..c0c0bfc6
--- /dev/null
+++ b/doc/src/snippets/connectivity.pro
@@ -0,0 +1,21 @@
+TARGET = connectivity
+TEMPLATE=app
+
+QT += bluetooth nfc
+
+INCLUDEPATH += ../../src/connectivity/nfc
+DEPENDPATH += ../../src/connectivity/nfc
+
+INCLUDEPATH += ../../src/connectivity/bluetooth
+DEPENDPATH += ../../src/connectivity/bluetooth
+
+SOURCES = main.cpp \
+ nfc.cpp \
+ devicediscovery.cpp \
+ servicediscovery.cpp \
+ foorecord.cpp
+
+HEADERS = \
+ foorecord.h
+
+CONFIG += strict_flags
diff --git a/doc/src/snippets/devicediscovery.cpp b/doc/src/snippets/devicediscovery.cpp
new file mode 100644
index 00000000..08936ba9
--- /dev/null
+++ b/doc/src/snippets/devicediscovery.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qbluetoothdevicediscoveryagent.h>
+
+#include <QtCore/QObject>
+
+QTBLUETOOTH_USE_NAMESPACE
+
+class Discoverer : public QObject
+{
+ Q_OBJECT
+
+public:
+ void deviceDiscovery();
+
+private slots:
+ void deviceDiscovered(const QBluetoothDeviceInfo &info);
+};
+
+void Discoverer::deviceDiscovery()
+{
+//! [Device discovery]
+ QBluetoothDeviceDiscoveryAgent *discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);
+
+ connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)),
+ this, SLOT(deviceDiscovered(const QBluetoothDeviceInfo&)));
+
+ // Automatically delete agent when device discovery finishes.
+ connect(discoveryAgent, SIGNAL(finished()), this, SLOT(deleteLater()));
+
+ discoveryAgent->start();
+//! [Device discovery]
+}
+
+void Discoverer::deviceDiscovered(const QBluetoothDeviceInfo &info)
+{
+ Q_UNUSED(info);
+}
diff --git a/doc/src/snippets/foorecord.cpp b/doc/src/snippets/foorecord.cpp
new file mode 100644
index 00000000..85888e78
--- /dev/null
+++ b/doc/src/snippets/foorecord.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "foorecord.h"
+#include <qndefrecord.h>
+
+//! [Declare foo record]
+Q_DECLARE_NDEFRECORD(QDeclarativeNdefFooRecord, QNdefRecord::ExternalRtd, "com.example:f")
+//! [Declare foo record]
+
+//! [createFooRecord]
+static inline QNdefRecord createFooRecord()
+{
+ QNdefRecord foo;
+ foo.setTypeNameFormat(QNdefRecord::ExternalRtd);
+ foo.setType("com.example:f");
+ foo.setPayload(QByteArray(sizeof(int), char(0)));
+ return foo;
+}
+//! [createFooRecord]
+
+//! [copyFooRecord]
+static inline QNdefRecord copyFooRecord(const QNdefRecord &record)
+{
+ if (record.typeNameFormat() != QNdefRecord::ExternalRtd)
+ return createFooRecord();
+ if (record.type() != "com.example:f")
+ return createFooRecord();
+
+ return record;
+}
+//! [copyFooRecord]
+
+//! [Constructors]
+QDeclarativeNdefFooRecord::QDeclarativeNdefFooRecord(QObject *parent)
+: QDeclarativeNdefRecord(createFooRecord(), parent)
+{
+}
+
+QDeclarativeNdefFooRecord::QDeclarativeNdefFooRecord(const QNdefRecord &record, QObject *parent)
+: QDeclarativeNdefRecord(copyFooRecord(record), parent)
+{
+}
+//! [Constructors]
+
+QDeclarativeNdefFooRecord::~QDeclarativeNdefFooRecord()
+{
+}
+
+int QDeclarativeNdefFooRecord::foo() const
+{
+ QByteArray payload = record().payload();
+
+ int value = payload.at(0) << 24 |
+ payload.at(1) << 16 |
+ payload.at(2) << 8 |
+ payload.at(3) << 0;
+
+ return value;
+}
+
+void QDeclarativeNdefFooRecord::setFoo(int value)
+{
+ if (foo() == value)
+ return;
+
+ QByteArray payload;
+ payload[0] = (value >> 24) & 0xff;
+ payload[1] = (value >> 16) & 0xff;
+ payload[2] = (value >> 8) & 0xff;
+ payload[3] = (value >> 0) & 0xff;
+
+ QNdefRecord r = record();
+ r.setPayload(payload);
+ setRecord(r);
+ emit fooChanged();
+}
diff --git a/doc/src/snippets/foorecord.h b/doc/src/snippets/foorecord.h
new file mode 100644
index 00000000..258948d8
--- /dev/null
+++ b/doc/src/snippets/foorecord.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef FOORECORD_H
+#define FOORECORD_H
+
+#include <qdeclarativendefrecord.h>
+
+QTNFC_USE_NAMESPACE
+
+//! [Foo declaration]
+class QDeclarativeNdefFooRecord : public QDeclarativeNdefRecord
+{
+ Q_OBJECT
+
+ Q_PROPERTY(int foo READ foo WRITE setFoo NOTIFY fooChanged)
+
+public:
+ explicit QDeclarativeNdefFooRecord(QObject *parent = 0);
+ Q_INVOKABLE QDeclarativeNdefFooRecord(const QNdefRecord &record, QObject *parent = 0);
+ ~QDeclarativeNdefFooRecord();
+
+ int foo() const;
+ void setFoo(int value);
+
+signals:
+ void fooChanged();
+};
+//! [Foo declaration]
+
+#endif // FOORECORD_H
diff --git a/doc/src/snippets/main.cpp b/doc/src/snippets/main.cpp
new file mode 100644
index 00000000..1530a245
--- /dev/null
+++ b/doc/src/snippets/main.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+int main(int /*argc*/, char ** /*argv*/)
+{
+ return 0;
+}
+
diff --git a/doc/src/snippets/nfc.cpp b/doc/src/snippets/nfc.cpp
new file mode 100644
index 00000000..93244caa
--- /dev/null
+++ b/doc/src/snippets/nfc.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qndefrecord.h>
+#include <qndefnfctextrecord.h>
+
+#include <QtCore/QDebug>
+
+QTNFC_USE_NAMESPACE
+
+void snippet_recordConversion()
+{
+ QNdefRecord record;
+
+ //! [Record conversion]
+ if (record.isRecordType<QNdefNfcTextRecord>()) {
+ QNdefNfcTextRecord textRecord(record);
+
+ qDebug() << textRecord.text();
+ }
+ //! [Record conversion]
+}
+
+//! [Specialized class definition]
+class ExampleComF : public QNdefRecord
+{
+public:
+ Q_DECLARE_NDEF_RECORD(ExampleComF, QNdefRecord::ExternalRtd, "example.com:f",
+ QByteArray(sizeof(int), char(0)))
+
+ int foo() const;
+ void setFoo(int v);
+};
+
+Q_DECLARE_ISRECORDTYPE_FOR_NDEF_RECORD(ExampleComF, QNdefRecord::ExternalRtd, "example.com:f")
+//! [Specialized class definition]
diff --git a/doc/src/snippets/servicediscovery.cpp b/doc/src/snippets/servicediscovery.cpp
new file mode 100644
index 00000000..e43c08a0
--- /dev/null
+++ b/doc/src/snippets/servicediscovery.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qbluetoothservicediscoveryagent.h>
+
+#include <QtCore/QObject>
+
+QTBLUETOOTH_USE_NAMESPACE
+
+class Discoverer : public QObject
+{
+ Q_OBJECT
+
+public:
+ void serviceDiscovery();
+
+private slots:
+ void serviceDiscovered(const QBluetoothServiceInfo &info);
+};
+
+void Discoverer::serviceDiscovery()
+{
+//! [Service discovery]
+ QBluetoothServiceDiscoveryAgent *discoveryAgent = new QBluetoothServiceDiscoveryAgent(this);
+
+ connect(discoveryAgent, SIGNAL(serviceDiscovered(const QBluetoothServiceInfo&)),
+ this, SLOT(serviceDiscovered(const QBluetoothServiceInfo&)));
+
+ // Automatically delete agent when service discovery finishes.
+ connect(discoveryAgent, SIGNAL(finished()), this, SLOT(deleteLater()));
+
+ discoveryAgent->start();
+//! [Service discovery]
+}
+
+void Discoverer::serviceDiscovered(const QBluetoothServiceInfo &info)
+{
+ Q_UNUSED(info);
+}
+
diff --git a/doc/style/style.css b/doc/style/style.css
new file mode 100644
index 00000000..df84049f
--- /dev/null
+++ b/doc/style/style.css
@@ -0,0 +1,137 @@
+a:link, a:visited {
+ color: #00732F;
+ text-decoration: none;
+ font-weight: bold;
+}
+
+body {
+ font: normal 400 14px/1.2 Arial;
+ margin-top: 85px;
+}
+
+h1 {
+ margin: 0;
+}
+
+h2 {
+ font: 500 20px/1.2 Arial;
+}
+
+h3.fn, span.fn {
+ -moz-border-radius: 7px 7px 7px 7px;
+ -webkit-border-radius: 7px 7px 7px 7px;
+ border-radius: 7px 7px 7px 7px;
+ background-color: #F6F6F6;
+ border-width: 1px;
+ border-style: solid;
+ border-color: #E6E6E6;
+ word-spacing: 3px;
+ padding: 3px 5px;
+}
+
+table, pre {
+ -moz-border-radius: 7px 7px 7px 7px;
+ -webkit-border-radius: 7px 7px 7px 7px;
+ border-radius: 7px 7px 7px 7px;
+ background-color: #F6F6F6;
+ border: 1px solid #E6E6E6;
+ border-collapse: separate;
+ font-size: 12px;
+ line-height: 1.2;
+ margin-bottom: 25px;
+ margin-left: 15px;
+}
+
+table td {
+ padding: 3px 15px 3px 20px;
+}
+
+table tr.even {
+ background-color: white;
+ color: #66666E;
+}
+
+table tr.odd {
+ background-color: #F6F6F6;
+ color: #66666E;
+}
+
+li {
+ margin-bottom: 10px;
+ padding-left: 12px;
+}
+
+.cpp {
+ display: block;
+ margin: 10;
+ overflow: hidden;
+ overflow-x: hidden;
+ overflow-y: hidden;
+ padding: 20px 0 20px 0;
+}
+
+.footer {
+ margin-top: 50px;
+}
+
+.memItemLeft {
+ padding-right: 3px;
+}
+
+.memItemRight {
+ padding: 3px 15px 3px 0;
+}
+
+.qml {
+ display: block;
+ margin: 10;
+ overflow: hidden;
+ overflow-x: hidden;
+ overflow-y: hidden;
+ padding: 20px 0 20px 0;
+}
+
+.qmldefault {
+ padding-left: 5px;
+ float: right;
+ color: red;
+}
+
+.qmlreadonly {
+ padding-left: 5px;
+ float: right;
+ color: #254117;
+}
+
+.rightAlign {
+ padding: 3px 5px 3px 10px;
+ text-align: right;
+}
+
+.title {
+ background-color: white;
+ color: #44A51C;
+ font-family: Verdana;
+ font-size: 35px;
+ font-weight: normal;
+ left: 0;
+ padding-bottom: 5px;
+ padding-left: 16px;
+ padding-top: 20px;
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.toc {
+ float: right;
+ -moz-border-radius: 7px 7px 7px 7px;
+ -webkit-border-radius: 7px 7px 7px 7px;
+ border-radius: 7px 7px 7px 7px;
+ background-color: #F6F6F6;
+ border: 1px solid #DDD;
+ margin: 0 20px 10px 10px;
+ padding: 20px 15px 20px 20px;
+ height: auto;
+ width: 200px;
+}
diff --git a/examples/annotatedurl/annotatedurl.cpp b/examples/annotatedurl/annotatedurl.cpp
new file mode 100644
index 00000000..9b608931
--- /dev/null
+++ b/examples/annotatedurl/annotatedurl.cpp
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "annotatedurl.h"
+
+#include <qnearfieldtarget.h>
+#include <qndefmessage.h>
+#include <qndefrecord.h>
+#include <qndefnfctextrecord.h>
+#include <qndefnfcurirecord.h>
+
+#include <QtCore/QUrl>
+#include <QtCore/QLocale>
+
+#include <QGridLayout>
+#include <QLabel>
+#include <QMouseEvent>
+#include <QDesktopServices>
+
+AnnotatedUrl::AnnotatedUrl(QObject *parent)
+: QObject(parent)
+{
+}
+
+AnnotatedUrl::~AnnotatedUrl()
+{
+}
+
+void AnnotatedUrl::handleMessage(const QNdefMessage &message, QNearFieldTarget *target)
+{
+ Q_UNUSED(target);
+
+ enum {
+ MatchedNone,
+ MatchedFirst,
+ MatchedEnglish,
+ MatchedLanguage,
+ MatchedLanguageAndCountry
+ } bestMatch = MatchedNone;
+
+ QLocale defaultLocale;
+
+ QString title;
+ QUrl url;
+ QPixmap pixmap;
+
+ foreach (const QNdefRecord &record, message) {
+ if (record.isRecordType<QNdefNfcTextRecord>()) {
+ QNdefNfcTextRecord textRecord(record);
+
+ QLocale locale(textRecord.locale());
+
+ // already found best match
+ if (bestMatch == MatchedLanguageAndCountry) {
+ // do nothing
+ } else if (bestMatch <= MatchedLanguage && locale == defaultLocale) {
+ title = textRecord.text();
+ bestMatch = MatchedLanguageAndCountry;
+ } else if (bestMatch <= MatchedEnglish &&
+ locale.language() == defaultLocale.language()) {
+ title = textRecord.text();
+ bestMatch = MatchedLanguage;
+ } else if (bestMatch <= MatchedFirst && locale.language() == QLocale::English) {
+ title = textRecord.text();
+ bestMatch = MatchedEnglish;
+ } else if (bestMatch == MatchedNone) {
+ title = textRecord.text();
+ bestMatch = MatchedFirst;
+ }
+ } else if (record.isRecordType<QNdefNfcUriRecord>()) {
+ QNdefNfcUriRecord uriRecord(record);
+
+ url = uriRecord.uri();
+ } else if (record.typeNameFormat() == QNdefRecord::Mime &&
+ record.type().startsWith("image/")) {
+ pixmap = QPixmap::fromImage(QImage::fromData(record.payload()));
+ }
+ }
+
+ emit annotatedUrl(url, title, pixmap);
+}
+
diff --git a/examples/annotatedurl/annotatedurl.h b/examples/annotatedurl/annotatedurl.h
new file mode 100644
index 00000000..5b050105
--- /dev/null
+++ b/examples/annotatedurl/annotatedurl.h
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef ANNOTATEDURL_H
+#define ANNOTATEDURL_H
+
+#include <qnfcglobal.h>
+
+#include <QtCore/QObject>
+
+QT_FORWARD_DECLARE_CLASS(QUrl)
+QT_FORWARD_DECLARE_CLASS(QPixmap)
+
+QTNFC_BEGIN_NAMESPACE
+class QNearFieldTarget;
+class QNdefMessage;
+QTNFC_END_NAMESPACE
+
+QTNFC_USE_NAMESPACE
+
+class AnnotatedUrl : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit AnnotatedUrl(QObject *parent = 0);
+ ~AnnotatedUrl();
+
+signals:
+ void annotatedUrl(const QUrl &url, const QString &title, const QPixmap &pixmap);
+
+public slots:
+ void handleMessage(const QNdefMessage &message, QNearFieldTarget *target);
+};
+
+#endif // ANNOTATEDURL_H
diff --git a/examples/annotatedurl/annotatedurl.pro b/examples/annotatedurl/annotatedurl.pro
new file mode 100644
index 00000000..c9a22afa
--- /dev/null
+++ b/examples/annotatedurl/annotatedurl.pro
@@ -0,0 +1,18 @@
+QT += nfc widgets
+
+CONFIG += strict_flags
+
+INCLUDEPATH += $$PWD/../../src/connectivity/nfc
+DEPENDPATH += $$PWD/../../src/connectivity/nfc
+
+TARGET = annotatedurl
+
+SOURCES += main.cpp \
+ mainwindow.cpp \
+ annotatedurl.cpp
+
+HEADERS += mainwindow.h \
+ annotatedurl.h
+
+FORMS += mainwindow.ui
+
diff --git a/examples/annotatedurl/main.cpp b/examples/annotatedurl/main.cpp
new file mode 100644
index 00000000..55dc6571
--- /dev/null
+++ b/examples/annotatedurl/main.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "annotatedurl.h"
+#include "mainwindow.h"
+
+#include <qnearfieldmanager.h>
+#include <qndefnfctextrecord.h>
+#include <qndefnfcurirecord.h>
+
+#include <QtCore/QLocale>
+
+#include <QApplication>
+
+
+int main(int argc, char *argv[])
+{
+ //QLocale::setDefault(QLocale(QLocale::Japanese));
+
+ QApplication a(argc, argv);
+ MainWindow mainWindow;
+
+ QNearFieldManager manager;
+ AnnotatedUrl annotatedUrl;
+
+ QNdefFilter filter;
+ filter.setOrderMatch(false);
+ filter.appendRecord<QNdefNfcTextRecord>(1, UINT_MAX);
+ filter.appendRecord<QNdefNfcUriRecord>();
+ manager.registerNdefMessageHandler(filter, &annotatedUrl,
+ SLOT(handleMessage(QNdefMessage,QNearFieldTarget*)));
+
+ QObject::connect(&annotatedUrl, SIGNAL(annotatedUrl(QUrl,QString,QPixmap)),
+ &mainWindow, SLOT(displayAnnotatedUrl(QUrl,QString,QPixmap)));
+
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO)
+ mainWindow.showFullScreen();
+#else
+ mainWindow.show();
+#endif
+
+ return a.exec();
+}
diff --git a/examples/annotatedurl/mainwindow.cpp b/examples/annotatedurl/mainwindow.cpp
new file mode 100644
index 00000000..6cd4f00a
--- /dev/null
+++ b/examples/annotatedurl/mainwindow.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QtCore/QUrl>
+#include <QtGui/QMouseEvent>
+#include <QtGui/QDesktopServices>
+
+MainWindow::MainWindow(QWidget *parent)
+: QMainWindow(parent), ui(new Ui::MainWindow)
+{
+ ui->setupUi(this);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::displayAnnotatedUrl(const QUrl &url, const QString &title, const QPixmap &pixmap)
+{
+ ui->m_help->setHidden(true);
+
+ ui->m_url->setText(url.toString());
+ ui->m_title->setText(title);
+ ui->m_image->setPixmap(pixmap);
+}
+
+void MainWindow::mouseReleaseEvent(QMouseEvent *event)
+{
+ if (ui->centralWidget->rect().contains(event->pos()))
+ QDesktopServices::openUrl(QUrl(ui->m_url->text()));
+}
diff --git a/examples/annotatedurl/mainwindow.h b/examples/annotatedurl/mainwindow.h
new file mode 100644
index 00000000..d612c13a
--- /dev/null
+++ b/examples/annotatedurl/mainwindow.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+QT_FORWARD_DECLARE_CLASS(QUrl)
+
+namespace Ui {
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+public slots:
+ void displayAnnotatedUrl(const QUrl &url, const QString &title, const QPixmap &pixmap);
+
+protected:
+ void mouseReleaseEvent(QMouseEvent *event);
+
+private:
+ Ui::MainWindow *ui;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/annotatedurl/mainwindow.ui b/examples/annotatedurl/mainwindow.ui
new file mode 100644
index 00000000..26e3b302
--- /dev/null
+++ b/examples/annotatedurl/mainwindow.ui
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>590</width>
+ <height>420</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MainWindow</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QGridLayout" name="gridLayout" rowstretch="1,0,1" columnstretch="0,0,0">
+ <item row="0" column="1" colspan="2">
+ <widget class="QLabel" name="m_title">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" rowspan="3">
+ <widget class="QLabel" name="m_image">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="m_help">
+ <property name="text">
+ <string>Touch a tag</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1" colspan="2">
+ <widget class="QLabel" name="m_url">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/bluetoothtransferplugin/bluetoothtransfer.cpp b/examples/bluetoothtransferplugin/bluetoothtransfer.cpp
new file mode 100644
index 00000000..87843ffc
--- /dev/null
+++ b/examples/bluetoothtransferplugin/bluetoothtransfer.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtCore>
+
+#include "bluetoothtransfer.h"
+
+BluetoothTransfer::BluetoothTransfer(QObject *parent)
+ : QObject(parent)
+{
+}
+
+//! [sendFile]
+void BluetoothTransfer::sendFile(const QString &path)
+{
+ qDebug() << "BluetoothTransfer::sendFile()" << path;
+}
+//! [sendFile]
diff --git a/examples/bluetoothtransferplugin/bluetoothtransfer.h b/examples/bluetoothtransferplugin/bluetoothtransfer.h
new file mode 100644
index 00000000..95a8969f
--- /dev/null
+++ b/examples/bluetoothtransferplugin/bluetoothtransfer.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BLUETOOTHTRANSFER_H
+#define BLUETOOTHTRANSFER_H
+
+#include <QObject>
+
+class BluetoothTransfer : public QObject
+{
+ Q_OBJECT
+public:
+ BluetoothTransfer(QObject *parent = 0);
+
+public slots:
+ void sendFile(const QString &path);
+};
+
+
+#endif
diff --git a/examples/bluetoothtransferplugin/bluetoothtransferplugin.cpp b/examples/bluetoothtransferplugin/bluetoothtransferplugin.cpp
new file mode 100644
index 00000000..a656ff6a
--- /dev/null
+++ b/examples/bluetoothtransferplugin/bluetoothtransferplugin.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qserviceinterfacedescriptor.h>
+
+#include "bluetoothtransferplugin.h"
+#include "bluetoothtransfer.h"
+
+QObject* BluetoothTransferPlugin::createInstance(const QServiceInterfaceDescriptor& descriptor)
+{
+ Q_UNUSED(descriptor);
+ //! [createinstance]
+ return new BluetoothTransfer(this);
+ //! [createinstance]
+}
+
+Q_EXPORT_PLUGIN2(serviceframework_bluetoothtransferplugin, BluetoothTransferPlugin)
diff --git a/examples/bluetoothtransferplugin/bluetoothtransferplugin.h b/examples/bluetoothtransferplugin/bluetoothtransferplugin.h
new file mode 100644
index 00000000..814df199
--- /dev/null
+++ b/examples/bluetoothtransferplugin/bluetoothtransferplugin.h
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef BLUETOOTHTRANSFERPLUGIN_H
+#define BLUETOOTHTRANSFERPLUGIN_H
+
+#include <QObject>
+
+#include <qserviceplugininterface.h>
+
+class BluetoothTransferPlugin : public QObject,
+ public QServicePluginInterface
+{
+ Q_OBJECT
+ Q_INTERFACES(QServicePluginInterface)
+public:
+ QObject* createInstance(const QServiceInterfaceDescriptor& descriptor);
+};
+
+#endif
diff --git a/examples/bluetoothtransferplugin/bluetoothtransferplugin.pro b/examples/bluetoothtransferplugin/bluetoothtransferplugin.pro
new file mode 100644
index 00000000..214deb41
--- /dev/null
+++ b/examples/bluetoothtransferplugin/bluetoothtransferplugin.pro
@@ -0,0 +1,16 @@
+TEMPLATE = lib
+CONFIG += plugin
+PLUGIN_TYPE=serviceframework
+
+QT += bluetooth serviceframework
+
+HEADERS += bluetoothtransferplugin.h \
+ bluetoothtransfer.h
+SOURCES += bluetoothtransferplugin.cpp \
+ bluetoothtransfer.cpp
+TARGET = serviceframework_bluetoothtransferplugin
+DESTDIR = .
+
+xml.path = $$QT_MOBILITY_EXAMPLES/xmldata
+xml.files = bluetoothtransferservice.xml
+INSTALLS += xml
diff --git a/examples/bluetoothtransferplugin/bluetoothtransferservice.xml b/examples/bluetoothtransferplugin/bluetoothtransferservice.xml
new file mode 100644
index 00000000..eeeb76be
--- /dev/null
+++ b/examples/bluetoothtransferplugin/bluetoothtransferservice.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<SFW version="1.1">
+<service>
+ <name>BluetoothTransferService</name>
+ <filepath>serviceframework_bluetoothtransferplugin</filepath>
+ <description>Example Bluetooth transfer service</description>
+ <interface>
+ <name>com.nokia.qt.examples.FileTransfer</name>
+ <version>1.0</version>
+ <description>Implementation of FileTransferInterface</description>
+ </interface>
+</service>
+</SFW>
diff --git a/examples/btchat/btchat.pro b/examples/btchat/btchat.pro
new file mode 100644
index 00000000..3df3527d
--- /dev/null
+++ b/examples/btchat/btchat.pro
@@ -0,0 +1,27 @@
+TARGET = btchat
+
+QT += bluetooth widgets
+
+INCLUDEPATH += ../../src/connectivity/bluetooth
+DEPENDPATH += ../../src/connectivity/bluetooth
+
+SOURCES = \
+ main.cpp \
+ chat.cpp \
+ remoteselector.cpp \
+ chatserver.cpp \
+ chatclient.cpp
+
+HEADERS = \
+ chat.h \
+ remoteselector.h \
+ chatserver.h \
+ chatclient.h
+
+FORMS = \
+ chat.ui \
+ remoteselector.ui
+
+symbian {
+ TARGET.CAPABILITY = LocalServices UserEnvironment ReadUserData WriteUserData NetworkServices NetworkControl ReadDeviceData WriteDeviceData SwEvent
+}
diff --git a/examples/btchat/chat.cpp b/examples/btchat/chat.cpp
new file mode 100644
index 00000000..4dcb135e
--- /dev/null
+++ b/examples/btchat/chat.cpp
@@ -0,0 +1,179 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "chat.h"
+#include "remoteselector.h"
+#include "chatserver.h"
+#include "chatclient.h"
+
+#include <qbluetoothuuid.h>
+#include <qrfcommserver.h>
+#include <qbluetoothservicediscoveryagent.h>
+#include <qbluetoothdeviceinfo.h>
+#include <qbluetoothlocaldevice.h>
+
+#include <QTimer>
+
+#include <QDebug>
+
+static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8");
+
+Chat::Chat(QWidget *parent)
+: QDialog(parent), ui(new Ui_Chat)
+{
+ //! [Construct UI]
+ ui->setupUi(this);
+
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ setWindowState(Qt::WindowFullScreen);
+#endif
+
+ connect(ui->quitButton, SIGNAL(clicked()), this, SLOT(accept()));
+ connect(ui->connectButton, SIGNAL(clicked()), this, SLOT(connectClicked()));
+ connect(ui->sendButton, SIGNAL(clicked()), this, SLOT(sendClicked()));
+ //! [Construct UI]
+
+ //! [Create Chat Server]
+ server = new ChatServer(this);
+ connect(server, SIGNAL(clientConnected(QString)), this, SLOT(clientConnected(QString)));
+ connect(server, SIGNAL(clientDisconnected(QString)), this, SLOT(clientDisconnected(QString)));
+ connect(server, SIGNAL(messageReceived(QString,QString)),
+ this, SLOT(showMessage(QString,QString)));
+ connect(this, SIGNAL(sendMessage(QString)), server, SLOT(sendMessage(QString)));
+ server->startServer();
+ //! [Create Chat Server]
+
+ //! [Get local device name]
+ localName = QBluetoothLocalDevice().name();
+ //! [Get local device name]
+}
+
+Chat::~Chat()
+{
+ qDeleteAll(clients);
+ delete server;
+}
+
+//! [clientConnected clientDisconnected]
+void Chat::clientConnected(const QString &name)
+{
+ ui->chat->insertPlainText(QString::fromLatin1("%1 has joined chat.\n").arg(name));
+}
+
+void Chat::clientDisconnected(const QString &name)
+{
+ ui->chat->insertPlainText(QString::fromLatin1("%1 has left.\n").arg(name));
+}
+//! [clientConnected clientDisconnected]
+
+//! [connected]
+void Chat::connected(const QString &name)
+{
+ ui->chat->insertPlainText(QString::fromLatin1("Joined chat with %1.\n").arg(name));
+}
+//! [connected]
+
+//! [clientDisconnected]
+void Chat::clientDisconnected()
+{
+ ChatClient *client = qobject_cast<ChatClient *>(sender());
+ if (client) {
+ clients.removeOne(client);
+ client->deleteLater();
+ }
+}
+//! [clientDisconnected]
+
+//! [Connect to remote service]
+void Chat::connectClicked()
+{
+ ui->connectButton->setEnabled(false);
+
+ // scan for services
+ RemoteSelector remoteSelector;
+ remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid));
+ if (remoteSelector.exec() == QDialog::Accepted) {
+ QBluetoothServiceInfo service = remoteSelector.service();
+
+ qDebug() << "Connecting to service 2" << service.serviceName()
+ << "on" << service.device().name();
+
+ // Create client
+ qDebug() << "Going to create client";
+ ChatClient *client = new ChatClient(this);
+qDebug() << "Connecting...";
+
+ connect(client, SIGNAL(messageReceived(QString,QString)),
+ this, SLOT(showMessage(QString,QString)));
+ connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
+ connect(client, SIGNAL(connected(QString)), this, SLOT(connected(QString)));
+ connect(this, SIGNAL(sendMessage(QString)), client, SLOT(sendMessage(QString)));
+qDebug() << "Start client";
+ client->startClient(service);
+
+ clients.append(client);
+ }
+
+ ui->connectButton->setEnabled(true);
+}
+//! [Connect to remote service]
+
+//! [sendClicked]
+void Chat::sendClicked()
+{
+ ui->sendButton->setEnabled(false);
+ ui->sendText->setEnabled(false);
+
+ showMessage(localName, ui->sendText->text());
+ emit sendMessage(ui->sendText->text());
+
+ ui->sendText->clear();
+
+ ui->sendText->setEnabled(true);
+ ui->sendButton->setEnabled(true);
+}
+//! [sendClicked]
+
+//! [showMessage]
+void Chat::showMessage(const QString &sender, const QString &message)
+{
+ ui->chat->insertPlainText(QString::fromLatin1("%1: %2\n").arg(sender, message));
+}
+//! [showMessage]
diff --git a/examples/btchat/chat.h b/examples/btchat/chat.h
new file mode 100644
index 00000000..ff46fff0
--- /dev/null
+++ b/examples/btchat/chat.h
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "ui_chat.h"
+
+#include <QDialog>
+
+#include <qbluetoothserviceinfo.h>
+#include <qbluetoothsocket.h>
+
+#include <QDebug>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QRfcommServer;
+QTBLUETOOTH_END_NAMESPACE
+
+QTBLUETOOTH_USE_NAMESPACE
+
+class ChatServer;
+class ChatClient;
+
+//! [declaration]
+class Chat : public QDialog
+{
+ Q_OBJECT
+
+public:
+ Chat(QWidget *parent = 0);
+ ~Chat();
+
+signals:
+ void sendMessage(const QString &message);
+
+private slots:
+ void connectClicked();
+ void sendClicked();
+
+ void showMessage(const QString &sender, const QString &message);
+
+ void clientConnected(const QString &name);
+ void clientDisconnected(const QString &name);
+ void clientDisconnected();
+ void connected(const QString &name);
+
+private:
+ Ui_Chat *ui;
+
+ ChatServer *server;
+ QList<ChatClient *> clients;
+
+ QString localName;
+};
+//! [declaration]
diff --git a/examples/btchat/chat.ui b/examples/btchat/chat.ui
new file mode 100644
index 00000000..acebc937
--- /dev/null
+++ b/examples/btchat/chat.ui
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Chat</class>
+ <widget class="QDialog" name="Chat">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Bluetooth Chat</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QTextEdit" name="chat">
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="sendText"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="sendButton">
+ <property name="text">
+ <string>Send</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="connectButton">
+ <property name="text">
+ <string>Connect</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QPushButton" name="quitButton">
+ <property name="text">
+ <string>Quit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/btchat/chatclient.cpp b/examples/btchat/chatclient.cpp
new file mode 100644
index 00000000..ceeec732
--- /dev/null
+++ b/examples/btchat/chatclient.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "chatclient.h"
+
+#include <qbluetoothsocket.h>
+
+ChatClient::ChatClient(QObject *parent)
+: QObject(parent), socket(0)
+{
+}
+
+ChatClient::~ChatClient()
+{
+ stopClient();
+}
+
+//! [startClient]
+void ChatClient::startClient(const QBluetoothServiceInfo &remoteService)
+{
+ if (socket)
+ return;
+
+ // Connect to service
+ socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
+ qDebug() << "Create socket";
+ socket->connectToService(remoteService);
+ qDebug() << "ConnecttoService done";
+
+ connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
+ connect(socket, SIGNAL(connected()), this, SLOT(connected()));
+ connect(socket, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
+}
+//! [startClient]
+
+//! [stopClient]
+void ChatClient::stopClient()
+{
+ delete socket;
+ socket = 0;
+}
+//! [stopClient]
+
+//! [readSocket]
+void ChatClient::readSocket()
+{
+ if (!socket)
+ return;
+
+ while (socket->canReadLine()) {
+ QByteArray line = socket->readLine();
+ emit messageReceived(socket->peerName(),
+ QString::fromUtf8(line.constData(), line.length()));
+ }
+}
+//! [readSocket]
+
+//! [sendMessage]
+void ChatClient::sendMessage(const QString &message)
+{
+ QByteArray text = message.toUtf8() + '\n';
+ socket->write(text);
+}
+//! [sendMessage]
+
+//! [connected]
+void ChatClient::connected()
+{
+ emit connected(socket->peerName());
+}
+//! [connected]
diff --git a/examples/btchat/chatclient.h b/examples/btchat/chatclient.h
new file mode 100644
index 00000000..975abb06
--- /dev/null
+++ b/examples/btchat/chatclient.h
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CHATCLIENT_H
+#define CHATCLIENT_H
+
+#include <qbluetoothserviceinfo.h>
+
+#include <QtCore/QObject>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QBluetoothSocket;
+QTBLUETOOTH_END_NAMESPACE
+
+QTBLUETOOTH_USE_NAMESPACE
+
+//! [declaration]
+class ChatClient : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit ChatClient(QObject *parent = 0);
+ ~ChatClient();
+
+ void startClient(const QBluetoothServiceInfo &remoteService);
+ void stopClient();
+
+public slots:
+ void sendMessage(const QString &message);
+
+signals:
+ void messageReceived(const QString &sender, const QString &message);
+ void connected(const QString &name);
+ void disconnected();
+
+private slots:
+ void readSocket();
+ void connected();
+
+private:
+ QBluetoothSocket *socket;
+};
+//! [declaration]
+
+#endif // CHATCLIENT_H
diff --git a/examples/btchat/chatserver.cpp b/examples/btchat/chatserver.cpp
new file mode 100644
index 00000000..9a9ac0b1
--- /dev/null
+++ b/examples/btchat/chatserver.cpp
@@ -0,0 +1,182 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "chatserver.h"
+
+#include <qrfcommserver.h>
+#include <qbluetoothsocket.h>
+
+//! [Service UUID]
+static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c8");
+//! [Service UUID]
+
+ChatServer::ChatServer(QObject *parent)
+: QObject(parent), rfcommServer(0)
+{
+}
+
+ChatServer::~ChatServer()
+{
+ stopServer();
+}
+
+void ChatServer::startServer()
+{
+ if (rfcommServer)
+ return;
+
+ //! [Create the server]
+ rfcommServer = new QRfcommServer(this);
+ connect(rfcommServer, SIGNAL(newConnection()), this, SLOT(clientConnected()));
+ rfcommServer->listen();
+ //! [Create the server]
+
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceRecordHandle, (uint)0x00010010);
+
+ //! [Class Uuuid must contain at least 1 entry]
+ QBluetoothServiceInfo::Sequence classId;
+ classId << QVariant::fromValue(QBluetoothUuid(serviceUuid));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceClassIds, classId);
+ //! [Class Uuuid must contain at least 1 entry]
+
+
+ //! [Service name, description and provider]
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceName, tr("Bt Chat Server"));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceDescription,
+ tr("Example bluetooth chat server"));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ServiceProvider, tr("Nokia, QtDF"));
+ //! [Service name, description and provider]
+
+ //! [Service UUID set]
+ serviceInfo.setServiceUuid(QBluetoothUuid(serviceUuid));
+ //! [Service UUID set]
+
+ //! [Service Discoverability]
+ serviceInfo.setAttribute(QBluetoothServiceInfo::BrowseGroupList,
+ QBluetoothUuid(QBluetoothUuid::PublicBrowseGroup));
+ //! [Service Discoverability]
+
+ //! [Protocol descriptor list]
+ QBluetoothServiceInfo::Sequence protocolDescriptorList;
+ QBluetoothServiceInfo::Sequence protocol;
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::L2cap));
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ protocol.clear();
+ protocol << QVariant::fromValue(QBluetoothUuid(QBluetoothUuid::Rfcomm))
+ << QVariant::fromValue(quint8(rfcommServer->serverPort()));
+ protocolDescriptorList.append(QVariant::fromValue(protocol));
+ serviceInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
+ protocolDescriptorList);
+ //! [Protocol descriptor list]
+
+ //! [Register service]
+ serviceInfo.registerService();
+ //! [Register service]
+}
+
+//! [stopServer]
+void ChatServer::stopServer()
+{
+ // Unregister service
+ serviceInfo.unregisterService();
+
+ // Close sockets
+ qDeleteAll(clientSockets);
+
+ // Close server
+ delete rfcommServer;
+ rfcommServer = 0;
+}
+//! [stopServer]
+
+//! [sendMessage]
+void ChatServer::sendMessage(const QString &message)
+{
+ QByteArray text = message.toUtf8() + '\n';
+
+ foreach (QBluetoothSocket *socket, clientSockets)
+ socket->write(text);
+}
+//! [sendMessage]
+
+//! [clientConnected]
+void ChatServer::clientConnected()
+{
+ QBluetoothSocket *socket = rfcommServer->nextPendingConnection();
+ if (!socket)
+ return;
+
+ connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
+ connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
+ clientSockets.append(socket);
+
+ emit clientConnected(socket->peerName());
+}
+//! [clientConnected]
+
+//! [clientDisconnected]
+void ChatServer::clientDisconnected()
+{
+ QBluetoothSocket *socket = qobject_cast<QBluetoothSocket *>(sender());
+ if (!socket)
+ return;
+
+ emit clientDisconnected(socket->peerName());
+
+ clientSockets.removeOne(socket);
+
+ socket->deleteLater();
+}
+//! [clientDisconnected]
+
+//! [readSocket]
+void ChatServer::readSocket()
+{
+ QBluetoothSocket *socket = qobject_cast<QBluetoothSocket *>(sender());
+ if (!socket)
+ return;
+
+ while (socket->canReadLine()) {
+ QByteArray line = socket->readLine().trimmed();
+ emit messageReceived(socket->peerName(),
+ QString::fromUtf8(line.constData(), line.length()));
+ }
+}
+//! [readSocket]
diff --git a/examples/btchat/chatserver.h b/examples/btchat/chatserver.h
new file mode 100644
index 00000000..cdab7310
--- /dev/null
+++ b/examples/btchat/chatserver.h
@@ -0,0 +1,88 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef CHATSERVER_H
+#define CHATSERVER_H
+
+#include <qbluetoothserviceinfo.h>
+
+#include <QtCore/QObject>
+#include <QtCore/QList>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QRfcommServer;
+class QBluetoothSocket;
+QTBLUETOOTH_END_NAMESPACE
+
+QTBLUETOOTH_USE_NAMESPACE
+
+//! [declaration]
+class ChatServer : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit ChatServer(QObject *parent = 0);
+ ~ChatServer();
+
+ void startServer();
+ void stopServer();
+
+public slots:
+ void sendMessage(const QString &message);
+
+signals:
+ void messageReceived(const QString &sender, const QString &message);
+ void clientConnected(const QString &name);
+ void clientDisconnected(const QString &name);
+
+private slots:
+ void clientConnected();
+ void clientDisconnected();
+ void readSocket();
+
+private:
+ QRfcommServer *rfcommServer;
+ QBluetoothServiceInfo serviceInfo;
+ QList<QBluetoothSocket *> clientSockets;
+};
+//! [declaration]
+
+#endif // CHATSERVER_H
diff --git a/examples/btchat/main.cpp b/examples/btchat/main.cpp
new file mode 100644
index 00000000..10032ca8
--- /dev/null
+++ b/examples/btchat/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "chat.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ Chat d;
+ QObject::connect(&d, SIGNAL(accepted()), &app, SLOT(quit()));
+
+#if defined(Q_WS_MAEMO_6) || defined(Q_OS_SYMBIAN)
+ d.showFullScreen();
+#else
+ d.show();
+#endif
+
+ app.exec();
+
+ return 0;
+}
+
diff --git a/examples/btchat/remoteselector.cpp b/examples/btchat/remoteselector.cpp
new file mode 100644
index 00000000..cc009dd6
--- /dev/null
+++ b/examples/btchat/remoteselector.cpp
@@ -0,0 +1,146 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "remoteselector.h"
+#include "ui_remoteselector.h"
+
+#include <qbluetoothdeviceinfo.h>
+#include <qbluetoothaddress.h>
+
+QTBLUETOOTH_USE_NAMESPACE
+
+RemoteSelector::RemoteSelector(QWidget *parent)
+: QDialog(parent), ui(new Ui::RemoteSelector),
+ m_discoveryAgent(new QBluetoothServiceDiscoveryAgent)
+{
+ ui->setupUi(this);
+
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ setWindowState(Qt::WindowFullScreen);
+#endif
+
+ connect(m_discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
+ this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
+ connect(m_discoveryAgent, SIGNAL(finished()), this, SLOT(discoveryFinished()));
+}
+
+RemoteSelector::~RemoteSelector()
+{
+ delete ui;
+}
+
+void RemoteSelector::startDiscovery(const QBluetoothUuid &uuid)
+{
+ if (m_discoveryAgent->isActive())
+ m_discoveryAgent->stop();
+
+ ui->remoteDevices->clear();
+
+ m_discoveryAgent->setUuidFilter(uuid);
+ m_discoveryAgent->start();
+
+ ui->status->setText(tr("Scanning..."));
+}
+
+void RemoteSelector::stopDiscovery()
+{
+ if (m_discoveryAgent){
+ m_discoveryAgent->stop();
+ }
+}
+
+QBluetoothServiceInfo RemoteSelector::service() const
+{
+ return m_service;
+}
+
+void RemoteSelector::serviceDiscovered(const QBluetoothServiceInfo &serviceInfo)
+{
+#if 0
+ qDebug() << "Discovered service on"
+ << serviceInfo.device().name() << serviceInfo.device().address().toString();
+ qDebug() << "\tService name:" << serviceInfo.serviceName();
+ qDebug() << "\tDescription:"
+ << serviceInfo.attribute(QBluetoothServiceInfo::ServiceDescription).toString();
+ qDebug() << "\tProvider:"
+ << serviceInfo.attribute(QBluetoothServiceInfo::ServiceProvider).toString();
+ qDebug() << "\tL2CAP protocol service multiplexer:"
+ << serviceInfo.protocolServiceMultiplexer();
+ qDebug() << "\tRFCOMM server channel:" << serviceInfo.serverChannel();
+#endif
+ QMapIterator<QListWidgetItem *, QBluetoothServiceInfo> i(m_discoveredServices);
+ while (i.hasNext()){
+ i.next();
+ if (serviceInfo.device().address() == i.value().device().address()){
+ return;
+ }
+ }
+
+ QString remoteName;
+ if (serviceInfo.device().name().isEmpty())
+ remoteName = serviceInfo.device().address().toString();
+ else
+ remoteName = serviceInfo.device().name();
+
+ QListWidgetItem *item =
+ new QListWidgetItem(QString::fromLatin1("%1 %2").arg(remoteName,
+ serviceInfo.serviceName()));
+
+ m_discoveredServices.insert(item, serviceInfo);
+ ui->remoteDevices->addItem(item);
+}
+
+void RemoteSelector::discoveryFinished()
+{
+ ui->status->setText(tr("Select the chat service to connect to."));
+}
+
+void RemoteSelector::on_remoteDevices_itemActivated(QListWidgetItem *item)
+{
+ qDebug() << "got click" << item->text();
+ m_service = m_discoveredServices.value(item);
+
+ accept();
+}
+
+void RemoteSelector::on_cancelButton_clicked()
+{
+ reject();
+}
diff --git a/examples/btchat/remoteselector.h b/examples/btchat/remoteselector.h
new file mode 100644
index 00000000..8125de0d
--- /dev/null
+++ b/examples/btchat/remoteselector.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REMOTESELECTOR_H
+#define REMOTESELECTOR_H
+
+#include <QDialog>
+
+#include <qbluetoothuuid.h>
+#include <qbluetoothserviceinfo.h>
+#include <qbluetoothservicediscoveryagent.h>
+
+QT_FORWARD_DECLARE_CLASS(QModelIndex)
+QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
+
+QTBLUETOOTH_USE_NAMESPACE
+
+namespace Ui {
+ class RemoteSelector;
+}
+
+class RemoteSelector : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit RemoteSelector(QWidget *parent = 0);
+ ~RemoteSelector();
+
+ void startDiscovery(const QBluetoothUuid &uuid);
+ void stopDiscovery();
+ QBluetoothServiceInfo service() const;
+
+private:
+ Ui::RemoteSelector *ui;
+
+ QBluetoothServiceDiscoveryAgent *m_discoveryAgent;
+ QBluetoothServiceInfo m_service;
+ QMap<QListWidgetItem *, QBluetoothServiceInfo> m_discoveredServices;
+
+private slots:
+ void serviceDiscovered(const QBluetoothServiceInfo &serviceInfo);
+ void discoveryFinished();
+ void on_remoteDevices_itemActivated(QListWidgetItem *item);
+ void on_cancelButton_clicked();
+};
+
+#endif // REMOTESELECTOR_H
diff --git a/examples/btchat/remoteselector.ui b/examples/btchat/remoteselector.ui
new file mode 100644
index 00000000..d415f416
--- /dev/null
+++ b/examples/btchat/remoteselector.ui
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RemoteSelector</class>
+ <widget class="QDialog" name="RemoteSelector">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Available chat services</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="status">
+ <property name="text">
+ <string>Scanning...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="remoteDevices"/>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/btfiletransfer/btfiletransfer.pro b/examples/btfiletransfer/btfiletransfer.pro
new file mode 100644
index 00000000..7d823a17
--- /dev/null
+++ b/examples/btfiletransfer/btfiletransfer.pro
@@ -0,0 +1,34 @@
+TARGET = btfiletransfer
+
+QT += bluetooth widgets
+
+INCLUDEPATH += ../../src/connectivity/bluetooth
+DEPENDPATH += ../../src/connectivity/bluetooth
+
+SOURCES = \
+ main.cpp \
+ remoteselector.cpp \
+ progress.cpp \
+ pindisplay.cpp
+
+HEADERS = \
+ remoteselector.h \
+ progress.h \
+ pindisplay.h
+
+FORMS = \
+ remoteselector.ui \
+ progress.ui \
+ pindisplay.ui
+
+
+symbian {
+ TARGET.CAPABILITY = LocalServices UserEnvironment ReadUserData WriteUserData NetworkServices ReadDeviceData WriteDeviceData
+}
+
+OTHER_FILES += \
+ busy.gif \
+ pairing.gif
+
+RESOURCES += \
+ btfiletransfer.qrc
diff --git a/examples/btfiletransfer/btfiletransfer.qrc b/examples/btfiletransfer/btfiletransfer.qrc
new file mode 100644
index 00000000..10697d5b
--- /dev/null
+++ b/examples/btfiletransfer/btfiletransfer.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/icons">
+ <file>busy.gif</file>
+ <file>pairing.gif</file>
+ </qresource>
+</RCC>
diff --git a/examples/btfiletransfer/busy.gif b/examples/btfiletransfer/busy.gif
new file mode 100644
index 00000000..e192ca89
--- /dev/null
+++ b/examples/btfiletransfer/busy.gif
Binary files differ
diff --git a/examples/btfiletransfer/main.cpp b/examples/btfiletransfer/main.cpp
new file mode 100644
index 00000000..09621b23
--- /dev/null
+++ b/examples/btfiletransfer/main.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "remoteselector.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ RemoteSelector d;
+ QObject::connect(&d, SIGNAL(accepted()), &app, SLOT(quit()));
+ d.startDiscovery();
+#ifdef Q_OS_SYMBIAN
+ d.showFullScreen();
+#else
+ d.show();
+#endif
+
+ app.exec();
+
+ return 0;
+}
+
diff --git a/examples/btfiletransfer/pairing.gif b/examples/btfiletransfer/pairing.gif
new file mode 100644
index 00000000..e147f3ec
--- /dev/null
+++ b/examples/btfiletransfer/pairing.gif
Binary files differ
diff --git a/examples/btfiletransfer/pindisplay.cpp b/examples/btfiletransfer/pindisplay.cpp
new file mode 100644
index 00000000..13bd091a
--- /dev/null
+++ b/examples/btfiletransfer/pindisplay.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "pindisplay.h"
+#include "ui_pindisplay.h"
+
+pinDisplay::pinDisplay(QString title, QString pin, QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::pinDisplay)
+{
+ ui->setupUi(this);
+ ui->label->setText(title);
+ ui->pin->setText(pin);
+
+ connect(ui->buttonBox, SIGNAL(accepted()), this, SIGNAL(accepted()));
+ connect(ui->buttonBox, SIGNAL(rejected()), this, SIGNAL(rejected()));
+}
+
+pinDisplay::~pinDisplay()
+{
+ delete ui;
+}
+
+void pinDisplay::on_buttonBox_accepted()
+{
+ deleteLater();
+}
+
+void pinDisplay::setOkCancel()
+{
+ ui->buttonBox->addButton(QDialogButtonBox::Cancel);
+}
diff --git a/examples/btfiletransfer/pindisplay.h b/examples/btfiletransfer/pindisplay.h
new file mode 100644
index 00000000..9a251042
--- /dev/null
+++ b/examples/btfiletransfer/pindisplay.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PINDISPLAY_H
+#define PINDISPLAY_H
+
+#include <QDialog>
+
+namespace Ui {
+ class pinDisplay;
+}
+
+class pinDisplay : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit pinDisplay(QString title, QString pin, QWidget *parent = 0);
+ ~pinDisplay();
+
+ void setOkCancel();
+
+private Q_SLOTS:
+ void on_buttonBox_accepted();
+
+private:
+ Ui::pinDisplay *ui;
+};
+
+#endif // PINDISPLAY_H
diff --git a/examples/btfiletransfer/pindisplay.ui b/examples/btfiletransfer/pindisplay.ui
new file mode 100644
index 00000000..02bf7d50
--- /dev/null
+++ b/examples/btfiletransfer/pindisplay.ui
@@ -0,0 +1,89 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>pinDisplay</class>
+ <widget class="QDialog" name="pinDisplay">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>240</width>
+ <height>153</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Enter Pin Code</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="pin">
+ <property name="font">
+ <font>
+ <family>Monospace</family>
+ <pointsize>24</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>012345</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>pinDisplay</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>pinDisplay</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/examples/btfiletransfer/progress.cpp b/examples/btfiletransfer/progress.cpp
new file mode 100644
index 00000000..77f16c1a
--- /dev/null
+++ b/examples/btfiletransfer/progress.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "progress.h"
+#include "ui_progress.h"
+
+#include <qbluetoothdeviceinfo.h>
+#include <qbluetoothaddress.h>
+#include <qbluetoothtransferrequest.h>
+#include <qbluetoothtransferreply.h>
+
+QTBLUETOOTH_USE_NAMESPACE
+
+Progress::Progress(QWidget *parent) :
+ QDialog(parent),
+ ui(new Ui::Progress)
+{
+ ui->setupUi(this);
+ ui->progressBar->setRange(0, 1);
+ connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close()));
+}
+
+Progress::~Progress()
+{
+ delete ui;
+}
+
+void Progress::setStatus(QString title, QString filename) {
+ ui->titleLabel->setText(title);
+ ui->statusLabel->setText(filename);
+}
+
+void Progress::finished(QBluetoothTransferReply *reply){
+ if (reply->error() != QBluetoothTransferReply::NoError){
+ ui->progressBar->setDisabled(true);
+ ui->statusLabel->setText(tr("Failed: %1").arg(reply->errorString()));
+ }
+ else {
+ ui->statusLabel->setText(tr("Transfer complete"));
+ }
+ ui->cancelButton->setText(tr("Dismiss"));
+}
+
+void Progress::uploadProgress(qint64 bytesSent, qint64 bytesTotal)
+{
+ if (bytesSent == 0){
+ start.start();
+ }
+
+ ui->progressBar->setMaximum(bytesTotal);
+ ui->progressBar->setValue(bytesSent);
+ if (bytesSent && bytesTotal &&
+ (start.elapsed() > 1000) &&
+ (bytesSent > start.elapsed()/1000)) {
+
+ ui->statusLabel->setText(tr("Transferring...ETA: %1s")
+ .arg(((bytesTotal-bytesSent)/(bytesSent/(start.elapsed()/1000)))));
+ }
+}
+
diff --git a/examples/btfiletransfer/progress.h b/examples/btfiletransfer/progress.h
new file mode 100644
index 00000000..07faa76e
--- /dev/null
+++ b/examples/btfiletransfer/progress.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef PROGRESS_H
+#define PROGRESS_H
+
+#include <QDialog>
+#include <qbluetoothglobal.h>
+#include <QTime>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QBluetoothTransferReply;
+QTBLUETOOTH_END_NAMESPACE
+
+QTBLUETOOTH_USE_NAMESPACE
+
+namespace Ui {
+ class Progress;
+}
+
+class Progress : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit Progress(QWidget *parent = 0);
+ ~Progress();
+
+ void setStatus(QString title, QString filename);
+
+public Q_SLOTS:
+ void finished(QBluetoothTransferReply *);
+ void uploadProgress(qint64 bytesSent, qint64 bytesTotal);
+
+private:
+ Ui::Progress *ui;
+
+ QTime start;
+};
+
+#endif // PROGRESS_H
diff --git a/examples/btfiletransfer/progress.ui b/examples/btfiletransfer/progress.ui
new file mode 100644
index 00000000..3b151f06
--- /dev/null
+++ b/examples/btfiletransfer/progress.ui
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Progress</class>
+ <widget class="QDialog" name="Progress">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>408</width>
+ <height>115</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Transfer Progress</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="titleLabel">
+ <property name="text">
+ <string>Filename</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="minimumSize">
+ <size>
+ <width>390</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="value">
+ <number>24</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="statusLabel">
+ <property name="text">
+ <string>Status</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/btfiletransfer/remoteselector.cpp b/examples/btfiletransfer/remoteselector.cpp
new file mode 100644
index 00000000..ca49d9c3
--- /dev/null
+++ b/examples/btfiletransfer/remoteselector.cpp
@@ -0,0 +1,372 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "remoteselector.h"
+#include "ui_remoteselector.h"
+
+#include <qbluetoothdeviceinfo.h>
+#include <qbluetoothaddress.h>
+#include <qbluetoothtransferrequest.h>
+#include <qbluetoothtransferreply.h>
+#include <qbluetoothlocaldevice.h>
+
+#include <QMovie>
+#include <QMessageBox>
+#include <QFileDialog>
+#include <QCheckBox>
+
+#include "progress.h"
+#include "pindisplay.h"
+
+QTBLUETOOTH_USE_NAMESPACE
+
+RemoteSelector::RemoteSelector(QWidget *parent)
+: QDialog(parent), ui(new Ui::RemoteSelector),
+ m_discoveryAgent(new QBluetoothServiceDiscoveryAgent), m_localDevice(new QBluetoothLocalDevice), m_pindisplay(0)
+{
+ ui->setupUi(this);
+
+ connect(m_discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
+ this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
+ connect(m_discoveryAgent, SIGNAL(finished()), this, SLOT(discoveryFinished()));
+
+ ui->remoteDevices->setColumnWidth(3, 75);
+ ui->remoteDevices->setColumnWidth(4, 100);
+
+ connect(m_localDevice, SIGNAL(pairingDisplayPinCode(const QBluetoothAddress &,QString)), this, SLOT(displayPin(const QBluetoothAddress &, QString)));
+ connect(m_localDevice, SIGNAL(pairingDisplayConfirmation(QBluetoothAddress,QString)), this, SLOT(displayConfirmation(QBluetoothAddress,QString)));
+ connect(m_localDevice, SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)), this, SLOT(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)));
+
+ ui->busyWidget->setMovie(new QMovie(":/icons/busy.gif"));
+ ui->busyWidget->movie()->start();
+
+ ui->pairingBusy->setMovie(new QMovie(":/icons/pairing.gif"));
+ ui->pairingBusy->hide();
+
+ ui->remoteDevices->clearContents();
+ ui->remoteDevices->setRowCount(0);
+
+
+}
+
+RemoteSelector::~RemoteSelector()
+{
+ delete ui;
+ delete m_discoveryAgent;
+ delete m_localDevice;
+}
+
+void RemoteSelector::startDiscovery(const QBluetoothUuid &uuid)
+{
+ ui->stopButton->setDisabled(false);
+ if (m_discoveryAgent->isActive())
+ m_discoveryAgent->stop();
+
+ m_discoveryAgent->setUuidFilter(uuid);
+ m_discoveryAgent->start();
+
+ ui->status->setText(tr("Scanning..."));
+ ui->busyWidget->show();
+ ui->busyWidget->movie()->start();
+}
+
+QBluetoothServiceInfo RemoteSelector::service() const
+{
+ return m_service;
+}
+
+void RemoteSelector::serviceDiscovered(const QBluetoothServiceInfo &serviceInfo)
+{
+#if 0
+ qDebug() << "Discovered service on"
+ << serviceInfo.device().name() << serviceInfo.device().address().toString();
+ qDebug() << "\tService name:" << serviceInfo.serviceName();
+ qDebug() << "\tDescription:"
+ << serviceInfo.attribute(QBluetoothServiceInfo::ServiceDescription).toString();
+ qDebug() << "\tProvider:"
+ << serviceInfo.attribute(QBluetoothServiceInfo::ServiceProvider).toString();
+ qDebug() << "\tL2CAP protocol service multiplexer:"
+ << serviceInfo.protocolServiceMultiplexer();
+ qDebug() << "\tRFCOMM server channel:" << serviceInfo.serverChannel();
+#endif
+
+ QString remoteName;
+ if (serviceInfo.device().name().isEmpty())
+ remoteName = serviceInfo.device().address().toString();
+ else
+ remoteName = serviceInfo.device().name();
+
+// QListWidgetItem *item =
+// new QListWidgetItem(QString::fromLatin1("%1\t%2\t%3").arg(serviceInfo.device().address().toString(),
+// serviceInfo.device().name(), serviceInfo.serviceName()));
+
+ QMutableMapIterator<int, QBluetoothServiceInfo> i(m_discoveredServices);
+ while (i.hasNext()){
+ i.next();
+ if (serviceInfo.device().address() == i.value().device().address()){
+ i.setValue(serviceInfo);
+ return;
+ }
+ }
+
+ int row = ui->remoteDevices->rowCount();
+ ui->remoteDevices->insertRow(row);
+ QTableWidgetItem *item = new QTableWidgetItem(serviceInfo.device().address().toString());
+ ui->remoteDevices->setItem(row, 0, item);
+ item = new QTableWidgetItem(serviceInfo.device().name());
+ ui->remoteDevices->setItem(row, 1, item);
+ item = new QTableWidgetItem(serviceInfo.serviceName());
+
+ ui->remoteDevices->setItem(row, 2, item);
+
+ QBluetoothLocalDevice::Pairing p;
+
+ p = m_localDevice->pairingStatus(serviceInfo.device().address());
+
+ ui->remoteDevices->blockSignals(true);
+
+ item = new QTableWidgetItem();
+ if ((p&QBluetoothLocalDevice::Paired) || (p&QBluetoothLocalDevice::AuthorizedPaired))
+ item->setCheckState(Qt::Checked);
+ else
+ item->setCheckState(Qt::Unchecked);
+ ui->remoteDevices->setItem(row, 3, item);
+
+ item = new QTableWidgetItem();
+ if (p&QBluetoothLocalDevice::AuthorizedPaired)
+ item->setCheckState(Qt::Checked);
+ else
+ item->setCheckState(Qt::Unchecked);
+
+ ui->remoteDevices->setItem(row, 4, item);
+
+ ui->remoteDevices->blockSignals(false);
+
+
+ m_discoveredServices.insert(row, serviceInfo);
+}
+
+void RemoteSelector::discoveryFinished()
+{
+ ui->status->setText(tr("Select the device to send to."));
+ ui->stopButton->setDisabled(true);
+ ui->busyWidget->movie()->stop();
+ ui->busyWidget->hide();
+}
+
+void RemoteSelector::startDiscovery()
+{
+ startDiscovery(QBluetoothUuid(QBluetoothUuid::ObexObjectPush));
+}
+
+void RemoteSelector::on_refreshPB_clicked()
+{
+ startDiscovery();
+ ui->stopButton->setDisabled(false);
+}
+
+void RemoteSelector::on_fileSelectPB_clicked()
+{
+ ui->fileName->setText(QFileDialog::getOpenFileName());
+ if (m_service.isValid())
+ ui->sendButton->setDisabled(false);
+}
+
+void RemoteSelector::on_sendButton_clicked()
+{
+ QBluetoothTransferManager mgr;
+ QBluetoothTransferRequest req(m_service.device().address());
+
+ m_file = new QFile(ui->fileName->text());
+
+ Progress *p = new Progress;
+ p->setStatus("Sending to: " + m_service.device().name(), "Waiting for start");
+ p->show();
+
+ QBluetoothTransferReply *reply = mgr.put(req, m_file);
+ if (reply->error()){
+ qDebug() << "Failed to send file";
+ delete reply;
+ p->finished(reply);
+ return;
+ }
+
+ connect(reply, SIGNAL(uploadProgress(qint64,qint64)), p, SLOT(uploadProgress(qint64,qint64)));
+ connect(reply, SIGNAL(finished(QBluetoothTransferReply*)), p, SLOT(finished(QBluetoothTransferReply*)));
+ connect(p, SIGNAL(rejected()), reply, SLOT(abort()));
+}
+
+void RemoteSelector::on_stopButton_clicked()
+{
+ m_discoveryAgent->stop();
+}
+
+QString RemoteSelector::addressToName(const QBluetoothAddress &address)
+{
+ QMapIterator<int, QBluetoothServiceInfo> i(m_discoveredServices);
+ while (i.hasNext()){
+ i.next();
+ if (i.value().device().address() == address)
+ return i.value().device().name();
+ }
+ return address.toString();
+}
+
+void RemoteSelector::displayPin(const QBluetoothAddress &address, QString pin)
+{
+ if (m_pindisplay)
+ m_pindisplay->deleteLater();
+ m_pindisplay = new pinDisplay(QString("Enter pairing pin on: %1").arg(addressToName(address)), pin, this);
+ m_pindisplay->show();
+}
+
+void RemoteSelector::displayConfirmation(const QBluetoothAddress &address, QString pin)
+{
+ Q_UNUSED(address);
+
+ if (m_pindisplay)
+ m_pindisplay->deleteLater();
+ m_pindisplay = new pinDisplay(QString("Confirm this pin is the same"), pin, this);
+ connect(m_pindisplay, SIGNAL(accepted()), this, SLOT(displayConfAccepted()));
+ connect(m_pindisplay, SIGNAL(rejected()), this, SLOT(displayConfReject()));
+ m_pindisplay->setOkCancel();
+ m_pindisplay->show();
+}
+
+void RemoteSelector::displayConfAccepted()
+{
+ m_localDevice->pairingConfirmation(true);
+}
+void RemoteSelector::displayConfReject()
+{
+ m_localDevice->pairingConfirmation(false);
+}
+
+void RemoteSelector::pairingFinished(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing status)
+{
+ QBluetoothServiceInfo service;
+ int row = 0;
+
+ ui->pairingBusy->hide();
+ ui->pairingBusy->movie()->stop();
+
+ ui->remoteDevices->blockSignals(true);
+
+ for (int i = 0; i < m_discoveredServices.count(); i++){
+ if (m_discoveredServices.value(i).device().address() == address){
+ service = m_discoveredServices.value(i);
+ row = i;
+ break;
+ }
+ }
+
+ if (m_pindisplay)
+ delete m_pindisplay;
+
+ QMessageBox msgBox;
+ if (status == QBluetoothLocalDevice::Paired ||
+ status == QBluetoothLocalDevice::AuthorizedPaired){
+ msgBox.setText("Paired successfully with" + address.toString());
+ }
+ else {
+ msgBox.setText("Pairing failed with " + address.toString());
+ }
+
+ if (service.isValid()){
+ if (status == QBluetoothLocalDevice::AuthorizedPaired){
+ ui->remoteDevices->item(row, 3)->setCheckState(Qt::Checked);
+ ui->remoteDevices->item(row, 4)->setCheckState(Qt::Checked);
+ }
+ else if (status == QBluetoothLocalDevice::Paired){
+ ui->remoteDevices->item(row, 3)->setCheckState(Qt::Checked);
+ ui->remoteDevices->item(row, 4)->setCheckState(Qt::Unchecked);
+ }
+ else {
+ ui->remoteDevices->item(row, 3)->setCheckState(Qt::Unchecked);
+ ui->remoteDevices->item(row, 4)->setCheckState(Qt::Unchecked);
+ }
+ }
+
+ msgBox.exec();
+
+ ui->remoteDevices->blockSignals(false);
+
+
+}
+
+void RemoteSelector::on_remoteDevices_cellClicked(int row, int column)
+{
+ Q_UNUSED(column);
+
+ m_service = m_discoveredServices.value(row);
+ if (!ui->fileName->text().isEmpty()) {
+ ui->sendButton->setDisabled(false);
+ }
+}
+
+void RemoteSelector::on_remoteDevices_itemChanged(QTableWidgetItem* item)
+{
+ int row = item->row();
+ int column = item->column();
+ m_service = m_discoveredServices.value(row);
+
+ if (column < 3)
+ return;
+
+ if (item->checkState() == Qt::Unchecked && column == 3){
+ m_localDevice->requestPairing(m_service.device().address(), QBluetoothLocalDevice::Unpaired);
+ return; // don't continue and start movie
+ }
+ else if ((item->checkState() == Qt::Checked && column == 3) ||
+ (item->checkState() == Qt::Unchecked && column == 4)){
+ m_localDevice->requestPairing(m_service.device().address(), QBluetoothLocalDevice::Paired);
+ ui->remoteDevices->blockSignals(true);
+ ui->remoteDevices->item(row, column)->setCheckState(Qt::PartiallyChecked);
+ ui->remoteDevices->blockSignals(false);
+ }
+ else if (item->checkState() == Qt::Checked && column == 4){
+ m_localDevice->requestPairing(m_service.device().address(), QBluetoothLocalDevice::AuthorizedPaired);
+ ui->remoteDevices->blockSignals(true);
+ ui->remoteDevices->item(row, column)->setCheckState(Qt::PartiallyChecked);
+ ui->remoteDevices->blockSignals(false);
+ }
+ ui->pairingBusy->show();
+ ui->pairingBusy->movie()->start();
+}
diff --git a/examples/btfiletransfer/remoteselector.h b/examples/btfiletransfer/remoteselector.h
new file mode 100644
index 00000000..bb52c6f9
--- /dev/null
+++ b/examples/btfiletransfer/remoteselector.h
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef REMOTESELECTOR_H
+#define REMOTESELECTOR_H
+
+#include <QDialog>
+#include <QPointer>
+
+#include <qbluetoothuuid.h>
+#include <qbluetoothserviceinfo.h>
+#include <qbluetoothservicediscoveryagent.h>
+#include <qbluetoothlocaldevice.h>
+
+QT_FORWARD_DECLARE_CLASS(QModelIndex)
+QT_FORWARD_DECLARE_CLASS(QTableWidgetItem)
+QT_FORWARD_DECLARE_CLASS(QFile)
+
+class pinDisplay;
+
+QTBLUETOOTH_USE_NAMESPACE
+
+namespace Ui {
+ class RemoteSelector;
+}
+
+class RemoteSelector : public QDialog
+{
+ Q_OBJECT
+
+public:
+ explicit RemoteSelector(QWidget *parent = 0);
+ ~RemoteSelector();
+
+ void startDiscovery(const QBluetoothUuid &uuid);
+ QBluetoothServiceInfo service() const;
+
+private:
+ Ui::RemoteSelector *ui;
+
+ QBluetoothServiceDiscoveryAgent *m_discoveryAgent;
+ QBluetoothServiceInfo m_service;
+ QMap<int, QBluetoothServiceInfo> m_discoveredServices;
+ QFile *m_file;
+ QBluetoothLocalDevice *m_localDevice;
+ QPointer<pinDisplay> m_pindisplay;
+
+ QString addressToName(const QBluetoothAddress &address);
+
+public Q_SLOTS:
+ void startDiscovery();
+
+private slots:
+ void serviceDiscovered(const QBluetoothServiceInfo &serviceInfo);
+ void discoveryFinished();
+ void on_refreshPB_clicked();
+ void on_fileSelectPB_clicked();
+ void on_sendButton_clicked();
+ void on_stopButton_clicked();
+
+ void pairingFinished(const QBluetoothAddress &address,QBluetoothLocalDevice::Pairing pairing);
+ void displayPin(const QBluetoothAddress &address, QString pin);
+ void displayConfirmation(const QBluetoothAddress &address, QString pin);
+ void displayConfReject();
+ void displayConfAccepted();
+
+ void on_remoteDevices_cellClicked(int row, int column);
+ void on_remoteDevices_itemChanged(QTableWidgetItem* item);
+};
+
+#endif // REMOTESELECTOR_H
diff --git a/examples/btfiletransfer/remoteselector.ui b/examples/btfiletransfer/remoteselector.ui
new file mode 100644
index 00000000..f99deaa7
--- /dev/null
+++ b/examples/btfiletransfer/remoteselector.ui
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RemoteSelector</class>
+ <widget class="QDialog" name="RemoteSelector">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>681</width>
+ <height>394</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Available file transfer services</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="horizontalSpacing">
+ <number>6</number>
+ </property>
+ <item row="7" column="0" colspan="2">
+ <widget class="QLineEdit" name="fileName"/>
+ </item>
+ <item row="7" column="2">
+ <widget class="QPushButton" name="fileSelectPB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Select File</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0" colspan="3">
+ <widget class="QPushButton" name="sendButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Send</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="3">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="busyWidget">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="baseSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="status">
+ <property name="text">
+ <string>Scanning...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="pairingBusy">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="stopButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="refreshPB">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Refresh</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="6" column="0" colspan="3">
+ <widget class="QTableWidget" name="remoteDevices">
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ <property name="editTriggers">
+ <set>QAbstractItemView::NoEditTriggers</set>
+ </property>
+ <property name="showDropIndicator" stdset="0">
+ <bool>false</bool>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="showGrid">
+ <bool>false</bool>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="rowCount">
+ <number>1</number>
+ </property>
+ <attribute name="horizontalHeaderCascadingSectionResizes">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="horizontalHeaderDefaultSectionSize">
+ <number>150</number>
+ </attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="verticalHeaderCascadingSectionResizes">
+ <bool>false</bool>
+ </attribute>
+ <row>
+ <property name="text">
+ <string>Test</string>
+ </property>
+ </row>
+ <column>
+ <property name="text">
+ <string>MAC Address</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Device Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Device Service</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Paired</string>
+ </property>
+ <property name="toolTip">
+ <string comment="Paired" extracomment="Paired"/>
+ </property>
+ <property name="whatsThis">
+ <string comment="Paired" extracomment="Paired"/>
+ </property>
+ <property name="textAlignment">
+ <set>AlignHCenter|AlignVCenter|AlignCenter</set>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Authorized</string>
+ </property>
+ <property name="textAlignment">
+ <set>AlignHCenter|AlignVCenter|AlignCenter</set>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/btscanner/btscanner.pro b/examples/btscanner/btscanner.pro
new file mode 100644
index 00000000..629d7d8f
--- /dev/null
+++ b/examples/btscanner/btscanner.pro
@@ -0,0 +1,21 @@
+TARGET = btscanner
+
+INCLUDEPATH += ../../src/connectivity/bluetooth
+DEPENDPATH += ../../src/connectivity/bluetooth
+
+QT += bluetooth widgets
+TEMPLATE = app
+
+SOURCES = \
+ main.cpp \
+ device.cpp \
+ service.cpp
+
+HEADERS = \
+ device.h \
+ service.h
+
+FORMS = \
+ device.ui \
+ service.ui
+
diff --git a/examples/btscanner/device.cpp b/examples/btscanner/device.cpp
new file mode 100644
index 00000000..ea9579d2
--- /dev/null
+++ b/examples/btscanner/device.cpp
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "device.h"
+#include "service.h"
+
+#include <qbluetoothaddress.h>
+#include <qbluetoothdevicediscoveryagent.h>
+#include <qbluetoothlocaldevice.h>
+#include <QMenu>
+#include <QDebug>
+
+DeviceDiscoveryDialog::DeviceDiscoveryDialog(QWidget *parent)
+: QDialog(parent), discoveryAgent(new QBluetoothDeviceDiscoveryAgent),
+ localDevice(new QBluetoothLocalDevice),
+ ui(new Ui_DeviceDiscovery)
+{
+ ui->setupUi(this);
+
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ setWindowState(Qt::WindowFullScreen);
+#endif
+
+ connect(ui->inquiryType, SIGNAL(toggled(bool)), this, SLOT(setGeneralUnlimited(bool)));
+ connect(ui->scan, SIGNAL(clicked()), this, SLOT(startScan()));
+
+ connect(discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)),
+ this, SLOT(addDevice(const QBluetoothDeviceInfo&)));
+ connect(discoveryAgent, SIGNAL(finished()), this, SLOT(scanFinished()));
+
+ connect(ui->list, SIGNAL(itemActivated(QListWidgetItem*)),
+ this, SLOT(itemActivated(QListWidgetItem*)));
+
+ connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)),
+ this, SLOT(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));
+
+ hostModeStateChanged(localDevice->hostMode());
+ // add context menu for devices to be able to pair device
+ ui->list->setContextMenuPolicy(Qt::CustomContextMenu);
+ connect(ui->list, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(displayPairingMenu(QPoint)));
+ connect(localDevice, SIGNAL(pairingFinished(const QBluetoothAddress&, QBluetoothLocalDevice::Pairing))
+ , this, SLOT(pairingDone(const QBluetoothAddress&, QBluetoothLocalDevice::Pairing)));
+
+}
+
+DeviceDiscoveryDialog::~DeviceDiscoveryDialog()
+{
+ delete discoveryAgent;
+}
+
+void DeviceDiscoveryDialog::addDevice(const QBluetoothDeviceInfo &info)
+{
+ QString label = QString("%1 %2").arg(info.address().toString()).arg(info.name());
+ QList<QListWidgetItem *> items = ui->list->findItems(label, Qt::MatchExactly);
+ if (items.empty()) {
+ QListWidgetItem *item = new QListWidgetItem(label);
+ QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(info.address());
+ if (pairingStatus == QBluetoothLocalDevice::Paired || pairingStatus == QBluetoothLocalDevice::AuthorizedPaired )
+ item->setTextColor(QColor(Qt::green));
+ else
+ item->setTextColor(QColor(Qt::black));
+
+ ui->list->addItem(item);
+ }
+
+}
+
+void DeviceDiscoveryDialog::startScan()
+{
+ discoveryAgent->start();
+ ui->scan->setEnabled(false);
+ ui->inquiryType->setEnabled(false);
+}
+
+void DeviceDiscoveryDialog::scanFinished()
+{
+ ui->scan->setEnabled(true);
+ ui->inquiryType->setEnabled(true);
+}
+
+void DeviceDiscoveryDialog::setGeneralUnlimited(bool unlimited)
+{
+ if (unlimited)
+ discoveryAgent->setInquiryType(QBluetoothDeviceDiscoveryAgent::GeneralUnlimitedInquiry);
+ else
+ discoveryAgent->setInquiryType(QBluetoothDeviceDiscoveryAgent::LimitedInquiry);
+}
+
+void DeviceDiscoveryDialog::itemActivated(QListWidgetItem *item)
+{
+ QString text = item->text();
+
+ int index = text.indexOf(' ');
+
+ if (index == -1)
+ return;
+
+ QBluetoothAddress address(text.left(index));
+ QString name(text.mid(index + 1));
+
+ ServiceDiscoveryDialog d(name, address);
+ d.exec();
+}
+
+void DeviceDiscoveryDialog::on_discoverable_clicked(bool clicked)
+{
+ if (clicked)
+ localDevice->setHostMode(QBluetoothLocalDevice::HostDiscoverable);
+ else
+ localDevice->setHostMode(QBluetoothLocalDevice::HostConnectable);
+}
+
+void DeviceDiscoveryDialog::on_power_clicked(bool clicked)
+{
+ if (clicked)
+ localDevice->powerOn();
+ else
+ localDevice->setHostMode(QBluetoothLocalDevice::HostPoweredOff);
+}
+
+void DeviceDiscoveryDialog::hostModeStateChanged(QBluetoothLocalDevice::HostMode mode)
+{
+ if (mode != QBluetoothLocalDevice::HostPoweredOff)
+ ui->power->setChecked(true);
+ else
+ ui->power->setChecked( false);
+
+ if (mode == QBluetoothLocalDevice::HostDiscoverable)
+ ui->discoverable->setChecked(true);
+ else
+ ui->discoverable->setChecked(false);
+
+ bool on = !(mode == QBluetoothLocalDevice::HostPoweredOff);
+
+
+ ui->scan->setEnabled(on);
+ ui->discoverable->setEnabled(on);
+}
+void DeviceDiscoveryDialog::displayPairingMenu(const QPoint &pos)
+{
+ QMenu menu(this);
+ QAction *pairAction = menu.addAction("Pair");
+ QAction *removePairAction = menu.addAction("Remove Pairing");
+ QAction *chosenAction = menu.exec(ui->list->viewport()->mapToGlobal(pos));
+ QListWidgetItem *currentItem = ui->list->currentItem();
+
+ QString text = currentItem->text();
+ int index = text.indexOf(' ');
+ if (index == -1)
+ return;
+
+ QBluetoothAddress address (text.left(index));
+ if (chosenAction == pairAction) {
+ localDevice->requestPairing(address, QBluetoothLocalDevice::Paired);
+ } else if (chosenAction == removePairAction) {
+ localDevice->requestPairing(address, QBluetoothLocalDevice::Unpaired);
+ }
+}
+void DeviceDiscoveryDialog::pairingDone(const QBluetoothAddress &address, QBluetoothLocalDevice::Pairing pairing)
+{
+ QList<QListWidgetItem *> items = ui->list->findItems(address.toString(), Qt::MatchContains);
+
+ if (pairing == QBluetoothLocalDevice::Paired || pairing == QBluetoothLocalDevice::AuthorizedPaired ) {
+ for (int var = 0; var < items.count(); ++var) {
+ QListWidgetItem *item = items.at(var);
+ item->setTextColor(QColor(Qt::green));
+ }
+ } else {
+ for (int var = 0; var < items.count(); ++var) {
+ QListWidgetItem *item = items.at(var);
+ item->setTextColor(QColor(Qt::red));
+ }
+ }
+}
diff --git a/examples/btscanner/device.h b/examples/btscanner/device.h
new file mode 100644
index 00000000..ddeb5638
--- /dev/null
+++ b/examples/btscanner/device.h
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef DEVICE_H
+#define DEVICE_H
+
+#include "ui_device.h"
+
+#include <qbluetoothglobal.h>
+#include <qbluetoothlocaldevice.h>
+
+#include <QDialog>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QBluetoothDeviceDiscoveryAgent;
+class QBluetoothDeviceInfo;
+QTBLUETOOTH_END_NAMESPACE
+
+QTBLUETOOTH_USE_NAMESPACE
+
+class DeviceDiscoveryDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ DeviceDiscoveryDialog(QWidget *parent = 0);
+ ~DeviceDiscoveryDialog();
+
+public slots:
+ void addDevice(const QBluetoothDeviceInfo&);
+ void on_power_clicked(bool clicked);
+ void on_discoverable_clicked(bool clicked);
+ void displayPairingMenu(const QPoint &pos);
+ void pairingDone(const QBluetoothAddress&, QBluetoothLocalDevice::Pairing);
+private slots:
+ void startScan();
+ void scanFinished();
+ void setGeneralUnlimited(bool unlimited);
+ void itemActivated(QListWidgetItem *item);
+ void hostModeStateChanged(QBluetoothLocalDevice::HostMode);
+
+private:
+ QBluetoothDeviceDiscoveryAgent *discoveryAgent;
+ QBluetoothLocalDevice *localDevice;
+ Ui_DeviceDiscovery *ui;
+};
+
+#endif
diff --git a/examples/btscanner/device.ui b/examples/btscanner/device.ui
new file mode 100644
index 00000000..1f62dd96
--- /dev/null
+++ b/examples/btscanner/device.ui
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DeviceDiscovery</class>
+ <widget class="QDialog" name="DeviceDiscovery">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>411</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Bluetooth Scanner</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QListWidget" name="list"/>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Local Device</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="power">
+ <property name="text">
+ <string>Bluetooth Powered On</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="discoverable">
+ <property name="text">
+ <string>Discoverable</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="inquiryType">
+ <property name="text">
+ <string>General Unlimited Inquiry</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QPushButton" name="scan">
+ <property name="text">
+ <string>Scan</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clear">
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="quit">
+ <property name="text">
+ <string>Quit</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>quit</sender>
+ <signal>clicked()</signal>
+ <receiver>DeviceDiscovery</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>323</x>
+ <y>275</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>396</x>
+ <y>268</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>clear</sender>
+ <signal>clicked()</signal>
+ <receiver>list</receiver>
+ <slot>clear()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>188</x>
+ <y>276</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>209</x>
+ <y>172</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/examples/btscanner/main.cpp b/examples/btscanner/main.cpp
new file mode 100644
index 00000000..fc1cf3d4
--- /dev/null
+++ b/examples/btscanner/main.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "device.h"
+
+#include <QApplication>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ DeviceDiscoveryDialog d;
+ QObject::connect(&d, SIGNAL(accepted()), &app, SLOT(quit()));
+ d.show();
+
+ app.exec();
+
+ return 0;
+}
+
diff --git a/examples/btscanner/service.cpp b/examples/btscanner/service.cpp
new file mode 100644
index 00000000..c8d35b50
--- /dev/null
+++ b/examples/btscanner/service.cpp
@@ -0,0 +1,87 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "service.h"
+
+#include <qbluetoothaddress.h>
+#include <qbluetoothservicediscoveryagent.h>
+#include <qbluetoothserviceinfo.h>
+
+
+ServiceDiscoveryDialog::ServiceDiscoveryDialog(const QString &name,
+ const QBluetoothAddress &address, QWidget *parent)
+: QDialog(parent), discoveryAgent(new QBluetoothServiceDiscoveryAgent(address)),
+ ui(new Ui_ServiceDiscovery)
+{
+ ui->setupUi(this);
+
+#if defined (Q_OS_SYMBIAN) || defined(Q_OS_WINCE) || defined(Q_WS_MAEMO_5) || defined(Q_WS_MAEMO_6)
+ setWindowState(Qt::WindowMaximized);
+#endif
+
+ setWindowTitle(name);
+
+ connect(discoveryAgent, SIGNAL(serviceDiscovered(const QBluetoothServiceInfo&)),
+ this, SLOT(addService(const QBluetoothServiceInfo&)));
+ connect(discoveryAgent, SIGNAL(finished()), ui->status, SLOT(hide()));
+
+ discoveryAgent->start();
+}
+
+ServiceDiscoveryDialog::~ServiceDiscoveryDialog()
+{
+ delete discoveryAgent;
+ delete ui;
+}
+
+void ServiceDiscoveryDialog::addService(const QBluetoothServiceInfo &info)
+{
+ if (info.serviceName().isEmpty())
+ return;
+
+ QString line = info.serviceName();
+ if (!info.serviceDescription().isEmpty())
+ line.append("\n\t" + info.serviceDescription());
+ if (!info.serviceProvider().isEmpty())
+ line.append("\n\t" + info.serviceProvider());
+
+ ui->list->addItem(line);
+}
+
diff --git a/examples/btscanner/service.h b/examples/btscanner/service.h
new file mode 100644
index 00000000..dd231f1d
--- /dev/null
+++ b/examples/btscanner/service.h
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtBluetooth module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef SERVICE_H
+#define SERVICE_H
+
+#include "ui_service.h"
+
+#include <qbluetoothglobal.h>
+
+#include <QDialog>
+
+QTBLUETOOTH_BEGIN_NAMESPACE
+class QBluetoothServiceDiscoveryAgent;
+class QBluetoothServiceInfo;
+class QBluetoothAddress;
+QTBLUETOOTH_END_NAMESPACE
+
+QTBLUETOOTH_USE_NAMESPACE
+
+class ServiceDiscoveryDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ServiceDiscoveryDialog(const QString &name, const QBluetoothAddress &address, QWidget *parent = 0);
+ ~ServiceDiscoveryDialog();
+
+public slots:
+ void addService(const QBluetoothServiceInfo&);
+
+private:
+ QBluetoothServiceDiscoveryAgent *discoveryAgent;
+ Ui_ServiceDiscovery *ui;
+};
+
+#endif
diff --git a/examples/btscanner/service.ui b/examples/btscanner/service.ui
new file mode 100644
index 00000000..68ebc5dc
--- /dev/null
+++ b/examples/btscanner/service.ui
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ServiceDiscovery</class>
+ <widget class="QDialog" name="ServiceDiscovery">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Available Services</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QListWidget" name="list"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="status">
+ <property name="text">
+ <string>Querying...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="close">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <tabstops>
+ <tabstop>list</tabstop>
+ <tabstop>close</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>close</sender>
+ <signal>clicked()</signal>
+ <receiver>ServiceDiscovery</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>350</x>
+ <y>277</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>237</x>
+ <y>269</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/examples/ndefeditor/main.cpp b/examples/ndefeditor/main.cpp
new file mode 100644
index 00000000..78089ff2
--- /dev/null
+++ b/examples/ndefeditor/main.cpp
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include "mainwindow.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication a(argc, argv);
+ MainWindow w;
+
+#if defined(Q_WS_S60) || defined(Q_WS_MAEMO_6) || defined(Q_WS_MEEGO)
+ w.showFullScreen();
+#else
+ w.show();
+#endif
+
+ return a.exec();
+}
diff --git a/examples/ndefeditor/mainwindow.cpp b/examples/ndefeditor/mainwindow.cpp
new file mode 100644
index 00000000..1b227210
--- /dev/null
+++ b/examples/ndefeditor/mainwindow.cpp
@@ -0,0 +1,361 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include "textrecordeditor.h"
+#include "urirecordeditor.h"
+#include "mimeimagerecordeditor.h"
+
+#include <QtCore/QTime>
+#include <QMenu>
+#include <QVBoxLayout>
+#include <QFrame>
+#include <QLabel>
+#include <QFileDialog>
+
+#include <qnearfieldmanager.h>
+#include <qnearfieldtarget.h>
+#include <qndefrecord.h>
+#include <qndefnfctextrecord.h>
+#include <qndefnfcurirecord.h>
+#include <qndefmessage.h>
+
+#include <QtCore/QDebug>
+
+class EmptyRecordLabel : public QLabel
+{
+ Q_OBJECT
+
+public:
+ EmptyRecordLabel() : QLabel(tr("Empty Record")) { }
+ ~EmptyRecordLabel() { }
+
+ void setRecord(const QNdefRecord &record)
+ {
+ Q_UNUSED(record);
+ }
+
+ QNdefRecord record() const
+ {
+ return QNdefRecord();
+ }
+};
+
+class UnknownRecordLabel : public QLabel
+{
+ Q_OBJECT
+
+public:
+ UnknownRecordLabel() : QLabel(tr("Unknown Record Type")) { }
+ ~UnknownRecordLabel() { }
+
+ void setRecord(const QNdefRecord &record) { m_record = record; }
+ QNdefRecord record() const { return m_record; }
+
+private:
+ QNdefRecord m_record;
+};
+
+template <typename T>
+void addRecord(Ui::MainWindow *ui, const QNdefRecord &record = QNdefRecord())
+{
+ QVBoxLayout *vbox = qobject_cast<QVBoxLayout *>(ui->scrollAreaWidgetContents->layout());
+ if (!vbox)
+ return;
+
+ if (!vbox->isEmpty()) {
+ QFrame *hline = new QFrame;
+ hline->setFrameShape(QFrame::HLine);
+ hline->setObjectName(QLatin1String("line-spacer"));
+
+ vbox->addWidget(hline);
+ }
+
+ T *recordEditor = new T;
+ recordEditor->setObjectName(QLatin1String("record-editor"));
+
+ if (!record.isEmpty())
+ recordEditor->setRecord(record);
+
+ vbox->addWidget(recordEditor);
+}
+
+MainWindow::MainWindow(QWidget *parent)
+: QMainWindow(parent), ui(new Ui::MainWindow), m_manager(new QNearFieldManager(this)),
+ m_touchAction(NoAction)
+{
+ ui->setupUi(this);
+
+ QMenu *addRecordMenu = new QMenu(this);
+ addRecordMenu->addAction(tr("NFC Text Record"), this, SLOT(addNfcTextRecord()));
+ addRecordMenu->addAction(tr("NFC URI Record"), this, SLOT(addNfcUriRecord()));
+ addRecordMenu->addAction(tr("MIME Image Record"), this, SLOT(addMimeImageRecord()));
+ addRecordMenu->addAction(tr("Empty Record"), this, SLOT(addEmptyRecord()));
+ ui->addRecord->setMenu(addRecordMenu);
+
+ QVBoxLayout *vbox = new QVBoxLayout;
+ ui->scrollAreaWidgetContents->setLayout(vbox);
+
+ connect(m_manager, SIGNAL(targetDetected(QNearFieldTarget*)),
+ this, SLOT(targetDetected(QNearFieldTarget*)));
+ connect(m_manager, SIGNAL(targetLost(QNearFieldTarget*)),
+ this, SLOT(targetLost(QNearFieldTarget*)));
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::addNfcTextRecord()
+{
+ addRecord<TextRecordEditor>(ui);
+}
+
+void MainWindow::addNfcUriRecord()
+{
+ addRecord<UriRecordEditor>(ui);
+}
+
+void MainWindow::addMimeImageRecord()
+{
+ addRecord<MimeImageRecordEditor>(ui);
+}
+
+void MainWindow::addEmptyRecord()
+{
+ addRecord<EmptyRecordLabel>(ui);
+}
+
+void MainWindow::loadMessage()
+{
+ QString filename = QFileDialog::getOpenFileName(this, tr("Select NDEF Message"));
+ if (filename.isEmpty())
+ return;
+
+ QFile file(filename);
+ if (!file.open(QIODevice::ReadOnly))
+ return;
+
+ QByteArray ndef = file.readAll();
+
+ ndefMessageRead(QNdefMessage::fromByteArray(ndef));
+
+ file.close();
+}
+
+void MainWindow::saveMessage()
+{
+ QString filename = QFileDialog::getSaveFileName(this, tr("Select NDEF Message"));
+ if (filename.isEmpty())
+ return;
+
+ QFile file(filename);
+ if (!file.open(QIODevice::WriteOnly))
+ return;
+
+ file.write(ndefMessage().toByteArray());
+
+ file.close();
+}
+
+void MainWindow::touchReceive()
+{
+ ui->status->setStyleSheet(QLatin1String("background: blue"));
+
+ m_touchAction = ReadNdef;
+
+ m_manager->setTargetAccessModes(QNearFieldManager::NdefReadTargetAccess);
+ m_manager->startTargetDetection();
+}
+
+void MainWindow::touchStore()
+{
+ ui->status->setStyleSheet(QLatin1String("background: yellow"));
+
+ m_touchAction = WriteNdef;
+
+ m_manager->setTargetAccessModes(QNearFieldManager::NdefWriteTargetAccess);
+ m_manager->startTargetDetection();
+}
+
+void MainWindow::targetDetected(QNearFieldTarget *target)
+{
+ switch (m_touchAction) {
+ case NoAction:
+ break;
+ case ReadNdef:
+ connect(target, SIGNAL(ndefMessageRead(QNdefMessage)),
+ this, SLOT(ndefMessageRead(QNdefMessage)));
+ connect(target, SIGNAL(error(QNearFieldTarget::Error,QNearFieldTarget::RequestId)),
+ this, SLOT(targetError(QNearFieldTarget::Error,QNearFieldTarget::RequestId)));
+
+ m_request = target->readNdefMessages();
+ break;
+ case WriteNdef:
+ connect(target, SIGNAL(ndefMessagesWritten()), this, SLOT(ndefMessageWritten()));
+ connect(target, SIGNAL(error(QNearFieldTarget::Error,QNearFieldTarget::RequestId)),
+ this, SLOT(targetError(QNearFieldTarget::Error,QNearFieldTarget::RequestId)));
+
+ m_request = target->writeNdefMessages(QList<QNdefMessage>() << ndefMessage());
+ break;
+ }
+}
+
+void MainWindow::targetLost(QNearFieldTarget *target)
+{
+ target->deleteLater();
+}
+
+void MainWindow::ndefMessageRead(const QNdefMessage &message)
+{
+ clearMessage();
+
+ foreach (const QNdefRecord &record, message) {
+ if (record.isRecordType<QNdefNfcTextRecord>()) {
+ addRecord<TextRecordEditor>(ui, record);
+ } else if (record.isRecordType<QNdefNfcUriRecord>()) {
+ addRecord<UriRecordEditor>(ui, record);
+ } else if (record.typeNameFormat() == QNdefRecord::Mime &&
+ record.type().startsWith("image/")) {
+ addRecord<MimeImageRecordEditor>(ui, record);
+ } else if (record.isEmpty()) {
+ addRecord<EmptyRecordLabel>(ui);
+ } else {
+ addRecord<UnknownRecordLabel>(ui, record);
+ }
+ }
+
+ ui->status->setStyleSheet(QString());
+ m_manager->setTargetAccessModes(QNearFieldManager::NoTargetAccess);
+ m_manager->stopTargetDetection();
+ m_request = QNearFieldTarget::RequestId();
+ ui->statusBar->clearMessage();
+}
+
+void MainWindow::ndefMessageWritten()
+{
+ ui->status->setStyleSheet(QString());
+ m_manager->setTargetAccessModes(QNearFieldManager::NoTargetAccess);
+ m_manager->stopTargetDetection();
+ m_request = QNearFieldTarget::RequestId();
+ ui->statusBar->clearMessage();
+}
+
+void MainWindow::targetError(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id)
+{
+ Q_UNUSED(error);
+ Q_UNUSED(id);
+
+ if (m_request == id) {
+ switch (error) {
+ case QNearFieldTarget::NoError:
+ ui->statusBar->clearMessage();
+ break;
+ case QNearFieldTarget::UnsupportedError:
+ ui->statusBar->showMessage(tr("Unsupported tag"));
+ break;
+ case QNearFieldTarget::TargetOutOfRangeError:
+ ui->statusBar->showMessage(tr("Tag removed from field"));
+ break;
+ case QNearFieldTarget::NoResponseError:
+ ui->statusBar->showMessage(tr("No response from tag"));
+ break;
+ case QNearFieldTarget::ChecksumMismatchError:
+ ui->statusBar->showMessage(tr("Checksum mismatch"));
+ break;
+ case QNearFieldTarget::InvalidParametersError:
+ ui->statusBar->showMessage(tr("Invalid parameters"));
+ break;
+ case QNearFieldTarget::NdefReadError:
+ ui->statusBar->showMessage(tr("NDEF read error"));
+ break;
+ case QNearFieldTarget::NdefWriteError:
+ ui->statusBar->showMessage(tr("NDEF write error"));
+ break;
+ default:
+ ui->statusBar->showMessage(tr("Unknown error"));
+ }
+
+ ui->status->setStyleSheet(QString());
+ m_manager->setTargetAccessModes(QNearFieldManager::NoTargetAccess);
+ m_manager->stopTargetDetection();
+ m_request = QNearFieldTarget::RequestId();
+ }
+}
+
+void MainWindow::clearMessage()
+{
+ QWidget *scrollArea = ui->scrollAreaWidgetContents;
+
+ qDeleteAll(scrollArea->findChildren<QWidget *>(QLatin1String("line-spacer")));
+ qDeleteAll(scrollArea->findChildren<QWidget *>(QLatin1String("record-editor")));
+}
+
+QNdefMessage MainWindow::ndefMessage() const
+{
+ QVBoxLayout *vbox = qobject_cast<QVBoxLayout *>(ui->scrollAreaWidgetContents->layout());
+ if (!vbox)
+ return QNdefMessage();
+
+ QNdefMessage message;
+
+ for (int i = 0; i < vbox->count(); ++i) {
+ QWidget *widget = vbox->itemAt(i)->widget();
+
+ if (TextRecordEditor *editor = qobject_cast<TextRecordEditor *>(widget)) {
+ message.append(editor->record());
+ } else if (UriRecordEditor *editor = qobject_cast<UriRecordEditor *>(widget)) {
+ message.append(editor->record());
+ } else if (MimeImageRecordEditor *editor = qobject_cast<MimeImageRecordEditor *>(widget)) {
+ message.append(editor->record());
+ } else if (qobject_cast<EmptyRecordLabel *>(widget)) {
+ message.append(QNdefRecord());
+ } else if (UnknownRecordLabel *label = qobject_cast<UnknownRecordLabel *>(widget)) {
+ message.append(label->record());
+ }
+ }
+
+ return message;
+}
+
+#include "mainwindow.moc"
diff --git a/examples/ndefeditor/mainwindow.h b/examples/ndefeditor/mainwindow.h
new file mode 100644
index 00000000..bd9330e2
--- /dev/null
+++ b/examples/ndefeditor/mainwindow.h
@@ -0,0 +1,107 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QMainWindow>
+
+#include <qnfcglobal.h>
+
+#include <qnearfieldtarget.h>
+
+QTNFC_BEGIN_NAMESPACE
+class QNearFieldManager;
+class QNdefMessage;
+QTNFC_END_NAMESPACE
+
+QTNFC_USE_NAMESPACE
+
+namespace Ui {
+ class MainWindow;
+}
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(QWidget *parent = 0);
+ ~MainWindow();
+
+private slots:
+ void addNfcTextRecord();
+ void addNfcUriRecord();
+ void addMimeImageRecord();
+ void addEmptyRecord();
+
+ void clearMessage();
+
+ void loadMessage();
+ void saveMessage();
+
+ void touchReceive();
+ void touchStore();
+
+ void targetDetected(QNearFieldTarget *target);
+ void targetLost(QNearFieldTarget *target);
+
+ void ndefMessageRead(const QNdefMessage &message);
+ void ndefMessageWritten();
+ void targetError(QNearFieldTarget::Error error, const QNearFieldTarget::RequestId &id);
+
+private:
+ enum TouchAction {
+ NoAction,
+ ReadNdef,
+ WriteNdef
+ };
+
+ QNdefMessage ndefMessage() const;
+
+private:
+ Ui::MainWindow *ui;
+
+ QNearFieldManager *m_manager;
+ TouchAction m_touchAction;
+ QNearFieldTarget::RequestId m_request;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/ndefeditor/mainwindow.ui b/examples/ndefeditor/mainwindow.ui
new file mode 100644
index 00000000..adffa331
--- /dev/null
+++ b/examples/ndefeditor/mainwindow.ui
@@ -0,0 +1,225 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QMainWindow" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>553</width>
+ <height>397</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>NDEF Message Editor</string>
+ </property>
+ <widget class="QWidget" name="centralWidget">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="leftMargin">
+ <number>9</number>
+ </property>
+ <property name="rightMargin">
+ <number>9</number>
+ </property>
+ <item>
+ <widget class="QWidget" name="status" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="touchRetrieve">
+ <property name="text">
+ <string>Retrieve</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="touchStore">
+ <property name="text">
+ <string>Store</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="loadMessage">
+ <property name="text">
+ <string>Load</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="saveMessage">
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearMessage">
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="addRecord">
+ <property name="text">
+ <string>Add</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QScrollArea" name="scrollArea">
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Plain</enum>
+ </property>
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="widgetResizable">
+ <bool>true</bool>
+ </property>
+ <widget class="QWidget" name="scrollAreaWidgetContents">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>553</width>
+ <height>335</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QStatusBar" name="statusBar"/>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>saveMessage</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>saveMessage()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>419</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>touchRetrieve</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>touchReceive()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>142</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>touchStore</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>touchStore()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>244</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>loadMessage</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>loadMessage()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>334</x>
+ <y>47</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>clearMessage</sender>
+ <signal>clicked()</signal>
+ <receiver>MainWindow</receiver>
+ <slot>clearMessage()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>419</x>
+ <y>22</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>275</x>
+ <y>198</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <slots>
+ <slot>saveMessage()</slot>
+ <slot>loadMessage()</slot>
+ <slot>touchReceive()</slot>
+ <slot>touchStore()</slot>
+ <slot>clearMessage()</slot>
+ </slots>
+</ui>
diff --git a/examples/ndefeditor/mimeimagerecordeditor.cpp b/examples/ndefeditor/mimeimagerecordeditor.cpp
new file mode 100644
index 00000000..f67239c8
--- /dev/null
+++ b/examples/ndefeditor/mimeimagerecordeditor.cpp
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mimeimagerecordeditor.h"
+#include "ui_mimeimagerecordeditor.h"
+
+#include <QBuffer>
+#include <QFileDialog>
+#include <QImageReader>
+
+static QString imageFormatToMimeType(const QByteArray &format)
+{
+ if (format == "bmp")
+ return QLatin1String("image/bmp");
+ else if (format == "gif")
+ return QLatin1String("image/gif");
+ else if (format == "jpg" || format == "jpeg")
+ return QLatin1String("image/jpeg");
+ else if (format == "mng")
+ return QLatin1String("video/x-mng");
+ else if (format == "png")
+ return QLatin1String("image/png");
+ else if (format == "pbm")
+ return QLatin1String("image/x-portable-bitmap");
+ else if (format == "pgm")
+ return QLatin1String("image/x-portable-graymap");
+ else if (format == "ppm")
+ return QLatin1String("image/x-portable-pixmap");
+ else if (format == "tiff")
+ return QLatin1String("image/tiff");
+ else if (format == "xbm")
+ return QLatin1String("image/x-xbitmap");
+ else if (format == "xpm")
+ return QLatin1String("image/x-xpixmap");
+ else if (format == "svg")
+ return QLatin1String("image/svg+xml");
+ else
+ return QString();
+}
+
+MimeImageRecordEditor::MimeImageRecordEditor(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::MimeImageRecordEditor)
+{
+ ui->setupUi(this);
+}
+
+MimeImageRecordEditor::~MimeImageRecordEditor()
+{
+ delete ui;
+}
+
+void MimeImageRecordEditor::setRecord(const QNdefRecord &record)
+{
+ m_record = record;
+
+ QByteArray data = record.payload();
+ QBuffer buffer(&data);
+ buffer.open(QIODevice::ReadOnly);
+
+ QImageReader reader(&buffer);
+
+ ui->mimeImageType->setText(imageFormatToMimeType(reader.format()));
+
+ ui->mimeImageImage->setPixmap(QPixmap::fromImage(reader.read()));
+ ui->mimeImageFile->clear();
+}
+
+QNdefRecord MimeImageRecordEditor::record() const
+{
+ return m_record;
+}
+
+void MimeImageRecordEditor::on_mimeImageOpen_clicked()
+{
+ QString mimeDataFile = QFileDialog::getOpenFileName(this, tr("Select Image File"));
+ if (mimeDataFile.isEmpty())
+ return;
+
+ QFile imageFile(mimeDataFile);
+ if (!imageFile.open(QIODevice::ReadOnly)) {
+ ui->mimeImageFile->clear();
+ ui->mimeImageImage->clear();
+ }
+
+ QByteArray imageData = imageFile.readAll();
+
+ QBuffer buffer(&imageData);
+ buffer.open(QIODevice::ReadOnly);
+
+ QImageReader reader(&buffer);
+ QString mimeType = imageFormatToMimeType(reader.format());
+ ui->mimeImageType->setText(mimeType);
+
+ QImage image = reader.read();
+
+ ui->mimeImageFile->setText(mimeDataFile);
+ ui->mimeImageImage->setPixmap(QPixmap::fromImage(image));
+
+ m_record.setType(mimeType.toAscii());
+ m_record.setPayload(imageData);
+}
diff --git a/examples/ndefeditor/mimeimagerecordeditor.h b/examples/ndefeditor/mimeimagerecordeditor.h
new file mode 100644
index 00000000..a62cce13
--- /dev/null
+++ b/examples/ndefeditor/mimeimagerecordeditor.h
@@ -0,0 +1,76 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef MIMEIMAGERECORDEDITOR_H
+#define MIMEIMAGERECORDEDITOR_H
+
+#include <qnfcglobal.h>
+
+#include <QWidget>
+
+#include <qndefrecord.h>
+
+QTNFC_USE_NAMESPACE
+
+namespace Ui {
+ class MimeImageRecordEditor;
+}
+
+class MimeImageRecordEditor : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit MimeImageRecordEditor(QWidget *parent = 0);
+ ~MimeImageRecordEditor();
+
+ void setRecord(const QNdefRecord &record);
+ QNdefRecord record() const;
+
+private:
+ Ui::MimeImageRecordEditor *ui;
+ QNdefRecord m_record;
+
+private slots:
+ void on_mimeImageOpen_clicked();
+};
+
+#endif // MIMEIMAGERECORDEDITOR_H
diff --git a/examples/ndefeditor/mimeimagerecordeditor.ui b/examples/ndefeditor/mimeimagerecordeditor.ui
new file mode 100644
index 00000000..4cde216f
--- /dev/null
+++ b/examples/ndefeditor/mimeimagerecordeditor.ui
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MimeImageRecordEditor</class>
+ <widget class="QWidget" name="MimeImageRecordEditor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>403</width>
+ <height>106</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>MIME Record &lt;image/*&gt;</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="mimeImageType">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>image/</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>File:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="mimeImageFile">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="mimeImageOpen">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLabel" name="mimeImageImage">
+ <property name="text">
+ <string>TextLabel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/ndefeditor/ndefeditor.pro b/examples/ndefeditor/ndefeditor.pro
new file mode 100644
index 00000000..8ed0d7e5
--- /dev/null
+++ b/examples/ndefeditor/ndefeditor.pro
@@ -0,0 +1,28 @@
+INCLUDEPATH += $$PWD/../../src/connectivity/nfc
+DEPENDPATH += $$PWD/../../src/connectivity/nfc
+
+QT += nfc widgets
+
+TARGET = ndefeditor
+TEMPLATE = app
+
+SOURCES += \
+ main.cpp \
+ mainwindow.cpp \
+ textrecordeditor.cpp \
+ urirecordeditor.cpp \
+ mimeimagerecordeditor.cpp
+
+HEADERS += \
+ mainwindow.h \
+ textrecordeditor.h \
+ urirecordeditor.h \
+ mimeimagerecordeditor.h
+
+FORMS += \
+ mainwindow.ui \
+ textrecordeditor.ui \
+ urirecordeditor.ui \
+ mimeimagerecordeditor.ui
+
+symbian:TARGET.CAPABILITY += LocalServices
diff --git a/examples/ndefeditor/textrecord.ui b/examples/ndefeditor/textrecord.ui
new file mode 100644
index 00000000..eedd2d83
--- /dev/null
+++ b/examples/ndefeditor/textrecord.ui
@@ -0,0 +1,21 @@
+<ui version="4.0">
+ <author/>
+ <comment/>
+ <exportmacro/>
+ <class>TextRecord</class>
+ <widget class="QWidget" name="TextRecord">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ </widget>
+ <pixmapfunction/>
+ <connections/>
+</ui>
diff --git a/examples/ndefeditor/textrecordeditor.cpp b/examples/ndefeditor/textrecordeditor.cpp
new file mode 100644
index 00000000..37d66b14
--- /dev/null
+++ b/examples/ndefeditor/textrecordeditor.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "textrecordeditor.h"
+#include "ui_textrecordeditor.h"
+
+#include <QtCore/QDebug>
+
+TextRecordEditor::TextRecordEditor(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::TextRecordEditor)
+{
+ ui->setupUi(this);
+}
+
+TextRecordEditor::~TextRecordEditor()
+{
+ delete ui;
+}
+
+void TextRecordEditor::setRecord(const QNdefNfcTextRecord &textRecord)
+{
+ ui->text->setText(textRecord.text());
+ ui->locale->setText(textRecord.locale());
+
+ if (textRecord.encoding() == QNdefNfcTextRecord::Utf8)
+ ui->encoding->setCurrentIndex(0);
+ else if (textRecord.encoding() == QNdefNfcTextRecord::Utf16)
+ ui->encoding->setCurrentIndex(1);
+}
+
+QNdefNfcTextRecord TextRecordEditor::record() const
+{
+ QNdefNfcTextRecord record;
+
+ if (ui->encoding->currentIndex() == 0)
+ record.setEncoding(QNdefNfcTextRecord::Utf8);
+ else if (ui->encoding->currentIndex() == 1)
+ record.setEncoding(QNdefNfcTextRecord::Utf16);
+
+ record.setLocale(ui->locale->text());
+
+ record.setText(ui->text->text());
+
+ return record;
+}
diff --git a/examples/ndefeditor/textrecordeditor.h b/examples/ndefeditor/textrecordeditor.h
new file mode 100644
index 00000000..5f6218d1
--- /dev/null
+++ b/examples/ndefeditor/textrecordeditor.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef TEXTRECORDEDITOR_H
+#define TEXTRECORDEDITOR_H
+
+#include <QWidget>
+
+#include <qndefnfctextrecord.h>
+
+namespace Ui {
+ class TextRecordEditor;
+}
+
+QTNFC_USE_NAMESPACE
+
+class TextRecordEditor : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit TextRecordEditor(QWidget *parent = 0);
+ ~TextRecordEditor();
+
+ void setRecord(const QNdefNfcTextRecord &textRecord);
+ QNdefNfcTextRecord record() const;
+
+private:
+ Ui::TextRecordEditor *ui;
+};
+
+#endif // TEXTRECORDEDITOR_H
diff --git a/examples/ndefeditor/textrecordeditor.ui b/examples/ndefeditor/textrecordeditor.ui
new file mode 100644
index 00000000..41950e7d
--- /dev/null
+++ b/examples/ndefeditor/textrecordeditor.ui
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TextRecordEditor</class>
+ <widget class="QWidget" name="TextRecordEditor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>344</width>
+ <height>115</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="rowWrapPolicy">
+ <enum>QFormLayout::WrapLongRows</enum>
+ </property>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>NFC Text Record</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Text:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="text">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>Locale:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="locale">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Encoding:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="encoding">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text">
+ <string>UTF-8</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>UTF-16</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/ndefeditor/urirecordeditor.cpp b/examples/ndefeditor/urirecordeditor.cpp
new file mode 100644
index 00000000..a8f30c71
--- /dev/null
+++ b/examples/ndefeditor/urirecordeditor.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "urirecordeditor.h"
+#include "ui_urirecordeditor.h"
+
+#include <QtCore/QUrl>
+
+UriRecordEditor::UriRecordEditor(QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::UriRecordEditor)
+{
+ ui->setupUi(this);
+}
+
+UriRecordEditor::~UriRecordEditor()
+{
+ delete ui;
+}
+
+void UriRecordEditor::setRecord(const QNdefNfcUriRecord &uriRecord)
+{
+ ui->uri->setText(uriRecord.uri().toString());
+}
+
+QNdefNfcUriRecord UriRecordEditor::record() const
+{
+ QNdefNfcUriRecord record;
+
+ record.setUri(ui->uri->text());
+
+ return record;
+}
diff --git a/examples/ndefeditor/urirecordeditor.h b/examples/ndefeditor/urirecordeditor.h
new file mode 100644
index 00000000..e92309df
--- /dev/null
+++ b/examples/ndefeditor/urirecordeditor.h
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#ifndef URIRECORDEDITOR_H
+#define URIRECORDEDITOR_H
+
+#include <QWidget>
+
+#include <qndefnfcurirecord.h>
+
+namespace Ui {
+ class UriRecordEditor;
+}
+
+QTNFC_USE_NAMESPACE
+
+class UriRecordEditor : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit UriRecordEditor(QWidget *parent = 0);
+ ~UriRecordEditor();
+
+ void setRecord(const QNdefNfcUriRecord &uriRecord);
+ QNdefNfcUriRecord record() const;
+
+private:
+ Ui::UriRecordEditor *ui;
+};
+
+#endif // URIRECORDEDITOR_H
diff --git a/examples/ndefeditor/urirecordeditor.ui b/examples/ndefeditor/urirecordeditor.ui
new file mode 100644
index 00000000..929c1eb4
--- /dev/null
+++ b/examples/ndefeditor/urirecordeditor.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UriRecordEditor</class>
+ <widget class="QWidget" name="UriRecordEditor">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>439</width>
+ <height>59</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>NFC URI Record</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Uri:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="uri">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/poster/poster.pro b/examples/poster/poster.pro
new file mode 100644
index 00000000..de2e1a05
--- /dev/null
+++ b/examples/poster/poster.pro
@@ -0,0 +1,13 @@
+QT += declarative quick network nfc widgets
+
+SOURCES += \
+ qmlposter.cpp
+
+TARGET = qml_poster
+TEMPLATE = app
+
+RESOURCES += \
+ poster.qrc
+
+OTHER_FILES += \
+ poster.qml
diff --git a/examples/poster/poster.qml b/examples/poster/poster.qml
new file mode 100644
index 00000000..c521eb43
--- /dev/null
+++ b/examples/poster/poster.qml
@@ -0,0 +1,186 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+import QtNfc 5.0
+
+Rectangle {
+ id: root
+ width: 640
+ height: 360
+
+ NearField {
+ id: nearfield
+
+ filter: [
+ NdefFilter { type: "urn:nfc:wkt:U"; minimum: 1; maximum: 1 },
+ NdefFilter { type: "urn:nfc:wkt:T"; minimum: 1 }
+ ]
+
+ onMessageRecordsChanged: {
+ posterText.text = "";
+ posterImage.source = "";
+ posterUrl.text = "";
+
+ var currentLocaleMatch = NdefTextRecord.LocaleMatchedNone;
+ var i;
+ for (i = 0; i < messageRecords.length; ++i) {
+ if (messageRecords[i].recordType == "urn:nfc:wkt:T") {
+ if (messageRecords[i].localeMatch > currentLocaleMatch) {
+ currentLocaleMatch = messageRecords[i].localeMatch;
+ posterText.text = messageRecords[i].text;
+ }
+ } else if (messageRecords[i].recordType == "urn:nfc:wkt:U") {
+ posterUrl.text = messageRecords[i].uri;
+ } else if (messageRecords[i].recordType.substr(0, 19) == "urn:nfc:mime:image/") {
+ posterImage.source = messageRecords[i].uri;
+ }
+ }
+
+ root.state = "show";
+ }
+ }
+
+ Text {
+ id: touchText
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ text: "Touch an NFC tag"
+ font.bold: true
+ font.pointSize: 18
+ }
+
+ Text {
+ id: posterText
+ anchors.horizontalCenter: parent.right
+ anchors.horizontalCenterOffset: - parent.width / 4
+ y: -height
+ font.bold: true
+ font.pointSize: 18
+ }
+
+ Image {
+ id: posterImage
+ scale: Image.PreserveAspectFit
+ height: parent.height * 0.8
+ width: height * sourceSize.width / sourceSize.height
+ anchors.verticalCenter: parent.verticalCenter
+ x: -width
+ smooth: true
+ }
+
+ Text {
+ id: posterUrl
+ anchors.horizontalCenter: parent.right
+ anchors.horizontalCenterOffset: - parent.width / 4
+ y: parent.height
+ font.italic: true
+ font.pointSize: 14
+ }
+
+ MouseArea {
+ id: openMouseArea
+ anchors.fill: parent
+ enabled: root.state == "show"
+
+ onClicked: Qt.openUrlExternally(posterUrl.text)
+
+ Rectangle {
+ id: testTouch
+ width: 50
+ height: 50
+ color: "lightsteelblue"
+ opacity: 0.3
+ anchors.top: parent.top
+ anchors.right: close.left
+ anchors.rightMargin: 10
+
+ MouseArea {
+ id: touchMouseArea
+ anchors.fill: parent
+
+ onClicked: {
+ if (root.state == "") {
+ root.state = "show";
+ } else {
+ root.state = "";
+ }
+ }
+ }
+ }
+
+ Rectangle {
+ id: close
+ width: 50
+ height: 50
+ color: "black"
+ radius: 0
+ opacity: 0.3
+ anchors.top: parent.top
+ anchors.topMargin: 0
+ anchors.right: parent.right
+ anchors.rightMargin: 0
+
+ MouseArea {
+ id: closeMouseArea
+ anchors.fill: parent
+
+ onClicked: Qt.quit();
+ }
+ }
+ }
+
+ states: [
+ State {
+ name: "show"
+ PropertyChanges { target: posterText; y: root.height / 3 }
+ PropertyChanges { target: posterUrl; y: 2 * root.height / 3 }
+ PropertyChanges { target: posterImage; x: root.width / 20 }
+ PropertyChanges { target: touchText; opacity: 0 }
+ }
+ ]
+
+ transitions: [
+ Transition {
+ PropertyAnimation { easing.type: Easing.OutQuad; properties: "x,y" }
+ PropertyAnimation { property: "opacity"; duration: 125 }
+ }
+ ]
+}
diff --git a/examples/poster/poster.qrc b/examples/poster/poster.qrc
new file mode 100644
index 00000000..d8286e71
--- /dev/null
+++ b/examples/poster/poster.qrc
@@ -0,0 +1,6 @@
+<RCC>
+ <qresource prefix="/">
+ <file>poster.qml</file>
+ </qresource>
+ <qresource prefix="/icons"/>
+</RCC>
diff --git a/examples/poster/qmlposter.cpp b/examples/poster/qmlposter.cpp
new file mode 100644
index 00000000..ccbf9700
--- /dev/null
+++ b/examples/poster/qmlposter.cpp
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtNfc module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtDeclarative/QDeclarativeEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+ const QString mainQmlApp = QLatin1String("qrc:/poster.qml");
+ QQuickView view;
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ // Qt.quit() called in embedded .qml by default only emits
+ // quit() signal, so do this (optionally use Qt.exit()).
+ QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
+#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_6) || defined(Q_WS_SIMULATOR)
+ view.showFullScreen();
+#else // Q_OS_SYMBIAN
+ view.setGeometry(QRect(100, 100, 640, 360));
+ view.show();
+#endif // Q_OS_SYMBIAN
+ return application.exec();
+}
diff --git a/examples/scanner/qmlscanner.cpp b/examples/scanner/qmlscanner.cpp
new file mode 100644
index 00000000..47dcb15e
--- /dev/null
+++ b/examples/scanner/qmlscanner.cpp
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the QtBluetooth module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtWidgets/QApplication>
+#include <QtQuick/QQuickView>
+#include <QtDeclarative/QDeclarativeEngine>
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+ const QString mainQmlApp = QLatin1String("qrc:/scanner.qml");
+ QQuickView view;
+ view.setSource(QUrl(mainQmlApp));
+ view.setResizeMode(QQuickView::SizeRootObjectToView);
+ // Qt.quit() called in embedded .qml by default only emits
+ // quit() signal, so do this (optionally use Qt.exit()).
+ QObject::connect(view.engine(), SIGNAL(quit()), qApp, SLOT(quit()));
+#if defined(Q_OS_SYMBIAN)
+ view.showFullScreen();
+#elif defined(Q_WS_MAEMO_6)
+ view.showFullScreen();
+#else // Q_OS_SYMBIAN
+ view.setGeometry(QRect(100, 100, 360, 640));
+ view.show();
+#endif // Q_OS_SYMBIAN
+ return application.exec();
+}
diff --git a/examples/scanner/scanner.pro b/examples/scanner/scanner.pro
new file mode 100644
index 00000000..39eb453b
--- /dev/null
+++ b/examples/scanner/scanner.pro
@@ -0,0 +1,11 @@
+QT += widgets declarative network bluetooth quick
+SOURCES += qmlscanner.cpp
+
+TARGET = qml_scanner
+TEMPLATE = app
+
+RESOURCES += \
+ scanner.qrc
+
+OTHER_FILES += \
+ scanner.qml
diff --git a/examples/scanner/scanner.qml b/examples/scanner/scanner.qml
new file mode 100644
index 00000000..ac16504d
--- /dev/null
+++ b/examples/scanner/scanner.qml
@@ -0,0 +1,251 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the QtBluetooth module.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+import QtBluetooth 5.0
+
+Rectangle {
+ id: top
+
+ property BluetoothService currentService
+ property alias minimalDiscovery: myModel.minimalDiscovery
+ property alias uuidFilder: myModel.uuidFilter
+
+ anchors.fill: parent
+
+ BluetoothDiscoveryModel {
+ id: myModel
+ minimalDiscovery: true
+ onDiscoveryChanged: busy.running = discovery;
+// onNewServiceDiscovered: console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName);
+// uuidFilter: "e8e10f95-1a70-4b27-9ccf-02010264e9c9"
+ }
+
+ Rectangle {
+ id: busy
+ property bool running: true
+
+ width: top.width/1.2;
+ x: top.width/2-width/2
+ anchors.top: top.top;
+ height: 20;
+ radius: 5
+ color: "#1c56f3"
+
+ Text {
+ id: text
+ text: "<b>Scanning</b>"
+ x: busy.width/2-paintedWidth/2
+ y: busy.height/2-paintedHeight/2
+ }
+
+ SequentialAnimation on color {
+ id: busyThrobber
+ ColorAnimation { easing.type: Easing.InOutSine; from: "#1c56f3"; to: "white"; duration: 1000; }
+ ColorAnimation { easing.type: Easing.InOutSine; to: "#1c56f3"; from: "white"; duration: 1000 }
+ loops: Animation.Infinite
+ }
+ states: [
+ State {
+ name: "stopped"
+ when: !busy.running
+ PropertyChanges { target: busy; height: 0; }
+ PropertyChanges { target: busyThrobber; running: false }
+ PropertyChanges { target: text; visible: false }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "stopped"
+ reversible: true
+ NumberAnimation { target: busy; property: "height"; to: 0; duration: 200 }
+ }
+ ]
+ }
+
+ Component {
+ id: del;
+
+ Item {
+ id: item
+
+ function item_clicked(service) {
+ console.log("Clicked " + service.deviceName + service.deviceAddress);
+ top.currentService = service;
+ }
+
+ property int text_height: 5+(bticon.height > bttext.height ? bticon.height : bttext.height)
+
+ height: text_height
+ width: parent.width
+
+ Column {
+ anchors.fill: item
+ Row {
+ width: parent.width
+ Image {
+ id: bticon
+ source: icon;
+ width: del.height;
+ }
+ Text {
+ id: bttext
+ text: name;
+ font.family: "FreeSerif"
+ font.pointSize: 12
+ }
+ }
+ Text {
+ function get_details(s) {
+ var str = "Address: " + s.deviceAddress;
+ if (s.serviceName) { str += "<br>Service: " + s.serviceName; }
+ if (s.serviceDescription) { str += "<br>Description: " + s.serviceDescription; }
+ if (s.serviceProtocol) { str += "<br>Port: " + s.serviceProtocol; }
+ if (s.servicePort) { str += "<br>Port: " + s.servicePort; }
+ return str;
+ }
+
+ id: details
+ opacity: 0.0
+ text: get_details(service)
+ font: bttext.font
+ x: bticon.width
+ }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: item.state = ((item.state == "details") ? "" : "details")
+ }
+
+ states: [
+ State {
+ name: "details"
+ PropertyChanges { target: item; height: item.text_height+details.height; }
+ PropertyChanges { target: details; opacity: 1.0 }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "details"
+ reversible: true
+ NumberAnimation { target: item; property: "height"; duration: 200 }
+ NumberAnimation { target: details; property: "lopacity"; duration: 200 }
+ }
+ ]
+ }
+ }
+
+ Component {
+ id: highlightBox
+
+ Rectangle {
+ id: background
+ anchors.fill: del
+ border.color: "#34ca57"
+ radius: 5
+ border.width: 2
+ }
+
+ }
+
+ ListView {
+ id: mainList
+ width: top.width
+ anchors.top: busy.bottom
+// anchors.bottom: top.bottom
+ anchors.bottom: fullbutton.top
+
+ model: myModel
+ highlight: highlightBox
+ delegate: del
+ focus: true
+ }
+
+ Rectangle {
+ id: fullbutton
+
+ function button_clicked() {
+ myModel.minimalDiscovery = !myModel.minimalDiscovery;
+ fullbutton.state = fullbutton.state == "clicked" ? "" : "clicked";
+ myModel.setDiscovery(true);
+ }
+
+ anchors.bottom: top.bottom
+ anchors.margins: 3
+
+ width: top.width-6
+ x: 3
+ height: 20
+
+ radius: 5
+ border.width: 1
+ color: "white"
+
+ Text {
+ id: label
+ text: "Full Discovery"
+ x: parent.width/2-paintedWidth/2;
+ y: parent.height/2-paintedHeight/2;
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: fullbutton.button_clicked();
+ }
+
+ states: [
+ State {
+ name: "clicked"
+ PropertyChanges { target: fullbutton; color: "#1c56f3" }
+ }
+ ]
+ transitions: [
+ Transition {
+ from: "*"
+ to: "details"
+ reversible: true
+ ColorAnimation { duration: 200 }
+ }
+ ]
+ }
+}
diff --git a/examples/scanner/scanner.qrc b/examples/scanner/scanner.qrc
new file mode 100644
index 00000000..93e9ce08
--- /dev/null
+++ b/examples/scanner/scanner.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>scanner.qml</file>
+ </qresource>
+</RCC>
diff --git a/qtconnectivity.pro b/qtconnectivity.pro
index 245fd603..312fa6c8 100644
--- a/qtconnectivity.pro
+++ b/qtconnectivity.pro
@@ -1,6 +1,8 @@
TEMPLATE = subdirs
CONFIG += ordered
+include(doc/doc.pri)
+
module_qtconnectivity_src.subdir = src
module_qtconnectivity_src.target = module-qtconnectivity-src
diff --git a/src/bluetooth/qbluetooth.cpp b/src/bluetooth/qbluetooth.cpp
index bda46c58..07bdba3c 100644
--- a/src/bluetooth/qbluetooth.cpp
+++ b/src/bluetooth/qbluetooth.cpp
@@ -44,10 +44,9 @@
/*!
\namespace QBluetooth
\brief The QBluetooth namespace contains functions and definitions related to Bluetooth.
- \since 5.0
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
*/
/*!
diff --git a/src/bluetooth/qbluetoothaddress.cpp b/src/bluetooth/qbluetoothaddress.cpp
index 40fcfd4c..60649f9c 100644
--- a/src/bluetooth/qbluetoothaddress.cpp
+++ b/src/bluetooth/qbluetoothaddress.cpp
@@ -47,10 +47,9 @@ QTBLUETOOTH_BEGIN_NAMESPACE
/*!
\class QBluetoothAddress
\brief The QBluetoothAddress class provides a Bluetooth address.
- \since 5.0
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
This class holds a Bluetooth address in a platform- and protocol- independent manner.
*/
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
index 978ff461..271a261e 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent.cpp
@@ -48,15 +48,14 @@ QTBLUETOOTH_BEGIN_NAMESPACE
\class QBluetoothDeviceDiscoveryAgent
\brief The QBluetoothDeviceDiscoveryAgent class provides an API for discovering nearby
Bluetooth devices.
- \since 5.0
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
To discovery nearby Bluetooth devices create an instance of QBluetoothDeviceDiscoveryAgent,
connect to either the deviceDiscovered() or finished() signals and call start().
- \snippet snippets/connectivity/devicediscovery.cpp Device discovery
+ \snippet ../doc/src/snippets/devicediscovery.cpp Device discovery
To retrieve results asynchronously connect to the deviceDiscovered() signal. To get a list of
all discovered devices call discoveredDevices() after the finished() signal is emitted.
diff --git a/src/bluetooth/qbluetoothdeviceinfo.cpp b/src/bluetooth/qbluetoothdeviceinfo.cpp
index b57ee9de..ffd7814f 100644
--- a/src/bluetooth/qbluetoothdeviceinfo.cpp
+++ b/src/bluetooth/qbluetoothdeviceinfo.cpp
@@ -51,8 +51,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
\brief The QBluetoothDeviceInfo class provides information about Bluetooth devices.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
QBluetoothDeviceInfo provides information about a Bluetooth device's name, address and class of device.
*/
diff --git a/src/bluetooth/qbluetoothglobal.h b/src/bluetooth/qbluetoothglobal.h
index de4ab379..72737c2e 100644
--- a/src/bluetooth/qbluetoothglobal.h
+++ b/src/bluetooth/qbluetoothglobal.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtConnectivity module of the Qt Toolkit.
+** This file is part of the QtBluetooth module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/bluetooth/qbluetoothlocaldevice.cpp b/src/bluetooth/qbluetoothlocaldevice.cpp
index 6941eea1..131060a3 100644
--- a/src/bluetooth/qbluetoothlocaldevice.cpp
+++ b/src/bluetooth/qbluetoothlocaldevice.cpp
@@ -53,8 +53,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
\brief The QBluetoothLocalDevice class provides access to local Bluetooth devices.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
QBluetoothLocalDevice provides functions for getting and setting the state of local Bluetooth
devices.
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent.cpp b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
index 1afe9e15..567dcb3d 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent.cpp
@@ -52,14 +52,13 @@ QTBLUETOOTH_BEGIN_NAMESPACE
provided by a Bluetooth device.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
To query the services provided by all contactable Bluetooth devices create an instance of
QBluetoothServiceDiscoveryAgent, connect to either the serviceDiscovered() or finished()
signals and call start().
- \snippet snippets/connectivity/servicediscovery.cpp Service discovery
+ \snippet ../doc/src/snippets/servicediscovery.cpp Service discovery
By default a minimal service discovery is performed. In this mode the QBluetotohServiceInfo
objects returned are guaranteed to contain only device and service UUID information. Depending
diff --git a/src/bluetooth/qbluetoothserviceinfo.cpp b/src/bluetooth/qbluetoothserviceinfo.cpp
index 97178f36..398c6427 100644
--- a/src/bluetooth/qbluetoothserviceinfo.cpp
+++ b/src/bluetooth/qbluetoothserviceinfo.cpp
@@ -50,10 +50,9 @@ QTBLUETOOTH_BEGIN_NAMESPACE
\class QBluetoothServiceInfo::Sequence
\brief The Sequence class provides a data type for Bluetooth Data
Element Sequence attributes.
- \since 5.0
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
*/
/*!
@@ -74,7 +73,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
Element Alternative attributes.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
*/
/*!
@@ -94,7 +93,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
\brief The QBluetoothServiceInfo class provides information about services.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
QBluetoothServiceInfo provides information about a service offered by a Bluetooth device.
*/
diff --git a/src/bluetooth/qbluetoothsocket.cpp b/src/bluetooth/qbluetoothsocket.cpp
index 4712f1ef..517c5511 100644
--- a/src/bluetooth/qbluetoothsocket.cpp
+++ b/src/bluetooth/qbluetoothsocket.cpp
@@ -57,8 +57,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
\brief The QBluetoothSocket class provides a Bluetooth socket.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
QBluetoothSocket supports two socket types, \l {QBluetoothSocket::L2capSocket}{L2CAP} and
\l {QBluetoothSocket::RfcommSocket}{RFCOMM}.
diff --git a/src/bluetooth/qbluetoothtransfermanager.cpp b/src/bluetooth/qbluetoothtransfermanager.cpp
index 4b489ef7..f634b060 100644
--- a/src/bluetooth/qbluetoothtransfermanager.cpp
+++ b/src/bluetooth/qbluetoothtransfermanager.cpp
@@ -50,8 +50,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
devices. Currently implemented using OPP.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
QBluetoothTransferManager uses OBEX to send get and put commands to remote devices.
*/
diff --git a/src/bluetooth/qbluetoothtransferreply.cpp b/src/bluetooth/qbluetoothtransferreply.cpp
index b68ae34f..f4820e8a 100644
--- a/src/bluetooth/qbluetoothtransferreply.cpp
+++ b/src/bluetooth/qbluetoothtransferreply.cpp
@@ -52,8 +52,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
QBluetoothTranferManager.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
In additional to a copy of the QBluetoothTransferRequest object used to create the request,
QBluetoothTransferReply contains the contents of the reply itself.
@@ -207,6 +206,12 @@ void QBluetoothTransferReply::setManager(QBluetoothTransferManager *manager)
}
/*!
+ \fn TransferError QBluetoothTransferReply::error() const
+
+ The error code of the error that happened.
+*/
+
+/*!
\fn QString QBluetoothTransferReply::errorString() const
String describing the error. Can be displayed to the user.
diff --git a/src/bluetooth/qbluetoothtransferrequest.cpp b/src/bluetooth/qbluetoothtransferrequest.cpp
index 21b95dd9..4e5ff4be 100644
--- a/src/bluetooth/qbluetoothtransferrequest.cpp
+++ b/src/bluetooth/qbluetoothtransferrequest.cpp
@@ -52,8 +52,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
QBluetoothTransferManager.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
QBluetoothTransferRequest is part of the Bluetooth Transfer API and is the class holding the
information necessary to initiate a transfer over Bluetooth.
diff --git a/src/bluetooth/qbluetoothuuid.cpp b/src/bluetooth/qbluetoothuuid.cpp
index 9cc57e40..4f310bb7 100644
--- a/src/bluetooth/qbluetoothuuid.cpp
+++ b/src/bluetooth/qbluetoothuuid.cpp
@@ -60,10 +60,9 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
/*!
\class QBluetoothUuid
\brief The QBluetoothUuid class provides a Bluetooth UUID.
- \since 5.0
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
*/
/*!
@@ -131,8 +130,8 @@ Q_GLOBAL_STATIC_WITH_ARGS(QUuid, baseUuid, ("{00000000-0000-1000-8000-00805F9B34
\value DirectPrinting Basic Printing Profile (BPP) UUID
\value ReferencePrinting Related to Basic Printing Profile (BPP) UUID
\value ImagingResponder Basic Imaging Profile (BIP) UUID
- \value ImagingResponder Basic Imaging Profile (BIP) UUID
\value ImagingAutomaticArchive Basic Imaging Profile (BIP) UUID
+ \value ImagingReferenceObjects Basic Imaging Profile (BIP) UUID
\value Handsfree Hands-Free Profile (HFP) Service Class Identifier and Profile Identifier
\value HandsfreeAudioGateway Hands-free Profile (HFP) UUID
\value DirectPrintingReferenceObjectsService Basic Printing Profile (BPP) UUID
diff --git a/src/bluetooth/ql2capserver.cpp b/src/bluetooth/ql2capserver.cpp
index 8a6240e8..6a8c3007 100644
--- a/src/bluetooth/ql2capserver.cpp
+++ b/src/bluetooth/ql2capserver.cpp
@@ -50,8 +50,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
\brief The QL2capServer class provides an L2CAP server.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
QL2capServer is used to implement Bluetooth services over L2CAP.
diff --git a/src/bluetooth/qrfcommserver.cpp b/src/bluetooth/qrfcommserver.cpp
index e5c24885..690e9219 100644
--- a/src/bluetooth/qrfcommserver.cpp
+++ b/src/bluetooth/qrfcommserver.cpp
@@ -50,8 +50,7 @@ QTBLUETOOTH_BEGIN_NAMESPACE
\brief The QRfcommServer class provides an RFCOMM server.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtBluetooth
QRfcommServer is used to implement Bluetooth services over RFCOMM.
diff --git a/src/bluetooth/symbian/bluetoothlinkmanagerdevicediscoverer.cpp b/src/bluetooth/symbian/bluetoothlinkmanagerdevicediscoverer.cpp
index 148ce3cb..0ad88256 100644
--- a/src/bluetooth/symbian/bluetoothlinkmanagerdevicediscoverer.cpp
+++ b/src/bluetooth/symbian/bluetoothlinkmanagerdevicediscoverer.cpp
@@ -56,10 +56,9 @@
/*! \internal
\class BluetoothLinkManagerDeviceDiscoverer
\brief The BluetoothLinkManagerDeviceDiscoverer class searches other bluetooth devices.
- \since 5.0
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
\internal
BluetoothLinkManagerDeviceDiscoverer is an Symbian ActiveObject derived class that discovers
diff --git a/src/bluetooth/symbian/bluetoothsymbianpairingadapter.cpp b/src/bluetooth/symbian/bluetoothsymbianpairingadapter.cpp
index 96186b50..43b6669e 100644
--- a/src/bluetooth/symbian/bluetoothsymbianpairingadapter.cpp
+++ b/src/bluetooth/symbian/bluetoothsymbianpairingadapter.cpp
@@ -60,7 +60,7 @@ const static TInt BTKErrRemoteDeviceIndicatedNoBonding = KLinkManagerErrBase-4;
It uses following Symbian class CBTEngConnMan for native operations.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
\internal
*/
diff --git a/src/bluetooth/symbian/bluetoothsymbianregistryadapter.cpp b/src/bluetooth/symbian/bluetoothsymbianregistryadapter.cpp
index f4a45371..1ea237e1 100644
--- a/src/bluetooth/symbian/bluetoothsymbianregistryadapter.cpp
+++ b/src/bluetooth/symbian/bluetoothsymbianregistryadapter.cpp
@@ -56,7 +56,7 @@
It uses following Symbian class CBTEngDevMan for native operations.
\ingroup connectivity-bluetooth
- \inmodule QtConnectivity
+ \inmodule QtBluetooth
\internal
@internalComponent
diff --git a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
index 18224a36..46e01cd1 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothdiscoverymodel.cpp
@@ -52,10 +52,10 @@
\qmlclass BluetoothDiscoveryModel QDeclarativeBluetoothDiscoveryModel
\brief The BluetoothDisoceryModel element provides access device and service scanning
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup bluetooth-qml
+ \inmodule QtBluetooth
- This element is part of the \bold{QtConnectivity} module.
+ The BluetoothDiscoveryModel element was introduced in \bold{QtBluetooth 5.0}.
BluetoothDiscoveryModel provides a model of connectable services. The
contents of the model can be filtered by UUID allowing discovery to be
diff --git a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
index f1836a6f..74e722b8 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothservice.cpp
@@ -53,15 +53,15 @@
/*!
\qmlclass BluetoothService QDeclarativeBluetoothService
- \brief The BluetoothService element contains all the information available for a single bluetooth service.\.
+ \brief The BluetoothService element contains all the information available for a single Bluetooth service.\.
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup bluetooth-qml
+ \inmodule QtBluetooth
\sa QBluetoothAddress
\sa QBluetoothSocket
- The BluetoothService element is part of the \bold{QtMobility.connectivity 1.2} module.
+ The BluetoothService element was introduced in \bold{QtBluetooth 5.0}.
It allows a QML project to get information about a remote service, or describe a service
for a BluetoothSocket to connect to.
diff --git a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
index 904b48f0..3e784e80 100644
--- a/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
+++ b/src/imports/bluetooth/qdeclarativebluetoothsocket.cpp
@@ -59,13 +59,13 @@
\qmlclass BluetoothSocket QDeclarativeBluetoothSocket
\brief The BluetoothSocket element represents a single bluetooth client socket.
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup bluetooth-qml
+ \inmodule QtBluetooth
\sa QBluetoothSocket
\sa QDataStream
- The BluetoothSocket element is part of the \bold{QtConnectivity} module.
+ The BluetoothSocket element was introduced in \bold{QtBluetooth 5.0}.
It allows a QML class easily connect to another bluetooth device and send
and received QString's from the device. Data is sent and received via a
diff --git a/src/imports/nfc/qdeclarativendeffilter.cpp b/src/imports/nfc/qdeclarativendeffilter.cpp
index b44dd365..8efd5080 100644
--- a/src/imports/nfc/qdeclarativendeffilter.cpp
+++ b/src/imports/nfc/qdeclarativendeffilter.cpp
@@ -45,13 +45,13 @@
\qmlclass NdefFilter QDeclarativeNdefFilter
\brief The NdefFilter element represents a filtering constraint for NDEF message records.
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup nfc-qml
+ \inmodule QtNfc
\sa NearField
\sa QNdefFilter
- The NdefFilter element is part of the \bold {QtMobility.connectivity 1.2} module.
+ The NdefFilter element was introduced in \bold {QtNfc 5.0}.
The NdefFilter element is used with the NearField element to read NDEF messages from NFC Forum
tags that match a given structure.
diff --git a/src/imports/nfc/qdeclarativendefmimerecord.cpp b/src/imports/nfc/qdeclarativendefmimerecord.cpp
index f854754d..493bb63a 100644
--- a/src/imports/nfc/qdeclarativendefmimerecord.cpp
+++ b/src/imports/nfc/qdeclarativendefmimerecord.cpp
@@ -46,11 +46,11 @@
\brief The NdefMimeRecord element represents an NFC MIME record.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
\inherits NdefRecord
- The NdefMimeRecord element is part of the \bold {QtMobility.connectivity 1.2} module.
+ The NdefMimeRecord element was introduced in \bold {QtNfc 5.0}.
The NdefMimeRecord element can contain data with an associated MIME type. The data is
accessible from the uri in the \l {NdefMimeRecord::uri}{uri} property.
diff --git a/src/imports/nfc/qdeclarativendeftextrecord.cpp b/src/imports/nfc/qdeclarativendeftextrecord.cpp
index 9fe6d898..eda5ce6f 100644
--- a/src/imports/nfc/qdeclarativendeftextrecord.cpp
+++ b/src/imports/nfc/qdeclarativendeftextrecord.cpp
@@ -47,14 +47,14 @@
\qmlclass NdefTextRecord QDeclarativeNdefTextRecord
\brief The NdefTextRecord element represents an NFC RTD-Text NDEF record.
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup nfc-qml
+ \inmodule QtNfc
\inherits NdefRecord
\sa QNdefNfcTextRecord
- The NdefTextRecord element is part of the \bold {QtMobility.connectivity 1.2} module.
+ The NdefTextRecord element was introduced in \bold {QtNfc 5.0}.
The NdefTextRecord element contains a localized piece of text that can be display to the user.
An NDEF message may contain many text records for different locales, it is up to the
diff --git a/src/imports/nfc/qdeclarativendefurirecord.cpp b/src/imports/nfc/qdeclarativendefurirecord.cpp
index 4d8e43ca..38b4556a 100644
--- a/src/imports/nfc/qdeclarativendefurirecord.cpp
+++ b/src/imports/nfc/qdeclarativendefurirecord.cpp
@@ -47,14 +47,14 @@
\qmlclass NdefUriRecord QDeclarativeNdefUriRecord
\brief The NdefUriRecord element represents an NFC RTD-URI NDEF record.
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup nfc-qml
+ \inmodule QtNfc
\inherits NdefRecord
\sa QNdefNfcUriRecord
- The NdefUriRecord element is part of the \bold {QtMobility.connectivity 1.2} module.
+ The NdefUriRecord element was introduced in \bold {QtNfc 5.0}.
*/
/*!
diff --git a/src/imports/nfc/qdeclarativenearfield.cpp b/src/imports/nfc/qdeclarativenearfield.cpp
index d20f39ee..e6e9b7c8 100644
--- a/src/imports/nfc/qdeclarativenearfield.cpp
+++ b/src/imports/nfc/qdeclarativenearfield.cpp
@@ -53,8 +53,8 @@
\qmlclass NearField QDeclarativeNearField
\brief The NearField element provides access to NDEF messages stored on NFC Forum tags.
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup nfc-qml
+ \inmodule QtNfc
\sa NdefFilter
\sa NdefRecord
@@ -63,7 +63,7 @@
\sa QNdefMessage
\sa QNdefRecord
- The NearField element is part of the \bold {QtNfc 5.0} module.
+ The NearField element was introduced in \bold {QtNfc 5.0}.
The NearField element can be used to read NDEF messages from NFC Forum tags. Set the \l filter
and \l orderMatch properties to match the required NDEF messages. Once an NDEF message is
diff --git a/src/imports/nfc/qdeclarativenearfieldsocket.cpp b/src/imports/nfc/qdeclarativenearfieldsocket.cpp
index ee19d0a6..4ffd6d0e 100644
--- a/src/imports/nfc/qdeclarativenearfieldsocket.cpp
+++ b/src/imports/nfc/qdeclarativenearfieldsocket.cpp
@@ -47,13 +47,13 @@
\qmlclass NearFieldSocket QDeclarativeNearFieldSocket
\brief The NearFieldSocket element represents an LLCP socket.
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup nfc-qml
+ \inmodule QtNfc
\sa QLlcpSocket
\sa QLlcpServer
- The NearFieldSocket element is part of the \bold {QtMobility.connectivity 1.2} module.
+ The NearFieldSocket element was introduced in \bold {QtNfc 5.0}.
The NearFieldSocket element can be used to create a peer-to-peer connection over NFC LLCP
sockets. NearfieldSocket can be used for both client and server side sockets.
diff --git a/src/nfc/qdeclarativendefrecord.cpp b/src/nfc/qdeclarativendefrecord.cpp
index 8cf9dc56..901b4fb1 100644
--- a/src/nfc/qdeclarativendefrecord.cpp
+++ b/src/nfc/qdeclarativendefrecord.cpp
@@ -51,8 +51,7 @@ QTNFC_BEGIN_NAMESPACE
\brief The QDeclarativeNdefRecord class implements the NdefRecord element in QML.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
\sa NdefRecord
@@ -72,11 +71,11 @@ QTNFC_BEGIN_NAMESPACE
For example the declaration of such a class may look like the following.
- \snippet snippets/connectivity/foorecord.h Foo declaration
+ \snippet ../doc/src/snippets/foorecord.h Foo declaration
Within the implementation file the Q_DECLARE_NDEFRECORD() macro is expanded:
- \snippet snippets/connectivity/foorecord.cpp Declare foo record
+ \snippet ../doc/src/snippets/foorecord.cpp Declare foo record
Finially the application or plugin code calls qmlRegisterType():
@@ -89,8 +88,8 @@ QTNFC_BEGIN_NAMESPACE
\qmlclass NdefRecord QDeclarativeNdefRecord
\brief The NdefRecord element represents a record in an NDEF message.
- \ingroup connectivity-qml
- \inmodule QtConnectivity
+ \ingroup nfc-qml
+ \inmodule QtNfc
\sa NdefFilter
\sa NearField
diff --git a/src/nfc/qllcpserver.cpp b/src/nfc/qllcpserver.cpp
index c7e3697b..d39dc501 100644
--- a/src/nfc/qllcpserver.cpp
+++ b/src/nfc/qllcpserver.cpp
@@ -58,8 +58,7 @@ QTNFC_BEGIN_NAMESPACE
\brief The QLlcpServer class provides an NFC LLCP socket based server.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
This class makes it possible to accept incoming LLCP socket connections.
@@ -152,8 +151,7 @@ QString QLlcpServer::serviceUri() const
/*!
Returns the LLCP port associated with the service URI that the server is listening on.
-
- \note This call is not supported on all platforms and will return 0 on these platforms.
+ This call is not supported on all platforms and will return 0 on these platforms.
*/
quint8 QLlcpServer::serverPort() const
{
diff --git a/src/nfc/qllcpsocket.cpp b/src/nfc/qllcpsocket.cpp
index e79da7fb..08f3c177 100644
--- a/src/nfc/qllcpsocket.cpp
+++ b/src/nfc/qllcpsocket.cpp
@@ -56,10 +56,9 @@ QTNFC_BEGIN_NAMESPACE
/*!
\class QLlcpSocket
\brief The QLlcpSocket class provides an NFC LLCP socket.
- \since 5.0
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
NFC LLCP protocol is a peer-to-peer communication protocol between two NFC compliant devices.
*/
diff --git a/src/nfc/qndeffilter.cpp b/src/nfc/qndeffilter.cpp
index d89bb85b..86de8aa4 100644
--- a/src/nfc/qndeffilter.cpp
+++ b/src/nfc/qndeffilter.cpp
@@ -50,8 +50,7 @@ QTNFC_BEGIN_NAMESPACE
\brief The QNdefFilter class provides a filter for matching NDEF messages.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
The QNdefFilter encapsulates the structure of an NDEF message and is used by
QNearFieldManager::registerNdefMessageHandler() to match NDEF message that have a particular
diff --git a/src/nfc/qndefmessage.cpp b/src/nfc/qndefmessage.cpp
index 9966097a..e311b1ff 100644
--- a/src/nfc/qndefmessage.cpp
+++ b/src/nfc/qndefmessage.cpp
@@ -49,8 +49,7 @@ QTNFC_BEGIN_NAMESPACE
\brief The QNdefMessage class provides an NFC NDEF message.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
A QNdefMessage is a collection of 0 or more QNdefRecords. QNdefMessage inherits from
QList<QNdefRecord> and therefore the standard QList functions can be used to manipulate the
diff --git a/src/nfc/qndefnfctextrecord.cpp b/src/nfc/qndefnfctextrecord.cpp
index 133f9ea4..098d78aa 100644
--- a/src/nfc/qndefnfctextrecord.cpp
+++ b/src/nfc/qndefnfctextrecord.cpp
@@ -51,8 +51,7 @@ QTNFC_BEGIN_NAMESPACE
\brief The QNdefNfcTextRecord class provides an NFC RTD-Text
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
RTD-Text encapsulates a user displayable text record.
*/
diff --git a/src/nfc/qndefnfcurirecord.cpp b/src/nfc/qndefnfcurirecord.cpp
index 08768b7c..31980488 100644
--- a/src/nfc/qndefnfcurirecord.cpp
+++ b/src/nfc/qndefnfcurirecord.cpp
@@ -53,8 +53,7 @@ QTNFC_BEGIN_NAMESPACE
\brief The QNdefNfcUriRecord class provides an NFC RTD-URI
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
RTD-URI encapsulates a URI.
*/
diff --git a/src/nfc/qndefrecord.cpp b/src/nfc/qndefrecord.cpp
index 4d165075..3a2d6734 100644
--- a/src/nfc/qndefrecord.cpp
+++ b/src/nfc/qndefrecord.cpp
@@ -52,8 +52,7 @@ QTNFC_BEGIN_NAMESPACE
\brief The QNdefRecord class provides an NFC NDEF record.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
QNdefRecord and derived classes are used to parse the contents of
\l {QNdefMessage}{NDEF messages} and create new NDEF messages.
@@ -73,7 +72,7 @@ QTNFC_BEGIN_NAMESPACE
to test if a conversion is possible. The following example shows how to test if a QNdefRecord
is an NFC RTD Text record and extract the text information from it.
- \snippet snippets/connectivity/nfc.cpp Record conversion
+ \snippet ../doc/src/snippets/nfc.cpp Record conversion
\section1 Creating specialized NDEF record classes
@@ -82,7 +81,7 @@ QTNFC_BEGIN_NAMESPACE
declaration of the hypothetical \i {example.com:f} record type that encapsulates a single int
property foo.
- \snippet snippets/connectivity/nfc.cpp Specialized class definition
+ \snippet ../doc/src/snippets/nfc.cpp Specialized class definition
The developer only needs to provide implementations for the \c {foo()} and \c {setFoo()}
functions that parse and set the contents of the NDEF record's payload.
diff --git a/src/nfc/qnearfieldmanager.cpp b/src/nfc/qnearfieldmanager.cpp
index 671109c3..76514a7f 100644
--- a/src/nfc/qnearfieldmanager.cpp
+++ b/src/nfc/qnearfieldmanager.cpp
@@ -62,8 +62,7 @@ QTNFC_BEGIN_NAMESPACE
\brief The QNearFieldManager class provides access to notifications for NFC events.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
NFC Forum devices support two modes of communications. The first mode, peer-to-peer
communications, is used to communicate between two NFC Forum devices. The second mode,
@@ -145,113 +144,10 @@ QTNFC_BEGIN_NAMESPACE
SLOT(handleNdefMessage(QNdefMessage,QNearFieldTarget)));
\endcode
- \section3 Symbian^3
-
- On Symbian^3 an xml file needs to be created and installed into a particular directory on the
- device. The format of the xml is given below.
-
- \quotefile tools/ndefhandlergen/templates/symbian/symbian.xml
-
- The \i {%APPNAME%} tags need to be changed to match the name of the application. The
- \i description xml tags should be used to describe the application, however these values are
- not used. The \i {%DATATYPE%} tag must be set with the NDEF record type to match For example
- the following would be used to match NDEF messages that contain a RTD-URI record:
-
\code
<customproperty key="datatype">urn:nfc:wkt:U</customproperty>
\endcode
- The following would be used to match NDEF messages that contain a custom type
- urn:nfc:ext:example.com:f:
-
- \code
- <customproperty key="datatype">urn:nfc:ext:com.example:f</customproperty>
- \endcode
-
- The value of the \i customproperty xml tag can be set to any valid match string supported by
- the Symbian^3 platform.
-
- It is recommended to name the xml file after the application package name. For example
- myapplication.xml. To install the above xml file into the correct location the following should
- be added to the application .pro file:
-
- \code
- symbian {
- ndefhandler.sources = myapplication.xml
- ndefhandler.path = /private/2002AC7F/import/
- DEPLOYMENT += ndefhandler
- }
- \endcode
-
- \section3 Maemo6
-
- On Maemo6 the NDEF message handler notifications are passed over D-Bus. Registration of the
- NDEF message match criteria is done via a D-Bus call. The application must also ensure that it
- has registered a D-Bus service name so that the application can be automatically launched when
- a notification message is sent to the registered service.
-
- To register the D-Bus service the two files need to be created and installed into particular
- directories on the device. The first file is the D-Bus bus configuration file:
-
- \quotefile tools/ndefhandlergen/templates/maemo6/maemo6.conf
-
- The \i {%APPNAME%} tag must be replaced with the name of your application binary.
-
- The second file is a D-Bus service file which is used by the D-Bus daemon to launch your
- application.
-
- \quotefile tools/ndefhandlergen/templates/maemo6/maemo6.service
-
- The \i {%APPNAME%} tag must be replace with the name of your application binary and the
- \i {%APPPATH%} tag must be replaced with the path to your installed application binary.
-
- It is recommended to name these files after the application package name. For example
- myapplication.conf and myapplication.service. To install the above files into the correct
- location the following should be added to the application .pro file:
-
- \code
- maemo6 {
- ndefhandler_conf.sources = myapplication.conf
- ndefhandler_conf.path = /etc/dbus-1/system.d/
-
- ndefhandler_service.sources = myapplication.service
- ndefhandler_service.path = /usr/share/dbus-1/system-services/
-
- DEPLOYMENT += ndefhandler_conf ndefhandler_service
- }
- \endcode
-
- The NDEF message handler is registered with the following D-Bus command. Applications should
- ensure that the following command (or similar) is executed once at installation time. For
- example in the packages post-installation script.
-
- \quotefile tools/ndefhandlergen/templates/maemo6/maemo6.postinst
-
- The \i {%APPNAME%} string must be replaced with the name of the application binary. The
- \i {%DATATYPE%} string must be replaced with the NDEF record type to match. For example the
- following would be used to match NDEF messages that contain a RTD-URI record:
-
- \code
- string:"urn:nfc:wkt:U[1:*];"
- \endcode
-
- The following would be used to match NDEF messages that contain a custom type
- urn:nfc:ext:example.com:f:
-
- \code
- string:"urn:nfc:ext:example.com:f[1:*];"
- \endcode
-
- Note that \c {[1:*]} indicates one or more records of the specified type must be in the NDEF
- message. The value of the datatype string argument can be set to any valid match string
- supported by the Maemo6 platform.
-
- The NDEF message handler should be unregistered at uninstallation time. For example in the
- packages pre-removal script.
-
- \quotefile tools/ndefhandlergen/templates/maemo6/maemo6.prerm
-
- The \i {%APPNAME%} string must be replace with the name of the application binary.
*/
/*!
diff --git a/src/nfc/qnearfieldmanager_symbian.cpp b/src/nfc/qnearfieldmanager_symbian.cpp
index a2343320..41fe8612 100644
--- a/src/nfc/qnearfieldmanager_symbian.cpp
+++ b/src/nfc/qnearfieldmanager_symbian.cpp
@@ -79,7 +79,7 @@ void ContentHandlerInterface::handleMessage(const QByteArray& btArray)
\brief The QNearFieldManagerPrivateImpl class provides symbian backend access to NFC service.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
A Qt-Symbian wrapper implementation class to support symbian NFC backend.
*/
diff --git a/src/nfc/qnearfieldtagtype1.cpp b/src/nfc/qnearfieldtagtype1.cpp
index cd63f1d6..d9845ef7 100644
--- a/src/nfc/qnearfieldtagtype1.cpp
+++ b/src/nfc/qnearfieldtagtype1.cpp
@@ -55,10 +55,9 @@ QTNFC_BEGIN_NAMESPACE
\class QNearFieldTagType1
\brief The QNearFieldTagType1 class provides an interface for communicating with an NFC Tag
Type 1 tag.
- \since 5.0
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
*/
/*!
diff --git a/src/nfc/qnearfieldtagtype1_symbian.cpp b/src/nfc/qnearfieldtagtype1_symbian.cpp
index f1adfede..1cfe1b42 100644
--- a/src/nfc/qnearfieldtagtype1_symbian.cpp
+++ b/src/nfc/qnearfieldtagtype1_symbian.cpp
@@ -171,7 +171,7 @@ QVariant QNearFieldTagType1Symbian::decodeResponse(const QByteArray &command, co
Type 1 tag.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
*/
/*
diff --git a/src/nfc/qnearfieldtagtype2.cpp b/src/nfc/qnearfieldtagtype2.cpp
index 6ee0f77d..7755af68 100644
--- a/src/nfc/qnearfieldtagtype2.cpp
+++ b/src/nfc/qnearfieldtagtype2.cpp
@@ -54,10 +54,9 @@ QTNFC_BEGIN_NAMESPACE
\class QNearFieldTagType2
\brief The QNearFieldTagType2 class provides an interface for communicating with an NFC Tag
Type 2 tag.
- \since 5.0
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
*/
/*!
diff --git a/src/nfc/qnearfieldtagtype3.cpp b/src/nfc/qnearfieldtagtype3.cpp
index 68f26bfb..c39b7812 100644
--- a/src/nfc/qnearfieldtagtype3.cpp
+++ b/src/nfc/qnearfieldtagtype3.cpp
@@ -47,10 +47,9 @@ QTNFC_BEGIN_NAMESPACE
\class QNearFieldTagType3
\brief The QNearFieldTagType3 class provides an interface for communicating with an NFC Tag
Type 3 tag.
- \since 5.0
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
*/
/*!
diff --git a/src/nfc/qnearfieldtagtype4.cpp b/src/nfc/qnearfieldtagtype4.cpp
index 0fa36ac7..6bd59de8 100644
--- a/src/nfc/qnearfieldtagtype4.cpp
+++ b/src/nfc/qnearfieldtagtype4.cpp
@@ -47,10 +47,9 @@ QTNFC_BEGIN_NAMESPACE
\class QNearFieldTagType4
\brief The QNearFieldTagType4 class provides an interface for communicating with an NFC Tag
Type 4 tag.
- \since 5.0
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
*/
/*!
diff --git a/src/nfc/qnearfieldtarget.cpp b/src/nfc/qnearfieldtarget.cpp
index 6bdfbc8a..aea8b0de 100644
--- a/src/nfc/qnearfieldtarget.cpp
+++ b/src/nfc/qnearfieldtarget.cpp
@@ -57,8 +57,7 @@ QTNFC_BEGIN_NAMESPACE
device.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
QNearFieldTarget provides a generic interface for communicating with an NFC target device.
Both NFC Forum devices and NFC Forum Tag targets are supported by this class. All target
diff --git a/src/nfc/qnfcglobal.h b/src/nfc/qnfcglobal.h
index 3e9618b6..6cb90386 100644
--- a/src/nfc/qnfcglobal.h
+++ b/src/nfc/qnfcglobal.h
@@ -4,7 +4,7 @@
** All rights reserved.
** Contact: http://www.qt-project.org/
**
-** This file is part of the QtConnectivity module of the Qt Toolkit.
+** This file is part of the QtNfc module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
diff --git a/src/nfc/symbian/nearfieldmanager_symbian.cpp b/src/nfc/symbian/nearfieldmanager_symbian.cpp
index b6e6f636..ca4826ca 100644
--- a/src/nfc/symbian/nearfieldmanager_symbian.cpp
+++ b/src/nfc/symbian/nearfieldmanager_symbian.cpp
@@ -52,8 +52,7 @@
\brief The CNearFieldManager class provides symbian backend implementation to access NFC service.
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
\internal
A Symbian implementation class to support symbian NFC backend.
diff --git a/src/nfc/symbian/nearfieldtag_symbian.cpp b/src/nfc/symbian/nearfieldtag_symbian.cpp
index 5e4a6a41..3b68cdf3 100644
--- a/src/nfc/symbian/nearfieldtag_symbian.cpp
+++ b/src/nfc/symbian/nearfieldtag_symbian.cpp
@@ -50,9 +50,8 @@
\brief The CNearFieldTag class provides ways to access tag
\ingroup connectivity-nfc
- \inmodule QtConnectivity
+ \inmodule QtNfc
\internal
- \since 5.0
*/
CNearFieldTag::CNearFieldTag(MNfcTag * aNfcTag, RNfcServer& aNfcServer) : CActive(EPriorityStandard),
diff --git a/src/nfc/symbian/nearfieldtargetfactory_symbian.cpp b/src/nfc/symbian/nearfieldtargetfactory_symbian.cpp
index 959f46e1..32e8d1c9 100644
--- a/src/nfc/symbian/nearfieldtargetfactory_symbian.cpp
+++ b/src/nfc/symbian/nearfieldtargetfactory_symbian.cpp
@@ -59,8 +59,7 @@
to the input tag information
\ingroup connectivity-nfc
- \inmodule QtConnectivity
- \since 5.0
+ \inmodule QtNfc
*/
/*
diff --git a/tests/btclient/btclient.c b/tests/btclient/btclient.c
index 6ad40b0f..4d06460d 100644
--- a/tests/btclient/btclient.c
+++ b/tests/btclient/btclient.c
@@ -96,10 +96,10 @@ const char *xmldefn =
" </sequence>\n"
" </attribute>\n"
" <attribute id=\"0x0100\">\n"
- " <text value=\"QtConnectivity Test Echo Server\" />\n"
+ " <text value=\"QtBluetooth Test Echo Server\" />\n"
" </attribute>\n"
" <attribute id=\"0x0101\">\n"
- " <text value=\"QtConnectivity test echo server\" />\n"
+ " <text value=\"QtBluetooth test echo server\" />\n"
" </attribute>\n"
" <attribute id=\"0x0102\">\n"
" <text value=\"Nokia, QtDF\" />\n"