return NULL;
}
+static void _free_sticker_data(sticker_data_h sticker_data)
+{
+ if (!sticker_data)
+ return;
+
+ if (sticker_data->app_id) {
+ free(sticker_data->app_id);
+ sticker_data->app_id = NULL;
+ }
+
+ if (sticker_data->uri) {
+ free(sticker_data->uri);
+ sticker_data->uri = NULL;
+ }
+
+ if (sticker_data->thumbnail) {
+ free(sticker_data->thumbnail);
+ sticker_data->thumbnail = NULL;
+ }
+
+ if (sticker_data->keyword) {
+ g_list_free_full(sticker_data->keyword, free);
+ sticker_data->keyword = NULL;
+ }
+
+ if (sticker_data->group) {
+ free(sticker_data->group);
+ sticker_data->group = NULL;
+ }
+
+ if (sticker_data->description) {
+ free(sticker_data->description);
+ sticker_data->description = NULL;
+ }
+
+ if (sticker_data->date) {
+ free(sticker_data->date);
+ sticker_data->date = NULL;
+ }
+
+ free(sticker_data);
+ sticker_data = NULL;
+}
+
EXPORT_API int sticker_data_create(sticker_data_h *data_handle)
{
CHECK_STICKER_FEATURE();
return STICKER_ERROR_NONE;
}
+EXPORT_API int sticker_data_get_handle(const char* uri, sticker_data_h *data_handle)
+{
+ CHECK_STICKER_FEATURE();
+
+ int ret;
+ GDBusConnection *gdbus_connection = NULL;
+ int server_watcher_id = 0;
+ int monitor_id = 0;
+ int server_monitor_id = 0;
+ int is_exist = 0;
+
+ if (!uri || uri[0] == '\0' || !data_handle)
+ return STICKER_ERROR_INVALID_PARAMETER;
+
+ struct sticker_data_s *handle = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
+ if (!handle)
+ return STICKER_ERROR_OUT_OF_MEMORY;
+
+ ret = sticker_dbus_init(&gdbus_connection, &server_watcher_id, &monitor_id, &server_monitor_id, STICKER_CLIENT_LIB_PROVIDER, NULL);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to initialize dbus : %d", ret);
+ ret = STICKER_ERROR_OPERATION_FAILED;
+ goto cleanup;
+ }
+
+ ret = sticker_dbus_check_file_exists(gdbus_connection, uri, &is_exist);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to check file exists : %d", ret);
+ ret = STICKER_ERROR_OPERATION_FAILED;
+ goto cleanup;
+ }
+
+ if (!is_exist) {
+ LOGE("Sticker does not exist. URI : %s", uri);
+ ret = STICKER_ERROR_NO_SUCH_FILE;
+ goto cleanup;
+ }
+
+ ret = sticker_dbus_get_sticker_info_by_uri(gdbus_connection, handle, uri);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to get sticker information : %d", ret);
+ goto cleanup;
+ }
+
+ *data_handle = handle;
+
+ ret = sticker_dbus_shutdown(gdbus_connection, &server_watcher_id, &server_monitor_id, &monitor_id, STICKER_CLIENT_LIB_PROVIDER);
+ if (ret != STICKER_ERROR_NONE)
+ LOGE("Failed to finalize dbus : %d", ret);
+
+ g_object_unref(gdbus_connection);
+
+ return STICKER_ERROR_NONE;
+
+cleanup:
+ if (handle)
+ _free_sticker_data(handle);
+
+ if (gdbus_connection) {
+ ret = sticker_dbus_shutdown(gdbus_connection, &server_watcher_id, &server_monitor_id, &monitor_id, STICKER_CLIENT_LIB_PROVIDER);
+ if (ret != STICKER_ERROR_NONE)
+ LOGE("Failed to finalize dbus : %d", ret);
+
+ g_object_unref(gdbus_connection);
+ }
+
+ return ret;
+}
+
EXPORT_API int sticker_data_get_app_id(sticker_data_h data_handle, char **app_id)
{
CHECK_STICKER_FEATURE();
while (g_variant_iter_loop (info_iter, "{iv}", &key, &value)) {
switch(key) {
+ case STICKER_DATA_TYPE_INFO_ID:
+ sticker_data->sticker_info_id = g_variant_get_int32(value);
+ break;
case STICKER_DATA_TYPE_APP_ID:
sticker_data->app_id = g_variant_dup_string(value, NULL);
break;
g_object_unref(reply);
return ret;
+}
+
+int sticker_dbus_get_sticker_info_by_uri(GDBusConnection *gdbus_connection, sticker_data_h sticker_data, const char *uri)
+{
+ int ret;
+ GDBusMessage *reply = NULL;
+ GVariant *reply_body = NULL;
+ GVariantIter *info_iter = NULL;
+ GVariantIter *keyword_iter = NULL;
+
+ ret = _send_sync_message(gdbus_connection, g_variant_new("(s)", uri), &reply, "get_sticker_info_by_uri");
+ if (ret == STICKER_CLIENT_ERROR_NONE) {
+ reply_body = g_dbus_message_get_body(reply);
+ g_variant_get(reply_body, "(a{iv}a(s))", &info_iter, &keyword_iter);
+ _get_sticker_info_from_gvariant(info_iter, keyword_iter, sticker_data);
+
+ if (reply_body)
+ g_variant_unref(reply_body);
+
+ if (info_iter)
+ g_variant_iter_free(info_iter);
+
+ if (keyword_iter)
+ g_variant_iter_free(keyword_iter);
+ }
+
+ if (reply)
+ g_object_unref(reply);
+
+ return ret;
}
\ No newline at end of file
int sticker_dbus_check_file_exists(GDBusConnection *gdbus_connection, const char *uri, int *result);
int sticker_dbus_insert_recent_sticker_info(GDBusConnection *gdbus_connection, int record_id);
int sticker_dbus_get_recent_sticker_list(GDBusConnection *gdbus_connection, int count, GVariantIter **id_iter);
+int sticker_dbus_get_sticker_info_by_uri(GDBusConnection *gdbus_connection, sticker_data_h sticker_data, const char *uri);
#ifdef __cplusplus
}
int sticker_data_clone(sticker_data_h origin_handle, sticker_data_h *target_handle);
/**
+ * @brief Gets the sticker data handle for the given URI.
+ * @since_tizen 5.5
+ * @remarks If the function succeeds, @a data_handle must be released with sticker_data_destroy().
+ * @param[in] uri The URI of the sticker data handle
+ * @param[out] data_handle The sticker data handle for the given sticker URI
+ * @return 0 on success, otherwise a negative error value
+ * @retval #STICKER_ERROR_NONE Successful
+ * @retval #STICKER_ERROR_NOT_SUPPORTED Not supported
+ * @retval #STICKER_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #STICKER_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #STICKER_ERROR_OPERATION_FAILED Operation failed
+ * @retval #STICKER_ERROR_NO_SUCH_FILE A sticker with given @a uri does not exist
+ * @see sticker_data_destroy()
+ */
+int sticker_data_get_handle(const char* uri, sticker_data_h *data_handle);
+
+/**
* @brief Gets the name of the sticker provider application from sticker data handle.
* @since_tizen 5.5
* @remarks @a app_id must be released using free().
ret = stickerd_get_recent_sticker_info(parameters, &reply_body);
} else if (g_strcmp0(method_name, "send_update_event") == 0) {
ret = stickerd_send_update_event(parameters, &reply_body);
+ } else if (g_strcmp0(method_name, "get_sticker_info_by_uri") == 0) {
+ ret = stickerd_get_sticker_info_by_uri(parameters, &reply_body);
}
if (ret == STICKERD_SERVER_ERROR_NONE) {
" <method name='send_update_event'>"
" <arg type='i' name='record_id' direction='in'/>"
" </method>"
+
+ " <method name='get_sticker_info_by_uri'>"
+ " <arg type='s' name='uri' direction='in'/>"
+ " <arg type='a{iv}' name='sticker_info' direction='out'/>"
+ " <arg type='a(s)' name='keyword_list' direction='out'/>"
+ " </method>"
" </interface>"
" </node>";
}
return ret;
+}
+
+int stickerd_get_sticker_info_by_uri(GVariant *parameters, GVariant **reply_body)
+{
+ int ret;
+ char *uri = NULL;
+ GVariantBuilder *info_builder;
+ GVariantBuilder *keyword_builder;
+
+ g_variant_get(parameters, "(&s)", &uri);
+
+ sticker_info_db *sticker_info = (sticker_info_db *)calloc(1, sizeof(sticker_info_db));
+
+ if (!sticker_info)
+ return STICKERD_SERVER_ERROR_OUT_OF_MEMORY;
+
+ ret = stickerd_db_get_sticker_info_by_uri(uri, sticker_info);
+ if (ret != STICKERD_SERVER_ERROR_NONE) {
+ LOGE("Failed to get sticker info");
+ ret = STICKERD_SERVER_ERROR_OPERATION_FAILED;
+ goto cleanup;
+ }
+
+ info_builder = g_variant_builder_new(G_VARIANT_TYPE("a{iv}"));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_INFO_ID, g_variant_new_int32(sticker_info->record_id));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_APP_ID, g_variant_new_string((const gchar *)sticker_info->app_id));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_URI_TYPE, g_variant_new_int32(sticker_info->type));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_URI, g_variant_new_string((const gchar *)sticker_info->uri));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_THUMBNAIL, g_variant_new_string((const gchar *)sticker_info->thumbnail));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_DESCRIPTION, g_variant_new_string((const gchar *)sticker_info->description));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_GROUP, g_variant_new_string((const gchar *)sticker_info->group));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_DATE, g_variant_new_string((const gchar *)sticker_info->date));
+ g_variant_builder_add(info_builder, "{iv}", STICKER_DATA_TYPE_DISP_TYPE, g_variant_new_int32(sticker_info->display_type));
+
+ keyword_builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+ g_list_foreach(sticker_info->keyword, (GFunc) _set_keyword_builder, keyword_builder);
+
+ *reply_body = g_variant_new("(a{iv}a(s))", info_builder, keyword_builder);
+ g_variant_builder_unref(info_builder);
+ g_variant_builder_unref(keyword_builder);
+
+ if (*reply_body == NULL) {
+ LOGE("Failed to create reply_body");
+ ret = STICKERD_SERVER_ERROR_OPERATION_FAILED;
+ }
+
+cleanup:
+ if (sticker_info) {
+ _free_sticker_data(sticker_info);
+ sticker_info = NULL;
+ }
+
+ return ret;
}
\ No newline at end of file
int stickerd_insert_recent_sticker_info(GVariant *parameters, GVariant **reply_body);
int stickerd_get_recent_sticker_info(GVariant *parameters, GVariant **reply_body);
int stickerd_send_update_event(GVariant *parameters, GVariant **reply_body);
+int stickerd_get_sticker_info_by_uri(GVariant *parameters, GVariant **reply_body);
#ifdef __cplusplus
}
int stickerd_db_get_sticker_info_by_uri(char *uri, sticker_info_db *sticker_info)
{
int ret;
- int record_id;
sqlite3 *db = NULL;
sqlite3_stmt *stmt = NULL;
goto cleanup;
}
- record_id = sticker_info->display_type = sqlite3_column_int(stmt, 0);
+ sticker_info->record_id = sqlite3_column_int(stmt, 0);
const unsigned char *tmp_app_id = sqlite3_column_text(stmt, 1);
if (tmp_app_id)
goto cleanup;
}
- sqlite3_bind_int(stmt, 1, record_id);
+ sqlite3_bind_int(stmt, 1, sticker_info->record_id);
while (sqlite3_step(stmt) == SQLITE_ROW) {
const unsigned char *keyword = sqlite3_column_text(stmt, 0);
} sticker_info_db_type;
typedef struct {
+ int record_id;
char *app_id;
int type;
char *uri;