2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 #include <PlatformException.h>
21 #include <appsvc/appsvc.h>
23 #include "StatusNotification.h"
26 namespace Notification {
28 #define DEFAULT_ICON_PATH "/opt/share/icons/default/"
29 #define MAX_NOTIFICATION_DETAIL_INFO_LENGTH 2
30 #define MAX_THUMBNAIL_LENGTH 4
32 extern "C" int service_create_event(bundle *data, struct service_s **service);
33 extern "C" int service_to_bundle(service_h service, bundle **data);
36 static bool service_extra_data_cb(service_h service, const char *key, void *user_data)
42 if (user_data != NULL && key != NULL)
44 LogInfo("user data & key is existed");
46 DeviceAPI::Application::ApplicationControlPtr* appControl =
47 (DeviceAPI::Application::ApplicationControlPtr*)(user_data);
49 DeviceAPI::Application::ApplicationControlDataPtr data(new DeviceAPI::Application::ApplicationControlData());
50 LogInfo("key = " << key);
51 std::string keyStr = key;
52 std::vector<std::string> keyValue;
55 if (service_get_extra_data_array((*appControl)->getService_h(), key, &value, &length) == SERVICE_ERROR_NONE)
57 LogInfo("extra_data_array length = " << length);
59 if (value != NULL && length != 0)
61 LogInfo("extra_data_length = " << length);
63 for (index = 0; index < length; index++)
65 LogInfo("Value=" << value[index]);
66 keyValue.push_back(value[index]);
69 data->setValue(keyValue);
70 (*appControl)->addAppControlData(data);
80 static bool service_extra_data_delete_cb(service_h service, const char *key, void *user_data)
85 LogInfo("del key = " << key);
87 if (service_remove_extra_data(service, key) != SERVICE_ERROR_NONE)
89 LogWarning("remove extra data failed");
96 StatusNotification::StatusNotification(NotificationType statusType) :
97 m_notiType(NOTI_TYPE_NONE),
100 m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
101 m_notiUpdated(false),
104 LogInfo("statusType =" << statusType);
106 notification_type_e type = NOTIFICATION_TYPE_NONE;
107 setNotiType(statusType);
109 if (statusType == NOTI_TYPE_SIMPLE || statusType == NOTI_TYPE_MUTIPLE || statusType == NOTI_TYPE_THUMBNAIL)
111 type = NOTIFICATION_TYPE_NOTI;
113 else if ( statusType == NOTI_TYPE_ONGOING || statusType == NOTI_TYPE_PROGRESS)
115 type = NOTIFICATION_TYPE_ONGOING;
119 LogInfo(" invalide noti type");
120 throw TypeMismatchException("value is not notification type");
123 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
125 LogInfo("Notification Type : " << type);
127 notification_h noti = notification_create(type); //create notificatin.
130 LogInfo("noti =" << noti);
131 setNotificationHandle((void*)noti);
133 if (NOTIFICATION_TYPE_ONGOING == type)
134 { //ongoing no ticker.
135 LogInfo("ongoing type");
136 notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY |NOTIFICATION_DISPLAY_APP_INDICATOR );
141 throw UnknownException("can't make new notification object");
144 //m_detailInfos = new std::vector<NotificationDetailInfo*>();
145 //m_thumbs = new std::vector<std::string>();
149 StatusNotification::StatusNotification(void* noti) :
150 m_notiType(NOTI_TYPE_NONE),
153 m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
154 m_notiUpdated(false),
157 LogInfo("noti : " << noti);
159 notification_h notification = (notification_h)noti;
163 NotificationType type = NOTI_TYPE_NONE;
164 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
165 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
167 notification_get_type(notification, ¬i_type);
168 notification_get_layout(notification, ¬i_layout);
171 if ( noti_type == NOTIFICATION_TYPE_NOTI )
173 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
174 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
176 type = NOTI_TYPE_SIMPLE;
178 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
180 type = NOTI_TYPE_THUMBNAIL;
183 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
185 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
187 type = NOTI_TYPE_ONGOING;
189 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
191 type = NOTI_TYPE_PROGRESS;
195 LogInfo(" notification type =" << type);
197 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
199 setNotificationHandle((void*)notification);
203 if ( type == NOTI_TYPE_PROGRESS)
205 notification_update_progress(notification, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
211 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
212 LogInfo("ret = " << ret);
213 if (ret == NOTIFICATION_ERROR_NONE)
215 LogInfo(" bundle = " << bSvc);
218 LogInfo("bundle is valid");
219 int ret = service_create_event(bSvc, &m_service);
220 if (ret != SERVICE_ERROR_NONE)
222 LogInfo("Service Create Event Error");
223 throw UnknownException("can't make service object");
229 notification_free(notification);
230 throw UnknownException("can't get service data");
236 throw InvalidValuesException("It is not notification object.");
241 StatusNotification::StatusNotification(int privID) :
242 m_notiType(NOTI_TYPE_NONE),
245 m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
246 m_notiUpdated(false),
249 LogInfo("priv ID : " << privID);
251 notification_h notification = notification_load( NULL, privID); //load notification.
252 LogInfo(" 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 LogInfo(" notification type =" << type);
289 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
290 setNotificationHandle((void*)notification);
294 if ( type == NOTI_TYPE_PROGRESS)
296 notification_update_progress(notification, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
302 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
303 LogInfo("ret = " << ret);
304 if (ret == NOTIFICATION_ERROR_NONE)
306 LogInfo(" bundle = " << bSvc);
309 LogInfo("bundle is valid");
310 int ret = service_create_event(bSvc, &m_service);
311 if (ret != SERVICE_ERROR_NONE)
313 LogInfo("Service Create Event Error");
314 throw UnknownException("can't make service object");
320 notification_free(notification);
321 throw UnknownException("can't get service data");
327 throw NotFoundException("It is not notification ID or removed notification");
332 StatusNotification::~StatusNotification()
334 LogInfo(" notification = " << m_notiHandle);
337 //clearDetailInfos();
342 LogInfo(" service = " << m_service);
343 if (m_service != NULL)
345 service_destroy(m_service);
349 if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
351 throw UnknownException("notification free failed...");
358 int StatusNotification::getID()
360 int id = -1; // notification not inserted yet.
363 notification_get_id(m_notiHandle, NULL, &id);
369 std::string StatusNotification::getStatusType()
373 if ( NOTI_TYPE_SIMPLE == getNotiType())
377 else if ( NOTI_TYPE_ONGOING == getNotiType())
381 else if ( NOTI_TYPE_PROGRESS == getNotiType())
385 else if ( NOTI_TYPE_THUMBNAIL == getNotiType())
396 void StatusNotification::setStatusType(std::string type)
398 LogInfo("type = " << type);
400 NotificationType notiType = NOTI_TYPE_NONE;
402 if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_SIMPLE) == 0)
403 notiType = NOTI_TYPE_SIMPLE;
404 else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_THUMBNAIL) == 0)
405 notiType = NOTI_TYPE_THUMBNAIL;
406 else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_ONGOING) == 0)
407 notiType = NOTI_TYPE_ONGOING;
408 else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_PROGRESS) == 0)
409 notiType = NOTI_TYPE_PROGRESS;
411 throw InvalidValuesException("Invalid Status Type.");
413 LogInfo("Notification type = " << notiType);
414 setNotiType(notiType);
417 time_t StatusNotification::getPostedTime()
419 LogInfo("get m_notiHandle = " << m_notiHandle);
421 time_t postedTime = 0;
425 if (notification_get_insert_time(m_notiHandle, &postedTime) != NOTIFICATION_ERROR_NONE)
427 throw UnknownException("get notification posted time error");
431 LogInfo("posted Time =" << ctime(&postedTime));
435 std::string StatusNotification::getTitle()
441 if (notification_get_text(m_notiHandle,NOTIFICATION_TEXT_TYPE_TITLE, &title) != NOTIFICATION_ERROR_NONE)
443 throw UnknownException("get notification title error");
446 std::string notiTitle(title);
451 throw UnknownException("notification handle is null");
455 void StatusNotification::setTitle(std::string title)
457 LogInfo("Title : " << title);
460 LogInfo("get Title : " << getTitle());
461 if((getTitle()).compare(title)) //different value.
463 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_TITLE, title.c_str(),
464 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
466 throw UnknownException("set notification title error");
469 setUpdatedFlag(true);
473 LogInfo(" title = " << title << " getTitle = " << getTitle());
478 LogDebug("noti Handle is NULL");
479 throw UnknownException("notification handle is null");
484 std::string StatusNotification::getContent()
486 LogInfo("get Content handle: " << m_notiHandle);
489 char *content = NULL;
491 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) != NOTIFICATION_ERROR_NONE)
493 throw UnknownException("get notification Content error");
496 LogInfo(" get Content : " << content);
498 std::string notiContent;
501 notiContent = content;
508 throw UnknownException("notification handle is null");
513 void StatusNotification::setContent(std::string content)
515 LogInfo("Content : " << content);
518 if((getContent()).compare(content)) //different value.
520 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, content.c_str(),
521 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
523 throw UnknownException("set notification content error");
525 setUpdatedFlag(true);
530 LogDebug("noti Handle is NULL");
531 throw UnknownException("notification handle is null");
535 std::string StatusNotification::getIconPath()
538 LogInfo("m_notiHandle = " << m_notiHandle);
541 char *iconPath = NULL;
542 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON, &iconPath) != NOTIFICATION_ERROR_NONE)
544 throw UnknownException("get notification icon path error");
547 std::string notiIconPath(iconPath);
548 LogInfo("icon Path = " << iconPath);
550 //if icon path invalid, return empty string.
551 if ( notiIconPath.find(DEFAULT_ICON_PATH,0) == std::string::npos)
555 return std::string(""); //return empty string.
560 throw UnknownException("notification handle is null");
564 void StatusNotification::setIconPath(const std::string& iconPath)
568 LogInfo("icon path = " << iconPath << " origin icon path = " << getIconPath());
569 if( getIconPath().compare(iconPath))
571 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON, iconPath.c_str()) != NOTIFICATION_ERROR_NONE)
573 throw UnknownException("set notification icon error");
575 setUpdatedFlag(true);
580 LogDebug("noti Handle is NULL");
581 throw UnknownException("notification handle is null");
585 std::string StatusNotification::getSoundPath()
587 LogInfo("Handle = " << m_notiHandle);
591 const char *soundPath = NULL;
592 notification_sound_type_e type = NOTIFICATION_SOUND_TYPE_NONE;
594 if (notification_get_sound(m_notiHandle, &type, &soundPath) != NOTIFICATION_ERROR_NONE)
596 throw UnknownException("get notification sound error");
599 LogInfo(" sound type = " << type << " path = " << soundPath);
600 if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
602 LogInfo("soundPath = " << soundPath);
603 return std::string(soundPath);
607 return std::string("");
612 LogDebug("noti Handle is NULL");
613 throw UnknownException("notification handle is null");
617 void StatusNotification::setSoundPath(const std::string& sound)
621 LogInfo("sound path = " << sound << " origin sound path = " << getSoundPath());
623 if( getSoundPath().compare(sound))
625 if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_USER_DATA, sound.c_str()) != NOTIFICATION_ERROR_NONE)
627 throw UnknownException("set notification sound error");
629 setUpdatedFlag(true);
634 LogInfo("sound path is NULL");
635 if ( NOTI_TYPE_ONGOING == getNotiType() || NOTI_TYPE_PROGRESS == getNotiType())
637 LogInfo("Ongoing Type" );
638 if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_NONE, NULL) != NOTIFICATION_ERROR_NONE)
640 throw UnknownException("set notification sound error");
645 if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_DEFAULT, sound.c_str()) != NOTIFICATION_ERROR_NONE)
647 throw UnknownException("set notification sound error");
655 LogDebug("noti Handle is NULL");
656 throw UnknownException("notification handle is null");
660 bool StatusNotification::getDefaultVibration()
662 LogInfo("getDefaultVibration");
665 notification_vibration_type_e vib_type;
666 if (notification_get_vibration(m_notiHandle, &vib_type, NULL) != NOTIFICATION_ERROR_NONE)
668 throw UnknownException("set notification sound error");
671 if (NOTIFICATION_VIBRATION_TYPE_DEFAULT == vib_type || NOTIFICATION_VIBRATION_TYPE_USER_DATA == vib_type)
682 LogDebug("noti Handle is NULL");
683 throw UnknownException("notification handle is null");
689 void StatusNotification::setDefaultVibration(const bool& vibration)
691 LogInfo("vibration = " << vibration);
694 notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
695 LogInfo("old vibration = " << getDefaultVibration());
696 if (getDefaultVibration() != vibration)
700 vib_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
704 vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
706 LogInfo("type vibration type= " << vib_type);
708 if (notification_set_vibration(m_notiHandle, vib_type , NULL) != NOTIFICATION_ERROR_NONE)
710 throw UnknownException("set notification sound error");
712 setUpdatedFlag(true);
717 LogDebug("noti Handle is NULL");
718 throw UnknownException("notification handle is null");
723 DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
726 service_h service = NULL;
727 char *tempStr = NULL;
729 DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
734 appControl->setService_h(m_service);
736 if(service_get_operation(m_service, &tempStr) == SERVICE_ERROR_NONE)
738 LogDebug("Operation Str = " << tempStr);
741 appControl->setOperation(tempStr);
748 if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
750 LogDebug("Mime Str = " << tempStr);
753 appControl->setMime(tempStr);
760 if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
762 LogDebug("Uri Str = " << tempStr);
765 appControl->setUri(tempStr);
771 if (service_get_category(m_service, &tempStr) == SERVICE_ERROR_NONE)
773 LogDebug("Category Str = " << tempStr);
776 appControl->setCategory(tempStr);
783 if ( service_foreach_extra_data(m_service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
785 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
792 Catch (WrtDeviceApis::Commons::Exception)
806 LogWarning(_rethrown_exception.GetMessage());
812 void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr control)
814 LogInfo("Entered m_service : " << m_service << " control : " << control);
816 //delete old service.
819 service_destroy(m_service);
823 if(service_create(&m_service) != SERVICE_ERROR_NONE)
825 throw UnknownException("service creation error");
829 LogInfo("getOperation : " << control->getOperation().c_str());
830 if (control->getOperation().size() != 0)
832 m_launchFlag = true; //default attribute
833 if (service_set_operation(m_service, control->getOperation().c_str()) != SERVICE_ERROR_NONE)
835 throw UnknownException("service set operation error");
840 LogInfo("getUri : " << control->getUri().c_str());
841 if (control->getUri().size() != 0)
843 if (service_set_uri(m_service, control->getUri().c_str() ) != SERVICE_ERROR_NONE)
845 throw UnknownException("service set uri error");
850 LogInfo("getMime : " << control->getMime().c_str());
851 if (control->getMime().size() != 0)
853 if (service_set_mime(m_service, control->getMime().c_str() ) != SERVICE_ERROR_NONE)
855 throw UnknownException("service set mime error");
859 LogInfo("Category : " << control->getCategory().c_str());
860 if (control->getCategory().size() != 0)
862 if (service_set_category(m_service, control->getCategory().c_str() ) != SERVICE_ERROR_NONE)
864 throw UnknownException("service set mime error");
869 //if ( service_foreach_extra_data(m_service, service_extra_data_delete_cb, NULL) != SERVICE_ERROR_NONE)
871 // throw UnknownException("get notification service uri error");
874 std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = control->getAppControlDataArray();
877 LogInfo (" App Control Datas Count : " << appControlDataArray.size());
879 DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
881 for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
883 DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
884 std::string key = appControlData->getKey();
885 LogInfo(" key : " << key);
890 std::vector<std::string> value = appControlDataArray[index]->getValue();
891 const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
893 for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
895 arrayValue[indexArray] = (char*)value[indexArray].c_str();
896 LogInfo( " value : " << arrayValue[indexArray]);
899 const char* strKey = key.c_str();
900 LogInfo( " value size: " << value.size());
901 if (service_add_extra_data_array(m_service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
903 throw UnknownException("service set extra data error");
910 bundle *bundle_data=NULL;
912 if(service_to_bundle(m_service, &bundle_data) != SERVICE_ERROR_NONE)
914 throw UnknownException("service get bundle");
917 LogDebug("bundle_data : " << bundle_data);
921 notification_set_execute_option(m_notiHandle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
922 NULL,NULL, bundle_data);
929 void StatusNotification::setApplicationId(const std::string& appId)
931 LogInfo("m_service = " << m_service << " appId = " << appId);
934 if (service_create(&m_service) != SERVICE_ERROR_NONE)
936 LogWarning("Create Service Failed..");
937 throw DeviceAPI::Common::UnknownException ("service creation error");
946 if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
948 throw DeviceAPI::Common::UnknownException ("service set appId error");
955 std::string StatusNotification::getApplicationId()
957 std::string retString;
958 service_h service = NULL;
959 char* appIdStr = NULL;
961 if (m_service != NULL)
964 retcode = service_clone(&service, m_service);
966 if (retcode != SERVICE_ERROR_NONE)
968 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
970 LogWarning("SERVICE_ERROR_OUT_OF_MEMORY");
974 LogWarning("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
976 throw DeviceAPI::Common::UnknownException ("get notification service error ");
982 throw DeviceAPI::Common::UnknownException ("get notification service ok, but service null");
989 if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
991 throw DeviceAPI::Common::UnknownException ("get a appId error");
994 if (appIdStr != NULL)
996 retString = appIdStr;
1006 double StatusNotification::getProgressValue()
1012 NotificationProgressType progressType = getProgressType();
1014 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
1016 if (notification_get_size(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
1018 throw UnknownException("get notification size error");
1020 LogInfo("Size Val = " << value);
1022 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
1024 if (notification_get_progress(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
1026 throw UnknownException("get notification percentage error");
1028 LogInfo("Percentage Val = " << value);
1032 throw UnknownException("get notification progress type error");
1037 LogDebug("noti Handle is NULL");
1039 LogInfo("value = " << value);
1044 void StatusNotification::setProgressValue(const double &progressValue)
1048 NotificationProgressType progressType = getProgressType();
1049 LogInfo("Progress Type : " << progressType);
1051 double val = getProgressValue();
1052 LogInfo("Progress value = " << progressValue << " origin Progress Value =" << val);
1054 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
1056 if (notification_set_size(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
1058 throw UnknownException("set notification progress size error");
1061 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
1063 if (notification_set_progress(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
1065 throw UnknownException("set notification percentage error");
1070 throw UnknownException("get notification progress type error");
1075 LogDebug("noti Handle is NULL");
1076 throw UnknownException( "notification handle is null");
1080 std::string StatusNotification::getSubIconPath()
1082 LogInfo("Handle = " << m_notiHandle);
1085 char *subIconPath = NULL;
1087 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &subIconPath) != NOTIFICATION_ERROR_NONE)
1089 throw UnknownException("get notification sub icon error");
1092 std::string notiSubIconPath;
1094 notiSubIconPath = subIconPath;
1095 return notiSubIconPath;
1099 throw UnknownException("notification handle is null");
1104 void StatusNotification::setSubIconPath(const std::string& subIconPath)
1108 LogInfo(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
1110 if( getSubIconPath().compare(subIconPath))
1112 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON_SUB, subIconPath.c_str()) != NOTIFICATION_ERROR_NONE)
1114 throw UnknownException("set notification sound error");
1116 setUpdatedFlag(true);
1121 LogDebug("noti Handle is NULL");
1122 throw UnknownException("notification handle is null");
1127 std::string StatusNotification::getInformation(int index)
1131 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1135 type = NOTIFICATION_TEXT_TYPE_INFO_1;
1138 type = NOTIFICATION_TEXT_TYPE_INFO_2;
1141 type = NOTIFICATION_TEXT_TYPE_INFO_3;
1144 type = NOTIFICATION_TEXT_TYPE_NONE;
1148 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
1150 throw UnknownException("get notification information error");
1153 std::string strInfo;
1156 LogDebug(" info " << strInfo);
1162 LogDebug("noti Handle is NULL");
1163 throw UnknownException("notification handle is null");
1168 void StatusNotification::setInformation( const std::string& info, int index)
1174 LogDebug(" index : " << idx);
1175 LogDebug(" log : " << info);
1176 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1181 type = NOTIFICATION_TEXT_TYPE_INFO_1;
1184 type = NOTIFICATION_TEXT_TYPE_INFO_2;
1187 type = NOTIFICATION_TEXT_TYPE_INFO_3;
1190 type = NOTIFICATION_TEXT_TYPE_NONE;
1193 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1195 if (getInformation(idx).compare(info))
1197 if (notification_set_text(m_notiHandle, type, info.c_str(),
1198 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1200 throw UnknownException("set notification sound error");
1202 setUpdatedFlag(true);
1208 LogDebug("noti Handle is NULL");
1209 throw UnknownException("notification handle is null");
1213 std::string StatusNotification::getSubInformation(int index)
1218 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1222 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1225 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1228 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1231 type = NOTIFICATION_TEXT_TYPE_NONE;
1234 char *subInfo = NULL;
1236 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
1238 throw UnknownException( "get notification sub information error");
1241 std::string strSubInfo;
1243 strSubInfo = subInfo;
1244 LogDebug(" subInfo " << strSubInfo);
1250 LogDebug("noti Handle is NULL");
1251 throw UnknownException( "notification handle is null");
1256 void StatusNotification::setSubInformation( const std::string& subInfo, int index)
1261 LogDebug(" index : " << idx);
1262 LogDebug(" log : " << subInfo);
1263 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1268 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1271 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1274 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1277 type = NOTIFICATION_TEXT_TYPE_NONE;
1280 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1282 if (getSubInformation(idx).compare(subInfo))
1284 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
1285 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1287 throw UnknownException( "set notification sound error");
1289 setUpdatedFlag(true);
1295 LogDebug("noti Handle is NULL");
1296 throw UnknownException( "notification handle is null");
1302 void StatusNotification::loadThumbnails()
1306 if (!m_thumbs.empty())
1310 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1312 throw UnknownException( "get notification thumbnail error");
1315 m_thumbs.push_back(thumb);
1317 // m_thumbs.push_back(std::string("")); //set empty
1320 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1322 throw UnknownException( "get notification sub information error");
1325 m_thumbs.push_back(thumb);
1327 // m_thumbs.push_back(std::string("")); //set empty
1330 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1332 throw UnknownException( "get notification sub information error");
1336 m_thumbs.push_back(thumb);
1338 // m_thumbs.push_back(std::string("")); //set empty
1341 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1343 throw UnknownException( "get notification sub information error");
1347 m_thumbs.push_back(thumb);
1349 // m_thumbs.push_back(std::string("")); //set empty
1352 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1354 throw UnknownException( "get notification sub information error");
1358 m_thumbs.push_back(thumb);
1360 m_thumbs.push_back(std::string("")); //set empty
1367 LogDebug("noti Handle is NULL");
1368 throw UnknownException( "notification handle is null");
1372 std::vector<std::string> StatusNotification::getThumbnails()
1374 LogInfo(" thumbnail Size : " << m_thumbs.size());
1378 std::string StatusNotification::getThumbnail(int index)
1382 LogInfo(" index : " << index);
1384 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1389 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1392 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1395 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1398 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1401 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1404 type = NOTIFICATION_IMAGE_TYPE_NONE;
1407 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1410 if (notification_get_image(m_notiHandle, type, &thumb) != NOTIFICATION_ERROR_NONE)
1412 throw UnknownException( "set notification thumbnail error");
1415 std::string thumbnail;
1422 throw UnknownException( "notification handle is null");
1428 LogDebug("noti Handle is NULL");
1429 throw UnknownException( "notification handle is null");
1432 if (m_thumbs.size() > index)
1433 return m_thumbs[index];
1435 return std::string("");
1440 void StatusNotification::setThumbnails(std::vector<std::string> thumbs)
1442 LogInfo("set thumbnails");
1445 std::vector<std::string>::iterator it;
1448 for (it = thumbs.begin(); it < thumbs.end(); ++it)
1450 std::string str = *it;
1451 if ( idx < MAX_THUMBNAIL_LENGTH )
1452 setThumbnail(str, idx); //set notification's thumbnail value.
1460 LogDebug("noti Handle is NULL");
1461 throw UnknownException( "notification handle is null");
1465 void StatusNotification::setThumbnail( const std::string& thumb, int index)
1469 LogInfo(" index : " << index);
1470 LogInfo(" thumb : " << thumb);
1471 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1476 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1479 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1482 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1485 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1488 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1491 type = NOTIFICATION_IMAGE_TYPE_NONE;
1494 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1496 if (getThumbnail(index).compare(thumb))
1498 if (notification_set_image(m_notiHandle, type, thumb.c_str()) != NOTIFICATION_ERROR_NONE)
1500 throw UnknownException( "set notification thumbnail error");
1502 setUpdatedFlag(true);
1508 std::string StatusNotification::getBackground()
1510 LogInfo(" Handle : " << m_notiHandle);
1514 char *background = NULL;
1516 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &background) != NOTIFICATION_ERROR_NONE)
1518 throw UnknownException( "get notification background error");
1521 std::string notiBackground;
1523 notiBackground = background;
1524 return notiBackground;
1528 LogDebug("noti Handle is NULL");
1529 throw UnknownException( "notification handle is null");
1534 void StatusNotification::setBackground(const std::string imagePath)
1536 LogInfo(" imagePath : " << imagePath);
1539 if (getBackground().compare(imagePath))
1541 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_BACKGROUND, imagePath.c_str()) != NOTIFICATION_ERROR_NONE)
1543 throw UnknownException( "set notification sound error");
1545 setUpdatedFlag(true);
1550 LogDebug("noti Handle is NULL");
1551 throw UnknownException( "notification handle is null");
1555 unsigned int StatusNotification::getNumber()
1557 LogInfo("Handle = " << m_notiHandle);
1561 char *strNumber = NULL;
1563 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
1565 throw UnknownException( "get notification background error");
1569 std::istringstream(strNumber) >> number;
1571 LogInfo("number = " << number);
1579 LogDebug("noti Handle is NULL");
1584 void StatusNotification::setNumber(const unsigned int number)
1586 LogInfo("Number = " << number);
1589 if(number!=getNumber())
1591 std::stringstream stream;
1593 if (stream.fail()) {
1594 throw UnknownException(
1595 "Couldn't convert e-mail account id");
1598 std::string strNumber = stream.str();
1599 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, strNumber.c_str(),
1600 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1602 throw UnknownException( "set notification sound error");
1604 setUpdatedFlag(true);
1609 LogDebug("noti Handle is NULL");
1610 throw UnknownException( "notification handle is null");
1614 void* StatusNotification::getNotificationHandle()
1616 return m_notiHandle;
1619 void StatusNotification::setNotificationHandle(void *handle)
1623 throw UnknownException( "notification handle null error");
1625 LogInfo("handle = " << handle << " m_notiHandle = " << m_notiHandle);
1627 if (m_notiHandle != NULL)
1630 if ( notification_delete(m_notiHandle) != NOTIFICATION_ERROR_NONE)
1632 throw UnknownException( "notification delete error");
1634 m_notiHandle = NULL;
1637 m_notiHandle = (notification_h)handle;
1640 service_h StatusNotification::getService()
1647 void StatusNotification::loadDetailInfos()
1649 LogInfo("noti Handle = " << m_notiHandle);
1653 for ( int idx = 0; idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH; idx++)
1655 std::string main = getInformation(idx);
1656 std::string sub = getSubInformation(idx);
1657 LogInfo("Main : " << main << " Sub : " << sub);
1658 NotificationDetailInfo *info = new NotificationDetailInfo(m_notiHandle, idx, main, sub);
1659 m_detailInfos.push_back(info);
1664 LogDebug("noti Handle is NULL");
1665 throw UnknownException( "notification handle is null");
1670 std::vector<NotificationDetailInfo*> StatusNotification::getDetailInfos() const
1672 return m_detailInfos;
1675 void StatusNotification::setDetailInfos(const std::vector<NotificationDetailInfo*> value)
1677 LogInfo("DetailInfos = " << value.size());
1681 std::vector<NotificationDetailInfo*>::const_iterator it;
1684 for (it = value.begin(); it < value.end(); ++it)
1686 NotificationDetailInfo* info = *it;
1687 if ( idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH )
1689 LogInfo("main " << info->getMainText() << " sub " << info->getSubText() );
1690 setInformation(info->getMainText(), idx);
1691 setSubInformation(info->getSubText(), idx);
1696 m_detailInfos = value;
1700 LogDebug("noti Handle is NULL");
1701 throw UnknownException( "notification handle is null");
1706 int StatusNotification::getDetailInfosNum() const
1708 return m_detailInfos.size();
1711 void StatusNotification::clearDetailInfos()
1713 if ( !m_detailInfos.empty() )
1715 std::vector<NotificationDetailInfo*>::const_iterator it;
1718 for (it = m_detailInfos.begin(); it < m_detailInfos.end(); ++it)
1720 NotificationDetailInfo* info = *it;
1721 LogInfo("Delete Detail Info : " << info);
1726 m_detailInfos.clear(); //clear
1730 std::string StatusNotification::getInformation(int index)
1734 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1738 type = NOTIFICATION_TEXT_TYPE_INFO_1;
1741 type = NOTIFICATION_TEXT_TYPE_INFO_2;
1744 type = NOTIFICATION_TEXT_TYPE_INFO_3;
1747 type = NOTIFICATION_TEXT_TYPE_NONE;
1751 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
1753 throw UnknownException("Detail Info index value is invalid or mainText value getting is failed in Detail Info.");
1756 std::string strInfo;
1759 LogInfo(" info " << strInfo);
1765 LogWarning("noti Handle is NULL");
1766 throw UnknownException( "notification handle is null");
1771 std::string StatusNotification::getSubInformation(int index)
1775 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1779 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1782 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1785 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1788 type = NOTIFICATION_TEXT_TYPE_NONE;
1791 char *subInfo = NULL;
1793 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
1795 throw UnknownException("Detail Info index value is invalid or subText value getting is failed in Detail Info.");
1798 std::string strSubInfo;
1800 strSubInfo = subInfo;
1801 LogInfo(" subInfo " << strSubInfo);
1807 LogWarning("noti Handle is NULL");
1808 throw UnknownException ("notification handle is null");
1813 void StatusNotification::setInformation( const std::string& info, int index)
1818 LogDebug(" index : " << idx);
1819 LogDebug(" log : " << info);
1820 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1825 type = NOTIFICATION_TEXT_TYPE_INFO_1;
1828 type = NOTIFICATION_TEXT_TYPE_INFO_2;
1831 type = NOTIFICATION_TEXT_TYPE_INFO_3;
1834 type = NOTIFICATION_TEXT_TYPE_NONE;
1837 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1839 if (getInformation(idx).compare(info))
1841 if (notification_set_text(m_notiHandle, type, info.c_str(),
1842 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1844 throw UnknownException("set notification sound error");
1846 setUpdatedFlag(true);
1851 LogWarning("noti Handle is NULL");
1852 throw UnknownException("notification handle is null");
1857 LogWarning("noti Handle is NULL");
1858 throw UnknownException("notification handle is null");
1862 void StatusNotification::setSubInformation( const std::string& subInfo, int index)
1868 LogDebug(" index : " << idx);
1869 LogDebug(" log : " << subInfo);
1870 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1875 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1878 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1881 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1884 type = NOTIFICATION_TEXT_TYPE_NONE;
1887 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1889 if (getSubInformation(idx).compare(subInfo))
1891 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
1892 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1894 throw UnknownException("set notification sound error");
1896 setUpdatedFlag(true);
1902 LogWarning("noti Handle is NULL");
1903 throw UnknownException("notification handle is null");
1910 StatusNotification::StatusNotification():
1915 m_backgroundImagePath(""),
1923 StatusNotification::~StatusNotification()
1927 std::string StatusNotification::getStatusType() const
1929 return m_statusType;
1932 void StatusNotification::setStatusType(std::string statusType)
1934 m_statusType = statusType;
1937 std::string StatusNotification::getIconPath() const
1942 void StatusNotification::setIconPath(std::string iconPath)
1944 m_iconPath = iconPath;
1947 std::string StatusNotification::getSubIconPath() const
1949 return m_subIconPath;
1952 void StatusNotification::setSubIconPath(std::string subIconPath)
1954 m_subIconPath = subIconPath;
1957 long StatusNotification::getNumber() const
1962 void StatusNotification::setNumber(long number)
1967 std::vector<NotificationDetailInfo*> StatusNotification::getDetailInfo() const
1969 return m_detailInfo;
1972 void StatusNotification::setDetailInfo(std::vector<NotificationDetailInfo*> detailInfo)
1974 m_detailInfo = detailInfo;
1977 std::string StatusNotification::getBackgroundImagePath() const
1979 return m_backgroundImagePath;
1982 void StatusNotification::setBackgroundImagePath(std::string backgroundImagePath)
1984 m_backgroundImagePath = backgroundImagePath;
1987 std::vector<std::string> StatusNotification::getThumbnails() const
1989 return m_thumbnails;
1992 void StatusNotification::setThumbnails(std::vector<std::string> thumbnails)
1994 m_thumbnails = thumbnails;
1997 std::string StatusNotification::getSoundPath() const
2002 void StatusNotification::setSoundPath(std::string soundPath)
2004 m_soundPath = soundPath;
2007 bool StatusNotification::getVibration() const
2012 void StatusNotification::setVibration(bool vibration)
2014 m_vibration = vibration;
2017 ApplicationControl StatusNotification::getAppControl() const
2019 return m_appControl;
2022 void StatusNotification::setAppControl(ApplicationControl appControl)
2024 m_appControl = appControl;
2027 ApplicationId StatusNotification::getAppId() const
2032 void StatusNotification::setAppId(ApplicationId appId)
2037 std::string StatusNotification::getProgressType() const
2039 return m_progressType;
2042 void StatusNotification::setProgressType(std::string progressType)
2044 m_progressType = progressType;
2047 unsigned long StatusNotification::getProgressValue() const
2049 return m_progressValue;
2052 void StatusNotification::setProgressValue(unsigned long progressValue)
2054 m_progressValue = progressValue;