#include <aul.h>
#include "bluetooth-hid-agent.h"
+#include "bluetooth-hid-manager.h"
static GMainLoop *gmain_loop;
static char *g_obj_path;
ret = _bt_hid_register_application(FALSE, name_owner);
if (ret == BT_HID_AGENT_ERROR_NONE) {
- is_hid_connectable = FALSE;
- if (name_owner_sig_id > 0) {
- g_dbus_connection_signal_unsubscribe(gdbus_conn,
- name_owner_sig_id);
- name_owner_sig_id = 0;
+ if (_bt_hid_get_sender_list() == NULL) {
+ is_hid_connectable = FALSE;
+ if (name_owner_sig_id > 0) {
+ g_dbus_connection_signal_unsubscribe(gdbus_conn,
+ name_owner_sig_id);
+ name_owner_sig_id = 0;
+ }
}
}
}
ret = _bt_hid_register_application(FALSE, sender);
if (ret == BT_HID_AGENT_ERROR_NONE) {
- is_hid_connectable = FALSE;
- if (name_owner_sig_id > 0) {
- g_dbus_connection_signal_unsubscribe(gdbus_conn,
- name_owner_sig_id);
- name_owner_sig_id = 0;
+ if (_bt_hid_get_sender_list() == NULL) {
+ is_hid_connectable = FALSE;
+ if (name_owner_sig_id > 0) {
+ g_dbus_connection_signal_unsubscribe(gdbus_conn,
+ name_owner_sig_id);
+ name_owner_sig_id = 0;
+ }
}
} else {
goto fail;
-bt_hid_agent_error_t __bt_hid_disconnect_profile(void)
+bt_hid_agent_error_t _bt_hid_disconnect_profile(void)
{
FN_START;
GDBusProxy *proxy;
*/
#include "bluetooth-hid-agent.h"
+#include "bluetooth-hid-manager.h"
-static char *sender;
+static GSList *sender_list;
static bt_hid_state_t hid_state;
static const char *__bt_hid_state2str(bt_hid_state_t state)
return NULL;
}
-#if 0
static gboolean __bt_hid_check_for_callpath(const char *call_sender)
{
- GSList *s_list = app_list;
+ GSList *s_list = sender_list;
char *sender;
DBG_SECURE("sender is = %s\n", call_sender);
if (call_sender == NULL) {
-
ERR("Invalid Parameters");
return FALSE;
}
s_list = s_list->next;
}
- ERR("Sender [%s] is not registered", call_sender);
+ INFO("Sender [%s] is not registered", call_sender);
return FALSE;
}
if (sender == NULL)
return BT_HID_AGENT_ERROR_INVALID_PARAM;
- DBG(" Requesting [%s]", register_flag ? "Register" : "Unregister");
- DBG(" sender = %s", sender);
-
- if (register_flag) {
- if (__bt_hid_check_for_callpath(sender))
+ if (register_flag == TRUE) {
+ if (__bt_hid_check_for_callpath(sender) == TRUE) {
+ ERR("Already registered [sender:%s]", sender);
return BT_HID_AGENT_ERROR_ALREADY_EXIST;
+ }
- /* add call path to the senders list*/
- sender_name = g_strdup(sender);
- app_list = g_slist_append(app_list, sender_name);
+ INFO("Registered [sender:%s]", sender);
- return BT_HID_AGENT_ERROR_NONE;
+ /* add the call path to the sender list */
+ sender_name = g_strdup(sender);
+ sender_list = g_slist_append(sender_list, sender_name);
} else {
/*remove the call from senders list */
- GSList *s_list = app_list;
+ GSList *s_list = sender_list;
while (s_list != NULL) {
sender_name = s_list->data;
return BT_HID_AGENT_ERROR_NOT_AVAILABLE;
if (g_strcmp0(sender_name, sender) == 0) {
- app_list = g_slist_remove(app_list, sender_name);
+ sender_list = g_slist_remove(sender_list, sender_name);
g_free(sender_name);
- if (app_list == NULL && hid_state == BT_HID_STATE_CONNECTED)
- __bt_hid_disconnect_profile();
+ if (sender_list == NULL && hid_state == BT_HID_STATE_CONNECTED)
+ _bt_hid_disconnect_profile();
+
+ INFO("Unregistered [sender:%s]", sender);
return BT_HID_AGENT_ERROR_NONE;
}
return BT_HID_AGENT_ERROR_NOT_AVAILABLE;
}
-}
-
-#else
-bt_hid_agent_error_t _bt_hid_register_application(gboolean register_flag,
- const char *sender_name)
-{
- if (sender_name == NULL)
- return BT_HID_AGENT_ERROR_INVALID_PARAM;
-
- if (register_flag == TRUE) {
- if (sender != NULL) {
- ERR("Already registered [sender:%s]", sender_name);
- return BT_HID_AGENT_ERROR_ALREADY_EXIST;
- }
-
- /* set the call path to the sender */
- sender = g_strdup(sender_name);
- INFO("Registered [sender:%s]", sender_name);
- } else {
- if (sender == NULL)
- return BT_HID_AGENT_ERROR_NOT_AVAILABLE;
- if (strcasecmp(sender, sender_name) != 0)
- return BT_HID_AGENT_ERROR_NOT_AVAILABLE;
-
- /* unset the call path to the sender */
- g_free(sender);
- sender = NULL;
- if (hid_state == BT_HID_STATE_CONNECTED)
- __bt_hid_disconnect_profile();
- INFO("Unregistered [sender:%s]", sender_name);
- }
return BT_HID_AGENT_ERROR_NONE;
}
-#endif
void _bt_hid_set_profile_state(bt_hid_state_t new_state)
{
case BT_HID_STATE_DISCONNECTED:
break;
case BT_HID_STATE_CONNECTED:
+ if (sender_list == NULL)
+ _bt_hid_disconnect_profile();
break;
case BT_HID_STATE_CONNECTING:
case BT_HID_STATE_DISCONNECTING:
{
return hid_state;
}
+
+const GSList* _bt_hid_get_sender_list(void)
+{
+ return sender_list;
+}
--- /dev/null
+/*
+ * Bluetooth-hid-agent
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef __DEF_BT_HID_MANAGER_H_
+#define __DEF_BT_HID_MANAGER_H_
+
+void _bt_hid_set_profile_state(bt_hid_state_t new_state);
+bt_hid_agent_error_t _bt_hid_register_application(gboolean register_flag,
+ const char *sender_name);
+const GSList* _bt_hid_get_sender_list(void);
+
+#endif /* __DEF_BT_HID_MANAGER_H_ */