/* current discovery filter, if any */
struct mgmt_cp_start_service_discovery *current_discovery_filter;
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+ struct watch_client *client; /* active discovery client */
+#endif
+
GSList *discovery_found; /* list of found devices */
guint discovery_idle_timeout; /* timeout between discovery runs */
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
{
struct watch_client *client = user_data;
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+ DBG("%p", client);
+#endif
if (client->watch)
g_dbus_remove_watch(dbus_conn, client->watch);
g_free(client);
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
static void discovery_remove(struct watch_client *client, bool exit)
+#else
+static void discovery_remove(struct watch_client *client)
+#endif
+
{
struct btd_adapter *adapter = client->adapter;
adapter->discovery_list = g_slist_remove(adapter->discovery_list,
client);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
if (!exit && client->discovery_filter)
+#else
+ if (adapter->client == client)
+ adapter->client = NULL;
+
+ if (client->watch && client->discovery_filter)
+#endif
adapter->set_filter_list = g_slist_prepend(
adapter->set_filter_list, client);
else
static void trigger_start_discovery(struct btd_adapter *adapter, guint delay);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
static void discovery_reply(struct watch_client *client, uint8_t status)
+#else
+static struct watch_client *discovery_complete(struct btd_adapter *adapter,
+ uint8_t status)
+#endif
{
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+ struct watch_client *client = adapter->client;
+#endif
DBusMessage *reply;
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+
+ if (!client)
+ return NULL;
+
+ adapter->client = NULL;
+#endif
if (!client->msg)
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
return;
-
+#else
+ return client;
+#endif
if (!status) {
g_dbus_send_reply(dbus_conn, client->msg, DBUS_TYPE_INVALID);
} else {
dbus_message_unref(client->msg);
client->msg = NULL;
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+ return client;
+#endif
}
static void start_discovery_complete(uint8_t status, uint16_t length,
else
adapter->filtered_discovery = false;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
discovery_reply(client, status);
-
+#else
+ discovery_complete(adapter, status);
+#endif
if (adapter->discovering)
return;
#endif
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
fail:
/* Reply with an error if the first discovery has failed */
if (client->msg) {
discovery_reply(client, status);
discovery_remove(client, false);
+#else
+ client = discovery_complete(adapter, status);
+ if (client) {
+ discovery_remove(client);
+#endif
return;
}
struct mgmt_cp_start_discovery cp;
cp.type = new_type;
mgmt_send(adapter->mgmt, MGMT_OP_START_DISCOVERY,
- adapter->dev_id, sizeof(cp), &cp,
- start_discovery_complete, adapter, NULL);
+ adapter->dev_id, sizeof(cp), &cp,
+ start_discovery_complete, adapter,
+ NULL);
+
#else
/* If we're doing filtered discovery, it must be quickly restarted */
cp.type = new_type;
mgmt_send(adapter->mgmt, MGMT_OP_START_DISCOVERY,
- adapter->dev_id, sizeof(cp), &cp,
- start_discovery_complete, adapter, NULL);
+ adapter->dev_id, sizeof(cp), &cp,
+ start_discovery_complete, adapter,
+ NULL);
+
return FALSE;
}
DBG("status 0x%02x", status);
- /* Is there are no clients the discovery must have been stopped while
- * discovery command was pending.
- */
- if (!adapter->discovery_list)
- return;
-
- client = adapter->discovery_list->data;
-
- discovery_reply(client, status);
-
- if (status != MGMT_STATUS_SUCCESS)
- goto done;
+ client = discovery_complete(adapter, status);
+ if (client)
+ discovery_remove(client);
adapter->discovery_type = 0x00;
adapter->discovery_enable = 0x00;
ADAPTER_INTERFACE, "Discovering");
trigger_passive_scanning(adapter);
-
-done:
- discovery_remove(client);
}
#endif
return -EINPROGRESS;
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
static int discovery_stop(struct watch_client *client, bool exit)
+#else
+static int discovery_stop(struct watch_client *client)
+#endif
{
struct btd_adapter *adapter = client->adapter;
struct mgmt_cp_stop_discovery cp;
/* Check if there are more client discovering */
if (g_slist_next(adapter->discovery_list)) {
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
discovery_remove(client, exit);
+#else
+ discovery_remove(client);
+#endif
update_discovery_filter(adapter);
return 0;
}
* and so it is enough to send out the signal and just return.
*/
if (adapter->discovery_enable == 0x00) {
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
discovery_remove(client, exit);
+#else
+ discovery_remove(client);
+#endif
adapter->discovering = false;
g_dbus_emit_property_changed(dbus_conn, adapter->path,
ADAPTER_INTERFACE, "Discovering");
adapter->disc_type = BT_DISC_TYPE_BREDR_ONLY;
#endif
cp.type = adapter->discovery_type;
-
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+ adapter->client = client;
+#endif
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
cp.type = 0x01;
#endif
struct watch_client *client = user_data;
DBG("owner %s", client->owner);
-
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
discovery_stop(client, true);
+#else
+ client->watch = 0;
+
+ discovery_stop(client);
+#endif
}
/*
/* If the discovery has to be started wait it complete to reply */
if (err == -EINPROGRESS) {
client->msg = dbus_message_ref(msg);
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+ adapter->client = client;
+#endif
return NULL;
+
}
return btd_error_failed(msg, strerror(-err));
if (client->msg)
return btd_error_busy(msg);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
err = discovery_stop(client, false);
+#else
+ err = discovery_stop(client);
+#endif
switch (err) {
case 0:
return dbus_message_new_method_return(msg);
case -EINPROGRESS:
client->msg = dbus_message_ref(msg);
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
+ adapter->client = client;
+#endif
return NULL;
default:
return btd_error_failed(msg, strerror(-err));