Bug 834551 - Replace 'LOG()' with 'BT_WARNING()' defined in BluetoothCommon.h for consistency, r=qdot

This commit is contained in:
Eric Chou 2013-01-29 18:37:51 +08:00
parent dea952907e
commit 3c923fe145
3 changed files with 39 additions and 48 deletions

View File

@ -24,13 +24,19 @@ 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...) \
#define BT_LOG(args, ...) \
do { \
if (gBluetoothDebugFlag) { \
printf(args); \
printf(args, ##__VA_ARGS__); \
} \
} while(0)
#define BT_WARNING(args, ...) printf(args, ##__VA_ARGS__)
#endif
#define BEGIN_BLUETOOTH_NAMESPACE \

View File

@ -35,15 +35,6 @@
#include "BluetoothUnixSocketConnector.h"
#include "nsThreadUtils.h"
#undef LOG
#if defined(MOZ_WIDGET_GONK)
#include <android/log.h>
#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

View File

@ -59,15 +59,6 @@ using namespace mozilla;
using namespace mozilla::ipc;
USING_BLUETOOTH_NAMESPACE
#undef LOG
#if defined(MOZ_WIDGET_GONK)
#include <android/log.h>
#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"
@ -419,7 +410,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;
}
@ -459,7 +450,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 =
@ -491,7 +482,8 @@ 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(
@ -523,7 +515,8 @@ 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(
@ -551,7 +544,8 @@ 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(
@ -589,7 +583,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;
}
@ -630,7 +624,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;
}
@ -639,7 +633,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;
}
@ -647,7 +641,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;
}
@ -664,11 +658,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;
}
}
@ -698,7 +692,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;
@ -720,7 +714,7 @@ ExtractHandles(DBusMessage *aReply, nsTArray<uint32_t>& 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]);
@ -774,7 +768,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;
}
@ -1306,13 +1300,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;
}
@ -1634,13 +1628,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);
}
@ -2184,7 +2178,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;
@ -2193,7 +2187,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);
@ -2208,7 +2202,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 {
@ -2232,7 +2226,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;
@ -2241,7 +2235,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);
@ -2254,7 +2248,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 {
@ -2278,7 +2272,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;
@ -2294,7 +2288,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);
@ -2323,7 +2317,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;
@ -2339,7 +2333,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);