1 //******************************************************************
\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
7 // Licensed under the Apache License, Version 2.0 (the "License");
\r
8 // you may not use this file except in compliance with the License.
\r
9 // You may obtain a copy of the License at
\r
11 // http://www.apache.org/licenses/LICENSE-2.0
\r
13 // Unless required by applicable law or agreed to in writing, software
\r
14 // distributed under the License is distributed on an "AS IS" BASIS,
\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 // See the License for the specific language governing permissions and
\r
17 // limitations under the License.
\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
21 #include "NSMessage.h"
\r
23 #include "NSUtils.h"
\r
30 NSMessage::NSMessage(::NSMessage *msg)
\r
33 m_type = NSMessage::NSMessageType::NS_MESSAGE_ALERT;
\r
35 m_mediaContents = new NSMediaContents();
\r
39 m_messageId = msg->messageId;
\r
40 m_providerId.assign(msg->providerId, NS_UTILS_UUID_STRING_SIZE);
\r
42 m_type = (NSMessageType)msg->type;
\r
44 if ((msg->dateTime != nullptr) && strlen(msg->dateTime))
\r
45 m_time.assign(msg->dateTime, strlen(msg->dateTime));
\r
49 if ((msg->title != nullptr) && strlen(msg->title))
\r
50 m_title.assign(msg->title, strlen(msg->title));
\r
52 if ((msg->contentText != nullptr) && strlen(msg->contentText))
\r
53 m_contentText.assign(msg->contentText, strlen(msg->contentText));
\r
55 if ((msg->sourceName != nullptr) && strlen(msg->sourceName))
\r
56 m_sourceName.assign(msg->sourceName, strlen(msg->sourceName));
\r
58 if (msg->mediaContents != nullptr)
\r
59 if ((msg->mediaContents->iconImage != nullptr) && strlen(msg->mediaContents->iconImage))
\r
60 m_mediaContents->setIconImage(msg->mediaContents->iconImage);
\r
62 if ((msg->topic != nullptr) && strlen(msg->topic))
\r
63 m_topic.assign(msg->topic, strlen(msg->topic));
\r
68 NSMessage::~NSMessage()
\r
70 if (m_mediaContents != nullptr)
\r
71 delete m_mediaContents;
\r
74 uint64_t NSMessage::getMessageId() const
\r
79 std::string NSMessage::getProviderId() const
\r
81 return m_providerId;
\r
84 NSMessage::NSMessageType NSMessage::getType() const
\r
89 std::string NSMessage::getTime() const
\r
94 uint64_t NSMessage::getTTL() const
\r
99 std::string NSMessage::getTitle() const
\r
104 std::string NSMessage::getContentText() const
\r
106 return m_contentText;
\r
109 std::string NSMessage::getSourceName() const
\r
111 return m_sourceName;
\r
114 NSMediaContents *NSMessage::getMediaContents() const
\r
116 return m_mediaContents;
\r
119 std::string NSMessage::getTopic() const
\r
124 void NSMessage::setType(const NSMessageType &type)
\r
129 void NSMessage::setTime(const std::string &time)
\r
134 void NSMessage::setTTL(const uint64_t &ttl)
\r
139 void NSMessage::setTitle(const std::string &title)
\r
144 void NSMessage::setContentText(const std::string &contextText)
\r
146 m_contentText = contextText;
\r
149 void NSMessage::setSourceName(const std::string &sourceName)
\r
151 m_sourceName = sourceName;
\r
154 void NSMessage::setMediaContents(NSMediaContents *mediaContents)
\r
156 m_mediaContents = mediaContents;
\r
159 void NSMessage::setTopic(const std::string &topic)
\r