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/"
32 extern "C" int service_create_event(bundle *data, struct service_s **service);
35 static void service_bundle_iterator(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
37 service_h service = (service_h)user_data;
38 LogDebug("key = " << key);
39 LogDebug(" type = " << type);
40 void *basic_val = NULL;
41 size_t basic_size = 0;
43 if (bundle_keyval_type_is_array((bundle_keyval_t*)kv))
49 bundle_keyval_get_basic_val((bundle_keyval_t*)kv, &basic_val, &basic_size);
51 service_add_extra_data(service, key, );
56 StatusNotification::StatusNotification(NotificationType statusType) :
61 notification_type_e type = NOTIFICATION_TYPE_NONE;
63 LogDebug("statusType =" << statusType);
64 setNotiType(statusType);
66 if (statusType == NOTI_TYPE_SIMPLE || statusType == NOTI_TYPE_MUTIPLE || statusType == NOTI_TYPE_THUMBNAIL)
68 type = NOTIFICATION_TYPE_NOTI;
70 else if ( statusType == NOTI_TYPE_ONGOING || statusType == NOTI_TYPE_PROGRESS)
72 type = NOTIFICATION_TYPE_ONGOING;
76 LogDebug(" invalide noti type");
77 ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Error : noti type");
80 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
82 LogDebug("Notification Type : " << type);
84 notification_h noti = NULL;
85 noti = notification_create(type); //create notificatin.
88 LogDebug("noti =" << noti);
89 setNotificationHandle((void*)noti);
90 setNotificationState(NOTI_STATE_CREATED);
92 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
93 m_thumbs = StringArrayPtr(new StringArray());
97 StatusNotification::StatusNotification(void* noti) :
102 LogDebug("noti : " << noti);
103 notification_h notification = (notification_h)noti;
107 NotificationType type = NOTI_TYPE_NONE;
108 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
109 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
111 notification_get_type(notification, ¬i_type);
112 notification_get_layout(notification, ¬i_layout);
114 if ( noti_type == NOTIFICATION_TYPE_NOTI )
116 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
117 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
119 type = NOTI_TYPE_SIMPLE;
121 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
123 type = NOTI_TYPE_THUMBNAIL;
126 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
128 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
130 type = NOTI_TYPE_ONGOING;
132 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
134 type = NOTI_TYPE_PROGRESS;
138 LogDebug(" notification type =" << type);
140 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
141 setNotificationHandle((void*)notification);
143 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
144 m_thumbs = StringArrayPtr(new StringArray());
146 setNotificationLines();
147 setNotificationState(NOTI_STATE_CREATED);
152 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
153 LogDebug("ret = " << ret);
154 if (ret == NOTIFICATION_ERROR_NONE)
155 //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
157 LogDebug(" bundle = " << bSvc);
160 LogDebug("bundle is valid");
161 int ret = service_create_event(bSvc, &m_service);
162 if (ret != SERVICE_ERROR_NONE)
164 LogDebug("Service Create Event Error");
165 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
169 const char *tmpStr = NULL;
170 if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
172 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
175 tmpStr = appsvc_get_operation(bSvc);
178 LogDebug("operation = " << tmpStr);
181 if (service_set_operation(m_service, tmpStr) != SERVICE_ERROR_NONE)
183 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
186 else if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
188 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
195 if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
196 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
199 tmpStr = appsvc_get_uri(bSvc);
202 LogDebug("uri = " << tmpStr);
203 if (service_set_uri(m_service, tmpStr) != SERVICE_ERROR_NONE)
205 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
210 tmpStr = appsvc_get_mime(bSvc);
213 LogDebug("mime = " << tmpStr);
214 if (service_set_mime(m_service, tmpStr) != SERVICE_ERROR_NONE)
216 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
221 tmpStr = appsvc_get_category(bSvc);
224 LogDebug("category = " << tmpStr);
225 if (service_set_category(m_service, tmpStr) != SERVICE_ERROR_NONE)
227 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set category error");
233 bundle_foreach(bSvc, service_bundle_iterator, m_service);
235 bundle_free(bSvc); //bundle free
241 StatusNotification::StatusNotification(int privID) :
246 LogDebug("priv ID : " << privID);
248 notification_h notification = notification_load( NULL, privID);
249 LogDebug(" notification " << notification);
253 NotificationType type = NOTI_TYPE_NONE;
254 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
255 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
257 notification_get_type(notification, ¬i_type);
258 notification_get_layout(notification, ¬i_layout);
260 if ( noti_type == NOTIFICATION_TYPE_NOTI )
262 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
263 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
265 type = NOTI_TYPE_SIMPLE;
267 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
269 type = NOTI_TYPE_THUMBNAIL;
272 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
274 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
276 type = NOTI_TYPE_ONGOING;
278 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
280 type = NOTI_TYPE_PROGRESS;
284 LogDebug(" notification type =" << type);
286 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
287 setNotificationHandle((void*)notification);
289 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
290 m_thumbs = StringArrayPtr(new StringArray());
292 setNotificationLines();
293 setNotificationState(NOTI_STATE_CREATED);
298 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
299 LogDebug("ret = " << ret);
300 if (ret == NOTIFICATION_ERROR_NONE)
301 //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
303 LogDebug(" bundle = " << bSvc);
306 LogDebug("bundle is valid");
307 int ret = service_create_event(bSvc, &m_service);
308 if (ret != SERVICE_ERROR_NONE)
310 LogDebug("Service Create Event Error");
311 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
314 //bundle_free(bSvc); //bundle free
320 LogDebug(" can't find notification");
321 ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "Can't find noti");
327 StatusNotification::~StatusNotification()
329 LogDebug(" notification = " << m_notiHandle);
333 if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
335 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
339 LogDebug(" service = " << m_service);
340 if (m_service != NULL)
342 service_destroy(m_service);
352 static bool service_extra_data_cb(service_h service, const char *key, void *user_data)
357 if (user_data != NULL && key != NULL)
361 DeviceAPI::Application::ApplicationControlPtr* appControl =
362 (DeviceAPI::Application::ApplicationControlPtr*)(user_data);
364 DeviceAPI::Application::ApplicationControlDataPtr data(new DeviceAPI::Application::ApplicationControlData());
365 std::string keyStr = key;
366 std::vector<std::string> keyValue;
369 if (service_get_extra_data_array((*appControl)->getService_h(), key, &value, &length) == SERVICE_ERROR_NONE)
371 if (value != NULL && length != 0)
374 for (index = 0; index < length; index++)
376 keyValue.push_back(value[index]);
379 data->setValue(keyValue);
380 (*appControl)->addAppControlData(data);
388 int StatusNotification::getID()
393 notification_get_id(m_notiHandle, NULL, &id);
398 return -1; // notification not inserted yet.
402 time_t StatusNotification::getPostedTime()
404 LogDebug("get m_notiHandle = " << m_notiHandle);
406 time_t postedTime = 0;
410 if (notification_get_insert_time(m_notiHandle, &postedTime) != NOTIFICATION_ERROR_NONE)
412 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification posted time error");
416 LogDebug("posted Time =" << ctime(&postedTime));
420 std::string StatusNotification::getTitle()
426 if (notification_get_text(m_notiHandle,NOTIFICATION_TEXT_TYPE_TITLE, &title) != NOTIFICATION_ERROR_NONE)
428 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
431 std::string notiTitle(title);
436 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
440 void StatusNotification::setTitle(std::string title)
442 LogDebug("Title : " << title);
445 LogDebug("get Title : " << getTitle());
446 if((getTitle()).compare(title)) //different value.
448 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_TITLE, title.c_str(),
449 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
451 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification title error");
454 setUpdatedFlag(true);
458 LogDebug(" title = " << title << " getTitle = " << getTitle());
463 LogDebug("noti Handle is NULL");
464 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
468 std::string StatusNotification::getContent()
470 LogDebug("get Content : " << m_notiHandle);
473 char *content = NULL;
475 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) != NOTIFICATION_ERROR_NONE)
477 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification Content error");
480 LogDebug(" get Content : " << content);
484 std::string notiContent(content);
489 return std::string("");
494 LogDebug("noti Handle is NULL");
495 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
500 void StatusNotification::setContent(std::string content)
502 LogDebug("Content : " << content);
505 if((getContent()).compare(content)) //different value.
507 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, content.c_str(),
508 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
510 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification content error");
512 setUpdatedFlag(true);
517 LogDebug("noti Handle is NULL");
518 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
522 std::string StatusNotification::getIconPath()
526 char *iconPath = NULL;
528 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON, &iconPath) != NOTIFICATION_ERROR_NONE)
530 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification icon path error");
533 std::string notiIconPath(iconPath);
534 LogDebug("icon Path = " << iconPath);
536 //if icon path invalid, return empty string.
537 if ( notiIconPath.find(DEFAULT_ICON_PATH,0) == std::string::npos)
541 return std::string("");
546 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
550 void StatusNotification::setIconPath(const std::string& iconPath)
554 LogDebug("icon path = " << iconPath << " origin icon path = " << getIconPath());
555 if( getIconPath().compare(iconPath))
557 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON, iconPath.c_str()) != NOTIFICATION_ERROR_NONE)
559 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification icon error");
561 setUpdatedFlag(true);
566 LogDebug("noti Handle is NULL");
567 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
571 std::string StatusNotification::getSoundPath()
575 const char *soundPath = NULL;
576 notification_sound_type_e type = NOTIFICATION_SOUND_TYPE_NONE;
578 if (notification_get_sound(m_notiHandle, &type, &soundPath) != NOTIFICATION_ERROR_NONE)
580 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sound error");
583 LogDebug(" sound type = " << type << " path = " << soundPath);
585 if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
587 LogDebug("soundPath = " << soundPath);
588 return std::string(soundPath);
592 return std::string("");
597 LogDebug("noti Handle is NULL");
598 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
602 void StatusNotification::setSoundPath(const std::string& sound)
606 LogDebug("sound path = " << sound << " origin sound path = " << getSoundPath());
608 if( getSoundPath().compare(sound))
610 if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_USER_DATA, sound.c_str()) != NOTIFICATION_ERROR_NONE)
612 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
614 setUpdatedFlag(true);
619 LogDebug("noti Handle is NULL");
620 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
624 bool StatusNotification::getDefaultVibration()
628 notification_vibration_type_e vib_type;
629 if (notification_get_vibration(m_notiHandle, &vib_type, NULL) != NOTIFICATION_ERROR_NONE)
631 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
634 if (vib_type == NOTIFICATION_VIBRATION_TYPE_DEFAULT)
645 LogDebug("noti Handle is NULL");
651 void StatusNotification::setDefaultVibration(const bool& vibration)
655 notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
657 if (getDefaultVibration() != vibration)
661 vib_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
664 if (notification_set_vibration(m_notiHandle, vib_type , NULL) != NOTIFICATION_ERROR_NONE)
666 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
668 setUpdatedFlag(true);
673 LogDebug("noti Handle is NULL");
674 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
679 double StatusNotification::getProgressValue()
685 NotificationProgressType progressType = getProgressType();
687 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
689 if (notification_get_size(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
691 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification size error");
694 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
696 if (notification_get_progress(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
698 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
703 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
708 LogDebug("noti Handle is NULL");
715 void StatusNotification::setProgressValue(const double &progressValue)
720 NotificationProgressType progressType = getProgressType();
721 LogDebug("Progress Type : " << progressType);
723 double val = getProgressValue();
724 LogDebug("Progress value = " << progressValue << " origin Progress Value =" << val);
726 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
728 if (notification_set_size(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
730 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification size error");
733 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
736 if (notification_set_progress(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
738 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification progress error");
743 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
748 LogDebug("noti Handle is NULL");
749 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
753 std::string StatusNotification::getSubIconPath()
757 char *subIconPath = NULL;
759 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &subIconPath) != NOTIFICATION_ERROR_NONE)
761 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub icon error");
764 std::string notiSubIconPath;
766 notiSubIconPath = subIconPath;
767 return notiSubIconPath;
771 return std::string("");
776 void StatusNotification::setSubIconPath(const std::string& subIconPath)
780 LogDebug(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
782 if( getSubIconPath().compare(subIconPath))
784 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON_SUB, subIconPath.c_str()) != NOTIFICATION_ERROR_NONE)
786 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
788 setUpdatedFlag(true);
793 LogDebug("noti Handle is NULL");
794 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
798 std::vector<std::string> StatusNotification::getInformations()
801 std::vector<std::string> infos;
807 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_1, &info) != NOTIFICATION_ERROR_NONE)
809 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
813 infos.push_back(info); //info 1
815 infos.push_back(std::string("")); // insert empty String
818 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_2, &info) != NOTIFICATION_ERROR_NONE)
820 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
824 infos.push_back(info); //info 2
826 infos.push_back(std::string("")); // insert empty String
829 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_3, &info) != NOTIFICATION_ERROR_NONE)
831 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
835 infos.push_back(info); //info 3
837 infos.push_back(std::string("")); // insert empty String
844 LogDebug("noti Handle is NULL");
845 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
851 std::string StatusNotification::getInformation(int index)
855 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
859 type = NOTIFICATION_TEXT_TYPE_INFO_1;
862 type = NOTIFICATION_TEXT_TYPE_INFO_2;
865 type = NOTIFICATION_TEXT_TYPE_INFO_3;
868 type = NOTIFICATION_TEXT_TYPE_NONE;
872 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
874 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
880 LogDebug(" info " << strInfo);
886 LogDebug("noti Handle is NULL");
887 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
892 void StatusNotification::setInformations( std::vector<std::string>& infos)
897 std::vector<std::string>::iterator it;
900 for (it = infos.begin(); it != infos.end(); ++it)
902 std::string str = *it;
903 LogDebug(" Info : " << str);
905 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
909 type = NOTIFICATION_TEXT_TYPE_INFO_1;
912 type = NOTIFICATION_TEXT_TYPE_INFO_2;
915 type = NOTIFICATION_TEXT_TYPE_INFO_3;
918 type = NOTIFICATION_TEXT_TYPE_NONE;
921 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
923 if (getInformation(idx).compare(str))
925 if (notification_set_text(m_notiHandle, type, str.c_str(),
926 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
928 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification information error");
930 setUpdatedFlag(true);
940 LogDebug("noti Handle is NULL");
941 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
946 void StatusNotification::setInformation( const std::string& info, int index)
952 LogDebug(" index : " << idx);
953 LogDebug(" log : " << info);
954 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
959 type = NOTIFICATION_TEXT_TYPE_INFO_1;
962 type = NOTIFICATION_TEXT_TYPE_INFO_2;
965 type = NOTIFICATION_TEXT_TYPE_INFO_3;
968 type = NOTIFICATION_TEXT_TYPE_NONE;
971 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
973 if (getInformation(idx).compare(info))
975 if (notification_set_text(m_notiHandle, type, info.c_str(),
976 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
978 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
980 setUpdatedFlag(true);
986 std::vector<std::string> StatusNotification::getSubInformations()
988 std::vector<std::string> subInfos;
992 char *subInfo = NULL;
993 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, &subInfo) != NOTIFICATION_ERROR_NONE)
995 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub background error");
999 subInfos.push_back(subInfo);
1001 subInfos.push_back(std::string());
1004 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_2, &subInfo) != NOTIFICATION_ERROR_NONE)
1006 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1010 subInfos.push_back(subInfo);
1012 subInfos.push_back(std::string());
1016 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_3, &subInfo) != NOTIFICATION_ERROR_NONE)
1018 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1022 subInfos.push_back(subInfo);
1024 subInfos.push_back(std::string());
1031 LogDebug("noti Handle is NULL");
1032 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1038 std::string StatusNotification::getSubInformation(int index)
1043 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1047 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1050 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1053 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1056 type = NOTIFICATION_TEXT_TYPE_NONE;
1059 char *subInfo = NULL;
1061 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
1063 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1066 std::string strSubInfo;
1068 strSubInfo = subInfo;
1069 LogDebug(" subInfo " << strSubInfo);
1075 LogDebug("noti Handle is NULL");
1076 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1081 void StatusNotification::setSubInformations(std::vector<std::string>& subInfos)
1085 std::vector<std::string>::iterator it;
1088 for (it = subInfos.begin(); it < subInfos.end(); ++it)
1090 std::string str = *it;
1091 LogDebug(" sub Info : " << str);
1093 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1097 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1100 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1103 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1106 type = NOTIFICATION_TEXT_TYPE_NONE;
1109 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1111 if (getSubInformation(idx).compare(str))
1113 if (notification_set_text(m_notiHandle, type, str.c_str(),
1114 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1116 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification text error");
1118 setUpdatedFlag(true);
1127 LogDebug("noti Handle is NULL");
1128 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1133 void StatusNotification::setSubInformation( const std::string& subInfo, int index)
1139 LogDebug(" index : " << idx);
1140 LogDebug(" log : " << subInfo);
1141 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1146 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1149 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1152 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1155 type = NOTIFICATION_TEXT_TYPE_NONE;
1158 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1160 if (getSubInformation(idx).compare(subInfo))
1162 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
1163 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1165 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1167 setUpdatedFlag(true);
1174 std::vector<std::string> StatusNotification::getThumbnails()
1176 std::vector<std::string> thumbs;
1180 if ( !thumbs.empty() )
1184 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1186 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1189 thumbs.push_back(thumb);
1191 thumbs.push_back(std::string("")); //set empty
1194 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1196 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1199 thumbs.push_back(thumb);
1201 thumbs.push_back(std::string("")); //set empty
1204 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1206 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1210 thumbs.push_back(thumb);
1212 thumbs.push_back(std::string("")); //set empty
1215 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1217 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1221 thumbs.push_back(thumb);
1223 thumbs.push_back(std::string("")); //set empty
1226 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1228 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1232 thumbs.push_back(thumb);
1234 thumbs.push_back(std::string("")); //set empty
1240 LogDebug("noti Handle is NULL");
1241 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1248 std::string StatusNotification::getThumbnail(int index)
1253 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1258 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1261 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1264 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1267 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1270 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1274 type = NOTIFICATION_IMAGE_TYPE_NONE;
1279 if (NOTIFICATION_IMAGE_TYPE_NONE != type && notification_get_image(m_notiHandle, type, &thumb) != NOTIFICATION_ERROR_NONE)
1281 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1284 std::string strThumb;
1289 LogDebug(" info " << strThumb);
1295 LogDebug("noti Handle is NULL");
1296 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1301 void StatusNotification::setThumbnails(std::vector<std::string>& thumbs)
1305 std::vector<std::string>::iterator it;
1308 for (it = thumbs.begin(); it < thumbs.end(); ++it)
1310 std::string str = *it;
1311 LogDebug(" thumbs : " << str);
1313 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1317 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1320 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1323 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1326 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1329 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1332 type = NOTIFICATION_IMAGE_TYPE_NONE;
1335 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1337 if (getThumbnail(idx).compare(str))
1339 if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
1341 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1343 setUpdatedFlag(true);
1353 LogDebug("noti Handle is NULL");
1354 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1359 void StatusNotification::setThumbnail( const std::string& thumb, int index)
1363 LogDebug(" index : " << index);
1364 LogDebug(" thumb : " << thumb);
1365 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1370 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1373 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1376 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1379 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1382 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1385 type = NOTIFICATION_IMAGE_TYPE_NONE;
1388 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1391 if (getThumbnail(index).compare(thumb))
1393 if (notification_set_image(m_notiHandle, type, thumb.c_str()) != NOTIFICATION_ERROR_NONE)
1395 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1397 setUpdatedFlag(true);
1404 void StatusNotification::setThumbnails(const StringArrayPtr &value)
1407 m_thumbs = StringArrayPtr(new StringArray());
1417 std::vector<std::string>::iterator it;
1420 for (it = m_thumbs->begin(); it < m_thumbs->end(); ++it)
1422 std::string str = *it;
1423 LogDebug(" thumbs : " << str);
1424 DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, soundPath);
1425 str = path->getFullPath();
1427 LogDebug(" thumbs : " << str);
1428 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1432 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1435 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1438 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1441 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1444 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1447 type = NOTIFICATION_IMAGE_TYPE_NONE;
1450 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1452 if (getThumbnail(idx).compare(str))
1454 if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
1456 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1458 setUpdatedFlag(true);
1472 StringArrayPtr StatusNotification::getThumbnails()
1477 if ( !m_thumbs->empty() )
1481 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1483 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1486 m_thumbs->push_back(thumb);
1488 m_thumbs->push_back(std::string("")); //set empty
1491 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1493 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1496 m_thumbs->push_back(thumb);
1498 m_thumbs->push_back(std::string("")); //set empty
1501 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1503 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1507 m_thumbs->push_back(thumb);
1509 m_thumbs->push_back(std::string("")); //set empty
1512 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1514 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1518 m_thumbs->push_back(thumb);
1520 m_thumbs->push_back(std::string("")); //set empty
1523 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1525 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1529 m_thumbs->push_back(thumb);
1531 m_thumbs->push_back(std::string("")); //set empty
1540 std::string StatusNotification::getBackground()
1544 char *background = NULL;
1546 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &background) != NOTIFICATION_ERROR_NONE)
1548 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
1551 std::string notiBackground;
1553 notiBackground = background;
1554 return notiBackground;
1558 LogDebug("noti Handle is NULL");
1559 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1564 void StatusNotification::setBackground(const std::string imagePath)
1568 if (getBackground().compare(imagePath))
1570 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_BACKGROUND, imagePath.c_str()) != NOTIFICATION_ERROR_NONE)
1572 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1574 setUpdatedFlag(true);
1579 LogDebug("noti Handle is NULL");
1580 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1584 unsigned int StatusNotification::getNumber()
1589 char *strNumber = NULL;
1591 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
1593 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
1597 std::istringstream(strNumber) >> number;
1599 LogDebug("number = " << number);
1607 LogDebug("noti Handle is NULL");
1612 void StatusNotification::setNumber(const unsigned int number)
1616 if(number!=getNumber())
1618 std::stringstream stream;
1620 if (stream.fail()) {
1621 ThrowMsg(WrtDeviceApis::Commons::UnknownException,
1622 "Couldn't convert e-mail account id");
1625 std::string strNumber = stream.str();
1626 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, strNumber.c_str(),
1627 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1629 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1631 setUpdatedFlag(true);
1636 LogDebug("noti Handle is NULL");
1637 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1643 void* StatusNotification::getNotificationHandle()
1645 return m_notiHandle;
1648 void StatusNotification::setNotificationHandle(void *handle)
1652 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
1654 LogDebug("handle = " << handle << " m_notiHandle = " << m_notiHandle);
1656 if (m_notiHandle != NULL)
1659 if ( notification_delete(m_notiHandle) != NOTIFICATION_ERROR_NONE)
1661 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification delete error");
1663 m_notiHandle = NULL;
1666 m_notiHandle = (notification_h)handle;
1669 void StatusNotification::setNotificationLines()
1671 if (m_notiHandle == NULL)
1673 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
1675 LogDebug("handle = " << m_notiHandle);
1677 if (getLinesNum() > 0)
1681 std::vector<std::string> infos = getInformations();
1682 std::vector<std::string> subInfos = getSubInformations();
1684 LogDebug("info size = " << infos.size());
1685 LogDebug("subInfo size = " << subInfos.size());
1687 std::vector<std::string>::iterator it;
1691 NotificationLineArrayPtr lines = getLines();
1693 for (it = infos.begin(); it < infos.end(); ++it)
1695 std::string info = *it;
1696 LogDebug(" Info : " << info);
1697 LogDebug("subInfo=" << subInfos[idx]);
1699 if (!(info.empty() && subInfos[idx].empty()))
1701 NotificationLinePtr line(new NotificationLine(m_notiHandle,idx,info,subInfos[idx]));
1702 lines->push_back(line);
1709 DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
1711 service_h service = NULL;
1714 char *tempStr = NULL;
1716 DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
1722 appControl->setService_h(m_service);
1725 int ret = service_get_operation(m_service, &tempStr);
1726 LogDebug("ret = " << ret);
1727 //if (service_get_operation(service, &tempStr) != SERVICE_ERROR_NONE)
1728 if(ret != SERVICE_ERROR_NONE)
1730 LogDebug(" Opertation is Empty");
1732 LogDebug("temp Str = " << tempStr);
1736 appControl->setOperation(tempStr);
1742 if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
1746 appControl->setMime(tempStr);
1753 if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
1757 appControl->setUri(tempStr);
1764 if ( service_foreach_extra_data(m_service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
1766 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1773 Catch (WrtDeviceApis::Commons::Exception)
1787 if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
1789 ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
1794 ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
1801 if (m_service != NULL)
1803 retcode = service_clone(&service, m_service);
1805 if (retcode != SERVICE_ERROR_NONE)
1808 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
1810 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
1814 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
1816 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
1820 if (service == NULL)
1822 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");
1827 appControl->setService_h(service);
1830 int ret = service_get_operation(service, &tempStr);
1831 LogDebug("ret = " << ret);
1832 //if (service_get_operation(service, &tempStr) != SERVICE_ERROR_NONE)
1833 if(ret != SERVICE_ERROR_NONE)
1835 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service operation error");
1838 LogDebug("temp Str = " << tempStr);
1842 appControl->setOperation(tempStr);
1848 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service operation ok, but null");
1852 if (service_get_mime(service, &tempStr) == SERVICE_ERROR_NONE)
1856 appControl->setMime(tempStr);
1863 if (service_get_uri(service, &tempStr) == SERVICE_ERROR_NONE)
1867 appControl->setUri(tempStr);
1874 if ( service_foreach_extra_data(service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
1877 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1883 Catch (WrtDeviceApis::Commons::Exception)
1897 if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
1899 ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
1904 ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
1913 void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr appControl)
1916 LogDebug("Entered m_service : " << m_service);
1918 if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
1920 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
1924 LogDebug("getOperation : " << appControl->getOperation().c_str());
1925 if (appControl->getOperation().size() != 0)
1927 if (service_set_operation(m_service, appControl->getOperation().c_str()) != SERVICE_ERROR_NONE)
1929 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
1934 LogDebug("getUri : " << appControl->getUri().c_str());
1935 if (appControl->getUri().size() != 0)
1937 if (service_set_uri(m_service, appControl->getUri().c_str() ) != SERVICE_ERROR_NONE)
1939 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
1944 LogDebug("getMime : " << appControl->getMime().c_str());
1945 if (appControl->getMime().size() != 0)
1947 if (service_set_mime(m_service, appControl->getMime().c_str() ) != SERVICE_ERROR_NONE)
1949 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
1953 LogDebug("Category : " << appControl->getCategory().c_str());
1954 if (appControl->getCategory().size() != 0)
1956 if (service_set_category(m_service, appControl->getCategory().c_str() ) != SERVICE_ERROR_NONE)
1958 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
1962 std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = appControl->getAppControlDataArray();
1963 size_t index = 0, indexArray = 0;
1965 LogDebug (" App Control Datas Count : " << appControlDataArray.size());
1967 DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
1969 for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
1971 DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
1972 std::string key = appControlData->getKey();
1973 LogDebug(" key : " << key);
1978 std::vector<std::string> value = appControlDataArray[index]->getValue();
1979 const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
1981 for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
1983 arrayValue[indexArray] = (char*)value[indexArray].c_str();
1984 LogDebug( " value : " << arrayValue[indexArray]);
1987 const char* strKey = key.c_str();
1988 if ( value.size() == 1)
1990 if (service_add_extra_data(m_service, strKey, arrayValue[0]) != SERVICE_ERROR_NONE)
1992 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
1997 if (service_add_extra_data_array(m_service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
1999 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
2010 LogDebug("Entered");
2011 service_h service = NULL;
2012 int retcode = SERVICE_ERROR_NONE;
2014 LogDebug("m_service : " << m_service);
2016 if(service == NULL && service_create(&service) != SERVICE_ERROR_NONE)
2018 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2024 LogDebug("getOperation : " << appControl->getOperation().c_str());
2025 if (appControl->getOperation().size() != 0)
2027 if (service_set_operation(service, appControl->getOperation().c_str()) != SERVICE_ERROR_NONE)
2029 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
2034 if (appControl->getUri().size() != 0)
2036 if (service_set_uri(service, appControl->getUri().c_str() ) != SERVICE_ERROR_NONE)
2038 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
2043 if (appControl->getMime().size() != 0)
2045 if (service_set_mime(service, appControl->getMime().c_str() ) != SERVICE_ERROR_NONE)
2047 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
2051 std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = appControl->getAppControlDataArray();
2052 size_t index = 0, indexArray = 0;
2054 LogDebug (" App Control Datas Count : " << appControlDataArray.size());
2056 DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
2058 for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
2060 DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
2061 std::string key = appControlData->getKey();
2062 LogDebug(" key : " << key);
2067 std::vector<std::string> value = appControlDataArray[index]->getValue();
2068 const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
2070 for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
2072 arrayValue[indexArray] = (char*)value[indexArray].c_str();
2073 LogDebug( " value : " << arrayValue[indexArray]);
2076 const char* strKey = key.c_str();
2077 if ( value.size() == 1)
2079 if (service_add_extra_data(service, strKey, arrayValue[0]) != SERVICE_ERROR_NONE)
2081 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
2086 if (service_add_extra_data_array(service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
2088 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
2098 if (m_service != NULL) //service destory.
2100 service_destroy(m_service);
2104 m_service = service;
2108 LogDebug(" Service is NULL ");
2111 LogDebug("m_service : " << m_service);
2115 void StatusNotification::setApplicationId(const std::string& appId)
2118 LogDebug("m_service = " << m_service << " appId = " << appId);
2121 LogDebug("m_service = " << m_service);
2122 if (service_create(&m_service) != SERVICE_ERROR_NONE)
2124 LogDebug("Create Service Failed..");
2125 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2131 if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
2133 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");
2139 service_h service = NULL;
2140 char* operation = NULL;
2141 LogDebug("Entered : " << appId);
2143 LogDebug("m_service = " << m_service);
2144 if (m_service != NULL)
2146 retcode = service_clone(&service, m_service);
2147 if (retcode != SERVICE_ERROR_NONE)
2149 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
2151 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
2155 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
2158 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
2164 if (service_create(&service) != SERVICE_ERROR_NONE)
2166 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2172 if (service_get_operation(service, &operation) != SERVICE_ERROR_NONE)
2174 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service get operation error");
2182 else if (service_set_operation(service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
2184 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
2187 if (service_set_app_id(service, appId.c_str())!= SERVICE_ERROR_NONE)
2189 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");
2192 if (m_service != NULL)
2194 service_destroy(m_service);
2198 m_service = service; //set service.
2203 std::string StatusNotification::getApplicationId()
2205 std::string retString;
2206 service_h service = NULL;
2207 char* appIdStr = NULL;
2209 if (m_service != NULL)
2212 retcode = service_clone(&service, m_service);
2214 if (retcode != SERVICE_ERROR_NONE)
2216 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
2218 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
2222 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
2224 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
2228 if (service == NULL)
2230 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");
2235 if (service != NULL)
2237 if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
2239 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get a appId error");
2242 if (appIdStr != NULL)
2244 retString = appIdStr;
2248 LogDebug(retString);
2253 service_h StatusNotification::getService()
2259 NotificationLineArrayPtr StatusNotification::getLines() const
2264 int StatusNotification::getLinesNum() const
2266 return m_lines->size();
2269 void StatusNotification::setLines(const NotificationLineArrayPtr &value)
2271 LogDebug("setlines");
2274 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
2280 NotificationLineArray::iterator iter;
2282 for(iter = m_lines->begin(); iter != m_lines->end(); iter++)
2284 NotificationLinePtr line = *iter;
2285 LogDebug("info = " << line->getInformation());
2286 LogDebug("sub info = " << line->getSubInformation());
2288 setInformation(line->getInformation(),index);
2289 setSubInformation(line->getSubInformation(),index);
2298 void StatusNotification::addLine(const NotificationLinePtr &value)
2300 m_lines->push_back(value);
2303 void StatusNotification::clearLines()