LOGD("consumer_handle : %p", consumer_handle);
ret = sticker_dbus_shutdown(consumer_handle->gdbus_connection, &consumer_handle->server_watcher_id,
- &consumer_handle->server_monitor_id, &consumer_handle->monitor_id);
+ &consumer_handle->server_monitor_id, &consumer_handle->monitor_id, STICKER_CLIENT_LIB_CONSUMER);
if (ret != STICKER_ERROR_NONE) {
LOGE("Failed to finalize dbus : %d", ret);
free(consumer_handle);
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;
+}
+
+EXPORT_API int sticker_consumer_add_recent_data(sticker_consumer_h consumer_handle, sticker_data_h data_handle)
+{
+ CHECK_STICKER_FEATURE();
+
+ int ret;
+
+ if (!consumer_handle || !data_handle || (data_handle->sticker_info_id <= 0) || !data_handle->uri)
+ return STICKER_ERROR_INVALID_PARAMETER;
+
+ ret = sticker_dbus_insert_recent_sticker_info(consumer_handle->gdbus_connection, data_handle->sticker_info_id);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to add recent sticker information : %d", ret);
+ return STICKER_ERROR_OPERATION_FAILED;
+ }
+
+ return STICKER_ERROR_NONE;
+}
+
+EXPORT_API int sticker_consumer_get_recent_data_list(sticker_consumer_h consumer_handle, int count, int *result, sticker_consumer_data_foreach_cb callback, void *user_data)
+{
+ CHECK_STICKER_FEATURE();
+
+ int ret;
+ int info_id;
+ int sticker_count = 0;
+ GVariantIter *id_iter = NULL;
+
+ if (!consumer_handle || (count <= 0) || !result || !callback)
+ return STICKER_ERROR_INVALID_PARAMETER;
+
+ ret = sticker_dbus_get_recent_sticker_list(consumer_handle->gdbus_connection, count, &id_iter);
+ if (ret != STICKER_ERROR_NONE) {
+ LOGE("Failed to get recent sticker information : %d", ret);
+ ret = STICKER_ERROR_OPERATION_FAILED;
+ goto cleanup;
+ }
+
+ if (id_iter) {
+ while (g_variant_iter_loop (id_iter, "(i)", &info_id)) {
+ sticker_data_h sticker_data = (sticker_data_h)calloc(1, sizeof(struct sticker_data_s));
+ if (!sticker_data) {
+ ret = STICKER_ERROR_OUT_OF_MEMORY;
+ goto cleanup;
+ }
+
+ ret = sticker_dbus_get_sticker_info_by_record_id(consumer_handle->gdbus_connection, sticker_data, info_id);
+ if (ret == STICKER_ERROR_NONE) {
+ sticker_count++;
+ callback(sticker_data, user_data);
+ _free_sticker_data(sticker_data);
+ } else {
+ _free_sticker_data(sticker_data);
+ goto cleanup;
+ }
+ }
+ }
+
+ *result = sticker_count;
+
+cleanup:
+ if (id_iter)
+ g_variant_iter_free(id_iter);
+
+ return ret;
+}
+
+EXPORT_API int sticker_consumer_set_event_cb(sticker_consumer_h consumer_handle, sticker_consumer_event_cb callback, void *user_data)
+{
+ CHECK_STICKER_FEATURE();
+
+ if (!consumer_handle || !callback)
+ return STICKER_ERROR_INVALID_PARAMETER;
+
+ consumer_handle->event_cb = callback;
+ consumer_handle->event_cb_user_data = user_data;
+
+ return STICKER_ERROR_NONE;
+}
+
+EXPORT_API int sticker_consumer_unset_event_cb(sticker_consumer_h consumer_handle)
+{
+ CHECK_STICKER_FEATURE();
+
+ if (!consumer_handle)
+ return STICKER_ERROR_INVALID_PARAMETER;
+
+ consumer_handle->event_cb = NULL;
+ consumer_handle->event_cb_user_data = NULL;
+
+ return STICKER_ERROR_NONE;
}
\ No newline at end of file