[rygel-gst-0-10-plugins] Cleanup.



commit 944cb38e87dd5dadba1fa8747e533c61269e21f0
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Mon Jan 14 16:19:31 2013 +0100

    Cleanup.

 src/media-export/rygel-media-export-db-container.c |  110 ++++----
 src/media-export/rygel-media-export-db-container.h |   25 ++-
 src/media-export/rygel-media-export-sql-operator.c |  323 +++++++++++---------
 src/media-export/rygel-media-export-sql-operator.h |   30 ++-
 .../rygel-media-export-sqlite-wrapper.c            |    6 +-
 5 files changed, 281 insertions(+), 213 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-db-container.c b/src/media-export/rygel-media-export-db-container.c
index bcf9964..dc06d40 100644
--- a/src/media-export/rygel-media-export-db-container.c
+++ b/src/media-export/rygel-media-export-db-container.c
@@ -26,8 +26,11 @@
 
 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, rygel_media_export_db_container_rygel_searchable_container_interface_init))
+G_DEFINE_TYPE_WITH_CODE (RygelMediaExportDBContainer,
+			 rygel_media_export_db_container,
+			 RYGEL_TYPE_MEDIA_CONTAINER,
+			 G_IMPLEMENT_INTERFACE (RYGEL_TYPE_DATA_SOURCE,
+						rygel_media_export_db_container_rygel_searchable_container_interface_init))
 
 typedef struct _RygelMediaExportDbContainerGetChildrenData RygelMediaExportDbContainerGetChildrenData;
 typedef struct _RygelMediaExportDbContainerSearchData RygelMediaExportDbContainerSearchData;
@@ -35,7 +38,8 @@ typedef struct _RygelMediaExportDbContainerFindObjectData RygelMediaExportDbCont
 
 
 struct _RygelMediaExportDBContainerPrivate {
-	GeeArrayList* _search_classes;
+  GeeArrayList *search_classes;
+  RygelMediaExportMediaCache *media_db;
 };
 
 struct _RygelMediaExportDbContainerGetChildrenData {
@@ -116,35 +120,32 @@ struct _RygelMediaExportDbContainerFindObjectData {
 
 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, RygelMediaExportDBContainerPrivate))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+				RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, \
+				RygelMediaExportDBContainerPrivate))
 
 enum  {
-	RYGEL_MEDIA_EXPORT_DB_CONTAINER_DUMMY_PROPERTY,
-	RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES
+  RYGEL_MEDIA_EXPORT_DB_CONTAINER_DUMMY_PROPERTY,
+  RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES
 };
-RygelMediaExportDBContainer* rygel_media_export_db_container_new (RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title);
+
 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);
-GQuark rygel_media_export_database_error_quark (void);
-gint rygel_media_export_media_cache_get_child_count (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
+
 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_);
-RygelMediaObjects* rygel_media_export_media_cache_get_children (RygelMediaExportMediaCache* self, RygelMediaContainer* container, const gchar* sort_criteria, glong offset, glong max_count, GError** error);
 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_);
-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);
 static gboolean rygel_media_export_db_container_real_search_co (RygelMediaExportDbContainerSearchData* _data_);
-RygelMediaObjects* rygel_media_export_media_cache_get_objects_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, const gchar* sort_criteria, guint offset, guint max_count, guint* total_matches, GError** error);
-GQuark rygel_media_export_media_cache_error_quark (void);
 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_);
-RygelMediaObject* rygel_media_export_media_cache_get_object (RygelMediaExportMediaCache* self, const gchar* object_id, GError** error);
 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);
@@ -175,8 +176,8 @@ RygelMediaExportDBContainer* rygel_media_export_db_container_construct (GType ob
 	self = (RygelMediaExportDBContainer*) rygel_media_container_construct (object_type, _tmp0_, NULL, _tmp1_, 0);
 	_tmp2_ = media_db;
 	_tmp3_ = g_object_ref (_tmp2_);
-	g_object_unref (self->media_db);
-	self->media_db = _tmp3_;
+	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_);
@@ -201,7 +202,7 @@ static void rygel_media_export_db_container_count_children (RygelMediaExportDBCo
 		const gchar* _tmp2_;
 		gint _tmp3_ = 0;
 		gint _tmp4_;
-		_tmp0_ = self->media_db;
+		_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_);
@@ -304,7 +305,7 @@ static gboolean rygel_media_export_db_container_real_get_children_co (RygelMedia
 		g_assert_not_reached ();
 	}
 	_state_0:
-	_data_->_tmp0_ = _data_->self->media_db;
+	_data_->_tmp0_ = _data_->self->priv->media_db;
 	_data_->_tmp1_ = _data_->sort_criteria;
 	_data_->_tmp2_ = _data_->offset;
 	_data_->_tmp3_ = _data_->max_count;
@@ -429,7 +430,7 @@ static gboolean rygel_media_export_db_container_real_search_co (RygelMediaExport
 	_state_0:
 	_data_->children = NULL;
 	{
-		_data_->_tmp0_ = _data_->self->media_db;
+		_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_;
@@ -586,7 +587,7 @@ static gboolean rygel_media_export_db_container_real_find_object_co (RygelMediaE
 		g_assert_not_reached ();
 	}
 	_state_0:
-	_data_->_tmp0_ = _data_->self->media_db;
+	_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_);
@@ -625,7 +626,7 @@ static GeeArrayList* rygel_media_export_db_container_real_get_search_classes (Ry
 	RygelMediaExportDBContainer* self;
 	GeeArrayList* _tmp0_;
 	self = (RygelMediaExportDBContainer*) base;
-	_tmp0_ = self->priv->_search_classes;
+	_tmp0_ = self->priv->search_classes;
 	result = _tmp0_;
 	return result;
 }
@@ -638,8 +639,8 @@ static void rygel_media_export_db_container_real_set_search_classes (RygelSearch
 	self = (RygelMediaExportDBContainer*) base;
 	_tmp0_ = value;
 	_tmp1_ = g_object_ref (_tmp0_);
-	g_object_unref (self->priv->_search_classes);
-	self->priv->_search_classes = _tmp1_;
+	g_object_unref (self->priv->search_classes);
+	self->priv->search_classes = _tmp1_;
 	g_object_notify ((GObject *) self, "search-classes");
 }
 
@@ -675,41 +676,42 @@ static void rygel_media_export_db_container_init (RygelMediaExportDBContainer *
 
 
 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->media_db);
-	g_object_unref (self->priv->_search_classes);
-	G_OBJECT_CLASS (rygel_media_export_db_container_parent_class)->finalize (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);
+
+  G_OBJECT_CLASS (rygel_media_export_db_container_parent_class)->finalize (obj);
 }
 
 
 
 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));
-		break;
-		default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-		break;
-	}
+  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));
+    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;
-	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:
-		rygel_searchable_container_set_search_classes ((RygelSearchableContainer*) self, g_value_get_object (value));
-		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);
+
+  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;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    break;
+  }
 }
-
-
-
diff --git a/src/media-export/rygel-media-export-db-container.h b/src/media-export/rygel-media-export-db-container.h
index e2d230b..0ee4cd7 100644
--- a/src/media-export/rygel-media-export-db-container.h
+++ b/src/media-export/rygel-media-export-db-container.h
@@ -40,7 +40,6 @@ typedef struct _RygelMediaExportDBContainerPrivate RygelMediaExportDBContainerPr
 struct _RygelMediaExportDBContainer {
   RygelMediaContainer parent_instance;
   RygelMediaExportDBContainerPrivate *priv;
-  RygelMediaExportMediaCache* media_db; /* TODO: Move to priv. */
 };
 
 struct _RygelMediaExportDBContainerClass {
@@ -50,9 +49,29 @@ struct _RygelMediaExportDBContainerClass {
   RygelMediaObjects* (*search_finish) (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error);
 };
 
-GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+GType
+rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
 
-RygelMediaExportDBContainer* rygel_media_export_db_container_new (RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title);
+RygelMediaExportDBContainer *
+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);
 
 G_END_DECLS
 
diff --git a/src/media-export/rygel-media-export-sql-operator.c b/src/media-export/rygel-media-export-sql-operator.c
index d5427a7..652a4ee 100644
--- a/src/media-export/rygel-media-export-sql-operator.c
+++ b/src/media-export/rygel-media-export-sql-operator.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2010 Jens Georg <mail jensge org>.
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2012, 2013 Intel Corporation.
  *
  * Author: Jens Georg <mail jensge org>
  *
@@ -25,164 +25,205 @@
 
 G_DEFINE_TYPE (RygelMediaExportSqlOperator, rygel_media_export_sql_operator, G_TYPE_OBJECT)
 
-RygelMediaExportSqlOperator* rygel_media_export_sql_operator_construct (GType object_type, const gchar* name, const gchar* arg, const gchar* collate);
-RygelMediaExportSqlOperator* rygel_media_export_sql_operator_construct_from_search_criteria_op (GType object_type, GUPnPSearchCriteriaOp op, const gchar* arg, const gchar* collate);
-static gchar* rygel_media_export_sql_operator_real_to_string (RygelMediaExportSqlOperator* self);
-static void rygel_media_export_sql_operator_finalize (GObject* obj);
-
-
-RygelMediaExportSqlOperator* rygel_media_export_sql_operator_construct (GType object_type, const gchar* name, const gchar* arg, const gchar* collate) {
-	RygelMediaExportSqlOperator * self = NULL;
-	const gchar* _tmp0_;
-	gchar* _tmp1_;
-	const gchar* _tmp2_;
-	gchar* _tmp3_;
-	const gchar* _tmp4_;
-	gchar* _tmp5_;
-	g_return_val_if_fail (name != NULL, NULL);
-	g_return_val_if_fail (arg != NULL, NULL);
-	g_return_val_if_fail (collate != NULL, NULL);
-	self = (RygelMediaExportSqlOperator*) g_object_new (object_type, NULL);
-	_tmp0_ = name;
-	_tmp1_ = g_strdup (_tmp0_);
-	g_free (self->name);
-	self->name = _tmp1_;
-	_tmp2_ = arg;
-	_tmp3_ = g_strdup (_tmp2_);
-	g_free (self->arg);
-	self->arg = _tmp3_;
-	_tmp4_ = collate;
-	_tmp5_ = g_strdup (_tmp4_);
-	g_free (self->collate);
-	self->collate = _tmp5_;
-	return self;
-}
-
+#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR_GET_PRIVATE(o) \
+  (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+                                RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, \
+                                RygelMediaExportSqlOperatorPrivate))
 
-RygelMediaExportSqlOperator* rygel_media_export_sql_operator_new (const gchar* name, const gchar* arg, const gchar* collate) {
-	return rygel_media_export_sql_operator_construct (RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, name, arg, collate);
+enum {
+  PROP_0,
+  PROP_NAME,
+  PROP_ARG,
+  PROP_COLLATE
 }
 
-
-RygelMediaExportSqlOperator* rygel_media_export_sql_operator_construct_from_search_criteria_op (GType object_type, GUPnPSearchCriteriaOp op, const gchar* arg, const gchar* collate) {
-	RygelMediaExportSqlOperator * self = NULL;
-	gchar* sql;
-	GUPnPSearchCriteriaOp _tmp0_;
-	const gchar* _tmp7_;
-	const gchar* _tmp8_;
-	const gchar* _tmp9_;
-	g_return_val_if_fail (arg != NULL, NULL);
-	g_return_val_if_fail (collate != NULL, NULL);
-	sql = NULL;
-	_tmp0_ = op;
-	switch (_tmp0_) {
-		case GUPNP_SEARCH_CRITERIA_OP_EQ:
-		{
-			gchar* _tmp1_;
-			_tmp1_ = g_strdup ("=");
-			g_free (sql);
-			sql = _tmp1_;
-			break;
-		}
-		case GUPNP_SEARCH_CRITERIA_OP_NEQ:
-		{
-			gchar* _tmp2_;
-			_tmp2_ = g_strdup ("!=");
-			g_free (sql);
-			sql = _tmp2_;
-			break;
-		}
-		case GUPNP_SEARCH_CRITERIA_OP_LESS:
-		{
-			gchar* _tmp3_;
-			_tmp3_ = g_strdup ("<");
-			g_free (sql);
-			sql = _tmp3_;
-			break;
-		}
-		case GUPNP_SEARCH_CRITERIA_OP_LEQ:
-		{
-			gchar* _tmp4_;
-			_tmp4_ = g_strdup ("<=");
-			g_free (sql);
-			sql = _tmp4_;
-			break;
-		}
-		case GUPNP_SEARCH_CRITERIA_OP_GREATER:
-		{
-			gchar* _tmp5_;
-			_tmp5_ = g_strdup (">");
-			g_free (sql);
-			sql = _tmp5_;
-			break;
-		}
-		case GUPNP_SEARCH_CRITERIA_OP_GEQ:
-		{
-			gchar* _tmp6_;
-			_tmp6_ = g_strdup (">=");
-			g_free (sql);
-			sql = _tmp6_;
-			break;
-		}
-		default:
-		{
-			g_assert_not_reached ();
-		}
-	}
-	_tmp7_ = sql;
-	_tmp8_ = arg;
-	_tmp9_ = collate;
-	self = (RygelMediaExportSqlOperator*) rygel_media_export_sql_operator_construct (object_type, _tmp7_, _tmp8_, _tmp9_);
-	g_free (sql);
-	return self;
+struct _RygelMediaExportSqlOperatorPrivate {
+  gchar *name;
+  gchar *arg;
+  gchar *collate;
+};
+
+RygelMediaExportSqlOperator *
+rygel_media_export_sql_operator_new (const gchar *name,
+                                     const gchar *arg,
+                                     const gchar *collate) {
+  return RYGEL_MEDIA_EXPORT_SQL_OPERATOR (g_object_new (RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR,
+                                                        "name", name,
+                                                        "arg", arg,
+                                                        "collate", collate,
+                                                        NULL));
 }
 
-
-RygelMediaExportSqlOperator* rygel_media_export_sql_operator_new_from_search_criteria_op (GUPnPSearchCriteriaOp op, const gchar* arg, const gchar* collate) {
-	return rygel_media_export_sql_operator_construct_from_search_criteria_op (RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, op, arg, collate);
+RygelMediaExportSqlOperator *
+rygel_media_export_sql_operator_new_from_search_criteria_op (GUPnPSearchCriteriaOp  op,
+                                                             const gchar           *arg,
+                                                             const gchar           *collate) {
+  const gchar* sql;
+
+  g_return_val_if_fail (arg != NULL, NULL);
+  g_return_val_if_fail (collate != NULL, NULL);
+
+  switch (op) {
+  case GUPNP_SEARCH_CRITERIA_OP_EQ:
+    sql = "=";
+    break;
+  case GUPNP_SEARCH_CRITERIA_OP_NEQ:
+    sql = "!=";
+    break;
+  case GUPNP_SEARCH_CRITERIA_OP_LESS:
+    sql = "<";
+    break;
+  case GUPNP_SEARCH_CRITERIA_OP_LEQ:
+    sql = "<=";
+    break;
+  case GUPNP_SEARCH_CRITERIA_OP_GREATER:
+    sql = ">";
+    break;
+  case GUPNP_SEARCH_CRITERIA_OP_GEQ:
+    sql = ">=";
+    break;
+  default:
+    g_assert_not_reached ();
+  }
+
+  return rygel_media_export_sql_operator_new (sql, arg, collate);
 }
 
+static gchar *
+rygel_media_export_sql_operator_real_to_string (RygelMediaExportSqlOperator *self) {
+  RygelMediaExportSqlOperatorPrivate *priv = self->priv;
 
-static gchar* rygel_media_export_sql_operator_real_to_string (RygelMediaExportSqlOperator* self) {
-	gchar* result = NULL;
-	const gchar* _tmp0_;
-	const gchar* _tmp1_;
-	const gchar* _tmp2_;
-	gchar* _tmp3_ = NULL;
-	_tmp0_ = self->arg;
-	_tmp1_ = self->name;
-	_tmp2_ = self->collate;
-	_tmp3_ = g_strdup_printf ("(%s %s ? %s)", _tmp0_, _tmp1_, _tmp2_);
-	result = _tmp3_;
-	return result;
+  return g_strdup_printf ("(%s %s ? %s)",
+                          priv->arg,
+                          priv->name,
+                          priv->collate);
 }
 
+gchar*
+rygel_media_export_sql_operator_to_string (RygelMediaExportSqlOperator *self) {
+  g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_SQL_OPERATOR (self), NULL);
 
-gchar* rygel_media_export_sql_operator_to_string (RygelMediaExportSqlOperator* self) {
-	g_return_val_if_fail (self != NULL, NULL);
-	return RYGEL_MEDIA_EXPORT_SQL_OPERATOR_GET_CLASS (self)->to_string (self);
+  return RYGEL_MEDIA_EXPORT_SQL_OPERATOR_GET_CLASS (self)->to_string (self);
 }
 
-
-static void rygel_media_export_sql_operator_class_init (RygelMediaExportSqlOperatorClass * klass) {
-	rygel_media_export_sql_operator_parent_class = g_type_class_peek_parent (klass);
-	RYGEL_MEDIA_EXPORT_SQL_OPERATOR_CLASS (klass)->to_string = rygel_media_export_sql_operator_real_to_string;
-	G_OBJECT_CLASS (klass)->finalize = rygel_media_export_sql_operator_finalize;
+static void
+rygel_media_export_sql_operator_get_property (GObject    *object,
+                                              guint       property_id,
+                                              GValue     *value,
+                                              GParamSpec *pspec) {
+  RygelMediaExportSqlOperator *self = RYGEL_MEDIA_EXPORT_SQL_OPERATOR (object);
+  RygelMediaExportSqlOperatorPrivate *priv = self->priv;
+
+  switch (property_id) {
+  case PROP_NAME:
+    g_value_set_string (value, priv->name);
+    break;
+
+  case PROP_ARG:
+    g_value_set_string (value, priv->arg);
+    break;
+
+  case PROP_COLLATE:
+    g_value_set_string (value, priv->collate);
+    break;
+
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    break;
+  }
 }
 
-
-static void rygel_media_export_sql_operator_init (RygelMediaExportSqlOperator * self) {
+static void
+rygel_media_export_sql_operator_set_property (GObject      *object,
+                                              guint         property_id,
+                                              const GValue *value,
+                                              GParamSpec   *pspec) {
+  RygelMediaExportSqlOperator *self = RYGEL_MEDIA_EXPORT_SQL_OPERATOR (object);
+  RygelMediaExportSqlOperatorPrivate *priv = self->priv;
+
+  switch (property_id) {
+  case PROP_NAME:
+    priv->name = g_value_dup_string (value);
+    break;
+
+  case PROP_ARG:
+    priv->arg = g_value_dup_string (value);
+    break;
+
+  case PROP_COLLATE:
+    priv->collate = g_value_dup_string (value);
+    break;
+
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    break;
+  }
 }
 
+static void
+rygel_media_export_sql_operator_finalize (GObject *object) {
+  RygelMediaExportSqlOperator *self = RYGEL_MEDIA_EXPORT_SQL_OPERATOR (object);
+  RygelMediaExportSqlOperatorPrivate *priv = self->priv;
 
-static void rygel_media_export_sql_operator_finalize (GObject* obj) {
-	RygelMediaExportSqlOperator * self;
-	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperator);
-	g_free (self->name);
-	g_free (self->arg);
-	g_free (self->collate);
-	G_OBJECT_CLASS (rygel_media_export_sql_operator_parent_class)->finalize (obj);
-}
+  g_free (priv->name);
+  g_free (priv->arg);
+  g_free (priv->collate);
 
+  G_OBJECT_CLASS (rygel_media_export_sql_operator_parent_class)->finalize (object);
+}
 
+static void
+rygel_media_export_sql_operator_class_init (RygelMediaExportSqlOperatorClass *operator_class) {
+  GObjectClass *object_class = G_OBJECT_CLASS (operator_class);
+
+  operator_class->to_string = rygel_media_export_sql_operator_real_to_string;
+  object_class->finalize = rygel_media_export_sql_operator_finalize;
+  object_class->get_property = rygel_media_export_sql_operator_get_property;
+  object_class->set_property = rygel_media_export_sql_operator_set_property;
+
+  g_object_class_install_property (object_class,
+                                   PROP_NAME,
+                                   g_param_spec_string ("name",
+                                                        "name",
+                                                        "name",
+                                                        NULL,
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB |
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_WRITABLE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+
+  g_object_class_install_property (object_class,
+                                   PROP_ARG,
+                                   g_param_spec_string ("arg",
+                                                        "arg",
+                                                        "arg",
+                                                        NULL,
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB |
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_WRITABLE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+
+  g_object_class_install_property (object_class,
+                                   PROP_COLLATE,
+                                   g_param_spec_string ("collate",
+                                                        "collate",
+                                                        "collate",
+                                                        NULL,
+                                                        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 (operator_class,
+                            sizeof (RygelMediaExportSqlOperatorPrivate));
+}
 
+static void rygel_media_export_sql_operator_init (RygelMediaExportSqlOperator *self) {
+  self->priv = RYGEL_MEDIA_EXPORT_SQL_OPERATOR_GET_PRIVATE (self);
+}
diff --git a/src/media-export/rygel-media-export-sql-operator.h b/src/media-export/rygel-media-export-sql-operator.h
index 6896e70..a6e231a 100644
--- a/src/media-export/rygel-media-export-sql-operator.h
+++ b/src/media-export/rygel-media-export-sql-operator.h
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2012, 2013 Intel Corporation.
  *
  * This file is part of Rygel.
  *
@@ -44,25 +44,31 @@ typedef struct _RygelMediaExportSqlOperatorClass RygelMediaExportSqlOperatorClas
 typedef struct _RygelMediaExportSqlOperatorPrivate RygelMediaExportSqlOperatorPrivate;
 
 struct _RygelMediaExportSqlOperator {
-	GObject parent_instance;
-	RygelMediaExportSqlOperatorPrivate * priv;
-	gchar* name;
-	gchar* arg;
-	gchar* collate;
+  GObject parent_instance;
+  RygelMediaExportSqlOperatorPrivate * priv;
 };
 
 struct _RygelMediaExportSqlOperatorClass {
-	GObjectClass parent_class;
-	gchar* (*to_string) (RygelMediaExportSqlOperator* self);
+  GObjectClass parent_class;
+
+  gchar * (* to_string) (RygelMediaExportSqlOperator *self);
 };
 
-GType rygel_media_export_sql_operator_get_type (void) G_GNUC_CONST;
+GType
+rygel_media_export_sql_operator_get_type (void) G_GNUC_CONST;
 
-RygelMediaExportSqlOperator* rygel_media_export_sql_operator_new (const gchar* name, const gchar* arg, const gchar* collate);
+RygelMediaExportSqlOperator *
+rygel_media_export_sql_operator_new (const gchar *name,
+                                     const gchar *arg,
+                                     const gchar *collate);
 
-RygelMediaExportSqlOperator* rygel_media_export_sql_operator_new_from_search_criteria_op (GUPnPSearchCriteriaOp op, const gchar* arg, const gchar* collate);
+RygelMediaExportSqlOperator *
+rygel_media_export_sql_operator_new_from_search_criteria_op (GUPnPSearchCriteriaOp  op,
+                                                             const gchar           *arg,
+                                                             const gchar           *collate);
 
-gchar* rygel_media_export_sql_operator_to_string (RygelMediaExportSqlOperator* self);
+gchar *
+rygel_media_export_sql_operator_to_string (RygelMediaExportSqlOperator *self);
 
 G_END_DECLS
 
diff --git a/src/media-export/rygel-media-export-sqlite-wrapper.c b/src/media-export/rygel-media-export-sqlite-wrapper.c
index 866127b..a7321dd 100644
--- a/src/media-export/rygel-media-export-sqlite-wrapper.c
+++ b/src/media-export/rygel-media-export-sqlite-wrapper.c
@@ -157,7 +157,7 @@ rygel_media_export_sqlite_wrapper_get_property (GObject    *object,
 
   switch (property_id) {
   case RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_DB:
-    g_value_set_pointer (value, self->priv->reference);
+    g_value_set_pointer (value, priv->reference);
     break;
 
   default:
@@ -176,11 +176,11 @@ rygel_media_export_sqlite_wrapper_set_property (GObject      *object,
 
   switch (property_id) {
   case RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_DB:
-    g_value_set_pointer (value, self->priv->reference);
+    priv->reference = g_value_get_pointer (value);
     break;
 
   case RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_ONW_DB:
-    g_value_set_pointer (value, self->priv->database);
+    priv->database = g_value_get_pointer (value);
     break;
 
   default:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]