[rygel-gst-0-10-plugins] Cleanup the RygelMediaExportDBContainer.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-gst-0-10-plugins] Cleanup the RygelMediaExportDBContainer.
- Date: Fri, 18 Jan 2013 12:14:37 +0000 (UTC)
commit b5b403a5736c11302ea29084a9b2a438c7d147df
Author: Krzesimir Nowak <krnowak openismus com>
Date: Fri Jan 18 13:14:18 2013 +0100
Cleanup the RygelMediaExportDBContainer.
src/media-export/rygel-media-export-db-container.c | 983 ++++++++------------
src/media-export/rygel-media-export-db-container.h | 20 +-
.../rygel-media-export-leaf-query-container.c | 6 +-
.../rygel-media-export-node-query-container.c | 6 +-
.../rygel-media-export-query-container.c | 2 +-
.../rygel-media-export-root-container.c | 30 +-
.../rygel-media-export-writable-db-container.c | 4 +-
7 files changed, 416 insertions(+), 635 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-db-container.c b/src/media-export/rygel-media-export-db-container.c
index dc06d40..0f97206 100644
--- a/src/media-export/rygel-media-export-db-container.c
+++ b/src/media-export/rygel-media-export-db-container.c
@@ -24,102 +24,28 @@
#include "rygel-media-export-db-container.h"
#include "rygel-media-export-database.h"
-static void rygel_media_export_db_container_rygel_searchable_container_interface_init (RygelSearchableContainerIface * iface);
+static void
+rygel_media_export_db_container_rygel_searchable_container_interface_init (RygelSearchableContainerIface *iface);
G_DEFINE_TYPE_WITH_CODE (RygelMediaExportDBContainer,
rygel_media_export_db_container,
RYGEL_TYPE_MEDIA_CONTAINER,
- G_IMPLEMENT_INTERFACE (RYGEL_TYPE_DATA_SOURCE,
+ G_IMPLEMENT_INTERFACE (RYGEL_TYPE_SEARCHABLE_CONTAINER,
rygel_media_export_db_container_rygel_searchable_container_interface_init))
-typedef struct _RygelMediaExportDbContainerGetChildrenData RygelMediaExportDbContainerGetChildrenData;
-typedef struct _RygelMediaExportDbContainerSearchData RygelMediaExportDbContainerSearchData;
-typedef struct _RygelMediaExportDbContainerFindObjectData RygelMediaExportDbContainerFindObjectData;
-
+typedef struct _RygelMediaExportDBContainerSearchData RygelMediaExportDBContainerSearchData;
struct _RygelMediaExportDBContainerPrivate {
GeeArrayList *search_classes;
RygelMediaExportMediaCache *media_db;
};
-struct _RygelMediaExportDbContainerGetChildrenData {
- int _state_;
- GObject* _source_object_;
- GAsyncResult* _res_;
- GSimpleAsyncResult* _async_result;
- RygelMediaExportDBContainer* self;
- guint offset;
- guint max_count;
- gchar* sort_criteria;
- GCancellable* cancellable;
- RygelMediaObjects* result;
- RygelMediaExportMediaCache* _tmp0_;
- const gchar* _tmp1_;
- guint _tmp2_;
- guint _tmp3_;
- RygelMediaObjects* _tmp4_;
- RygelMediaObjects* _tmp5_;
- GError * _inner_error_;
-};
-
-struct _RygelMediaExportDbContainerSearchData {
- int _state_;
- GObject* _source_object_;
- GAsyncResult* _res_;
- GSimpleAsyncResult* _async_result;
- RygelMediaExportDBContainer* self;
- RygelSearchExpression* expression;
- guint offset;
- guint max_count;
- guint total_matches;
- gchar* sort_criteria;
- GCancellable* cancellable;
- RygelMediaObjects* result;
- RygelMediaObjects* children;
- RygelMediaExportMediaCache* _tmp0_;
- RygelSearchExpression* _tmp1_;
- const gchar* _tmp2_;
- const gchar* _tmp3_;
- const gchar* _tmp4_;
- guint _tmp5_;
- guint _tmp6_;
- guint _tmp7_;
- RygelMediaObjects* _tmp8_;
- RygelMediaObjects* _tmp9_;
- GError* _error_;
- GError* _tmp10_;
- RygelSearchExpression* _tmp11_;
- guint _tmp12_;
- guint _tmp13_;
- const gchar* _tmp14_;
- GCancellable* _tmp15_;
- guint _tmp16_;
- RygelMediaObjects* _tmp17_;
- RygelMediaObjects* _tmp18_;
- GError* _tmp19_;
- GError* _tmp20_;
- GError * _inner_error_;
-};
-
-struct _RygelMediaExportDbContainerFindObjectData {
- int _state_;
- GObject* _source_object_;
- GAsyncResult* _res_;
- GSimpleAsyncResult* _async_result;
- RygelMediaExportDBContainer* self;
- gchar* id;
- GCancellable* cancellable;
- RygelMediaObject* result;
- RygelMediaExportMediaCache* _tmp0_;
- const gchar* _tmp1_;
- RygelMediaObject* _tmp2_;
- RygelMediaObject* _tmp3_;
- GError * _inner_error_;
+struct _RygelMediaExportDBContainerSearchData {
+ RygelMediaObjects *result;
+ guint total_matches;
+ GSimpleAsyncResult *async_result;
};
-
-static RygelSearchableContainerIface* rygel_media_export_db_container_rygel_searchable_container_parent_iface = NULL;
-
#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), \
RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, \
@@ -127,591 +53,462 @@ static RygelSearchableContainerIface* rygel_media_export_db_container_rygel_sear
enum {
RYGEL_MEDIA_EXPORT_DB_CONTAINER_DUMMY_PROPERTY,
- RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES,
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_MEDIA_DB
};
-RygelMediaExportDBContainer* rygel_media_export_db_container_construct (GType object_type, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title);
-
-static void __lambda2_ (RygelMediaExportDBContainer* self);
-static void rygel_media_export_db_container_count_children (RygelMediaExportDBContainer* self);
-static void ___lambda2__rygel_media_container_container_updated (RygelMediaContainer* _sender, RygelMediaContainer* container, RygelMediaObject* object, RygelObjectEventType event_type, gboolean sub_tree_update, gpointer self);
-
-static void rygel_media_export_db_container_real_get_children_data_free (gpointer _data);
-static void rygel_media_export_db_container_real_get_children (RygelMediaContainer* base, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
-static gboolean rygel_media_export_db_container_real_get_children_co (RygelMediaExportDbContainerGetChildrenData* _data_);
-static void rygel_media_export_db_container_real_search_data_free (gpointer _data);
-static void rygel_media_export_db_container_real_search (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
-static gboolean rygel_media_export_db_container_real_search_co (RygelMediaExportDbContainerSearchData* _data_);
-static void rygel_media_export_db_container_search_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
-static void rygel_media_export_db_container_real_find_object_data_free (gpointer _data);
-static void rygel_media_export_db_container_real_find_object (RygelMediaContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
-static gboolean rygel_media_export_db_container_real_find_object_co (RygelMediaExportDbContainerFindObjectData* _data_);
-static void rygel_media_export_db_container_finalize (GObject* obj);
-static void _vala_rygel_media_export_db_container_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
-static void _vala_rygel_media_export_db_container_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
-
-static void __lambda2_ (RygelMediaExportDBContainer* self) {
- rygel_media_export_db_container_count_children (self);
-}
-
-
-static void ___lambda2__rygel_media_container_container_updated (RygelMediaContainer* _sender, RygelMediaContainer* container, RygelMediaObject* object, RygelObjectEventType event_type, gboolean sub_tree_update, gpointer self) {
- __lambda2_ (self);
-}
-
-
-RygelMediaExportDBContainer* rygel_media_export_db_container_construct (GType object_type, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title) {
- RygelMediaExportDBContainer * self = NULL;
- const gchar* _tmp0_;
- const gchar* _tmp1_;
- RygelMediaExportMediaCache* _tmp2_;
- RygelMediaExportMediaCache* _tmp3_;
- GeeArrayList* _tmp4_;
- GeeArrayList* _tmp5_;
- g_return_val_if_fail (media_db != NULL, NULL);
- g_return_val_if_fail (id != NULL, NULL);
- g_return_val_if_fail (title != NULL, NULL);
- _tmp0_ = id;
- _tmp1_ = title;
- self = (RygelMediaExportDBContainer*) rygel_media_container_construct (object_type, _tmp0_, NULL, _tmp1_, 0);
- _tmp2_ = media_db;
- _tmp3_ = g_object_ref (_tmp2_);
- g_object_unref (self->priv->media_db);
- self->priv->media_db = _tmp3_;
- _tmp4_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
- _tmp5_ = _tmp4_;
- rygel_searchable_container_set_search_classes ((RygelSearchableContainer*) self, _tmp5_);
- g_object_unref (_tmp5_);
- g_signal_connect_object ((RygelMediaContainer*) self, "container-updated", (GCallback) ___lambda2__rygel_media_container_container_updated, self, 0);
- rygel_media_export_db_container_count_children (self);
- return self;
-}
-
-
-RygelMediaExportDBContainer* rygel_media_export_db_container_new (RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title) {
- return rygel_media_export_db_container_construct (RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, media_db, id, title);
-}
-
+static void
+rygel_media_export_db_container_count_children (RygelMediaExportDBContainer* self) {
+ GError *inner_error = NULL;
+ gint count;
+ gint id;
-static void rygel_media_export_db_container_count_children (RygelMediaExportDBContainer* self) {
- GError * _inner_error_ = NULL;
- g_return_if_fail (self != NULL);
- {
- RygelMediaExportMediaCache* _tmp0_;
- const gchar* _tmp1_;
- const gchar* _tmp2_;
- gint _tmp3_ = 0;
- gint _tmp4_;
- _tmp0_ = self->priv->media_db;
- _tmp1_ = rygel_media_object_get_id ((RygelMediaObject*) self);
- _tmp2_ = _tmp1_;
- _tmp3_ = rygel_media_export_media_cache_get_child_count (_tmp0_, _tmp2_, &_inner_error_);
- _tmp4_ = _tmp3_;
- if (_inner_error_ != NULL) {
- if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
- goto __catch3_rygel_media_export_database_error;
- }
- g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
- ((RygelMediaContainer*) self)->child_count = _tmp4_;
- }
- goto __finally3;
- __catch3_rygel_media_export_database_error:
- {
- GError* _error_ = NULL;
- GError* _tmp5_;
- const gchar* _tmp6_;
- _error_ = _inner_error_;
- _inner_error_ = NULL;
- _tmp5_ = _error_;
- _tmp6_ = _tmp5_->message;
- g_debug ("rygel-media-export-db-container.vala:43: Could not get child count fro" \
-"m database: %s", _tmp6_);
- ((RygelMediaContainer*) self)->child_count = 0;
- g_error_free (_error_);
- }
- __finally3:
- if (_inner_error_ != NULL) {
- g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
- g_clear_error (&_inner_error_);
- return;
- }
-}
+ g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER (self));
+ id = rygel_media_object_get_id (RYGEL_MEDIA_OBJECT (self));
+ count = rygel_media_export_media_cache_get_child_count (self->priv->media_db,
+ id,
+ &inner_error);
-static void rygel_media_export_db_container_real_get_children_data_free (gpointer _data) {
- RygelMediaExportDbContainerGetChildrenData* _data_;
- _data_ = _data;
- g_free (_data_->sort_criteria);
- g_object_unref (_data_->cancellable);
- g_object_unref (_data_->result);
- g_object_unref (_data_->self);
- g_slice_free (RygelMediaExportDbContainerGetChildrenData, _data_);
+ if (inner_error) {
+ g_debug ("Could not get child count from database: %s", inner_error->message);
+ count = 0;
+ g_error_free (inner_error);
+ }
+ rygel_media_object_set_child_count (RYGEL_MEDIA_CONTAINER (self), count);
}
+static void
+on_media_container_updated (RygelMediaContainer *sender,
+ RygelMediaContainer *container,
+ RygelMediaObject *object,
+ RygelObjectEventType event_type,
+ gboolean sub_tree_update,
+ gpointer user_data) {
+ RygelMediaExportDBContainer *self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (user_data);
-static void rygel_media_export_db_container_real_get_children (RygelMediaContainer* base, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
- RygelMediaExportDBContainer * self;
- RygelMediaExportDbContainerGetChildrenData* _data_;
- RygelMediaExportDBContainer* _tmp0_;
- guint _tmp1_;
- guint _tmp2_;
- const gchar* _tmp3_;
- gchar* _tmp4_;
- GCancellable* _tmp5_;
- GCancellable* _tmp6_;
- self = (RygelMediaExportDBContainer*) base;
- _data_ = g_slice_new0 (RygelMediaExportDbContainerGetChildrenData);
- _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_db_container_real_get_children);
- g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_db_container_real_get_children_data_free);
- _tmp0_ = g_object_ref (self);
- _data_->self = _tmp0_;
- _tmp1_ = offset;
- _data_->offset = _tmp1_;
- _tmp2_ = max_count;
- _data_->max_count = _tmp2_;
- _tmp3_ = sort_criteria;
- _tmp4_ = g_strdup (_tmp3_);
- g_free (_data_->sort_criteria);
- _data_->sort_criteria = _tmp4_;
- _tmp5_ = cancellable;
- _tmp6_ = g_object_ref (_tmp5_);
- g_object_unref (_data_->cancellable);
- _data_->cancellable = _tmp6_;
- rygel_media_export_db_container_real_get_children_co (_data_);
+ rygel_media_export_db_container_count_children (self);
}
-
-static RygelMediaObjects* rygel_media_export_db_container_real_get_children_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
- RygelMediaObjects* result;
- RygelMediaExportDbContainerGetChildrenData* _data_;
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
- return NULL;
- }
- _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
- result = _data_->result;
- _data_->result = NULL;
- return result;
+static void
+rygel_media_export_db_container_constructed (GObject *object)
+{
+ RygelMediaExportDBContainer *self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (object);
+ GeeArrayList *classes = gee_array_list_new (G_TYPE_STRING,
+ (GBoxedCopyFunc) g_strdup,
+ g_free,
+ NULL,
+ NULL,
+ NULL)
+
+ rygel_searchable_container_set_search_classes (RYGEL_SEARCHABLE_CONTAINER (self),
+ classes);
+ g_object_unref (classes);
+ g_signal_connect_object (self,
+ "container-updated",
+ G_CALLBACK (on_media_container_updated),
+ self,
+ 0);
+ rygel_media_export_db_container_count_children (self);
}
-
-static gboolean rygel_media_export_db_container_real_get_children_co (RygelMediaExportDbContainerGetChildrenData* _data_) {
- switch (_data_->_state_) {
- case 0:
- goto _state_0;
- default:
- g_assert_not_reached ();
- }
- _state_0:
- _data_->_tmp0_ = _data_->self->priv->media_db;
- _data_->_tmp1_ = _data_->sort_criteria;
- _data_->_tmp2_ = _data_->offset;
- _data_->_tmp3_ = _data_->max_count;
- _data_->_tmp4_ = NULL;
- _data_->_tmp4_ = rygel_media_export_media_cache_get_children (_data_->_tmp0_, (RygelMediaContainer*) _data_->self, _data_->_tmp1_, (glong) _data_->_tmp2_, (glong) _data_->_tmp3_, &_data_->_inner_error_);
- _data_->_tmp5_ = _data_->_tmp4_;
- if (_data_->_inner_error_ != NULL) {
- g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
- g_error_free (_data_->_inner_error_);
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
- }
- _data_->result = _data_->_tmp5_;
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
+RygelMediaExportDBContainer *
+rygel_media_export_db_container_new (RygelMediaExportMediaCache *media_db,
+ const gchar *id,
+ const gchar *title) {
+ return RYGEL_MEDIA_EXPORT_DB_CONTAINER (g_object_new (RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER,
+ "id", id,
+ "parent", NULL,
+ "title", title,
+ "child-count", 0,
+ "media-db", media-db,
+ NULL));
}
+static void
+rygel_media_export_db_container_real_get_children (RygelMediaContainer *base,
+ guint offset,
+ guint max_count,
+ const gchar *sort_criteria,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data) {
+ RygelMediaExportDBContainer *self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (base);
+ GError *inner_error = NULL;
+ RygelMediaObjects *objects = rygel_media_export_media_cache_get_children (self->priv->media_db,
+ base,
+ sort_criteria,
+ offset,
+ max_count,
+ &inner_error);
+ GSimpleAsyncResult *simple;
+
+ if (inner_error) {
+ simple = g_simple_async_result_new_take_error (G_OBJECT (self),
+ callback,
+ user_data,
+ inner_error);
+ } else {
+ simple = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ rygel_media_export_db_container_real_get_children);
+ g_simple_async_result_set_op_res_gpointer (simple,
+ objects,
+ g_object_unref);
-static void rygel_media_export_db_container_real_search_data_free (gpointer _data) {
- RygelMediaExportDbContainerSearchData* _data_;
- _data_ = _data;
- rygel_search_expression_unref (_data_->expression);
- g_free (_data_->sort_criteria);
- g_object_unref (_data_->cancellable);
- g_object_unref (_data_->result);
- g_object_unref (_data_->self);
- g_slice_free (RygelMediaExportDbContainerSearchData, _data_);
+ }
+ g_simple_async_result_complete_in_idle (simple);
+ g_object_unref (simple);
}
+static RygelMediaObjects *
+rygel_media_export_db_container_real_get_children_finish (RygelMediaContainer *base,
+ GAsyncResult *res,
+ GError **error) {
+ RygelMediaObjects *result;
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
-static gpointer _rygel_search_expression_ref0 (gpointer self) {
- return self ? rygel_search_expression_ref (self) : NULL;
-}
+ if (g_simple_async_result_propagate_error (simple, error)) {
+ return NULL;
+ }
+ result = RYGEL_MEDIA_OBJECTS (g_simple_async_result_get_op_res_gpointer (simple));
-static void rygel_media_export_db_container_real_search (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
- RygelMediaExportDbContainerSearchData* _data_;
- RygelMediaExportDBContainer* _tmp0_;
- RygelSearchExpression* _tmp1_;
- RygelSearchExpression* _tmp2_;
- guint _tmp3_;
- guint _tmp4_;
- const gchar* _tmp5_;
- gchar* _tmp6_;
- GCancellable* _tmp7_;
- GCancellable* _tmp8_;
- _data_ = g_slice_new0 (RygelMediaExportDbContainerSearchData);
- _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_db_container_real_search);
- g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_db_container_real_search_data_free);
- _tmp0_ = g_object_ref (self);
- _data_->self = _tmp0_;
- _tmp1_ = expression;
- _tmp2_ = _rygel_search_expression_ref0 (_tmp1_);
- rygel_search_expression_unref (_data_->expression);
- _data_->expression = _tmp2_;
- _tmp3_ = offset;
- _data_->offset = _tmp3_;
- _tmp4_ = max_count;
- _data_->max_count = _tmp4_;
- _tmp5_ = sort_criteria;
- _tmp6_ = g_strdup (_tmp5_);
- g_free (_data_->sort_criteria);
- _data_->sort_criteria = _tmp6_;
- _tmp7_ = cancellable;
- _tmp8_ = g_object_ref (_tmp7_);
- g_object_unref (_data_->cancellable);
- _data_->cancellable = _tmp8_;
- rygel_media_export_db_container_real_search_co (_data_);
-}
-
+ if (result) {
+ g_object_ref (result);
+ }
-static RygelMediaObjects* rygel_media_export_db_container_real_search_finish (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error) {
- RygelMediaObjects* result;
- RygelMediaExportDbContainerSearchData* _data_;
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
- return NULL;
- }
- _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
- if (total_matches) {
- *total_matches = _data_->total_matches;
- }
- result = _data_->result;
- _data_->result = NULL;
- return result;
+ return result;
}
+static void
+rygel_media_export_db_container_real_search_data_free (gpointer user_data) {
+ RygelMediaExportDBContainerSearchData *data = (RygelMediaExportDBContainerSearchData *) user_data;
+ if (!data) {
+ return;
+ }
-static void rygel_media_export_db_container_search_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
- RygelMediaExportDbContainerSearchData* _data_;
- _data_ = _user_data_;
- _data_->_source_object_ = source_object;
- _data_->_res_ = _res_;
- rygel_media_export_db_container_real_search_co (_data_);
+ if (data->result) {
+ g_object_unref (data->result);
+ }
+ g_slice_free (RygelMediaExportDBContainerSearchData, data);
}
-static gboolean rygel_media_export_db_container_real_search_co (RygelMediaExportDbContainerSearchData* _data_) {
- switch (_data_->_state_) {
- case 0:
- goto _state_0;
- case 1:
- goto _state_1;
- default:
- g_assert_not_reached ();
- }
- _state_0:
- _data_->children = NULL;
- {
- _data_->_tmp0_ = _data_->self->priv->media_db;
- _data_->_tmp1_ = _data_->expression;
- _data_->_tmp2_ = rygel_media_object_get_id ((RygelMediaObject*) _data_->self);
- _data_->_tmp3_ = _data_->_tmp2_;
- _data_->_tmp4_ = _data_->sort_criteria;
- _data_->_tmp5_ = _data_->offset;
- _data_->_tmp6_ = _data_->max_count;
- _data_->_tmp7_ = 0U;
- _data_->_tmp8_ = NULL;
- _data_->_tmp8_ = rygel_media_export_media_cache_get_objects_by_search_expression (_data_->_tmp0_, _data_->_tmp1_, _data_->_tmp3_, _data_->_tmp4_, _data_->_tmp5_, _data_->_tmp6_, &_data_->_tmp7_, &_data_->_inner_error_);
- _data_->total_matches = _data_->_tmp7_;
- _data_->_tmp9_ = _data_->_tmp8_;
- if (_data_->_inner_error_ != NULL) {
- if (_data_->_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR) {
- goto __catch4_rygel_media_export_media_cache_error;
- }
- goto __finally4;
- }
- g_object_unref (_data_->children);
- _data_->children = _data_->_tmp9_;
- }
- goto __finally4;
- __catch4_rygel_media_export_media_cache_error:
- {
- _data_->_error_ = _data_->_inner_error_;
- _data_->_inner_error_ = NULL;
- _data_->_tmp10_ = _data_->_error_;
- if (g_error_matches (_data_->_tmp10_, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH)) {
- _data_->_tmp11_ = _data_->expression;
- _data_->_tmp12_ = _data_->offset;
- _data_->_tmp13_ = _data_->max_count;
- _data_->_tmp14_ = _data_->sort_criteria;
- _data_->_tmp15_ = _data_->cancellable;
- _data_->_tmp16_ = 0U;
- _data_->_state_ = 1;
- rygel_searchable_container_simple_search ((RygelSearchableContainer*) _data_->self, _data_->_tmp11_, _data_->_tmp12_, _data_->_tmp13_, _data_->_tmp14_, _data_->_tmp15_, rygel_media_export_db_container_search_ready, _data_);
- return FALSE;
- _state_1:
- _data_->_tmp17_ = NULL;
- _data_->_tmp17_ = rygel_searchable_container_simple_search_finish ((RygelSearchableContainer*) _data_->self, _data_->_res_, &_data_->_tmp16_, &_data_->_inner_error_);
- _data_->total_matches = _data_->_tmp16_;
- _data_->_tmp18_ = _data_->_tmp17_;
- if (_data_->_inner_error_ != NULL) {
- g_error_free (_data_->_error_);
- goto __finally4;
- }
- g_object_unref (_data_->children);
- _data_->children = _data_->_tmp18_;
- } else {
- _data_->_tmp19_ = _data_->_error_;
- _data_->_tmp20_ = g_error_copy (_data_->_tmp19_);
- _data_->_inner_error_ = _data_->_tmp20_;
- g_error_free (_data_->_error_);
- goto __finally4;
- }
- g_error_free (_data_->_error_);
- }
- __finally4:
- if (_data_->_inner_error_ != NULL) {
- g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
- g_error_free (_data_->_inner_error_);
- g_object_unref (_data_->children);
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
- }
- _data_->result = _data_->children;
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
- g_object_unref (_data_->children);
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
+static void
+rygel_media_export_db_container_search_ready (GObject *source_object,
+ GAsyncResult *res,
+ gpointer user_data) {
+ RygelMediaExportDBContainerSearchData *data = (RygelMediaExportDBContainerSearchData *) user_data;
+ RygelSearchableContainer *searchable = RYGEL_SEARCHABLE_CONTAINER (source_object);
+ GError *inner_error = NULL;
+ RygelMediaObjects *objects = rygel_searchable_container_simple_search_finish (searchable,
+ res,
+ &data->total_matches,
+ &inner_error);
+
+ if (inner_error) {
+ g_simple_async_result_take_error (data->async_result, inner_error);
+ } else {
+ data->result = objects;
+ }
+ g_simple_async_result_complete (data->async_result);
+ g_object_unref (data->async_result);
}
+static void
+rygel_media_export_db_container_real_search (RygelSearchableContainer *base,
+ RygelSearchExpression *expression,
+ guint offset,
+ guint max_count,
+ const gchar *sort_criteria,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data) {
+ RygelMediaExportDBContainer *self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (base);
+ gint id = rygel_media_object_get_id (RYGEL_MEDIA_OBJECT (self));
+ GError *inner_error = NULL;
+ guint total_matches = 0;
+ GSimpleAsyncResult *simple;
+ gboolean do_simple_search = FALSE;
+ RygelMediaObjects *objects = rygel_media_export_media_cache_get_objects_by_search_expression (self->priv->media_db,
+ expression,
+ id,
+ sort_criteria,
+ offset,
+ max_count,
+ &total_matches,
+ &inner_error);
+
+ if (inner_error &&
+ g_error_matches (inner_error,
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR,
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH)) {
+ do_simple_search = TRUE;
+ g_error_free (inner_error);
+ inner_error = NULL;
+ }
-void rygel_media_export_db_container_search (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
- RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS (self)->search (self, expression, offset, max_count, sort_criteria, cancellable, _callback_, _user_data_);
-}
-
+ if (inner_error) {
+ simple = g_simple_async_result_new_take_error (G_OBJECT (self),
+ callback,
+ user_data,
+ inner_error);
+ } else {
+ RygelMediaExportDBContainerSearchData *data = g_slice_new0 (RygelMediaExportDBContainerSearchData);
+
+ simple = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ rygel_media_export_db_container_real_search);
+ g_simple_async_result_set_op_res_gpointer (simple,
+ data,
+ rygel_media_export_db_container_real_search_data_free);
+
+ if (do_simple_search) {
+ data->async_result = simple;
+ rygel_searchable_container_simple_search (base,
+ expression,
+ offset,
+ max_count,
+ sort_criteria,
+ cancellable,
+ rygel_media_export_db_container_search_ready,
+ data);
+ return;
+ } else {
+ data->result = objects;
+ data->total_matches = total_matches;
+ }
+ }
-RygelMediaObjects* rygel_media_export_db_container_search_finish (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error) {
- return RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS (self)->search_finish (self, _res_, total_matches, error);
+ g_simple_async_result_complete_in_idle (simple);
+ g_object_unref (simple);
}
-
-static void rygel_media_export_db_container_real_find_object_data_free (gpointer _data) {
- RygelMediaExportDbContainerFindObjectData* _data_;
- _data_ = _data;
- g_free (_data_->id);
- g_object_unref (_data_->cancellable);
- g_object_unref (_data_->result);
- g_object_unref (_data_->self);
- g_slice_free (RygelMediaExportDbContainerFindObjectData, _data_);
+static RygelMediaObjects *
+rygel_media_export_db_container_real_search_finish (RygelSearchableContainer *base G_GNUC_UNUSED,
+ GAsyncResult *res,
+ guint *total_matches,
+ GError **error) {
+ RygelMediaObjects* result;
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
+ RygelMediaExportDBContainerSearchData* data;
+
+ if (g_simple_async_result_propagate_error (simple, error)) {
+ return NULL;
+ }
+ data = g_simple_async_result_get_op_res_gpointer (simple);
+ if (total_matches) {
+ *total_matches = data->total_matches;
+ }
+ result = data->result;
+ data->result = NULL;
+ return result;
}
-
-static void rygel_media_export_db_container_real_find_object (RygelMediaContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
- RygelMediaExportDBContainer * self;
- RygelMediaExportDbContainerFindObjectData* _data_;
- RygelMediaExportDBContainer* _tmp0_;
- const gchar* _tmp1_;
- gchar* _tmp2_;
- GCancellable* _tmp3_;
- GCancellable* _tmp4_;
- self = (RygelMediaExportDBContainer*) base;
- _data_ = g_slice_new0 (RygelMediaExportDbContainerFindObjectData);
- _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_db_container_real_find_object);
- g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_db_container_real_find_object_data_free);
- _tmp0_ = g_object_ref (self);
- _data_->self = _tmp0_;
- _tmp1_ = id;
- _tmp2_ = g_strdup (_tmp1_);
- g_free (_data_->id);
- _data_->id = _tmp2_;
- _tmp3_ = cancellable;
- _tmp4_ = g_object_ref (_tmp3_);
- g_object_unref (_data_->cancellable);
- _data_->cancellable = _tmp4_;
- rygel_media_export_db_container_real_find_object_co (_data_);
+static void
+rygel_media_export_db_container_real_find_object (RygelMediaContainer *base,
+ const gchar *id,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data) {
+ GError *inner_error = NULL;
+ RygelMediaObject *object = rygel_media_export_media_cache_get_object (self->priv->media_db,
+ id,
+ &inner_error);
+ GSimpleAsyncResult *simple;
+
+ if (inner_error) {
+ simple = g_simple_async_result_new_take_error (G_OBJECT (self),
+ callback,
+ user_data,
+ inner_error);
+ } else {
+ simple = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ rygel_media_export_db_container_real_find_object);
+ g_simple_async_result_set_op_res_gpointer (simple,
+ object,
+ g_object_unref);
+ }
+ g_simple_async_result_complete_in_idle (simple);
+ g_object_unref (simple);
}
-static RygelMediaObject* rygel_media_export_db_container_real_find_object_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
- RygelMediaObject* result;
- RygelMediaExportDbContainerFindObjectData* _data_;
- if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
- return NULL;
- }
- _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
- result = _data_->result;
- _data_->result = NULL;
- return result;
-}
-
+static RygelMediaObject *
+rygel_media_export_db_container_real_find_object_finish (RygelMediaContainer *base,
+ GAsyncResult *res,
+ GError **error) {
+ RygelMediaObject *result;
+ GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (res);
-static gboolean rygel_media_export_db_container_real_find_object_co (RygelMediaExportDbContainerFindObjectData* _data_) {
- switch (_data_->_state_) {
- case 0:
- goto _state_0;
- default:
- g_assert_not_reached ();
- }
- _state_0:
- _data_->_tmp0_ = _data_->self->priv->media_db;
- _data_->_tmp1_ = _data_->id;
- _data_->_tmp2_ = NULL;
- _data_->_tmp2_ = rygel_media_export_media_cache_get_object (_data_->_tmp0_, _data_->_tmp1_, &_data_->_inner_error_);
- _data_->_tmp3_ = _data_->_tmp2_;
- if (_data_->_inner_error_ != NULL) {
- g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
- g_error_free (_data_->_inner_error_);
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
- }
- _data_->result = _data_->_tmp3_;
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
- if (_data_->_state_ == 0) {
- g_simple_async_result_complete_in_idle (_data_->_async_result);
- } else {
- g_simple_async_result_complete (_data_->_async_result);
- }
- g_object_unref (_data_->_async_result);
- return FALSE;
-}
+ if (g_simple_async_result_propagate_error (simple, error)) {
+ return NULL;
+ }
+ result = RYGEL_MEDIA_OBJECT (g_simple_async_result_get_op_res_gpointer (simple));
+ if (result) {
+ g_object_ref (result);
+ }
-static GeeArrayList* rygel_media_export_db_container_real_get_search_classes (RygelSearchableContainer* base) {
- GeeArrayList* result;
- RygelMediaExportDBContainer* self;
- GeeArrayList* _tmp0_;
- self = (RygelMediaExportDBContainer*) base;
- _tmp0_ = self->priv->search_classes;
- result = _tmp0_;
- return result;
+ return result;
}
+static GeeArrayList *
+rygel_media_export_db_container_real_get_search_classes (RygelSearchableContainer *base) {
+ RygelMediaExportDBContainer* self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (base);
-static void rygel_media_export_db_container_real_set_search_classes (RygelSearchableContainer* base, GeeArrayList* value) {
- RygelMediaExportDBContainer* self;
- GeeArrayList* _tmp0_;
- GeeArrayList* _tmp1_;
- self = (RygelMediaExportDBContainer*) base;
- _tmp0_ = value;
- _tmp1_ = g_object_ref (_tmp0_);
- g_object_unref (self->priv->search_classes);
- self->priv->search_classes = _tmp1_;
- g_object_notify ((GObject *) self, "search-classes");
+ return self->priv->search_classes;
}
-static void rygel_media_export_db_container_class_init (RygelMediaExportDBContainerClass * klass) {
- rygel_media_export_db_container_parent_class = g_type_class_peek_parent (klass);
- g_type_class_add_private (klass, sizeof (RygelMediaExportDBContainerPrivate));
- RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children = rygel_media_export_db_container_real_get_children;
- RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children_finish = rygel_media_export_db_container_real_get_children_finish;
- RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (klass)->search = rygel_media_export_db_container_real_search;
- RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (klass)->search_finish = rygel_media_export_db_container_real_search_finish;
- RYGEL_MEDIA_CONTAINER_CLASS (klass)->find_object = rygel_media_export_db_container_real_find_object;
- RYGEL_MEDIA_CONTAINER_CLASS (klass)->find_object_finish = rygel_media_export_db_container_real_find_object_finish;
- G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_db_container_get_property;
- G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_db_container_set_property;
- G_OBJECT_CLASS (klass)->finalize = rygel_media_export_db_container_finalize;
- g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES, g_param_spec_object ("search-classes", "search-classes", "search-classes", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
-}
+static void
+rygel_media_export_db_container_real_set_search_classes (RygelSearchableContainer *base,
+ GeeArrayList *value) {
+ RygelMediaExportDBContainer* self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (base);
+ GeeArrayList *old = self->priv->search_classes;
+ if (value) {
+ g_object_ref (value);
+ }
+ self->priv->search_classes = value;
+ if (old) {
+ g_object_unref (old);
+ }
-static void rygel_media_export_db_container_rygel_searchable_container_interface_init (RygelSearchableContainerIface * iface) {
- rygel_media_export_db_container_rygel_searchable_container_parent_iface = g_type_interface_peek_parent (iface);
- iface->search = (RygelMediaObjects* (*)(RygelSearchableContainer*, RygelSearchExpression*, guint, guint, guint*, const gchar*, GCancellable*, GError**)) rygel_media_export_db_container_search;
- iface->search_finish = rygel_media_export_db_container_search_finish;
- iface->get_search_classes = rygel_media_export_db_container_real_get_search_classes;
- iface->set_search_classes = rygel_media_export_db_container_real_set_search_classes;
+ g_object_notify (G_OBJECT (self), "search-classes");
}
+static void
+rygel_media_export_db_container_dispose (GObject *object) {
+ RygelMediaExportDBContainer *self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (object);
+ RygelMediaExportDBContainerPrivate *priv = self->priv;
-static void rygel_media_export_db_container_init (RygelMediaExportDBContainer * self) {
- self->priv = RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_PRIVATE (self);
-}
+ if (priv->media_db) {
+ RygelMediaExportMediaCache *cache = priv->media_db;
+ priv->media_db = NULL;
+ g_object_unref (cache);
+ }
+ if (priv->search_classes) {
+ GeeArrayList *list = priv->search_classes;
-static void rygel_media_export_db_container_finalize (GObject* obj) {
- RygelMediaExportDBContainer * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer);
- g_object_unref (self->priv->media_db);
- g_object_unref (self->priv->search_classes);
+ priv->search_classes = NULL;
+ g_object_unref (list);
+ }
- G_OBJECT_CLASS (rygel_media_export_db_container_parent_class)->finalize (obj);
+ G_OBJECT_CLASS (rygel_media_export_db_container_parent_class)->dispose (object);
}
+static void
+rygel_media_export_db_container_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec) {
+ RygelMediaExportDBContainer *self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (object);
+ RygelMediaExportDBContainerPrivate *priv = self->priv;
-
-static void _vala_rygel_media_export_db_container_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
- RygelMediaExportDBContainer * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer);
switch (property_id) {
case RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES:
- g_value_set_object (value, rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self));
+ g_value_set_object (value, priv->search_classes);
+ break;
+
+ case RYGEL_MEDIA_EXPORT_DB_CONTAINER_MEDIA_DB:
+ g_value_set_object (value, priv->media_db);
break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
-static void _vala_rygel_media_export_db_container_set_property (GObject *object,
- guint property_id,
- const GValue * value,
- GParamSpec * pspec) {
- RygelMediaExportDBContainer * self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (object);
+static void
+rygel_media_export_db_container_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec) {
+ RygelMediaExportDBContainer *self = RYGEL_MEDIA_EXPORT_DB_CONTAINER (object);
+ RygelMediaExportDBContainer *priv = self->priv;
switch (property_id) {
case RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES:
rygel_searchable_container_set_search_classes (RYGEL_SEARCHABLE_CONTAINER (self),
g_value_get_object (value));
break;
+
+ case RYGEL_MEDIA_EXPORT_DB_CONTAINER_MEDIA_DB:
+ /* construct only property */
+ priv->media_db = g_value_dup_object (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
+
+static void
+rygel_media_export_db_container_class_init (RygelMediaExportDBContainerClass *db_container_class) {
+ GObjectClass *object_class = G_OBJECT_CLASS (db_container_class);
+ RygelMediaContainerClass *media_container_class = RYGEL_MEDIA_CONTAINER_CLASS (db_container_class);
+
+ media_container_class->get_children = rygel_media_export_db_container_real_get_children;
+ media_container_class->get_children_finish = rygel_media_export_db_container_real_get_children_finish;
+ media_container_class->find_object = rygel_media_export_db_container_real_find_object;
+ media_container_class->find_object_finish = rygel_media_export_db_container_real_find_object_finish;
+ object_class->get_property = rygel_media_export_db_container_get_property;
+ object_class->set_property = rygel_media_export_db_container_set_property;
+ object_class->dispose = rygel_media_export_db_container_dispose;
+
+ g_object_class_install_property (object_class,
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES,
+ g_param_spec_object ("search-classes",
+ "search-classes",
+ "search-classes",
+ GEE_TYPE_ARRAY_LIST,
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB |
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE));
+ g_object_class_install_property (object_class,
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_MEDIA_DB,
+ g_param_spec_object ("media-db",
+ "media-db",
+ "media-db",
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE,
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB |
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ g_type_class_add_private (klass,
+ sizeof (RygelMediaExportDBContainerPrivate));
+}
+
+static void
+rygel_media_export_db_container_rygel_searchable_container_interface_init (RygelSearchableContainerIface *iface) {
+ iface->search = rygel_media_export_db_container_real_search;
+ iface->search_finish = rygel_media_export_db_container_real_search_finish;
+ iface->get_search_classes = rygel_media_export_db_container_real_get_search_classes;
+ iface->set_search_classes = rygel_media_export_db_container_real_set_search_classes;
+}
+
+static void
+rygel_media_export_db_container_init (RygelMediaExportDBContainer *self) {
+ self->priv = RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_PRIVATE (self);
+}
+
+RygelMediaExportMediaCache *
+rygel_media_export_db_container_get_media_db (RygelMediaExportDBContainer *self)
+{
+ g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER (self), NULL);
+
+ return self->priv->media_db;
+}
diff --git a/src/media-export/rygel-media-export-db-container.h b/src/media-export/rygel-media-export-db-container.h
index 0ee4cd7..05828ed 100644
--- a/src/media-export/rygel-media-export-db-container.h
+++ b/src/media-export/rygel-media-export-db-container.h
@@ -44,9 +44,6 @@ struct _RygelMediaExportDBContainer {
struct _RygelMediaExportDBContainerClass {
RygelMediaContainerClass parent_class;
-
- void (*search) (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
- RygelMediaObjects* (*search_finish) (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error);
};
GType
@@ -57,21 +54,8 @@ rygel_media_export_db_container_new (RygelMediaExportMediaCache *media_db,
const gchar *id,
const gchar *title);
-void
-rygel_media_export_db_container_search (RygelMediaExportDBContainer *self,
- RygelSearchExpression *expression,
- guint offset,
- guint max_count,
- const gchar *sort_criteria,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
-RygelMediaObjects *
-rygel_media_export_db_container_search_finish (RygelMediaExportDBContainer *self,
- GAsyncResult *res,
- guint *total_matches,
- GError **error);
+RygelMediaExportMediaCache *
+rygel_media_export_db_container_get_media_db (RygelMediaExportDBContainer *self);
G_END_DECLS
diff --git a/src/media-export/rygel-media-export-leaf-query-container.c b/src/media-export/rygel-media-export-leaf-query-container.c
index 67d6f43..4d4c51f 100644
--- a/src/media-export/rygel-media-export-leaf-query-container.c
+++ b/src/media-export/rygel-media-export-leaf-query-container.c
@@ -271,11 +271,11 @@ static gboolean rygel_media_export_leaf_query_container_real_get_children_co (Ry
_data_->_tmp3_ = _data_->cancellable;
_data_->_tmp4_ = 0U;
_data_->_state_ = 1;
- rygel_media_export_db_container_search ((RygelMediaExportDBContainer*) _data_->self, NULL, _data_->_tmp0_, _data_->_tmp1_, _data_->_tmp2_, _data_->_tmp3_, rygel_media_export_leaf_query_container_get_children_ready, _data_);
+ rygel_searchable_container_search ((RygelSearchableContainer*) _data_->self, NULL, _data_->_tmp0_, _data_->_tmp1_, _data_->_tmp2_, _data_->_tmp3_, rygel_media_export_leaf_query_container_get_children_ready, _data_);
return FALSE;
_state_1:
_data_->_tmp5_ = NULL;
- _data_->_tmp5_ = rygel_media_export_db_container_search_finish ((RygelMediaExportDBContainer*) _data_->self, _data_->_res_, &_data_->_tmp4_, &_data_->_inner_error_);
+ _data_->_tmp5_ = rygel_searchable_container_search_finish ((RygelSearchableContainer*) _data_->self, _data_->_res_, &_data_->_tmp4_, &_data_->_inner_error_);
_data_->total_matches = _data_->_tmp4_;
_data_->children = _data_->_tmp5_;
if (_data_->_inner_error_ != NULL) {
@@ -344,7 +344,7 @@ static gint rygel_media_export_leaf_query_container_real_count_children (RygelMe
glong _tmp3_;
GError * _inner_error_ = NULL;
self = (RygelMediaExportLeafQueryContainer*) base;
- _tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp0_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER(self);
_tmp1_ = ((RygelMediaExportQueryContainer*) self)->expression;
_tmp2_ = rygel_media_export_media_cache_get_object_count_by_search_expression (_tmp0_, _tmp1_, NULL, &_inner_error_);
_tmp3_ = _tmp2_;
diff --git a/src/media-export/rygel-media-export-node-query-container.c b/src/media-export/rygel-media-export-node-query-container.c
index 8a9442b..fb2733e 100644
--- a/src/media-export/rygel-media-export-node-query-container.c
+++ b/src/media-export/rygel-media-export-node-query-container.c
@@ -396,7 +396,7 @@ static gboolean rygel_media_export_node_query_container_real_get_children_co (Ry
_state_0:
_data_->_tmp0_ = rygel_media_objects_new ();
_data_->children = _data_->_tmp0_;
- _data_->_tmp1_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp1_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (_data_->self));
_data_->_tmp2_ = _data_->self->priv->attribute;
_data_->_tmp3_ = ((RygelMediaExportQueryContainer*) _data_->self)->expression;
_data_->_tmp4_ = _data_->offset;
@@ -451,7 +451,7 @@ static gboolean rygel_media_export_node_query_container_real_get_children_co (Ry
_data_->_tmp22_ = rygel_media_export_query_container_factory_get_default ();
_data_->factory = _data_->_tmp22_;
_data_->_tmp23_ = _data_->factory;
- _data_->_tmp24_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp24_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (_data_->self));
_data_->_tmp25_ = _data_->new_id;
_data_->_tmp26_ = _data_->meta_data;
_data_->_tmp27_ = NULL;
@@ -518,7 +518,7 @@ static gint rygel_media_export_node_query_container_real_count_children (RygelMe
result = 0;
return result;
}
- _tmp4_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp4_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp5_ = self->priv->attribute;
_tmp6_ = ((RygelMediaExportQueryContainer*) self)->expression;
_tmp7_ = rygel_media_export_media_cache_get_object_attribute_by_search_expression (_tmp4_, _tmp5_, _tmp6_, (glong) 0, (guint) (-1), &_inner_error_);
diff --git a/src/media-export/rygel-media-export-query-container.c b/src/media-export/rygel-media-export-query-container.c
index a488b69..8453da4 100644
--- a/src/media-export/rygel-media-export-query-container.c
+++ b/src/media-export/rygel-media-export-query-container.c
@@ -241,7 +241,7 @@ static gboolean rygel_media_export_query_container_real_search_co (RygelMediaExp
rygel_search_expression_unref (_data_->local_expression);
}
{
- _data_->_tmp13_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp13_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (_data_->self));
_data_->_tmp14_ = _data_->combined_expression;
_data_->_tmp15_ = _data_->sort_criteria;
_data_->_tmp16_ = _data_->offset;
diff --git a/src/media-export/rygel-media-export-root-container.c b/src/media-export/rygel-media-export-root-container.c
index 4662972..5b5e20c 100644
--- a/src/media-export/rygel-media-export-root-container.c
+++ b/src/media-export/rygel-media-export-root-container.c
@@ -500,7 +500,7 @@ static gboolean rygel_media_export_root_container_real_find_object_co (RygelMedi
_data_->_tmp7_ = rygel_media_export_query_container_factory_get_default ();
_data_->factory = _data_->_tmp7_;
_data_->_tmp8_ = _data_->factory;
- _data_->_tmp9_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp9_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (_data_->self));
_data_->_tmp10_ = _data_->id;
_data_->_tmp11_ = NULL;
_data_->_tmp11_ = rygel_media_export_query_container_factory_create_from_id (_data_->_tmp8_, _data_->_tmp9_, _data_->_tmp10_, "");
@@ -1204,7 +1204,7 @@ static RygelMediaExportQueryContainer* rygel_media_export_root_container_search_
_tmp18_ = rygel_media_export_query_container_factory_get_default ();
factory = _tmp18_;
_tmp19_ = factory;
- _tmp20_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp20_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp21_ = id;
_tmp22_ = rygel_media_export_query_container_factory_create_from_description (_tmp19_, _tmp20_, _tmp21_, "");
result = _tmp22_;
@@ -1408,7 +1408,7 @@ static gboolean rygel_media_export_root_container_is_search_in_virtual_container
_tmp44_ = g_strdup_printf ("%s%s,%s,%s", RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX, (const gchar*) _tmp41_, _tmp42_, _tmp43_);
new_id = _tmp44_;
_tmp45_ = factory;
- _tmp46_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp46_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp47_ = new_id;
_tmp48_ = rygel_media_export_query_container_factory_create_from_description (_tmp45_, _tmp46_, _tmp47_, "");
g_object_unref (_vala_container);
@@ -1492,7 +1492,7 @@ static RygelMediaExportRootContainer* rygel_media_export_root_container_construc
}
{
RygelMediaExportMediaCache* _tmp8_;
- _tmp8_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp8_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
rygel_media_export_media_cache_save_container (_tmp8_, (RygelMediaContainer*) self, &_inner_error_);
if (_inner_error_ != NULL) {
goto __catch33_g_error;
@@ -1520,14 +1520,14 @@ static RygelMediaExportRootContainer* rygel_media_export_root_container_construc
RygelMediaContainer* _tmp12_;
RygelMediaExportMediaCache* _tmp13_;
RygelMediaContainer* _tmp14_;
- _tmp9_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp9_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp10_ = _ (RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_NAME);
_tmp11_ = rygel_media_export_db_container_new (_tmp9_, RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID, _tmp10_);
g_object_unref (self->priv->filesystem_container);
self->priv->filesystem_container = (RygelMediaContainer*) _tmp11_;
_tmp12_ = self->priv->filesystem_container;
((RygelMediaObject*) _tmp12_)->parent = (RygelMediaContainer*) self;
- _tmp13_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp13_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp14_ = self->priv->filesystem_container;
rygel_media_export_media_cache_save_container (_tmp13_, _tmp14_, &_inner_error_);
if (_inner_error_ != NULL) {
@@ -1553,7 +1553,7 @@ static RygelMediaExportRootContainer* rygel_media_export_root_container_construc
RygelMediaExportMediaCache* _tmp15_;
GeeArrayList* _tmp16_ = NULL;
GeeArrayList* _tmp17_;
- _tmp15_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp15_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp16_ = rygel_media_export_media_cache_get_child_ids (_tmp15_, RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID, &_inner_error_);
_tmp17_ = _tmp16_;
if (_inner_error_ != NULL) {
@@ -1703,7 +1703,7 @@ static RygelMediaExportRootContainer* rygel_media_export_root_container_construc
{
RygelMediaExportMediaCache* _tmp57_;
const gchar* _tmp58_;
- _tmp57_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp57_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp58_ = id;
rygel_media_export_media_cache_remove_by_id (_tmp57_, _tmp58_, &_inner_error_);
if (_inner_error_ != NULL) {
@@ -1781,7 +1781,7 @@ static void rygel_media_export_root_container_on_initial_harvesting_done (RygelM
_tmp0_ = self->priv->harvester;
_tmp1_ = self->priv->harvester_signal_id;
g_signal_handler_disconnect ((GObject*) _tmp0_, _tmp1_);
- _tmp2_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp2_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
rygel_media_export_media_cache_debug_statistics (_tmp2_);
rygel_media_export_root_container_add_default_virtual_folders (self);
rygel_media_container_updated ((RygelMediaContainer*) self, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
@@ -1948,7 +1948,7 @@ static void rygel_media_export_root_container_add_folder_definition (RygelMediaE
_tmp8_ = rygel_media_export_query_container_factory_get_default ();
factory = _tmp8_;
_tmp9_ = factory;
- _tmp10_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp10_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp11_ = id;
_tmp12_ = *definition;
_tmp13_ = _tmp12_.title;
@@ -1965,7 +1965,7 @@ static void rygel_media_export_root_container_add_folder_definition (RygelMediaE
_tmp18_ = query_container;
_tmp19_ = container;
((RygelMediaObject*) _tmp18_)->parent = _tmp19_;
- _tmp20_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp20_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp21_ = query_container;
rygel_media_export_media_cache_save_container (_tmp20_, (RygelMediaContainer*) _tmp21_, &_inner_error_);
if (_inner_error_ != NULL) {
@@ -1978,7 +1978,7 @@ static void rygel_media_export_root_container_add_folder_definition (RygelMediaE
} else {
RygelMediaExportMediaCache* _tmp22_;
const gchar* _tmp23_;
- _tmp22_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp22_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp23_ = id;
rygel_media_export_media_cache_remove_by_id (_tmp22_, _tmp23_, &_inner_error_);
if (_inner_error_ != NULL) {
@@ -2032,7 +2032,7 @@ static void rygel_media_export_root_container_add_virtual_containers_for_class (
_tmp7_ = _tmp6_;
rygel_media_object_set_id ((RygelMediaObject*) _tmp4_, _tmp7_);
g_free (_tmp7_);
- _tmp8_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp8_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp9_ = container;
rygel_media_export_media_cache_save_container (_tmp8_, (RygelMediaContainer*) _tmp9_, &_inner_error_);
if (_inner_error_ != NULL) {
@@ -2104,7 +2104,7 @@ static void rygel_media_export_root_container_add_virtual_containers_for_class (
}
}
}
- _tmp19_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp19_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp20_ = container;
_tmp21_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp20_);
_tmp22_ = _tmp21_;
@@ -2120,7 +2120,7 @@ static void rygel_media_export_root_container_add_virtual_containers_for_class (
RygelNullContainer* _tmp26_;
const gchar* _tmp27_;
const gchar* _tmp28_;
- _tmp25_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp25_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (self));
_tmp26_ = container;
_tmp27_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp26_);
_tmp28_ = _tmp27_;
diff --git a/src/media-export/rygel-media-export-writable-db-container.c b/src/media-export/rygel-media-export-writable-db-container.c
index d217319..1acd2fb 100644
--- a/src/media-export/rygel-media-export-writable-db-container.c
+++ b/src/media-export/rygel-media-export-writable-db-container.c
@@ -295,7 +295,7 @@ static gboolean rygel_media_export_writable_db_container_real_add_item_co (Rygel
_data_->_tmp14_ = _data_->_tmp13_;
rygel_media_object_set_id ((RygelMediaObject*) _data_->_tmp11_, _data_->_tmp14_);
g_free (_data_->_tmp14_);
- _data_->_tmp15_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp15_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (_data_->self));
_data_->_tmp16_ = _data_->item;
rygel_media_export_media_cache_save_item (_data_->_tmp15_, _data_->_tmp16_, &_data_->_inner_error_);
if (_data_->_inner_error_ != NULL) {
@@ -374,7 +374,7 @@ static gboolean rygel_media_export_writable_db_container_real_remove_item_co (Ry
g_assert_not_reached ();
}
_state_0:
- _data_->_tmp0_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp0_ = rygel_media_export_db_container_get_media_db (RYGEL_MEDIA_EXPORT_DB_CONTAINER (_data_->self));
_data_->_tmp1_ = _data_->id;
rygel_media_export_media_cache_remove_by_id (_data_->_tmp0_, _data_->_tmp1_, &_data_->_inner_error_);
if (_data_->_inner_error_ != NULL) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]