{
newMsg->topic = OICStrdup(msg->topic);
}
-
- // TODO change to copy function.
- newMsg->mediaContents = msg->mediaContents;
+ if (msg->mediaContents)
+ {
+ newMsg->mediaContents = (NSMediaContents *)OICMalloc(sizeof(NSMediaContents));
+ NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(
+ newMsg->mediaContents, NULL, NSRemoveMessage(newMsg));
+ newMsg->mediaContents->iconImage =
+ (char *)OICMalloc(sizeof(char)*strlen(msg->mediaContents->iconImage));
+ NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(
+ newMsg->mediaContents->iconImage, NULL, NSRemoveMessage(newMsg));
+ memcpy(newMsg->mediaContents->iconImage, msg->mediaContents->iconImage,
+ strlen(msg->mediaContents->iconImage));
+ }
return newMsg;
}
NSOICFree(msg->dateTime);
NSOICFree(msg->topic);
- // TODO change to remove function.
+ if (msg->mediaContents)
+ {
+ NSOICFree(msg->mediaContents->iconImage);
+ }
NSOICFree(msg->mediaContents);
NSOICFree(msg);
OCRepPayloadGetPropString(payload, NS_ATTRIBUTE_DATETIME, &retMsg->dateTime);
OCRepPayloadGetPropInt(payload, NS_ATTRIBUTE_TTL, (int64_t *)&retMsg->ttl);
+ char * icon = NULL;
+ OCRepPayloadGetPropString(payload, NS_ATTRIBUTE_ICON_IMAGE, &icon);
+
+ if (icon)
+ {
+ NSMediaContents * contents = (NSMediaContents *)OICMalloc(sizeof(NSMediaContents));
+ if (contents)
+ {
+ contents->iconImage = icon;
+ retMsg->mediaContents = contents;
+ }
+ else
+ {
+ NSOICFree(icon);
+ }
+ }
+
NS_LOG_V(DEBUG, "Msg ID : %lld", (long long int)retMsg->messageId);
NS_LOG_V(DEBUG, "Msg Title : %s", retMsg->title);
NS_LOG_V(DEBUG, "Msg Content : %s", retMsg->contentText);