From 8ecf7af141e4605b810e8bcc4ef9d76ab4f98cba Mon Sep 17 00:00:00 2001 From: kmook Date: Wed, 20 Jul 2016 13:35:43 +0900 Subject: [PATCH] fixed bug in library. subject registering was not working properly Change-Id: I200a2d9c8522d4f078b469269afd16c4e4c81a09 Signed-off-by: kmook --- lib/conv_lib.cpp | 6 +----- lib/conv_lib_service.cpp | 8 ++------ lib/dbus_client.cpp | 9 ++++++--- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/conv_lib.cpp b/lib/conv_lib.cpp index f88f0aa..0daf7b6 100755 --- a/lib/conv_lib.cpp +++ b/lib/conv_lib.cpp @@ -61,12 +61,8 @@ static void conv_subject_cb(const char* subject, int req_id, int error, json dat static void register_subject_callbacks() { - static bool done = false; + conv::dbus_client::register_callback(CONV_SUBJECT_DISCOVERY_START, conv_subject_cb); - if (!done) { - conv::dbus_client::register_callback(CONV_SUBJECT_DISCOVERY_START, conv_subject_cb); - done = true; - } _I("Done with registering subject callback"); } //LCOV_EXCL_STOP diff --git a/lib/conv_lib_service.cpp b/lib/conv_lib_service.cpp index 7d58c5c..b66ecab 100755 --- a/lib/conv_lib_service.cpp +++ b/lib/conv_lib_service.cpp @@ -150,13 +150,9 @@ static void conv_connect_subject_cb(const char* subject, int req_id, int error, static void register_subject_callbacks() { - static bool done = false; + conv::dbus_client::register_callback(CONV_SUBJECT_COMMUNICATION_RECV, conv_subject_cb); + conv::dbus_client::register_callback(CONV_SUBJECT_CONNECTION_START, conv_connect_subject_cb); - if (!done) { - conv::dbus_client::register_callback(CONV_SUBJECT_COMMUNICATION_RECV, conv_subject_cb); - conv::dbus_client::register_callback(CONV_SUBJECT_CONNECTION_START, conv_connect_subject_cb); - done = true; - } _I("Done with registering subject callback"); } //LCOV_EXCL_STOP diff --git a/lib/dbus_client.cpp b/lib/dbus_client.cpp index c917b45..4d20557 100755 --- a/lib/dbus_client.cpp +++ b/lib/dbus_client.cpp @@ -231,9 +231,12 @@ int conv::dbus_client::register_callback(const char* subject, subject_response_c _I("Registering callback for subject '%s'", subject); _I("response_cb_map : %x", response_cb_map); - response_cb_map->insert(std::pair (subject, callback)); - - _D("registering done.."); + if (response_cb_map->find(subject) == response_cb_map->end()) { + response_cb_map->insert(std::pair (subject, callback)); + _D("registering done.."); + } else { + _I("Already registered for subject %s", subject); + } return true; } -- 2.7.4