* limitations under the License.
*
*/
-
+#include <dlog.h>
#include "notification.h"
Notification::Notification(notification_type_e type)
void Notification::setTitle(const std::string &title)
{
- ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE,
+ int ret = ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE,
title.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ if (ret != NOTIFICATION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set title text to notification");
}
void Notification::setContentText(const std::string &content)
{
- ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT,
+ int ret = ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT,
content.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+ if (ret != NOTIFICATION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set content text to notification");
}
void Notification::setProgress(double value)
{
- ::notification_set_progress(notification, value);
+ if (::notification_set_progress(notification, value)
+ != NOTIFICATION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set progress to notification");
}
double Notification::getProgress()
void Notification::setLayout(notification_ly_type_e type)
{
- ::notification_set_layout(notification, type);
+ if (::notification_set_layout(notification, type) != NOTIFICATION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set layout to notification");
}
void Notification::setImage(const std::string &path)
{
- ::notification_set_image(notification, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, path.c_str());
+ if (::notification_set_image(notification, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, path.c_str()) != NOTIFICATION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set image to notification");
}
void Notification::setAppControl(AppControl &appControl)
{
- ::notification_set_launch_option(notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl);
+ if (::notification_set_launch_option(notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl)
+ != NOTIFICATION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to set launch option to notification");
}
void Notification::update()
{
- ::notification_update(notification);
+ if (::notification_update(notification) != NOTIFICATION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to update notification");
}
void Notification::post()
{
- ::notification_post(notification);
+ if (::notification_post(notification) != NOTIFICATION_ERROR_NONE)
+ dlog_print(DLOG_ERROR, LOG_TAG, "Failed to post notification");
}
void Notification::dispose()
if (title) {
ret = notification_set_text(handle, NOTIFICATION_TEXT_TYPE_TITLE, title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
- if (ret != NOTIFICATION_ERROR_NONE)
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ notification_free(handle);
return NULL;
+ }
}
if (content) {
ret = notification_set_text(handle, NOTIFICATION_TEXT_TYPE_CONTENT, content, NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
- if (ret != NOTIFICATION_ERROR_NONE)
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ notification_free(handle);
return NULL;
+ }
}
if (image) {
ret = notification_set_image(handle, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, image);
- if (ret != NOTIFICATION_ERROR_NONE)
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ notification_free(handle);
return NULL;
+ }
}
ret = notification_set_layout(handle, layout);
- if (ret != NOTIFICATION_ERROR_NONE)
+ if (ret != NOTIFICATION_ERROR_NONE) {
+ notification_free(handle);
return NULL;
+ }
return handle;
}