registerProfile after registering the dbus object
authorKevron Rees <kevron.m.rees@intel.com>
Sat, 17 May 2014 01:18:09 +0000 (18:18 -0700)
committerKevron Rees <kevron.m.rees@intel.com>
Sat, 17 May 2014 01:18:09 +0000 (18:18 -0700)
plugins/bluetooth/bluetoothplugin.cpp
plugins/common/bluetooth.hpp

index b1a647d..0791316 100644 (file)
@@ -39,6 +39,19 @@ BluetoothSinkPlugin::BluetoothSinkPlugin(AbstractRoutingEngine* re, map<string,
        new BtProfileAdaptor(this);
 
        QDBusConnection::systemBus().registerObject("/org/bluez/spp", this);
+
+       QDBusInterface profileManagerIface("org.bluez", "/org/bluez", "org.bluez.ProfileManager1", QDBusConnection::systemBus());
+
+       QVariantMap options;
+       options["Name"] = "spp";
+       options["Role"] = "server";
+
+       QDBusReply<void> reply = profileManagerIface.call("RegisterProfile", qVariantFromValue(QDBusObjectPath("/org/bluez/spp")), "00001101-0000-1000-8000-00805F9B34FB", options);
+
+       if(!reply.isValid())
+       {
+               DebugOut(DebugOut::Error)<<"RegisterProfile call failed: "<<reply.error().message().toStdString()<<endl;
+       }
 }
 
 
@@ -89,18 +102,7 @@ void BluetoothSinkPlugin::canHasData()
 BtProfileAdaptor::BtProfileAdaptor(BluetoothSinkPlugin *parent)
        :QDBusAbstractAdaptor(parent), mParent(parent)
 {
-       QDBusInterface profileManagerIface("org.bluez", "/org/bluez", "org.bluez.ProfileManager1", QDBusConnection::systemBus());
-
-       QVariantMap options;
-       options["Name"] = "spp";
-       options["Role"] = "server";
 
-       QDBusReply<void> reply = profileManagerIface.call("RegisterProfile", qVariantFromValue(QDBusObjectPath("/org/bluez/spp")), "00001101-0000-1000-8000-00805F9B34FB", options);
-
-       if(!reply.isValid())
-       {
-               DebugOut(DebugOut::Error)<<"RegisterProfile call failed: "<<reply.error().message().toStdString()<<endl;
-       }
 }
 
 void BtProfileAdaptor::Release()
index 23b876d..a5799b5 100644 (file)
@@ -22,7 +22,7 @@ public:
 
                if(!manager)
                {
-                       DebugOut(0)<<"Error getting bluetooth manager proxy: "<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error getting bluetooth manager proxy: "<<error->message<<endl;
                        g_error_free(error);
                        return "";
                }
@@ -35,7 +35,7 @@ public:
                {
                        if(!org_bluez_manager_call_find_adapter_sync(manager,adapterAddy.c_str(), &adapterPath, NULL, &error))
                        {
-                               DebugOut(0)<<"Error getting bluetooth adapter ("<<adapterAddy<<"): "<<error->message<<endl;
+                               DebugOut(DebugOut::Warning)<<"Error getting bluetooth adapter ("<<adapterAddy<<"): "<<error->message<<endl;
                                g_error_free(error);
                                return "";
                        }
@@ -47,7 +47,7 @@ public:
                {
                        if(!org_bluez_manager_call_default_adapter_sync(manager,&adapterPath, NULL, &error))
                        {
-                               DebugOut(0)<<"Error getting bluetooth default adapter: "<<error->message<<endl;
+                               DebugOut(DebugOut::Warning)<<"Error getting bluetooth default adapter: "<<error->message<<endl;
                                g_error_free(error);
                                return "";
                        }
@@ -60,7 +60,7 @@ public:
                                                                                                                                                                 "org.bluez",adapterPath,NULL,&error);
                if(!adapter)
                {
-                       DebugOut(0)<<"Error getting bluetooth adapter proxy: "<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error getting bluetooth adapter proxy: "<<error->message<<endl;
                        g_error_free(error);
                        return "";
                }
@@ -71,7 +71,7 @@ public:
                if(!org_bluez_adapter_call_find_device_sync(adapter,address.c_str(),&devicePath,NULL,&error) ||
                                std::string(devicePath) == "")
                {
-                       DebugOut(0)<<"Error finding bluetooth device: "<<address<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error finding bluetooth device: "<<address<<error->message<<endl;
                        g_error_free(error);
                        return "";
                }
@@ -84,7 +84,7 @@ public:
 
                if(!serialDevice)
                {
-                       DebugOut(0)<<"Error getting bluetooth serial device proxy: "<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error getting bluetooth serial device proxy: "<<error->message<<endl;
                        g_error_free(error);
                        return "";
                }
@@ -92,7 +92,7 @@ public:
                gchar* serialDeviceName;
                if(!org_bluez_serial_call_connect_sync(serialDevice,"spp",&serialDeviceName,NULL,&error))
                {
-                       DebugOut(0)<<"Error connecting bluetooth serial device: "<<address<<" - "<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error connecting bluetooth serial device: "<<address<<" - "<<error->message<<endl;
                        g_error_free(error);
                        return "";
                }
@@ -109,7 +109,7 @@ public:
 
                if(!manager)
                {
-                       DebugOut(0)<<"Error getting bluetooth manager proxy: "<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error getting bluetooth manager proxy: "<<error->message<<endl;
                        g_error_free(error);
                        return ;
                }
@@ -122,7 +122,7 @@ public:
                {
                        if(!org_bluez_manager_call_find_adapter_sync(manager,adapterAddy.c_str(), &adapterPath, NULL, &error))
                        {
-                               DebugOut(0)<<"Error getting bluetooth adapter ("<<adapterAddy<<"): "<<error->message<<endl;
+                               DebugOut(DebugOut::Warning)<<"Error getting bluetooth adapter ("<<adapterAddy<<"): "<<error->message<<endl;
                                g_error_free(error);
                                return ;
                        }
@@ -134,7 +134,7 @@ public:
                {
                        if(!org_bluez_manager_call_default_adapter_sync(manager,&adapterPath, NULL, &error))
                        {
-                               DebugOut(0)<<"Error getting bluetooth default adapter: "<<error->message<<endl;
+                               DebugOut(DebugOut::Warning)<<"Error getting bluetooth default adapter: "<<error->message<<endl;
                                g_error_free(error);
                                return ;
                        }
@@ -147,7 +147,7 @@ public:
                                                                                                                                                                 "org.bluez",adapterPath,NULL,&error);
                if(!adapter)
                {
-                       DebugOut(0)<<"Error getting bluetooth adapter proxy: "<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error getting bluetooth adapter proxy: "<<error->message<<endl;
                        g_error_free(error);
                        return ;
                }
@@ -158,7 +158,7 @@ public:
                if(!org_bluez_adapter_call_find_device_sync(adapter,address.c_str(),&devicePath,NULL,&error) ||
                                std::string(devicePath) == "")
                {
-                       DebugOut(0)<<"Error finding bluetooth device: "<<address<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error finding bluetooth device: "<<address<<error->message<<endl;
                        g_error_free(error);
                        return ;
                }
@@ -171,7 +171,7 @@ public:
 
                if(!serialDevice)
                {
-                       DebugOut(0)<<"Error getting bluetooth serial device proxy: "<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error getting bluetooth serial device proxy: "<<error->message<<endl;
                        g_error_free(error);
                        return ;
                }
@@ -179,7 +179,7 @@ public:
                gchar* serialDeviceName;
                if(!org_bluez_serial_call_disconnect_sync(serialDevice,"spp",NULL,&error))
                {
-                       DebugOut(0)<<"Error disconnecting bluetooth serial device: "<<address<<" - "<<error->message<<endl;
+                       DebugOut(DebugOut::Warning)<<"Error disconnecting bluetooth serial device: "<<address<<" - "<<error->message<<endl;
                        g_error_free(error);
                        return ;
                }