summaryrefslogtreecommitdiffstats
path: root/examples/btchat
diff options
context:
space:
mode:
authorJerome Pasion <jerome.pasion@digia.com>2012-09-25 15:20:41 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-27 14:43:52 +0200
commitd8a179128c0fa8e9cc482df58b9334c696602be6 (patch)
treedd5032440aa87dfd63c973265adc9947db0918f6 /examples/btchat
parent9d89c661395347bdda9362a77d38c86ad60f486b (diff)
Qt Bluetooth: Modularized documentation
-moved documentation to src/bluetooth/doc -added a qdocconf file for Qt Bluetooth -fixed relative paths for snippets -moved examples to examples/bluetooth Change-Id: Id41bac50dca628400568d191f1c3ccfbaac790a1 Reviewed-by: Alex <ablasche@gmail.com>
Diffstat (limited to 'examples/btchat')
-rw-r--r--examples/btchat/btchat.pro21
-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.h87
-rw-r--r--examples/btchat/remoteselector.ui38
12 files changed, 0 insertions, 1160 deletions
diff --git a/examples/btchat/btchat.pro b/examples/btchat/btchat.pro
deleted file mode 100644
index f215cb87..00000000
--- a/examples/btchat/btchat.pro
+++ /dev/null
@@ -1,21 +0,0 @@
-TEMPLATE = app
-TARGET = btchat
-
-QT += concurrent bluetooth widgets
-
-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
diff --git a/examples/btchat/chat.cpp b/examples/btchat/chat.cpp
deleted file mode 100644
index 7047cbdd..00000000
--- a/examples/btchat/chat.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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_WINCE) || 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
deleted file mode 100644
index 740999d0..00000000
--- a/examples/btchat/chat.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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
deleted file mode 100644
index acebc937..00000000
--- a/examples/btchat/chat.ui
+++ /dev/null
@@ -1,76 +0,0 @@
-<?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
deleted file mode 100644
index 8ea66e51..00000000
--- a/examples/btchat/chatclient.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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
deleted file mode 100644
index 710634e5..00000000
--- a/examples/btchat/chatclient.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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
deleted file mode 100644
index 545a0b03..00000000
--- a/examples/btchat/chatserver.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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
deleted file mode 100644
index ee4728a9..00000000
--- a/examples/btchat/chatserver.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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
deleted file mode 100644
index cb32f448..00000000
--- a/examples/btchat/main.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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)
- d.showFullScreen();
-#else
- d.show();
-#endif
-
- app.exec();
-
- return 0;
-}
-
diff --git a/examples/btchat/remoteselector.cpp b/examples/btchat/remoteselector.cpp
deleted file mode 100644
index a63c81c2..00000000
--- a/examples/btchat/remoteselector.cpp
+++ /dev/null
@@ -1,146 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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_WINCE) || 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
deleted file mode 100644
index eff94895..00000000
--- a/examples/btchat/remoteselector.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** 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 Digia Plc 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
-
-QT_BEGIN_NAMESPACE
-namespace Ui {
- class RemoteSelector;
-}
-QT_END_NAMESPACE
-
-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
deleted file mode 100644
index d415f416..00000000
--- a/examples/btchat/remoteselector.ui
+++ /dev/null
@@ -1,38 +0,0 @@
-<?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>