From 65d4db7193b198dfe4a4a81cdbe0052797d66505 Mon Sep 17 00:00:00 2001 From: Prajwal Mohan Date: Fri, 27 Apr 2012 15:41:57 -0700 Subject: [PATCH] Initial Import --- LICENSE | 202 +++++++++++++++++++++++ bluetooth-qt.pro | 3 + bluetooth-qt/adapter.xml | 66 ++++++++ bluetooth-qt/agentadaptor.cpp | 113 +++++++++++++ bluetooth-qt/agentadaptor.h | 44 +++++ bluetooth-qt/asyncagent.cpp | 109 +++++++++++++ bluetooth-qt/asyncagent.h | 46 ++++++ bluetooth-qt/audio.xml | 15 ++ bluetooth-qt/audiosink.xml | 23 +++ bluetooth-qt/audiosrc.xml | 16 ++ bluetooth-qt/bluetooth-qt.conf | 14 ++ bluetooth-qt/bluetooth-qt.pro | 74 +++++++++ bluetooth-qt/bluetoothbaseagent.cpp | 89 ++++++++++ bluetooth-qt/bluetoothbaseagent.h | 43 +++++ bluetooth-qt/bluetoothdevice.cpp | 295 ++++++++++++++++++++++++++++++++++ bluetooth-qt/bluetoothdevice.h | 77 +++++++++ bluetooth-qt/bluetoothdevicemodel.cpp | 292 +++++++++++++++++++++++++++++++++ bluetooth-qt/bluetoothdevicemodel.h | 70 ++++++++ bluetooth-qt/btprofiles.h | 34 ++++ bluetooth-qt/device.xml | 26 +++ bluetooth-qt/devicetypes.h | 24 +++ bluetooth-qt/headset.xml | 53 ++++++ bluetooth-qt/input.xml | 16 ++ bluetooth-qt/manager.xml | 34 ++++ bluetooth-qt/nearbydevicesmodel.cpp | 204 +++++++++++++++++++++++ bluetooth-qt/nearbydevicesmodel.h | 117 ++++++++++++++ bluetooth-qt/obex/agent.xml | 20 +++ bluetooth-qt/obex/client.xml | 34 ++++ bluetooth-qt/obex/obex.pri | 14 ++ bluetooth-qt/obex/obexagent.cpp | 59 +++++++ bluetooth-qt/obex/obexagent.h | 60 +++++++ bluetooth-qt/obex/obexclient.cpp | 26 +++ bluetooth-qt/obex/obexclient.h | 82 ++++++++++ bluetooth-qt/obex/obexftp.cpp | 131 +++++++++++++++ bluetooth-qt/obex/obexftp.h | 61 +++++++ bluetooth-qt/obex/obexsession.cpp | 39 +++++ bluetooth-qt/obex/obexsession.h | 149 +++++++++++++++++ bluetooth-qt/obex/obextransfer.cpp | 26 +++ bluetooth-qt/obex/obextransfer.h | 59 +++++++ bluetooth-qt/obex/session.xml | 49 ++++++ bluetooth-qt/obex/transfer.xml | 12 ++ bluetooth-qt/obex/types.h | 11 ++ declarative/components.cpp | 28 ++++ declarative/components.h | 24 +++ declarative/declarative.pro | 27 ++++ declarative/qmldir | 1 + makedist | 52 ++++++ packaging/bluetooth-qt.spec | 97 +++++++++++ patches/bmc20660.patch | 61 +++++++ 49 files changed, 3221 insertions(+) create mode 100644 LICENSE create mode 100644 bluetooth-qt.pro create mode 100644 bluetooth-qt/adapter.xml create mode 100644 bluetooth-qt/agentadaptor.cpp create mode 100644 bluetooth-qt/agentadaptor.h create mode 100644 bluetooth-qt/asyncagent.cpp create mode 100644 bluetooth-qt/asyncagent.h create mode 100644 bluetooth-qt/audio.xml create mode 100644 bluetooth-qt/audiosink.xml create mode 100644 bluetooth-qt/audiosrc.xml create mode 100644 bluetooth-qt/bluetooth-qt.conf create mode 100644 bluetooth-qt/bluetooth-qt.pro create mode 100644 bluetooth-qt/bluetoothbaseagent.cpp create mode 100644 bluetooth-qt/bluetoothbaseagent.h create mode 100644 bluetooth-qt/bluetoothdevice.cpp create mode 100644 bluetooth-qt/bluetoothdevice.h create mode 100644 bluetooth-qt/bluetoothdevicemodel.cpp create mode 100644 bluetooth-qt/bluetoothdevicemodel.h create mode 100644 bluetooth-qt/btprofiles.h create mode 100644 bluetooth-qt/device.xml create mode 100644 bluetooth-qt/devicetypes.h create mode 100644 bluetooth-qt/headset.xml create mode 100644 bluetooth-qt/input.xml create mode 100644 bluetooth-qt/manager.xml create mode 100644 bluetooth-qt/nearbydevicesmodel.cpp create mode 100644 bluetooth-qt/nearbydevicesmodel.h create mode 100644 bluetooth-qt/obex/agent.xml create mode 100644 bluetooth-qt/obex/client.xml create mode 100644 bluetooth-qt/obex/obex.pri create mode 100644 bluetooth-qt/obex/obexagent.cpp create mode 100644 bluetooth-qt/obex/obexagent.h create mode 100644 bluetooth-qt/obex/obexclient.cpp create mode 100644 bluetooth-qt/obex/obexclient.h create mode 100644 bluetooth-qt/obex/obexftp.cpp create mode 100644 bluetooth-qt/obex/obexftp.h create mode 100644 bluetooth-qt/obex/obexsession.cpp create mode 100644 bluetooth-qt/obex/obexsession.h create mode 100644 bluetooth-qt/obex/obextransfer.cpp create mode 100644 bluetooth-qt/obex/obextransfer.h create mode 100644 bluetooth-qt/obex/session.xml create mode 100644 bluetooth-qt/obex/transfer.xml create mode 100644 bluetooth-qt/obex/types.h create mode 100644 declarative/components.cpp create mode 100644 declarative/components.h create mode 100644 declarative/declarative.pro create mode 100644 declarative/qmldir create mode 100755 makedist create mode 100644 packaging/bluetooth-qt.spec create mode 100644 patches/bmc20660.patch diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d645695 --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/bluetooth-qt.pro b/bluetooth-qt.pro new file mode 100644 index 0000000..52e0afc --- /dev/null +++ b/bluetooth-qt.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs +SUBDIRS += bluetooth-qt declarative +CONFIG += ordered diff --git a/bluetooth-qt/adapter.xml b/bluetooth-qt/adapter.xml new file mode 100644 index 0000000..c02b83d --- /dev/null +++ b/bluetooth-qt/adapter.xml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/agentadaptor.cpp b/bluetooth-qt/agentadaptor.cpp new file mode 100644 index 0000000..96d1487 --- /dev/null +++ b/bluetooth-qt/agentadaptor.cpp @@ -0,0 +1,113 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + +#include "agentadaptor.h" + +AgentAdaptor::AgentAdaptor(BluetoothBaseAgent *parent) : + QDBusAbstractAdaptor(parent), agent(parent) +{ + +} + +AgentAdaptor::~AgentAdaptor() +{ + +} + +void AgentAdaptor::Authorize(const QDBusObjectPath &deviceObject, const QString &uuid) +{ + if (!agent) + { + return; + } + + OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus()); + + agent->authorize(device, uuid); +} + +void AgentAdaptor::Cancel() +{ + if(!agent) + { + return; + } + + agent->cancel(); +} + +void AgentAdaptor::ConfirmModeChange(const QString &mode) +{ + if(!agent) + { + return; + } + + agent->confirmModeChange(mode); +} + +void AgentAdaptor::DisplayPasskey(const QDBusObjectPath &deviceObject, uint passkey, uint entered) +{ + if(!agent) + { + return; + } + + OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus()); + + agent->displayPasskey(device, passkey, entered); +} + +void AgentAdaptor::Release() +{ + if(!agent) + { + return; + } + + agent->release(); +} + +void AgentAdaptor::RequestConfirmation(const QDBusObjectPath &deviceObject, uint passkey) +{ + if(!agent) + { + return; + } + + OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus()); + + agent->requestConfirmation(device, passkey); +} + +uint AgentAdaptor::RequestPasskey(const QDBusObjectPath &deviceObject) +{ + if(!agent) + { + return 0; + } + + OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus()); + + return agent->requestPasskey(device); +} + +QString AgentAdaptor::RequestPinCode(const QDBusObjectPath &deviceObject) +{ + if(!agent) + { + return QString(); + } + + OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus()); + + return agent->requestPidCode(device); +} diff --git a/bluetooth-qt/agentadaptor.h b/bluetooth-qt/agentadaptor.h new file mode 100644 index 0000000..bec276f --- /dev/null +++ b/bluetooth-qt/agentadaptor.h @@ -0,0 +1,44 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + + + +#ifndef AGENTADAPTOR_H +#define AGENTADAPTOR_H + +#include +#include "bluetoothbaseagent.h" + +class AgentAdaptor : public QDBusAbstractAdaptor +{ +Q_OBJECT +Q_CLASSINFO("D-Bus Interface", "org.bluez.Agent"); +public: + AgentAdaptor(BluetoothBaseAgent *parent = NULL); + virtual ~AgentAdaptor(); + +signals: + +public slots: + void Authorize(const QDBusObjectPath &device, const QString &uuid); + void Cancel(); + void ConfirmModeChange(const QString &mode); + void DisplayPasskey(const QDBusObjectPath &device, uint passkey, uint entered); + void Release(); + void RequestConfirmation(const QDBusObjectPath &device, uint passkey); + uint RequestPasskey(const QDBusObjectPath &device); + QString RequestPinCode(const QDBusObjectPath &device); + +private: + BluetoothBaseAgent *agent; +}; + +#endif // AGENTADAPTOR_H diff --git a/bluetooth-qt/asyncagent.cpp b/bluetooth-qt/asyncagent.cpp new file mode 100644 index 0000000..ef8ddbd --- /dev/null +++ b/bluetooth-qt/asyncagent.cpp @@ -0,0 +1,109 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + +#include "asyncagent.h" + +AsyncAgent::AsyncAgent(QString path, QObject *parent) : + BluetoothBaseAgent(path,parent), m_connection(QDBusConnection::systemBus()) +{ + +} + +void AsyncAgent::requestConfirmation(OrgBluezDeviceInterface &device, uint key) +{ + qDebug("requestConfirmation"); + setDelayedReply(true); + pendingMessage = message(); + m_connection = connection(); + + QVariantMap props = device.GetProperties(); + + QString alias = props["Alias"].toString(); + + deviceToPair = new BluetoothDevice(QDBusObjectPath(device.path()),this); + + QMetaObject::invokeMethod(parent(),"requestConfirmation", + Qt::QueuedConnection, Q_ARG(QString, alias), Q_ARG(uint,key)); + + return; +} + +uint AsyncAgent::requestPasskey(OrgBluezDeviceInterface &device) +{ + qDebug("requestKey"); + setDelayedReply(true); + pendingMessage = message(); + m_connection = connection(); + + QVariantMap props = device.GetProperties(); + + QString alias = props["Alias"].toString(); + + deviceToPair = new BluetoothDevice(QDBusObjectPath(device.path()),this); + + QMetaObject::invokeMethod(parent(), "requestPasskey", Qt::QueuedConnection, Q_ARG(QString, alias)); + + return 0; +} + +QString AsyncAgent::requestPidCode(OrgBluezDeviceInterface &device) +{ + qDebug("requestPidCode"); + setDelayedReply(true); + pendingMessage = message(); + m_connection = connection(); + + QVariantMap props = device.GetProperties(); + + QString alias = props["Alias"].toString(); + + deviceToPair = new BluetoothDevice(QDBusObjectPath(device.path()),this); + + QMetaObject::invokeMethod(parent(), "requestPidCode", Qt::QueuedConnection, Q_ARG(QString, alias)); + + return ""; +} + +void AsyncAgent::release() +{ + qDebug("releasing!"); + if (!QMetaObject::invokeMethod(parent(), "release", Qt::QueuedConnection)) + qDebug("sending relay signal failed!!!"); +} + + +void AsyncAgent::replyRequestConfirmation(bool confirmed) +{ + if(!confirmed) + { + qDebug("rejecting"); + QDBusMessage reply = pendingMessage.createErrorReply("org.bluez.Error.Rejected", "The request was rejected"); + m_connection.send(reply); + } + else + { + qDebug("accepting"); + QDBusMessage reply = pendingMessage.createReply(); + m_connection.send(reply); + } +} + +void AsyncAgent::replyPasskey(uint passkey) +{ + QDBusMessage reply = pendingMessage.createReply(passkey); + m_connection.send(reply); +} + +void AsyncAgent::replyRequestPidCode(QString pidCode) +{ + QDBusMessage reply = pendingMessage.createReply(pidCode); + m_connection.send(reply); +} diff --git a/bluetooth-qt/asyncagent.h b/bluetooth-qt/asyncagent.h new file mode 100644 index 0000000..568e2c9 --- /dev/null +++ b/bluetooth-qt/asyncagent.h @@ -0,0 +1,46 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + +#ifndef ASYNCAGENT_H +#define ASYNCAGENT_H + +#include "bluetoothbaseagent.h" +#include "bluetoothdevice.h" + +class AsyncAgent : public BluetoothBaseAgent +{ + Q_OBJECT +public: + explicit AsyncAgent(QString path, QObject *parent = 0); + + BluetoothDevice* device() { return deviceToPair; } + + void requestConfirmation(OrgBluezDeviceInterface &device, uint key); + uint requestPasskey(OrgBluezDeviceInterface &device); + QString requestPidCode(OrgBluezDeviceInterface &device); + void release(); + +signals: + +public slots: + void replyRequestConfirmation(bool confirmed); + void replyPasskey(uint passkey); + void replyRequestPidCode(QString pidCode); + +private: + QDBusMessage pendingMessage; + QDBusConnection m_connection; + + BluetoothDevice* deviceToPair; + +}; + +#endif // ASYNCAGENT_H diff --git a/bluetooth-qt/audio.xml b/bluetooth-qt/audio.xml new file mode 100644 index 0000000..cf98e8c --- /dev/null +++ b/bluetooth-qt/audio.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/audiosink.xml b/bluetooth-qt/audiosink.xml new file mode 100644 index 0000000..dc20f05 --- /dev/null +++ b/bluetooth-qt/audiosink.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/audiosrc.xml b/bluetooth-qt/audiosrc.xml new file mode 100644 index 0000000..c5273b6 --- /dev/null +++ b/bluetooth-qt/audiosrc.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/bluetooth-qt.conf b/bluetooth-qt/bluetooth-qt.conf new file mode 100644 index 0000000..24125b0 --- /dev/null +++ b/bluetooth-qt/bluetooth-qt.conf @@ -0,0 +1,14 @@ + + + + + + + + + + 512 + diff --git a/bluetooth-qt/bluetooth-qt.pro b/bluetooth-qt/bluetooth-qt.pro new file mode 100644 index 0000000..726994f --- /dev/null +++ b/bluetooth-qt/bluetooth-qt.pro @@ -0,0 +1,74 @@ +system(qdbusxml2cpp -p bluemanager.h:bluemanager.cpp manager.xml) +system(qdbusxml2cpp -p blueadapter.h:blueadapter.cpp adapter.xml) +system(qdbusxml2cpp -p bluedevice.h:bluedevice.cpp -i devicetypes.h device.xml) +system(qdbusxml2cpp -p audio.h:audio.cpp audio.xml) +system(qdbusxml2cpp -p audiosink.h:audiosink.cpp audiosink.xml) +system(qdbusxml2cpp -p audiosource.h:audiosource.cpp audiosrc.xml) +system(qdbusxml2cpp -p headset.h:headset.cpp headset.xml) +system(qdbusxml2cpp -p input.h:input.cpp input.xml) +include(obex/obex.pri) + +VERSION+= 0.0.9 + +TEMPLATE = lib +TARGET = bluetooth-qt +QT += dbus +CONFIG += link_pkgconfig \ + debug +OTHER_FILES += bluetooth-qt.conf \ + manager.xml \ + device.xml \ + audiosrc.xml \ + audiosink.xml \ + adapter.xml \ + headset.xml \ + input.xml +HEADERS += agentadaptor.h \ + bluemanager.h \ + bluedevice.h \ + blueadapter.h \ + audiosource.h \ + audiosink.h \ + headset.h \ + btprofiles.h \ + nearbydevicesmodel.h \ + bluetoothbaseagent.h \ + asyncagent.h \ + devicetypes.h \ + bluetoothdevice.h \ + bluetoothdevicemodel.h \ + audio.h \ + input.h +SOURCES += agentadaptor.cpp \ + bluemanager.cpp \ + bluedevice.cpp \ + blueadapter.cpp \ + audiosource.cpp \ + audiosink.cpp \ + headset.cpp \ + nearbydevicesmodel.cpp \ + bluetoothbaseagent.cpp \ + asyncagent.cpp \ + bluetoothdevice.cpp \ + bluetoothdevicemodel.cpp \ + audio.cpp \ + input.cpp + +target.path = $$INSTALL_ROOT/usr/lib +headers.path = $$INSTALL_ROOT/usr/include/bluetooth-qt/ +headers.files = $$HEADERS +INSTALLS += target \ + headers + +CONFIG += create_pc create_prl +QMAKE_PKGCONFIG_DESCRIPTION = Qt Bluetooth Library +QMAKE_PKGCONFIG_INCDIR = $$headers.path +pkgconfig.path = $$INSTALL_ROOT/usr/lib/pkgconfig +pkgconfig.files = bluetooth-qt.pc + +INSTALLS += pkgconfig + +dbusfiles.path = $$INSTALL_ROOT/etc/dbus-1/system.d +dbusfiles.files = bluetooth-qt.conf + +INSTALLS += dbusfiles diff --git a/bluetooth-qt/bluetoothbaseagent.cpp b/bluetooth-qt/bluetoothbaseagent.cpp new file mode 100644 index 0000000..8677b26 --- /dev/null +++ b/bluetooth-qt/bluetoothbaseagent.cpp @@ -0,0 +1,89 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + +#include "bluetoothbaseagent.h" + +#include "agentadaptor.h" +#include "bluemanager.h" +#include "blueadapter.h" +#include + +BluetoothBaseAgent::BluetoothBaseAgent(QString path, QObject *parent):QObject(parent),requestAccepted(false),m_path(path) +{ + new AgentAdaptor(this); + QDBusConnection::systemBus().registerObject(path,this); +} + +void BluetoothBaseAgent::registerAgent() +{ + OrgBluezManagerInterface manager( + "org.bluez", + "/", QDBusConnection::systemBus()); + + QDBusObjectPath adapterpath = manager.DefaultAdapter(); + + OrgBluezAdapterInterface adapter( + "org.bluez", + adapterpath.path(), + QDBusConnection::systemBus()); + + adapter.RegisterAgent(QDBusObjectPath(m_path),""); + qDebug()<<"last error: "< +#include +#include "bluedevice.h" + +class BluetoothBaseAgent: public QObject, public QDBusContext +{ + Q_OBJECT +public: + BluetoothBaseAgent(QString path="", QObject *parent=0); +public slots: + virtual void authorize(OrgBluezDeviceInterface &device, QString); + virtual void registerAgent(); + virtual void cancel() + { + sendErrorReply("org.bluez.Error.Canceled","The request was canceled"); + } + virtual void confirmModeChange(QString); + virtual void displayPasskey(OrgBluezDeviceInterface &device, uint key, uint entered); + virtual void release(); + virtual void requestConfirmation(OrgBluezDeviceInterface &device, uint key); + virtual uint requestPasskey(OrgBluezDeviceInterface &device); + virtual QString requestPidCode(OrgBluezDeviceInterface &device); + +private: + bool requestAccepted; + QString m_path; +}; + +#endif // BLUETOOTHBASEAGENT_H diff --git a/bluetooth-qt/bluetoothdevice.cpp b/bluetooth-qt/bluetoothdevice.cpp new file mode 100644 index 0000000..4f2268e --- /dev/null +++ b/bluetooth-qt/bluetoothdevice.cpp @@ -0,0 +1,295 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + +#include "bluetoothdevice.h" +#include "blueadapter.h" +#include "bluemanager.h" +#include "btprofiles.h" +#include "audiosink.h" +#include "audiosource.h" +#include "headset.h" +#include "audio.h" +#include "input.h" + +BluetoothDevice::BluetoothDevice(QDBusObjectPath path, QObject *parent) : + QObject(parent),m_device(new OrgBluezDeviceInterface("org.bluez",path.path(),QDBusConnection::systemBus(),this)),audio(NULL),input(NULL) +{ + if(!m_device->isValid()) + return; + QObject::connect(m_device,SIGNAL(PropertyChanged(QString,QDBusVariant)), + this,SLOT(propertyChanged(QString,QDBusVariant))); + + setupProfiles(); +} + +bool BluetoothDevice::paired() +{ + QVariantMap props = m_device->GetProperties(); + return props["Paired"].toBool(); +} + +void BluetoothDevice::setupProfiles() +{ + if(isProfileSupported(BluetoothProfiles::hid)) + { + if(!input) + { + input = new OrgBluezInputInterface("org.bluez", m_device->path(), + QDBusConnection::systemBus(), this); + connect(input,SIGNAL(PropertyChanged(QString,QDBusVariant)),this, + SLOT(inputPropertiesChanged(QString,QDBusVariant))); + } + } + else + { + if(input) + { + input->deleteLater(); + input = NULL; + } + } + + if(isProfileSupported(BluetoothProfiles::a2sink) || isProfileSupported(BluetoothProfiles::hs)) + { + if(!audio) audio = new OrgBluezAudioInterface("org.bluez", m_device->path(), QDBusConnection::systemBus(), this); + + connect(audio,SIGNAL(PropertyChanged(QString,QDBusVariant)),this,SLOT(audioPropertiesChanged(QString,QDBusVariant))); + } + else + { + if(audio) + { + audio->deleteLater(); + audio = NULL; + } + } +} + +void BluetoothDevice::cancelPairing() +{ + OrgBluezManagerInterface manager( + "org.bluez", + "/", QDBusConnection::systemBus()); + + QDBusObjectPath adapterpath = manager.DefaultAdapter(); + + if(adapterpath.path().isEmpty()) return; + + OrgBluezAdapterInterface adapter( + "org.bluez", + adapterpath.path(), + QDBusConnection::systemBus()); + + adapter.CancelDeviceCreation(address()); +} + + +void BluetoothDevice::unpair() +{ + OrgBluezManagerInterface manager( + "org.bluez", + "/", QDBusConnection::systemBus()); + + QDBusObjectPath adapterpath = manager.DefaultAdapter(); + + if(adapterpath.path().isEmpty()) return; + + OrgBluezAdapterInterface adapter( + "org.bluez", + adapterpath.path(), + QDBusConnection::systemBus()); + + adapter.RemoveDevice(QDBusObjectPath(m_device->path())); +} + +void BluetoothDevice::connectAudio() +{ + audio->Connect(); +} +void BluetoothDevice::connectAudioSrc() +{ + + if(isProfileSupported(BluetoothProfiles::a2src)) + { + OrgBluezAudioSourceInterface source("org.bluez",m_device->path(), + QDBusConnection::systemBus()); + source.Connect(); + } +} + +QString BluetoothDevice::connectSerial() +{ + if(isProfileSupported(BluetoothProfiles::spp)) + { + QDBusInterface interface("org.bluez",m_device->path(),"org.bluez.Serial",QDBusConnection::systemBus()); + QDBusReply reply = interface.call(QDBus::AutoDetect, "Connect","spp"); + + if(reply.isValid()) return reply; + else qDebug()<<"Error connecting spp profile: "<Connect(); +} + +void BluetoothDevice::disconnect() +{ + m_device->Disconnect(); +} + +void BluetoothDevice::disconnectAudio() +{ + if(!audio) audio = new OrgBluezAudioInterface("org.bluez", m_device->path(), QDBusConnection::systemBus(), this); + + audio->Disconnect(); +} + +QStringList BluetoothDevice::profiles() +{ + QVariantMap props = m_device->GetProperties(); + + QStringList uuidlist = props["UUIDs"].toStringList(); + + return uuidlist; +} + +bool BluetoothDevice::isProfileSupported(QString profile) +{ + QVariantMap props = m_device->GetProperties(); + + QStringList uuidlist = props["UUIDs"].toStringList(); + + return uuidlist.contains(profile.toLower()); +} + +bool BluetoothDevice::connected() +{ + QVariantMap props = m_device->GetProperties(); + return props["Connected"].toBool(); +} + +bool BluetoothDevice::audioConnected() +{ + if(!audio) + { + audio = new OrgBluezAudioInterface("org.bluez",m_device->path(), QDBusConnection::systemBus(),this); + connect(audio,SIGNAL(PropertyChanged(QString,QDBusVariant)),this,SLOT(audioPropertiesChanged(QString,QDBusVariant))); + } + + QVariantMap props = audio->GetProperties(); + return props["State"].toString() == "connected"; +} + +bool BluetoothDevice::inputConnected() +{ + if(!input) + { + input = new OrgBluezInputInterface("org.bluez",m_device->path(), QDBusConnection::systemBus(),this); + connect(input,SIGNAL(PropertyChanged(QString,QDBusVariant)),this, SLOT(inputPropertiesChanged(QString,QDBusVariant))); + } + + QVariantMap props = input->GetProperties(); + return props["Connected"].toBool(); +} + +QString BluetoothDevice::alias() +{ + QVariantMap props = m_device->GetProperties(); + return props["Alias"].toString(); +} + +QString BluetoothDevice::name() +{ + QVariantMap props = m_device->GetProperties(); + return props["Name"].toString(); +} + +QString BluetoothDevice::address() +{ + QVariantMap props = m_device->GetProperties(); + return props["Address"].toString(); +} + +QString BluetoothDevice::icon() +{ + QVariantMap props = m_device->GetProperties(); + return props["Icon"].toString(); +} + +QString BluetoothDevice::path() +{ + return m_device->path(); +} + +bool BluetoothDevice::trusted() +{ + QVariantMap props = m_device->GetProperties(); + return props["Trusted"].toBool(); +} + +void BluetoothDevice::setTrusted(bool trust) +{ + m_device->SetProperty("Trusted",QDBusVariant(trust)); +} + +void BluetoothDevice::propertyChanged(QString name,QDBusVariant value) +{ + qDebug()<<"BluetoothDevice::propertyChanged()"; + + if(name == "Connected") + { + emit connectedChanged(value.variant().toBool()); + } + + if(name == "UUIDs") + { + emit profilesChanged(value.variant().toStringList()); + setupProfiles(); + } + + if(name == "Trusted") + { + emit trustedChanged(value.variant().toBool()); + } + + if(name == "Paired") + { + emit pairedChanged(); + } + + emit propertyChanged(name,value.variant()); + + ///TODO: create individual signals for each property... maybe +} + +void BluetoothDevice::audioPropertiesChanged(QString name,QDBusVariant value) +{ + ///don't think i need to be doing this: + //emit propertyChanged(name, value.variant()); + + if(name == "State") + { + emit audioConnectedChanged(value.variant().toString() == "connected"); + } +} + +void BluetoothDevice::inputPropertiesChanged(QString name, QDBusVariant value) +{ + qDebug()<<"Input properties changed: "< +#include +#include + +class OrgBluezAudioInterface; +class OrgBluezInputInterface; + +class BluetoothDevice : public QObject +{ + Q_OBJECT + Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged); + Q_PROPERTY(bool audioConnected READ audioConnected NOTIFY audioConnectedChanged) + Q_PROPERTY(bool inputConnected READ inputConnected NOTIFY inputConnectedChanged) + Q_PROPERTY(bool trusted READ trusted WRITE setTrusted NOTIFY trustedChanged) + Q_PROPERTY(bool paired READ paired NOTIFY pairedChanged) + Q_PROPERTY(QStringList profiles READ profiles NOTIFY profilesChanged) + Q_PROPERTY(QString alias READ alias) + Q_PROPERTY(QString name READ name) + Q_PROPERTY(QString address READ address) + Q_PROPERTY(QString icon READ icon) + Q_PROPERTY(QString path READ path) + +public: + explicit BluetoothDevice(QDBusObjectPath path = QDBusObjectPath(), QObject *parent = 0); + bool paired(); + +signals: + void connectedChanged(bool isConnected); + void audioConnectedChanged(bool isConnected); + void inputConnectedChanged(bool isConnected); + void propertyChanged(QString name, QVariant value); + void profilesChanged(QStringList uuids); + void trustedChanged(bool trust); + void pairedChanged(); + +public slots: + void cancelPairing(); + void unpair(); + void connectAudio(); + void connectAudioSrc(); + QString connectSerial(); + void connectInput(); + void disconnect(); + void disconnectAudio(); + bool trusted(); + void setTrusted(bool trust); + + QStringList profiles(); + bool isProfileSupported(QString profile); + + ///properties: + bool connected(); + bool audioConnected(); + bool inputConnected(); + QString alias(); + QString name(); + QString address(); + QString icon(); + QString path(); + +private slots: + void propertyChanged(QString name,QDBusVariant value); + void audioPropertiesChanged(QString name, QDBusVariant value); + void inputPropertiesChanged(QString name, QDBusVariant value); + +private: + void setupProfiles(); + + OrgBluezDeviceInterface *m_device; + OrgBluezAudioInterface *audio; + OrgBluezInputInterface *input; +}; + +#endif // BLUETOOTHDEVICE_H diff --git a/bluetooth-qt/bluetoothdevicemodel.cpp b/bluetooth-qt/bluetoothdevicemodel.cpp new file mode 100644 index 0000000..24015a5 --- /dev/null +++ b/bluetooth-qt/bluetoothdevicemodel.cpp @@ -0,0 +1,292 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + +#include "bluetoothdevicemodel.h" + +BluetoothDevicesModel::BluetoothDevicesModel(QObject *parent) : + QAbstractListModel(parent), m_connected(false), adapter(NULL) +{ + manager = new OrgBluezManagerInterface( + "org.bluez", + "/", QDBusConnection::systemBus(), this); + + connect(manager,SIGNAL(AdapterAdded(QDBusObjectPath)),this,SLOT(adapterAdded(QDBusObjectPath))); + connect(manager,SIGNAL(AdapterRemoved(QDBusObjectPath)),this,SLOT(adapterRemoved(QDBusObjectPath))); + adapterAdded(QDBusObjectPath()); + + QHash roles; + + QMetaObject properties = BluetoothDevice::staticMetaObject; + + for(int i=0; iname() == devicename) + return device->path(); + } + return ""; +} + +BluetoothDevice* BluetoothDevicesModel::device(QString path) +{ + foreach(BluetoothDevice* device, m_devices) + { + if(device->path() == path) + return device; + } + qDebug()<<"Device not found for path: "<SetProperty("Powered", QDBusVariant(poweredValue)); +} + +bool BluetoothDevicesModel::powered() +{ + if(adapter) + { + QVariantMap props = adapter->GetProperties(); + return props["Powered"].toBool(); + } + + return false; +} + +void BluetoothDevicesModel::makeDiscoverable(bool discoverableValue) +{ + if(adapter) adapter->SetProperty("Discoverable", QDBusVariant(discoverableValue)); +} + +bool BluetoothDevicesModel::discoverable() +{ + if(adapter) + { + QVariantMap props = adapter->GetProperties(); + return props["Discoverable"].toBool(); + } + + return false; +} + +int BluetoothDevicesModel::discoverableTimeout() +{ + if(adapter) + { + QVariantMap props = adapter->GetProperties(); + return props["DiscoverableTimeout"].toInt(); + } + + return -1; +} + +void BluetoothDevicesModel::setDiscoverableTimeout(int timeout) +{ + if(adapter) + { + bool success = adapter->setProperty("DiscoverableTimeout", timeout); + qDebug()<<"Setting discoverable timeout to "<path() == path.path()) return; + + QDBusObjectPath adapterpath = manager->DefaultAdapter(); + + if(adapterpath.path() == "") + { + ///we actually shouldn't ever get here. + return; + } + + adapter = new OrgBluezAdapterInterface( + "org.bluez", + adapterpath.path(), + QDBusConnection::systemBus(), this); + + connect(adapter, + SIGNAL(PropertyChanged(QString,QDBusVariant)), + this, + SLOT(adapterPropertyChanged(QString,QDBusVariant))); + + connect(adapter, + SIGNAL(DeviceRemoved(QDBusObjectPath)), + this, + SLOT(deviceRemoved(QDBusObjectPath))); + + connect(adapter, + SIGNAL(DeviceCreated(QDBusObjectPath)), + this, + SLOT(deviceCreated(QDBusObjectPath))); + + adapterChanged(true); + + QList list = adapter->ListDevices(); + foreach(QDBusObjectPath item, list) + { + deviceCreated(item); + } +} + +void BluetoothDevicesModel::adapterRemoved(QDBusObjectPath) +{ + QDBusObjectPath adapterpath = manager->DefaultAdapter(); + + if(adapterpath.path() == "") + { + beginRemoveRows(QModelIndex(), 0, m_devices.size()-1); + foreach(BluetoothDevice* device, m_devices) + { + updateConnected(device->connected()); + device->deleteLater(); + } + m_devices.clear(); + endRemoveRows(); + + if(adapter) delete adapter; + adapter = NULL; + adapterChanged(false); + return; + } +} + +void BluetoothDevicesModel::deviceCreated(QDBusObjectPath devicepath) +{ + BluetoothDevice* device = new BluetoothDevice(devicepath,this); + + updateConnected(device->connected()); + connect(device,SIGNAL(propertyChanged(QString,QVariant)),this,SLOT(devicePropertyChanged(QString,QVariant))); + + beginInsertRows(QModelIndex(),m_devices.size(),m_devices.size()); + m_devices.append(device); + endInsertRows(); +} + +void BluetoothDevicesModel::deviceRemoved(QDBusObjectPath devicepath) +{ + for(int i=0; ipath() == devicepath.path()) + { + beginRemoveRows(QModelIndex(), i, i); + m_devices[i]->deleteLater(); + m_devices.removeAt(i); + endRemoveRows(); + } + } +} + +void BluetoothDevicesModel::devicePropertyChanged(QString name, QVariant value) +{ + BluetoothDevice* device = qobject_cast(sender()); + + qDebug()<<"device property changed for "<address()<<": "<connected(); + } + + if(temp != m_connected) + { + m_connected = temp; + connectedChanged(m_connected); + } + } +} diff --git a/bluetooth-qt/bluetoothdevicemodel.h b/bluetooth-qt/bluetoothdevicemodel.h new file mode 100644 index 0000000..1a8fbb2 --- /dev/null +++ b/bluetooth-qt/bluetoothdevicemodel.h @@ -0,0 +1,70 @@ +#ifndef BLUETOOTHDEVICEMODEL_H +#define BLUETOOTHDEVICEMODEL_H + +#include +#include "bluemanager.h" +#include "blueadapter.h" +#include "bluetoothdevice.h" + +class BluetoothDevicesModel : public QAbstractListModel +{ + Q_OBJECT; + + Q_PROPERTY(bool powered READ powered WRITE makePowered NOTIFY poweredChanged); + Q_PROPERTY(bool discoverable READ discoverable WRITE makeDiscoverable NOTIFY discoverableChanged); + Q_PROPERTY(int discoverableTimeout READ discoverableTimeout WRITE setDiscoverableTimeout NOTIFY discoverableTimeoutChanged); + Q_PROPERTY(bool adapterPresent READ adapterPresent NOTIFY adapterChanged); + Q_PROPERTY(bool connected READ connected NOTIFY connectedChanged); + +public: + explicit BluetoothDevicesModel(QObject *parent = 0); + + bool adapterPresent() { return adapter != NULL; } + +public slots: + + int columnCount(const QModelIndex &) const { return 1; } + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + + QString devicePath(QString name); + + QList devices(){ return m_devices; } + + bool connected() { return m_connected; } + + BluetoothDevice* device(QString path); + void makePowered(bool poweredValue); + bool powered(); + void makeDiscoverable(bool discoverableValue); + bool discoverable(); + int discoverableTimeout(); + void setDiscoverableTimeout(int timeout); + void deviceRemoved(QDBusObjectPath); + +private slots: + void adapterAdded(QDBusObjectPath); + void adapterRemoved(QDBusObjectPath); + void deviceCreated(QDBusObjectPath); + + void devicePropertyChanged(QString name, QVariant value); + void adapterPropertyChanged(QString name, QDBusVariant value); + +signals: + void poweredChanged(bool powered); + void discoverableTimeoutChanged(int timeout); + void devicePaired(BluetoothDevice* device); + void discoverableChanged(bool discoverable); + void adapterChanged(bool adapterPresent); + void connectedChanged(bool isConnected); + +private: + void updateConnected(bool deviceconnectedStatus); + + bool m_connected; + OrgBluezManagerInterface *manager; + OrgBluezAdapterInterface *adapter; + QList m_devices; +}; + +#endif // BLUETOOTHDEVICEMODEL_H diff --git a/bluetooth-qt/btprofiles.h b/bluetooth-qt/btprofiles.h new file mode 100644 index 0000000..e6afd01 --- /dev/null +++ b/bluetooth-qt/btprofiles.h @@ -0,0 +1,34 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + +#ifndef BTPROFILES_H +#define BTPROFILES_H + +#include + +namespace BluetoothProfiles +{ + + const char a2sink[] = "0000110b-0000-1000-8000-00805f9b34fb"; + const char a2src[] = "0000110a-0000-1000-8000-00805f9b34fb"; + const char syncml[] = "00005601-0000-1000-8000-0002ee000001"; + const char hf[] = "0000111e-0000-1000-8000-00805f9b34fb"; + const char hfag[] = "0000111f-0000-1000-8000-00805f9b34fb"; + const char hs[] = "00001108-0000-1000-8000-00805f9b34fb"; + const char hsag[] = "00001112-0000-1000-8000-00805f9b34fb"; + const char opush[] = "00001105-0000-1000-8000-00805f9b34fb"; + const char ftp[] = "00001106-0000-1000-8000-00805f9b34fb"; + const char panu[] = "00001115-0000-1000-8000-00805f9b34fb"; + const char nap[] = "00001116-0000-1000-8000-00805f9b34fb"; + const char spp[] = "00001101-0000-1000-8000-00805f9b34fb"; + const char hid[] = "00001124-0000-1000-8000-00805f9b34fb"; +} +#endif // BTPROFILES_H diff --git a/bluetooth-qt/device.xml b/bluetooth-qt/device.xml new file mode 100644 index 0000000..60658d0 --- /dev/null +++ b/bluetooth-qt/device.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/devicetypes.h b/bluetooth-qt/devicetypes.h new file mode 100644 index 0000000..aa0267b --- /dev/null +++ b/bluetooth-qt/devicetypes.h @@ -0,0 +1,24 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + + + +#ifndef _DEVICETYPES_H_ +#define _DEVICETYPES_H_ + +#include + +typedef QMap UIntStringMap; +Q_DECLARE_METATYPE(UIntStringMap) + + + +#endif diff --git a/bluetooth-qt/headset.xml b/bluetooth-qt/headset.xml new file mode 100644 index 0000000..c12573a --- /dev/null +++ b/bluetooth-qt/headset.xml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/input.xml b/bluetooth-qt/input.xml new file mode 100644 index 0000000..d49aac9 --- /dev/null +++ b/bluetooth-qt/input.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/manager.xml b/bluetooth-qt/manager.xml new file mode 100644 index 0000000..b9bb111 --- /dev/null +++ b/bluetooth-qt/manager.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/nearbydevicesmodel.cpp b/bluetooth-qt/nearbydevicesmodel.cpp new file mode 100644 index 0000000..455c78c --- /dev/null +++ b/bluetooth-qt/nearbydevicesmodel.cpp @@ -0,0 +1,204 @@ +/* -*- Mode: C++ -*- + * + * meego handset bluetooth + * Copyright © 2010, Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + * + */ + +#include "nearbydevicesmodel.h" +#include "bluetoothbaseagent.h" + +NearbyDevicesModel::NearbyDevicesModel(QObject *parent) : + QAbstractListModel(parent), adapter(NULL), agent(NULL) +{ + manager = new OrgBluezManagerInterface( + "org.bluez", + "/", QDBusConnection::systemBus(), this); + + connect(manager,SIGNAL(AdapterAdded(QDBusObjectPath)),this,SLOT(adapterAdded(QDBusObjectPath))); + connect(manager,SIGNAL(AdapterRemoved(QDBusObjectPath)),this,SLOT(adapterRemoved(QDBusObjectPath))); + adapterAdded(QDBusObjectPath()); + + QHash roles; + QMetaObject properties = NearbyItem::staticMetaObject; + for(int i=0; iCreatePairedDevice(hwaddy, + QDBusObjectPath("/temp/agent"),""); + + //qDebug()<<"new object created: "<StartDiscovery(); + else adapter->StopDiscovery(); +} + +void NearbyDevicesModel::removeAll(bool) +{ + for(int i=0;ireplyRequestConfirmation(confirmed); +} + +void NearbyDevicesModel::replyPasskey(uint passkey) +{ + if(agent) agent->replyPasskey(passkey); +} + +void NearbyDevicesModel::replyRequestPidCode(QString pidCode) +{ + if(agent) agent->replyRequestPidCode(pidCode); +} + +void NearbyDevicesModel::setAdapterProperty(QString name, QVariant value) +{ + if(adapter) adapter->setProperty(name.toAscii().data(),value); +} + +void NearbyDevicesModel::deviceCreated(QString hwaddy, QVariantMap properties) +{ + bool found = false; + foreach(NearbyItem* path, devices) + { + if(path->address() == hwaddy) + { + path->setName(properties["Name"].toString()); + path->setAlias(properties["Alias"].toString()); + path->setIcon(properties["Icon"].toString()); + return; + } + } + + beginInsertRows(QModelIndex(), devices.size(), devices.size()); + + NearbyItem* item = new NearbyItem(properties["Name"].toString(), + hwaddy,properties["Icon"].toString(), + properties["LegacyPairing"].toBool(),this); + + item->setAlias(properties["Alias"].toString()); + + devices.append(item); + emit nearbyDeviceFound(devices.indexOf(item)); + endInsertRows(); + +} + +void NearbyDevicesModel::deviceRemoved(QString hwaddy) +{ + foreach(NearbyItem* device, devices) + { + if(device->address() == hwaddy) + { + qDebug()<<"device "<name()<<" has disappeared"; + int i=devices.indexOf(device); + beginRemoveRows(QModelIndex(),i,i); + devices.removeAt(i); + emit nearbyDeviceRemoved(i); + endRemoveRows(); + } + } +} + +void NearbyDevicesModel::adapterAdded(QDBusObjectPath path) +{ + if(adapter && adapter->path() == path.path()) return; + + QDBusObjectPath adapterpath = manager->DefaultAdapter(); + + if(adapterpath.path() == "") + return; + + adapter = new OrgBluezAdapterInterface( + "org.bluez", + adapterpath.path(), + QDBusConnection::systemBus(), this); + + connect(adapter, + SIGNAL(DeviceFound(QString, QVariantMap)), + this, + SLOT(deviceCreated(QString, QVariantMap))); + connect(adapter, + SIGNAL(DeviceDisappeared(QString)), + this, + SLOT(deviceRemoved(QString))); + connect(adapter, + SIGNAL(PropertyChanged(QString,QDBusVariant)), + this, + SLOT(adapterPropertiesChangedSlot(QString,QDBusVariant))); +} + +void NearbyDevicesModel::adapterRemoved(QDBusObjectPath) +{ + QDBusObjectPath adapterpath = manager->DefaultAdapter(); + + if(adapterpath.path() == "") + { + removeAll(true); + if(adapter){ delete adapter; adapter = NULL; } + return; + } +} + +void NearbyDevicesModel::adapterPropertiesChangedSlot(QString n,QDBusVariant v) +{ + adapterPropertiesChanged(n,v.variant()); +} diff --git a/bluetooth-qt/nearbydevicesmodel.h b/bluetooth-qt/nearbydevicesmodel.h new file mode 100644 index 0000000..7de241b --- /dev/null +++ b/bluetooth-qt/nearbydevicesmodel.h @@ -0,0 +1,117 @@ +#ifndef NEARBYDEVICESMODEL_H +#define NEARBYDEVICESMODEL_H + +#include +#include +#include + +#include "bluemanager.h" +#include "blueadapter.h" +#include "asyncagent.h" +#include "bluetoothdevice.h" + +namespace NearbyDevicesModelRoles +{ + enum + { + name = Qt::UserRole + 1, + address, + icon + }; +} + +class NearbyItem: public QObject +{ + Q_OBJECT + Q_PROPERTY(QString name READ name NOTIFY nameChanged) + Q_PROPERTY(QString alias READ alias NOTIFY aliasChanged) + Q_PROPERTY(QString address READ address) + Q_PROPERTY(QString icon READ icon NOTIFY iconChanged) + Q_PROPERTY(bool legacyPairing READ legacyPairing) +public: + NearbyItem(QString name="", QString address="", QString icon="", bool legacy=false, QObject* parent = 0) + :QObject(parent) + { + m_name=name; + m_addy=address; + m_icon=icon; + m_legacy = legacy; + } + + QString name() { return m_name; } + QString alias() { return m_alias; } + QString address() { return m_addy; } + QString icon() { return m_icon; } + bool legacyPairing() { return m_legacy; } + + void setName(QString n) { m_name = n; nameChanged(); } + void setIcon(QString i) { m_icon = i; iconChanged(); } + void setAlias(QString a) { m_alias = a; aliasChanged(); } + +signals: + void nameChanged(); + void aliasChanged(); + void iconChanged(); + +private: + QString m_name; + QString m_alias; + QString m_addy; + QString m_icon; + bool m_legacy; +}; + +class NearbyDevicesModel : public QAbstractListModel +{ + Q_OBJECT + Q_PROPERTY(BluetoothDevice* pairingDevice READ pairingDevice) +public: + NearbyDevicesModel(QObject *parent = 0); + + BluetoothDevice* pairingDevice() { if(agent) return agent->device(); else return NULL; } + +public slots: + + int columnCount(const QModelIndex &) const { return 1;} + int rowCount(const QModelIndex &parent = QModelIndex()) const; + QVariant data(const QModelIndex &index, int role) const; + + QString hwAddress(int index) { return devices[index]->address(); } + QString alias(int index){ return devices[index]->name(); } + void pair(QString hwaddy); + void discover(bool start); + void removeAll(bool); + + void replyRequestConfirmation(bool confirmed); + void replyPasskey(uint passkey); + void replyRequestPidCode(QString pidCode); + + void setAdapterProperty(QString name, QVariant value); + +private slots: + void adapterAdded(QDBusObjectPath); + void adapterRemoved(QDBusObjectPath); + void deviceCreated(QString hwaddy, QVariantMap properties); + void deviceRemoved(QString hwaddy); + + void adapterPropertiesChangedSlot(QString n,QDBusVariant v); + +signals: + void requestConfirmation(QString device, uint code); + void requestPasskey(QString device); + void requestPidCode(QString device); + void release(); + + void nearbyDeviceFound(int index); + void nearbyDeviceRemoved(int index); + + void adapterPropertiesChanged(QString name, QVariant value); + +private: + QList devices; + OrgBluezManagerInterface *manager; + OrgBluezAdapterInterface *adapter; + AsyncAgent* agent; +}; + +#endif // NEARBYDEVICESMODEL_H diff --git a/bluetooth-qt/obex/agent.xml b/bluetooth-qt/obex/agent.xml new file mode 100644 index 0000000..be0606b --- /dev/null +++ b/bluetooth-qt/obex/agent.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/obex/client.xml b/bluetooth-qt/obex/client.xml new file mode 100644 index 0000000..0520bbf --- /dev/null +++ b/bluetooth-qt/obex/client.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/obex/obex.pri b/bluetooth-qt/obex/obex.pri new file mode 100644 index 0000000..b5bb507 --- /dev/null +++ b/bluetooth-qt/obex/obex.pri @@ -0,0 +1,14 @@ +!exists(obexagent.h):system(qdbusxml2cpp -c ObexAgentAdaptor -a obexagent.h:obexagent.cpp agent.xml) +!exists(obexclient.h):system(qdbusxml2cpp -p obexclient.h:obexclient.cpp client.xml) +!exists(obexsession.h):system(qdbusxml2cpp -p obexsession.h:obexsession.cpp -i types.h session.xml) +!exists(obextransfer.h):system(qdbusxml2cpp -p obextransfer.h:obextransfer.cpp transfer.xml) +SOURCES += obex/obexagent.cpp \ + obex/obexclient.cpp \ + obex/obexsession.cpp \ + obex/obextransfer.cpp \ + obex/obexftp.cpp +HEADERS += obex/obexagent.h \ + obex/obexclient.h \ + obex/obexsession.h \ + obex/obextransfer.h \ + obex/obexftp.h diff --git a/bluetooth-qt/obex/obexagent.cpp b/bluetooth-qt/obex/obexagent.cpp new file mode 100644 index 0000000..71323bc --- /dev/null +++ b/bluetooth-qt/obex/obexagent.cpp @@ -0,0 +1,59 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -c ObexAgentAdaptor -a obexagent.h:obexagent.cpp agent.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#include "obexagent.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class ObexAgentAdaptor + */ + +ObexAgentAdaptor::ObexAgentAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +ObexAgentAdaptor::~ObexAgentAdaptor() +{ + // destructor +} + +void ObexAgentAdaptor::Complete(const QDBusObjectPath &path) +{ + // handle method call org.openobex.Agent.Complete + QMetaObject::invokeMethod(parent(), "Complete", Q_ARG(QDBusObjectPath, path)); +} + +void ObexAgentAdaptor::Error(const QDBusObjectPath &path, const QString &error) +{ + // handle method call org.openobex.Agent.Error + QMetaObject::invokeMethod(parent(), "Error", Q_ARG(QDBusObjectPath, path), Q_ARG(QString, error)); +} + +void ObexAgentAdaptor::Progress(const QDBusObjectPath &path, qulonglong transferred) +{ + // handle method call org.openobex.Agent.Progress + QMetaObject::invokeMethod(parent(), "Progress", Q_ARG(QDBusObjectPath, path), Q_ARG(qulonglong, transferred)); +} + +void ObexAgentAdaptor::Release() +{ + // handle method call org.openobex.Agent.Release + QMetaObject::invokeMethod(parent(), "Release"); +} + diff --git a/bluetooth-qt/obex/obexagent.h b/bluetooth-qt/obex/obexagent.h new file mode 100644 index 0000000..07dbbff --- /dev/null +++ b/bluetooth-qt/obex/obexagent.h @@ -0,0 +1,60 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -c ObexAgentAdaptor -a obexagent.h:obexagent.cpp agent.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#ifndef OBEXAGENT_H_1306341758 +#define OBEXAGENT_H_1306341758 + +#include +#include +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; + +/* + * Adaptor class for interface org.openobex.Agent + */ +class ObexAgentAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.openobex.Agent") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + ObexAgentAdaptor(QObject *parent); + virtual ~ObexAgentAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + void Complete(const QDBusObjectPath &path); + void Error(const QDBusObjectPath &path, const QString &error); + void Progress(const QDBusObjectPath &path, qulonglong transferred); + void Release(); +Q_SIGNALS: // SIGNALS +}; + +#endif diff --git a/bluetooth-qt/obex/obexclient.cpp b/bluetooth-qt/obex/obexclient.cpp new file mode 100644 index 0000000..5295373 --- /dev/null +++ b/bluetooth-qt/obex/obexclient.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -p obexclient.h:obexclient.cpp client.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "obexclient.h" + +/* + * Implementation of interface class OrgOpenobexClientInterface + */ + +OrgOpenobexClientInterface::OrgOpenobexClientInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +OrgOpenobexClientInterface::~OrgOpenobexClientInterface() +{ +} + diff --git a/bluetooth-qt/obex/obexclient.h b/bluetooth-qt/obex/obexclient.h new file mode 100644 index 0000000..3fcbb16 --- /dev/null +++ b/bluetooth-qt/obex/obexclient.h @@ -0,0 +1,82 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -p obexclient.h:obexclient.cpp client.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef OBEXCLIENT_H_1306341758 +#define OBEXCLIENT_H_1306341758 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface org.openobex.Client + */ +class OrgOpenobexClientInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.openobex.Client"; } + +public: + OrgOpenobexClientInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~OrgOpenobexClientInterface(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply CreateSession(const QVariantMap &in0) + { + QList argumentList; + argumentList << qVariantFromValue(in0); + return asyncCallWithArgumentList(QLatin1String("CreateSession"), argumentList); + } + + inline QDBusPendingReply<> ExchangeBusinessCards(const QVariantMap &in0, const QString &in1, const QString &in2) + { + QList argumentList; + argumentList << qVariantFromValue(in0) << qVariantFromValue(in1) << qVariantFromValue(in2); + return asyncCallWithArgumentList(QLatin1String("ExchangeBusinessCards"), argumentList); + } + + inline QDBusPendingReply GetCapabilities(const QVariantMap &in0) + { + QList argumentList; + argumentList << qVariantFromValue(in0); + return asyncCallWithArgumentList(QLatin1String("GetCapabilities"), argumentList); + } + + inline QDBusPendingReply<> PullBusinessCard(const QVariantMap &in0, const QString &in1) + { + QList argumentList; + argumentList << qVariantFromValue(in0) << qVariantFromValue(in1); + return asyncCallWithArgumentList(QLatin1String("PullBusinessCard"), argumentList); + } + + inline QDBusPendingReply<> SendFiles(const QVariantMap &in0, const QStringList &in1, const QDBusObjectPath &in2) + { + QList argumentList; + argumentList << qVariantFromValue(in0) << qVariantFromValue(in1) << qVariantFromValue(in2); + return asyncCallWithArgumentList(QLatin1String("SendFiles"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +namespace org { + namespace openobex { + typedef ::OrgOpenobexClientInterface Client; + } +} +#endif diff --git a/bluetooth-qt/obex/obexftp.cpp b/bluetooth-qt/obex/obexftp.cpp new file mode 100644 index 0000000..6fce62c --- /dev/null +++ b/bluetooth-qt/obex/obexftp.cpp @@ -0,0 +1,131 @@ +#include "obexftp.h" + +#include + +ObexFtp::ObexFtp(QString device, QObject *parent) : + QObject(parent), m_device(device), m_session(0), m_ftp(0), agent(0) +{ + m_client = new OrgOpenobexClientInterface("org.openobex.client", "/", QDBusConnection::sessionBus(), this); + +} + +bool ObexFtp::isConnected() +{ + if(!m_session) return false; + + QVariantMap props = m_session->GetProperties(); + foreach(QString key, props.keys()) + { + qDebug()<<"session property key: "<CreateSession(session); + + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); + + QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + this, SLOT(finishedConnecting(QDBusPendingCallWatcher*))); + +} + +void ObexFtp::disconnect() +{ + if(isConnected()) + m_session->Close(); +} + +void ObexFtp::cancel() +{ + +} + +void ObexFtp::transferFile(QString localfile, QString remotefile) +{ + if(!isConnected()) + { + qDebug()<<"must be connected first."; + return; + } + + QDBusPendingCall async = m_ftp->PutFile(localfile,remotefile); + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(async, this); + + QObject::connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)), + this, SLOT(finishedTransfer(QDBusPendingCallWatcher*))); +} + +void ObexFtp::finishedTransfer(QDBusPendingCallWatcher* call) +{ + QDBusPendingReply reply = *call; + + if(!reply.isValid()) + { + QDBusError errors = reply.error(); + emit error(errors.name()+" : "+errors.message()); + } +} + +void ObexFtp::finishedConnecting(QDBusPendingCallWatcher* call) +{ + QDBusPendingReply reply = *call; + + if(!reply.isValid()) + { + QDBusError errors = reply.error(); + emit error(errors.name()+" : "+errors.message()); + } + + QDBusObjectPath sessionPath = reply.value(); + + qDebug()<< sessionPath.path(); + + m_session = new OrgOpenobexSessionInterface("org.openobex.client", sessionPath.path(), QDBusConnection::sessionBus()); + + if(agent) delete agent; + agent = new ObexAgentAdaptor(this); + + QDBusConnection::sessionBus().registerObject(sessionPath.path(), agent); + m_session->AssignAgent(sessionPath); + + if(m_ftp) m_ftp->deleteLater(); + + m_ftp = new OrgOpenobexFileTransferInterface("org.openobex.client", + sessionPath.path(),QDBusConnection::sessionBus(),this); + + emit connected(); +} + +void ObexFtp::Complete(const QDBusObjectPath &path) +{ + emit transferComplete(); +} + +void ObexFtp::Error(const QDBusObjectPath &path, const QString &errors) +{ + emit error(path.path()+" : "+errors); +} + +void ObexFtp::Progress(const QDBusObjectPath &path, qulonglong transferred) +{ + OrgOpenobexTransferInterface transfer("org.openobex.client",path.path(),QDBusConnection::sessionBus()); + + QVariantMap props = transfer.GetProperties(); + + emit transferProgress(transferred, props["Size"].toULongLong()); +} + +void ObexFtp::Release() +{ + ///FIXME: not sure what to do here +} diff --git a/bluetooth-qt/obex/obexftp.h b/bluetooth-qt/obex/obexftp.h new file mode 100644 index 0000000..bba46e9 --- /dev/null +++ b/bluetooth-qt/obex/obexftp.h @@ -0,0 +1,61 @@ +#ifndef OBEXFTP_H +#define OBEXFTP_H + +#include +#include "obextransfer.h" +#include "obexsession.h" +#include "obexclient.h" +#include "obexagent.h" + +class ObexFtp : public QObject +{ +Q_OBJECT +public: + + enum State + { + Disconnected = 0, + Connecting, + Connected, + Busy + }; + + explicit ObexFtp(QString device, QObject *parent = 0); + + bool isConnected(); + +public slots: + + void connect(); + void disconnect(); + void cancel(); + + void transferFile(QString localfile, QString remotefile); + +private slots: + void finishedTransfer(QDBusPendingCallWatcher*); + void finishedConnecting(QDBusPendingCallWatcher*); + + ///for the agent adaptor: + void Complete(const QDBusObjectPath &path); + void Error(const QDBusObjectPath &path, const QString &error); + void Progress(const QDBusObjectPath &path, qulonglong transferred); + void Release(); + + +signals: + void transferProgress(quint64 done, quint64 total); + void transferComplete(); + void error(QString); + void connected(); + +private: + QString m_device; + OrgOpenobexSessionInterface* m_session; + OrgOpenobexFileTransferInterface* m_ftp; + OrgOpenobexClientInterface* m_client; + ObexAgentAdaptor* agent; + +}; + +#endif // OBEXFTP_H diff --git a/bluetooth-qt/obex/obexsession.cpp b/bluetooth-qt/obex/obexsession.cpp new file mode 100644 index 0000000..cbdfd1f --- /dev/null +++ b/bluetooth-qt/obex/obexsession.cpp @@ -0,0 +1,39 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -p obexsession.h:obexsession.cpp -i types.h session.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "obexsession.h" + +/* + * Implementation of interface class OrgOpenobexFileTransferInterface + */ + +OrgOpenobexFileTransferInterface::OrgOpenobexFileTransferInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +OrgOpenobexFileTransferInterface::~OrgOpenobexFileTransferInterface() +{ +} + +/* + * Implementation of interface class OrgOpenobexSessionInterface + */ + +OrgOpenobexSessionInterface::OrgOpenobexSessionInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +OrgOpenobexSessionInterface::~OrgOpenobexSessionInterface() +{ +} + diff --git a/bluetooth-qt/obex/obexsession.h b/bluetooth-qt/obex/obexsession.h new file mode 100644 index 0000000..63532bb --- /dev/null +++ b/bluetooth-qt/obex/obexsession.h @@ -0,0 +1,149 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -p obexsession.h:obexsession.cpp -i types.h session.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef OBEXSESSION_H_1306341758 +#define OBEXSESSION_H_1306341758 + +#include +#include +#include +#include +#include +#include +#include +#include +#include "types.h" + +/* + * Proxy class for interface org.openobex.FileTransfer + */ +class OrgOpenobexFileTransferInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.openobex.FileTransfer"; } + +public: + OrgOpenobexFileTransferInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~OrgOpenobexFileTransferInterface(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<> ChangeFolder(const QString &in0) + { + QList argumentList; + argumentList << qVariantFromValue(in0); + return asyncCallWithArgumentList(QLatin1String("ChangeFolder"), argumentList); + } + + inline QDBusPendingReply<> CopyFile(const QString &in0, const QString &in1) + { + QList argumentList; + argumentList << qVariantFromValue(in0) << qVariantFromValue(in1); + return asyncCallWithArgumentList(QLatin1String("CopyFile"), argumentList); + } + + inline QDBusPendingReply<> CreateFolder(const QString &in0) + { + QList argumentList; + argumentList << qVariantFromValue(in0); + return asyncCallWithArgumentList(QLatin1String("CreateFolder"), argumentList); + } + + inline QDBusPendingReply<> Delete(const QString &in0) + { + QList argumentList; + argumentList << qVariantFromValue(in0); + return asyncCallWithArgumentList(QLatin1String("Delete"), argumentList); + } + + inline QDBusPendingReply<> GetFile(const QString &in0, const QString &in1) + { + QList argumentList; + argumentList << qVariantFromValue(in0) << qVariantFromValue(in1); + return asyncCallWithArgumentList(QLatin1String("GetFile"), argumentList); + } + + inline QDBusPendingReply ListFolder() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("ListFolder"), argumentList); + } + + inline QDBusPendingReply<> MoveFile(const QString &in0, const QString &in1) + { + QList argumentList; + argumentList << qVariantFromValue(in0) << qVariantFromValue(in1); + return asyncCallWithArgumentList(QLatin1String("MoveFile"), argumentList); + } + + inline QDBusPendingReply<> PutFile(const QString &in0, const QString &in1) + { + QList argumentList; + argumentList << qVariantFromValue(in0) << qVariantFromValue(in1); + return asyncCallWithArgumentList(QLatin1String("PutFile"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +/* + * Proxy class for interface org.openobex.Session + */ +class OrgOpenobexSessionInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.openobex.Session"; } + +public: + OrgOpenobexSessionInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~OrgOpenobexSessionInterface(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<> AssignAgent(const QDBusObjectPath &in0) + { + QList argumentList; + argumentList << qVariantFromValue(in0); + return asyncCallWithArgumentList(QLatin1String("AssignAgent"), argumentList); + } + + inline QDBusPendingReply<> Close() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Close"), argumentList); + } + + inline QDBusPendingReply GetProperties() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); + } + + inline QDBusPendingReply<> ReleaseAgent(const QDBusObjectPath &in0) + { + QList argumentList; + argumentList << qVariantFromValue(in0); + return asyncCallWithArgumentList(QLatin1String("ReleaseAgent"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +namespace org { + namespace openobex { + typedef ::OrgOpenobexFileTransferInterface FileTransfer; + typedef ::OrgOpenobexSessionInterface Session; + } +} +#endif diff --git a/bluetooth-qt/obex/obextransfer.cpp b/bluetooth-qt/obex/obextransfer.cpp new file mode 100644 index 0000000..be139d2 --- /dev/null +++ b/bluetooth-qt/obex/obextransfer.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -p obextransfer.h:obextransfer.cpp transfer.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "obextransfer.h" + +/* + * Implementation of interface class OrgOpenobexTransferInterface + */ + +OrgOpenobexTransferInterface::OrgOpenobexTransferInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +OrgOpenobexTransferInterface::~OrgOpenobexTransferInterface() +{ +} + diff --git a/bluetooth-qt/obex/obextransfer.h b/bluetooth-qt/obex/obextransfer.h new file mode 100644 index 0000000..7450eac --- /dev/null +++ b/bluetooth-qt/obex/obextransfer.h @@ -0,0 +1,59 @@ +/* + * This file was generated by qdbusxml2cpp version 0.7 + * Command line was: qdbusxml2cpp -p obextransfer.h:obextransfer.cpp transfer.xml + * + * qdbusxml2cpp is Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef OBEXTRANSFER_H_1306341758 +#define OBEXTRANSFER_H_1306341758 + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface org.openobex.Transfer + */ +class OrgOpenobexTransferInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.openobex.Transfer"; } + +public: + OrgOpenobexTransferInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~OrgOpenobexTransferInterface(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply<> Cancel() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("Cancel"), argumentList); + } + + inline QDBusPendingReply GetProperties() + { + QList argumentList; + return asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +namespace org { + namespace openobex { + typedef ::OrgOpenobexTransferInterface Transfer; + } +} +#endif diff --git a/bluetooth-qt/obex/session.xml b/bluetooth-qt/obex/session.xml new file mode 100644 index 0000000..596f152 --- /dev/null +++ b/bluetooth-qt/obex/session.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bluetooth-qt/obex/transfer.xml b/bluetooth-qt/obex/transfer.xml new file mode 100644 index 0000000..d1b1235 --- /dev/null +++ b/bluetooth-qt/obex/transfer.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/bluetooth-qt/obex/types.h b/bluetooth-qt/obex/types.h new file mode 100644 index 0000000..e6517a1 --- /dev/null +++ b/bluetooth-qt/obex/types.h @@ -0,0 +1,11 @@ +#ifndef _OBEX_TYPES_H_ +#define _OBEX_TYPES_H_ + +#include +#include +#include + +typedef QList QVariantMapList; +Q_DECLARE_METATYPE(QVariantMapList) + +#endif diff --git a/declarative/components.cpp b/declarative/components.cpp new file mode 100644 index 0000000..57df6d4 --- /dev/null +++ b/declarative/components.cpp @@ -0,0 +1,28 @@ +/* + * Copyright 2011 Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +#include "components.h" + +#include +#include +#include + +void Components::registerTypes(const char *uri) +{ + qmlRegisterType(uri,0,0,"NearbyDevicesModel"); + qmlRegisterType(uri,0,0,"BluetoothDevice"); + qmlRegisterType(uri,0,0,"BluetoothDevicesModel"); +} + +void Components::initializeEngine(QDeclarativeEngine *engine, const char *uri) +{ + Q_UNUSED(uri); + Q_UNUSED(engine); +} + +Q_EXPORT_PLUGIN(Components); diff --git a/declarative/components.h b/declarative/components.h new file mode 100644 index 0000000..5e3813b --- /dev/null +++ b/declarative/components.h @@ -0,0 +1,24 @@ +/* + * Copyright 2011 Intel Corporation. + * + * This program is licensed under the terms and conditions of the + * Apache License, version 2.0. The full text of the Apache License is at + * http://www.apache.org/licenses/LICENSE-2.0 + */ + +#ifndef COMPONENTS_H +#define COMPONENTS_H + +#include +#include + +class Components : public QDeclarativeExtensionPlugin +{ + Q_OBJECT + +public: + void registerTypes(const char *uri); + void initializeEngine(QDeclarativeEngine *engine, const char *uri); +}; + +#endif // COMPONENTS_H diff --git a/declarative/declarative.pro b/declarative/declarative.pro new file mode 100644 index 0000000..401d3e7 --- /dev/null +++ b/declarative/declarative.pro @@ -0,0 +1,27 @@ +TEMPLATE = lib +QT += declarative dbus + +CONFIG += qt \ + plugin \ + link_pkgconfig + +INCLUDEPATH += ../bluetooth-qt +LIBS += -L../bluetooth-qt -lbluetooth-qt + +TARGET = Bluetooth-qt +OBJECTS_DIR = .obj +MOC_DIR = .moc + +# Input +SOURCES += components.cpp + +OTHER_FILES += qmldir + +HEADERS += components.h + +qmldir.files += qmldir +qmldir.path = $$[QT_INSTALL_IMPORTS]/Tizen/Bluetooth + +target.path = $$[QT_INSTALL_IMPORTS]/Tizen/Bluetooth + +INSTALLS += qmldir target diff --git a/declarative/qmldir b/declarative/qmldir new file mode 100644 index 0000000..c20fc84 --- /dev/null +++ b/declarative/qmldir @@ -0,0 +1 @@ +plugin Bluetooth-qt diff --git a/makedist b/makedist new file mode 100755 index 0000000..f260801 --- /dev/null +++ b/makedist @@ -0,0 +1,52 @@ +#!/bin/bash + + + + +# Determine project name based on current directory +PROJECT=$(basename $PWD) + +# NOTE: Don't like this? Then uncomment one of the following as appropriate +# +# Just set it explictly to whatever you like: +# PROJECT=libseaside +# +# Parse it from any Qt *.pro or *.pri files in CWD: +# PROJECT=$(grep -E "TARGET ?= ?" *.pr[io]|cut -d' ' -f3) + +while getopts ht: o +do case $o in + h) head=1;; + t) TAG="$OPTARG";; + ?) printf >&2 "Usage: $0 [-h] [-t TAG]\n" + exit 2;; + esac +done + +# Grab most recent tag from git unless TAG is set +if [ -z "$TAG" ] ; then + TAG=$(git describe --tags --abbrev=0) +fi + +# Parse out just the version number +#PARTS=(${TAG//-/ }) +#VERSION=${PARTS[1]} +VERSION=${TAG} + +# Set name of toplevel directory for the archive +PREFIX="${PROJECT}-${VERSION}/" + +# Set name of resulting release archive file +ARCHIVE=${PROJECT}-${VERSION}.tar.bz2 + +[ -e ${ARCHIVE} ] && rm -rf ${ARCHIVE} && echo "Removed: ${ARCHIVE}" + +if [ ! -z "$head" ] ; then + TAG="HEAD" +fi + +git archive --format=tar --prefix=${PREFIX} $TAG | bzip2 -c -- > ${ARCHIVE} && { + echo "Created: ${ARCHIVE}" +} || { + echo "Creation of release archive ${ARCHIVE} failed. Reason unknown." +} diff --git a/packaging/bluetooth-qt.spec b/packaging/bluetooth-qt.spec new file mode 100644 index 0000000..46fac32 --- /dev/null +++ b/packaging/bluetooth-qt.spec @@ -0,0 +1,97 @@ +%define buildwayland 1 +%if %{buildwayland} +%define backend -wayland +%else +%define backend -xlib +%endif + +Name: bluetooth-qt%{backend} +Summary: Library for accessing bluetooth functionality in Qt +Version: 0.1.0 +Release: 1 +Group: System/GUI/Other +License: Apache License 2.0 +Source0: bluetooth-qt-%{version}.tar.bz2 +Patch0: bmc20660.patch +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig +BuildRequires: pkgconfig(QtCore%{backend}) +BuildRequires: pkgconfig(QtDBus%{backend}) +BuildRequires: pkgconfig(QtOpenGL%{backend}) +BuildRequires: pkgconfig(QtGui%{backend}) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: doxygen + + +%description +This is a library for accessing bluetooth through bluez functionality in Qt. + + + +%package devel +Summary: Development files for bluetooth-qt +Group: Development/Libraries +Requires: %{name} = %{version}-%{release} + +%description devel +This package contains the files necessary to develop +applications using qt to access bluetooth devices using bluez + + + +%prep +%setup -q -n bluetooth-qt-%{version} + +# bmc20660.patch +%patch0 -p1 +# >> setup +# << setup + +%build +# >> build pre +qmake install_prefix=/usr +# << build pre + + +make %{?jobs:-j%jobs} + +# >> build post +# << build post +%install +rm -rf %{buildroot} +# >> install pre +# << install pre +%make_install + +# >> install post +# << install post + + + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + + + + +%files +%defattr(-,root,root,-) +%{_libdir}/libbluetooth-qt.so.* +%{_libdir}/qt4/imports/Tizen/Bluetooth/* +/etc/dbus-1/system.d/bluetooth-qt.conf +# >> files +# << files + + +%files devel +%defattr(-,root,root,-) +%{_includedir}/bluetooth-qt/*.h +%{_libdir}/libbluetooth-qt.so +%{_libdir}/*.prl +%{_libdir}/pkgconfig/*.pc +%{_libdir}/*.pc +# >> files devel +# << files devel + diff --git a/patches/bmc20660.patch b/patches/bmc20660.patch new file mode 100644 index 0000000..3a4bc07 --- /dev/null +++ b/patches/bmc20660.patch @@ -0,0 +1,61 @@ +diff --git a/bluetooth-qt/bluetoothdevicemodel.cpp b/bluetooth-qt/bluetoothdevicemodel.cpp +index 24015a5..4fdd2b4 100644 +--- a/bluetooth-qt/bluetoothdevicemodel.cpp ++++ b/bluetooth-qt/bluetoothdevicemodel.cpp +@@ -31,6 +31,8 @@ BluetoothDevicesModel::BluetoothDevicesModel(QObject *parent) : + roles[i]=properties.property(i).name(); + } + ++ roles[roles.keys().count()+1] = "bluetoothDevice"; ++ + setRoleNames(roles); + } + +@@ -49,6 +51,11 @@ QVariant BluetoothDevicesModel::data(const QModelIndex &index, int role) const + return QVariant(); ///this is retarded but it has to be done. + } + ++ if(roleNames()[role] == "bluetoothDevice") ++ { ++ return QVariant::fromValue((QObject*)m_devices[index.row()]); ++ } ++ + QString roleName = roleNames()[role]; + QMetaObject object = BluetoothDevice::staticMetaObject; + +@@ -131,8 +138,15 @@ void BluetoothDevicesModel::setDiscoverableTimeout(int timeout) + { + if(adapter) + { +- bool success = adapter->setProperty("DiscoverableTimeout", timeout); +- qDebug()<<"Setting discoverable timeout to "< reply = adapter->SetProperty("DiscoverableTimeout", QDBusVariant((uint)timeout)); ++ if(!reply.isValid()) ++ { ++ qDebug()<<"error setting discoverable timeout: "<address() == hwaddy) + { ++ bool nameUpdated = false; ++ if((path->name() == "") && (properties["Name"].toString() != "")) nameUpdated = true; + path->setName(properties["Name"].toString()); + path->setAlias(properties["Alias"].toString()); + path->setIcon(properties["Icon"].toString()); ++ ++ emit dataChanged(createIndex(devices.indexOf(path),0),createIndex(devices.indexOf(path),0)); + return; + } + } -- 2.7.4