// limitations under the License.
//
-#include <cassert>
-#include <Commons/Exception.h>
+#include <PlatformException.h>
+#include <Logger.h>
#include <sstream>
-#include <notification.h>
#include <appsvc/appsvc.h>
-#include "StatusNotification.h"
-#include <FilesystemUtils.h>
+#include <sstream>
+#include <boost/algorithm/string.hpp>
+#include "StatusNotification.h"
namespace DeviceAPI {
-namespace Notification{
+namespace Notification {
#define DEFAULT_ICON_PATH "/opt/share/icons/default/"
+#define MAX_NOTIFICATION_DETAIL_INFO_LENGTH 2
+#define MAX_THUMBNAIL_LENGTH 4
extern "C" int service_create_event(bundle *data, struct service_s **service);
+//tern "C" int service_to_bundle(service_h service, bundle **data);
-#if 0
-static void service_bundle_iterator(const char *key, const int type, const bundle_keyval_t *kv, void *user_data)
+//callback functions.
+static bool service_extra_data_cb(service_h service, const char *key, void *user_data)
{
- service_h service = (service_h)user_data;
- LogDebug("key = " << key);
- LogDebug(" type = " << type);
- void *basic_val = NULL;
- size_t basic_size = 0;
-
- if (bundle_keyval_type_is_array((bundle_keyval_t*)kv))
- {
- LogDebug("Array");
- }
- else
- {
- bundle_keyval_get_basic_val((bundle_keyval_t*)kv, &basic_val, &basic_size);
-
- service_add_extra_data(service, key, );
+ LoggerI("OK");
+ char **value = NULL;
+ int length = 0;
+
+ if (user_data != NULL && key != NULL)
+ {
+ LoggerI("user data & key is existed");
+
+ DeviceAPI::Application::ApplicationControlPtr* appControl =
+ (DeviceAPI::Application::ApplicationControlPtr*)(user_data);
+
+ DeviceAPI::Application::ApplicationControlDataPtr data(new DeviceAPI::Application::ApplicationControlData());
+ 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)
+ {
+ LoggerI("extra_data_array length = " << length);
+
+ if (value != NULL && length != 0)
+ {
+ LoggerI("extra_data_length = " << length);
+ data->setKey(key);
+ for (index = 0; index < length; index++)
+ {
+ LoggerI("Value=" << value[index]);
+ keyValue.push_back(value[index]);
+ }
+
+ data->setValue(keyValue);
+ (*appControl)->addAppControlData(data);
+ }
+
+ if(value)
+ free(value);
+ }
}
+ return true;
}
-#endif
StatusNotification::StatusNotification(NotificationType statusType) :
- m_notiHandle(NULL),
+ m_notiType(NOTI_TYPE_NONE),
m_service(NULL),
- m_lines(NULL)
-{
- notification_type_e type = NOTIFICATION_TYPE_NONE;
+ m_notiHandle(NULL),
+ m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
+ m_notiUpdated(false),
+ m_launchFlag(false)
+{
+ LoggerI("statusType =" << statusType);
- LogDebug("statusType =" << statusType);
+ notification_type_e type = NOTIFICATION_TYPE_NONE;
setNotiType(statusType);
-
+
if (statusType == NOTI_TYPE_SIMPLE || statusType == NOTI_TYPE_MUTIPLE || statusType == NOTI_TYPE_THUMBNAIL)
{
type = NOTIFICATION_TYPE_NOTI;
}
else
{
- LogDebug(" invalide noti type");
- ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Error : noti type");
+ LoggerI(" invalide noti type");
+ throw TypeMismatchException("value is not notification type");
}
- setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
-
- LogDebug("Notification Type : " << type);
-
- notification_h noti = NULL;
- noti = notification_create(type); //create notificatin.
+ //setProgressType(NOTI_PROGRESS_TYPE_PERCENTAGE); //default
+
+ LoggerI("Notification Type : " << type);
+
+ notification_h noti = notification_create(type); //create notificatin.
if ( noti )
{
- LogDebug("noti =" << noti);
+ LoggerI("noti =" << noti);
setNotificationHandle((void*)noti);
- setNotificationState(NOTI_STATE_CREATED);
- }
- m_lines = NotificationLineArrayPtr(new NotificationLineArray());
- m_thumbs = StringArrayPtr(new StringArray());
+
+ if (NOTIFICATION_TYPE_ONGOING == type)
+ { //ongoing no ticker.
+ 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
+ {
+ throw UnknownException("can't make new notification object");
+ }
+
+ //m_detailInfos = new std::vector<NotificationDetailInfo*>();
+ //m_thumbs = new std::vector<std::string>();
+
}
StatusNotification::StatusNotification(void* noti) :
- m_notiHandle(NULL),
+ m_notiType(NOTI_TYPE_NONE),
m_service(NULL),
- m_lines(NULL)
+ m_notiHandle(NULL),
+ m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
+ m_notiUpdated(false),
+ m_launchFlag(false)
{
- LogDebug("noti : " << noti);
- notification_h notification = (notification_h)noti;
+ LoggerI("noti : " << noti);
+ notification_h notification = (notification_h)noti;
+
if ( notification )
{
- NotificationType type = NOTI_TYPE_NONE;
+ NotificationType type = NOTI_TYPE_NONE;
notification_type_e noti_type = NOTIFICATION_TYPE_NONE;
notification_ly_type_e noti_layout = NOTIFICATION_LY_NONE;
-
+
notification_get_type(notification, ¬i_type);
notification_get_layout(notification, ¬i_layout);
-
+
+ //get type.
if ( noti_type == NOTIFICATION_TYPE_NOTI )
{
if ( noti_layout == NOTIFICATION_LY_NOTI_EVENT_SINGLE ||
}
}
- LogDebug(" 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();
- m_lines = NotificationLineArrayPtr(new NotificationLineArray());
- m_thumbs = StringArrayPtr(new StringArray());
-
- setNotificationLines();
- setNotificationState(NOTI_STATE_CREATED);
-
+#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);
- LogDebug("ret = " << ret);
+ LoggerI("ret = " << ret);
if (ret == NOTIFICATION_ERROR_NONE)
- //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
{
- LogDebug(" bundle = " << bSvc);
+ LoggerI(" bundle = " << bSvc);
if (bSvc)
{
- LogDebug("bundle is valid");
+ LoggerI("bundle is valid");
int ret = service_create_event(bSvc, &m_service);
if (ret != SERVICE_ERROR_NONE)
{
- LogDebug("Service Create Event Error");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
- }
-
-#if 0
- const char *tmpStr = NULL;
- if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
- }
-
- tmpStr = appsvc_get_operation(bSvc);
- if (tmpStr)
- {
- LogDebug("operation = " << tmpStr);
- if (tmpStr)
- {
- if (service_set_operation(m_service, tmpStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
- }
- }
- else if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
- }
- tmpStr = NULL;
- }
-
- else
- {
- if (service_set_operation(m_service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
- }
-
- tmpStr = appsvc_get_uri(bSvc);
- if (tmpStr)
- {
- LogDebug("uri = " << tmpStr);
- if (service_set_uri(m_service, tmpStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
- }
- tmpStr = NULL;
+ LoggerI("Service Create Event Error");
+ throw UnknownException("can't make service object");
}
-
- tmpStr = appsvc_get_mime(bSvc);
- if(tmpStr)
- {
- LogDebug("mime = " << tmpStr);
- if (service_set_mime(m_service, tmpStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
- }
- tmpStr = NULL;
- }
-
- tmpStr = appsvc_get_category(bSvc);
- if(tmpStr)
- {
- LogDebug("category = " << tmpStr);
- if (service_set_category(m_service, tmpStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set category error");
- }
- tmpStr = NULL;
- }
-
- //extra option
- bundle_foreach(bSvc, service_bundle_iterator, m_service);
-#endif
- bundle_free(bSvc); //bundle free
}
}
+ else
+ {
+ notification_free(notification);
+ throw UnknownException("can't get service data");
+ }
+
}
+ else
+ {
+ throw InvalidValuesException("It is not notification object.");
+ }
+
}
StatusNotification::StatusNotification(int privID) :
- m_notiHandle(NULL),
- m_service(NULL),
- m_lines(NULL)
+ m_notiType(NOTI_TYPE_NONE),
+ m_service(NULL),
+ m_notiHandle(NULL),
+ m_progressType(NOTI_PROGRESS_TYPE_PERCENTAGE),
+ m_notiUpdated(false),
+ m_launchFlag(false)
{
- LogDebug("priv ID : " << privID);
-
- notification_h notification = notification_load( NULL, privID);
- LogDebug(" notification " << notification);
-
+ LoggerI("priv ID : " << privID);
+
+ notification_h notification = notification_load( NULL, privID); //load notification.
+ LoggerI(" notification " << notification);
+
if ( notification )
{
NotificationType type = NOTI_TYPE_NONE;
}
}
- LogDebug(" 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);
-
- m_lines = NotificationLineArrayPtr(new NotificationLineArray());
- m_thumbs = StringArrayPtr(new StringArray());
-
- setNotificationLines();
- setNotificationState(NOTI_STATE_CREATED);
-
+ 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);
- LogDebug("ret = " << ret);
+ LoggerI("ret = " << ret);
if (ret == NOTIFICATION_ERROR_NONE)
- //if ( notification_get_execute_option(notification, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &bSvc) == NOTIFICATION_ERROR_NONE)
{
- LogDebug(" bundle = " << bSvc);
+ LoggerI(" bundle = " << bSvc);
if (bSvc)
{
- LogDebug("bundle is valid");
+ LoggerI("bundle is valid");
int ret = service_create_event(bSvc, &m_service);
if (ret != SERVICE_ERROR_NONE)
{
- LogDebug("Service Create Event Error");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
+ LoggerI("Service Create Event Error");
+ throw UnknownException("can't make service object");
}
-
- //bundle_free(bSvc); //bundle free
}
}
+ else
+ {
+ notification_free(notification);
+ throw UnknownException("can't get service data");
+ }
+
}
else
{
- LogDebug(" can't find notification");
- ThrowMsg(WrtDeviceApis::Commons::NotFoundException, "Can't find noti");
+ throw NotFoundException("It is not notification ID or removed notification");
}
}
-
StatusNotification::~StatusNotification()
{
- LogDebug(" notification = " << m_notiHandle);
+ LoggerI(" notification = " << m_notiHandle);
+ //clear thumbnail.
+ //clearDetailInfos();
+
if (m_notiHandle)
{
- if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
- }
-
-#if 0
- LogDebug(" service = " << m_service);
+ LoggerI(" service = " << m_service);
if (m_service != NULL)
{
service_destroy(m_service);
m_service = NULL;
}
-#endif
- m_notiHandle = NULL;
- }
-}
-
-namespace {
-
-static bool service_extra_data_cb(service_h service, const char *key, void *user_data)
-{
- char **value = NULL;
- int length = 0;
-
- if (user_data != NULL && key != NULL)
- {
- LogDebug("OK");
-
- DeviceAPI::Application::ApplicationControlPtr* appControl =
- (DeviceAPI::Application::ApplicationControlPtr*)(user_data);
-
- DeviceAPI::Application::ApplicationControlDataPtr data(new DeviceAPI::Application::ApplicationControlData());
- 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)
+ if (notification_free(m_notiHandle) != NOTIFICATION_ERROR_NONE)
{
- if (value != NULL && length != 0)
- {
- data->setKey(key);
- for (index = 0; index < length; index++)
- {
- keyValue.push_back(value[index]);
- }
-
- data->setValue(keyValue);
- (*appControl)->addAppControlData(data);
- }
+ throw UnknownException("notification free failed...");
}
+
+ m_notiHandle = NULL;
}
- return true;
}
-}//namespace
int StatusNotification::getID()
{
+ int id = -1; // notification not inserted yet.
if (m_notiHandle)
{
- int id = 0;
notification_get_id(m_notiHandle, NULL, &id);
- return id;
}
- else
+
+ return id;
+}
+
+std::string StatusNotification::getStatusType()
+{
+ std::string type;
+
+ if ( NOTI_TYPE_SIMPLE == getNotiType())
+ {
+ type = "SIMPLE";
+ }
+ else if ( NOTI_TYPE_ONGOING == getNotiType())
+ {
+ type = "ONGOING";
+ }
+ else if ( NOTI_TYPE_PROGRESS == getNotiType())
+ {
+ type = "PROGRESS";
+ }
+ else if ( NOTI_TYPE_THUMBNAIL == getNotiType())
{
- return -1; // notification not inserted yet.
+ type = "THUMBNAIL";
}
+
+ return type;
+
+}
+
+
+
+void StatusNotification::setStatusType(std::string type)
+{
+ LoggerI("type = " << type);
+
+ NotificationType notiType = NOTI_TYPE_NONE;
+
+ if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_SIMPLE) == 0)
+ notiType = NOTI_TYPE_SIMPLE;
+ else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_THUMBNAIL) == 0)
+ notiType = NOTI_TYPE_THUMBNAIL;
+ else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_ONGOING) == 0)
+ notiType = NOTI_TYPE_ONGOING;
+ else if( type.compare(TIZEN_STATUS_NOTIFICATION_TYPE_PROGRESS) == 0)
+ notiType = NOTI_TYPE_PROGRESS;
+ else
+ throw InvalidValuesException("Invalid Status Type.");
+
+ LoggerI("Notification type = " << notiType);
+ setNotiType(notiType);
}
time_t StatusNotification::getPostedTime()
{
- LogDebug("get m_notiHandle = " << m_notiHandle);
+ LoggerI("get m_notiHandle = " << m_notiHandle);
time_t postedTime = 0;
{
if (notification_get_insert_time(m_notiHandle, &postedTime) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification posted time error");
+ throw UnknownException("get notification posted time error");
}
}
- LogDebug("posted Time =" << ctime(&postedTime));
+ LoggerI("posted Time =" << ctime(&postedTime));
return postedTime;
}
if (notification_get_text(m_notiHandle,NOTIFICATION_TEXT_TYPE_TITLE, &title) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification title error");
+ throw UnknownException("get notification title error");
}
- std::string notiTitle(title);
- return notiTitle;
+ std::string notiTitle;
+ if (title)
+ {
+ notiTitle = title;
+ LoggerI(" get title : " << title);
+ }
+
+ return notiTitle;
}
else
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ throw UnknownException("notification handle is null");
}
}
void StatusNotification::setTitle(std::string title)
{
- LogDebug("Title : " << title);
+ LoggerI("Title : " << title);
if (m_notiHandle)
{
- LogDebug("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(),
NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification title error");
+ throw UnknownException("set notification title error");
}
setUpdatedFlag(true);
}
else
{
- LogDebug(" title = " << title << " getTitle = " << getTitle());
+ LoggerI(" title = " << title << " getTitle = " << getTitle());
}
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
std::string StatusNotification::getContent()
{
- LogDebug("get Content : " << m_notiHandle);
+ 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)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification Content error");
+ throw UnknownException("get notification Content error");
}
- LogDebug(" get Content : " << content);
+ std::string notiContent;
if(content)
{
- std::string notiContent(content);
- return notiContent;
+ notiContent = content;
+ LoggerI(" get Content : " << content);
}
- else
+
+ return notiContent;
+
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+
+}
+
+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)
{
- return std::string("");
+ throw UnknownException("get notification Content error");
}
+
+ return content;
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ throw UnknownException("notification handle is null");
}
-
}
void StatusNotification::setContent(std::string content)
{
- LogDebug("Content : " << content);
+ LoggerI("Content : " << content);
if (m_notiHandle)
{
if((getContent()).compare(content)) //different value.
if (notification_set_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_CONTENT, content.c_str(),
NULL, NOTIFICATION_VARIABLE_TYPE_NONE ) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification content error");
+ throw UnknownException("set notification content error");
}
setUpdatedFlag(true);
}
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
-
+
std::string StatusNotification::getIconPath()
{
+
+ LoggerI("m_notiHandle = " << m_notiHandle);
if (m_notiHandle)
{
char *iconPath = NULL;
-
if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON, &iconPath) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification icon path error");
+ throw UnknownException("get notification icon path error");
}
- std::string notiIconPath(iconPath);
- LogDebug("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)
return notiIconPath;
else
{
- return std::string("");
+ return std::string(""); //return empty string.
}
}
else
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ throw UnknownException("notification handle is null");
}
}
{
if (m_notiHandle)
{
- LogDebug("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)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification icon error");
+ throw UnknownException("set notification icon error");
}
setUpdatedFlag(true);
}
}
else
- {
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ {
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
std::string StatusNotification::getSoundPath()
{
+ LoggerI("Handle = " << m_notiHandle);
+
if (m_notiHandle)
{
const char *soundPath = NULL;
if (notification_get_sound(m_notiHandle, &type, &soundPath) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sound error");
+ throw UnknownException("get notification sound error");
}
-
- LogDebug(" sound type = " << type << " path = " << soundPath);
- if ( type == NOTIFICATION_SOUND_TYPE_USER_DATA )
- {
- LogDebug("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");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
{
if (m_notiHandle)
{
- LogDebug("sound path = " << sound << " origin sound path = " << getSoundPath());
+ LoggerI("sound path = " << sound << " origin sound path = " << getSoundPath());
if( getSoundPath().compare(sound))
{
if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_USER_DATA, sound.c_str()) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
+ throw UnknownException("set notification sound error");
}
setUpdatedFlag(true);
}
+
+ if (sound.empty())
+ {
+ LoggerI("sound path is NULL");
+ if ( NOTI_TYPE_ONGOING == getNotiType() || NOTI_TYPE_PROGRESS == getNotiType())
+ {
+ LoggerI("Ongoing Type" );
+ if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_NONE, NULL) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification sound error");
+ }
+ }
+ else
+ {
+ if (notification_set_sound(m_notiHandle,NOTIFICATION_SOUND_TYPE_DEFAULT, sound.c_str()) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification sound error");
+ }
+ }
+
+ }
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
bool StatusNotification::getDefaultVibration()
{
+ LoggerI("getDefaultVibration");
if (m_notiHandle)
{
notification_vibration_type_e vib_type;
if (notification_get_vibration(m_notiHandle, &vib_type, NULL) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
+ throw UnknownException("set notification sound error");
}
- if (vib_type == NOTIFICATION_VIBRATION_TYPE_DEFAULT)
+ if (NOTIFICATION_VIBRATION_TYPE_DEFAULT == vib_type || NOTIFICATION_VIBRATION_TYPE_USER_DATA == vib_type)
{
return true;
}
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
return false;
void StatusNotification::setDefaultVibration(const bool& vibration)
{
+ LoggerI("vibration = " << vibration);
if (m_notiHandle)
{
notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
-
+ LoggerI("old vibration = " << getDefaultVibration());
if (getDefaultVibration() != vibration)
{
if (vibration)
{
vib_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
}
-
+ else
+ {
+ vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
+ }
+ LoggerI("type vibration type= " << vib_type);
+
if (notification_set_vibration(m_notiHandle, vib_type , NULL) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
+ throw UnknownException("set notification sound error");
}
setUpdatedFlag(true);
}
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
-double StatusNotification::getProgressValue()
+DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
{
- double value = 0.0;
-
- if (m_notiHandle)
- {
+
+ service_h service = NULL;
+ char *tempStr = NULL;
+
+ DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
+
+ try {
+ if (m_service)
+ {
+ appControl->setService_h(m_service);
+ // mandatory
+ if(service_get_operation(m_service, &tempStr) == SERVICE_ERROR_NONE)
+ {
+ LoggerD("Operation Str = " << tempStr);
+ if (tempStr)
+ {
+ appControl->setOperation(tempStr);
+ free(tempStr);
+ tempStr = NULL;
+ }
+ }
+
+ // optional
+ if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
+ {
+ LoggerD("Mime Str = " << tempStr);
+ if (tempStr)
+ {
+ appControl->setMime(tempStr);
+ free(tempStr);
+ tempStr = NULL;
+ }
+ }
+
+ // optional
+ if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
+ {
+ LoggerD("Uri Str = " << tempStr);
+ if (tempStr)
+ {
+ appControl->setUri(tempStr);
+ free(tempStr);
+ tempStr = NULL;
+ }
+ }
+
+ if (service_get_category(m_service, &tempStr) == SERVICE_ERROR_NONE)
+ {
+ LoggerD("Category Str = " << tempStr);
+ if (tempStr)
+ {
+ appControl->setCategory(tempStr);
+ free(tempStr);
+ tempStr = NULL;
+ }
+ }
+
+ // optional
+ if ( service_foreach_extra_data(m_service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
+ {
+ ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
+ }
+
+ return appControl;
+ }
+
+ }
+ Catch (WrtDeviceApis::Commons::Exception)
+ {
+ if (tempStr)
+ {
+ free(tempStr);
+ tempStr = NULL;
+ }
+
+ if (service)
+ {
+ free(service);
+ service = NULL;
+ }
+
+ LoggerW(_rethrown_exception.GetMessage());
+ }
+
+ return appControl;
+}
+
+void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr control)
+{
+ LoggerI("Entered m_service : " << m_service << " control : " << control);
+
+ //delete old service.
+ if (m_service)
+ {
+ service_destroy(m_service);
+ m_service = NULL;
+ }
+
+ if(service_create(&m_service) != SERVICE_ERROR_NONE)
+ {
+ throw UnknownException("service creation error");
+ }
+ else
+ {
+ 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
+ LoggerI("getUri : " << control->getUri().c_str());
+ if (control->getUri().size() != 0)
+ {
+ if (service_set_uri(m_service, control->getUri().c_str() ) != SERVICE_ERROR_NONE)
+ {
+ throw UnknownException("service set uri error");
+ }
+ }
+
+ // optional
+ LoggerI("getMime : " << control->getMime().c_str());
+ if (control->getMime().size() != 0)
+ {
+ if (service_set_mime(m_service, control->getMime().c_str() ) != SERVICE_ERROR_NONE)
+ {
+ throw UnknownException("service set mime error");
+ }
+ }
+
+ 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");
+ }
+#endif
+ std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = control->getAppControlDataArray();
+ size_t index = 0;
+
+ LoggerI (" App Control Datas Count : " << appControlDataArray.size());
+
+ DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
+
+ for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
+ {
+ DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
+ std::string key = appControlData->getKey();
+ LoggerI(" key : " << key);
+
+ if (key.empty())
+ continue;
+
+ std::vector<std::string> value = appControlDataArray[index]->getValue();
+ const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
+
+ for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
+ {
+ arrayValue[indexArray] = (char*)value[indexArray].c_str();
+ LoggerI( " value : " << arrayValue[indexArray]);
+ }
+
+ const char* strKey = key.c_str();
+ 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");
+ }
+
+ 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)
+{
+ LoggerI("m_service = " << m_service << " appId = " << appId);
+ if (!m_service)
+ {
+ if (service_create(&m_service) != SERVICE_ERROR_NONE)
+ {
+ 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 UnknownException("service set appId error");
+ }
+ }
+
+}
+
+std::string StatusNotification::getApplicationId()
+{
+ std::string retString;
+ char* appIdStr = NULL;
+#if 0
+ service_h service = NULL;
+
+ if (m_service != NULL)
+ {
+ int retcode;
+ retcode = service_clone(&service, m_service);
+
+ if (retcode != SERVICE_ERROR_NONE)
+ {
+ if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
+ {
+ LoggerW("SERVICE_ERROR_OUT_OF_MEMORY");
+ }
+ else
+ {
+ LoggerW("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
+ }
+ throw UnknownException ("get notification service error ");
+ }
+ else
+ {
+ if (service == NULL)
+ {
+ throw UnknownException ("get notification service ok, but service null");
+ }
+ }
+ }
+#endif
+ if (m_service != NULL)
+ {
+ if (service_get_app_id(m_service, &appIdStr) != SERVICE_ERROR_NONE)
+ {
+ throw UnknownException ("get a appId error");
+ }
+
+ if (appIdStr != NULL)
+ {
+ retString = appIdStr;
+ free(appIdStr);
+ }
+ }
+ LoggerI(retString);
+
+ return retString;
+
+}
+
+double StatusNotification::getProgressValue()
+{
+ double value = 0.0;
+
+ if (m_notiHandle)
+ {
NotificationProgressType progressType = getProgressType();
if (progressType == NOTI_PROGRESS_TYPE_SIZE)
{
if (notification_get_size(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification size error");
+ throw UnknownException("get notification size error");
}
+ LoggerI("Size Val = " << value);
}
else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
{
if (notification_get_progress(m_notiHandle, &value) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
+ throw UnknownException("get notification percentage error");
}
+ LoggerI("Percentage Val = " << value);
}
else
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
+ throw UnknownException("get notification progress type error");
}
}
else
{
- LogDebug("noti Handle is NULL");
+ LoggerD("noti Handle is NULL");
}
-
+ LoggerI("value = " << value);
return value;
}
void StatusNotification::setProgressValue(const double &progressValue)
{
- LogDebug(" ");
if (m_notiHandle)
{
NotificationProgressType progressType = getProgressType();
- LogDebug("Progress Type : " << progressType);
-
+ LoggerI("Progress Type : " << progressType);
+
double val = getProgressValue();
- LogDebug("Progress value = " << progressValue << " origin Progress Value =" << val);
+ LoggerI("Progress value = " << progressValue << " origin Progress Value =" << val);
if (progressType == NOTI_PROGRESS_TYPE_SIZE)
{
if (notification_set_size(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification size error");
+ throw UnknownException("set notification progress size error");
}
}
else if ( progressType == NOTI_PROGRESS_TYPE_PERCENTAGE )
{
-
if (notification_set_progress(m_notiHandle, progressValue) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification progress error");
+ throw UnknownException("set notification percentage error");
}
}
else
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification progress error");
+ throw UnknownException("get notification progress type error");
}
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification 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()
{
+ LoggerI("Handle = " << m_notiHandle);
if (m_notiHandle)
{
char *subIconPath = NULL;
if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_ICON_SUB, &subIconPath) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub icon error");
+ throw UnknownException("get notification sub icon error");
}
std::string notiSubIconPath;
}
else
{
- return std::string("");
+ throw UnknownException("notification handle is null");
}
}
{
if (m_notiHandle)
{
- LogDebug(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
+ LoggerI(" subIconPath = " << subIconPath << " origin SubIconPath = " << getSubIconPath());
if( getSubIconPath().compare(subIconPath))
{
if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_ICON_SUB, subIconPath.c_str()) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
+ throw UnknownException("set notification sound error");
}
setUpdatedFlag(true);
}
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
-std::vector<std::string> StatusNotification::getInformations()
+#if 0
+std::string StatusNotification::getInformation(int index)
{
-
- std::vector<std::string> infos;
-
if (m_notiHandle)
{
-
- char *info = NULL;
- if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_1, &info) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
- }
-
- if (info)
- infos.push_back(info); //info 1
- else
- infos.push_back(std::string("")); // insert empty String
- info = NULL;
-
- if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_2, &info) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
- }
-
- if (info)
- infos.push_back(info); //info 2
- else
- infos.push_back(std::string("")); // insert empty String
- info = NULL;
-#if 0
- if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_3, &info) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
- }
-
- if (info)
- infos.push_back(info); //info 3
- else
- infos.push_back(std::string("")); // insert empty String
-#endif
- info = NULL;
-
- }
- else
- {
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
- }
-
- return infos;
-}
-
-std::string StatusNotification::getInformation(int index)
-{
- if (m_notiHandle)
- {
- notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
- switch (index)
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
+ switch (index)
{
case 0:
type = NOTIFICATION_TEXT_TYPE_INFO_1;
if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification information error");
+ throw UnknownException("get notification information error");
}
std::string strInfo;
if (info)
strInfo = info;
- LogDebug(" info " << strInfo);
+ LoggerD(" info " << strInfo);
return strInfo;
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
- }
-
-}
-
-void StatusNotification::setInformations( std::vector<std::string>& infos)
-{
-
- if (m_notiHandle)
- {
- std::vector<std::string>::iterator it;
-
- int idx = 0;
- for (it = infos.begin(); it != infos.end(); ++it)
- {
- std::string str = *it;
- LogDebug(" Info : " << str);
-
- notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
- switch (idx)
- {
- 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;
- }
-
- if ( type != NOTIFICATION_TEXT_TYPE_NONE)
- {
- if (getInformation(idx).compare(str))
- {
- if (notification_set_text(m_notiHandle, type, str.c_str(),
- NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification information error");
- }
- setUpdatedFlag(true);
- }
- }
- idx ++;
- }
-
-
- }
- else
- {
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification 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)
if (notification_set_text(m_notiHandle, type, info.c_str(),
NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
+ throw UnknownException("set notification sound error");
}
setUpdatedFlag(true);
}
}
}
-}
-
-std::vector<std::string> StatusNotification::getSubInformations()
-{
- std::vector<std::string> subInfos;
-
- if (m_notiHandle)
- {
- char *subInfo = NULL;
- if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_1, &subInfo) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub background error");
- }
-
- if (subInfo)
- subInfos.push_back(subInfo);
- else
- subInfos.push_back(std::string());
- subInfo = NULL;
-
- if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_2, &subInfo) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
- }
-
- if (subInfo)
- subInfos.push_back(subInfo);
- else
- subInfos.push_back(std::string());
-
- subInfo = NULL;
-#if 0
- if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_INFO_SUB_3, &subInfo) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
- }
-
- if (subInfo)
- subInfos.push_back(subInfo);
- else
- subInfos.push_back(std::string());
-
- subInfo = NULL;
-#endif
- }
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
-
- return subInfos;
}
std::string StatusNotification::getSubInformation(int index)
if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
+ throw UnknownException( "get notification sub information error");
}
std::string strSubInfo;
if (subInfo)
strSubInfo = subInfo;
- LogDebug(" subInfo " << strSubInfo);
+ LoggerD(" subInfo " << strSubInfo);
return strSubInfo;
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
- }
-
-}
-
-void StatusNotification::setSubInformations(std::vector<std::string>& subInfos)
-{
- if (m_notiHandle)
- {
- std::vector<std::string>::iterator it;
-
- int idx = 0;
- for (it = subInfos.begin(); it < subInfos.end(); ++it)
- {
- std::string str = *it;
- LogDebug(" sub Info : " << str);
-
- notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
- switch (idx)
- {
- case 0:
- type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
- break;
- case 1:
- type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
- break;
- case 2:
- type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
- break;
- default :
- type = NOTIFICATION_TEXT_TYPE_NONE;
- }
-
- if ( type != NOTIFICATION_TEXT_TYPE_NONE)
- {
- if (getSubInformation(idx).compare(str))
- {
- if (notification_set_text(m_notiHandle, type, str.c_str(),
- NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification text error");
- }
- setUpdatedFlag(true);
- }
- }
- idx ++;
- }
-
- }
- else
- {
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
}
}
void StatusNotification::setSubInformation( const std::string& subInfo, int index)
{
-
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)
if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
+ throw UnknownException( "set notification sound error");
}
setUpdatedFlag(true);
}
}
}
+ else
+ {
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
+ }
+
}
+#endif
-#if 0
-std::vector<std::string> StatusNotification::getThumbnails()
+void StatusNotification::loadThumbnails()
{
- std::vector<std::string> thumbs;
if (m_notiHandle)
- {
- //clean
- if ( !thumbs.empty() )
- thumbs.clear();
-
+ {
+ if (!m_thumbs.empty())
+ m_thumbs.clear();
+
char *thumb = NULL;
if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
+ throw UnknownException( "get notification thumbnail error");
}
if (thumb)
- thumbs.push_back(thumb);
- else
- thumbs.push_back(std::string("")); //set empty
+ m_thumbs.push_back(thumb);
+ //else
+ // m_thumbs.push_back(std::string("")); //set empty
thumb = NULL;
if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
+ throw UnknownException( "get notification sub information error");
}
if (thumb)
- thumbs.push_back(thumb);
- else
- thumbs.push_back(std::string("")); //set empty
+ m_thumbs.push_back(thumb);
+ //else
+ // m_thumbs.push_back(std::string("")); //set empty
thumb = NULL;
if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
+ throw UnknownException( "get notification sub information error");
}
if (thumb)
- thumbs.push_back(thumb);
- else
- thumbs.push_back(std::string("")); //set empty
+ m_thumbs.push_back(thumb);
+ //else
+ // m_thumbs.push_back(std::string("")); //set empty
thumb = NULL;
if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
+ throw UnknownException( "get notification sub information error");
}
if (thumb)
- thumbs.push_back(thumb);
- else
- thumbs.push_back(std::string("")); //set empty
+ m_thumbs.push_back(thumb);
+ //else
+ // m_thumbs.push_back(std::string("")); //set empty
thumb = NULL;
-
+#if 0
if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
+ throw UnknownException( "get notification sub information error");
}
if (thumb)
- thumbs.push_back(thumb);
+ m_thumbs.push_back(thumb);
else
- thumbs.push_back(std::string("")); //set empty
+ m_thumbs.push_back(std::string("")); //set empty
thumb = NULL;
+#endif
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
}
+}
- return thumbs;
+std::vector<std::string> StatusNotification::getThumbnails()
+{
+ LoggerI(" thumbnail Size : " << m_thumbs.size());
+ return m_thumbs;
}
-#endif
std::string StatusNotification::getThumbnail(int index)
{
-
if (m_notiHandle)
{
- notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_LIST_1;
+ LoggerI(" index : " << index);
+
+ notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
switch (index)
{
case 4:
type = NOTIFICATION_IMAGE_TYPE_LIST_5;
break;
-
default :
type = NOTIFICATION_IMAGE_TYPE_NONE;
}
-
- char* thumb=NULL;
-
- if (NOTIFICATION_IMAGE_TYPE_NONE != type && notification_get_image(m_notiHandle, type, &thumb) != NOTIFICATION_ERROR_NONE)
+
+ if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
- }
+ char *thumb = NULL;
+ if (notification_get_image(m_notiHandle, type, &thumb) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException( "set notification thumbnail error");
+ }
- std::string strThumb;
-
- if (thumb)
- strThumb = thumb;
+ std::string thumbnail;
+ if(thumb)
+ thumbnail = thumb;
+ return thumbnail;
+ }
+ else
+ {
+ throw UnknownException( "notification handle is null");
+ }
- LogDebug(" info " << strThumb);
- return strThumb;
-
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
}
+#if 0
+ if (m_thumbs.size() > index)
+ return m_thumbs[index];
+ else
+ return std::string("");
+#endif
}
-void StatusNotification::setThumbnails(std::vector<std::string>& thumbs)
+void StatusNotification::setThumbnails(std::vector<std::string> thumbs)
{
+ LoggerI("set thumbnails");
if (m_notiHandle)
{
std::vector<std::string>::iterator it;
for (it = thumbs.begin(); it < thumbs.end(); ++it)
{
std::string str = *it;
- LogDebug(" thumbs : " << str);
-
- notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
- switch (idx)
- {
- case 0:
- type = NOTIFICATION_IMAGE_TYPE_LIST_1;
- break;
- case 1:
- type = NOTIFICATION_IMAGE_TYPE_LIST_2;
- break;
- case 2:
- type = NOTIFICATION_IMAGE_TYPE_LIST_3;
- break;
- case 3:
- type = NOTIFICATION_IMAGE_TYPE_LIST_4;
- break;
- case 4:
- type = NOTIFICATION_IMAGE_TYPE_LIST_5;
- break;
- default :
- type = NOTIFICATION_IMAGE_TYPE_NONE;
- }
-
- if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
- {
- if (getThumbnail(idx).compare(str))
- {
- if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
- }
- setUpdatedFlag(true);
- }
- }
+ if ( idx < MAX_THUMBNAIL_LENGTH )
+ setThumbnail(str, idx); //set notification's thumbnail value.
idx ++;
}
-
+ m_thumbs = thumbs;
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
}
-
}
void StatusNotification::setThumbnail( const std::string& thumb, int index)
{
if (m_notiHandle)
{
- LogDebug(" index : " << index);
- LogDebug(" thumb : " << thumb);
+ LoggerI(" index : " << index);
+ LoggerI(" thumb : " << thumb);
notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
switch (index)
break;
case 4:
type = NOTIFICATION_IMAGE_TYPE_LIST_5;
- break;
+ break;
default :
type = NOTIFICATION_IMAGE_TYPE_NONE;
}
- if ( type != NOTIFICATION_TEXT_TYPE_NONE)
+ if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
{
-
if (getThumbnail(index).compare(thumb))
{
if (notification_set_image(m_notiHandle, type, thumb.c_str()) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
+ throw UnknownException( "set notification thumbnail error");
}
setUpdatedFlag(true);
}
}
}
-
-}
-
-void StatusNotification::setThumbnails(const StringArrayPtr &value)
-{
- if(value == NULL)
- m_thumbs = StringArrayPtr(new StringArray());
- else
- m_thumbs = value;
-#if 0
- if (m_notiHandle)
- {
- //set notification.
- if (value)
- {
- //setThumbnails
- std::vector<std::string>::iterator it;
-
- int idx = 0;
- for (it = m_thumbs->begin(); it < m_thumbs->end(); ++it)
- {
- std::string str = *it;
- LogDebug(" thumbs : " << str);
- DeviceAPI::Filesystem::IPathPtr path = DeviceAPI::Filesystem::Utils::fromVirtualPath(context, soundPath);
- str = path->getFullPath();
-
- LogDebug(" thumbs : " << str);
- notification_image_type_e type = NOTIFICATION_IMAGE_TYPE_NONE;
- switch (idx)
- {
- case 0:
- type = NOTIFICATION_IMAGE_TYPE_LIST_1;
- break;
- case 1:
- type = NOTIFICATION_IMAGE_TYPE_LIST_2;
- break;
- case 2:
- type = NOTIFICATION_IMAGE_TYPE_LIST_3;
- break;
- case 3:
- type = NOTIFICATION_IMAGE_TYPE_LIST_4;
- break;
- case 4:
- type = NOTIFICATION_IMAGE_TYPE_LIST_5;
- break;
- default :
- type = NOTIFICATION_IMAGE_TYPE_NONE;
- }
-
- if ( type != NOTIFICATION_IMAGE_TYPE_NONE)
- {
- if (getThumbnail(idx).compare(str))
- {
- if (notification_set_image(m_notiHandle, type, str.c_str()) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification thumbnail error");
- }
- setUpdatedFlag(true);
- }
- }
- idx ++;
- }
-
-
-
- }
- }
-#endif
-
-}
-
-StringArrayPtr StatusNotification::getThumbnails()
-{
-
- if (m_notiHandle)
- {
- if ( !m_thumbs->empty() )
- m_thumbs->clear();
-
- char *thumb = NULL;
- if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_1, &thumb) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification thumbnail error");
- }
- if (thumb)
- m_thumbs->push_back(thumb);
- else
- m_thumbs->push_back(std::string("")); //set empty
- thumb = NULL;
-
- if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_2, &thumb) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
- }
- if (thumb)
- m_thumbs->push_back(thumb);
- else
- m_thumbs->push_back(std::string("")); //set empty
- thumb = NULL;
-
- if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_3, &thumb) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
- }
-
- if (thumb)
- m_thumbs->push_back(thumb);
- else
- m_thumbs->push_back(std::string("")); //set empty
- thumb = NULL;
-
- if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_4, &thumb) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
- }
-
- if (thumb)
- m_thumbs->push_back(thumb);
- else
- m_thumbs->push_back(std::string("")); //set empty
- thumb = NULL;
-#if 0
- if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_LIST_5, &thumb) != NOTIFICATION_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification sub information error");
- }
-
- if (thumb)
- m_thumbs->push_back(thumb);
- else
- m_thumbs->push_back(std::string("")); //set empty
- thumb = NULL;
-#endif
- }
- return m_thumbs;
}
-
-
std::string StatusNotification::getBackground()
{
+ LoggerI(" Handle : " << m_notiHandle);
+
if (m_notiHandle)
{
char *background = NULL;
if (notification_get_image(m_notiHandle, NOTIFICATION_IMAGE_TYPE_BACKGROUND, &background) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
+ throw UnknownException( "get notification background error");
}
std::string notiBackground;
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
}
}
void StatusNotification::setBackground(const std::string imagePath)
{
+ LoggerI(" imagePath : " << imagePath);
if (m_notiHandle)
{
if (getBackground().compare(imagePath))
{
if (notification_set_image(m_notiHandle,NOTIFICATION_IMAGE_TYPE_BACKGROUND, imagePath.c_str()) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
+ throw UnknownException( "set notification sound error");
}
setUpdatedFlag(true);
}
}
else
{
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
}
}
-unsigned int StatusNotification::getNumber()
+long StatusNotification::getNumber()
{
+ 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)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification background error");
+ throw UnknownException( "get notification background error");
}
if (strNumber)
std::istringstream(strNumber) >> number;
+ else
+ LoggerI("Number Is NULL");
- LogDebug("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()
{
+ LoggerI("Handle = " << m_notiHandle);
if (m_notiHandle)
{
- if(number!=getNumber())
+ char *strNumber = NULL;
+
+ if (notification_get_text(m_notiHandle, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, &strNumber) != NOTIFICATION_ERROR_NONE)
{
- std::stringstream stream;
- stream << number;
- if (stream.fail()) {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException,
- "Couldn't convert e-mail account id");
- }
-
- 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)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "set notification sound error");
- }
- setUpdatedFlag(true);
+ throw UnknownException( "get notification background error");
}
+
+ if (!strNumber)
+ {
+ return NULL;
+ }
+
+ return strNumber;
}
else
- {
- LogDebug("noti Handle is NULL");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle is null");
+ {
+ LoggerD("noti Handle is NULL");
+ return NULL;
}
}
-
+void StatusNotification::setNumber(const long number)
+{
+ LoggerI("Number = " << number);
+ if (m_notiHandle)
+ {
+ if(number!=getNumber())
+ {
+ std::stringstream stream;
+ stream << number;
+ if (stream.fail()) {
+ throw UnknownException(
+ "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 text error");
+ }
+ setUpdatedFlag(true);
+ }
+ }
+ else
+ {
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
+ }
+}
void* StatusNotification::getNotificationHandle()
{
{
if (handle == NULL)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
+ throw UnknownException( "notification handle null error");
}
- LogDebug("handle = " << handle << " m_notiHandle = " << m_notiHandle);
+ LoggerI("handle = " << handle << " m_notiHandle = " << m_notiHandle);
if (m_notiHandle != NULL)
{
//delete old noti.
if ( notification_delete(m_notiHandle) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification delete error");
+ throw UnknownException( "notification delete error");
}
m_notiHandle = NULL;
}
m_notiHandle = (notification_h)handle;
}
-void StatusNotification::setNotificationLines()
+service_h StatusNotification::getService()
{
- if (m_notiHandle == NULL)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "notification handle null error");
- }
- LogDebug("handle = " << m_notiHandle);
-
- if (getLinesNum() > 0)
- clearLines();
-
- //getLine
- std::vector<std::string> infos = getInformations();
- std::vector<std::string> subInfos = getSubInformations();
-
- LogDebug("info size = " << infos.size());
- LogDebug("subInfo size = " << subInfos.size());
-
- std::vector<std::string>::iterator it;
-
- int idx = 0;
-
- NotificationLineArrayPtr lines = getLines();
+ return m_service;
+}
- for (it = infos.begin(); it < infos.end(); ++it)
+std::string StatusNotification::getLight()
+{
+ LoggerI("get Light handle: " << m_notiHandle);
+ if (m_notiHandle)
{
- std::string info = *it;
- LogDebug(" Info : " << info);
- LogDebug("subInfo=" << subInfos[idx]);
-
- if (!(info.empty() && subInfos[idx].empty()))
+ int ledColor = 0;
+ notification_led_op_e type = NOTIFICATION_LED_OP_ON;
+ if (notification_get_led(m_notiHandle, &type, &ledColor) != NOTIFICATION_ERROR_NONE)
{
- NotificationLinePtr line(new NotificationLine(m_notiHandle,idx,info,subInfos[idx]));
- lines->push_back(line);
+ throw UnknownException("get notification Content error");
}
- idx++;
- }
-
-}
-
-DeviceAPI::Application::ApplicationControlPtr StatusNotification::getApplicationControl()
-{
- service_h service = NULL;
- int retcode = 0;
- int error = 0;
- char *tempStr = NULL;
-
- DeviceAPI::Application::ApplicationControlPtr appControl(new DeviceAPI::Application::ApplicationControl());
-
- try {
-
- if (m_service)
+ std::string light;
+ std::stringstream stream;
+ if (NOTIFICATION_LED_OP_OFF != type)
{
- appControl->setService_h(m_service);
-
- // mandatory
- int ret = service_get_operation(m_service, &tempStr);
- LogDebug("ret = " << ret);
- //if (service_get_operation(service, &tempStr) != SERVICE_ERROR_NONE)
- if(ret != SERVICE_ERROR_NONE)
- {
- LogDebug(" Opertation is Empty");
- }
- LogDebug("temp Str = " << tempStr);
-
- if (tempStr)
- {
- appControl->setOperation(tempStr);
- free(tempStr);
- tempStr = NULL;
- }
-
- // optional
- if (service_get_mime(m_service, &tempStr) == SERVICE_ERROR_NONE)
- {
- if (tempStr)
- {
- appControl->setMime(tempStr);
- free(tempStr);
- tempStr = NULL;
- }
- }
-
- // optional
- if (service_get_uri(m_service, &tempStr) == SERVICE_ERROR_NONE)
- {
- if (tempStr)
- {
- appControl->setUri(tempStr);
- free(tempStr);
- tempStr = NULL;
- }
- }
-
- // optional
- if ( service_foreach_extra_data(m_service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
- }
-
- return appControl;
+ stream << std::hex << ledColor;
+ light = "#" + stream.str();
}
-
+
+ return boost::to_lower_copy(light);
}
- Catch (WrtDeviceApis::Commons::Exception)
+ else
{
- if (tempStr)
+ 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++)
{
- free(tempStr);
- tempStr = NULL;
+ if (std::string::npos == hexCode.find(color[i]))
+ return false;
}
+ return true;
+ }
+ return false;
+}
- if (service)
+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))
{
- free(service);
- service = NULL;
- }
+ std::stringstream stream;
+ int ledColor = 0;
+ notification_led_op_e type = NOTIFICATION_LED_OP_ON;
+ std::string colorCode = color.substr(1, color.length());
- if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
- {
- ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
+ 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
{
- ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
- }
- }
-
-#if 0
- try {
-
- if (m_service != NULL)
- {
- retcode = service_clone(&service, m_service);
-
- if (retcode != SERVICE_ERROR_NONE)
- {
-
- if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
- {
- LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
- }
- else
+ LoggerI("color.length()=" << color.length());
+ if (color.length() == 0)
+ {
+ if (notification_set_led(m_notiHandle, NOTIFICATION_LED_OP_OFF, 0) != NOTIFICATION_ERROR_NONE)
{
- LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
+ throw UnknownException("set notification led ");
}
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
}
else
{
- if (service == NULL)
- {
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");
- }
+ throw InvalidValuesException("color code error!");
}
}
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
- appControl->setService_h(service);
-
- // mandatory
- int ret = service_get_operation(service, &tempStr);
- LogDebug("ret = " << ret);
- //if (service_get_operation(service, &tempStr) != SERVICE_ERROR_NONE)
- if(ret != SERVICE_ERROR_NONE)
+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)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service operation error");
+ throw UnknownException("set notification led ");
}
+ LoggerI("onTime " << onTime);
- LogDebug("temp Str = " << tempStr);
+ return (unsigned long) onTime;
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
- if (tempStr)
- {
- appControl->setOperation(tempStr);
- free(tempStr);
- tempStr = NULL;
- }
- else
+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)
{
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service operation ok, but null");
+ throw UnknownException("set notification led ");
}
+
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
- // optional
- if (service_get_mime(service, &tempStr) == SERVICE_ERROR_NONE)
- {
- if (tempStr)
- {
- appControl->setMime(tempStr);
- free(tempStr);
- tempStr = NULL;
- }
- }
+unsigned long StatusNotification::getLightOffTime()
+{
- // optional
- if (service_get_uri(service, &tempStr) == SERVICE_ERROR_NONE)
+ 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)
{
- if (tempStr)
- {
- appControl->setUri(tempStr);
- free(tempStr);
- tempStr = NULL;
- }
+ throw UnknownException("set notification led ");
}
+ LoggerI("offTime " << offTime);
+
+ return offTime;
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
- // optional
- if ( service_foreach_extra_data(service, service_extra_data_cb,(void*)&appControl) != SERVICE_ERROR_NONE)
- {
- LogDebug(error);
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service uri error");
- }
+}
- return appControl;
-
- }
- Catch (WrtDeviceApis::Commons::Exception)
+void StatusNotification::setLightOffTime(unsigned long time)
+{
+ LoggerI("set Light off Time handle: " << m_notiHandle);
+ LoggerI("time = " << time);
+ if (m_notiHandle)
{
- if (tempStr)
+ int onTime = getLightOnTime();
+
+ if (notification_set_led_time_period(m_notiHandle, onTime, time ) != NOTIFICATION_ERROR_NONE)
{
- free(tempStr);
- tempStr = NULL;
+ throw UnknownException("set notification led ");
}
+ }
+ else
+ {
+ throw UnknownException("notification handle is null");
+ }
+}
- if (service)
- {
- free(service);
- service = NULL;
- }
+//Detail Info
+void StatusNotification::loadDetailInfos()
+{
+ LoggerI("noti Handle = " << m_notiHandle);
- if (_rethrown_exception.getCode() == WrtDeviceApis::Commons::ExceptionCodes::NullPointerException)
+ if (m_notiHandle)
+ {
+ for ( int idx = 0; idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH; idx++)
{
- ReThrowMsg(WrtDeviceApis::Commons::NullPointerException, _rethrown_exception.GetMessage());
+ 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
- {
- ReThrowMsg(WrtDeviceApis::Commons::UnknownException, _rethrown_exception.GetMessage());
- }
-
+ }
+ else
+ {
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
}
-#endif
-
- return appControl;
+
}
-void StatusNotification::setApplicationControl(DeviceAPI::Application::ApplicationControlPtr appControl)
+std::vector<NotificationDetailInfo*> StatusNotification::getDetailInfos() const
{
+ return m_detailInfos;
+}
- LogDebug("Entered m_service : " << m_service);
+void StatusNotification::setDetailInfos(const std::vector<NotificationDetailInfo*> value)
+{
+ LoggerI("DetailInfos = " << value.size());
+
+ if (m_notiHandle)
+ {
+ std::vector<NotificationDetailInfo*>::const_iterator it;
+
+ int idx = 0;
+ for (it = value.begin(); it < value.end(); ++it)
+ {
+ NotificationDetailInfo* info = *it;
+ if ( idx < MAX_NOTIFICATION_DETAIL_INFO_LENGTH )
+ {
+
+ LoggerI("main " << info->getMainText() << " sub " << info->getSubText() );
+ setInformation(info->getMainText(), idx);
+ setSubInformation(info->getSubText(), idx);
+ }
+ idx ++;
+ }
+
+ m_detailInfos = value;
+ }
+ else
+ {
+ LoggerD("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
+ }
- if(m_service == NULL && service_create(&m_service) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
+}
+
+int StatusNotification::getDetailInfosNum() const
+{
+ return m_detailInfos.size();
+}
+
+void StatusNotification::clearDetailInfos()
+{
+ if ( !m_detailInfos.empty() )
+ {
+ std::vector<NotificationDetailInfo*>::const_iterator it;
+
+ int idx = 0;
+ for (it = m_detailInfos.begin(); it < m_detailInfos.end(); ++it)
+ {
+ NotificationDetailInfo* info = *it;
+ LoggerI("Delete Detail Info : " << info);
+ if (info)
+ delete info;
+ idx ++;
+ }
+ m_detailInfos.clear(); //clear
}
- else
+}
+
+std::string StatusNotification::getInformation(int index)
+{
+ if (m_notiHandle)
{
- LogDebug("getOperation : " << appControl->getOperation().c_str());
- if (appControl->getOperation().size() != 0)
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
+ switch (index)
{
- if (service_set_operation(m_service, appControl->getOperation().c_str()) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
- }
+ 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;
}
-
- // optional
- LogDebug("getUri : " << appControl->getUri().c_str());
- if (appControl->getUri().size() != 0)
+ char *info = NULL;
+
+ if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
{
- if (service_set_uri(m_service, appControl->getUri().c_str() ) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
- }
+ throw UnknownException("Detail Info index value is invalid or mainText value getting is failed in Detail Info.");
}
- // optional
- LogDebug("getMime : " << appControl->getMime().c_str());
- if (appControl->getMime().size() != 0)
- {
- if (service_set_mime(m_service, appControl->getMime().c_str() ) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
- }
- }
+ std::string strInfo;
+ if (info)
+ strInfo = info;
+ LoggerI(" info " << strInfo);
+ return strInfo;
- LogDebug("Category : " << appControl->getCategory().c_str());
- if (appControl->getCategory().size() != 0)
- {
- if (service_set_category(m_service, appControl->getCategory().c_str() ) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
- }
- }
-
- std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = appControl->getAppControlDataArray();
- size_t index = 0, indexArray = 0;
-
- LogDebug (" App Control Datas Count : " << appControlDataArray.size());
-
- DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
-
- for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
- {
- DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
- std::string key = appControlData->getKey();
- LogDebug(" key : " << key);
-
- if (key.empty())
- continue;
-
- std::vector<std::string> value = appControlDataArray[index]->getValue();
- const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
-
- for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
- {
- arrayValue[indexArray] = (char*)value[indexArray].c_str();
- LogDebug( " value : " << arrayValue[indexArray]);
- }
-
- const char* strKey = key.c_str();
- if ( value.size() == 1)
- {
- if (service_add_extra_data(m_service, strKey, arrayValue[0]) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
- }
- }
- else
- {
- if (service_add_extra_data_array(m_service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
- }
-
- }
-
- if (arrayValue)
- free(arrayValue);
- }
-
- }
-#if 0
- LogDebug("Entered");
- service_h service = NULL;
- int retcode = SERVICE_ERROR_NONE;
-
- LogDebug("m_service : " << m_service);
-
- if(service == NULL && service_create(&service) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
}
+ else
+ {
+ LoggerW("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
+ }
+
+}
- if (service)
+bool StatusNotification::isNullInformation(int index)
+{
+ if (m_notiHandle)
{
-
- LogDebug("getOperation : " << appControl->getOperation().c_str());
- if (appControl->getOperation().size() != 0)
- {
- if (service_set_operation(service, appControl->getOperation().c_str()) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
- }
- }
-
- // optional
- if (appControl->getUri().size() != 0)
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
+ switch (index)
{
- if (service_set_uri(service, appControl->getUri().c_str() ) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set uri error");
- }
+ 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;
}
-
- // optional
- if (appControl->getMime().size() != 0)
+ char *info = NULL;
+
+ if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &info) != NOTIFICATION_ERROR_NONE)
{
- if (service_set_mime(service, appControl->getMime().c_str() ) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set mime error");
- }
+ throw UnknownException("Detail Info index value is invalid or mainText value getting is failed in Detail Info.");
}
- std::vector<DeviceAPI::Application::ApplicationControlDataPtr> appControlDataArray = appControl->getAppControlDataArray();
- size_t index = 0, indexArray = 0;
-
- LogDebug (" App Control Datas Count : " << appControlDataArray.size());
-
- DeviceAPI::Application::ApplicationControlDataArray::iterator iter;
-
- for(iter = appControlDataArray.begin(); iter != appControlDataArray.end(); iter++)
+ if (info)
{
- DeviceAPI::Application::ApplicationControlDataPtr appControlData = *iter;
- std::string key = appControlData->getKey();
- LogDebug(" key : " << key);
-
- if (key.empty())
- continue;
-
- std::vector<std::string> value = appControlDataArray[index]->getValue();
- const char **arrayValue = (const char**)calloc(sizeof(char*), value.size());
-
- for (size_t indexArray = 0; indexArray < value.size(); indexArray++)
- {
- arrayValue[indexArray] = (char*)value[indexArray].c_str();
- LogDebug( " value : " << arrayValue[indexArray]);
- }
-
- const char* strKey = key.c_str();
- if ( value.size() == 1)
- {
- if (service_add_extra_data(service, strKey, arrayValue[0]) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
- }
- }
- else
- {
- if (service_add_extra_data_array(service, strKey, arrayValue, value.size()) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set extra data error");
- }
-
- }
-
- if (arrayValue)
- free(arrayValue);
-
+ LoggerI("is not null");
+ return false;
}
-
- if (m_service != NULL) //service destory.
+ else
{
- service_destroy(m_service);
- m_service = NULL;
+ LoggerI("is null");
+ return true;
}
- m_service = service;
}
else
- {
- LogDebug(" Service is NULL ");
+ {
+ LoggerW("noti Handle is NULL");
+ throw UnknownException( "notification handle is null");
}
-
- LogDebug("m_service : " << m_service);
-#endif
}
-void StatusNotification::setApplicationId(const std::string& appId)
+std::string StatusNotification::getSubInformation(int index)
{
- int retcode = 0;
- LogDebug("m_service = " << m_service << " appId = " << appId);
- if (!m_service)
- {
- LogDebug("m_service = " << m_service);
- if (service_create(&m_service) != SERVICE_ERROR_NONE)
- {
- LogDebug("Create Service Failed..");
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
- }
- }
-
- if (m_service)
- {
- if (service_set_app_id(m_service, appId.c_str())!= SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");
- }
- }
-
-#if 0
- int retcode = 0;
- service_h service = NULL;
- char* operation = NULL;
- LogDebug("Entered : " << appId);
-
- LogDebug("m_service = " << m_service);
- if (m_service != NULL)
- {
- retcode = service_clone(&service, m_service);
- if (retcode != SERVICE_ERROR_NONE)
- {
- if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
- {
- LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
- }
- else
- {
- LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
- }
-
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
- }
- }
-
- if(service == NULL)
+ if (m_notiHandle)
{
- if (service_create(&service) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service creation error");
- }
- }
-
- if(service)
- {
- if (service_get_operation(service, &operation) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service get operation error");
- }
-
- if (operation)
- {
- free(operation);
- operation = NULL;
- }
- else if (service_set_operation(service, SERVICE_OPERATION_DEFAULT) != SERVICE_ERROR_NONE)
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
+ switch (index)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set operation error");
+ case 0:
+ type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
+ break;
+ case 1:
+ type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
+ break;
+ case 2:
+ type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
+ break;
+ default :
+ type = NOTIFICATION_TEXT_TYPE_NONE;
}
+
+ char *subInfo = NULL;
- if (service_set_app_id(service, appId.c_str())!= SERVICE_ERROR_NONE)
+ if (NOTIFICATION_TEXT_TYPE_NONE != type && notification_get_text(m_notiHandle, type, &subInfo) != NOTIFICATION_ERROR_NONE)
{
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "service set appId error");
+ throw UnknownException("Detail Info index value is invalid or subText value getting is failed in Detail Info.");
}
- if (m_service != NULL)
- {
- service_destroy(m_service);
- m_service = NULL;
- }
-
- m_service = service; //set service.
+ std::string strSubInfo;
+ if (subInfo)
+ strSubInfo = subInfo;
+ LoggerI(" subInfo " << strSubInfo);
+ return strSubInfo;
+
}
-#endif
+ else
+ {
+ LoggerW("noti Handle is NULL");
+ throw UnknownException ("notification handle is null");
+ }
+
}
-std::string StatusNotification::getApplicationId()
+void StatusNotification::setInformation( const std::string& info, int index)
{
- std::string retString;
- service_h service = NULL;
- char* appIdStr = NULL;
-
- if (m_service != NULL)
+ if (m_notiHandle)
{
- int retcode;
- retcode = service_clone(&service, m_service);
+ int idx = index;
+ LoggerD(" index : " << idx);
+ LoggerD(" log : " << info);
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
- if (retcode != SERVICE_ERROR_NONE)
+ switch (idx)
{
- if (retcode == SERVICE_ERROR_OUT_OF_MEMORY)
- {
- LogDebug("SERVICE_ERROR_OUT_OF_MEMORY");
- }
- else
- {
- LogDebug("UI_NOTIFICATION_ERROR_INVALID_PARAMETER");
- }
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get notification service error ");
+ 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;
}
- else
+
+ if ( type != NOTIFICATION_TEXT_TYPE_NONE)
{
- if (service == NULL)
+ if (getInformation(idx).compare(info) || isNullInformation(idx))
{
- ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "get notification service ok, but service null");
+ if (notification_set_text(m_notiHandle, type, info.c_str(),
+ NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification sound error");
+ }
+ setUpdatedFlag(true);
}
}
- }
-
- if (service != NULL)
- {
- if (service_get_app_id(service, &appIdStr) != SERVICE_ERROR_NONE)
- {
- ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get a appId error");
- }
-
- if (appIdStr != NULL)
- {
- retString = appIdStr;
- free(appIdStr);
+ else
+ {
+ LoggerW("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
- LogDebug(retString);
-
- return retString;
-}
-
-service_h StatusNotification::getService()
-{
- return m_service;
+ else
+ {
+ LoggerW("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
+ }
}
-
-NotificationLineArrayPtr StatusNotification::getLines() const
+void StatusNotification::setSubInformation( const std::string& subInfo, int index)
{
- return m_lines;
-}
-int StatusNotification::getLinesNum() const
-{
- return m_lines->size();
-}
-
-void StatusNotification::setLines(const NotificationLineArrayPtr &value)
-{
- LogDebug("setlines");
- if (value == NULL)
- {
- m_lines = NotificationLineArrayPtr(new NotificationLineArray());
- }
- else
+ if (m_notiHandle)
{
- m_lines = value;
-
- NotificationLineArray::iterator iter;
- int index = 0;
- for(iter = m_lines->begin(); iter != m_lines->end(); iter++)
- {
- NotificationLinePtr line = *iter;
- LogDebug("info = " << line->getInformation());
- LogDebug("sub info = " << line->getSubInformation());
-
- setInformation(line->getInformation(),index);
- setSubInformation(line->getSubInformation(),index);
- index ++;
- if (index>1)
+ int idx = index;
+ LoggerD(" index : " << idx);
+ LoggerD(" log : " << subInfo);
+ notification_text_type_e type = NOTIFICATION_TEXT_TYPE_NONE;
+
+ switch (idx)
+ {
+ case 0:
+ type = NOTIFICATION_TEXT_TYPE_INFO_SUB_1;
+ break;
+ case 1:
+ type = NOTIFICATION_TEXT_TYPE_INFO_SUB_2;
break;
+ case 2:
+ type = NOTIFICATION_TEXT_TYPE_INFO_SUB_3;
+ break;
+ default :
+ type = NOTIFICATION_TEXT_TYPE_NONE;
}
+ if ( type != NOTIFICATION_TEXT_TYPE_NONE)
+ {
+ if (getSubInformation(idx).compare(subInfo))
+ {
+ if (notification_set_text(m_notiHandle, type, subInfo.c_str(),
+ NULL, NOTIFICATION_VARIABLE_TYPE_NONE) != NOTIFICATION_ERROR_NONE)
+ {
+ throw UnknownException("set notification sound error");
+ }
+ setUpdatedFlag(true);
+ }
+ }
+ }
+ else
+ {
+ LoggerW("noti Handle is NULL");
+ throw UnknownException("notification handle is null");
}
}
-void StatusNotification::addLine(const NotificationLinePtr &value)
-{
- m_lines->push_back(value);
-}
-
-void StatusNotification::clearLines()
-{
- m_lines->clear();
-}
-
-}
-}
-
+} // Notification
+} // DeviceAPI