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.
19 #include <Commons/Exception.h>
21 #include <notification.h>
22 #include <appsvc/appsvc.h>
23 #include "StatusNotification.h"
24 #include <FilesystemUtils.h>
28 namespace Notification{
30 #define DEFAULT_ICON_PATH "/opt/share/icons/default/"
31 #define MAX_NOTIFICATION_LINE_LENGTH 2
32 #define MAX_THUMBNAIL_LENGTH 4
34 extern "C" int service_create_event(bundle *data, struct service_s **service);
35 extern "C" int service_to_bundle(service_h service, bundle **data);
38 static void service_bundle_iterator(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
40 service_h service = (service_h)user_data;
41 LogDebug("key = " << key);
42 LogDebug(" type = " << type);
43 void *basic_val = NULL;
44 size_t basic_size = 0;
46 if (bundle_keyval_type_is_array((bundle_keyval_t*)kv))
52 bundle_keyval_get_basic_val((bundle_keyval_t*)kv, &basic_val, &basic_size);
54 service_add_extra_data(service, key, );
59 StatusNotification::StatusNotification(NotificationType statusType) :
64 notification_type_e type = NOTIFICATION_TYPE_NONE;
66 LogDebug("statusType =" << statusType);
67 setNotiType(statusType);
69 if (statusType == NOTI_TYPE_SIMPLE || statusType == NOTI_TYPE_MUTIPLE || statusType == NOTI_TYPE_THUMBNAIL)
71 type = NOTIFICATION_TYPE_NOTI;
73 else if ( statusType == NOTI_TYPE_ONGOING || statusType == NOTI_TYPE_PROGRESS)
75 type = NOTIFICATION_TYPE_ONGOING;
79 LogDebug(" invalide noti type");
80 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Error : noti type");
83 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
85 LogDebug("Notification Type : " << type);
87 notification_h noti = NULL;
88 noti = notification_create(type); //create notificatin.
91 LogDebug("noti =" << noti);
92 setNotificationHandle((void*)noti);
93 setNotificationState(NOTI_STATE_CREATED);
94 if ( statusType == NOTI_TYPE_PROGRESS)
96 notification_update_progress(noti, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
99 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
100 m_thumbs = StringArrayPtr(new StringArray());
104 StatusNotification::StatusNotification(void* noti) :
109 LogDebug("noti : " << noti);
110 notification_h notification = (notification_h)noti;
114 NotificationType type = NOTI_TYPE_NONE;
115 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
116 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
118 notification_get_type(notification, ¬i_type);
119 notification_get_layout(notification, ¬i_layout);
121 if ( noti_type == NOTIFICATION_TYPE_NOTI )
123 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
124 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
126 type = NOTI_TYPE_SIMPLE;
128 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
130 type = NOTI_TYPE_THUMBNAIL;
133 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
135 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
137 type = NOTI_TYPE_ONGOING;
139 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
141 type = NOTI_TYPE_PROGRESS;
145 LogDebug(" notification type =" << type);
147 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
148 setNotificationHandle((void*)notification);
150 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
151 m_thumbs = StringArrayPtr(new StringArray());
153 setNotificationLines();
154 setNotificationState(NOTI_STATE_CREATED);
156 if ( type == NOTI_TYPE_PROGRESS)
158 notification_update_progress(notification, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
164 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
165 LogDebug("ret = " << ret);
166 if (ret == NOTIFICATION_ERROR_NONE)
167 //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
169 LogDebug(" bundle = " << bSvc);
172 LogDebug("bundle is valid");
173 int ret = service_create_event(bSvc, &m_service);
174 if (ret != SERVICE_ERROR_NONE)
176 LogDebug("Service Create Event Error");
177 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
180 bundle_free(bSvc); //bundle free
186 StatusNotification::StatusNotification(int privID) :
191 LogDebug("priv ID : " << privID);
193 notification_h notification = notification_load( NULL, privID);
194 LogDebug(" notification " << notification);
198 NotificationType type = NOTI_TYPE_NONE;
199 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
200 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
202 notification_get_type(notification, ¬i_type);
203 notification_get_layout(notification, ¬i_layout);
205 if ( noti_type == NOTIFICATION_TYPE_NOTI )
207 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
208 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
210 type = NOTI_TYPE_SIMPLE;
212 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
214 type = NOTI_TYPE_THUMBNAIL;
217 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
219 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
221 type = NOTI_TYPE_ONGOING;
223 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
225 type = NOTI_TYPE_PROGRESS;
229 LogDebug(" notification type =" << type);
231 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
232 setNotificationHandle((void*)notification);
234 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
235 m_thumbs = StringArrayPtr(new StringArray());
237 setNotificationLines();
238 setNotificationState(NOTI_STATE_CREATED);
243 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
244 LogDebug("ret = " << ret);
245 if (ret == NOTIFICATION_ERROR_NONE)
246 //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
248 LogDebug(" bundle = " << bSvc);
251 LogDebug("bundle is valid");
252 int ret = service_create_event(bSvc, &m_service);
253 if (ret != SERVICE_ERROR_NONE)
255 LogDebug("Service Create Event Error");
256 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
259 //bundle_free(bSvc); //bundle free
265 LogDebug(" can't find notification");
266 ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "Can't find noti");
272 StatusNotification::~StatusNotification()
274 LogDebug(" notification = " << m_notiHandle);
278 if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
280 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
284 LogDebug(" service = " << m_service);
285 if (m_service != NULL)
287 service_destroy(m_service);
297 static bool service_extra_data_cb(service_h service, const char *key, void *user_data)
303 if (user_data != NULL && key != NULL)
305 LogDebug("user data & key is existed");
307 DeviceAPI::Application::ApplicationControlPtr* appControl =
308 (DeviceAPI::Application::ApplicationControlPtr*)(user_data);
310 DeviceAPI::Application::ApplicationControlDataPtr data(new DeviceAPI::Application::ApplicationControlData());
311 LogDebug("key = " << key);
312 std::string keyStr = key;
313 std::vector<std::string> keyValue;
316 if (service_get_extra_data_array((*appControl)->getService_h(), key, &value, &length) == SERVICE_ERROR_NONE)
318 LogDebug("extra_data_array length = " << length);
320 if (value != NULL && length != 0)
322 LogDebug("extra_data_length = " << length);
324 for (index = 0; index < length; index++)
326 LogDebug("Value=" << value[index]);
327 keyValue.push_back(value[index]);
330 data->setValue(keyValue);
331 (*appControl)->addAppControlData(data);
341 static bool service_extra_data_delete_cb(service_h service, const char *key, void *user_data)
346 LogDebug("del key = " << key);
348 if (service_remove_extra_data(service, key) != SERVICE_ERROR_NONE)
350 LogDebug("remove extra data failed");
361 int StatusNotification::getID()
366 notification_get_id(m_notiHandle, NULL, &id);
371 return -1; // notification not inserted yet.
375 time_t StatusNotification::getPostedTime()
377 LogDebug("get m_notiHandle = " << m_notiHandle);
379 time_t postedTime = 0;
383 if (notification_get_insert_time(m_notiHandle, &postedTime) != NOTIFICATION_ERROR_NONE)
385 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification posted time error");
389 LogDebug("posted Time =" << ctime(&postedTime));
393 std::string StatusNotification::getTitle()
399 if (notification_get_text(m_notiHandle,NOTIFICATION_TEXT_TYPE_TITLE, &title) != NOTIFICATION_ERROR_NONE)
401 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
404 std::string notiTitle(title);
409 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
413 void StatusNotification::setTitle(std::string title)
415 LogDebug("Title : " << title);
418 LogDebug("get Title : " << getTitle());
419 if((getTitle()).compare(title)) //different value.
421 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_TITLE, title.c_str(),
422 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
424 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification title error");
427 setUpdatedFlag(true);
431 LogDebug(" title = " << title << " getTitle = " << getTitle());
436 LogDebug("noti Handle is NULL");
437 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
441 std::string StatusNotification::getContent()
443 LogDebug("get Content : " << m_notiHandle);
446 char *content = NULL;
448 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) != NOTIFICATION_ERROR_NONE)
450 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification Content error");
453 LogDebug(" get Content : " << content);
457 std::string notiContent(content);
462 return std::string("");
467 LogDebug("noti Handle is NULL");
468 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
473 void StatusNotification::setContent(std::string content)
475 LogDebug("Content : " << content);
478 if((getContent()).compare(content)) //different value.
480 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, content.c_str(),
481 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
483 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification content error");
485 setUpdatedFlag(true);
490 LogDebug("noti Handle is NULL");
491 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
495 std::string StatusNotification::getIconPath()
499 char *iconPath = NULL;
501 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON, &iconPath) != NOTIFICATION_ERROR_NONE)
503 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification icon path error");
506 std::string notiIconPath(iconPath);
507 LogDebug("icon Path = " << iconPath);
509 //if icon path invalid, return empty string.
510 if ( notiIconPath.find(DEFAULT_ICON_PATH,0) == std::string::npos)
514 return std::string("");
519 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
523 void StatusNotification::setIconPath(const std::string& iconPath)
527 LogDebug("icon path = " << iconPath << " origin icon path = " << getIconPath());
528 if( getIconPath().compare(iconPath))
530 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON, iconPath.c_str()) != NOTIFICATION_ERROR_NONE)
532 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification icon error");
534 setUpdatedFlag(true);
539 LogDebug("noti Handle is NULL");
540 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
544 std::string StatusNotification::getSoundPath()
548 const char *soundPath = NULL;
549 notification_sound_type_e type = NOTIFICATION_SOUND_TYPE_NONE;
551 if (notification_get_sound(m_notiHandle, &type, &soundPath) != NOTIFICATION_ERROR_NONE)
553 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sound error");
556 LogDebug(" sound type = " << type << " path = " << soundPath);
558 if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
560 LogDebug("soundPath = " << soundPath);
561 return std::string(soundPath);
565 return std::string("");
570 LogDebug("noti Handle is NULL");
571 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
575 void StatusNotification::setSoundPath(const std::string& sound)
579 LogDebug("sound path = " << sound << " origin sound path = " << getSoundPath());
581 if( getSoundPath().compare(sound))
583 if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_USER_DATA, sound.c_str()) != NOTIFICATION_ERROR_NONE)
585 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
587 setUpdatedFlag(true);
592 LogDebug("noti Handle is NULL");
593 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
597 bool StatusNotification::getDefaultVibration()
601 notification_vibration_type_e vib_type;
602 if (notification_get_vibration(m_notiHandle, &vib_type, NULL) != NOTIFICATION_ERROR_NONE)
604 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
607 if (vib_type == NOTIFICATION_VIBRATION_TYPE_DEFAULT)
618 LogDebug("noti Handle is NULL");
624 void StatusNotification::setDefaultVibration(const bool& vibration)
628 notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
630 if (getDefaultVibration() != vibration)
634 vib_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
637 if (notification_set_vibration(m_notiHandle, vib_type , NULL) != NOTIFICATION_ERROR_NONE)
639 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
641 setUpdatedFlag(true);
646 LogDebug("noti Handle is NULL");
647 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
652 double StatusNotification::getProgressValue()
658 NotificationProgressType progressType = getProgressType();
660 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
662 if (notification_get_size(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
664 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification size error");
667 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
669 if (notification_get_progress(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
671 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
676 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
681 LogDebug("noti Handle is NULL");
688 void StatusNotification::setProgressValue(const double &progressValue)
693 NotificationProgressType progressType = getProgressType();
694 LogDebug("Progress Type : " << progressType);
696 double val = getProgressValue();
697 LogDebug("Progress value = " << progressValue << " origin Progress Value =" << val);
699 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
701 if (notification_set_size(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
703 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification size error");
706 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
709 if (notification_set_progress(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
711 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification progress error");
716 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
721 LogDebug("noti Handle is NULL");
722 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
726 std::string StatusNotification::getSubIconPath()
730 char *subIconPath = NULL;
732 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &subIconPath) != NOTIFICATION_ERROR_NONE)
734 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub icon error");
737 std::string notiSubIconPath;
739 notiSubIconPath = subIconPath;
740 return notiSubIconPath;
744 return std::string("");
749 void StatusNotification::setSubIconPath(const std::string& subIconPath)
753 LogDebug(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
755 if( getSubIconPath().compare(subIconPath))
757 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON_SUB, subIconPath.c_str()) != NOTIFICATION_ERROR_NONE)
759 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
761 setUpdatedFlag(true);
766 LogDebug("noti Handle is NULL");
767 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
771 std::vector<std::string> StatusNotification::getInformations()
774 std::vector<std::string> infos;
780 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_1, &info) != NOTIFICATION_ERROR_NONE)
782 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
786 infos.push_back(info); //info 1
788 infos.push_back(std::string("")); // insert empty String
791 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_2, &info) != NOTIFICATION_ERROR_NONE)
793 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
797 infos.push_back(info); //info 2
799 infos.push_back(std::string("")); // insert empty String
802 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_3, &info) != NOTIFICATION_ERROR_NONE)
804 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
808 infos.push_back(info); //info 3
810 infos.push_back(std::string("")); // insert empty String
817 LogDebug("noti Handle is NULL");
818 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
824 std::string StatusNotification::getInformation(int index)
828 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
832 type = NOTIFICATION_TEXT_TYPE_INFO_1;
835 type = NOTIFICATION_TEXT_TYPE_INFO_2;
838 type = NOTIFICATION_TEXT_TYPE_INFO_3;
841 type = NOTIFICATION_TEXT_TYPE_NONE;
845 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
847 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
853 LogDebug(" info " << strInfo);
859 LogDebug("noti Handle is NULL");
860 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
865 void StatusNotification::setInformations( std::vector<std::string>& infos)
870 std::vector<std::string>::iterator it;
873 for (it = infos.begin(); it != infos.end(); ++it)
875 std::string str = *it;
876 LogDebug(" Info : " << str);
878 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
882 type = NOTIFICATION_TEXT_TYPE_INFO_1;
885 type = NOTIFICATION_TEXT_TYPE_INFO_2;
888 type = NOTIFICATION_TEXT_TYPE_INFO_3;
891 type = NOTIFICATION_TEXT_TYPE_NONE;
894 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
896 if (getInformation(idx).compare(str))
898 if (notification_set_text(m_notiHandle, type, str.c_str(),
899 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
901 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification information error");
903 setUpdatedFlag(true);
913 LogDebug("noti Handle is NULL");
914 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
919 void StatusNotification::setInformation( const std::string& info, int index)
925 LogDebug(" index : " << idx);
926 LogDebug(" log : " << info);
927 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
932 type = NOTIFICATION_TEXT_TYPE_INFO_1;
935 type = NOTIFICATION_TEXT_TYPE_INFO_2;
938 type = NOTIFICATION_TEXT_TYPE_INFO_3;
941 type = NOTIFICATION_TEXT_TYPE_NONE;
944 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
946 if (getInformation(idx).compare(info))
948 if (notification_set_text(m_notiHandle, type, info.c_str(),
949 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
951 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
953 setUpdatedFlag(true);
959 std::vector<std::string> StatusNotification::getSubInformations()
961 std::vector<std::string> subInfos;
965 char *subInfo = NULL;
966 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, &subInfo) != NOTIFICATION_ERROR_NONE)
968 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub background error");
972 subInfos.push_back(subInfo);
974 subInfos.push_back(std::string());
977 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_2, &subInfo) != NOTIFICATION_ERROR_NONE)
979 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
983 subInfos.push_back(subInfo);
985 subInfos.push_back(std::string());
989 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_3, &subInfo) != NOTIFICATION_ERROR_NONE)
991 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
995 subInfos.push_back(subInfo);
997 subInfos.push_back(std::string());
1004 LogDebug("noti Handle is NULL");
1005 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1011 std::string StatusNotification::getSubInformation(int index)
1016 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1020 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1023 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1026 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1029 type = NOTIFICATION_TEXT_TYPE_NONE;
1032 char *subInfo = NULL;
1034 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
1036 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1039 std::string strSubInfo;
1041 strSubInfo = subInfo;
1042 LogDebug(" subInfo " << strSubInfo);
1048 LogDebug("noti Handle is NULL");
1049 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1054 void StatusNotification::setSubInformations(std::vector<std::string>& subInfos)
1058 std::vector<std::string>::iterator it;
1061 for (it = subInfos.begin(); it < subInfos.end(); ++it)
1063 std::string str = *it;
1064 LogDebug(" sub Info : " << str);
1066 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1070 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1073 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1076 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1079 type = NOTIFICATION_TEXT_TYPE_NONE;
1082 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1084 if (getSubInformation(idx).compare(str))
1086 if (notification_set_text(m_notiHandle, type, str.c_str(),
1087 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1089 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification text error");
1091 setUpdatedFlag(true);
1100 LogDebug("noti Handle is NULL");
1101 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1106 void StatusNotification::setSubInformation( const std::string& subInfo, int index)
1112 LogDebug(" index : " << idx);
1113 LogDebug(" log : " << subInfo);
1114 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1119 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1122 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1125 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1128 type = NOTIFICATION_TEXT_TYPE_NONE;
1131 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1133 if (getSubInformation(idx).compare(subInfo))
1135 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
1136 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1138 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1140 setUpdatedFlag(true);
1147 std::vector<std::string> StatusNotification::getThumbnails()
1149 std::vector<std::string> thumbs;
1153 if ( !thumbs.empty() )
1157 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1159 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1162 thumbs.push_back(thumb);
1164 thumbs.push_back(std::string("")); //set empty
1167 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1169 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1172 thumbs.push_back(thumb);
1174 thumbs.push_back(std::string("")); //set empty
1177 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1179 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1183 thumbs.push_back(thumb);
1185 thumbs.push_back(std::string("")); //set empty
1188 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1190 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1194 thumbs.push_back(thumb);
1196 thumbs.push_back(std::string("")); //set empty
1199 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1201 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1205 thumbs.push_back(thumb);
1207 thumbs.push_back(std::string("")); //set empty
1213 LogDebug("noti Handle is NULL");
1214 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1221 std::string StatusNotification::getThumbnail(int index)
1226 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1231 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1234 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1237 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1240 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1243 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1247 type = NOTIFICATION_IMAGE_TYPE_NONE;
1252 if (NOTIFICATION_IMAGE_TYPE_NONE != type && notification_get_image(m_notiHandle, type, &thumb) != NOTIFICATION_ERROR_NONE)
1254 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1257 std::string strThumb;
1262 LogDebug(" info " << strThumb);
1268 LogDebug("noti Handle is NULL");
1269 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1274 void StatusNotification::setThumbnails(std::vector<std::string>& thumbs)
1278 std::vector<std::string>::iterator it;
1281 for (it = thumbs.begin(); it < thumbs.end(); ++it)
1283 std::string str = *it;
1284 LogDebug(" thumbs : " << str);
1286 if ( idx < MAX_THUMBNAIL_LENGTH )
1287 setThumbnail(str, idx);
1289 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1293 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1296 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1299 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1302 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1305 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1308 type = NOTIFICATION_IMAGE_TYPE_NONE;
1311 if ( idx < MAX_THUMBNAIL_LENGTH )
1314 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1316 if (getThumbnail(idx).compare(str))
1318 if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
1320 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1322 setUpdatedFlag(true);
1331 if ( idx < MAX_THUMBNAIL_LENGTH)
1333 setThumbnail("", idx); //set empty value
1340 LogDebug("noti Handle is NULL");
1341 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1346 void StatusNotification::setThumbnail( const std::string& thumb, int index)
1350 LogDebug(" index : " << index);
1351 LogDebug(" thumb : " << thumb);
1352 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1357 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1360 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1363 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1366 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1369 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1372 type = NOTIFICATION_IMAGE_TYPE_NONE;
1375 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1378 if (getThumbnail(index).compare(thumb))
1380 if (notification_set_image(m_notiHandle, type, thumb.c_str()) != NOTIFICATION_ERROR_NONE)
1382 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1384 setUpdatedFlag(true);
1391 void StatusNotification::setThumbnails(const StringArrayPtr &value)
1394 m_thumbs = StringArrayPtr(new StringArray());
1404 std::vector<std::string>::iterator it;
1407 for (it = m_thumbs->begin(); it < m_thumbs->end(); ++it)
1409 std::string str = *it;
1410 LogDebug(" thumbs : " << str);
1411 DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, soundPath);
1412 str = path->getFullPath();
1414 LogDebug(" thumbs : " << str);
1415 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1419 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1422 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1425 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1428 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1431 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1434 type = NOTIFICATION_IMAGE_TYPE_NONE;
1437 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1439 if (getThumbnail(idx).compare(str))
1441 if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
1443 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1445 setUpdatedFlag(true);
1459 StringArrayPtr StatusNotification::getThumbnails()
1464 if ( !m_thumbs->empty() )
1468 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1470 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1473 m_thumbs->push_back(thumb);
1475 m_thumbs->push_back(std::string("")); //set empty
1478 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1480 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1483 m_thumbs->push_back(thumb);
1485 m_thumbs->push_back(std::string("")); //set empty
1488 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1490 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1494 m_thumbs->push_back(thumb);
1496 m_thumbs->push_back(std::string("")); //set empty
1499 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1501 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1505 m_thumbs->push_back(thumb);
1507 m_thumbs->push_back(std::string("")); //set empty
1510 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1512 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1516 m_thumbs->push_back(thumb);
1518 m_thumbs->push_back(std::string("")); //set empty
1527 std::string StatusNotification::getBackground()
1531 char *background = NULL;
1533 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &background) != NOTIFICATION_ERROR_NONE)
1535 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
1538 std::string notiBackground;
1540 notiBackground = background;
1541 return notiBackground;
1545 LogDebug("noti Handle is NULL");
1546 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1551 void StatusNotification::setBackground(const std::string imagePath)
1555 if (getBackground().compare(imagePath))
1557 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_BACKGROUND, imagePath.c_str()) != NOTIFICATION_ERROR_NONE)
1559 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1561 setUpdatedFlag(true);
1566 LogDebug("noti Handle is NULL");
1567 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1571 unsigned int StatusNotification::getNumber()
1576 char *strNumber = NULL;
1578 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
1580 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
1584 std::istringstream(strNumber) >> number;
1586 LogDebug("number = " << number);
1594 LogDebug("noti Handle is NULL");
1599 void StatusNotification::setNumber(const unsigned int number)
1603 if(number!=getNumber())
1605 std::stringstream stream;
1607 if (stream.fail()) {
1608 ThrowMsg(WrtDeviceApis::Commons::UnknownException,
1609 "Couldn't convert e-mail account id");
1612 std::string strNumber = stream.str();
1613 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, strNumber.c_str(),
1614 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1616 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1618 setUpdatedFlag(true);
1623 LogDebug("noti Handle is NULL");
1624 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1630 void* StatusNotification::getNotificationHandle()
1632 return m_notiHandle;
1635 void StatusNotification::setNotificationHandle(void *handle)
1639 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
1641 LogDebug("handle = " << handle << " m_notiHandle = " << m_notiHandle);
1643 if (m_notiHandle != NULL)
1646 if ( notification_delete(m_notiHandle) != NOTIFICATION_ERROR_NONE)
1648 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification delete error");
1650 m_notiHandle = NULL;
1653 m_notiHandle = (notification_h)handle;
1656 void StatusNotification::setNotificationLines()
1658 if (m_notiHandle == NULL)
1660 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
1662 LogDebug("handle = " << m_notiHandle);
1664 if (getLinesNum() > 0)
1668 std::vector<std::string> infos = getInformations();
1669 std::vector<std::string> subInfos = getSubInformations();
1671 LogDebug("info size = " << infos.size());
1672 LogDebug("subInfo size = " << subInfos.size());
1674 std::vector<std::string>::iterator it;
1678 NotificationLineArrayPtr lines = getLines();
1680 for (it = infos.begin(); it < infos.end(); ++it)
1682 std::string info = *it;
1683 LogDebug(" Info : " << info);
1684 LogDebug("subInfo=" << subInfos[idx]);
1686 if (!(info.empty() && subInfos[idx].empty()))
1688 NotificationLinePtr line(new NotificationLine(m_notiHandle,idx,info,subInfos[idx]));
1689 lines->push_back(line);
1696 DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
1698 service_h service = NULL;
1699 char *tempStr = NULL;
1701 DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
1706 appControl->setService_h(m_service);
1708 if(service_get_operation(m_service, &tempStr) == SERVICE_ERROR_NONE)
1710 LogDebug("Operation Str = " << tempStr);
1713 appControl->setOperation(tempStr);
1720 if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
1722 LogDebug("Mime Str = " << tempStr);
1725 appControl->setMime(tempStr);
1732 if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
1734 LogDebug("Uri Str = " << tempStr);
1737 appControl->setUri(tempStr);
1743 if (service_get_category(m_service, &tempStr) == SERVICE_ERROR_NONE)
1745 LogDebug("Category Str = " << tempStr);
1748 appControl->setCategory(tempStr);
1755 if ( service_foreach_extra_data(m_service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
1757 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1764 Catch (WrtDeviceApis::Commons::Exception)
1778 if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
1780 ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
1785 ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
1792 if (m_service != NULL)
1794 retcode = service_clone(&service, m_service);
1796 if (retcode != SERVICE_ERROR_NONE)
1799 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
1801 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
1805 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
1807 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
1811 if (service == NULL)
1813 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");
1818 appControl->setService_h(service);
1821 int ret = service_get_operation(service, &tempStr);
1822 LogDebug("ret = " << ret);
1823 //if (service_get_operation(service, &tempStr) != SERVICE_ERROR_NONE)
1824 if(ret != SERVICE_ERROR_NONE)
1826 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service operation error");
1829 LogDebug("temp Str = " << tempStr);
1833 appControl->setOperation(tempStr);
1839 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service operation ok, but null");
1843 if (service_get_mime(service, &tempStr) == SERVICE_ERROR_NONE)
1847 appControl->setMime(tempStr);
1854 if (service_get_uri(service, &tempStr) == SERVICE_ERROR_NONE)
1858 appControl->setUri(tempStr);
1865 if ( service_foreach_extra_data(service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
1868 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1874 Catch (WrtDeviceApis::Commons::Exception)
1888 if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
1890 ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
1895 ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
1904 void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr appControl)
1907 LogDebug("Entered m_service : " << m_service);
1909 if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
1911 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
1915 LogDebug("getOperation : " << appControl->getOperation().c_str());
1916 if (appControl->getOperation().size() != 0)
1918 if (service_set_operation(m_service, appControl->getOperation().c_str()) != SERVICE_ERROR_NONE)
1920 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
1925 LogDebug("getUri : " << appControl->getUri().c_str());
1926 if (appControl->getUri().size() != 0)
1928 if (service_set_uri(m_service, appControl->getUri().c_str() ) != SERVICE_ERROR_NONE)
1930 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
1935 LogDebug("getMime : " << appControl->getMime().c_str());
1936 if (appControl->getMime().size() != 0)
1938 if (service_set_mime(m_service, appControl->getMime().c_str() ) != SERVICE_ERROR_NONE)
1940 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
1944 LogDebug("Category : " << appControl->getCategory().c_str());
1945 if (appControl->getCategory().size() != 0)
1947 if (service_set_category(m_service, appControl->getCategory().c_str() ) != SERVICE_ERROR_NONE)
1949 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
1954 if ( service_foreach_extra_data(m_service, service_extra_data_delete_cb, NULL) != SERVICE_ERROR_NONE)
1956 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1959 std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = appControl->getAppControlDataArray();
1962 LogDebug (" App Control Datas Count : " << appControlDataArray.size());
1964 DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
1966 for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
1968 DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
1969 std::string key = appControlData->getKey();
1970 LogDebug(" key : " << key);
1975 std::vector<std::string> value = appControlDataArray[index]->getValue();
1976 const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
1978 for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
1980 arrayValue[indexArray] = (char*)value[indexArray].c_str();
1981 LogDebug( " value : " << arrayValue[indexArray]);
1984 const char* strKey = key.c_str();
1985 LogDebug( " value size: " << value.size());
1986 if (service_add_extra_data_array(m_service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
1988 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
1995 bundle *bundle_data=NULL;
1997 if(service_to_bundle(m_service, &bundle_data) != SERVICE_ERROR_NONE)
1999 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service get bundle");
2004 notification_set_execute_option(m_notiHandle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
2005 NULL,NULL, bundle_data);
2006 //bundle_free(bundle_data);
2013 void StatusNotification::setApplicationId(const std::string& appId)
2015 LogDebug("m_service = " << m_service << " appId = " << appId);
2018 LogDebug("m_service = " << m_service);
2019 if (service_create(&m_service) != SERVICE_ERROR_NONE)
2021 LogDebug("Create Service Failed..");
2022 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2028 if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
2030 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");
2036 service_h service = NULL;
2037 char* operation = NULL;
2038 LogDebug("Entered : " << appId);
2040 LogDebug("m_service = " << m_service);
2041 if (m_service != NULL)
2043 retcode = service_clone(&service, m_service);
2044 if (retcode != SERVICE_ERROR_NONE)
2046 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
2048 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
2052 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
2055 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
2061 if (service_create(&service) != SERVICE_ERROR_NONE)
2063 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2069 if (service_get_operation(service, &operation) != SERVICE_ERROR_NONE)
2071 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service get operation error");
2079 else if (service_set_operation(service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
2081 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
2084 if (service_set_app_id(service, appId.c_str())!= SERVICE_ERROR_NONE)
2086 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");
2089 if (m_service != NULL)
2091 service_destroy(m_service);
2095 m_service = service; //set service.
2100 std::string StatusNotification::getApplicationId()
2102 std::string retString;
2103 service_h service = NULL;
2104 char* appIdStr = NULL;
2106 if (m_service != NULL)
2109 retcode = service_clone(&service, m_service);
2111 if (retcode != SERVICE_ERROR_NONE)
2113 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
2115 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
2119 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
2121 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
2125 if (service == NULL)
2127 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");
2132 if (service != NULL)
2134 if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
2136 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get a appId error");
2139 if (appIdStr != NULL)
2141 retString = appIdStr;
2145 LogDebug(retString);
2150 service_h StatusNotification::getService()
2156 NotificationLineArrayPtr StatusNotification::getLines() const
2161 int StatusNotification::getLinesNum() const
2163 return m_lines->size();
2166 void StatusNotification::setLines(const NotificationLineArrayPtr &value)
2168 LogDebug("setlines");
2171 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
2177 NotificationLineArray::iterator iter;
2179 for(iter = m_lines->begin(); iter != m_lines->end(); iter++)
2181 NotificationLinePtr line = *iter;
2182 LogDebug("info = " << line->getInformation());
2183 LogDebug("sub info = " << line->getSubInformation());
2185 if ( index < MAX_NOTIFICATION_LINE_LENGTH)
2187 setInformation(line->getInformation(),index);
2188 setSubInformation(line->getSubInformation(),index);
2193 //clean empty solt.`
2194 for ( ;index < MAX_NOTIFICATION_LINE_LENGTH; index++)
2196 setInformation("", index);
2197 setSubInformation("", index);
2202 void StatusNotification::addLine(const NotificationLinePtr &value)
2204 m_lines->push_back(value);
2207 void StatusNotification::clearLines()