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);
95 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
96 m_thumbs = StringArrayPtr(new StringArray());
100 StatusNotification::StatusNotification(void* noti) :
105 LogDebug("noti : " << noti);
106 notification_h notification = (notification_h)noti;
110 NotificationType type = NOTI_TYPE_NONE;
111 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
112 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
114 notification_get_type(notification, ¬i_type);
115 notification_get_layout(notification, ¬i_layout);
117 if ( noti_type == NOTIFICATION_TYPE_NOTI )
119 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
120 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
122 type = NOTI_TYPE_SIMPLE;
124 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
126 type = NOTI_TYPE_THUMBNAIL;
129 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
131 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
133 type = NOTI_TYPE_ONGOING;
135 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
137 type = NOTI_TYPE_PROGRESS;
141 LogDebug(" notification type =" << type);
143 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
144 setNotificationHandle((void*)notification);
146 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
147 m_thumbs = StringArrayPtr(new StringArray());
149 setNotificationLines();
150 setNotificationState(NOTI_STATE_CREATED);
155 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
156 LogDebug("ret = " << ret);
157 if (ret == NOTIFICATION_ERROR_NONE)
158 //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
160 LogDebug(" bundle = " << bSvc);
163 LogDebug("bundle is valid");
164 int ret = service_create_event(bSvc, &m_service);
165 if (ret != SERVICE_ERROR_NONE)
167 LogDebug("Service Create Event Error");
168 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
172 const char *tmpStr = NULL;
173 if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
175 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
178 tmpStr = appsvc_get_operation(bSvc);
181 LogDebug("operation = " << tmpStr);
184 if (service_set_operation(m_service, tmpStr) != SERVICE_ERROR_NONE)
186 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
189 else if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
191 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
198 if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
199 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
202 tmpStr = appsvc_get_uri(bSvc);
205 LogDebug("uri = " << tmpStr);
206 if (service_set_uri(m_service, tmpStr) != SERVICE_ERROR_NONE)
208 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
213 tmpStr = appsvc_get_mime(bSvc);
216 LogDebug("mime = " << tmpStr);
217 if (service_set_mime(m_service, tmpStr) != SERVICE_ERROR_NONE)
219 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
224 tmpStr = appsvc_get_category(bSvc);
227 LogDebug("category = " << tmpStr);
228 if (service_set_category(m_service, tmpStr) != SERVICE_ERROR_NONE)
230 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set category error");
236 bundle_foreach(bSvc, service_bundle_iterator, m_service);
238 bundle_free(bSvc); //bundle free
244 StatusNotification::StatusNotification(int privID) :
249 LogDebug("priv ID : " << privID);
251 notification_h notification = notification_load( NULL, privID);
252 LogDebug(" notification " << notification);
256 NotificationType type = NOTI_TYPE_NONE;
257 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
258 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
260 notification_get_type(notification, ¬i_type);
261 notification_get_layout(notification, ¬i_layout);
263 if ( noti_type == NOTIFICATION_TYPE_NOTI )
265 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
266 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
268 type = NOTI_TYPE_SIMPLE;
270 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
272 type = NOTI_TYPE_THUMBNAIL;
275 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
277 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
279 type = NOTI_TYPE_ONGOING;
281 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
283 type = NOTI_TYPE_PROGRESS;
287 LogDebug(" notification type =" << type);
289 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
290 setNotificationHandle((void*)notification);
292 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
293 m_thumbs = StringArrayPtr(new StringArray());
295 setNotificationLines();
296 setNotificationState(NOTI_STATE_CREATED);
301 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
302 LogDebug("ret = " << ret);
303 if (ret == NOTIFICATION_ERROR_NONE)
304 //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
306 LogDebug(" bundle = " << bSvc);
309 LogDebug("bundle is valid");
310 int ret = service_create_event(bSvc, &m_service);
311 if (ret != SERVICE_ERROR_NONE)
313 LogDebug("Service Create Event Error");
314 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
317 //bundle_free(bSvc); //bundle free
323 LogDebug(" can't find notification");
324 ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "Can't find noti");
330 StatusNotification::~StatusNotification()
332 LogDebug(" notification = " << m_notiHandle);
336 if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
338 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
342 LogDebug(" service = " << m_service);
343 if (m_service != NULL)
345 service_destroy(m_service);
355 static bool service_extra_data_cb(service_h service, const char *key, void *user_data)
361 if (user_data != NULL && key != NULL)
363 LogDebug("user data & key is existed");
365 DeviceAPI::Application::ApplicationControlPtr* appControl =
366 (DeviceAPI::Application::ApplicationControlPtr*)(user_data);
368 DeviceAPI::Application::ApplicationControlDataPtr data(new DeviceAPI::Application::ApplicationControlData());
369 LogDebug("key = " << key);
370 std::string keyStr = key;
371 std::vector<std::string> keyValue;
374 if (service_get_extra_data_array((*appControl)->getService_h(), key, &value, &length) == SERVICE_ERROR_NONE)
376 LogDebug("extra_data_array length = " << length);
378 if (value != NULL && length != 0)
380 LogDebug("extra_data_length = " << length);
382 for (index = 0; index < length; index++)
384 LogDebug("Value=" << value[index]);
385 keyValue.push_back(value[index]);
388 data->setValue(keyValue);
389 (*appControl)->addAppControlData(data);
399 static bool service_extra_data_delete_cb(service_h service, const char *key, void *user_data)
404 LogDebug("del key = " << key);
406 if (service_remove_extra_data(service, key) != SERVICE_ERROR_NONE)
408 LogDebug("remove extra data failed");
419 int StatusNotification::getID()
424 notification_get_id(m_notiHandle, NULL, &id);
429 return -1; // notification not inserted yet.
433 time_t StatusNotification::getPostedTime()
435 LogDebug("get m_notiHandle = " << m_notiHandle);
437 time_t postedTime = 0;
441 if (notification_get_insert_time(m_notiHandle, &postedTime) != NOTIFICATION_ERROR_NONE)
443 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification posted time error");
447 LogDebug("posted Time =" << ctime(&postedTime));
451 std::string StatusNotification::getTitle()
457 if (notification_get_text(m_notiHandle,NOTIFICATION_TEXT_TYPE_TITLE, &title) != NOTIFICATION_ERROR_NONE)
459 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
462 std::string notiTitle(title);
467 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
471 void StatusNotification::setTitle(std::string title)
473 LogDebug("Title : " << title);
476 LogDebug("get Title : " << getTitle());
477 if((getTitle()).compare(title)) //different value.
479 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_TITLE, title.c_str(),
480 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
482 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification title error");
485 setUpdatedFlag(true);
489 LogDebug(" title = " << title << " getTitle = " << getTitle());
494 LogDebug("noti Handle is NULL");
495 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
499 std::string StatusNotification::getContent()
501 LogDebug("get Content : " << m_notiHandle);
504 char *content = NULL;
506 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) != NOTIFICATION_ERROR_NONE)
508 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification Content error");
511 LogDebug(" get Content : " << content);
515 std::string notiContent(content);
520 return std::string("");
525 LogDebug("noti Handle is NULL");
526 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
531 void StatusNotification::setContent(std::string content)
533 LogDebug("Content : " << content);
536 if((getContent()).compare(content)) //different value.
538 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, content.c_str(),
539 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
541 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification content error");
543 setUpdatedFlag(true);
548 LogDebug("noti Handle is NULL");
549 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
553 std::string StatusNotification::getIconPath()
557 char *iconPath = NULL;
559 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON, &iconPath) != NOTIFICATION_ERROR_NONE)
561 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification icon path error");
564 std::string notiIconPath(iconPath);
565 LogDebug("icon Path = " << iconPath);
567 //if icon path invalid, return empty string.
568 if ( notiIconPath.find(DEFAULT_ICON_PATH,0) == std::string::npos)
572 return std::string("");
577 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
581 void StatusNotification::setIconPath(const std::string& iconPath)
585 LogDebug("icon path = " << iconPath << " origin icon path = " << getIconPath());
586 if( getIconPath().compare(iconPath))
588 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON, iconPath.c_str()) != NOTIFICATION_ERROR_NONE)
590 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification icon error");
592 setUpdatedFlag(true);
597 LogDebug("noti Handle is NULL");
598 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
602 std::string StatusNotification::getSoundPath()
606 const char *soundPath = NULL;
607 notification_sound_type_e type = NOTIFICATION_SOUND_TYPE_NONE;
609 if (notification_get_sound(m_notiHandle, &type, &soundPath) != NOTIFICATION_ERROR_NONE)
611 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sound error");
614 LogDebug(" sound type = " << type << " path = " << soundPath);
616 if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
618 LogDebug("soundPath = " << soundPath);
619 return std::string(soundPath);
623 return std::string("");
628 LogDebug("noti Handle is NULL");
629 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
633 void StatusNotification::setSoundPath(const std::string& sound)
637 LogDebug("sound path = " << sound << " origin sound path = " << getSoundPath());
639 if( getSoundPath().compare(sound))
641 if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_USER_DATA, sound.c_str()) != NOTIFICATION_ERROR_NONE)
643 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
645 setUpdatedFlag(true);
650 LogDebug("noti Handle is NULL");
651 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
655 bool StatusNotification::getDefaultVibration()
659 notification_vibration_type_e vib_type;
660 if (notification_get_vibration(m_notiHandle, &vib_type, NULL) != NOTIFICATION_ERROR_NONE)
662 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
665 if (vib_type == NOTIFICATION_VIBRATION_TYPE_DEFAULT)
676 LogDebug("noti Handle is NULL");
682 void StatusNotification::setDefaultVibration(const bool& vibration)
686 notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
688 if (getDefaultVibration() != vibration)
692 vib_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
695 if (notification_set_vibration(m_notiHandle, vib_type , NULL) != NOTIFICATION_ERROR_NONE)
697 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
699 setUpdatedFlag(true);
704 LogDebug("noti Handle is NULL");
705 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
710 double StatusNotification::getProgressValue()
716 NotificationProgressType progressType = getProgressType();
718 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
720 if (notification_get_size(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
722 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification size error");
725 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
727 if (notification_get_progress(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
729 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
734 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
739 LogDebug("noti Handle is NULL");
746 void StatusNotification::setProgressValue(const double &progressValue)
751 NotificationProgressType progressType = getProgressType();
752 LogDebug("Progress Type : " << progressType);
754 double val = getProgressValue();
755 LogDebug("Progress value = " << progressValue << " origin Progress Value =" << val);
757 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
759 if (notification_set_size(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
761 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification size error");
764 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
767 if (notification_set_progress(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
769 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification progress error");
774 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
779 LogDebug("noti Handle is NULL");
780 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
784 std::string StatusNotification::getSubIconPath()
788 char *subIconPath = NULL;
790 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &subIconPath) != NOTIFICATION_ERROR_NONE)
792 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub icon error");
795 std::string notiSubIconPath;
797 notiSubIconPath = subIconPath;
798 return notiSubIconPath;
802 return std::string("");
807 void StatusNotification::setSubIconPath(const std::string& subIconPath)
811 LogDebug(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
813 if( getSubIconPath().compare(subIconPath))
815 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON_SUB, subIconPath.c_str()) != NOTIFICATION_ERROR_NONE)
817 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
819 setUpdatedFlag(true);
824 LogDebug("noti Handle is NULL");
825 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
829 std::vector<std::string> StatusNotification::getInformations()
832 std::vector<std::string> infos;
838 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_1, &info) != NOTIFICATION_ERROR_NONE)
840 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
844 infos.push_back(info); //info 1
846 infos.push_back(std::string("")); // insert empty String
849 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_2, &info) != NOTIFICATION_ERROR_NONE)
851 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
855 infos.push_back(info); //info 2
857 infos.push_back(std::string("")); // insert empty String
860 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_3, &info) != NOTIFICATION_ERROR_NONE)
862 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
866 infos.push_back(info); //info 3
868 infos.push_back(std::string("")); // insert empty String
875 LogDebug("noti Handle is NULL");
876 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
882 std::string StatusNotification::getInformation(int index)
886 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
890 type = NOTIFICATION_TEXT_TYPE_INFO_1;
893 type = NOTIFICATION_TEXT_TYPE_INFO_2;
896 type = NOTIFICATION_TEXT_TYPE_INFO_3;
899 type = NOTIFICATION_TEXT_TYPE_NONE;
903 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
905 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
911 LogDebug(" info " << strInfo);
917 LogDebug("noti Handle is NULL");
918 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
923 void StatusNotification::setInformations( std::vector<std::string>& infos)
928 std::vector<std::string>::iterator it;
931 for (it = infos.begin(); it != infos.end(); ++it)
933 std::string str = *it;
934 LogDebug(" Info : " << str);
936 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
940 type = NOTIFICATION_TEXT_TYPE_INFO_1;
943 type = NOTIFICATION_TEXT_TYPE_INFO_2;
946 type = NOTIFICATION_TEXT_TYPE_INFO_3;
949 type = NOTIFICATION_TEXT_TYPE_NONE;
952 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
954 if (getInformation(idx).compare(str))
956 if (notification_set_text(m_notiHandle, type, str.c_str(),
957 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
959 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification information error");
961 setUpdatedFlag(true);
971 LogDebug("noti Handle is NULL");
972 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
977 void StatusNotification::setInformation( const std::string& info, int index)
983 LogDebug(" index : " << idx);
984 LogDebug(" log : " << info);
985 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
990 type = NOTIFICATION_TEXT_TYPE_INFO_1;
993 type = NOTIFICATION_TEXT_TYPE_INFO_2;
996 type = NOTIFICATION_TEXT_TYPE_INFO_3;
999 type = NOTIFICATION_TEXT_TYPE_NONE;
1002 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1004 if (getInformation(idx).compare(info))
1006 if (notification_set_text(m_notiHandle, type, info.c_str(),
1007 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1009 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1011 setUpdatedFlag(true);
1017 std::vector<std::string> StatusNotification::getSubInformations()
1019 std::vector<std::string> subInfos;
1023 char *subInfo = NULL;
1024 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, &subInfo) != NOTIFICATION_ERROR_NONE)
1026 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub background error");
1030 subInfos.push_back(subInfo);
1032 subInfos.push_back(std::string());
1035 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_2, &subInfo) != NOTIFICATION_ERROR_NONE)
1037 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1041 subInfos.push_back(subInfo);
1043 subInfos.push_back(std::string());
1047 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_3, &subInfo) != NOTIFICATION_ERROR_NONE)
1049 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1053 subInfos.push_back(subInfo);
1055 subInfos.push_back(std::string());
1062 LogDebug("noti Handle is NULL");
1063 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1069 std::string StatusNotification::getSubInformation(int index)
1074 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1078 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1081 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1084 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1087 type = NOTIFICATION_TEXT_TYPE_NONE;
1090 char *subInfo = NULL;
1092 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
1094 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1097 std::string strSubInfo;
1099 strSubInfo = subInfo;
1100 LogDebug(" subInfo " << strSubInfo);
1106 LogDebug("noti Handle is NULL");
1107 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1112 void StatusNotification::setSubInformations(std::vector<std::string>& subInfos)
1116 std::vector<std::string>::iterator it;
1119 for (it = subInfos.begin(); it < subInfos.end(); ++it)
1121 std::string str = *it;
1122 LogDebug(" sub Info : " << str);
1124 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1128 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1131 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1134 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1137 type = NOTIFICATION_TEXT_TYPE_NONE;
1140 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1142 if (getSubInformation(idx).compare(str))
1144 if (notification_set_text(m_notiHandle, type, str.c_str(),
1145 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1147 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification text error");
1149 setUpdatedFlag(true);
1158 LogDebug("noti Handle is NULL");
1159 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1164 void StatusNotification::setSubInformation( const std::string& subInfo, int index)
1170 LogDebug(" index : " << idx);
1171 LogDebug(" log : " << subInfo);
1172 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1177 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1180 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1183 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1186 type = NOTIFICATION_TEXT_TYPE_NONE;
1189 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1191 if (getSubInformation(idx).compare(subInfo))
1193 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
1194 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1196 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1198 setUpdatedFlag(true);
1205 std::vector<std::string> StatusNotification::getThumbnails()
1207 std::vector<std::string> thumbs;
1211 if ( !thumbs.empty() )
1215 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1217 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1220 thumbs.push_back(thumb);
1222 thumbs.push_back(std::string("")); //set empty
1225 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1227 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1230 thumbs.push_back(thumb);
1232 thumbs.push_back(std::string("")); //set empty
1235 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1237 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1241 thumbs.push_back(thumb);
1243 thumbs.push_back(std::string("")); //set empty
1246 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1248 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1252 thumbs.push_back(thumb);
1254 thumbs.push_back(std::string("")); //set empty
1257 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1259 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1263 thumbs.push_back(thumb);
1265 thumbs.push_back(std::string("")); //set empty
1271 LogDebug("noti Handle is NULL");
1272 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1279 std::string StatusNotification::getThumbnail(int index)
1284 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1289 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1292 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1295 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1298 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1301 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1305 type = NOTIFICATION_IMAGE_TYPE_NONE;
1310 if (NOTIFICATION_IMAGE_TYPE_NONE != type && notification_get_image(m_notiHandle, type, &thumb) != NOTIFICATION_ERROR_NONE)
1312 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1315 std::string strThumb;
1320 LogDebug(" info " << strThumb);
1326 LogDebug("noti Handle is NULL");
1327 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1332 void StatusNotification::setThumbnails(std::vector<std::string>& thumbs)
1336 std::vector<std::string>::iterator it;
1339 for (it = thumbs.begin(); it < thumbs.end(); ++it)
1341 std::string str = *it;
1342 LogDebug(" thumbs : " << str);
1344 if ( idx < MAX_THUMBNAIL_LENGTH )
1345 setThumbnail(str, idx);
1347 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1351 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1354 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1357 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1360 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1363 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1366 type = NOTIFICATION_IMAGE_TYPE_NONE;
1369 if ( idx < MAX_THUMBNAIL_LENGTH )
1372 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1374 if (getThumbnail(idx).compare(str))
1376 if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
1378 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1380 setUpdatedFlag(true);
1389 if ( idx < MAX_THUMBNAIL_LENGTH)
1391 setThumbnail("", idx); //set empty value
1398 LogDebug("noti Handle is NULL");
1399 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1404 void StatusNotification::setThumbnail( const std::string& thumb, int index)
1408 LogDebug(" index : " << index);
1409 LogDebug(" thumb : " << thumb);
1410 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1415 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1418 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1421 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1424 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1427 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1430 type = NOTIFICATION_IMAGE_TYPE_NONE;
1433 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1436 if (getThumbnail(index).compare(thumb))
1438 if (notification_set_image(m_notiHandle, type, thumb.c_str()) != NOTIFICATION_ERROR_NONE)
1440 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1442 setUpdatedFlag(true);
1449 void StatusNotification::setThumbnails(const StringArrayPtr &value)
1452 m_thumbs = StringArrayPtr(new StringArray());
1462 std::vector<std::string>::iterator it;
1465 for (it = m_thumbs->begin(); it < m_thumbs->end(); ++it)
1467 std::string str = *it;
1468 LogDebug(" thumbs : " << str);
1469 DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, soundPath);
1470 str = path->getFullPath();
1472 LogDebug(" thumbs : " << str);
1473 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1477 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1480 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1483 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1486 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1489 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1492 type = NOTIFICATION_IMAGE_TYPE_NONE;
1495 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1497 if (getThumbnail(idx).compare(str))
1499 if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
1501 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
1503 setUpdatedFlag(true);
1517 StringArrayPtr StatusNotification::getThumbnails()
1522 if ( !m_thumbs->empty() )
1526 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1528 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
1531 m_thumbs->push_back(thumb);
1533 m_thumbs->push_back(std::string("")); //set empty
1536 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1538 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1541 m_thumbs->push_back(thumb);
1543 m_thumbs->push_back(std::string("")); //set empty
1546 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1548 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1552 m_thumbs->push_back(thumb);
1554 m_thumbs->push_back(std::string("")); //set empty
1557 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1559 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1563 m_thumbs->push_back(thumb);
1565 m_thumbs->push_back(std::string("")); //set empty
1568 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1570 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
1574 m_thumbs->push_back(thumb);
1576 m_thumbs->push_back(std::string("")); //set empty
1585 std::string StatusNotification::getBackground()
1589 char *background = NULL;
1591 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &background) != NOTIFICATION_ERROR_NONE)
1593 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
1596 std::string notiBackground;
1598 notiBackground = background;
1599 return notiBackground;
1603 LogDebug("noti Handle is NULL");
1604 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1609 void StatusNotification::setBackground(const std::string imagePath)
1613 if (getBackground().compare(imagePath))
1615 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_BACKGROUND, imagePath.c_str()) != NOTIFICATION_ERROR_NONE)
1617 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1619 setUpdatedFlag(true);
1624 LogDebug("noti Handle is NULL");
1625 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1629 unsigned int StatusNotification::getNumber()
1634 char *strNumber = NULL;
1636 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
1638 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
1642 std::istringstream(strNumber) >> number;
1644 LogDebug("number = " << number);
1652 LogDebug("noti Handle is NULL");
1657 void StatusNotification::setNumber(const unsigned int number)
1661 if(number!=getNumber())
1663 std::stringstream stream;
1665 if (stream.fail()) {
1666 ThrowMsg(WrtDeviceApis::Commons::UnknownException,
1667 "Couldn't convert e-mail account id");
1670 std::string strNumber = stream.str();
1671 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, strNumber.c_str(),
1672 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1674 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
1676 setUpdatedFlag(true);
1681 LogDebug("noti Handle is NULL");
1682 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
1688 void* StatusNotification::getNotificationHandle()
1690 return m_notiHandle;
1693 void StatusNotification::setNotificationHandle(void *handle)
1697 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
1699 LogDebug("handle = " << handle << " m_notiHandle = " << m_notiHandle);
1701 if (m_notiHandle != NULL)
1704 if ( notification_delete(m_notiHandle) != NOTIFICATION_ERROR_NONE)
1706 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification delete error");
1708 m_notiHandle = NULL;
1711 m_notiHandle = (notification_h)handle;
1714 void StatusNotification::setNotificationLines()
1716 if (m_notiHandle == NULL)
1718 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
1720 LogDebug("handle = " << m_notiHandle);
1722 if (getLinesNum() > 0)
1726 std::vector<std::string> infos = getInformations();
1727 std::vector<std::string> subInfos = getSubInformations();
1729 LogDebug("info size = " << infos.size());
1730 LogDebug("subInfo size = " << subInfos.size());
1732 std::vector<std::string>::iterator it;
1736 NotificationLineArrayPtr lines = getLines();
1738 for (it = infos.begin(); it < infos.end(); ++it)
1740 std::string info = *it;
1741 LogDebug(" Info : " << info);
1742 LogDebug("subInfo=" << subInfos[idx]);
1744 if (!(info.empty() && subInfos[idx].empty()))
1746 NotificationLinePtr line(new NotificationLine(m_notiHandle,idx,info,subInfos[idx]));
1747 lines->push_back(line);
1754 DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
1756 service_h service = NULL;
1758 char *tempStr = NULL;
1760 DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
1765 appControl->setService_h(m_service);
1767 if(service_get_operation(m_service, &tempStr) == SERVICE_ERROR_NONE)
1769 LogDebug("Operation Str = " << tempStr);
1772 appControl->setOperation(tempStr);
1779 if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
1781 LogDebug("Mime Str = " << tempStr);
1784 appControl->setMime(tempStr);
1791 if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
1793 LogDebug("Uri Str = " << tempStr);
1796 appControl->setUri(tempStr);
1802 if (service_get_category(m_service, &tempStr) == SERVICE_ERROR_NONE)
1804 LogDebug("Category Str = " << tempStr);
1807 appControl->setCategory(tempStr);
1814 if ( service_foreach_extra_data(m_service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
1816 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1823 Catch (WrtDeviceApis::Commons::Exception)
1837 if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
1839 ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
1844 ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
1851 if (m_service != NULL)
1853 retcode = service_clone(&service, m_service);
1855 if (retcode != SERVICE_ERROR_NONE)
1858 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
1860 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
1864 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
1866 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
1870 if (service == NULL)
1872 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");
1877 appControl->setService_h(service);
1880 int ret = service_get_operation(service, &tempStr);
1881 LogDebug("ret = " << ret);
1882 //if (service_get_operation(service, &tempStr) != SERVICE_ERROR_NONE)
1883 if(ret != SERVICE_ERROR_NONE)
1885 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service operation error");
1888 LogDebug("temp Str = " << tempStr);
1892 appControl->setOperation(tempStr);
1898 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service operation ok, but null");
1902 if (service_get_mime(service, &tempStr) == SERVICE_ERROR_NONE)
1906 appControl->setMime(tempStr);
1913 if (service_get_uri(service, &tempStr) == SERVICE_ERROR_NONE)
1917 appControl->setUri(tempStr);
1924 if ( service_foreach_extra_data(service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
1927 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
1933 Catch (WrtDeviceApis::Commons::Exception)
1947 if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
1949 ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
1954 ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
1963 void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr appControl)
1966 LogDebug("Entered m_service : " << m_service);
1968 if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
1970 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
1974 LogDebug("getOperation : " << appControl->getOperation().c_str());
1975 if (appControl->getOperation().size() != 0)
1977 if (service_set_operation(m_service, appControl->getOperation().c_str()) != SERVICE_ERROR_NONE)
1979 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
1984 LogDebug("getUri : " << appControl->getUri().c_str());
1985 if (appControl->getUri().size() != 0)
1987 if (service_set_uri(m_service, appControl->getUri().c_str() ) != SERVICE_ERROR_NONE)
1989 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
1994 LogDebug("getMime : " << appControl->getMime().c_str());
1995 if (appControl->getMime().size() != 0)
1997 if (service_set_mime(m_service, appControl->getMime().c_str() ) != SERVICE_ERROR_NONE)
1999 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
2003 LogDebug("Category : " << appControl->getCategory().c_str());
2004 if (appControl->getCategory().size() != 0)
2006 if (service_set_category(m_service, appControl->getCategory().c_str() ) != SERVICE_ERROR_NONE)
2008 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
2013 if ( service_foreach_extra_data(m_service, service_extra_data_delete_cb, NULL) != SERVICE_ERROR_NONE)
2015 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
2018 std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = appControl->getAppControlDataArray();
2019 size_t index = 0, indexArray = 0;
2021 LogDebug (" App Control Datas Count : " << appControlDataArray.size());
2023 DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
2025 for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
2027 DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
2028 std::string key = appControlData->getKey();
2029 LogDebug(" key : " << key);
2034 std::vector<std::string> value = appControlDataArray[index]->getValue();
2035 const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
2037 for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
2039 arrayValue[indexArray] = (char*)value[indexArray].c_str();
2040 LogDebug( " value : " << arrayValue[indexArray]);
2043 const char* strKey = key.c_str();
2044 LogDebug( " value size: " << value.size());
2045 if (service_add_extra_data_array(m_service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
2047 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
2054 bundle *bundle_data=NULL;
2056 if(service_to_bundle(m_service, &bundle_data) != SERVICE_ERROR_NONE)
2058 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service get bundle");
2063 notification_set_execute_option(m_notiHandle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
2064 NULL,NULL, bundle_data);
2065 //bundle_free(bundle_data);
2072 void StatusNotification::setApplicationId(const std::string& appId)
2075 LogDebug("m_service = " << m_service << " appId = " << appId);
2078 LogDebug("m_service = " << m_service);
2079 if (service_create(&m_service) != SERVICE_ERROR_NONE)
2081 LogDebug("Create Service Failed..");
2082 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2088 if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
2090 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");
2096 service_h service = NULL;
2097 char* operation = NULL;
2098 LogDebug("Entered : " << appId);
2100 LogDebug("m_service = " << m_service);
2101 if (m_service != NULL)
2103 retcode = service_clone(&service, m_service);
2104 if (retcode != SERVICE_ERROR_NONE)
2106 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
2108 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
2112 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
2115 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
2121 if (service_create(&service) != SERVICE_ERROR_NONE)
2123 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
2129 if (service_get_operation(service, &operation) != SERVICE_ERROR_NONE)
2131 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service get operation error");
2139 else if (service_set_operation(service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
2141 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
2144 if (service_set_app_id(service, appId.c_str())!= SERVICE_ERROR_NONE)
2146 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");
2149 if (m_service != NULL)
2151 service_destroy(m_service);
2155 m_service = service; //set service.
2160 std::string StatusNotification::getApplicationId()
2162 std::string retString;
2163 service_h service = NULL;
2164 char* appIdStr = NULL;
2166 if (m_service != NULL)
2169 retcode = service_clone(&service, m_service);
2171 if (retcode != SERVICE_ERROR_NONE)
2173 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
2175 LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
2179 LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
2181 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
2185 if (service == NULL)
2187 ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");
2192 if (service != NULL)
2194 if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
2196 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get a appId error");
2199 if (appIdStr != NULL)
2201 retString = appIdStr;
2205 LogDebug(retString);
2210 service_h StatusNotification::getService()
2216 NotificationLineArrayPtr StatusNotification::getLines() const
2221 int StatusNotification::getLinesNum() const
2223 return m_lines->size();
2226 void StatusNotification::setLines(const NotificationLineArrayPtr &value)
2228 LogDebug("setlines");
2231 m_lines = NotificationLineArrayPtr(new NotificationLineArray());
2237 NotificationLineArray::iterator iter;
2239 for(iter = m_lines->begin(); iter != m_lines->end(); iter++)
2241 NotificationLinePtr line = *iter;
2242 LogDebug("info = " << line->getInformation());
2243 LogDebug("sub info = " << line->getSubInformation());
2245 if ( index < MAX_NOTIFICATION_LINE_LENGTH)
2247 setInformation(line->getInformation(),index);
2248 setSubInformation(line->getSubInformation(),index);
2253 //clean empty solt.`
2254 for ( ;index < MAX_NOTIFICATION_LINE_LENGTH; index++)
2256 setInformation("", index);
2257 setSubInformation("", index);
2262 void StatusNotification::addLine(const NotificationLinePtr &value)
2264 m_lines->push_back(value);
2267 void StatusNotification::clearLines()