#include <Logger.h>
#include <sstream>
#include <appsvc/appsvc.h>
+#include <sstream>
+#include <boost/algorithm/string.hpp>
#include "StatusNotification.h"
namespace DeviceAPI {
#define MAX_THUMBNAIL_LENGTH 4
extern "C" int service_create_event(bundle *data, struct service_s **service);
-extern "C" int service_to_bundle(service_h service, bundle **data);
+//tern "C" int service_to_bundle(service_h service, bundle **data);
//callback functions.
static bool service_extra_data_cb(service_h service, const char *key, void *user_data)
{
- LogInfo("OK");
+ LoggerI("OK");
char **value = NULL;
int length = 0;
if (user_data != NULL && key != NULL)
{
- LogInfo("user data & key is existed");
+ LoggerI("user data & key is existed");
DeviceAPI::Application::ApplicationControlPtr* appControl =
(DeviceAPI::Application::ApplicationControlPtr*)(user_data);
DeviceAPI::Application::ApplicationControlDataPtr data(new DeviceAPI::Application::ApplicationControlData());
- LogInfo("key = " << key);
+ LoggerI("key = " << key);
std::string keyStr = key;
std::vector<std::string> keyValue;
int index = 0;
if (service_get_extra_data_array((*appControl)->getService_h(), key, &value, &length) == SERVICE_ERROR_NONE)
{
- LogInfo("extra_data_array length = " << length);
+ LoggerI("extra_data_array length = " << length);
if (value != NULL && length != 0)
{
- LogInfo("extra_data_length = " << length);
+ LoggerI("extra_data_length = " << length);
data->setKey(key);
for (index = 0; index < length; index++)
{
- LogInfo("Value=" << value[index]);
+ LoggerI("Value=" << value[index]);
keyValue.push_back(value[index]);
}
return true;
}
-static bool service_extra_data_delete_cb(service_h service, const char *key, void *user_data)
-{
- LogInfo("OK");
- if (key != NULL)
- {
- LogInfo("del key = " << key);
-
- if (service_remove_extra_data(service, key) != SERVICE_ERROR_NONE)
- {
- LogWarning("remove extra data failed");
- return false;
- }
- }
- return true;
-}
-
StatusNotification::StatusNotification(NotificationType statusType) :
m_notiType(NOTI_TYPE_NONE),
m_service(NULL),
m_notiHandle(NULL),
m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
- m_notiUpdated(false)
+ m_notiUpdated(false),
+ m_launchFlag(false)
{
- LogInfo("statusType =" << statusType);
+ LoggerI("statusType =" << statusType);
notification_type_e type = NOTIFICATION_TYPE_NONE;
setNotiType(statusType);
}
else
{
- LogInfo(" invalide noti type");
+ LoggerI(" invalide noti type");
throw TypeMismatchException("value is not notification type");
}
- setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
+ //setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
- LogInfo("Notification Type : " << type);
+ LoggerI("Notification Type : " << type);
notification_h noti = notification_create(type); //create notificatin.
if ( noti )
{
- LogInfo("noti =" << noti);
+ LoggerI("noti =" << noti);
setNotificationHandle((void*)noti);
if (NOTIFICATION_TYPE_ONGOING == type)
{ //ongoing no ticker.
- LogInfo("ongoing type");
- notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY |NOTIFICATION_DISPLAY_APP_INDICATOR );
+ LoggerI("ongoing type");
+ if ( NOTIFICATION_ERROR_NONE != notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY |NOTIFICATION_DISPLAY_APP_INDICATOR ))
+ {
+ throw UnknownException("can't set notification display applist");
+ }
}
+
}
else
{
m_service(NULL),
m_notiHandle(NULL),
m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
- m_notiUpdated(false)
+ m_notiUpdated(false),
+ m_launchFlag(false)
{
- LogInfo("noti : " << noti);
+ LoggerI("noti : " << noti);
notification_h notification = (notification_h)noti;
}
}
- LogInfo(" notification type =" << type);
+ LoggerI(" notification type =" << type);
setNotiType(type);
- setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
+ //setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
+ //read Progress type value.
+ char *strProgressType = NULL;
+ if (NOTIFICATION_ERROR_NONE == notification_get_image(notification, NOTIFICATION_IMAGE_TYPE_LIST_5, &strProgressType))
+ {
+ if ( strProgressType )
+ {
+ std::string notiProgressType(strProgressType);
+ if( notiProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
+ m_progressType = NOTI_PROGRESS_TYPE_SIZE;
+ }
+ }
setNotificationHandle((void*)notification);
loadThumbnails();
loadDetailInfos();
+#if 0
if ( type == NOTI_TYPE_PROGRESS)
{
notification_update_progress(notification, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
}
-
+#endif
//service
bundle *bSvc = NULL;
int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
- LogInfo("ret = " << ret);
+ LoggerI("ret = " << ret);
if (ret == NOTIFICATION_ERROR_NONE)
{
- LogInfo(" bundle = " << bSvc);
+ LoggerI(" bundle = " << bSvc);
if (bSvc)
{
- LogInfo("bundle is valid");
+ LoggerI("bundle is valid");
int ret = service_create_event(bSvc, &m_service);
if (ret != SERVICE_ERROR_NONE)
{
- LogInfo("Service Create Event Error");
+ LoggerI("Service Create Event Error");
throw UnknownException("can't make service object");
}
}
m_service(NULL),
m_notiHandle(NULL),
m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
- m_notiUpdated(false)
+ m_notiUpdated(false),
+ m_launchFlag(false)
{
- LogInfo("priv ID : " << privID);
+ LoggerI("priv ID : " << privID);
notification_h notification = notification_load( NULL, privID); //load notification.
- LogInfo(" notification " << notification);
+ LoggerI(" notification " << notification);
if ( notification )
{
}
}
- LogInfo(" notification type =" << type);
+ LoggerI(" notification type =" << type);
setNotiType(type);
- setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
+ //setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default.
+ //read Progress type value.
+ char *strProgressType = NULL;
+ if (NOTIFICATION_ERROR_NONE == notification_get_image(notification, NOTIFICATION_IMAGE_TYPE_LIST_5, &strProgressType))
+ {
+ if ( strProgressType )
+ {
+ std::string notiProgressType(strProgressType);
+ if( notiProgressType.compare(TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE) == 0)
+ m_progressType = NOTI_PROGRESS_TYPE_SIZE;
+ }
+ }
+
setNotificationHandle((void*)notification);
loadThumbnails();
loadDetailInfos();
-
+#if 0
if ( type == NOTI_TYPE_PROGRESS)
{
notification_update_progress(notification, NOTIFICATION_PRIV_ID_NONE, getProgressValue());
}
-
+#endif
//service
bundle *bSvc = NULL;
int ret = notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc);
- LogInfo("ret = " << ret);
+ LoggerI("ret = " << ret);
if (ret == NOTIFICATION_ERROR_NONE)
{
- LogInfo(" bundle = " << bSvc);
+ LoggerI(" bundle = " << bSvc);
if (bSvc)
{
- LogInfo("bundle is valid");
+ LoggerI("bundle is valid");
int ret = service_create_event(bSvc, &m_service);
if (ret != SERVICE_ERROR_NONE)
{
- LogInfo("Service Create Event Error");
+ LoggerI("Service Create Event Error");
throw UnknownException("can't make service object");
}
}
StatusNotification::~StatusNotification()
{
- LogInfo(" notification = " << m_notiHandle);
+ LoggerI(" notification = " << m_notiHandle);
//clear thumbnail.
//clearDetailInfos();
if (m_notiHandle)
{
-#if 0
- LogInfo(" service = " << m_service);
+ LoggerI(" service = " << m_service);
if (m_service != NULL)
{
service_destroy(m_service);
m_service = NULL;
}
-#endif
+
if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
{
throw UnknownException("notification free failed...");
void StatusNotification::setStatusType(std::string type)
{
- LogInfo("type = " << type);
+ LoggerI("type = " << type);
NotificationType notiType = NOTI_TYPE_NONE;
else
throw InvalidValuesException("Invalid Status Type.");
- LogInfo("Notification type = " << notiType);
+ LoggerI("Notification type = " << notiType);
setNotiType(notiType);
}
time_t StatusNotification::getPostedTime()
{
- LogInfo("get m_notiHandle = " << m_notiHandle);
+ LoggerI("get m_notiHandle = " << m_notiHandle);
time_t postedTime = 0;
}
}
- LogInfo("posted Time =" << ctime(&postedTime));
+ LoggerI("posted Time =" << ctime(&postedTime));
return postedTime;
}
throw UnknownException("get notification title error");
}
- std::string notiTitle(title);
+ std::string notiTitle;
+ if (title)
+ {
+ notiTitle = title;
+ LoggerI(" get title : " << title);
+ }
+
return notiTitle;
}
else
void StatusNotification::setTitle(std::string title)
{
- LogInfo("Title : " << title);
+ LoggerI("Title : " << title);
if (m_notiHandle)
{
- LogInfo("get Title : " << getTitle());
+ LoggerI("get Title : " << getTitle());
if((getTitle()).compare(title)) //different value.
{
if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_TITLE, title.c_str(),
}
else
{
- LogInfo(" title = " << title << " getTitle = " << getTitle());
+ LoggerI(" title = " << title << " getTitle = " << getTitle());
}
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
-
std::string StatusNotification::getContent()
{
- LogInfo("get Content handle: " << m_notiHandle);
+ LoggerI("get Content handle: " << m_notiHandle);
if (m_notiHandle)
{
char *content = NULL;
throw UnknownException("get notification Content error");
}
- LogInfo(" get Content : " << content);
-
std::string notiContent;
if(content)
+ {
notiContent = content;
+ LoggerI(" get Content : " << content);
+ }
return notiContent;
}
+char* StatusNotification::getStrContent()
+{
+ LoggerI("get Content handle: " << m_notiHandle);
+ if (m_notiHandle)
+ {
+ char *content = NULL;
+
+ if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, &content) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("get notification Content error");
+ }
+
+ return content;
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
void StatusNotification::setContent(std::string content)
{
- LogInfo("Content : " << content);
+ LoggerI("Content : " << content);
if (m_notiHandle)
{
if((getContent()).compare(content)) //different value.
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
std::string StatusNotification::getIconPath()
{
- LogInfo("m_notiHandle = " << m_notiHandle);
+ LoggerI("m_notiHandle = " << m_notiHandle);
if (m_notiHandle)
{
char *iconPath = NULL;
throw UnknownException("get notification icon path error");
}
- std::string notiIconPath(iconPath);
- LogInfo("icon Path = " << iconPath);
+ std::string notiIconPath;
+ if (iconPath)
+ {
+ notiIconPath = iconPath;
+ LoggerI("icon Path = " << iconPath);
+ }
//if icon path invalid, return empty string.
if ( notiIconPath.find(DEFAULT_ICON_PATH,0) == std::string::npos)
{
if (m_notiHandle)
{
- LogInfo("icon path = " << iconPath << " origin icon path = " << getIconPath());
+ LoggerI("icon path = " << iconPath << " origin icon path = " << getIconPath());
if( getIconPath().compare(iconPath))
{
if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON, iconPath.c_str()) != NOTIFICATION_ERROR_NONE)
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
std::string StatusNotification::getSoundPath()
{
- LogInfo("Handle = " << m_notiHandle);
+ LoggerI("Handle = " << m_notiHandle);
if (m_notiHandle)
{
{
throw UnknownException("get notification sound error");
}
-
- LogInfo(" sound type = " << type << " path = " << soundPath);
- if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
- {
- LogInfo("soundPath = " << soundPath);
- return std::string(soundPath);
- }
- else
+
+ std::string strSoundPath;
+ if (soundPath)
{
- return std::string("");
+ LoggerI(" soudn type=" << type);
+ if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA)
+ {
+ LoggerI("soundPath = " << soundPath);
+ strSoundPath = soundPath;
+ }
}
+
+ LoggerI("soundPath :" << strSoundPath);
+ return strSoundPath;
+
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
{
if (m_notiHandle)
{
- LogInfo("sound path = " << sound << " origin sound path = " << getSoundPath());
+ LoggerI("sound path = " << sound << " origin sound path = " << getSoundPath());
if( getSoundPath().compare(sound))
{
if (sound.empty())
{
- LogInfo("sound path is NULL");
+ LoggerI("sound path is NULL");
if ( NOTI_TYPE_ONGOING == getNotiType() || NOTI_TYPE_PROGRESS == getNotiType())
{
- LogInfo("Ongoing Type" );
+ LoggerI("Ongoing Type" );
if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_NONE, NULL) != NOTIFICATION_ERROR_NONE)
{
throw UnknownException("set notification sound error");
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
bool StatusNotification::getDefaultVibration()
{
- LogInfo("getDefaultVibration");
+ LoggerI("getDefaultVibration");
if (m_notiHandle)
{
notification_vibration_type_e vib_type;
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
void StatusNotification::setDefaultVibration(const bool& vibration)
{
- LogInfo("vibration = " << vibration);
+ LoggerI("vibration = " << vibration);
if (m_notiHandle)
{
notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
- LogInfo("old vibration = " << getDefaultVibration());
+ LoggerI("old vibration = " << getDefaultVibration());
if (getDefaultVibration() != vibration)
{
if (vibration)
{
vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
}
- LogInfo("type vibration type= " << vib_type);
+ LoggerI("type vibration type= " << vib_type);
if (notification_set_vibration(m_notiHandle, vib_type , NULL) != NOTIFICATION_ERROR_NONE)
{
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
// mandatory
if(service_get_operation(m_service, &tempStr) == SERVICE_ERROR_NONE)
{
- LogDebug("Operation Str = " << tempStr);
+ LoggerD("Operation Str = " << tempStr);
if (tempStr)
{
appControl->setOperation(tempStr);
// optional
if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
{
- LogDebug("Mime Str = " << tempStr);
+ LoggerD("Mime Str = " << tempStr);
if (tempStr)
{
appControl->setMime(tempStr);
// optional
if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
{
- LogDebug("Uri Str = " << tempStr);
+ LoggerD("Uri Str = " << tempStr);
if (tempStr)
{
appControl->setUri(tempStr);
if (service_get_category(m_service, &tempStr) == SERVICE_ERROR_NONE)
{
- LogDebug("Category Str = " << tempStr);
+ LoggerD("Category Str = " << tempStr);
if (tempStr)
{
appControl->setCategory(tempStr);
service = NULL;
}
- LogWarning(_rethrown_exception.GetMessage());
+ LoggerW(_rethrown_exception.GetMessage());
}
return appControl;
void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr control)
{
- LogInfo("Entered m_service : " << m_service << " control : " << control);
+ LoggerI("Entered m_service : " << m_service << " control : " << control);
//delete old service.
if (m_service)
}
else
{
- LogInfo("getOperation : " << control->getOperation().c_str());
+ LoggerI("getOperation : " << control->getOperation().c_str());
if (control->getOperation().size() != 0)
{
+ m_launchFlag = true; //default attribute
if (service_set_operation(m_service, control->getOperation().c_str()) != SERVICE_ERROR_NONE)
{
throw UnknownException("service set operation error");
}
// optional
- LogInfo("getUri : " << control->getUri().c_str());
+ LoggerI("getUri : " << control->getUri().c_str());
if (control->getUri().size() != 0)
{
if (service_set_uri(m_service, control->getUri().c_str() ) != SERVICE_ERROR_NONE)
}
// optional
- LogInfo("getMime : " << control->getMime().c_str());
+ LoggerI("getMime : " << control->getMime().c_str());
if (control->getMime().size() != 0)
{
if (service_set_mime(m_service, control->getMime().c_str() ) != SERVICE_ERROR_NONE)
}
}
- LogInfo("Category : " << control->getCategory().c_str());
+ LoggerI("Category : " << control->getCategory().c_str());
if (control->getCategory().size() != 0)
{
if (service_set_category(m_service, control->getCategory().c_str() ) != SERVICE_ERROR_NONE)
throw UnknownException("service set mime error");
}
}
-
+#if 0
//remove key
- //if ( service_foreach_extra_data(m_service, service_extra_data_delete_cb, NULL) != SERVICE_ERROR_NONE)
- //{
- // throw UnknownException("get notification service uri error");
- //}
-
+ if ( service_foreach_extra_data(m_service, service_extra_data_delete_cb, NULL) != SERVICE_ERROR_NONE)
+ {
+ throw UnknownException("get notification service uri error");
+ }
+#endif
std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = control->getAppControlDataArray();
size_t index = 0;
- LogInfo (" App Control Datas Count : " << appControlDataArray.size());
+ LoggerI (" App Control Datas Count : " << appControlDataArray.size());
DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
{
DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
std::string key = appControlData->getKey();
- LogInfo(" key : " << key);
+ LoggerI(" key : " << key);
if (key.empty())
continue;
for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
{
arrayValue[indexArray] = (char*)value[indexArray].c_str();
- LogInfo( " value : " << arrayValue[indexArray]);
+ LoggerI( " value : " << arrayValue[indexArray]);
}
const char* strKey = key.c_str();
- LogInfo( " value size: " << value.size());
+ LoggerI( " value size: " << value.size());
if (service_add_extra_data_array(m_service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
{
throw UnknownException("service set extra data error");
if (arrayValue)
free(arrayValue);
}
-
+
+#if 0
bundle *bundle_data=NULL;
if(service_to_bundle(m_service, &bundle_data) != SERVICE_ERROR_NONE)
throw UnknownException("service get bundle");
}
- LogDebug("bundle_data : " << bundle_data);
+ LoggerD("bundle_data : " << bundle_data);
if (bundle_data)
{
notification_set_execute_option(m_notiHandle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH,
NULL,NULL, bundle_data);
}
+#endif
}
void StatusNotification::setApplicationId(const std::string& appId)
{
- LogInfo("m_service = " << m_service << " appId = " << appId);
+ LoggerI("m_service = " << m_service << " appId = " << appId);
if (!m_service)
{
if (service_create(&m_service) != SERVICE_ERROR_NONE)
{
- LogWarning("Create Service Failed..");
- throw DeviceAPI::Common::UnknownException ("service creation error");
+ LoggerW("Create Service Failed..");
+ throw UnknownException("service creation error");
}
}
if (m_service)
{
+ m_launchFlag = true;
if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
{
- throw DeviceAPI::Common::UnknownException ("service set appId error");
+ throw UnknownException("service set appId error");
}
}
std::string StatusNotification::getApplicationId()
{
std::string retString;
- service_h service = NULL;
char* appIdStr = NULL;
-
+#if 0
+ service_h service = NULL;
+
if (m_service != NULL)
{
int retcode;
{
if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
{
- LogWarning("SERVICE_ERROR_OUT_OF_MEMORY");
+ LoggerW("SERVICE_ERROR_OUT_OF_MEMORY");
}
else
{
- LogWarning("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
+ LoggerW("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
}
- throw DeviceAPI::Common::UnknownException ("get notification service error ");
+ throw UnknownException ("get notification service error ");
}
else
{
if (service == NULL)
{
- throw DeviceAPI::Common::UnknownException ("get notification service ok, but service null");
+ throw UnknownException ("get notification service ok, but service null");
}
}
}
-
- if (service != NULL)
+#endif
+ if (m_service != NULL)
{
- if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
+ if (service_get_app_id(m_service, &appIdStr) != SERVICE_ERROR_NONE)
{
- throw DeviceAPI::Common::UnknownException ("get a appId error");
+ throw UnknownException ("get a appId error");
}
if (appIdStr != NULL)
free(appIdStr);
}
}
- LogInfo(retString);
+ LoggerI(retString);
return retString;
{
throw UnknownException("get notification size error");
}
- LogInfo("Size Val = " << value);
+ LoggerI("Size Val = " << value);
}
else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
{
{
throw UnknownException("get notification percentage error");
}
- LogInfo("Percentage Val = " << value);
+ LoggerI("Percentage Val = " << value);
}
else
{
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
}
- LogInfo("value = " << value);
+ LoggerI("value = " << value);
return value;
}
if (m_notiHandle)
{
NotificationProgressType progressType = getProgressType();
- LogInfo("Progress Type : " << progressType);
+ LoggerI("Progress Type : " << progressType);
double val = getProgressValue();
- LogInfo("Progress value = " << progressValue << " origin Progress Value =" << val);
+ LoggerI("Progress value = " << progressValue << " origin Progress Value =" << val);
if (progressType == NOTI_PROGRESS_TYPE_SIZE)
{
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
}
+NotificationProgressType StatusNotification::getProgressType()
+{
+ return m_progressType;
+}
+
+void StatusNotification::setProgressType(NotificationProgressType type)
+{
+
+ if (m_notiHandle)
+ {
+ LoggerI(" NotificationProgressType = " << type);
+
+ std::string progressType;
+
+ if ( type == NOTI_PROGRESS_TYPE_PERCENTAGE)
+ {
+ progressType = TIZEN_NOTIFICATION_PROGRESS_TYPE_PERCENTAGE;
+ }
+ else if ( type == NOTI_PROGRESS_TYPE_SIZE)
+ {
+ progressType = TIZEN_NOTIFICATION_PROGRESS_TYPE_BYTE;
+ }
+ else
+ {
+ throw TypeMismatchException("Invalid Progress Type.");
+ }
+
+ if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_LIST_5, progressType.c_str()) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification sound error");
+ }
+
+ m_progressType = type;
+ }
+ else
+ {
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
+ }
+
+}
+
std::string StatusNotification::getSubIconPath()
{
- LogInfo("Handle = " << m_notiHandle);
+ LoggerI("Handle = " << m_notiHandle);
if (m_notiHandle)
{
char *subIconPath = NULL;
{
if (m_notiHandle)
{
- LogInfo(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
+ LoggerI(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
if( getSubIconPath().compare(subIconPath))
{
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
std::string strInfo;
if (info)
strInfo = info;
- LogDebug(" info " << strInfo);
+ LoggerD(" info " << strInfo);
return strInfo;
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
if (m_notiHandle)
{
int idx = index;
- LogDebug(" index : " << idx);
- LogDebug(" log : " << info);
+ LoggerD(" index : " << idx);
+ LoggerD(" log : " << info);
notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
switch (idx)
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
std::string strSubInfo;
if (subInfo)
strSubInfo = subInfo;
- LogDebug(" subInfo " << strSubInfo);
+ LoggerD(" subInfo " << strSubInfo);
return strSubInfo;
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
if (m_notiHandle)
{
int idx = index;
- LogDebug(" index : " << idx);
- LogDebug(" log : " << subInfo);
+ LoggerD(" index : " << idx);
+ LoggerD(" log : " << subInfo);
notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
switch (idx)
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
}
std::vector<std::string> StatusNotification::getThumbnails()
{
- LogInfo(" thumbnail Size : " << m_thumbs.size());
+ LoggerI(" thumbnail Size : " << m_thumbs.size());
return m_thumbs;
}
{
if (m_notiHandle)
{
- LogInfo(" index : " << index);
+ LoggerI(" index : " << index);
notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
#if 0
void StatusNotification::setThumbnails(std::vector<std::string> thumbs)
{
- LogInfo("set thumbnails");
+ LoggerI("set thumbnails");
if (m_notiHandle)
{
std::vector<std::string>::iterator it;
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
}
{
if (m_notiHandle)
{
- LogInfo(" index : " << index);
- LogInfo(" thumb : " << thumb);
+ LoggerI(" index : " << index);
+ LoggerI(" thumb : " << thumb);
notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
switch (index)
std::string StatusNotification::getBackground()
{
- LogInfo(" Handle : " << m_notiHandle);
+ LoggerI(" Handle : " << m_notiHandle);
if (m_notiHandle)
{
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
void StatusNotification::setBackground(const std::string imagePath)
{
- LogInfo(" imagePath : " << imagePath);
+ LoggerI(" imagePath : " << imagePath);
if (m_notiHandle)
{
if (getBackground().compare(imagePath))
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
}
-unsigned int StatusNotification::getNumber()
+long StatusNotification::getNumber()
{
- LogInfo("Handle = " << m_notiHandle);
+ LoggerI("Handle = " << m_notiHandle);
if (m_notiHandle)
{
- int number = 0;
+ long number = 0;
char *strNumber = NULL;
if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
if (strNumber)
std::istringstream(strNumber) >> number;
+ else
+ LoggerI("Number Is NULL");
- LogInfo("number = " << number);
+ LoggerI("number = " << number);
- if (number < 0 )
- number = 0;
return number;
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
return 0;
}
}
-void StatusNotification::setNumber(const unsigned int number)
+const char* StatusNotification::getStrNumber()
{
- LogInfo("Number = " << number);
+ LoggerI("Handle = " << m_notiHandle);
+ if (m_notiHandle)
+ {
+ char *strNumber = NULL;
+
+ if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException( "get notification background error");
+ }
+
+ if (!strNumber)
+ {
+ return NULL;
+ }
+
+ return strNumber;
+ }
+ else
+ {
+ LoggerD("noti Handle is NULL");
+ return NULL;
+ }
+}
+
+void StatusNotification::setNumber(const long number)
+{
+ LoggerI("Number = " << number);
if (m_notiHandle)
{
if(number!=getNumber())
stream << number;
if (stream.fail()) {
throw UnknownException(
- "Couldn't convert e-mail account id");
+ "Couldn't convert notification number");
}
std::string strNumber = stream.str();
if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, strNumber.c_str(),
NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
{
- throw UnknownException( "set notification sound error");
+ throw UnknownException( "set notification text error");
}
setUpdatedFlag(true);
}
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
}
{
throw UnknownException( "notification handle null error");
}
- LogInfo("handle = " << handle << " m_notiHandle = " << m_notiHandle);
+ LoggerI("handle = " << handle << " m_notiHandle = " << m_notiHandle);
if (m_notiHandle != NULL)
{
return m_service;
}
+std::string StatusNotification::getLight()
+{
+ LoggerI("get Light handle: " << m_notiHandle);
+ if (m_notiHandle)
+ {
+ int ledColor = 0;
+ notification_led_op_e type = NOTIFICATION_LED_OP_ON;
+ if (notification_get_led(m_notiHandle, &type, &ledColor) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("get notification Content error");
+ }
+ std::string light;
+ std::stringstream stream;
+ if (NOTIFICATION_LED_OP_OFF != type)
+ {
+ stream << std::hex << ledColor;
+ light = "#" + stream.str();
+ }
+
+ return boost::to_lower_copy(light);
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
+bool StatusNotification::isColorFormatNumberic(std::string& color)
+{
+ //first check length
+ std::string hexCode = "0123456789abcdef";
+ if (color.length() == 7 && !color.compare(0, 1, "#") )
+ {
+ for ( size_t i = 1 ; i < color.length() ; i++)
+ {
+ if (std::string::npos == hexCode.find(color[i]))
+ return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+void StatusNotification::setLight(std::string color)
+{
+ LoggerI("set Light handle: " << m_notiHandle);
+ LoggerI("led Color : " << color);
+ if (m_notiHandle)
+ {
+ color = boost::to_lower_copy(color); //convert lowercase.
+ if ( isColorFormatNumberic(color))
+ {
+ std::stringstream stream;
+ int ledColor = 0;
+ notification_led_op_e type = NOTIFICATION_LED_OP_ON;
+ std::string colorCode = color.substr(1, color.length());
+
+ stream << std::hex << colorCode;
+ LoggerI("LedColor = " << stream.str());
+ stream >> ledColor;
+ LoggerI("LedColor = " << ledColor);
+
+ if (ledColor != 0)
+ type = NOTIFICATION_LED_OP_ON_CUSTOM_COLOR;
+ else
+ type = NOTIFICATION_LED_OP_OFF;
+
+ if (notification_set_led(m_notiHandle, type, ledColor) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+
+ }
+ else
+ {
+ LoggerI("color.length()=" << color.length());
+ if (color.length() == 0)
+ {
+ if (notification_set_led(m_notiHandle, NOTIFICATION_LED_OP_OFF, 0) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+ }
+ else
+ {
+ throw InvalidValuesException("color code error!");
+ }
+ }
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
+unsigned long StatusNotification::getLightOnTime()
+{
+ LoggerI("get Light on Time handle: " << m_notiHandle);
+ if (m_notiHandle)
+ {
+ int onTime = 0;
+ int offTime = 0;
+
+ if (notification_get_led_time_period(m_notiHandle, &onTime, &offTime ) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+ LoggerI("onTime " << onTime);
+
+ return (unsigned long) onTime;
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
+void StatusNotification::setLightOnTime(unsigned long time)
+{
+ LoggerI("set Light on Time handle: " << m_notiHandle);
+ LoggerI("itme = " << time);
+ if (m_notiHandle)
+ {
+ int offTime = getLightOffTime();
+
+ if (notification_set_led_time_period(m_notiHandle, time, offTime ) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
+
+unsigned long StatusNotification::getLightOffTime()
+{
+
+ LoggerI("get Light on Time handle: " << m_notiHandle);
+ if (m_notiHandle)
+ {
+ int onTime = 0;
+ int offTime = 0;
+
+ if (notification_get_led_time_period(m_notiHandle, &onTime, &offTime ) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+ LoggerI("offTime " << offTime);
+
+ return offTime;
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+
+}
+
+void StatusNotification::setLightOffTime(unsigned long time)
+{
+ LoggerI("set Light off Time handle: " << m_notiHandle);
+ LoggerI("time = " << time);
+ if (m_notiHandle)
+ {
+ int onTime = getLightOnTime();
+
+ if (notification_set_led_time_period(m_notiHandle, onTime, time ) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification led ");
+ }
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
//Detail Info
void StatusNotification::loadDetailInfos()
{
- LogInfo("noti Handle = " << m_notiHandle);
+ LoggerI("noti Handle = " << m_notiHandle);
if (m_notiHandle)
{
for ( int idx = 0; idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH; idx++)
{
- std::string main = getInformation(idx);
- std::string sub = getSubInformation(idx);
- LogInfo("Main : " << main << " Sub : " << sub);
- NotificationDetailInfo *info = new NotificationDetailInfo(m_notiHandle, idx, main, sub);
- m_detailInfos.push_back(info);
+ if (!isNullInformation(idx))
+ {
+ std::string main = getInformation(idx);
+ std::string sub = getSubInformation(idx);
+
+ LoggerI("Main : [" << main << "] Sub : ['" << sub <<"]");
+
+ NotificationDetailInfo *info = new NotificationDetailInfo(m_notiHandle, idx, main, sub);
+ m_detailInfos.push_back(info);
+ }
}
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
void StatusNotification::setDetailInfos(const std::vector<NotificationDetailInfo*> value)
{
- LogInfo("DetailInfos = " << value.size());
+ LoggerI("DetailInfos = " << value.size());
if (m_notiHandle)
{
NotificationDetailInfo* info = *it;
if ( idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH )
{
- LogInfo("main " << info->getMainText() << " sub " << info->getSubText() );
+
+ LoggerI("main " << info->getMainText() << " sub " << info->getSubText() );
setInformation(info->getMainText(), idx);
setSubInformation(info->getSubText(), idx);
}
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
for (it = m_detailInfos.begin(); it < m_detailInfos.end(); ++it)
{
NotificationDetailInfo* info = *it;
- LogInfo("Delete Detail Info : " << info);
+ LoggerI("Delete Detail Info : " << info);
if (info)
delete info;
idx ++;
std::string strInfo;
if (info)
strInfo = info;
- LogInfo(" info " << strInfo);
+ LoggerI(" info " << strInfo);
return strInfo;
}
else
{
- LogWarning("noti Handle is NULL");
+ LoggerW("noti Handle is NULL");
throw UnknownException( "notification handle is null");
}
}
+bool StatusNotification::isNullInformation(int index)
+{
+ if (m_notiHandle)
+ {
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
+ switch (index)
+ {
+ case 0:
+ type = NOTIFICATION_TEXT_TYPE_INFO_1;
+ break;
+ case 1:
+ type = NOTIFICATION_TEXT_TYPE_INFO_2;
+ break;
+ case 2:
+ type = NOTIFICATION_TEXT_TYPE_INFO_3;
+ break;
+ default :
+ type = NOTIFICATION_TEXT_TYPE_NONE;
+ }
+ char *info = NULL;
+
+ if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("Detail Info index value is invalid or mainText value getting is failed in Detail Info.");
+ }
+
+ if (info)
+ {
+ LoggerI("is not null");
+ return false;
+ }
+ else
+ {
+ LoggerI("is null");
+ return true;
+ }
+
+ }
+ else
+ {
+ LoggerW("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
+ }
+}
+
std::string StatusNotification::getSubInformation(int index)
{
if (m_notiHandle)
std::string strSubInfo;
if (subInfo)
strSubInfo = subInfo;
- LogInfo(" subInfo " << strSubInfo);
+ LoggerI(" subInfo " << strSubInfo);
return strSubInfo;
}
else
{
- LogWarning("noti Handle is NULL");
+ LoggerW("noti Handle is NULL");
throw UnknownException ("notification handle is null");
}
if (m_notiHandle)
{
int idx = index;
- LogDebug(" index : " << idx);
- LogDebug(" log : " << info);
+ LoggerD(" index : " << idx);
+ LoggerD(" log : " << info);
notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
switch (idx)
if ( type != NOTIFICATION_TEXT_TYPE_NONE)
{
- if (getInformation(idx).compare(info))
+ if (getInformation(idx).compare(info) || isNullInformation(idx))
{
if (notification_set_text(m_notiHandle, type, info.c_str(),
NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
}
else
{
- LogWarning("noti Handle is NULL");
+ LoggerW("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
else
{
- LogWarning("noti Handle is NULL");
+ LoggerW("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
if (m_notiHandle)
{
int idx = index;
- LogDebug(" index : " << idx);
- LogDebug(" log : " << subInfo);
+ LoggerD(" index : " << idx);
+ LoggerD(" log : " << subInfo);
notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
switch (idx)
}
else
{
- LogWarning("noti Handle is NULL");
+ LoggerW("noti Handle is NULL");
throw UnknownException("notification handle is null");
}
}
-
-#if 0
-
-StatusNotification::StatusNotification():
- m_statusType(""),
- m_iconPath(""),
- m_subIconPath(""),
- m_number(0),
- m_backgroundImagePath(""),
- m_soundPath(""),
- m_vibration(false),
- m_progressType(""),
- m_progressValue(0)
-{
-}
-
-StatusNotification::~StatusNotification()
-{
-}
-
-std::string StatusNotification::getStatusType() const
-{
- return m_statusType;
-}
-
-void StatusNotification::setStatusType(std::string statusType)
-{
- m_statusType = statusType;
-}
-
-std::string StatusNotification::getIconPath() const
-{
- return m_iconPath;
-}
-
-void StatusNotification::setIconPath(std::string iconPath)
-{
- m_iconPath = iconPath;
-}
-
-std::string StatusNotification::getSubIconPath() const
-{
- return m_subIconPath;
-}
-
-void StatusNotification::setSubIconPath(std::string subIconPath)
-{
- m_subIconPath = subIconPath;
-}
-
-long StatusNotification::getNumber() const
-{
- return m_number;
-}
-
-void StatusNotification::setNumber(long number)
-{
- m_number = number;
-}
-
-std::vector<NotificationDetailInfo*> StatusNotification::getDetailInfo() const
-{
- return m_detailInfo;
-}
-
-void StatusNotification::setDetailInfo(std::vector<NotificationDetailInfo*> detailInfo)
-{
- m_detailInfo = detailInfo;
-}
-
-std::string StatusNotification::getBackgroundImagePath() const
-{
- return m_backgroundImagePath;
-}
-
-void StatusNotification::setBackgroundImagePath(std::string backgroundImagePath)
-{
- m_backgroundImagePath = backgroundImagePath;
-}
-
-std::vector<std::string> StatusNotification::getThumbnails() const
-{
- return m_thumbnails;
-}
-
-void StatusNotification::setThumbnails(std::vector<std::string> thumbnails)
-{
- m_thumbnails = thumbnails;
-}
-
-std::string StatusNotification::getSoundPath() const
-{
- return m_soundPath;
-}
-
-void StatusNotification::setSoundPath(std::string soundPath)
-{
- m_soundPath = soundPath;
-}
-
-bool StatusNotification::getVibration() const
-{
- return m_vibration;
-}
-
-void StatusNotification::setVibration(bool vibration)
-{
- m_vibration = vibration;
-}
-
-ApplicationControl StatusNotification::getAppControl() const
-{
- return m_appControl;
-}
-
-void StatusNotification::setAppControl(ApplicationControl appControl)
-{
- m_appControl = appControl;
-}
-
-ApplicationId StatusNotification::getAppId() const
-{
- return m_appId;
-}
-
-void StatusNotification::setAppId(ApplicationId appId)
-{
- m_appId = appId;
-}
-
-std::string StatusNotification::getProgressType() const
-{
- return m_progressType;
-}
-
-void StatusNotification::setProgressType(std::string progressType)
-{
- m_progressType = progressType;
-}
-
-unsigned long StatusNotification::getProgressValue() const
-{
- return m_progressValue;
-}
-
-void StatusNotification::setProgressValue(unsigned long progressValue)
-{
- m_progressValue = progressValue;
-}
-#endif
-
} // Notification
} // DeviceAPI