Bug 995912: Remove BLUEZ_DBUS_BASE_IFC from RawDBusConnection, r=qdot, echou
authorThomas Zimmermann <tdz@users.sourceforge.net>
Thu, 17 Apr 2014 11:16:12 +0200
changeset 179524 7113f6dd5cdc328cdb5b017d0edd4732db5d58cd
parent 179523 b0da440e329fa7deb6cefcec9084af37359ced9d
child 179525 bc0034c4496c3ef61e94486120717e5820a11c96
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersqdot, echou
bugs995912
milestone31.0a1
Bug 995912: Remove BLUEZ_DBUS_BASE_IFC from RawDBusConnection, r=qdot, echou This patch removes the constant BLUEZ_DBUS_BASE_IFC from the file RawDBusconnection.cpp. The constant is specific to BlueZ, and that's where it's located now.
dom/bluetooth/bluez/BluetoothDBusService.cpp
ipc/dbus/RawDBusConnection.cpp
ipc/dbus/RawDBusConnection.h
--- a/dom/bluetooth/bluez/BluetoothDBusService.cpp
+++ b/dom/bluetooth/bluez/BluetoothDBusService.cpp
@@ -1149,18 +1149,18 @@ AppendDeviceName(BluetoothSignal& aSigna
   nsString devicePath = arr[0].value().get_nsString();
 
   nsRefPtr<AppendDeviceNameReplyHandler> handler =
     new AppendDeviceNameReplyHandler(nsCString(DBUS_DEVICE_IFACE),
                                      devicePath, aSignal);
 
   bool success = sDBusConnection->SendWithReply(
     AppendDeviceNameReplyHandler::Callback, handler.get(), 1000,
-    NS_ConvertUTF16toUTF8(devicePath).get(), DBUS_DEVICE_IFACE,
-    "GetProperties", DBUS_TYPE_INVALID);
+    BLUEZ_DBUS_BASE_IFC, NS_ConvertUTF16toUTF8(devicePath).get(),
+    DBUS_DEVICE_IFACE, "GetProperties", DBUS_TYPE_INVALID);
 
   NS_ENSURE_TRUE_VOID(success);
 
   unused << handler.forget(); // picked up by callback handler
 }
 
 static DBusHandlerResult
 AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data)
@@ -1483,16 +1483,17 @@ private:
     }
 
     nsRefPtr<RegisterAgentReplyHandler> handler =
       new RegisterAgentReplyHandler(aAgentVTable);
     MOZ_ASSERT(!sAdapterPath.IsEmpty());
 
     bool success = sDBusConnection->SendWithReply(
       RegisterAgentReplyHandler::Callback, handler.get(), -1,
+      BLUEZ_DBUS_BASE_IFC,
       NS_ConvertUTF16toUTF8(sAdapterPath).get(),
       DBUS_ADAPTER_IFACE, "RegisterAgent",
       DBUS_TYPE_OBJECT_PATH, &agentPath,
       DBUS_TYPE_STRING, &capabilities,
       DBUS_TYPE_INVALID);
 
     NS_ENSURE_TRUE(success, false);
 
@@ -1522,16 +1523,17 @@ public:
 
     nsRefPtr<DBusReplyHandler> handler =
       new AddReservedServiceRecordsReplyHandler();
 
     const dbus_uint32_t* services = sServices;
 
     bool success = sDBusConnection->SendWithReply(
       DBusReplyHandler::Callback, handler.get(), -1,
+      BLUEZ_DBUS_BASE_IFC,
       NS_ConvertUTF16toUTF8(sAdapterPath).get(),
       DBUS_ADAPTER_IFACE, "AddReservedServiceRecords",
       DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32,
       &services, ArrayLength(sServices), DBUS_TYPE_INVALID);
 
     NS_ENSURE_TRUE_VOID(success);
 
     unused << handler.forget(); /* picked up by callback handler */
@@ -1934,17 +1936,17 @@ public:
     /* Normally we'll receive the signal 'AdapterAdded' with the adapter object
      * path from the DBus daemon during start up. So, there's no need to query
      * the object path of default adapter here. However, if we restart from a
      * crash, the default adapter might already be available, so we ask the daemon
      * explicitly here.
      */
     if (sAdapterPath.IsEmpty()) {
       bool success = sDBusConnection->SendWithReply(OnDefaultAdapterReply, nullptr,
-                                                    1000, "/",
+                                                    1000, BLUEZ_DBUS_BASE_IFC, "/",
                                                     DBUS_MANAGER_IFACE,
                                                     "DefaultAdapter",
                                                     DBUS_TYPE_INVALID);
       if (!success) {
         BT_WARNING("Failed to query default adapter!");
       }
     }
   }
@@ -2206,16 +2208,17 @@ protected:
 
     mAdapterPath = value.get_nsString();
 
     // Acquire another reference to this reply handler
     nsRefPtr<DefaultAdapterPathReplyHandler> handler = this;
 
     bool success = sDBusConnection->SendWithReply(
       DefaultAdapterPathReplyHandler::Callback, handler.get(), 1000,
+      BLUEZ_DBUS_BASE_IFC,
       NS_ConvertUTF16toUTF8(mAdapterPath).get(),
       DBUS_ADAPTER_IFACE, "GetProperties", DBUS_TYPE_INVALID);
 
     if (!success) {
       aReplyError = NS_LITERAL_STRING("SendWithReply failed");
       return false;
     }
 
@@ -2269,17 +2272,17 @@ public:
     MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
     MOZ_ASSERT(sDBusConnection);
 
     nsRefPtr<DefaultAdapterPathReplyHandler> handler =
       new DefaultAdapterPathReplyHandler(mRunnable);
 
     bool success = sDBusConnection->SendWithReply(
       DefaultAdapterPathReplyHandler::Callback,
-      handler.get(), 1000,
+      handler.get(), 1000, BLUEZ_DBUS_BASE_IFC,
       "/", DBUS_MANAGER_IFACE, "DefaultAdapter",
       DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
 
     unused << handler.forget(); // picked up by callback handler
   }
 
 private:
@@ -2337,16 +2340,17 @@ public:
   {
     MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
     MOZ_ASSERT(sDBusConnection);
     MOZ_ASSERT(!sAdapterPath.IsEmpty());
 
     bool success = sDBusConnection->SendWithReply(
       OnSendDiscoveryMessageReply,
       static_cast<void*>(mRunnable.get()), -1,
+      BLUEZ_DBUS_BASE_IFC,
       NS_ConvertUTF16toUTF8(sAdapterPath).get(),
       DBUS_ADAPTER_IFACE, mMessageName.get(),
       DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
 
     unused << mRunnable.forget(); // picked up by callback handler
   }
 
@@ -2415,18 +2419,18 @@ public:
 
   void Run() MOZ_OVERRIDE
   {
     MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
     MOZ_ASSERT(sDBusConnection);
 
     bool success = sDBusConnection->SendWithReply(
       mCallback, static_cast<void*>(mServiceClass), -1,
-      mObjectPath.get(), mInterface.get(), mMessage.get(),
-      DBUS_TYPE_INVALID);
+      BLUEZ_DBUS_BASE_IFC, mObjectPath.get(), mInterface.get(),
+      mMessage.get(), DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
 
     mServiceClass.forget();
   }
 
 private:
   DBusReplyCallback mCallback;
   nsAutoPtr<BluetoothServiceClass> mServiceClass;
@@ -2602,17 +2606,17 @@ protected:
     // cache object path for reply
     mObjectPath = GetObjectPathFromAddress(sAdapterPath,
       mDeviceAddresses[mProcessedDeviceAddresses]);
 
     nsRefPtr<BluetoothArrayOfDevicePropertiesReplyHandler> handler = this;
 
     bool success = sDBusConnection->SendWithReply(
       BluetoothArrayOfDevicePropertiesReplyHandler::Callback,
-      handler.get(), 1000,
+      handler.get(), 1000, BLUEZ_DBUS_BASE_IFC,
       NS_ConvertUTF16toUTF8(mObjectPath).get(),
       DBUS_DEVICE_IFACE, "GetProperties",
       DBUS_TYPE_INVALID);
 
     NS_ENSURE_TRUE(success, false);
 
     unused << handler.forget(); // picked up by callback handler
 
@@ -2730,17 +2734,17 @@ public:
 
   void Send(unsigned int aType, const void* aValue)
   {
     MOZ_ASSERT(!NS_IsMainThread()); // I/O thread
     MOZ_ASSERT(sDBusConnection);
     MOZ_ASSERT(!sAdapterPath.IsEmpty());
 
     DBusMessage* msg =
-      dbus_message_new_method_call("org.bluez",
+      dbus_message_new_method_call(BLUEZ_DBUS_BASE_IFC,
                                    NS_ConvertUTF16toUTF8(sAdapterPath).get(),
                                    sBluetoothDBusIfaces[mType],
                                    "SetProperty");
     if (!msg) {
       BT_WARNING("Could not allocate D-Bus message object!");
       return;
     }
 
@@ -2900,16 +2904,17 @@ public:
     const char *deviceAddress = mDeviceAddress.get();
     const char *deviceAgentPath = KEY_REMOTE_AGENT;
     const char *capabilities = B2G_AGENT_CAPABILITIES;
 
     // Then send CreatePairedDevice, it will register a temp device agent then
     // unregister it after pairing process is over
     bool success = sDBusConnection->SendWithReply(
       GetObjectPathCallback, static_cast<void*>(mRunnable), mTimeout,
+      BLUEZ_DBUS_BASE_IFC,
       NS_ConvertUTF16toUTF8(sAdapterPath).get(),
       DBUS_ADAPTER_IFACE,
       "CreatePairedDevice",
       DBUS_TYPE_STRING, &deviceAddress,
       DBUS_TYPE_OBJECT_PATH, &deviceAgentPath,
       DBUS_TYPE_STRING, &capabilities,
       DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
@@ -2971,16 +2976,17 @@ public:
 
     nsCString deviceObjectPath =
       NS_ConvertUTF16toUTF8(GetObjectPathFromAddress(sAdapterPath,
                                                      mDeviceAddress));
     const char* cstrDeviceObjectPath = deviceObjectPath.get();
 
     bool success = sDBusConnection->SendWithReply(
       OnRemoveDeviceReply, static_cast<void*>(mRunnable.get()), -1,
+      BLUEZ_DBUS_BASE_IFC,
       NS_ConvertUTF16toUTF8(sAdapterPath).get(),
       DBUS_ADAPTER_IFACE, "RemoveDevice",
       DBUS_TYPE_OBJECT_PATH, &cstrDeviceObjectPath,
       DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
 
     unused << mRunnable.forget(); // picked up by callback handler
   }
@@ -3493,16 +3499,17 @@ public:
       new OnGetServiceChannelReplyHandler(mDeviceAddress, mServiceUUID,
                                           mBluetoothProfileManager);
 
     nsCString serviceUUID = NS_ConvertUTF16toUTF8(mServiceUUID);
     const char* cstrServiceUUID = serviceUUID.get();
 
     bool success = sDBusConnection->SendWithReply(
       OnGetServiceChannelReplyHandler::Callback, handler, -1,
+      BLUEZ_DBUS_BASE_IFC,
       NS_ConvertUTF16toUTF8(objectPath).get(),
       DBUS_DEVICE_IFACE, "GetServiceAttributeValue",
       DBUS_TYPE_STRING, &cstrServiceUUID,
       DBUS_TYPE_UINT16, &sProtocolDescriptorList,
       DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
 
     unused << handler.forget(); // picked up by callback handler
@@ -3573,16 +3580,17 @@ public:
 
     // I choose to use raw pointer here because this is going to be passed as an
     // argument into SendWithReply() at once.
     OnUpdateSdpRecordsRunnable* callbackRunnable =
       new OnUpdateSdpRecordsRunnable(objectPath, mBluetoothProfileManager);
 
     sDBusConnection->SendWithReply(DiscoverServicesCallback,
                                    (void*)callbackRunnable, -1,
+                                   BLUEZ_DBUS_BASE_IFC,
                                    NS_ConvertUTF16toUTF8(objectPath).get(),
                                    DBUS_DEVICE_IFACE,
                                    "DiscoverServices",
                                    DBUS_TYPE_STRING, &EmptyCString(),
                                    DBUS_TYPE_INVALID);
   }
 
 protected:
@@ -3791,16 +3799,17 @@ public:
     const char* artist = mArtist.get();
     const char* mediaNumber = tempMediaNumber.get();
     const char* totalMediaCount = tempTotalMediaCount.get();
     const char* duration = tempDuration.get();
     const char* genre = tempGenre.get();
 
     bool success = sDBusConnection->SendWithReply(
       GetVoidCallback, static_cast<void*>(mRunnable.get()), -1,
+      BLUEZ_DBUS_BASE_IFC,
       objectPath.get(),
       DBUS_CTL_IFACE, "UpdateMetaData",
       DBUS_TYPE_STRING, &title,
       DBUS_TYPE_STRING, &artist,
       DBUS_TYPE_STRING, &album,
       DBUS_TYPE_STRING, &mediaNumber,
       DBUS_TYPE_STRING, &totalMediaCount,
       DBUS_TYPE_STRING, &duration,
@@ -3927,16 +3936,17 @@ public:
 
     const nsCString objectPath = NS_ConvertUTF16toUTF8(
       GetObjectPathFromAddress(sAdapterPath, mDeviceAddress));
 
     uint32_t tempPlayStatus = mPlayStatus;
 
     bool success = sDBusConnection->SendWithReply(
       GetVoidCallback, static_cast<void*>(mRunnable.get()), -1,
+      BLUEZ_DBUS_BASE_IFC,
       objectPath.get(),
       DBUS_CTL_IFACE, "UpdatePlayStatus",
       DBUS_TYPE_UINT32, &mDuration,
       DBUS_TYPE_UINT32, &mPosition,
       DBUS_TYPE_UINT32, &tempPlayStatus,
       DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
 
@@ -4050,16 +4060,17 @@ public:
 
     const nsCString objectPath = NS_ConvertUTF16toUTF8(
       GetObjectPathFromAddress(sAdapterPath, mDeviceAddress));
 
     uint32_t tempPlayStatus = mPlayStatus;
 
     bool success = sDBusConnection->SendWithReply(
       ControlCallback, nullptr, -1,
+      BLUEZ_DBUS_BASE_IFC,
       objectPath.get(),
       DBUS_CTL_IFACE, "UpdatePlayStatus",
       DBUS_TYPE_UINT32, &mDuration,
       DBUS_TYPE_UINT32, &mPosition,
       DBUS_TYPE_UINT32, &tempPlayStatus,
       DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
   }
@@ -4116,16 +4127,17 @@ public:
 
     const nsCString objectPath = NS_ConvertUTF16toUTF8(
       GetObjectPathFromAddress(sAdapterPath, mDeviceAddress));
 
     uint16_t eventId = mEventId;
 
     bool success = sDBusConnection->SendWithReply(
       ControlCallback, nullptr, -1,
+      BLUEZ_DBUS_BASE_IFC,
       objectPath.get(),
       DBUS_CTL_IFACE, "UpdateNotification",
       DBUS_TYPE_UINT16, &eventId,
       DBUS_TYPE_UINT64, &mData,
       DBUS_TYPE_INVALID);
     NS_ENSURE_TRUE_VOID(success);
   }
 
--- a/ipc/dbus/RawDBusConnection.cpp
+++ b/ipc/dbus/RawDBusConnection.cpp
@@ -15,19 +15,16 @@
 
 #if defined(MOZ_WIDGET_GONK)
 #include <android/log.h>
 #define CHROMIUM_LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "Gonk", args);
 #else
 #define CHROMIUM_LOG(args...)  printf(args);
 #endif
 
-/* TODO: Remove BlueZ constant */
-#define BLUEZ_DBUS_BASE_IFC "org.bluez"
-
 namespace mozilla {
 namespace ipc {
 
 //
 // DBusWatcher
 //
 
 class DBusWatcher : public MessageLoopForIO::Watcher
@@ -329,45 +326,48 @@ bool RawDBusConnection::SendWithReply(DB
   dbus_message_unref(aMessage);
 
   return true;
 }
 
 bool RawDBusConnection::SendWithReply(DBusReplyCallback aCallback,
                                       void* aData,
                                       int aTimeout,
+                                      const char* aDestination,
                                       const char* aPath,
                                       const char* aIntf,
                                       const char* aFunc,
                                       int aFirstArgType,
                                       ...)
 {
   MOZ_ASSERT(!NS_IsMainThread());
   va_list args;
 
   va_start(args, aFirstArgType);
-  DBusMessage* msg = BuildDBusMessage(aPath, aIntf, aFunc,
+  DBusMessage* msg = BuildDBusMessage(aDestination, aPath, aIntf, aFunc,
                                       aFirstArgType, args);
   va_end(args);
 
   if (!msg) {
     return false;
   }
 
   return SendWithReply(aCallback, aData, aTimeout, msg);
 }
 
-DBusMessage* RawDBusConnection::BuildDBusMessage(const char* aPath,
+DBusMessage* RawDBusConnection::BuildDBusMessage(const char* aDestination,
+                                                 const char* aPath,
                                                  const char* aIntf,
                                                  const char* aFunc,
                                                  int aFirstArgType,
                                                  va_list aArgs)
 {
-  DBusMessage* msg = dbus_message_new_method_call(BLUEZ_DBUS_BASE_IFC,
-                                                  aPath, aIntf, aFunc);
+  DBusMessage* msg = dbus_message_new_method_call(aDestination,
+                                                  aPath, aIntf,
+                                                  aFunc);
   if (!msg) {
     CHROMIUM_LOG("Could not allocate D-Bus message object!");
     return nullptr;
   }
 
   /* append arguments */
   if (!dbus_message_append_args_valist(msg, aFirstArgType, aArgs)) {
     CHROMIUM_LOG("Could not append argument to method call!");
--- a/ipc/dbus/RawDBusConnection.h
+++ b/ipc/dbus/RawDBusConnection.h
@@ -39,21 +39,24 @@ public:
   }
 
   bool Send(DBusMessage* aMessage);
 
   bool SendWithReply(DBusReplyCallback aCallback, void* aData,
                      int aTimeout, DBusMessage* aMessage);
 
   bool SendWithReply(DBusReplyCallback aCallback, void* aData,
-                     int aTimeout, const char* aPath, const char* aIntf,
+                     int aTimeout,
+                     const char* aDestination,
+                     const char* aPath, const char* aIntf,
                      const char *aFunc, int aFirstArgType, ...);
 
 protected:
-  DBusMessage* BuildDBusMessage(const char* aPath, const char* aIntf,
+  DBusMessage* BuildDBusMessage(const char* aDestination,
+                                const char* aPath, const char* aIntf,
                                 const char* aFunc, int aFirstArgType,
                                 va_list args);
 
   Scoped<ScopedDBusConnectionPtrTraits> mConnection;
 
 private:
   static bool sDBusIsInit;
 };