--- /dev/null
+<!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>
--- /dev/null
+<!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>
--- /dev/null
+/* -*- 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)
+{
+ if(!agent)
+ {
+ return;
+ }
+
+ OrgBluezDeviceInterface device("org.bluez", deviceObject.path(), QDBusConnection::systemBus());
+
+ agent->displayPasskey(device, passkey);
+}
+
+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);
+}
--- /dev/null
+/* -*- 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 "bluetoothagent.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);
+ 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
--- /dev/null
+#include "asyncagent.h"
+
+AsyncAgent::AsyncAgent(QString path, QObject *parent) :
+ BluetoothBaseAgent(path,parent), m_connection(QDBusConnection::systemBus())
+{
+
+}
+
+void AsyncAgent::requestConfirmation(OrgBluezDeviceInterface &device, uint key)
+{
+ setDelayedReply(true);
+ pendingMessage = message();
+ m_connection = connection();
+
+ QVariantMap props = device.GetProperties();
+
+ QString alias = props["Alias"].toString();
+
+ 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();
+
+ QMetaObject::invokeMethod(parent(), "requestPasskey", Qt::QueuedConnection, Q_ARG(QString, alias));
+
+ return 0;
+}
+
+QString AsyncAgent::requestPidCode(OrgBluezDeviceInterface &device)
+{
+ setDelayedReply(true);
+ pendingMessage = message();
+ m_connection = connection();
+
+ QVariantMap props = device.GetProperties();
+
+ QString alias = props["Alias"].toString();
+
+ QMetaObject::invokeMethod(parent(), "requestPidCode", Qt::QueuedConnection, Q_ARG(QString, alias));
+
+ return "";
+}
+
+
+void AsyncAgent::replyRequestConfirmation(bool confirmed)
+{
+ if(!confirmed)
+ {
+ reject();
+ }
+ else
+ {
+ 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);
+}
--- /dev/null
+#ifndef ASYNCAGENT_H
+#define ASYNCAGENT_H
+
+#include "bluetoothbaseagent.h"
+
+class AsyncAgent : public BluetoothBaseAgent
+{
+ Q_OBJECT
+public:
+ explicit AsyncAgent(QString path, QObject *parent = 0);
+
+ void requestConfirmation(OrgBluezDeviceInterface &device, uint key);
+ uint requestPasskey(OrgBluezDeviceInterface &device);
+ QString requestPidCode(OrgBluezDeviceInterface &device);
+
+signals:
+
+public slots:
+ void replyRequestConfirmation(bool confirmed);
+ void replyPasskey(uint passkey);
+ void replyRequestPidCode(QString pidCode);
+
+private:
+ QDBusMessage pendingMessage;
+ QDBusConnection m_connection;
+
+};
+
+#endif // ASYNCAGENT_H
--- /dev/null
+<!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>
--- /dev/null
+<!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>
--- /dev/null
+!exists(bluemanager.h):system(qdbusxml2cpp -p bluemanager.h:bluemanager.cpp manager.xml)
+!exists(blueadapter.h):system(qdbusxml2cpp -p blueadapter.h:blueadapter.cpp adapter.xml)
+!exists(bluedevice.h):system(qdbusxml2cpp -p bluedevice.h:bluedevice.cpp -i devicetypes.h device.xml)
+!exists(audiosink.h):system(qdbusxml2cpp -p audiosink.h:audiosink.cpp audiosink.xml)
+!exists(audiosource.h):system(qdbusxml2cpp -p audiosource.h:audiosource.cpp audiosrc.xml)
+!exists(headset.h):system(qdbusxml2cpp -p headset.h:headset.cpp headset.xml)
+include(obex/obex.pri)
+
--- /dev/null
+<!DOCTYPE QtCreatorProject>
+<qtcreator>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value key="EditorConfiguration.Codec" type="QByteArray">System</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Desktop</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.DesktopTarget</value>
+ <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
+ <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Qt in PATH Debug</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/tripzero/src/bluetooth-qt-build-desktop</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+ </valuemap>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Qt in PATH Release</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/tripzero/src/bluetooth-qt-build-desktop</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+ </valuemap>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.2" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">4.6.0 Debug</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/tripzero/src/bluetooth-qt-build-desktop</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">3</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+ </valuemap>
+ <valuemap key="ProjectExplorer.Target.BuildConfiguration.3" type="QVariantMap">
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">qmake</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+ <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+ </valuemap>
+ <valuemap key="ProjectExplorer.BuildConfiguration.BuildStep.1" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.BuildStepsCount" type="int">2</value>
+ <valuemap key="ProjectExplorer.BuildConfiguration.CleanStep.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">Make</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+ <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+ <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+ <value type="QString">clean</value>
+ </valuelist>
+ <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.BuildConfiguration.CleanStepsCount" type="int">1</value>
+ <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+ <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">4.6.0 Release</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/tripzero/src/bluetooth-qt-build-desktop</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">3</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">0</value>
+ <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">4</value>
+ <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
+ <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString">bluetooth-qt</value>
+ <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4RunConfiguration</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.BaseEnvironmentBase" type="int">2</value>
+ <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments" type="QVariantList"/>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.ProFile" type="QString">bluetooth-qt.pro</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal" type="bool">false</value>
+ <valuelist key="Qt4ProjectManager.Qt4RunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetName" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserSetWorkingDirectory" type="bool">false</value>
+ <value key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory" type="QString"></value>
+ </valuemap>
+ <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.TargetCount</variable>
+ <value type="int">1</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+ <value type="int">4</value>
+ </data>
+</qtcreator>
--- /dev/null
+#include "bluetoothbaseagent.h"
+
+#include "agentadaptor.h"
+#include "bluemanager.h"
+#include "blueadapter.h"
+#include <QTimer>
+
+BluetoothBaseAgent::BluetoothBaseAgent(QString path, QObject *parent):QObject(parent),requestAccepted(false)
+{
+ new AgentAdaptor(this);
+ QDBusConnection::systemBus().registerObject(path,this);
+
+ OrgBluezManagerInterface manager(
+ "org.bluez",
+ "/", QDBusConnection::systemBus());
+
+ QDBusObjectPath adapterpath = manager.DefaultAdapter();
+
+ OrgBluezAdapterInterface adapter(
+ "org.bluez",
+ adapterpath.path(),
+ QDBusConnection::systemBus());
+
+ adapter.RegisterAgent(QDBusObjectPath("/pairing/agent"),"");
+
+ 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)
+{
+ qDebug()<<"display key "<<device.path()<<" "<<key;
+}
+
+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 "";
+}
+
+void BluetoothBaseAgent::accept()
+{
+ requestAccepted = true;
+}
+
+void BluetoothBaseAgent::doReject()
+{
+ if(requestAccepted)
+ {
+ requestAccepted=false;
+ return;
+ }
+ reject();
+}
--- /dev/null
+#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="/pairing/agent", QObject *parent=0);
+public slots:
+ virtual void authorize(OrgBluezDeviceInterface &device, QString);
+ virtual void cancel()
+ {
+ sendErrorReply("org.bluez.Error.Canceled","The request was canceled");
+ }
+ virtual void confirmModeChange(QString);
+ virtual void displayPasskey(OrgBluezDeviceInterface &device, uint key);
+ virtual void release();
+ virtual void requestConfirmation(OrgBluezDeviceInterface &device, uint key);
+ virtual uint requestPasskey(OrgBluezDeviceInterface &device);
+ virtual QString requestPidCode(OrgBluezDeviceInterface &device);
+
+ virtual void reject() { sendErrorReply("org.bluez.Error.Rejected", "The request was rejected"); }
+
+ virtual void accept();
+ virtual void doReject();
+private:
+ bool requestAccepted;
+};
+
+#endif // BLUETOOTHBASEAGENT_H
--- /dev/null
+/* -*- 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
+
+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 spp[] = "00001101-0000-1000-8000-00805f9b34fb";
+
+}
+#endif // BTPROFILES_H
--- /dev/null
+<!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>
--- /dev/null
+<!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>
--- /dev/null
+<!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>
--- /dev/null
+#include "nearbydevicesmodel.h"
+#include "bluetoothagent.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());
+}
+
+
+int NearbyDevicesModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent);
+ return devicepathlist.size();
+}
+
+QVariant NearbyDevicesModel::data(const QModelIndex &index, int role) const
+{
+ if (role == Qt::DisplayRole)
+ {
+ QString rowData;
+ if(index.row() < devicepathlist.size())
+ {
+ rowData = deviceAliasMap[devicepathlist[index.row()]];
+ }
+ return QVariant(rowData);
+ }
+
+ return QVariant();
+}
+
+void NearbyDevicesModel::pair(QString hwaddy)
+{
+ qDebug("attempting to pair...");
+ OrgBluezManagerInterface manager(
+ "org.bluez",
+ "/", QDBusConnection::systemBus());
+
+ QDBusObjectPath adapterpath = manager.DefaultAdapter();
+
+ OrgBluezAdapterInterface adapter(
+ "org.bluez",
+ adapterpath.path(),
+ QDBusConnection::systemBus());
+
+ agent = new AsyncAgent("/temp/agent",this);
+
+ //QDBusPendingCall response =
+ adapter.CreatePairedDevice(hwaddy,
+ QDBusObjectPath("/temp/agent"),"");
+
+ //qDebug()<<"new object created: "<<object.path();
+}
+
+void NearbyDevicesModel::discover()
+{
+ adapter->StartDiscovery();
+}
+
+void NearbyDevicesModel::removeAll(bool)
+{
+ for(int i=0;i<devicepathlist.size();i++)
+ {
+ devicepathlist.removeAt(i);
+ }
+}
+
+void NearbyDevicesModel::replyRequestConfirmation(bool 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::deviceCreated(QString hwaddy, QVariantMap properties)
+{
+ bool found = false;
+ foreach(QString path, devicepathlist)
+ {
+ if(path == hwaddy)
+ {
+ found=true;
+ break;
+ }
+ }
+
+ if(!found)
+ {
+ beginInsertRows(QModelIndex(), 0, devicepathlist.size());
+ devicepathlist.append(hwaddy);
+ deviceAliasMap[hwaddy] = properties["Alias"].toString();
+ emit nearbyDeviceFound(devicepathlist.indexOf(hwaddy));
+ endInsertRows();
+ }
+}
+
+void NearbyDevicesModel::deviceRemoved(QString hwaddy)
+{
+ int i=-1;
+ if((i = devicepathlist.indexOf(hwaddy)) >=0)
+ {
+ beginRemoveRows(QModelIndex(),i,i+1);
+ devicepathlist.removeAt(i);
+ emit nearbyDeviceRemoved(i);
+ endInsertRows();
+ }
+
+}
+
+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)));
+}
+
+void NearbyDevicesModel::adapterRemoved(QDBusObjectPath)
+{
+ QDBusObjectPath adapterpath = manager->DefaultAdapter();
+
+ if(adapterpath.path() == "")
+ {
+ removeAll(true);
+ if(adapter) delete adapter;
+ return;
+ }
+}
--- /dev/null
+#ifndef NEARBYDEVICESMODEL_H
+#define NEARBYDEVICESMODEL_H
+
+#include <QObject>
+#include <QAbstractListModel>
+#include <QDBusObjectPath>
+
+#include "bluemanager.h"
+#include "blueadapter.h"
+#include "asyncagent.h"
+
+class NearbyDevicesModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ NearbyDevicesModel(QObject *parent = 0);
+
+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 devicepathlist[index]; }
+ QString alias(int index){ return deviceAliasMap[devicepathlist[index]]; }
+ void pair(QString hwaddy);
+ void discover();
+ void removeAll(bool);
+
+ void replyRequestConfirmation(bool confirmed);
+ void replyPasskey(uint passkey);
+ void replyRequestPidCode(QString pidCode);
+
+private slots:
+ void adapterAdded(QDBusObjectPath);
+ void adapterRemoved(QDBusObjectPath);
+ void deviceCreated(QString hwaddy, QVariantMap properties);
+ void deviceRemoved(QString hwaddy);
+
+signals:
+ void requestConfirmation(QString device, uint code);
+ void requestPasskey(QString device);
+ void requestPidCode(QString device);
+
+ void nearbyDeviceFound(int index);
+ void nearbyDeviceRemoved(int index);
+
+private:
+ QList<QString> devicepathlist;
+ QMap<QString,QString> deviceAliasMap;
+ OrgBluezManagerInterface *manager;
+ OrgBluezAdapterInterface *adapter;
+ AsyncAgent* agent;
+};
+
+#endif // NEARBYDEVICESMODEL_H
--- /dev/null
+<!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>
+
--- /dev/null
+<!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>
+
--- /dev/null
+!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
--- /dev/null
+#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
+}
--- /dev/null
+#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
--- /dev/null
+<!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>
+
--- /dev/null
+<!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>
+
--- /dev/null
+#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