From df7d996af4498a365e812e4e9e945fd859682d16 Mon Sep 17 00:00:00 2001 From: YounghyunJoo Date: Thu, 26 May 2016 09:32:08 +0900 Subject: [PATCH] Add "Source" attribute in NSMessage Resource - source attribute contains message generation information(where it comes) Change-Id: Ibea94aed6044a18ba5d989cdc5aca7e109400ee9 Signed-off-by: YounghyunJoo Reviewed-on: https://gerrit.iotivity.org/gerrit/8339 Reviewed-by: Hun-je Yeon Tested-by: jenkins-iotivity Reviewed-by: Uze Choi --- service/notification/examples/linux/notificationconsumer.c | 1 + service/notification/src/common/NSUtil.c | 11 +++++++++++ service/notification/src/consumer/NSConsumerCommon.c | 6 ++++++ service/notification/src/consumer/NSConsumerCommon.h | 1 + service/notification/src/consumer/NSConsumerInterface.c | 6 ++++++ service/notification/src/consumer/NSConsumerNotification.c | 3 +++ 6 files changed, 28 insertions(+) diff --git a/service/notification/examples/linux/notificationconsumer.c b/service/notification/examples/linux/notificationconsumer.c index 85810bd..328bfbe 100644 --- a/service/notification/examples/linux/notificationconsumer.c +++ b/service/notification/examples/linux/notificationconsumer.c @@ -12,6 +12,7 @@ void onNotificationPosted(NSProvider * provider, NSMessage * notification) printf("id : %s\n", notification->mId); printf("title : %s\n", notification->mTitle); printf("content : %s\n", notification->mContentText); + printf("source : %s\n", notification->mSource); // NSDropNSObject(notification); NSConsumerReadCheck(notification); } diff --git a/service/notification/src/common/NSUtil.c b/service/notification/src/common/NSUtil.c index ce6aae2..7f074cf 100755 --- a/service/notification/src/common/NSUtil.c +++ b/service/notification/src/common/NSUtil.c @@ -45,6 +45,12 @@ NSResult NSFreeMessage(NSMessage * obj) obj->mContentText = NULL; } + if (obj->mSource) + { + OICFree(obj->mSource); + obj->mSource = NULL; + } + OICFree(obj); return NS_OK; @@ -75,6 +81,11 @@ NSMessage * NSDuplicateMessage(NSMessage * copyMsg) newMsg->mContentText = OICStrdup(copyMsg->mContentText); } + if (!copyMsg->mSource) + { + newMsg->mSource = OICStrdup(copyMsg->mSource); + } + return newMsg; } diff --git a/service/notification/src/consumer/NSConsumerCommon.c b/service/notification/src/consumer/NSConsumerCommon.c index 1cc11aa..2f37bea 100644 --- a/service/notification/src/consumer/NSConsumerCommon.c +++ b/service/notification/src/consumer/NSConsumerCommon.c @@ -211,6 +211,7 @@ NSMessage_consumer * NSCopyMessage(NSMessage_consumer * msg) newMsg->mId = OICStrdup(msg->mId); newMsg->mTitle = OICStrdup(msg->mTitle); newMsg->mContentText = OICStrdup(msg->mContentText); + newMsg->mSource = OICStrdup(msg->mSource); newMsg->addr = (OCDevAddr *)OICMalloc(sizeof(OCDevAddr)); if (!newMsg->addr) { @@ -237,6 +238,11 @@ void NSRemoveMessage(NSMessage_consumer * msg) OICFree(msg->mContentText); msg->mContentText = NULL; } + if (msg->mSource) + { + OICFree(msg->mSource); + msg->mSource = NULL; + } if (msg->addr) { OICFree(msg->addr); diff --git a/service/notification/src/consumer/NSConsumerCommon.h b/service/notification/src/consumer/NSConsumerCommon.h index f4074fe..6832009 100644 --- a/service/notification/src/consumer/NSConsumerCommon.h +++ b/service/notification/src/consumer/NSConsumerCommon.h @@ -59,6 +59,7 @@ typedef struct //Optional char * mContentText; + char * mSource; OCDevAddr * addr; char * syncUri; diff --git a/service/notification/src/consumer/NSConsumerInterface.c b/service/notification/src/consumer/NSConsumerInterface.c index 558a7d3..f5ced3d 100644 --- a/service/notification/src/consumer/NSConsumerInterface.c +++ b/service/notification/src/consumer/NSConsumerInterface.c @@ -170,6 +170,12 @@ NSResult NSDropNSObject(NSMessage * obj) obj->mContentText = NULL; } + if (obj->mSource) + { + OICFree(obj->mSource); + obj->mSource = NULL; + } + OICFree(obj); return NS_OK; diff --git a/service/notification/src/consumer/NSConsumerNotification.c b/service/notification/src/consumer/NSConsumerNotification.c index 62fc71e..766ea11 100644 --- a/service/notification/src/consumer/NSConsumerNotification.c +++ b/service/notification/src/consumer/NSConsumerNotification.c @@ -171,6 +171,7 @@ NSMessage_consumer * NSBuildOICNotification(OCClientResponse * clientResponse) retNoti->mId = NULL; retNoti->mTitle = NULL; retNoti->mContentText = NULL; + retNoti->mSource = NULL; OCRepPayload * payload = (OCRepPayload *)clientResponse->payload; if (!OCRepPayloadGetPropString(payload, NS_ATTRIBUTE_ID, &retNoti->mId)) @@ -182,11 +183,13 @@ NSMessage_consumer * NSBuildOICNotification(OCClientResponse * clientResponse) OCRepPayloadGetPropString(payload, NS_ATTRIBUTE_TITLE, &retNoti->mTitle); OCRepPayloadGetPropString(payload, NS_ATTRIBUTE_TEXT, &retNoti->mContentText); + OCRepPayloadGetPropString(payload, NS_ATTRIBUTE_SOURCE, &retNoti->mSource); NS_LOG_V(DEBUG, "Msg Address : %s", clientResponse->addr->addr); NS_LOG_V(DEBUG, "Msg ID : %s", retNoti->mId); NS_LOG_V(DEBUG, "Msg Title : %s", retNoti->mTitle); NS_LOG_V(DEBUG, "Msg Content : %s", retNoti->mContentText); + NS_LOG_V(DEBUG, "Msg Source : %s", retNoti->mSource); retNoti->addr = (OCDevAddr *)OICMalloc(sizeof(OCDevAddr)); memcpy(retNoti->addr, clientResponse->addr, sizeof(OCDevAddr)); -- 2.7.4