From: YounghyunJoo Date: Thu, 26 May 2016 00:32:08 +0000 (+0900) Subject: Add "Source" attribute in NSMessage Resource X-Git-Tag: 1.2.0+RC1~52^2~161 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=df7d996af4498a365e812e4e9e945fd859682d16;p=platform%2Fupstream%2Fiotivity.git 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 --- 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));