fixed bug in library. subject registering was not working properly 51/80751/1
authorkmook <kmook.choi@samsung.com>
Wed, 20 Jul 2016 04:35:43 +0000 (13:35 +0900)
committerkmook <kmook.choi@samsung.com>
Wed, 20 Jul 2016 04:35:43 +0000 (13:35 +0900)
Change-Id: I200a2d9c8522d4f078b469269afd16c4e4c81a09
Signed-off-by: kmook <kmook.choi@samsung.com>
lib/conv_lib.cpp
lib/conv_lib_service.cpp
lib/dbus_client.cpp

index f88f0aa..0daf7b6 100755 (executable)
@@ -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
index 7d58c5c..b66ecab 100755 (executable)
@@ -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
index c917b45..4d20557 100755 (executable)
@@ -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<std::string, subject_response_cb> (subject, callback));
-
-       _D("registering done..");
+       if (response_cb_map->find(subject) == response_cb_map->end()) {
+               response_cb_map->insert(std::pair<std::string, subject_response_cb> (subject, callback));
+               _D("registering done..");
+       } else {
+               _I("Already registered for subject %s", subject);
+       }
 
        return true;
 }