From 48165f030d5e1b7998163365587b1a7faf2bb04c Mon Sep 17 00:00:00 2001 From: Eric Chou Date: Mon, 28 Jan 2013 19:23:12 +0800 Subject: [PATCH] Bug 834551 - Replace 'LOG()' with 'BT_WARNING()' defined in BluetoothCommon.h for consistency, r=qdot --- dom/bluetooth/BluetoothCommon.h | 6 ++ .../BluetoothUnixSocketConnector.cpp | 9 --- dom/bluetooth/linux/BluetoothDBusService.cpp | 65 ++++++++----------- 3 files changed, 34 insertions(+), 46 deletions(-) diff --git a/dom/bluetooth/BluetoothCommon.h b/dom/bluetooth/BluetoothCommon.h index 4416a8b26359..045b88c6dffa 100644 --- a/dom/bluetooth/BluetoothCommon.h +++ b/dom/bluetooth/BluetoothCommon.h @@ -24,6 +24,10 @@ extern bool gBluetoothDebugFlag; __android_log_print(ANDROID_LOG_INFO, "GeckoBluetooth", args); \ } \ } while(0) + +#define BT_WARNING(args...) \ + __android_log_print(ANDROID_LOG_WARN, "GeckoBluetooth", args) + #else #define BT_LOG(args...) \ do { \ @@ -31,6 +35,8 @@ extern bool gBluetoothDebugFlag; printf(args); \ } \ } while(0) + +#define BT_WARNING(args...) printf(args); #endif #define BEGIN_BLUETOOTH_NAMESPACE \ diff --git a/dom/bluetooth/BluetoothUnixSocketConnector.cpp b/dom/bluetooth/BluetoothUnixSocketConnector.cpp index b6f136cd7338..f2eb8677928a 100644 --- a/dom/bluetooth/BluetoothUnixSocketConnector.cpp +++ b/dom/bluetooth/BluetoothUnixSocketConnector.cpp @@ -35,15 +35,6 @@ #include "BluetoothUnixSocketConnector.h" #include "nsThreadUtils.h" -#undef LOG -#if defined(MOZ_WIDGET_GONK) -#include -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GonkDBus", args); -#else -#define BTDEBUG true -#define LOG(args...) if (BTDEBUG) printf(args); -#endif - USING_BLUETOOTH_NAMESPACE static const int RFCOMM_SO_SNDBUF = 70 * 1024; // 70 KB send buffer diff --git a/dom/bluetooth/linux/BluetoothDBusService.cpp b/dom/bluetooth/linux/BluetoothDBusService.cpp index bd4e5b73011d..8071175e3e62 100644 --- a/dom/bluetooth/linux/BluetoothDBusService.cpp +++ b/dom/bluetooth/linux/BluetoothDBusService.cpp @@ -59,15 +59,6 @@ using namespace mozilla; using namespace mozilla::ipc; USING_BLUETOOTH_NAMESPACE -#undef LOG -#if defined(MOZ_WIDGET_GONK) -#include -#define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GonkDBus", args); -#else -#define BTDEBUG true -#define LOG(args...) if (BTDEBUG) printf(args); -#endif - #define B2G_AGENT_CAPABILITIES "DisplayYesNo" #define DBUS_MANAGER_IFACE BLUEZ_DBUS_BASE_IFC ".Manager" #define DBUS_ADAPTER_IFACE BLUEZ_DBUS_BASE_IFC ".Adapter" @@ -420,7 +411,7 @@ static DBusHandlerResult AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data) { if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_METHOD_CALL) { - LOG("%s: agent handler not interested (not a method call).\n", __FUNCTION__); + BT_WARNING("%s: agent handler not interested (not a method call).\n", __FUNCTION__); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -460,7 +451,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data) DBUS_TYPE_OBJECT_PATH, &objectPath, DBUS_TYPE_STRING, &uuid, DBUS_TYPE_INVALID)) { - LOG("%s: Invalid arguments for Authorize() method", __FUNCTION__); + BT_WARNING("%s: Invalid arguments for Authorize() method", __FUNCTION__); errorStr.AssignLiteral("Invalid arguments for Authorize() method"); } else { nsString deviceAddress = @@ -492,7 +483,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data) DBUS_TYPE_OBJECT_PATH, &objectPath, DBUS_TYPE_UINT32, &passkey, DBUS_TYPE_INVALID)) { - LOG("%s: Invalid arguments for RequestConfirmation() method", __FUNCTION__); + BT_WARNING("%s: Invalid arguments for RequestConfirmation() method", __FUNCTION__); errorStr.AssignLiteral("Invalid arguments for RequestConfirmation() method"); } else { parameters.AppendElement(BluetoothNamedValue( @@ -524,7 +515,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data) if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &objectPath, DBUS_TYPE_INVALID)) { - LOG("%s: Invalid arguments for RequestPinCode() method", __FUNCTION__); + BT_WARNING("%s: Invalid arguments for RequestPinCode() method", __FUNCTION__); errorStr.AssignLiteral("Invalid arguments for RequestPinCode() method"); } else { parameters.AppendElement(BluetoothNamedValue( @@ -552,7 +543,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data) if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_OBJECT_PATH, &objectPath, DBUS_TYPE_INVALID)) { - LOG("%s: Invalid arguments for RequestPasskey() method", __FUNCTION__); + BT_WARNING("%s: Invalid arguments for RequestPasskey() method", __FUNCTION__); errorStr.AssignLiteral("Invalid arguments for RequestPasskey() method"); } else { parameters.AppendElement(BluetoothNamedValue( @@ -590,7 +581,7 @@ AgentEventFilter(DBusConnection *conn, DBusMessage *msg, void *data) } } else { #ifdef DEBUG - LOG("agent handler %s: Unhandled event. Ignore.", __FUNCTION__); + BT_WARNING("agent handler %s: Unhandled event. Ignore.", __FUNCTION__); #endif return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -631,7 +622,7 @@ RegisterLocalAgent(const char* adapterPath, agentPath, &agentVtable, NULL)) { - LOG("%s: Can't register object path %s for agent!", + BT_WARNING("%s: Can't register object path %s for agent!", __FUNCTION__, agentPath); return false; } @@ -640,7 +631,7 @@ RegisterLocalAgent(const char* adapterPath, dbus_message_new_method_call("org.bluez", adapterPath, DBUS_ADAPTER_IFACE, "RegisterAgent"); if (!msg) { - LOG("%s: Can't allocate new method call for agent!", __FUNCTION__); + BT_WARNING("%s: Can't allocate new method call for agent!", __FUNCTION__); return false; } @@ -648,7 +639,7 @@ RegisterLocalAgent(const char* adapterPath, DBUS_TYPE_OBJECT_PATH, &agentPath, DBUS_TYPE_STRING, &capabilities, DBUS_TYPE_INVALID)) { - LOG("%s: Couldn't append arguments to dbus message.", __FUNCTION__); + BT_WARNING("%s: Couldn't append arguments to dbus message.", __FUNCTION__); return false; } @@ -665,11 +656,11 @@ RegisterLocalAgent(const char* adapterPath, if (!strcmp(err.name, "org.bluez.Error.AlreadyExists")) { LOG_AND_FREE_DBUS_ERROR(&err); #ifdef DEBUG - LOG("Agent already registered, still returning true"); + BT_WARNING("Agent already registered, still returning true"); #endif } else { LOG_AND_FREE_DBUS_ERROR(&err); - LOG("%s: Can't register agent!", __FUNCTION__); + BT_WARNING("%s: Can't register agent!", __FUNCTION__); return false; } } @@ -699,7 +690,7 @@ RegisterAgent(const nsAString& aAdapterPath) REMOTE_AGENT_PATH, &agentVtable, NULL)) { - LOG("%s: Can't register object path %s for remote device agent!", + BT_WARNING("%s: Can't register object path %s for remote device agent!", __FUNCTION__, REMOTE_AGENT_PATH); return false; @@ -721,7 +712,7 @@ ExtractHandles(DBusMessage *aReply, nsTArray& aOutHandles) DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &handles, &len, DBUS_TYPE_INVALID)) { if (!handles) { - LOG("Null array in extract_handles"); + BT_WARNING("Null array in extract_handles"); } else { for (int i = 0; i < len; ++i) { aOutHandles.AppendElement(handles[i]); @@ -775,7 +766,7 @@ BluetoothDBusService::AddReservedServicesInternal(const nsAString& aAdapterPath, &services, length, DBUS_TYPE_INVALID); if (!reply) { - LOG("Null DBus message. Couldn't extract handles."); + BT_WARNING("Null DBus message. Couldn't extract handles."); return false; } @@ -1307,13 +1298,13 @@ EventFilter(DBusConnection* aConn, DBusMessage* aMsg, void* aData) NS_ASSERTION(!NS_IsMainThread(), "Shouldn't be called from Main Thread!"); if (dbus_message_get_type(aMsg) != DBUS_MESSAGE_TYPE_SIGNAL) { - LOG("%s: event handler not interested in %s (not a signal).\n", + BT_WARNING("%s: event handler not interested in %s (not a signal).\n", __FUNCTION__, dbus_message_get_member(aMsg)); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } if (dbus_message_get_path(aMsg) == NULL) { - LOG("DBusMessage %s has no bluetooth destination, ignoring\n", + BT_WARNING("DBusMessage %s has no bluetooth destination, ignoring\n", dbus_message_get_member(aMsg)); return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -1635,13 +1626,13 @@ BluetoothDBusService::StopInternal() if (!dbus_connection_unregister_object_path(gThreadConnection->GetConnection(), LOCAL_AGENT_PATH)) { - LOG("%s: Can't unregister object path %s for agent!", + BT_WARNING("%s: Can't unregister object path %s for agent!", __FUNCTION__, LOCAL_AGENT_PATH); } if (!dbus_connection_unregister_object_path(gThreadConnection->GetConnection(), REMOTE_AGENT_PATH)) { - LOG("%s: Can't unregister object path %s for agent!", + BT_WARNING("%s: Can't unregister object path %s for agent!", __FUNCTION__, LOCAL_AGENT_PATH); } @@ -2229,7 +2220,7 @@ BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress, BluetoothValue v = true; DBusMessage *msg; if (!sPairingReqTable.Get(aDeviceAddress, &msg)) { - LOG("%s: Couldn't get original request message.", __FUNCTION__); + BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__); errorStr.AssignLiteral("Couldn't get original request message."); DispatchBluetoothReply(aRunnable, v, errorStr); return false; @@ -2238,7 +2229,7 @@ BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress, DBusMessage *reply = dbus_message_new_method_return(msg); if (!reply) { - LOG("%s: Memory can't be allocated for the message.", __FUNCTION__); + BT_WARNING("%s: Memory can't be allocated for the message.", __FUNCTION__); dbus_message_unref(msg); errorStr.AssignLiteral("Memory can't be allocated for the message."); DispatchBluetoothReply(aRunnable, v, errorStr); @@ -2253,7 +2244,7 @@ BluetoothDBusService::SetPinCodeInternal(const nsAString& aDeviceAddress, if (!dbus_message_append_args(reply, DBUS_TYPE_STRING, &pinCode, DBUS_TYPE_INVALID)) { - LOG("%s: Couldn't append arguments to dbus message.", __FUNCTION__); + BT_WARNING("%s: Couldn't append arguments to dbus message.", __FUNCTION__); errorStr.AssignLiteral("Couldn't append arguments to dbus message."); result = false; } else { @@ -2277,7 +2268,7 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress, BluetoothValue v = true; DBusMessage *msg; if (!sPairingReqTable.Get(aDeviceAddress, &msg)) { - LOG("%s: Couldn't get original request message.", __FUNCTION__); + BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__); errorStr.AssignLiteral("Couldn't get original request message."); DispatchBluetoothReply(aRunnable, v, errorStr); return false; @@ -2286,7 +2277,7 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress, DBusMessage *reply = dbus_message_new_method_return(msg); if (!reply) { - LOG("%s: Memory can't be allocated for the message.", __FUNCTION__); + BT_WARNING("%s: Memory can't be allocated for the message.", __FUNCTION__); dbus_message_unref(msg); errorStr.AssignLiteral("Memory can't be allocated for the message."); DispatchBluetoothReply(aRunnable, v, errorStr); @@ -2299,7 +2290,7 @@ BluetoothDBusService::SetPasskeyInternal(const nsAString& aDeviceAddress, if (!dbus_message_append_args(reply, DBUS_TYPE_UINT32, &passkey, DBUS_TYPE_INVALID)) { - LOG("%s: Couldn't append arguments to dbus message.", __FUNCTION__); + BT_WARNING("%s: Couldn't append arguments to dbus message.", __FUNCTION__); errorStr.AssignLiteral("Couldn't append arguments to dbus message."); result = false; } else { @@ -2323,7 +2314,7 @@ BluetoothDBusService::SetPairingConfirmationInternal(const nsAString& aDeviceAdd BluetoothValue v = true; DBusMessage *msg; if (!sPairingReqTable.Get(aDeviceAddress, &msg)) { - LOG("%s: Couldn't get original request message.", __FUNCTION__); + BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__); errorStr.AssignLiteral("Couldn't get original request message."); DispatchBluetoothReply(aRunnable, v, errorStr); return false; @@ -2339,7 +2330,7 @@ BluetoothDBusService::SetPairingConfirmationInternal(const nsAString& aDeviceAdd } if (!reply) { - LOG("%s: Memory can't be allocated for the message.", __FUNCTION__); + BT_WARNING("%s: Memory can't be allocated for the message.", __FUNCTION__); dbus_message_unref(msg); errorStr.AssignLiteral("Memory can't be allocated for the message."); DispatchBluetoothReply(aRunnable, v, errorStr); @@ -2368,7 +2359,7 @@ BluetoothDBusService::SetAuthorizationInternal(const nsAString& aDeviceAddress, DBusMessage *msg; if (!sAuthorizeReqTable.Get(aDeviceAddress, &msg)) { - LOG("%s: Couldn't get original request message.", __FUNCTION__); + BT_WARNING("%s: Couldn't get original request message.", __FUNCTION__); errorStr.AssignLiteral("Couldn't get original request message."); DispatchBluetoothReply(aRunnable, v, errorStr); return false; @@ -2384,7 +2375,7 @@ BluetoothDBusService::SetAuthorizationInternal(const nsAString& aDeviceAddress, } if (!reply) { - LOG("%s: Memory can't be allocated for the message.", __FUNCTION__); + BT_WARNING("%s: Memory can't be allocated for the message.", __FUNCTION__); dbus_message_unref(msg); errorStr.AssignLiteral("Memory can't be allocated for the message."); DispatchBluetoothReply(aRunnable, v, errorStr);