From: jaesick.shin Date: Mon, 22 Aug 2016 07:15:55 +0000 (+0900) Subject: bug fixes logic for subscription cache update. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=48fd9ed61a92aebbcc3ea3943f6b171c74a290b9;p=contrib%2Fiotivity.git bug fixes logic for subscription cache update. If consumer have controlled access then provider always allowed for subscription. Added call function of subscription updateState. second patch included, remove not required code. change NSSendSubscriptionResponse to NSSendConsumerSubResponse. Change-Id: Ia39766e814130bd492193e5c3a57436493b9e409 Signed-off-by: jaesick.shin Reviewed-on: https://gerrit.iotivity.org/gerrit/10719 Tested-by: jenkins-iotivity Reviewed-by: Chihyun Cho Reviewed-by: Uze Choi --- diff --git a/service/notification/src/provider/NSProviderSubscription.c b/service/notification/src/provider/NSProviderSubscription.c index db2b8a0..29f2223 100644 --- a/service/notification/src/provider/NSProviderSubscription.c +++ b/service/notification/src/provider/NSProviderSubscription.c @@ -173,7 +173,7 @@ void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResour else if (currPolicy == NS_POLICY_CONSUMER) { NS_LOG(DEBUG, "NSGetSubscriptionAccepter == NS_ACCEPTER_CONSUMER"); - NSSendSubscriptionResponse(entityHandlerRequest, true); + NSSendConsumerSubResponse(entityHandlerRequest); } } else if (resourceType == NS_RESOURCE_SYNC) @@ -291,7 +291,7 @@ NSResult NSSendResponse(const char * id, bool accepted) return NS_OK; } -NSResult NSSendSubscriptionResponse(OCEntityHandlerRequest *entityHandlerRequest, bool accepted) +NSResult NSSendConsumerSubResponse(OCEntityHandlerRequest * entityHandlerRequest) { NS_LOG(DEBUG, "NSSendSubscriptionResponse - IN"); @@ -310,33 +310,9 @@ NSResult NSSendSubscriptionResponse(OCEntityHandlerRequest *entityHandlerRequest return NS_ERROR; } - if (accepted) - { - NS_LOG(DEBUG, "accepted is true"); - NSCacheElement * element = (NSCacheElement *) OICMalloc(sizeof(NSCacheElement)); - NSCacheSubData * subData = (NSCacheSubData *) OICMalloc(sizeof(NSCacheSubData)); - - OICStrcpy(subData->id, UUID_STRING_SIZE, id); - - subData->isWhite = true; - subData->remote_messageObId = 0; - subData->remote_syncObId = 0; - subData->syncObId = 0; - subData->messageObId = entityHandlerRequest->obsInfo.obsId; - - element->data = (void*) subData; - element->next = NULL; - - if (NSStorageWrite(consumerSubList, element) != NS_OK) - { - NS_LOG(ERROR, "fail to write consumer white list"); - } - } - - NSSendResponse(id, accepted); - + NSCacheUpdateSubScriptionState(consumerSubList, id, true); + NSSendResponse(id, true); NSFreeOCEntityHandlerRequest(entityHandlerRequest); - NS_LOG(DEBUG, "NSSendSubscriptionResponse - OUT"); return NS_OK; } diff --git a/service/notification/src/provider/NSProviderSubscription.h b/service/notification/src/provider/NSProviderSubscription.h index a8f2139..9813250 100644 --- a/service/notification/src/provider/NSProviderSubscription.h +++ b/service/notification/src/provider/NSProviderSubscription.h @@ -42,7 +42,7 @@ NSResult NSSendAccessPolicyResponse(OCEntityHandlerRequest *entityHandlerRequest void NSHandleSubscription(OCEntityHandlerRequest *entityHandlerRequest, NSResourceType resourceType); void NSHandleUnsubscription(OCEntityHandlerRequest *entityHandlerRequest); void NSAskAcceptanceToUser(OCEntityHandlerRequest *entityHandlerRequest); -NSResult NSSendSubscriptionResponse(OCEntityHandlerRequest *entityHandlerRequest, bool accepted); +NSResult NSSendConsumerSubResponse(OCEntityHandlerRequest *entityHandlerRequest); NSResult NSSendResponse(const char * id, bool accepted); #endif /* _NS_PROVIDER_SUBSCRIPTION_H_ */