Enable Bluetooth examples

Change-Id: Ifa01f167a576f167be5b0388e736c95c219a00f2
Reviewed-by: Alex <alex.blasche@nokia.com>
This commit is contained in:
alex 2012-03-01 17:20:32 +01:00 committed by Qt by Nokia
parent 940737ffe7
commit 72c555821b
25 changed files with 48 additions and 355 deletions

View File

@ -87,9 +87,6 @@ The following sample applications show examples of API usage:
\row
\li \l{btscanner}{Bluetooth Scanner}
\li Scan for Bluetooth devices.
\row
\li \l{bluetoothtransferplugin}{Bluetooth Transfer Plugin}
\li A Service Framework plugin that enables sending files over Bluetooth through the Service Framework
\endtable

View File

@ -51,9 +51,6 @@
\row
\li \l{btscanner}{Bluetooth Scanner}
\li Scan for Bluetooth devices.
\row
\li \l{bluetoothtransferplugin}{Bluetooth Transfer Plugin}
\li A Service Framework plugin that enables sending files over Bluetooth through the Service Framework
\endtable
\section2 QML Examples

View File

@ -1,46 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** 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, \li{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
*/

View File

@ -2,9 +2,6 @@ QT += nfc widgets
CONFIG += strict_flags
INCLUDEPATH += $$PWD/../../src/connectivity/nfc
DEPENDPATH += $$PWD/../../src/connectivity/nfc
TARGET = annotatedurl
SOURCES += main.cpp \

View File

@ -1,55 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** 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]

View File

@ -1,57 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** 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

View File

@ -1,54 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** 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)

View File

@ -1,57 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/
**
** 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

View File

@ -1,16 +0,0 @@
TEMPLATE = lib
CONFIG += plugin
PLUGIN_TYPE=serviceframework
QT += concurrent 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

View File

@ -1,13 +0,0 @@
<?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>

View File

@ -1,10 +1,8 @@
TEMPLATE = app
TARGET = btchat
QT += concurrent bluetooth widgets
INCLUDEPATH += ../../src/connectivity/bluetooth
DEPENDPATH += ../../src/connectivity/bluetooth
SOURCES = \
main.cpp \
chat.cpp \

View File

@ -52,9 +52,11 @@ QT_FORWARD_DECLARE_CLASS(QListWidgetItem)
QTBLUETOOTH_USE_NAMESPACE
QT_BEGIN_NAMESPACE
namespace Ui {
class RemoteSelector;
}
QT_END_NAMESPACE
class RemoteSelector : public QDialog
{

View File

@ -1,10 +1,8 @@
TEMPLATE = app
TARGET = btfiletransfer
QT += concurrent bluetooth widgets
INCLUDEPATH += ../../src/connectivity/bluetooth
DEPENDPATH += ../../src/connectivity/bluetooth
SOURCES = \
main.cpp \
remoteselector.cpp \

View File

@ -43,9 +43,11 @@
#include <QDialog>
QT_BEGIN_NAMESPACE
namespace Ui {
class pinDisplay;
}
QT_END_NAMESPACE
class pinDisplay : public QDialog
{

View File

@ -51,9 +51,11 @@ QTBLUETOOTH_END_NAMESPACE
QTBLUETOOTH_USE_NAMESPACE
QT_BEGIN_NAMESPACE
namespace Ui {
class Progress;
}
QT_END_NAMESPACE
class Progress : public QDialog
{

View File

@ -57,9 +57,11 @@ class pinDisplay;
QTBLUETOOTH_USE_NAMESPACE
QT_BEGIN_NAMESPACE
namespace Ui {
class RemoteSelector;
}
QT_END_NAMESPACE
class RemoteSelector : public QDialog
{

View File

@ -1,8 +1,5 @@
TARGET = btscanner
INCLUDEPATH += ../../src/connectivity/bluetooth
DEPENDPATH += ../../src/connectivity/bluetooth
QT += concurrent bluetooth widgets
TEMPLATE = app

View File

@ -1,14 +1,8 @@
TEMPLATE = app
TARGET = bttennis
INCLUDEPATH += \
../../src/connectivity/bluetooth \
../../src/connectivity/nfc
DEPENDPATH += \
../../src/connectivity/bluetooth \
../../src/connectivity/nfc
QT += concurrent bluetooth nfc widgets
QT += concurrent bluetooth widgets
#QT += nfc
SOURCES = \
main.cpp \
@ -17,8 +11,8 @@ SOURCES = \
controller.cpp \
tennisserver.cpp \
tennisclient.cpp \
tennisview.cpp \
handover.cpp
tennisview.cpp
# handover.cpp
HEADERS = \
board.h \
@ -26,8 +20,8 @@ HEADERS = \
controller.h \
tennisserver.h \
tennisclient.h \
tennisview.h \
handover.h
tennisview.h
# handover.h
FORMS = \
tennis.ui

View File

@ -53,7 +53,7 @@
#include "tennisserver.h"
#include "tennisclient.h"
#include "handover.h"
//#include "handover.h"
#include <qbluetooth.h>
#include <qbluetoothdeviceinfo.h>
@ -61,13 +61,13 @@
#include <qbluetoothservicediscoveryagent.h>
#include <qbluetoothlocaldevice.h>
#include <qnearfieldmanager.h>
#include <qllcpserver.h>
#include <qllcpsocket.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)
m_discoveryAgent(new QBluetoothServiceDiscoveryAgent)//, m_handover(0)
{
// start Bluetooth if not started
QBluetoothLocalDevice *device = new QBluetoothLocalDevice();
@ -139,7 +139,7 @@ Tennis::Tennis(QWidget *parent)
// ui->pongView->setBackgroundBrush(QBrush(Qt::white));
ui->pongView->setCacheMode(QGraphicsView::CacheBackground);
QNearFieldManager nearFieldManager;
/* QNearFieldManager nearFieldManager;
if (nearFieldManager.isAvailable()) {
m_handover = new Handover(server->serverPort(), this);
connect(m_handover, SIGNAL(bluetoothServiceChanged()), this, SLOT(nearFieldHandover()));
@ -147,7 +147,7 @@ Tennis::Tennis(QWidget *parent)
connect(m_discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)),
this, SLOT(serviceDiscovered(QBluetoothServiceInfo)));
connect(m_discoveryAgent, SIGNAL(finished()), this, SLOT(discoveryFinished()));
}
}*/
m_discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid));
@ -188,9 +188,9 @@ Tennis::Tennis(QWidget *parent)
service.setDevice(device);
client->startClient(service);
board->setStatus("Connecting", 100, 25);
} else if (nearFieldManager.isAvailable()) {
} /*else if (nearFieldManager.isAvailable()) {
board->setStatus(tr("Touch to play"), 100, 25);
}
}*/
setEnabled(true);
@ -394,7 +394,7 @@ void Tennis::lagReport(int ms)
}
}
void Tennis::nearFieldHandover()
/*void Tennis::nearFieldHandover()
{
qDebug() << "Connecting to NFC provided address" << m_handover->bluetoothAddress().toString();
@ -415,7 +415,7 @@ void Tennis::nearFieldHandover()
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)
{

View File

@ -65,7 +65,7 @@ static const QLatin1String serviceUuid("e8e10f95-1a70-4b27-9ccf-02010264e9c9");
class TennisServer;
class TennisClient;
class Handover;
//class Handover;
//! [declaration]
class Tennis : public QDialog
@ -105,7 +105,7 @@ private slots:
void lagReport(int ms);
void nearFieldHandover();
// void nearFieldHandover();
void fps(const QString &f);
@ -135,6 +135,6 @@ private:
QPropertyAnimation *paddleAnimation;
QBluetoothServiceDiscoveryAgent *m_discoveryAgent;
Handover *m_handover;
// Handover *m_handover;
};
//! [declaration]

View File

@ -53,7 +53,9 @@ QTBLUETOOTH_BEGIN_NAMESPACE
class QBluetoothSocket;
QTBLUETOOTH_END_NAMESPACE
QT_BEGIN_NAMESPACE
class QDataStream;
QT_END_NAMESPACE
QTBLUETOOTH_USE_NAMESPACE

11
examples/examples.pro Normal file
View File

@ -0,0 +1,11 @@
TEMPLATE = subdirs
SUBDIRS += btchat \
btscanner \
btfiletransfer \
bttennis \
scanner
#Qt NFC based examples
#SUBDIRS += poster \
# ndefeditor \
# annotatedurl

View File

@ -1,6 +1,3 @@
INCLUDEPATH += $$PWD/../../src/connectivity/nfc
DEPENDPATH += $$PWD/../../src/connectivity/nfc
QT += nfc widgets
TARGET = ndefeditor

View File

@ -38,24 +38,20 @@
**
****************************************************************************/
import Qt 4.7
import QtQuick 2.0
import QtBluetooth 5.0
Rectangle {
Item {
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"
onNewServiceDiscovered: console.log("Found new service " + service.deviceAddress + " " + service.deviceName + " " + service.serviceName);
}
Rectangle {
@ -192,7 +188,6 @@ Rectangle {
id: mainList
width: top.width
anchors.top: busy.bottom
// anchors.bottom: top.bottom
anchors.bottom: fullbutton.top
model: myModel

View File

@ -22,6 +22,6 @@ module_qtconnectivity_examples.depends = module_qtconnectivity_src
SUBDIRS += module_qtconnectivity_src \
module_qtconnectivity_tests \
#module_qtconnectivity_examples # there are no examples yet
module_qtconnectivity_examples
include(doc/doc.pri)