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),
103 LogInfo("statusType =" << statusType);
105 notification_type_e type = NOTIFICATION_TYPE_NONE;
106 setNotiType(statusType);
108 if (statusType == NOTI_TYPE_SIMPLE || statusType == NOTI_TYPE_MUTIPLE || statusType == NOTI_TYPE_THUMBNAIL)
110 type = NOTIFICATION_TYPE_NOTI;
112 else if ( statusType == NOTI_TYPE_ONGOING || statusType == NOTI_TYPE_PROGRESS)
114 type = NOTIFICATION_TYPE_ONGOING;
118 LogInfo(" invalide noti type");
119 throw TypeMismatchException("value is not notification type");
122 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
124 LogInfo("Notification Type : " << type);
126 notification_h noti = notification_create(type); //create notificatin.
129 LogInfo("noti =" << noti);
130 setNotificationHandle((void*)noti);
132 if ( statusType == NOTI_TYPE_PROGRESS)
134 notification_update_progress(noti, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
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),
156 LogInfo("noti : " << noti);
158 notification_h notification = (notification_h)noti;
162 NotificationType type = NOTI_TYPE_NONE;
163 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
164 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
166 notification_get_type(notification, ¬i_type);
167 notification_get_layout(notification, ¬i_layout);
170 if ( noti_type == NOTIFICATION_TYPE_NOTI )
172 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
173 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
175 type = NOTI_TYPE_SIMPLE;
177 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
179 type = NOTI_TYPE_THUMBNAIL;
182 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
184 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
186 type = NOTI_TYPE_ONGOING;
188 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
190 type = NOTI_TYPE_PROGRESS;
194 LogInfo(" notification type =" << type);
196 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
198 setNotificationHandle((void*)notification);
202 if ( type == NOTI_TYPE_PROGRESS)
204 notification_update_progress(notification, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
210 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
211 LogInfo("ret = " << ret);
212 if (ret == NOTIFICATION_ERROR_NONE)
214 LogInfo(" bundle = " << bSvc);
217 LogInfo("bundle is valid");
218 int ret = service_create_event(bSvc, &m_service);
219 if (ret != SERVICE_ERROR_NONE)
221 LogInfo("Service Create Event Error");
222 throw UnknownException("can't make service object");
228 notification_free(notification);
229 throw UnknownException("can't get service data");
235 throw InvalidValuesException("It is not notification object.");
240 StatusNotification::StatusNotification(int privID) :
241 m_notiType(NOTI_TYPE_NONE),
244 m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
247 LogInfo("priv ID : " << privID);
249 notification_h notification = notification_load( NULL, privID); //load notification.
250 LogInfo(" notification " << notification);
254 NotificationType type = NOTI_TYPE_NONE;
255 notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
256 notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
258 notification_get_type(notification, ¬i_type);
259 notification_get_layout(notification, ¬i_layout);
261 if ( noti_type == NOTIFICATION_TYPE_NOTI )
263 if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
264 noti_layout == NOTIFICATION_LY_NOTI_EVENT_MULTIPLE )
266 type = NOTI_TYPE_SIMPLE;
268 else if (noti_layout == NOTIFICATION_LY_NOTI_THUMBNAIL)
270 type = NOTI_TYPE_THUMBNAIL;
273 else if ( noti_type == NOTIFICATION_TYPE_ONGOING)
275 if ( noti_layout == NOTIFICATION_LY_ONGOING_EVENT )
277 type = NOTI_TYPE_ONGOING;
279 else if ( noti_layout == NOTIFICATION_LY_ONGOING_PROGRESS)
281 type = NOTI_TYPE_PROGRESS;
285 LogInfo(" notification type =" << type);
287 setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
288 setNotificationHandle((void*)notification);
292 if ( type == NOTI_TYPE_PROGRESS)
294 notification_update_progress(notification, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
300 int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
301 LogInfo("ret = " << ret);
302 if (ret == NOTIFICATION_ERROR_NONE)
304 LogInfo(" bundle = " << bSvc);
307 LogInfo("bundle is valid");
308 int ret = service_create_event(bSvc, &m_service);
309 if (ret != SERVICE_ERROR_NONE)
311 LogInfo("Service Create Event Error");
312 throw UnknownException("can't make service object");
318 notification_free(notification);
319 throw UnknownException("can't get service data");
325 throw NotFoundException("It is not notification ID or removed notification");
330 StatusNotification::~StatusNotification()
332 LogInfo(" notification = " << m_notiHandle);
335 //clearDetailInfos();
340 LogInfo(" service = " << m_service);
341 if (m_service != NULL)
343 service_destroy(m_service);
347 if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
349 throw UnknownException("notification free failed...");
356 int StatusNotification::getID()
358 int id = -1; // notification not inserted yet.
361 notification_get_id(m_notiHandle, NULL, &id);
367 std::string StatusNotification::getStatusType()
371 if ( NOTI_TYPE_SIMPLE == getNotiType())
375 else if ( NOTI_TYPE_ONGOING == getNotiType())
379 else if ( NOTI_TYPE_PROGRESS == getNotiType())
383 else if ( NOTI_TYPE_THUMBNAIL == getNotiType())
394 void StatusNotification::setStatusType(std::string type)
396 LogInfo("type = " << type);
398 NotificationType notiType = NOTI_TYPE_NONE;
400 if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_SIMPLE) == 0)
401 notiType = NOTI_TYPE_SIMPLE;
402 else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_THUMBNAIL) == 0)
403 notiType = NOTI_TYPE_THUMBNAIL;
404 else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_ONGOING) == 0)
405 notiType = NOTI_TYPE_ONGOING;
406 else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_PROGRESS) == 0)
407 notiType = NOTI_TYPE_PROGRESS;
409 throw InvalidValuesException("Invalid Status Type.");
411 LogInfo("Notification type = " << notiType);
412 setNotiType(notiType);
415 time_t StatusNotification::getPostedTime()
417 LogInfo("get m_notiHandle = " << m_notiHandle);
419 time_t postedTime = 0;
423 if (notification_get_insert_time(m_notiHandle, &postedTime) != NOTIFICATION_ERROR_NONE)
425 throw UnknownException("get notification posted time error");
429 LogInfo("posted Time =" << ctime(&postedTime));
433 std::string StatusNotification::getTitle()
439 if (notification_get_text(m_notiHandle,NOTIFICATION_TEXT_TYPE_TITLE, &title) != NOTIFICATION_ERROR_NONE)
441 throw UnknownException("get notification title error");
444 std::string notiTitle(title);
449 throw UnknownException("notification handle is null");
453 void StatusNotification::setTitle(std::string title)
455 LogInfo("Title : " << title);
458 LogInfo("get Title : " << getTitle());
459 if((getTitle()).compare(title)) //different value.
461 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_TITLE, title.c_str(),
462 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
464 throw UnknownException("set notification title error");
467 setUpdatedFlag(true);
471 LogInfo(" title = " << title << " getTitle = " << getTitle());
476 LogDebug("noti Handle is NULL");
477 throw UnknownException("notification handle is null");
482 std::string StatusNotification::getContent()
484 LogInfo("get Content handle: " << m_notiHandle);
487 char *content = NULL;
489 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) != NOTIFICATION_ERROR_NONE)
491 throw UnknownException("get notification Content error");
494 LogInfo(" get Content : " << content);
496 std::string notiContent;
499 notiContent = content;
506 throw UnknownException("notification handle is null");
511 void StatusNotification::setContent(std::string content)
513 LogInfo("Content : " << content);
516 if((getContent()).compare(content)) //different value.
518 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, content.c_str(),
519 NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
521 throw UnknownException("set notification content error");
523 setUpdatedFlag(true);
528 LogDebug("noti Handle is NULL");
529 throw UnknownException("notification handle is null");
533 std::string StatusNotification::getIconPath()
536 LogInfo("m_notiHandle = " << m_notiHandle);
539 char *iconPath = NULL;
540 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON, &iconPath) != NOTIFICATION_ERROR_NONE)
542 throw UnknownException("get notification icon path error");
545 std::string notiIconPath(iconPath);
546 LogInfo("icon Path = " << iconPath);
548 //if icon path invalid, return empty string.
549 if ( notiIconPath.find(DEFAULT_ICON_PATH,0) == std::string::npos)
553 return std::string(""); //return empty string.
558 throw UnknownException("notification handle is null");
562 void StatusNotification::setIconPath(const std::string& iconPath)
566 LogInfo("icon path = " << iconPath << " origin icon path = " << getIconPath());
567 if( getIconPath().compare(iconPath))
569 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON, iconPath.c_str()) != NOTIFICATION_ERROR_NONE)
571 throw UnknownException("set notification icon error");
573 setUpdatedFlag(true);
578 LogDebug("noti Handle is NULL");
579 throw UnknownException("notification handle is null");
583 std::string StatusNotification::getSoundPath()
585 LogInfo("Handle = " << m_notiHandle);
589 const char *soundPath = NULL;
590 notification_sound_type_e type = NOTIFICATION_SOUND_TYPE_NONE;
592 if (notification_get_sound(m_notiHandle, &type, &soundPath) != NOTIFICATION_ERROR_NONE)
594 throw UnknownException("get notification sound error");
597 LogInfo(" sound type = " << type << " path = " << soundPath);
598 if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
600 LogInfo("soundPath = " << soundPath);
601 return std::string(soundPath);
605 return std::string("");
610 LogDebug("noti Handle is NULL");
611 throw UnknownException("notification handle is null");
615 void StatusNotification::setSoundPath(const std::string& sound)
619 LogInfo("sound path = " << sound << " origin sound path = " << getSoundPath());
621 if( getSoundPath().compare(sound))
623 if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_USER_DATA, sound.c_str()) != NOTIFICATION_ERROR_NONE)
625 throw UnknownException("set notification sound error");
627 setUpdatedFlag(true);
632 LogInfo("sound path is NULL");
633 if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_DEFAULT, sound.c_str()) != NOTIFICATION_ERROR_NONE)
635 throw UnknownException("set notification sound error");
641 LogDebug("noti Handle is NULL");
642 throw UnknownException("notification handle is null");
646 bool StatusNotification::getDefaultVibration()
648 LogInfo("getDefaultVibration");
651 notification_vibration_type_e vib_type;
652 if (notification_get_vibration(m_notiHandle, &vib_type, NULL) != NOTIFICATION_ERROR_NONE)
654 throw UnknownException("set notification sound error");
657 if (vib_type == NOTIFICATION_VIBRATION_TYPE_DEFAULT)
668 LogDebug("noti Handle is NULL");
669 throw UnknownException("notification handle is null");
675 void StatusNotification::setDefaultVibration(const bool& vibration)
677 LogInfo("vibration = " << vibration);
680 notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
682 if (getDefaultVibration() != vibration)
686 vib_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
689 if (notification_set_vibration(m_notiHandle, vib_type , NULL) != NOTIFICATION_ERROR_NONE)
691 throw UnknownException("set notification sound error");
693 setUpdatedFlag(true);
698 LogDebug("noti Handle is NULL");
699 throw UnknownException("notification handle is null");
704 DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
707 service_h service = NULL;
708 char *tempStr = NULL;
710 DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
715 appControl->setService_h(m_service);
717 if(service_get_operation(m_service, &tempStr) == SERVICE_ERROR_NONE)
719 LogDebug("Operation Str = " << tempStr);
722 appControl->setOperation(tempStr);
729 if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
731 LogDebug("Mime Str = " << tempStr);
734 appControl->setMime(tempStr);
741 if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
743 LogDebug("Uri Str = " << tempStr);
746 appControl->setUri(tempStr);
752 if (service_get_category(m_service, &tempStr) == SERVICE_ERROR_NONE)
754 LogDebug("Category Str = " << tempStr);
757 appControl->setCategory(tempStr);
764 if ( service_foreach_extra_data(m_service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
766 ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
773 Catch (WrtDeviceApis::Commons::Exception)
787 LogWarning(_rethrown_exception.GetMessage());
793 void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr control)
795 LogInfo("Entered m_service : " << m_service << " control : " << control);
797 //delete old service.
800 service_destroy(m_service);
804 if(service_create(&m_service) != SERVICE_ERROR_NONE)
806 throw UnknownException("service creation error");
810 LogInfo("getOperation : " << control->getOperation().c_str());
811 if (control->getOperation().size() != 0)
813 if (service_set_operation(m_service, control->getOperation().c_str()) != SERVICE_ERROR_NONE)
815 throw UnknownException("service set operation error");
820 LogInfo("getUri : " << control->getUri().c_str());
821 if (control->getUri().size() != 0)
823 if (service_set_uri(m_service, control->getUri().c_str() ) != SERVICE_ERROR_NONE)
825 throw UnknownException("service set uri error");
830 LogInfo("getMime : " << control->getMime().c_str());
831 if (control->getMime().size() != 0)
833 if (service_set_mime(m_service, control->getMime().c_str() ) != SERVICE_ERROR_NONE)
835 throw UnknownException("service set mime error");
839 LogInfo("Category : " << control->getCategory().c_str());
840 if (control->getCategory().size() != 0)
842 if (service_set_category(m_service, control->getCategory().c_str() ) != SERVICE_ERROR_NONE)
844 throw UnknownException("service set mime error");
849 //if ( service_foreach_extra_data(m_service, service_extra_data_delete_cb, NULL) != SERVICE_ERROR_NONE)
851 // throw UnknownException("get notification service uri error");
854 std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = control->getAppControlDataArray();
857 LogInfo (" App Control Datas Count : " << appControlDataArray.size());
859 DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
861 for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
863 DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
864 std::string key = appControlData->getKey();
865 LogInfo(" key : " << key);
870 std::vector<std::string> value = appControlDataArray[index]->getValue();
871 const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
873 for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
875 arrayValue[indexArray] = (char*)value[indexArray].c_str();
876 LogInfo( " value : " << arrayValue[indexArray]);
879 const char* strKey = key.c_str();
880 LogInfo( " value size: " << value.size());
881 if (service_add_extra_data_array(m_service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
883 throw UnknownException("service set extra data error");
890 bundle *bundle_data=NULL;
892 if(service_to_bundle(m_service, &bundle_data) != SERVICE_ERROR_NONE)
894 throw UnknownException("service get bundle");
897 LogDebug("bundle_data : " << bundle_data);
901 notification_set_execute_option(m_notiHandle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
902 NULL,NULL, bundle_data);
909 void StatusNotification::setApplicationId(const std::string& appId)
911 LogInfo("m_service = " << m_service << " appId = " << appId);
914 if (service_create(&m_service) != SERVICE_ERROR_NONE)
916 LogWarning("Create Service Failed..");
917 throw DeviceAPI::Common::UnknownException ("service creation error");
923 if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
925 throw DeviceAPI::Common::UnknownException ("service set appId error");
931 std::string StatusNotification::getApplicationId()
933 std::string retString;
934 service_h service = NULL;
935 char* appIdStr = NULL;
937 if (m_service != NULL)
940 retcode = service_clone(&service, m_service);
942 if (retcode != SERVICE_ERROR_NONE)
944 if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
946 LogWarning("SERVICE_ERROR_OUT_OF_MEMORY");
950 LogWarning("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
952 throw DeviceAPI::Common::UnknownException ("get notification service error ");
958 throw DeviceAPI::Common::UnknownException ("get notification service ok, but service null");
965 if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
967 throw DeviceAPI::Common::UnknownException ("get a appId error");
970 if (appIdStr != NULL)
972 retString = appIdStr;
982 double StatusNotification::getProgressValue()
988 NotificationProgressType progressType = getProgressType();
990 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
992 if (notification_get_size(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
994 throw UnknownException("get notification size error");
996 LogInfo("Size Val = " << value);
998 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
1000 if (notification_get_progress(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
1002 throw UnknownException("get notification percentage error");
1004 LogInfo("Percentage Val = " << value);
1008 throw UnknownException("get notification progress type error");
1013 LogDebug("noti Handle is NULL");
1015 LogInfo("value = " << value);
1020 void StatusNotification::setProgressValue(const double &progressValue)
1024 NotificationProgressType progressType = getProgressType();
1025 LogInfo("Progress Type : " << progressType);
1027 double val = getProgressValue();
1028 LogInfo("Progress value = " << progressValue << " origin Progress Value =" << val);
1030 if (progressType == NOTI_PROGRESS_TYPE_SIZE)
1032 if (notification_set_size(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
1034 throw UnknownException("set notification progress size error");
1037 else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
1039 if (notification_set_progress(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
1041 throw UnknownException("set notification percentage error");
1046 throw UnknownException("get notification progress type error");
1051 LogDebug("noti Handle is NULL");
1052 throw UnknownException( "notification handle is null");
1056 std::string StatusNotification::getSubIconPath()
1058 LogInfo("Handle = " << m_notiHandle);
1061 char *subIconPath = NULL;
1063 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &subIconPath) != NOTIFICATION_ERROR_NONE)
1065 throw UnknownException("get notification sub icon error");
1068 std::string notiSubIconPath;
1070 notiSubIconPath = subIconPath;
1071 return notiSubIconPath;
1075 throw UnknownException("notification handle is null");
1080 void StatusNotification::setSubIconPath(const std::string& subIconPath)
1084 LogInfo(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
1086 if( getSubIconPath().compare(subIconPath))
1088 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON_SUB, subIconPath.c_str()) != NOTIFICATION_ERROR_NONE)
1090 throw UnknownException("set notification sound error");
1092 setUpdatedFlag(true);
1097 LogDebug("noti Handle is NULL");
1098 throw UnknownException("notification handle is null");
1103 std::string StatusNotification::getInformation(int index)
1107 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1111 type = NOTIFICATION_TEXT_TYPE_INFO_1;
1114 type = NOTIFICATION_TEXT_TYPE_INFO_2;
1117 type = NOTIFICATION_TEXT_TYPE_INFO_3;
1120 type = NOTIFICATION_TEXT_TYPE_NONE;
1124 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
1126 throw UnknownException("get notification information error");
1129 std::string strInfo;
1132 LogDebug(" info " << strInfo);
1138 LogDebug("noti Handle is NULL");
1139 throw UnknownException("notification handle is null");
1144 void StatusNotification::setInformation( const std::string& info, int index)
1150 LogDebug(" index : " << idx);
1151 LogDebug(" log : " << info);
1152 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1157 type = NOTIFICATION_TEXT_TYPE_INFO_1;
1160 type = NOTIFICATION_TEXT_TYPE_INFO_2;
1163 type = NOTIFICATION_TEXT_TYPE_INFO_3;
1166 type = NOTIFICATION_TEXT_TYPE_NONE;
1169 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1171 if (getInformation(idx).compare(info))
1173 if (notification_set_text(m_notiHandle, type, info.c_str(),
1174 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1176 throw UnknownException("set notification sound error");
1178 setUpdatedFlag(true);
1184 LogDebug("noti Handle is NULL");
1185 throw UnknownException("notification handle is null");
1189 std::string StatusNotification::getSubInformation(int index)
1194 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1198 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1201 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1204 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1207 type = NOTIFICATION_TEXT_TYPE_NONE;
1210 char *subInfo = NULL;
1212 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
1214 throw UnknownException( "get notification sub information error");
1217 std::string strSubInfo;
1219 strSubInfo = subInfo;
1220 LogDebug(" subInfo " << strSubInfo);
1226 LogDebug("noti Handle is NULL");
1227 throw UnknownException( "notification handle is null");
1232 void StatusNotification::setSubInformation( const std::string& subInfo, int index)
1237 LogDebug(" index : " << idx);
1238 LogDebug(" log : " << subInfo);
1239 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1244 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1247 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1250 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1253 type = NOTIFICATION_TEXT_TYPE_NONE;
1256 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1258 if (getSubInformation(idx).compare(subInfo))
1260 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
1261 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1263 throw UnknownException( "set notification sound error");
1265 setUpdatedFlag(true);
1271 LogDebug("noti Handle is NULL");
1272 throw UnknownException( "notification handle is null");
1278 void StatusNotification::loadThumbnails()
1282 if (!m_thumbs.empty())
1286 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
1288 throw UnknownException( "get notification thumbnail error");
1291 m_thumbs.push_back(thumb);
1293 // m_thumbs.push_back(std::string("")); //set empty
1296 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
1298 throw UnknownException( "get notification sub information error");
1301 m_thumbs.push_back(thumb);
1303 // m_thumbs.push_back(std::string("")); //set empty
1306 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
1308 throw UnknownException( "get notification sub information error");
1312 m_thumbs.push_back(thumb);
1314 // m_thumbs.push_back(std::string("")); //set empty
1317 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
1319 throw UnknownException( "get notification sub information error");
1323 m_thumbs.push_back(thumb);
1325 // m_thumbs.push_back(std::string("")); //set empty
1328 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
1330 throw UnknownException( "get notification sub information error");
1334 m_thumbs.push_back(thumb);
1336 m_thumbs.push_back(std::string("")); //set empty
1343 LogDebug("noti Handle is NULL");
1344 throw UnknownException( "notification handle is null");
1348 std::vector<std::string> StatusNotification::getThumbnails()
1350 LogInfo(" thumbnail Size : " << m_thumbs.size());
1354 std::string StatusNotification::getThumbnail(int index)
1358 LogInfo(" index : " << index);
1360 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1365 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1368 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1371 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1374 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1377 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1380 type = NOTIFICATION_IMAGE_TYPE_NONE;
1383 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1386 if (notification_get_image(m_notiHandle, type, &thumb) != NOTIFICATION_ERROR_NONE)
1388 throw UnknownException( "set notification thumbnail error");
1391 std::string thumbnail;
1398 throw UnknownException( "notification handle is null");
1404 LogDebug("noti Handle is NULL");
1405 throw UnknownException( "notification handle is null");
1408 if (m_thumbs.size() > index)
1409 return m_thumbs[index];
1411 return std::string("");
1416 void StatusNotification::setThumbnails(std::vector<std::string> thumbs)
1418 LogInfo("set thumbnails");
1421 std::vector<std::string>::iterator it;
1424 for (it = thumbs.begin(); it < thumbs.end(); ++it)
1426 std::string str = *it;
1427 if ( idx < MAX_THUMBNAIL_LENGTH )
1428 setThumbnail(str, idx); //set notification's thumbnail value.
1436 LogDebug("noti Handle is NULL");
1437 throw UnknownException( "notification handle is null");
1441 void StatusNotification::setThumbnail( const std::string& thumb, int index)
1445 LogInfo(" index : " << index);
1446 LogInfo(" thumb : " << thumb);
1447 notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
1452 type = NOTIFICATION_IMAGE_TYPE_LIST_1;
1455 type = NOTIFICATION_IMAGE_TYPE_LIST_2;
1458 type = NOTIFICATION_IMAGE_TYPE_LIST_3;
1461 type = NOTIFICATION_IMAGE_TYPE_LIST_4;
1464 type = NOTIFICATION_IMAGE_TYPE_LIST_5;
1467 type = NOTIFICATION_IMAGE_TYPE_NONE;
1470 if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
1472 if (getThumbnail(index).compare(thumb))
1474 if (notification_set_image(m_notiHandle, type, thumb.c_str()) != NOTIFICATION_ERROR_NONE)
1476 throw UnknownException( "set notification thumbnail error");
1478 setUpdatedFlag(true);
1484 std::string StatusNotification::getBackground()
1486 LogInfo(" Handle : " << m_notiHandle);
1490 char *background = NULL;
1492 if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &background) != NOTIFICATION_ERROR_NONE)
1494 throw UnknownException( "get notification background error");
1497 std::string notiBackground;
1499 notiBackground = background;
1500 return notiBackground;
1504 LogDebug("noti Handle is NULL");
1505 throw UnknownException( "notification handle is null");
1510 void StatusNotification::setBackground(const std::string imagePath)
1512 LogInfo(" imagePath : " << imagePath);
1515 if (getBackground().compare(imagePath))
1517 if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_BACKGROUND, imagePath.c_str()) != NOTIFICATION_ERROR_NONE)
1519 throw UnknownException( "set notification sound error");
1521 setUpdatedFlag(true);
1526 LogDebug("noti Handle is NULL");
1527 throw UnknownException( "notification handle is null");
1531 unsigned int StatusNotification::getNumber()
1533 LogInfo("Handle = " << m_notiHandle);
1537 char *strNumber = NULL;
1539 if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
1541 throw UnknownException( "get notification background error");
1545 std::istringstream(strNumber) >> number;
1547 LogInfo("number = " << number);
1555 LogDebug("noti Handle is NULL");
1560 void StatusNotification::setNumber(const unsigned int number)
1562 LogInfo("Number = " << number);
1565 if(number!=getNumber())
1567 std::stringstream stream;
1569 if (stream.fail()) {
1570 throw UnknownException(
1571 "Couldn't convert e-mail account id");
1574 std::string strNumber = stream.str();
1575 if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, strNumber.c_str(),
1576 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1578 throw UnknownException( "set notification sound error");
1580 setUpdatedFlag(true);
1585 LogDebug("noti Handle is NULL");
1586 throw UnknownException( "notification handle is null");
1590 void* StatusNotification::getNotificationHandle()
1592 return m_notiHandle;
1595 void StatusNotification::setNotificationHandle(void *handle)
1599 throw UnknownException( "notification handle null error");
1601 LogInfo("handle = " << handle << " m_notiHandle = " << m_notiHandle);
1603 if (m_notiHandle != NULL)
1606 if ( notification_delete(m_notiHandle) != NOTIFICATION_ERROR_NONE)
1608 throw UnknownException( "notification delete error");
1610 m_notiHandle = NULL;
1613 m_notiHandle = (notification_h)handle;
1616 service_h StatusNotification::getService()
1623 void StatusNotification::loadDetailInfos()
1625 LogInfo("noti Handle = " << m_notiHandle);
1629 for ( int idx = 0; idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH; idx++)
1631 std::string main = getInformation(idx);
1632 std::string sub = getSubInformation(idx);
1633 LogInfo("Main : " << main << " Sub : " << sub);
1634 NotificationDetailInfo *info = new NotificationDetailInfo(m_notiHandle, idx, main, sub);
1635 m_detailInfos.push_back(info);
1640 LogDebug("noti Handle is NULL");
1641 throw UnknownException( "notification handle is null");
1646 std::vector<NotificationDetailInfo*> StatusNotification::getDetailInfos() const
1648 return m_detailInfos;
1651 void StatusNotification::setDetailInfos(const std::vector<NotificationDetailInfo*> value)
1653 LogInfo("DetailInfos = " << value.size());
1657 std::vector<NotificationDetailInfo*>::const_iterator it;
1660 for (it = value.begin(); it < value.end(); ++it)
1662 NotificationDetailInfo* info = *it;
1663 if ( idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH )
1665 LogInfo("main " << info->getMainText() << " sub " << info->getSubText() );
1666 setInformation(info->getMainText(), idx);
1667 setSubInformation(info->getSubText(), idx);
1672 m_detailInfos = value;
1676 LogDebug("noti Handle is NULL");
1677 throw UnknownException( "notification handle is null");
1682 int StatusNotification::getDetailInfosNum() const
1684 return m_detailInfos.size();
1687 void StatusNotification::clearDetailInfos()
1689 if ( !m_detailInfos.empty() )
1691 std::vector<NotificationDetailInfo*>::const_iterator it;
1694 for (it = m_detailInfos.begin(); it < m_detailInfos.end(); ++it)
1696 NotificationDetailInfo* info = *it;
1697 LogInfo("Delete Detail Info : " << info);
1702 m_detailInfos.clear(); //clear
1706 std::string StatusNotification::getInformation(int index)
1710 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1714 type = NOTIFICATION_TEXT_TYPE_INFO_1;
1717 type = NOTIFICATION_TEXT_TYPE_INFO_2;
1720 type = NOTIFICATION_TEXT_TYPE_INFO_3;
1723 type = NOTIFICATION_TEXT_TYPE_NONE;
1727 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
1729 throw UnknownException("Detail Info index value is invalid or mainText value getting is failed in Detail Info.");
1732 std::string strInfo;
1735 LogInfo(" info " << strInfo);
1741 LogWarning("noti Handle is NULL");
1742 throw UnknownException( "notification handle is null");
1747 std::string StatusNotification::getSubInformation(int index)
1751 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1755 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1758 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1761 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1764 type = NOTIFICATION_TEXT_TYPE_NONE;
1767 char *subInfo = NULL;
1769 if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
1771 throw UnknownException("Detail Info index value is invalid or subText value getting is failed in Detail Info.");
1774 std::string strSubInfo;
1776 strSubInfo = subInfo;
1777 LogInfo(" subInfo " << strSubInfo);
1783 LogWarning("noti Handle is NULL");
1784 throw UnknownException ("notification handle is null");
1789 void StatusNotification::setInformation( const std::string& info, int index)
1794 LogDebug(" index : " << idx);
1795 LogDebug(" log : " << info);
1796 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1801 type = NOTIFICATION_TEXT_TYPE_INFO_1;
1804 type = NOTIFICATION_TEXT_TYPE_INFO_2;
1807 type = NOTIFICATION_TEXT_TYPE_INFO_3;
1810 type = NOTIFICATION_TEXT_TYPE_NONE;
1813 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1815 if (getInformation(idx).compare(info))
1817 if (notification_set_text(m_notiHandle, type, info.c_str(),
1818 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1820 throw UnknownException("set notification sound error");
1822 setUpdatedFlag(true);
1827 LogWarning("noti Handle is NULL");
1828 throw UnknownException("notification handle is null");
1833 LogWarning("noti Handle is NULL");
1834 throw UnknownException("notification handle is null");
1838 void StatusNotification::setSubInformation( const std::string& subInfo, int index)
1844 LogDebug(" index : " << idx);
1845 LogDebug(" log : " << subInfo);
1846 notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
1851 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
1854 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
1857 type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
1860 type = NOTIFICATION_TEXT_TYPE_NONE;
1863 if ( type != NOTIFICATION_TEXT_TYPE_NONE)
1865 if (getSubInformation(idx).compare(subInfo))
1867 if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
1868 NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
1870 throw UnknownException("set notification sound error");
1872 setUpdatedFlag(true);
1878 LogWarning("noti Handle is NULL");
1879 throw UnknownException("notification handle is null");
1886 StatusNotification::StatusNotification():
1891 m_backgroundImagePath(""),
1899 StatusNotification::~StatusNotification()
1903 std::string StatusNotification::getStatusType() const
1905 return m_statusType;
1908 void StatusNotification::setStatusType(std::string statusType)
1910 m_statusType = statusType;
1913 std::string StatusNotification::getIconPath() const
1918 void StatusNotification::setIconPath(std::string iconPath)
1920 m_iconPath = iconPath;
1923 std::string StatusNotification::getSubIconPath() const
1925 return m_subIconPath;
1928 void StatusNotification::setSubIconPath(std::string subIconPath)
1930 m_subIconPath = subIconPath;
1933 long StatusNotification::getNumber() const
1938 void StatusNotification::setNumber(long number)
1943 std::vector<NotificationDetailInfo*> StatusNotification::getDetailInfo() const
1945 return m_detailInfo;
1948 void StatusNotification::setDetailInfo(std::vector<NotificationDetailInfo*> detailInfo)
1950 m_detailInfo = detailInfo;
1953 std::string StatusNotification::getBackgroundImagePath() const
1955 return m_backgroundImagePath;
1958 void StatusNotification::setBackgroundImagePath(std::string backgroundImagePath)
1960 m_backgroundImagePath = backgroundImagePath;
1963 std::vector<std::string> StatusNotification::getThumbnails() const
1965 return m_thumbnails;
1968 void StatusNotification::setThumbnails(std::vector<std::string> thumbnails)
1970 m_thumbnails = thumbnails;
1973 std::string StatusNotification::getSoundPath() const
1978 void StatusNotification::setSoundPath(std::string soundPath)
1980 m_soundPath = soundPath;
1983 bool StatusNotification::getVibration() const
1988 void StatusNotification::setVibration(bool vibration)
1990 m_vibration = vibration;
1993 ApplicationControl StatusNotification::getAppControl() const
1995 return m_appControl;
1998 void StatusNotification::setAppControl(ApplicationControl appControl)
2000 m_appControl = appControl;
2003 ApplicationId StatusNotification::getAppId() const
2008 void StatusNotification::setAppId(ApplicationId appId)
2013 std::string StatusNotification::getProgressType() const
2015 return m_progressType;
2018 void StatusNotification::setProgressType(std::string progressType)
2020 m_progressType = progressType;
2023 unsigned long StatusNotification::getProgressValue() const
2025 return m_progressValue;
2028 void StatusNotification::setProgressValue(unsigned long progressValue)
2030 m_progressValue = progressValue;