+static int ui_notification_construct(bool ongoing, notification_h raw_handle, ui_notification_h *notification)
+{
+ int retcode;
+ ui_notification_h notification_out;
+ char *icon;
+ time_t time;
+ char *title;
+ char *content;
+ bundle *service_data;
+
+ if (notification == NULL)
+ {
+ LOGE("[%s] INVALID_PARAMETER(0x%08x) : invalid output param", __FUNCTION__, UI_NOTIFICATION_ERROR_INVALID_PARAMETER);
+ return UI_NOTIFICATION_ERROR_INVALID_PARAMETER;
+ }
+
+ notification_out = (ui_notification_h)calloc(1, sizeof(struct ui_notification_s));
+
+ if (notification_out == NULL)
+ {
+ LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
+ return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ retcode = ui_notification_error_handler(notification_clone(raw_handle, &(notification_out->raw_handle)),\
+ __FUNCTION__, "failed to clone the notification handle");
+
+ if (retcode != NOTIFICATION_ERROR_NONE)
+ {
+ return retcode;
+ }
+
+ notification_out->ongoing = ongoing;
+
+ notification_out->posted = true;
+
+ notification_out->removed = false;
+
+ if (!notification_get_image(raw_handle, NOTIFICATION_IMAGE_TYPE_ICON, &icon))
+ {
+ notification_out->icon = icon;
+ }
+
+ if (!notification_get_time(raw_handle, &time))
+ {
+ notification_out->time = malloc(sizeof(struct tm));
+
+ if (notification_out->time == NULL)
+ {
+ ui_notification_destroy(notification_out);
+ LOGE("[%s] OUT_OF_MEMORY(0x%08x)", __FUNCTION__, UI_NOTIFICATION_ERROR_OUT_OF_MEMORY);
+ return UI_NOTIFICATION_ERROR_OUT_OF_MEMORY;
+ }
+
+ localtime_r(&time, notification_out->time);
+ }
+
+ if (!notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_TITLE, &title))
+ {
+ notification_out->title = title;
+ }
+
+ if (! notification_get_text(raw_handle, NOTIFICATION_TEXT_TYPE_CONTENT, &content))
+ {
+ notification_out->content = content;
+ }
+
+ if (!notification_get_execute_option(raw_handle, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, &service_data))
+ {
+ service_h service;
+
+ if (!service_create_request(service_data, &service))
+ {
+ notification_out->service = service;
+ }
+ }
+
+ *notification = notification_out;
+
+ return UI_NOTIFICATION_ERROR_NONE;
+}
+