Fix for API return type of Notification Manager issues about return value of APIs.
authorjyong2.kim <jyong2.kim@samsung.com>
Tue, 28 Apr 2015 11:41:47 +0000 (20:41 +0900)
committerUze Choi <uzchoi@samsung.com>
Wed, 29 Apr 2015 01:01:24 +0000 (01:01 +0000)
1. fix return value of APIs.
2. handle exception about memory.
[IOT-501]
[IOT-502]

Change-Id: I77e54efe9e44572a8f7bd83849dc6215ff6daa79
Signed-off-by: jyong2.kim <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/854
Reviewed-by: Uze Choi <uzchoi@samsung.com>
Tested-by: Uze Choi <uzchoi@samsung.com>
service/notification-manager/NotificationManager/src/hosting.c
service/notification-manager/SampleApp/linux/notificationManager/main.c

index 772a6ae..66b1b36 100755 (executable)
@@ -351,17 +351,32 @@ OCStackResult registerResourceAsCoordinatable(OCResourceHandle *handle,
  */
 OCStackResult OICStartCoordinate()
 {
-    s_mirrorResourceList = createMirrorResourceList();
-    s_requestHandleList = createRequestHandleList();
+    OCStackResult ret = OC_STACK_ERROR;
+    if (OCInit((char *) NULL, 0, OC_CLIENT_SERVER) != OC_STACK_OK)
+    {
+        OC_LOG(ERROR, HOSTING_TAG, PCF("OCStack init ERROR"));
+    }
+    else
+    {
+        s_mirrorResourceList = createMirrorResourceList();
+        s_requestHandleList = createRequestHandleList();
+        ret = requestPresence(OC_MULTICAST_PREFIX);
+    }
 
-    return requestPresence(OC_MULTICAST_PREFIX);
+    return ret;
 }
 
 OCStackResult OICStopCoordinate()
 {
     OCStackResult result = OC_STACK_ERROR;
 
+    if (OCStop() == OC_STACK_OK)
+    {
+        OC_LOG_V(DEBUG, HOSTING_TAG, "OCStack Stop OK");
+    }
+
     result = destroyMirrorResourceList(s_mirrorResourceList);
+    s_mirrorResourceList = NULL;
     if(result != OC_STACK_OK)
     {
         return OC_STACK_ERROR;
index 9340681..830db3a 100755 (executable)
@@ -41,7 +41,11 @@ int main()
         return 0;
     }
 
-    OICStartCoordinate();
+    if (OICStartCoordinate() != OC_STACK_OK)
+    {
+        printf("OIC coordinate start fail\n");
+        return 0;
+    }
 
     signal(SIGINT, handleSigInt);
     while (!g_quitFlag)
@@ -56,7 +60,14 @@ int main()
         sleep(2);
     }
 
-    OICStopCoordinate();
+    if (OICStopCoordinate() != OC_STACK_OK)
+    {
+        printf("OIC coordinate stop error\n");
+    }
+    else
+    {
+        printf("OIC coordinate stop success\n");
+    }
 
     printf("Exiting occlient main loop...\n");