From aaa5cb74fb602808b3cf6365bfe3d7bf96d0c66a Mon Sep 17 00:00:00 2001 From: "ch79.cho" Date: Wed, 10 Aug 2016 12:40:23 +0900 Subject: [PATCH] Send topic notification Change-Id: Iaa85682a09c2b99542191df0df063ac94584e98d Signed-off-by: ch79.cho Reviewed-on: https://gerrit.iotivity.org/gerrit/10215 Tested-by: jenkins-iotivity Reviewed-by: Madan Lanka --- service/notification/include/NSCommon.h | 1 + .../src/provider/NSProviderNotification.c | 23 ++++++++++++++++++++-- .../notification/src/provider/NSProviderTopic.c | 6 ++++++ .../notification/src/provider/NSProviderTopic.h | 2 ++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/service/notification/include/NSCommon.h b/service/notification/include/NSCommon.h index 6603fde..5806e3c 100644 --- a/service/notification/include/NSCommon.h +++ b/service/notification/include/NSCommon.h @@ -178,6 +178,7 @@ typedef struct char * contentText; char * sourceName; NSMediaContents * mediaContents; + char * topic; } NSMessage; diff --git a/service/notification/src/provider/NSProviderNotification.c b/service/notification/src/provider/NSProviderNotification.c index f6f7da9..7d42720 100644 --- a/service/notification/src/provider/NSProviderNotification.c +++ b/service/notification/src/provider/NSProviderNotification.c @@ -108,6 +108,8 @@ NSResult NSSendNotification(NSMessage *msg) return NS_ERROR; } + NS_LOG_V(DEBUG, "this is topic message: %s", msg->topic); + NSCacheElement * it = consumerSubList->head; while (it) @@ -124,13 +126,30 @@ NSResult NSSendNotification(NSMessage *msg) { if(subData->messageObId != 0) { - obArray[obCount++] = subData->messageObId; + if(msg->topic) + { + if(NSIsTopicSubscribed(subData->id, msg->topic)) + { + obArray[obCount++] = subData->messageObId; + } + } + else + { + obArray[obCount++] = subData->messageObId; + } } #ifdef WITH_CLOUD if(subData->remote_messageObId != 0) { - obArray[obCount++] = subData->remote_messageObId; + if(NSIsTopicSubscribed(subData->id, msg->topic)) + { + obArray[obCount++] = subData->remote_messageObId; + } + else + { + obArray[obCount++] = subData->remote_messageObId; + } } #endif diff --git a/service/notification/src/provider/NSProviderTopic.c b/service/notification/src/provider/NSProviderTopic.c index 41aebb5..ecd9602 100644 --- a/service/notification/src/provider/NSProviderTopic.c +++ b/service/notification/src/provider/NSProviderTopic.c @@ -39,6 +39,12 @@ NSTopicList * NSGetTopics(char *consumerId) return topicList; } +bool NSIsTopicSubscribed(char * consumerId, char * topic) +{ + //TODO: implement function + return true; +} + void * NSTopicSchedule(void * ptr) { if (ptr == NULL) diff --git a/service/notification/src/provider/NSProviderTopic.h b/service/notification/src/provider/NSProviderTopic.h index ef4abe6..e6ddb64 100644 --- a/service/notification/src/provider/NSProviderTopic.h +++ b/service/notification/src/provider/NSProviderTopic.h @@ -28,4 +28,6 @@ NSTopicList * NSGetTopics(char *consumerId); +bool NSIsTopicSubscribed(char *consumerId, char *topic); + #endif /* _NS_PROVIDER_TOPIC_H_ */ -- 2.7.4