This patch include,
1. Add extraInfo field in NSMessage.
2. Modify logic for related sendMessage.
second patch include,
modify setting Message payload.
third and fourth patch include,
add defence code for double free.
Change-Id: I2dcfaa9cf9bc0e42b1c0aaff83de99819433f01e
Signed-off-by: jaesick.shin <jaesick.shin@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11975
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
(cherry picked from commit
4ef1e3f85db4980d9e4d316c98bef3f2ac67c8e3)
Reviewed-on: https://gerrit.iotivity.org/gerrit/12449
#define _NS_COMMON_H_
#include <stdint.h>
#define _NS_COMMON_H_
#include <stdint.h>
#define NS_UUID_STRING_SIZE 37
#define NS_UUID_STRING_SIZE 37
char * sourceName;
NSMediaContents * mediaContents;
char * topic;
char * sourceName;
NSMediaContents * mediaContents;
char * topic;
+ OCRepPayload * extraInfo;
NSFreeMalloc(&(obj->sourceName));
NSFreeMalloc(&(obj->topic));
NSFreeMediaContents(obj->mediaContents);
NSFreeMalloc(&(obj->sourceName));
NSFreeMalloc(&(obj->topic));
NSFreeMediaContents(obj->mediaContents);
+ OCRepPayloadDestroy(obj->extraInfo);
OICFree(obj);
return NS_OK;
OICFree(obj);
return NS_OK;
newMsg->topic = OICStrdup(copyMsg->topic);
}
newMsg->topic = OICStrdup(copyMsg->topic);
}
+ if (copyMsg->extraInfo)
+ {
+ newMsg->extraInfo = OCRepPayloadClone(copyMsg->extraInfo);
+ }
+
msg->sourceName = NULL;
msg->mediaContents = NULL;
msg->topic = NULL;
msg->sourceName = NULL;
msg->mediaContents = NULL;
msg->topic = NULL;
{
NS_LOG(DEBUG, "NSSetMessagePayload - IN");
{
NS_LOG(DEBUG, "NSSetMessagePayload - IN");
- *msgPayload = OCRepPayloadCreate();
+ *msgPayload = msg->extraInfo != NULL ? msg->extraInfo : OCRepPayloadCreate();
NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_TEXT, msg->contentText);
NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_SOURCE, msg->sourceName);
NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_TOPIC_NAME, msg->topic);
NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_TEXT, msg->contentText);
NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_SOURCE, msg->sourceName);
NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_TOPIC_NAME, msg->topic);
+
+ if (msg->mediaContents)
- NSDuplicateSetPropertyString(msgPayload,
- NS_ATTRIBUTE_ICON_IMAGE, msg->mediaContents->iconImage);
+ NSDuplicateSetPropertyString(msgPayload, NS_ATTRIBUTE_ICON_IMAGE,
+ msg->mediaContents->iconImage);
}
NS_LOG(DEBUG, "NSSetMessagePayload - OUT");
}
NS_LOG(DEBUG, "NSSetMessagePayload - OUT");
{
NS_LOG(ERROR, "fail to send message");
OCRepPayloadDestroy(payload);
{
NS_LOG(ERROR, "fail to send message");
OCRepPayloadDestroy(payload);
return NS_ERROR;
}
OCRepPayloadDestroy(payload);
return NS_ERROR;
}
OCRepPayloadDestroy(payload);
NS_LOG(DEBUG, "NSSendMessage - OUT");
NS_LOG(DEBUG, "NSSendMessage - OUT");