g_object_unref(reply);
return ret;
+}
+
+int sticker_dbus_get_group_list_by_display_type(GDBusConnection *gdbus_connection, const char *app_id, sticker_data_display_type_e type, GList **group_list)
+{
+ int ret;
+ GDBusMessage *reply = NULL;
+ GVariantIter *iter = NULL;
+ GVariant *reply_body = NULL;
+ char *group = NULL;
+
+ if (group_list == NULL) {
+ LOGE("group_list is invalid");
+ return STICKER_CLIENT_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = _send_sync_message(gdbus_connection, g_variant_new("(si)", app_id, (int)type), &reply, "get_group_list_by_disp_type");
+ if (ret == STICKER_CLIENT_ERROR_NONE) {
+ reply_body = g_dbus_message_get_body(reply);
+ g_variant_get(reply_body, "(a(s))", &iter);
+
+ if (!iter) {
+ LOGD("failed to get iter");
+ return STICKER_CLIENT_ERROR_OPERATION_FAILED;
+ }
+
+ while (g_variant_iter_loop (iter, "(s)", &group)) {
+ *group_list = g_list_append(*group_list, strdup((const char *)group));
+ }
+
+ g_variant_iter_free(iter);
+ }
+
+ if (reply_body)
+ g_variant_unref(reply_body);
+
+ if (reply)
+ g_object_unref(reply);
+
+ return ret;
}
\ No newline at end of file
int sticker_dbus_get_sticker_info_by_group(GDBusConnection *gdbus_connection, const char *app_id, const char *group, int offset, int count, GVariantIter **id_iter);
int sticker_dbus_get_sticker_info_by_keyword(GDBusConnection *gdbus_connection, const char *app_id, const char *keyword, int offset, int count, GVariantIter **id_iter);
int sticker_dbus_get_sticker_info_by_display_type(GDBusConnection *gdbus_connection, const char *app_id, sticker_data_display_type_e type, int offset, int count, GVariantIter **id_iter);
+int sticker_dbus_get_group_list_by_display_type(GDBusConnection *gdbus_connection, const char *app_id, sticker_data_display_type_e type, GList **group_list);
#ifdef __cplusplus
}
g_variant_iter_free(id_iter);
return ret;
+}
+
+EXPORT_API int sticker_consumer_group_list_foreach_by_display_type(sticker_consumer_h consumer_handle, sticker_data_display_type_e type, sticker_consumer_group_list_foreach_cb callback, void *user_data)
+{
+ CHECK_STICKER_FEATURE();
+
+ int ret;
+ GList *list = NULL;
+
+ if (!consumer_handle || (type < 1) || !callback)
+ return STICKER_ERROR_INVALID_PARAMETER;
+
+ ret = sticker_dbus_get_group_list_by_display_type(consumer_handle->gdbus_connection, consumer_handle->app_id, type, &list);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to get group list : %d", ret);
+ ret = STICKER_ERROR_OPERATION_FAILED;
+ goto cleanup;
+ }
+
+ for(GList *tmp = g_list_first(list); tmp != NULL; tmp=tmp->next) {
+ callback((const char *)tmp->data, user_data);
+ }
+
+cleanup:
+ if (list)
+ g_list_free_full(list, free);
+
+ return ret;
}
\ No newline at end of file
int sticker_consumer_data_foreach_by_display_type(sticker_consumer_h consumer_handle, int offset, int count, int *result, sticker_data_display_type_e type, sticker_consumer_data_foreach_cb callback, void *user_data);
/**
+ * @brief Retrieves all group name in the sticker database using display type.
+ * @since_tizen 5.5
+ * @param[in] consumer_handle The sticker consumer handle
+ * @param[in] type The display type of the sticker for getting sticker data
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @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_OPERATION_FAILED Operation failed
+ * @post This function invokes sticker_consumer_group_list_foreach_cb() repeatedly for getting data.
+ * @see sticker_consumer_group_list_foreach_cb()
+ */
+int sticker_consumer_group_list_foreach_by_display_type(sticker_consumer_h consumer_handle, sticker_data_display_type_e type, sticker_consumer_group_list_foreach_cb callback, void *user_data);
+
+/**
* @}
*/
ret = stickerd_get_sticker_info_by_keyword(parameters, &reply_body);
} else if (g_strcmp0(method_name, "get_sticker_info_by_disp_type") == 0) {
ret = stickerd_get_sticker_info_by_display_type(parameters, &reply_body);
+ } else if (g_strcmp0(method_name, "get_group_list_by_disp_type") == 0) {
+ ret = stickerd_get_group_list_by_disp_type(parameters, &reply_body);
}
if (ret == STICKERD_SERVER_ERROR_NONE) {
" <arg type='i' name='count' direction='in'/>"
" <arg type='a(i)' name='id_list' direction='out'/>"
" </method>"
+
+ " <method name='get_group_list_by_disp_type'>"
+ " <arg type='s' name='app_id' direction='in'/>"
+ " <arg type='i' name='disp_type' direction='in'/>"
+ " <arg type='a(s)' name='group_list' direction='out'/>"
+ " </method>"
" </interface>"
" </node>";
g_variant_builder_unref(id_builder);
return ret;
+}
+
+int stickerd_get_group_list_by_disp_type(GVariant *parameters, GVariant **reply_body)
+{
+ int ret;
+ GVariantBuilder *builder = NULL;
+ char *app_id = NULL;
+ int disp_type;
+
+ g_variant_get(parameters, "(&si)", &app_id, &disp_type);
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+ ret = stickerd_db_get_group_list_by_display_type(builder, app_id, disp_type);
+ if (ret != STICKERD_SERVER_ERROR_NONE) {
+ LOGE("Failed to get sticker group list");
+ g_variant_builder_unref(builder);
+ return STICKERD_SERVER_ERROR_OPERATION_FAILED;
+ }
+
+ *reply_body = g_variant_new("(a(s))", builder);
+ g_variant_builder_unref(builder);
+
+ if (*reply_body == NULL) {
+ LOGE("Failed to create reply_body");
+ return STICKERD_SERVER_ERROR_OPERATION_FAILED;
+ }
+
+ return ret;
}
\ No newline at end of file
int stickerd_get_sticker_info_by_group(GVariant *parameters, GVariant **reply_body);
int stickerd_get_sticker_info_by_keyword(GVariant *parameters, GVariant **reply_body);
int stickerd_get_sticker_info_by_display_type(GVariant *parameters, GVariant **reply_body);
+int stickerd_get_group_list_by_disp_type(GVariant *parameters, GVariant **reply_body);
#ifdef __cplusplus
}
#define STICKER_DB_GET_RECORD_ID_BY_GROUP "SELECT sticker_info_id from sticker_info WHERE group_name = ? AND app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?)) LIMIT ?, ?"
#define STICKER_DB_GET_RECORD_ID_BY_KEYWORD "SELECT sticker_info_id FROM sticker_keyword_info WHERE keyword = ? INTERSECT SELECT sticker_info_id from sticker_info WHERE app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?)) LIMIT ?, ?"
#define STICKER_DB_GET_RECORD_ID_BY_DISP_TYPE "SELECT sticker_info_id FROM sticker_info WHERE display_type = ? AND app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?)) LIMIT ?, ?"
+#define STICKER_DB_GET_GROUP_LIST_BY_DISP_TYPE "SELECT DISTINCT group_name FROM sticker_info WHERE display_type = ? AND app_id NOT IN (SELECT DISTINCT provider_id FROM sticker_whitelist_info WHERE provider_id NOT IN (SELECT provider_id FROM sticker_whitelist_info WHERE consumer_id = ?))"
typedef enum
{
sqlite3_close(db);
return STICKERD_SERVER_ERROR_DB_FAILED;
+}
+
+int stickerd_db_get_group_list_by_display_type(GVariantBuilder *builder, char *app_id, int disp_type)
+{
+ int ret;
+ sqlite3 *db = NULL;
+ sqlite3_stmt *stmt = NULL;
+
+ db = _db_open();
+ if (!db)
+ return STICKERD_SERVER_ERROR_DB_FAILED;
+
+ ret = sqlite3_prepare_v2(db, STICKER_DB_GET_GROUP_LIST_BY_DISP_TYPE, -1, &stmt, NULL);
+ if (ret != SQLITE_OK) {
+ LOGE("fail to get group list : %s", sqlite3_errmsg(db));
+ goto cleanup;
+ }
+
+ sqlite3_bind_int(stmt, 1, disp_type);
+ sqlite3_bind_text(stmt, 2, app_id, -1, SQLITE_TRANSIENT);
+
+ while (sqlite3_step(stmt) == SQLITE_ROW) {
+ const unsigned char *group = sqlite3_column_text(stmt, 0);
+ if (group)
+ g_variant_builder_add(builder, "(s)", strdup((const char *)group));
+ }
+
+ sqlite3_finalize(stmt);
+ sqlite3_close(db);
+
+ return STICKERD_SERVER_ERROR_NONE;
+
+cleanup:
+ sqlite3_finalize(stmt);
+ sqlite3_close(db);
+
+ return STICKERD_SERVER_ERROR_DB_FAILED;
}
\ No newline at end of file
int stickerd_db_get_keyword_list(GVariantBuilder *builder, char *app_id);
int stickerd_db_get_sticker_count(int *count, char *app_id);
int stickerd_db_get_record_id(sticker_info_db_type type, GList **id_list, void *data, char *app_id, int offset, int count);
+int stickerd_db_get_group_list_by_display_type(GVariantBuilder *builder, char *app_id, int disp_type);
#ifdef __cplusplus
}