Add "Source" attribute in NSMessage Resource
authorYounghyunJoo <yh_.joo@samsung.com>
Thu, 26 May 2016 00:32:08 +0000 (09:32 +0900)
committerUze Choi <uzchoi@samsung.com>
Thu, 26 May 2016 05:17:58 +0000 (05:17 +0000)
- source attribute contains message generation information(where it comes)

Change-Id: Ibea94aed6044a18ba5d989cdc5aca7e109400ee9
Signed-off-by: YounghyunJoo <yh_.joo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/8339
Reviewed-by: Hun-je Yeon <hunje.yeon@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/notification/examples/linux/notificationconsumer.c
service/notification/src/common/NSUtil.c
service/notification/src/consumer/NSConsumerCommon.c
service/notification/src/consumer/NSConsumerCommon.h
service/notification/src/consumer/NSConsumerInterface.c
service/notification/src/consumer/NSConsumerNotification.c

index 85810bd..328bfbe 100644 (file)
@@ -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);
 }
index ce6aae2..7f074cf 100755 (executable)
@@ -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;
 }
 
index 1cc11aa..2f37bea 100644 (file)
@@ -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);
index f4074fe..6832009 100644 (file)
@@ -59,6 +59,7 @@ typedef struct
 
     //Optional
     char * mContentText;
+    char * mSource;
 
     OCDevAddr * addr;
     char * syncUri;
index 558a7d3..f5ced3d 100644 (file)
@@ -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;
index 62fc71e..766ea11 100644 (file)
@@ -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));