Move notification_get_text_input_max_length to internal
[platform/core/api/notification.git] / src / notification_internal.c
index 4fbe665..d1b8344 100755 (executable)
@@ -1281,3 +1281,133 @@ EXPORT_API notification_h notification_load_by_tag_for_uid(const char *tag, uid_
 
        return noti;
 }
+
+EXPORT_API notification_h notification_create_from_package_template(const char *pkgname, const char *template_name)
+{
+       int ret = 0;
+       notification_h noti = NULL;
+
+       if (pkgname == NULL || template_name == NULL) {
+               NOTIFICATION_ERR("Invalid parameter");
+               set_last_result(NOTIFICATION_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       noti = (notification_h)calloc(1, sizeof(struct _notification));
+       if (noti == NULL) {
+               NOTIFICATION_ERR("Failed to alloc a new notification");
+               set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+
+       ret = notification_ipc_request_create_from_package_template(noti, pkgname, template_name);
+
+       set_last_result(ret);
+       if (ret != NOTIFICATION_ERROR_NONE) {
+               notification_free(noti);
+               return NULL;
+       }
+
+       return noti;
+}
+
+EXPORT_API int notification_set_default_button(notification_h noti, notification_button_index_e index)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       if (index < 0 || index > NOTIFICATION_BUTTON_6)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->default_button_index = index;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_default_button(notification_h noti, notification_button_index_e *index)
+{
+       if (noti == NULL || index == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *index = noti->default_button_index;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_ongoing_value_type(notification_h noti, notification_ongoing_value_type_e *type)
+{
+       if (noti == NULL || type == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *type = noti->ongoing_value_type;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_set_ongoing_value_type(notification_h noti, notification_ongoing_value_type_e type)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       if (type < NOTIFICATION_ONGOING_VALUE_TYPE_PERCENT || type > NOTIFICATION_ONGOING_VALUE_TYPE_TIME)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->ongoing_value_type = type;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_ongoing_time(notification_h noti, int *current, int *duration)
+{
+       if (noti == NULL || current == NULL || duration == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *current = noti->ongoing_current;
+       *duration = noti->ongoing_duration;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_set_ongoing_time(notification_h noti, int current, int duration)
+{
+       if (noti == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       if (current < 0 || duration < 0 || current > duration)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->ongoing_current = current;
+       noti->ongoing_duration = duration;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_hide_timeout(notification_h noti, int *timeout)
+{
+       if (noti == NULL || timeout == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *timeout = noti->timeout;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_set_hide_timeout(notification_h noti, int timeout)
+{
+       if (noti == NULL || timeout < 0)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       noti->timeout = timeout;
+
+       return NOTIFICATION_ERROR_NONE;
+}
+
+EXPORT_API int notification_get_text_input_max_length(notification_h noti, int *text_input_max_length)
+{
+       if (noti == NULL || text_input_max_length == NULL)
+               return NOTIFICATION_ERROR_INVALID_PARAMETER;
+
+       *text_input_max_length = noti->text_input_max_length;
+
+       return NOTIFICATION_ERROR_NONE;
+}