2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include "NotificationLine.h"
19 #include <Commons/Exception.h>
22 namespace Notification {
24 NotificationLine::NotificationLine() :
28 LoggerD("created by constructor");
31 NotificationLine::~NotificationLine()
35 NotificationLine::NotificationLine(notification_h noti, int index):
39 LoggerD("create by notification");
42 NotificationLine::NotificationLine(notification_h noti, int index, std::string &info, std::string &subInfo):
48 LoggerD("create by notification with data" );
51 std::string NotificationLine::getInformation() const
54 if (m_notiHandle && m_index >= 0)
56 LoggerD("index = " << m_index);
58 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
62 type = NOTIFICATION_TEXT_TYPE_INFO_1;
65 type = NOTIFICATION_TEXT_TYPE_INFO_2;
68 type = NOTIFICATION_TEXT_TYPE_INFO_3;
71 type = NOTIFICATION_TEXT_TYPE_NONE;
76 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
78 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
84 LoggerD(" info " << strInfo);
95 void NotificationLine::setInformation(const std::string &info)
97 if (m_notiHandle && m_index >= 0)
100 LoggerD(" index : " << idx);
101 LoggerD(" info : " << info);
102 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
107 type = NOTIFICATION_TEXT_TYPE_INFO_1;
110 type = NOTIFICATION_TEXT_TYPE_INFO_2;
113 type = NOTIFICATION_TEXT_TYPE_INFO_3;
116 type = NOTIFICATION_TEXT_TYPE_NONE;
119 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
121 if (getInformation().compare(info))
123 if (notification_set_text(m_notiHandle, type, info.c_str(),
124 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
126 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
128 setUpdatedFlag(true);
138 std::string NotificationLine::getSubInformation() const
141 if (m_notiHandle && m_index >= 0)
144 LoggerD(" index : " << index);
146 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
150 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
153 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
156 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
159 type = NOTIFICATION_TEXT_TYPE_NONE;
162 char *subInfo = NULL;
164 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
166 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
169 std::string strSubInfo;
171 strSubInfo = subInfo;
172 LoggerD(" sub info " << strSubInfo);
182 void NotificationLine::setSubInformation(const std::string &subInfo)
184 if (m_notiHandle && m_index >= 0)
187 LoggerD(" index : " << idx);
188 LoggerD(" input value : " << subInfo);
189 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
194 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
197 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
200 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
203 type = NOTIFICATION_TEXT_TYPE_NONE;
206 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
208 if (getSubInformation().compare(subInfo))
210 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
211 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
213 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
215 setUpdatedFlag(true);
225 void NotificationLine::setUpdatedFlag(bool flag)
230 bool NotificationLine::getUpdatedFlag()