Fix FindGroup API of Things Manager about group sync feature.
authorHyunJun Kim <hyunjun2.kim@samsung.com>
Fri, 23 Jan 2015 05:00:54 +0000 (14:00 +0900)
committerUze Choi <uzchoi@samsung.com>
Fri, 23 Jan 2015 08:29:50 +0000 (08:29 +0000)
It is not notify about state of finding to caller.
So we will return 'OC_STACK_ERROR' when It was finding a group.
User should be wait findCallback.
Then user will know the result of finding.

FindCallback has the argument which OCResource.
If it is NULL we could not find a group.

Fix [IOT-286]

Change-Id: I2b95d5102e54e4242394c36d51de81f192b87e13
Signed-off-by: HyunJun Kim <hyunjun2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/230
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/things-manager/sdk/src/GroupSynchronization.cpp
service/things-manager/sdk/src/GroupSynchronization.h

index 2b476b5..4210a00 100644 (file)
@@ -29,6 +29,7 @@ namespace OIC
 {
 
     GroupSynchronization* GroupSynchronization::groupSyncnstance = NULL;
+    bool GroupSynchronization::bIsFinding = false;
 
     GroupSynchronization* GroupSynchronization::getInstance()
     {
@@ -53,6 +54,9 @@ namespace OIC
     {
         cout << "GroupSynchronization::findGroup" << endl;
 
+        if(bIsFinding)
+            return OC_STACK_ERROR;
+
         foundGroupResourceList.clear();
         findCallback = callback;
 
@@ -71,6 +75,8 @@ namespace OIC
                     std::bind(&GroupSynchronization::onFindGroup, this, std::placeholders::_1));
         }
 
+        bIsFinding = true;
+
         // thread to check if GroupSynchronization::onFoundGroup is called or not.
         std::thread t(std::bind(&GroupSynchronization::checkFindGroup, this));
         t.detach();
@@ -834,6 +840,7 @@ namespace OIC
                 findCallback(NULL);
             }
 
+            bIsFinding = false;
         }
         catch (std::exception& e)
         {
index da5f153..fdcea60 100644 (file)
@@ -66,6 +66,7 @@ private:
     std::shared_ptr< OCResourceRequest > resourceRequest; // this is used for slow response
 
     static GroupSynchronization* groupSyncnstance;
+    static bool bIsFinding;
 
     GroupSynchronization()
     {