Initial Import
authorPrajwal Mohan <prajwal.karur.mohan@intel.com>
Fri, 27 Apr 2012 22:41:57 +0000 (15:41 -0700)
committerPrajwal Mohan <prajwal.karur.mohan@intel.com>
Fri, 27 Apr 2012 22:41:57 +0000 (15:41 -0700)
49 files changed:
LICENSE [new file with mode: 0644]
bluetooth-qt.pro [new file with mode: 0644]
bluetooth-qt/adapter.xml [new file with mode: 0644]
bluetooth-qt/agentadaptor.cpp [new file with mode: 0644]
bluetooth-qt/agentadaptor.h [new file with mode: 0644]
bluetooth-qt/asyncagent.cpp [new file with mode: 0644]
bluetooth-qt/asyncagent.h [new file with mode: 0644]
bluetooth-qt/audio.xml [new file with mode: 0644]
bluetooth-qt/audiosink.xml [new file with mode: 0644]
bluetooth-qt/audiosrc.xml [new file with mode: 0644]
bluetooth-qt/bluetooth-qt.conf [new file with mode: 0644]
bluetooth-qt/bluetooth-qt.pro [new file with mode: 0644]
bluetooth-qt/bluetoothbaseagent.cpp [new file with mode: 0644]
bluetooth-qt/bluetoothbaseagent.h [new file with mode: 0644]
bluetooth-qt/bluetoothdevice.cpp [new file with mode: 0644]
bluetooth-qt/bluetoothdevice.h [new file with mode: 0644]
bluetooth-qt/bluetoothdevicemodel.cpp [new file with mode: 0644]
bluetooth-qt/bluetoothdevicemodel.h [new file with mode: 0644]
bluetooth-qt/btprofiles.h [new file with mode: 0644]
bluetooth-qt/device.xml [new file with mode: 0644]
bluetooth-qt/devicetypes.h [new file with mode: 0644]
bluetooth-qt/headset.xml [new file with mode: 0644]
bluetooth-qt/input.xml [new file with mode: 0644]
bluetooth-qt/manager.xml [new file with mode: 0644]
bluetooth-qt/nearbydevicesmodel.cpp [new file with mode: 0644]
bluetooth-qt/nearbydevicesmodel.h [new file with mode: 0644]
bluetooth-qt/obex/agent.xml [new file with mode: 0644]
bluetooth-qt/obex/client.xml [new file with mode: 0644]
bluetooth-qt/obex/obex.pri [new file with mode: 0644]
bluetooth-qt/obex/obexagent.cpp [new file with mode: 0644]
bluetooth-qt/obex/obexagent.h [new file with mode: 0644]
bluetooth-qt/obex/obexclient.cpp [new file with mode: 0644]
bluetooth-qt/obex/obexclient.h [new file with mode: 0644]
bluetooth-qt/obex/obexftp.cpp [new file with mode: 0644]
bluetooth-qt/obex/obexftp.h [new file with mode: 0644]
bluetooth-qt/obex/obexsession.cpp [new file with mode: 0644]
bluetooth-qt/obex/obexsession.h [new file with mode: 0644]
bluetooth-qt/obex/obextransfer.cpp [new file with mode: 0644]
bluetooth-qt/obex/obextransfer.h [new file with mode: 0644]
bluetooth-qt/obex/session.xml [new file with mode: 0644]
bluetooth-qt/obex/transfer.xml [new file with mode: 0644]
bluetooth-qt/obex/types.h [new file with mode: 0644]
declarative/components.cpp [new file with mode: 0644]
declarative/components.h [new file with mode: 0644]
declarative/declarative.pro [new file with mode: 0644]
declarative/qmldir [new file with mode: 0644]
makedist [new file with mode: 0755]
packaging/bluetooth-qt.spec [new file with mode: 0644]
patches/bmc20660.patch [new file with mode: 0644]

diff --git a/LICENSE b/LICENSE
new file mode 100644 (file)
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 (file)
index 0000000..52e0afc
--- /dev/null
@@ -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 (file)
index 0000000..c02b83d
--- /dev/null
@@ -0,0 +1,66 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+         "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+  <interface name="org.bluez.Adapter">
+    <method name="GetProperties">
+      <arg type="a{sv}" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+    </method>
+    <method name="SetProperty">
+      <arg type="s" direction="in"/>
+      <arg type="v" direction="in"/>
+    </method>
+    <method name="RequestSession"/>
+    <method name="ReleaseSession"/>
+    <method name="StartDiscovery"/>
+    <method name="StopDiscovery"/>
+    <method name="ListDevices">
+      <arg type="ao" direction="out"/>
+    </method>
+    <method name="CreateDevice">
+      <arg type="s" direction="in"/>
+      <arg type="o" direction="out"/>
+    </method>
+    <method name="CreatePairedDevice">
+      <arg type="s" direction="in"/>
+      <arg type="o" direction="in"/>
+      <arg type="s" direction="in"/>
+      <arg type="o" direction="out"/>
+    </method>
+    <method name="CancelDeviceCreation">
+      <arg type="s" direction="in"/>
+    </method>
+    <method name="RemoveDevice">
+      <arg type="o" direction="in"/>
+    </method>
+    <method name="FindDevice">
+      <arg type="s" direction="in"/>
+      <arg type="o" direction="out"/>
+    </method>
+    <method name="RegisterAgent">
+      <arg type="o" direction="in"/>
+      <arg type="s" direction="in"/>
+    </method>
+    <method name="UnregisterAgent">
+      <arg type="o" direction="in"/>
+    </method>
+    <signal name="PropertyChanged">
+      <arg type="s"/>
+      <arg type="v"/>
+    </signal>
+    <signal name="DeviceCreated">
+      <arg type="o"/>
+    </signal>
+    <signal name="DeviceRemoved">
+      <arg type="o"/>
+    </signal>
+    <signal name="DeviceFound">
+      <arg type="s"/>
+      <arg type="a{sv}"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.In1" value="QVariantMap"/>
+    </signal>
+    <signal name="DeviceDisappeared">
+      <arg type="s"/>
+    </signal>
+  </interface>
+</node>
diff --git a/bluetooth-qt/agentadaptor.cpp b/bluetooth-qt/agentadaptor.cpp
new file mode 100644 (file)
index 0000000..96d1487
--- /dev/null
@@ -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 (file)
index 0000000..bec276f
--- /dev/null
@@ -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 <QDBusAbstractAdaptor>
+#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 (file)
index 0000000..ef8ddbd
--- /dev/null
@@ -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 (file)
index 0000000..568e2c9
--- /dev/null
@@ -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 (file)
index 0000000..cf98e8c
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+  <interface name="org.bluez.Audio"> 
+    <method name="Connect"/> 
+    <method name="Disconnect"/> 
+    <method name="GetProperties"> 
+      <arg type="a{sv}" direction="out"/> 
+      <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+    </method> 
+    <signal name="PropertyChanged"> 
+      <arg type="s"/> 
+      <arg type="v"/> 
+    </signal>
+  </interface>
+</node>
diff --git a/bluetooth-qt/audiosink.xml b/bluetooth-qt/audiosink.xml
new file mode 100644 (file)
index 0000000..dc20f05
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+         "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.bluez.AudioSink">
+  <method name="Connect"/>
+  <method name="Disconnect"/>
+  <method name="IsConnected">
+   <arg type="b" direction="out"/>
+  </method>
+  <method name="GetProperties">
+   <arg type="a{sv}" direction="out"/>
+   <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+  </method>
+  <signal name="Connected"/>
+  <signal name="Disconnected"/>
+  <signal name="Playing"/>
+  <signal name="Stopped"/>
+  <signal name="PropertyChanged">
+   <arg type="s"/>
+   <arg type="v"/>
+  </signal>
+ </interface>
+</node>
diff --git a/bluetooth-qt/audiosrc.xml b/bluetooth-qt/audiosrc.xml
new file mode 100644 (file)
index 0000000..c5273b6
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+         "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.bluez.AudioSource">
+  <method name="Connect"/>
+  <method name="Disconnect"/>
+  <method name="GetProperties">
+   <arg type="a{sv}" direction="out"/>
+   <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+  </method>
+  <signal name="PropertyChanged">
+   <arg type="s"/>
+   <arg type="v"/>
+  </signal>
+ </interface>
+</node>
diff --git a/bluetooth-qt/bluetooth-qt.conf b/bluetooth-qt/bluetooth-qt.conf
new file mode 100644 (file)
index 0000000..24125b0
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE busconfig PUBLIC
+ "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+               <policy context="default">
+                       <allow own="com.meego.bluetooth" />
+                       <allow send_destination="com.meego.bluetooth" />
+                       <allow send_destination="com.meego.bluetooth"
+                               send_interface="com.meego.bluetooth" />
+                       <allow send_path="/pairing/agent" />
+               </policy>
+
+               <limit name="max_replies_per_connection">512</limit>
+</busconfig>
diff --git a/bluetooth-qt/bluetooth-qt.pro b/bluetooth-qt/bluetooth-qt.pro
new file mode 100644 (file)
index 0000000..726994f
--- /dev/null
@@ -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 (file)
index 0000000..8677b26
--- /dev/null
@@ -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 <QTimer>
+
+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: "<<adapter.lastError().message();
+}
+
+void BluetoothBaseAgent::authorize(OrgBluezDeviceInterface &device, QString uuid)
+{
+       Q_UNUSED(uuid);
+       Q_UNUSED(device);
+       qDebug("authorize");
+}
+
+void BluetoothBaseAgent::confirmModeChange(QString mode)
+{
+       qDebug()<<"mode changed "<<mode;
+}
+
+void BluetoothBaseAgent::displayPasskey(OrgBluezDeviceInterface &device, uint key, uint entered)
+{
+       qDebug()<<"display key "<<device.path()<<" "<<key;
+
+       ///create and return back an empty reply:
+       QDBusMessage reply = message().createReply();
+       connection().send(reply);
+}
+
+void BluetoothBaseAgent::release()
+{
+       qDebug("release called");
+}
+
+void BluetoothBaseAgent::requestConfirmation(OrgBluezDeviceInterface &device, uint key)
+{
+       QVariantMap props = device.GetProperties();
+
+       QString alias = props["Alias"].toString();
+
+       qDebug()<<"Pairing with "<< alias << " with key: "+QString::number(key);
+}
+
+uint BluetoothBaseAgent::requestPasskey(OrgBluezDeviceInterface &device)
+{
+       Q_UNUSED(device);
+       qDebug("requestKey");
+       return 0;
+}
+
+QString BluetoothBaseAgent::requestPidCode(OrgBluezDeviceInterface &device)
+{
+       Q_UNUSED(device);
+       return "";
+}
+
diff --git a/bluetooth-qt/bluetoothbaseagent.h b/bluetooth-qt/bluetoothbaseagent.h
new file mode 100644 (file)
index 0000000..fcf1873
--- /dev/null
@@ -0,0 +1,43 @@
+/*  -*- 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 BLUETOOTHBASEAGENT_H
+#define BLUETOOTHBASEAGENT_H
+
+#include <QObject>
+#include <QDBusContext>
+#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 (file)
index 0000000..4f2268e
--- /dev/null
@@ -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<QString> reply = interface.call(QDBus::AutoDetect, "Connect","spp");
+
+        if(reply.isValid()) return reply;
+        else qDebug()<<"Error connecting spp profile: "<<reply.error().message();
+    }
+
+    return "";
+}
+
+void BluetoothDevice::connectInput()
+{
+    input->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: "<<name<<" "<<value.variant();
+    if(name == "Connected")
+    {
+        emit inputConnectedChanged(value.variant().toBool());
+    }
+}
diff --git a/bluetooth-qt/bluetoothdevice.h b/bluetooth-qt/bluetoothdevice.h
new file mode 100644 (file)
index 0000000..38e75f7
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef BLUETOOTHDEVICE_H
+#define BLUETOOTHDEVICE_H
+
+#include <QObject>
+#include <QStringList>
+#include <bluedevice.h>
+
+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 (file)
index 0000000..24015a5
--- /dev/null
@@ -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<int, QByteArray> roles;
+
+       QMetaObject properties = BluetoothDevice::staticMetaObject;
+
+       for(int i=0; i<properties.propertyCount();i++)
+       {
+               roles[i]=properties.property(i).name();
+       }
+
+       setRoleNames(roles);
+}
+
+int BluetoothDevicesModel::rowCount(const QModelIndex &) const
+{
+       return m_devices.size();
+}
+
+QVariant BluetoothDevicesModel::data(const QModelIndex &index, int role) const
+{
+       qDebug()<<"requested role: "<<roleNames()[role];
+
+       if(!index.isValid() || index.row() < 0)
+       {
+               qDebug()<<"index is not valid: "<<index.row()<<","<<index.column();
+               return QVariant(); ///this is retarded but it has to be done.
+       }
+
+       QString roleName = roleNames()[role];
+       QMetaObject object = BluetoothDevice::staticMetaObject;
+
+       for(int i=0; i<object.propertyCount(); i++)
+       {
+               if(object.property(i).name() == roleName)
+               {
+
+                       return object.property(i).read(m_devices[index.row()]);
+               }
+       }
+       return QVariant();
+}
+
+QString BluetoothDevicesModel::devicePath(QString devicename)
+{
+       foreach(BluetoothDevice* device, m_devices)
+       {
+               if(device->name() == 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: "<<path;
+       return NULL;
+}
+
+void BluetoothDevicesModel::makePowered(bool poweredValue)
+{
+       if(adapter) adapter->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 "<<timeout<<": "<<success;
+       }
+}
+
+void BluetoothDevicesModel::adapterAdded(QDBusObjectPath path)
+{
+       if(adapter && adapter->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<QDBusObjectPath> 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; i<m_devices.size(); i++)
+       {
+
+               if(m_devices[i]->path() == 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<BluetoothDevice*>(sender());
+
+       qDebug()<<"device property changed for "<<device->address()<<": "<<name<<" "<<value;
+
+       if(name == "Paired" && value.toBool() == true)
+       {
+               emit devicePaired(device);
+       }
+
+       else if(name == "Connected")
+       {
+               updateConnected(value.toBool());
+       }
+       int row = m_devices.indexOf(device);
+       if(row == -1) return; ///device doesn't exist.
+
+       dataChanged(createIndex(row, 0),createIndex(row, 0));
+}
+
+void BluetoothDevicesModel::adapterPropertyChanged(QString name, QDBusVariant value)
+{
+       qDebug()<<"adapter property changed: "<<name<<" "<<value.variant();
+
+       if(name == "Powered")
+       {
+               poweredChanged(value.variant().toBool());
+       }
+       else if(name == "Discoverable")
+       {
+               discoverableChanged(value.variant().toBool());
+       }
+       else if(name == "DiscoverableTimeout")
+       {
+               discoverableTimeoutChanged(value.variant().toInt());
+       }
+}
+
+void BluetoothDevicesModel::updateConnected(bool deviceconnectedStatus)
+{
+       if(deviceconnectedStatus)
+       {
+               if(!m_connected)
+               {
+                       m_connected = true;
+                       connectedChanged(m_connected);
+               }
+       }
+       else
+       {
+               bool temp = false;
+               foreach(BluetoothDevice* device, devices())
+               {
+                       temp |= device->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 (file)
index 0000000..1a8fbb2
--- /dev/null
@@ -0,0 +1,70 @@
+#ifndef BLUETOOTHDEVICEMODEL_H
+#define BLUETOOTHDEVICEMODEL_H
+
+#include <QAbstractListModel>
+#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<BluetoothDevice*> 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<BluetoothDevice*> m_devices;
+};
+
+#endif // BLUETOOTHDEVICEMODEL_H
diff --git a/bluetooth-qt/btprofiles.h b/bluetooth-qt/btprofiles.h
new file mode 100644 (file)
index 0000000..e6afd01
--- /dev/null
@@ -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 <QMap>
+
+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 (file)
index 0000000..60658d0
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+         "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+  <interface name="org.bluez.Device">
+    <method name="GetProperties">
+      <arg type="a{sv}" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+    </method>
+    <method name="SetProperty">
+      <arg type="s" direction="in"/>
+      <arg type="v" direction="in"/>
+    </method>
+    <method name="DiscoverServices">
+      <arg type="s" direction="in"/>
+      <arg type="a{us}" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="UIntStringMap"/>
+    </method>
+    <method name="CancelDiscovery"/>
+    <method name="Disconnect"/>
+    <signal name="PropertyChanged">
+      <arg type="s"/>
+      <arg type="v"/>
+    </signal>
+    <signal name="DisconnectRequested"/>
+  </interface>
+</node>
diff --git a/bluetooth-qt/devicetypes.h b/bluetooth-qt/devicetypes.h
new file mode 100644 (file)
index 0000000..aa0267b
--- /dev/null
@@ -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 <QMap>
+
+typedef QMap<uint,QString> UIntStringMap;
+Q_DECLARE_METATYPE(UIntStringMap)
+
+
+
+#endif
diff --git a/bluetooth-qt/headset.xml b/bluetooth-qt/headset.xml
new file mode 100644 (file)
index 0000000..c12573a
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+         "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.bluez.Headset">
+  <method name="Connect"/>
+  <method name="Disconnect"/>
+  <method name="IsConnected">
+    <arg type="b" direction="out"/>
+  </method>
+  <method name="IndicateCall"/>
+  <method name="CancelCall"/>
+  <method name="Play"/>
+  <method name="Stop"/>
+  <method name="IsPlaying">
+    <arg type="b" direction="out"/>
+  </method>
+  <method name="GetSpeakerGain">
+    <arg type="q" direction="out"/>
+  </method>
+  <method name="GetMicrophoneGain">
+    <arg type="q" direction="out"/>
+  </method>
+  <method name="SetSpeakerGain">
+    <arg type="q" direction="in"/>
+  </method>
+  <method name="SetMicrophoneGain">
+    <arg type="q" direction="in"/>
+  </method>
+  <method name="GetProperties">
+    <arg type="a{sv}" direction="out"/>
+    <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+  </method>
+  <method name="SetProperty">
+    <arg type="s" direction="in"/>
+    <arg type="v" direction="in"/>
+  </method>
+  <signal name="Connected"/>
+  <signal name="Disconnected"/>
+  <signal name="AnswerRequested"/>
+  <signal name="Stopped"/>
+  <signal name="Playing"/>
+  <signal name="SpeakerGainChanged">
+    <arg type="q"/> </signal>
+  <signal name="MicrophoneGainChanged">
+    <arg type="q"/>
+  </signal>
+  <signal name="CallTerminated"/>
+  <signal name="PropertyChanged">
+    <arg type="s"/>
+    <arg type="v"/>
+  </signal>
+ </interface>
+</node>
diff --git a/bluetooth-qt/input.xml b/bluetooth-qt/input.xml
new file mode 100644 (file)
index 0000000..d49aac9
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+          "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.bluez.Input">
+  <method name="Connect"/>
+  <method name="Disconnect"/>
+  <method name="GetProperties">
+   <arg type="a{sv}" direction="out"/>
+   <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+  </method>
+  <signal name="PropertyChanged">
+    <arg type="s"/>
+    <arg type="v"/>
+    </signal>
+ </interface>
+</node>
diff --git a/bluetooth-qt/manager.xml b/bluetooth-qt/manager.xml
new file mode 100644 (file)
index 0000000..b9bb111
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+         "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+  <interface name="org.bluez.Manager">
+    <method name="GetProperties">
+      <arg type="a{sv}" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+    </method>
+    <method name="DefaultAdapter">
+      <arg type="o" direction="out"/>
+    </method>
+    <method name="FindAdapter">
+      <arg type="s" direction="in"/>
+      <arg type="o" direction="out"/>
+    </method>
+    <method name="ListAdapters">
+      <arg type="ao" direction="out"/>
+    </method>
+    <signal name="PropertyChanged">
+      <arg type="s"/>
+      <arg type="v"/>
+    </signal>
+    <signal name="AdapterAdded">
+      <arg type="o"/>
+    </signal>
+    <signal name="AdapterRemoved">
+      <arg type="o"/>
+    </signal>
+    <signal name="DefaultAdapterChanged">
+      <arg type="o"/>
+    </signal>
+  </interface>
+  <node name="org"/>
+</node>
diff --git a/bluetooth-qt/nearbydevicesmodel.cpp b/bluetooth-qt/nearbydevicesmodel.cpp
new file mode 100644 (file)
index 0000000..455c78c
--- /dev/null
@@ -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<int,QByteArray> roles;
+       QMetaObject properties = NearbyItem::staticMetaObject;
+       for(int i=0; i<properties.propertyCount();i++)
+       {
+               roles[i]=properties.property(i).name();
+       }
+       setRoleNames(roles);
+}
+
+
+int NearbyDevicesModel::rowCount(const QModelIndex &parent) const
+{
+       Q_UNUSED(parent);
+       return devices.size();
+}
+
+QVariant NearbyDevicesModel::data(const QModelIndex &index, int role) const
+{
+
+       if(!index.isValid() || index.row() < 0)
+       {
+               qDebug()<<"invalid index"<<index.row();
+               return QVariant();
+       }
+
+       QString roleName = roleNames()[role];
+       QMetaObject object = NearbyItem::staticMetaObject;
+
+       for(int i=0; i<object.propertyCount(); i++)
+       {
+               if(object.property(i).name() == roleName)
+               {
+
+                       return object.property(i).read(devices[index.row()]);
+               }
+       }
+
+       return QVariant();
+}
+
+void NearbyDevicesModel::pair(QString hwaddy)
+{
+
+       qDebug()<<"attempting to pair with "<<hwaddy;
+       if(!adapter) return;
+       if(!agent) agent = new AsyncAgent("/temp/agent", this);
+
+       adapter->CreatePairedDevice(hwaddy,
+                                  QDBusObjectPath("/temp/agent"),"");
+
+       //qDebug()<<"new object created: "<<object.path();
+}
+
+void NearbyDevicesModel::discover(bool start)
+{
+       if(!adapter) return;
+
+       if(start)
+               adapter->StartDiscovery();
+       else adapter->StopDiscovery();
+}
+
+void NearbyDevicesModel::removeAll(bool)
+{
+       for(int i=0;i<devices.size();i++)
+       {
+               devices.removeAt(i);
+       }
+}
+
+void NearbyDevicesModel::replyRequestConfirmation(bool confirmed)
+{
+       qDebug()<<"reply to RequestConfirmation:"<<confirmed;
+       if(agent) agent->replyRequestConfirmation(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 "<<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 (file)
index 0000000..7de241b
--- /dev/null
@@ -0,0 +1,117 @@
+#ifndef NEARBYDEVICESMODEL_H
+#define NEARBYDEVICESMODEL_H
+
+#include <QObject>
+#include <QAbstractListModel>
+#include <QDBusObjectPath>
+
+#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<NearbyItem*> 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 (file)
index 0000000..be0606b
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+          "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+  <interface name="org.openobex.Agent">
+    <method name="Release">
+    </method>
+    <method name="Progress">
+      <arg direction="in"  type="o" name="path" />
+      <arg direction="in"  type="t" name="transferred" />
+    </method>
+    <method name="Complete">
+      <arg direction="in"  type="o" name="path" />
+    </method>
+    <method name="Error">
+      <arg direction="in"  type="o" name="path" />
+      <arg direction="in"  type="s" name="error" />
+    </method>
+  </interface>
+</node>
+
diff --git a/bluetooth-qt/obex/client.xml b/bluetooth-qt/obex/client.xml
new file mode 100644 (file)
index 0000000..0520bbf
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+          "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+  <interface name="org.openobex.Client">
+    <method name="SendFiles">
+      <arg type="a{sv}" direction="in"/>
+      <arg type="as" direction="in"/>
+      <arg type="o" direction="in"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+    </method>
+    <method name="PullBusinessCard">
+      <arg type="a{sv}" direction="in"/>
+      <arg type="s" direction="in"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+    </method>
+    <method name="ExchangeBusinessCards">
+      <arg type="a{sv}" direction="in"/>
+      <arg type="s" direction="in"/>
+      <arg type="s" direction="in"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+    </method>
+    <method name="CreateSession">
+      <arg type="a{sv}" direction="in"/>
+      <arg type="o" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+    </method>
+    <method name="GetCapabilities">
+      <arg type="a{sv}" direction="in"/>
+      <arg type="s" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="QVariantMap"/>
+    </method>
+  </interface>
+</node>
+
diff --git a/bluetooth-qt/obex/obex.pri b/bluetooth-qt/obex/obex.pri
new file mode 100644 (file)
index 0000000..b5bb507
--- /dev/null
@@ -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 (file)
index 0000000..71323bc
--- /dev/null
@@ -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 <QtCore/QMetaObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+
+/*
+ * 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 (file)
index 0000000..07dbbff
--- /dev/null
@@ -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 <QtCore/QObject>
+#include <QtDBus/QtDBus>
+class QByteArray;
+template<class T> class QList;
+template<class Key, class Value> 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", ""
+"  <interface name=\"org.openobex.Agent\">\n"
+"    <method name=\"Release\"/>\n"
+"    <method name=\"Progress\">\n"
+"      <arg direction=\"in\" type=\"o\" name=\"path\"/>\n"
+"      <arg direction=\"in\" type=\"t\" name=\"transferred\"/>\n"
+"    </method>\n"
+"    <method name=\"Complete\">\n"
+"      <arg direction=\"in\" type=\"o\" name=\"path\"/>\n"
+"    </method>\n"
+"    <method name=\"Error\">\n"
+"      <arg direction=\"in\" type=\"o\" name=\"path\"/>\n"
+"      <arg direction=\"in\" type=\"s\" name=\"error\"/>\n"
+"    </method>\n"
+"  </interface>\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 (file)
index 0000000..5295373
--- /dev/null
@@ -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 (file)
index 0000000..3fcbb16
--- /dev/null
@@ -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 <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * 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<QDBusObjectPath> CreateSession(const QVariantMap &in0)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0);
+        return asyncCallWithArgumentList(QLatin1String("CreateSession"), argumentList);
+    }
+
+    inline QDBusPendingReply<> ExchangeBusinessCards(const QVariantMap &in0, const QString &in1, const QString &in2)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0) << qVariantFromValue(in1) << qVariantFromValue(in2);
+        return asyncCallWithArgumentList(QLatin1String("ExchangeBusinessCards"), argumentList);
+    }
+
+    inline QDBusPendingReply<QString> GetCapabilities(const QVariantMap &in0)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0);
+        return asyncCallWithArgumentList(QLatin1String("GetCapabilities"), argumentList);
+    }
+
+    inline QDBusPendingReply<> PullBusinessCard(const QVariantMap &in0, const QString &in1)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0) << qVariantFromValue(in1);
+        return asyncCallWithArgumentList(QLatin1String("PullBusinessCard"), argumentList);
+    }
+
+    inline QDBusPendingReply<> SendFiles(const QVariantMap &in0, const QStringList &in1, const QDBusObjectPath &in2)
+    {
+        QList<QVariant> 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 (file)
index 0000000..6fce62c
--- /dev/null
@@ -0,0 +1,131 @@
+#include "obexftp.h"
+
+#include <QDebug>
+
+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: "<<key<<" value: "<<props[key];
+       }
+
+       return !props["AgentPath"].toString().isEmpty();
+}
+
+void ObexFtp::connect()
+{
+       if(m_session) delete m_session;
+
+       QVariantMap session;
+       session["Destination"] = m_device;
+       session["Target"] = "FTP";
+
+       QDBusPendingCall async = m_client->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<void> reply = *call;
+
+       if(!reply.isValid())
+       {
+               QDBusError errors = reply.error();
+               emit error(errors.name()+" : "+errors.message());
+       }
+}
+
+void ObexFtp::finishedConnecting(QDBusPendingCallWatcher* call)
+{
+       QDBusPendingReply<QDBusObjectPath> 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 (file)
index 0000000..bba46e9
--- /dev/null
@@ -0,0 +1,61 @@
+#ifndef OBEXFTP_H
+#define OBEXFTP_H
+
+#include <QObject>
+#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 (file)
index 0000000..cbdfd1f
--- /dev/null
@@ -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 (file)
index 0000000..63532bb
--- /dev/null
@@ -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 <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+#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<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0);
+        return asyncCallWithArgumentList(QLatin1String("ChangeFolder"), argumentList);
+    }
+
+    inline QDBusPendingReply<> CopyFile(const QString &in0, const QString &in1)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0) << qVariantFromValue(in1);
+        return asyncCallWithArgumentList(QLatin1String("CopyFile"), argumentList);
+    }
+
+    inline QDBusPendingReply<> CreateFolder(const QString &in0)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0);
+        return asyncCallWithArgumentList(QLatin1String("CreateFolder"), argumentList);
+    }
+
+    inline QDBusPendingReply<> Delete(const QString &in0)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0);
+        return asyncCallWithArgumentList(QLatin1String("Delete"), argumentList);
+    }
+
+    inline QDBusPendingReply<> GetFile(const QString &in0, const QString &in1)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0) << qVariantFromValue(in1);
+        return asyncCallWithArgumentList(QLatin1String("GetFile"), argumentList);
+    }
+
+    inline QDBusPendingReply<QVariantMapList> ListFolder()
+    {
+        QList<QVariant> argumentList;
+        return asyncCallWithArgumentList(QLatin1String("ListFolder"), argumentList);
+    }
+
+    inline QDBusPendingReply<> MoveFile(const QString &in0, const QString &in1)
+    {
+        QList<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0) << qVariantFromValue(in1);
+        return asyncCallWithArgumentList(QLatin1String("MoveFile"), argumentList);
+    }
+
+    inline QDBusPendingReply<> PutFile(const QString &in0, const QString &in1)
+    {
+        QList<QVariant> 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<QVariant> argumentList;
+        argumentList << qVariantFromValue(in0);
+        return asyncCallWithArgumentList(QLatin1String("AssignAgent"), argumentList);
+    }
+
+    inline QDBusPendingReply<> Close()
+    {
+        QList<QVariant> argumentList;
+        return asyncCallWithArgumentList(QLatin1String("Close"), argumentList);
+    }
+
+    inline QDBusPendingReply<QVariantMap> GetProperties()
+    {
+        QList<QVariant> argumentList;
+        return asyncCallWithArgumentList(QLatin1String("GetProperties"), argumentList);
+    }
+
+    inline QDBusPendingReply<> ReleaseAgent(const QDBusObjectPath &in0)
+    {
+        QList<QVariant> 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 (file)
index 0000000..be139d2
--- /dev/null
@@ -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 (file)
index 0000000..7450eac
--- /dev/null
@@ -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 <QtCore/QObject>
+#include <QtCore/QByteArray>
+#include <QtCore/QList>
+#include <QtCore/QMap>
+#include <QtCore/QString>
+#include <QtCore/QStringList>
+#include <QtCore/QVariant>
+#include <QtDBus/QtDBus>
+
+/*
+ * 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<QVariant> argumentList;
+        return asyncCallWithArgumentList(QLatin1String("Cancel"), argumentList);
+    }
+
+    inline QDBusPendingReply<QVariantMap> GetProperties()
+    {
+        QList<QVariant> 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 (file)
index 0000000..596f152
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+          "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+  <interface name="org.openobex.Session">
+    <method name="GetProperties">
+      <arg type="a{sv}" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+    </method>
+    <method name="AssignAgent">
+      <arg type="o" direction="in"/>
+    </method>
+    <method name="ReleaseAgent">
+      <arg type="o" direction="in"/>
+    </method>
+    <method name="Close"/>
+  </interface>
+  <interface name="org.openobex.FileTransfer">
+    <method name="ChangeFolder">
+      <arg type="s" direction="in"/>
+    </method>
+    <method name="CreateFolder">
+      <arg type="s" direction="in"/>
+    </method>
+    <method name="ListFolder">
+      <arg type="aa{sv}" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMapList"/>
+    </method>
+    <method name="GetFile">
+      <arg type="s" direction="in"/>
+      <arg type="s" direction="in"/>
+    </method>
+    <method name="PutFile">
+      <arg type="s" direction="in"/>
+      <arg type="s" direction="in"/>
+    </method>
+    <method name="CopyFile">
+      <arg type="s" direction="in"/>
+      <arg type="s" direction="in"/>
+    </method>
+    <method name="MoveFile">
+      <arg type="s" direction="in"/>
+      <arg type="s" direction="in"/>
+    </method>
+    <method name="Delete">
+      <arg type="s" direction="in"/>
+    </method>
+  </interface>
+</node>
+
diff --git a/bluetooth-qt/obex/transfer.xml b/bluetooth-qt/obex/transfer.xml
new file mode 100644 (file)
index 0000000..d1b1235
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+          "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node name="/org/openobex/transfer5">
+  <interface name="org.openobex.Transfer">
+    <method name="GetProperties">
+      <arg type="a{sv}" direction="out"/>
+      <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QVariantMap"/>
+    </method>
+    <method name="Cancel"/>
+  </interface>
+</node>
+
diff --git a/bluetooth-qt/obex/types.h b/bluetooth-qt/obex/types.h
new file mode 100644 (file)
index 0000000..e6517a1
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _OBEX_TYPES_H_
+#define _OBEX_TYPES_H_
+
+#include <QtCore/QMap>
+#include <QtCore/QVariantMap>
+#include <QtCore/QString>
+
+typedef QList<QVariantMap> QVariantMapList;
+Q_DECLARE_METATYPE(QVariantMapList)
+
+#endif
diff --git a/declarative/components.cpp b/declarative/components.cpp
new file mode 100644 (file)
index 0000000..57df6d4
--- /dev/null
@@ -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 <nearbydevicesmodel.h>
+#include <bluetoothdevice.h>
+#include <bluetoothdevicemodel.h>
+
+void Components::registerTypes(const char *uri)
+{
+    qmlRegisterType<NearbyDevicesModel>(uri,0,0,"NearbyDevicesModel");
+    qmlRegisterType<BluetoothDevice>(uri,0,0,"BluetoothDevice");
+    qmlRegisterType<BluetoothDevicesModel>(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 (file)
index 0000000..5e3813b
--- /dev/null
@@ -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 <QtDeclarative/qdeclarative.h>
+#include <QtDeclarative/QDeclarativeExtensionPlugin>
+
+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 (file)
index 0000000..401d3e7
--- /dev/null
@@ -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 (file)
index 0000000..c20fc84
--- /dev/null
@@ -0,0 +1 @@
+plugin Bluetooth-qt
diff --git a/makedist b/makedist
new file mode 100755 (executable)
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 (file)
index 0000000..46fac32
--- /dev/null
@@ -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 (file)
index 0000000..3a4bc07
--- /dev/null
@@ -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*>((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 "<<timeout<<": "<<success;
++              QDBusReply<void> reply = adapter->SetProperty("DiscoverableTimeout", QDBusVariant((uint)timeout));
++              if(!reply.isValid())
++              {
++                      qDebug()<<"error setting discoverable timeout: "<<reply.error().message();
++              }
++              else
++              {
++                      qDebug()<<"Setting discoverable timeout to "<<timeout;
++              }
+       }
+ }
+diff --git a/bluetooth-qt/nearbydevicesmodel.cpp b/bluetooth-qt/nearbydevicesmodel.cpp
+index 455c78c..1e6d4fc 100644
+--- a/bluetooth-qt/nearbydevicesmodel.cpp
++++ b/bluetooth-qt/nearbydevicesmodel.cpp
+@@ -121,9 +121,13 @@ void NearbyDevicesModel::deviceCreated(QString hwaddy, QVariantMap properties)
+       {
+               if(path->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;
+               }
+       }