Fixed bug about Subscription logic on Consumer. 49/8349/3
authorjyong2.kim <jyong2.kim@samsung.com>
Thu, 26 May 2016 06:45:21 +0000 (15:45 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 26 May 2016 08:55:44 +0000 (08:55 +0000)
Now, consumer notify all messages of providers to user,
included subscription acceptance message.
but, subscription acceptance message no need for user.

and, in this patch, included deletion of unused comments.

Change-Id: I4e21bece1601492e55d0adb5d2f1bb49dac46277
Signed-off-by: jyong2.kim <jyong2.kim@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8349
Reviewed-by: Hun-je Yeon <hunje.yeon@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification/src/consumer/NSConsumerListener.c
service/notification/src/consumer/NSConsumerNotification.c

index 18adc7b..71f2e8d 100644 (file)
@@ -137,74 +137,3 @@ void NSAdapterStateListener(CATransportAdapter_t adapter, bool enabled)
         NSConsumerPushEvent(task);
     }
 }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// TODO move to other modules
-///////////////////////////////////////////////////////////////////////////////////////////////////
-//NSDiscoveredProvider * NSCreateDiscoveredProviderInfo(OCClientResponse *);
-//
-//OCStackResult NSSubscribeNotification(NSDiscoveredProvider * handle);
-//
-//NSObject * NSBuildOICNotification(OCClientResponse * clientResponse);
-//
-//
-//OCStackApplicationResult NSNotificationListener(
-//        void * ctx, OCDoHandle handle, OCClientResponse * clientResponse)
-//{
-//    if (!g_isStartedConsumer)
-//    {
-//        return OC_STACK_DELETE_TRANSACTION;
-//    }
-//
-//    (void) ctx;
-//    (void) handle;
-//    if (!clientResponse)
-//    {
-//        return OC_STACK_KEEP_TRANSACTION;
-//    }
-//
-//    if (clientResponse->result != OC_STACK_OK)
-//    {
-//        // TODO error handle.
-//        return OC_STACK_KEEP_TRANSACTION;
-//    }
-//
-//    NSObject * notification = NSBuildOICNotification(clientResponse);
-//    if (!notification)
-//    {
-//        // TODO error handle.
-//        return OC_STACK_KEEP_TRANSACTION;
-//    }
-//
-//    g_NotificationPostedCB(notification);
-//
-//    return OC_STACK_KEEP_TRANSACTION;
-//}
-//
-//OCStackResult NSSubscribeNotification(NSDiscoveredProvider * handle)
-//{
-//    // TODO add provider list.
-//
-//    OCDevAddr * addr = ((NSDiscoveredProvider *)handle)->addr;
-//
-//    return NSRequestToResourceIntrospection(
-//            ((NSDiscoveredProvider *)handle)->observeHandle,
-//            OC_REST_OBSERVE, addr, NS_OBSERVE_QUERY,
-//            NSNotificationListener, (void *)DEFAULT_CONTEXT_VALUE, NS_QOS);
-//}
-//
-//NSDiscoveredProvider * NSCreateDiscoveredProviderInfo(OCClientResponse * client)
-//{
-//    NSDiscoveredProvider * discoveredProvider
-//        = (NSDiscoveredProvider * )OICMalloc(sizeof(NSDiscoveredProvider));
-//
-//    if (!discoveredProvider)
-//    {
-//        return NULL;
-//    }
-//
-//    discoveredProvider->addr = (OCDevAddr *)OICMalloc(sizeof(OCDevAddr));
-//    memcpy(discoveredProvider->addr, client->addr,sizeof(OCDevAddr));
-//
-//    return discoveredProvider;
-//}
index 766ea11..fcdbf64 100644 (file)
@@ -26,6 +26,8 @@
 #include "oic_string.h"
 #include "ocpayload.h"
 
+const char NS_MESSAGE_ACCEPTANCE[] = "0000-0000-0000-0000";
+
 NSMessage_consumer * NSBuildOICNotification(OCClientResponse * clientResponse);
 NSSync * NSBuildOICNotificationSync(OCClientResponse * clientResponse);
 
@@ -122,6 +124,15 @@ OCStackApplicationResult NSConsumerNotificationListener(
         return OC_STACK_KEEP_TRANSACTION;
     }
 
+    if (!strcmp(newNoti->mId, NS_MESSAGE_ACCEPTANCE))
+    {
+        NS_LOG(DEBUG, "Receive Subscribe confirm");
+        OICFree(provider->mUserData);
+        OICFree(provider);
+        NSRemoveMessage(newNoti);
+        return OC_STACK_KEEP_TRANSACTION;
+    }
+
     NSTaskType taskType = TASK_CONSUMER_RECV_NOTIFICATION;
 
     NS_LOG(DEBUG, "newNoti->type == Notification");