From ee27c8abd1926a58c4293e55e9c2f48f50a5da50 Mon Sep 17 00:00:00 2001 From: "jyong2.kim" Date: Thu, 26 May 2016 15:45:21 +0900 Subject: [PATCH] Fixed bug about Subscription logic on Consumer. 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 Reviewed-on: https://gerrit.iotivity.org/gerrit/8349 Reviewed-by: Hun-je Yeon Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- .../notification/src/consumer/NSConsumerListener.c | 71 ---------------------- .../src/consumer/NSConsumerNotification.c | 11 ++++ 2 files changed, 11 insertions(+), 71 deletions(-) diff --git a/service/notification/src/consumer/NSConsumerListener.c b/service/notification/src/consumer/NSConsumerListener.c index 18adc7b..71f2e8d 100644 --- a/service/notification/src/consumer/NSConsumerListener.c +++ b/service/notification/src/consumer/NSConsumerListener.c @@ -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; -//} diff --git a/service/notification/src/consumer/NSConsumerNotification.c b/service/notification/src/consumer/NSConsumerNotification.c index 766ea11..fcdbf64 100644 --- a/service/notification/src/consumer/NSConsumerNotification.c +++ b/service/notification/src/consumer/NSConsumerNotification.c @@ -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"); -- 2.7.4