summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--audio/device.c4
-rw-r--r--audio/headset.c8
-rw-r--r--audio/sink.c4
-rw-r--r--audio/source.c4
-rw-r--r--input/device.c8
-rw-r--r--network/connection.c2
-rw-r--r--src/error.c6
-rw-r--r--src/error.h1
8 files changed, 14 insertions, 23 deletions
diff --git a/audio/device.c b/audio/device.c
index 6e005a524..fe7aed407 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -521,9 +521,7 @@ static DBusMessage *dev_connect(DBusConnection *conn, DBusMessage *msg,
if (priv->state == AUDIO_STATE_CONNECTING)
return btd_error_in_progress(msg);
else if (priv->state == AUDIO_STATE_CONNECTED)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Already Connected");
+ return btd_error_already_connected(msg);
dev->auto_connect = TRUE;
diff --git a/audio/headset.c b/audio/headset.c
index 840278971..3d584e030 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -1697,9 +1697,7 @@ static DBusMessage *hs_connect(DBusConnection *conn, DBusMessage *msg,
if (hs->state == HEADSET_STATE_CONNECTING)
return btd_error_in_progress(msg);
else if (hs->state > HEADSET_STATE_CONNECTING)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Already Connected");
+ return btd_error_already_connected(msg);
if (hs->hfp_handle && !ag.telephony_ready)
return g_dbus_create_error(msg, ERROR_INTERFACE ".NotReady",
@@ -1806,9 +1804,7 @@ static DBusMessage *hs_play(DBusConnection *conn, DBusMessage *msg,
}
return btd_error_busy(msg);
case HEADSET_STATE_PLAYING:
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
case HEADSET_STATE_CONNECTED:
default:
break;
diff --git a/audio/sink.c b/audio/sink.c
index 37ba8c0a2..176a4edea 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -442,9 +442,7 @@ static DBusMessage *sink_connect(DBusConnection *conn,
return btd_error_busy(msg);
if (sink->stream_state >= AVDTP_STATE_OPEN)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
if (!sink_setup_stream(sink, NULL))
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
diff --git a/audio/source.c b/audio/source.c
index 9b9dab7b2..c106eaa02 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -393,9 +393,7 @@ static DBusMessage *source_connect(DBusConnection *conn,
return btd_error_busy(msg);
if (source->stream_state >= AVDTP_STATE_OPEN)
- return g_dbus_create_error(msg, ERROR_INTERFACE
- ".AlreadyConnected",
- "Device Already Connected");
+ return btd_error_already_connected(msg);
if (!source_setup_stream(source, NULL))
return g_dbus_create_error(msg, ERROR_INTERFACE ".Failed",
diff --git a/input/device.c b/input/device.c
index 3c3f9fdbe..dee943bc8 100644
--- a/input/device.c
+++ b/input/device.c
@@ -315,12 +315,6 @@ failed:
return FALSE;
}
-static inline DBusMessage *already_connected(DBusMessage *msg)
-{
- return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyConnected",
- "Already connected to a device");
-}
-
static inline DBusMessage *connection_attempt_failed(DBusMessage *msg,
const char *err)
{
@@ -937,7 +931,7 @@ static DBusMessage *input_device_connect(DBusConnection *conn,
return btd_error_in_progress(msg);
if (is_connected(iconn))
- return already_connected(msg);
+ return btd_error_already_connected(msg);
iconn->pending_connect = dbus_message_ref(msg);
fake = iconn->fake;
diff --git a/network/connection.c b/network/connection.c
index a652b981e..89c38d83a 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -396,7 +396,7 @@ static DBusMessage *connection_connect(DBusConnection *conn,
return btd_error_not_supported(msg);
if (nc->state != DISCONNECTED)
- return already_connected(msg);
+ return btd_error_already_connected(msg);
nc->io = bt_io_connect(BT_IO_L2CAP, connect_cb, nc,
NULL, &err,
diff --git a/src/error.c b/src/error.c
index 0d33fb5fd..e1f0598a5 100644
--- a/src/error.c
+++ b/src/error.c
@@ -79,6 +79,12 @@ DBusMessage *btd_error_not_connected(DBusMessage *msg)
"Not Connected");
}
+DBusMessage *btd_error_already_connected(DBusMessage *msg)
+{
+ return g_dbus_create_error(msg, ERROR_INTERFACE ".AlreadyConnected",
+ "Already Connected");
+}
+
DBusMessage *btd_error_in_progress(DBusMessage *msg)
{
return g_dbus_create_error(msg, ERROR_INTERFACE ".InProgress",
diff --git a/src/error.h b/src/error.h
index a7028bd95..9d80fa07e 100644
--- a/src/error.h
+++ b/src/error.h
@@ -35,6 +35,7 @@ DBusMessage *btd_error_busy(DBusMessage *msg);
DBusMessage *btd_error_already_exists(DBusMessage *msg);
DBusMessage *btd_error_not_supported(DBusMessage *msg);
DBusMessage *btd_error_not_connected(DBusMessage *msg);
+DBusMessage *btd_error_already_connected(DBusMessage *msg);
DBusMessage *btd_error_not_available(DBusMessage *msg);
DBusMessage *btd_error_in_progress(DBusMessage *msg);
DBusMessage *btd_error_does_not_exist(DBusMessage *msg);