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



commit 12396de651bc3ca761dc6f649e7c6cc09d0a10bd
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Mon Feb 4 16:00:45 2013 +0100

    Cleanup RygelMediaExportObjectFactory.

 .../rygel-media-export-object-factory.c            |  296 ++++++--------------
 .../rygel-media-export-root-container.c            |    2 +-
 .../rygel-media-export-root-container.h            |    2 +-
 3 files changed, 88 insertions(+), 212 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-object-factory.c b/src/media-export/rygel-media-export-object-factory.c
index fb66b08..0951ea4 100644
--- a/src/media-export/rygel-media-export-object-factory.c
+++ b/src/media-export/rygel-media-export-object-factory.c
@@ -32,13 +32,8 @@
 
 G_DEFINE_TYPE (RygelMediaExportObjectFactory, rygel_media_export_object_factory, G_TYPE_OBJECT)
 
-enum  {
-	RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_DUMMY_PROPERTY
-};
 static RygelMediaExportDBContainer* rygel_media_export_object_factory_real_get_container (RygelMediaExportObjectFactory* self, const gchar* id, const gchar* title, guint child_count, const gchar* uri);
 static RygelMediaItem* rygel_media_export_object_factory_real_get_item (RygelMediaExportObjectFactory* self, RygelMediaContainer* parent, const gchar* id, const gchar* title, const gchar* upnp_class);
-RygelMediaExportObjectFactory* rygel_media_export_object_factory_construct (GType object_type);
-
 
 /**
  * Return a new instance of DBContainer
@@ -47,226 +42,107 @@ RygelMediaExportObjectFactory* rygel_media_export_object_factory_construct (GTyp
  * @param title title of the container
  * @param child_count number of children in the container
  */
-static RygelMediaExportDBContainer* rygel_media_export_object_factory_real_get_container (RygelMediaExportObjectFactory* self G_GNUC_UNUSED, const gchar* id, const gchar* title, guint child_count G_GNUC_UNUSED, const gchar* uri) {
-	RygelMediaExportDBContainer* result = NULL;
-	const gchar* _tmp0_;
-	const gchar* _tmp8_;
-	gboolean _tmp9_ = FALSE;
-	const gchar* _tmp16_;
-	const gchar* _tmp22_;
-	const gchar* _tmp23_;
-	RygelMediaExportWritableDbContainer* _tmp24_;
-	GError * _inner_error_ = NULL;
-	g_return_val_if_fail (id != NULL, NULL);
-	g_return_val_if_fail (title != NULL, NULL);
-	_tmp0_ = id;
-	if (g_strcmp0 (_tmp0_, "0") == 0) {
-		{
-			RygelMediaContainer* _tmp1_ = NULL;
-			RygelMediaContainer* _tmp2_;
-			_tmp1_ = rygel_media_export_root_container_get_instance (&_inner_error_);
-			_tmp2_ = _tmp1_;
-			if (_inner_error_ != NULL) {
-				goto __catch60_g_error;
-			}
-			result = G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER) ? ((RygelMediaExportDBContainer*) _tmp2_) : NULL;
-			return result;
-		}
-		goto __finally60;
-		__catch60_g_error:
-		{
-			GError* _error_ = NULL;
-			_error_ = _inner_error_;
-			_inner_error_ = NULL;
-			g_assert_not_reached ();
-			g_error_free (_error_);
-		}
-		__finally60:
-		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 NULL;
-	} else {
-		const gchar* _tmp3_;
-		_tmp3_ = id;
-		if (g_strcmp0 (_tmp3_, RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID) == 0) {
-			{
-				RygelMediaContainer* _tmp4_ = NULL;
-				RygelMediaContainer* _tmp5_;
-				RygelMediaExportRootContainer* root_container;
-				RygelMediaExportRootContainer* _tmp6_;
-				RygelMediaContainer* _tmp7_ = NULL;
-				_tmp4_ = rygel_media_export_root_container_get_instance (&_inner_error_);
-				_tmp5_ = _tmp4_;
-				if (_inner_error_ != NULL) {
-					goto __catch61_g_error;
-				}
-				root_container = G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER) ? ((RygelMediaExportRootContainer*) _tmp5_) : NULL;
-				_tmp6_ = root_container;
-				_tmp7_ = rygel_media_export_root_container_get_filesystem_container (_tmp6_);
-				result = G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER) ? ((RygelMediaExportDBContainer*) _tmp7_) : NULL;
-				g_object_unref (root_container);
-				return result;
-			}
-			goto __finally61;
-			__catch61_g_error:
-			{
-				GError* _error_ = NULL;
-				_error_ = _inner_error_;
-				_inner_error_ = NULL;
-				g_assert_not_reached ();
-				g_error_free (_error_);
-			}
-			__finally61:
-			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 NULL;
-		}
-	}
-	_tmp8_ = id;
-	_tmp9_ = g_str_has_prefix (_tmp8_, RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX);
-	if (_tmp9_) {
-		RygelMediaExportQueryContainerFactory* _tmp10_ = NULL;
-		RygelMediaExportQueryContainerFactory* factory;
-		RygelMediaExportQueryContainerFactory* _tmp11_;
-		const gchar* _tmp13_;
-		const gchar* _tmp14_;
-		RygelMediaExportQueryContainer* _tmp15_ = NULL;
-		_tmp10_ = rygel_media_export_query_container_factory_get_default ();
-		factory = _tmp10_;
-		_tmp11_ = factory;
-		_tmp13_ = id;
-		_tmp14_ = title;
-		_tmp15_ = rygel_media_export_query_container_factory_create_from_id (_tmp11_, _tmp13_, _tmp14_);
-		result = (RygelMediaExportDBContainer*) _tmp15_;
-		g_object_unref (factory);
-		return result;
-	}
-	_tmp16_ = uri;
-	if (_tmp16_ == NULL) {
-		const gchar* _tmp18_;
-		const gchar* _tmp19_;
-		RygelMediaExportDBContainer* _tmp20_;
-		_tmp18_ = id;
-		_tmp19_ = title;
-		_tmp20_ = rygel_media_export_db_container_new (_tmp18_, _tmp19_);
-		result = _tmp20_;
-		return result;
-	}
-	_tmp22_ = id;
-	_tmp23_ = title;
-	_tmp24_ = rygel_media_export_writable_db_container_new (_tmp22_, _tmp23_);
-	result = (RygelMediaExportDBContainer*) _tmp24_;
-	return result;
+static RygelMediaExportDBContainer *
+rygel_media_export_object_factory_real_get_container (RygelMediaExportObjectFactory *self G_GNUC_UNUSED,
+						      const gchar                   *id,
+						      const gchar                   *title,
+						      guint                          child_count G_GNUC_UNUSED,
+						      const gchar                   *uri) {
+  g_return_val_if_fail (id != NULL, NULL);
+  g_return_val_if_fail (title != NULL, NULL);
+
+  if (g_strcmp0 (id, "0") == 0) {
+    return RYGEL_MEDIA_EXPORT_DB_CONTAINER (rygel_media_export_root_container_get_instance ());
+  }
+
+  if (!g_strcmp0 (id, RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID)) {
+    RygelMediaExportRootContainer *root_container = RYGEL_MEDIA_EXPORT_ROOT_CONTAINER (rygel_media_export_root_container_get_instance ());
+    RygelMediaExportDBContainer *container = RYGEL_MEDIA_EXPORT_DB_CONTAINER (rygel_media_export_root_container_get_filesystem_container (root_container));
+
+    g_object_unref (root_container);
+    return container;
+  }
+
+  if (g_str_has_prefix (id, RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX)) {
+    RygelMediaExportQueryContainerFactory* factory = rygel_media_export_query_container_factory_get_default ();
+    RygelMediaExportDBContainer *container = RYGEL_MEDIA_EXPORT_DB_CONTAINER (rygel_media_export_query_container_factory_create_from_id (factory, id, title));
+
+    g_object_unref (factory);
+    return container;
+  }
+
+  if (!uri) {
+    return rygel_media_export_db_container_new (id, title);
+  }
+
+  return RYGEL_MEDIA_EXPORT_DB_CONTAINER (rygel_media_export_writable_db_container_new (id, title));
 }
 
+RygelMediaExportDBContainer *
+rygel_media_export_object_factory_get_container (RygelMediaExportObjectFactory *self,
+						 const gchar                   *id,
+						 const gchar                   *title,
+						 guint                          child_count,
+						 const gchar                   *uri) {
+  g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_OBJECT_FACTORY (self), NULL);
 
-RygelMediaExportDBContainer* rygel_media_export_object_factory_get_container (RygelMediaExportObjectFactory* self, const gchar* id, const gchar* title, guint child_count, const gchar* uri) {
-	g_return_val_if_fail (self != NULL, NULL);
-	return RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_GET_CLASS (self)->get_container (self, id, title, child_count, uri);
+  return RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_GET_CLASS (self)->get_container (self, id, title, child_count, uri);
 }
 
-
 /**
-     * Return a new instance of MediaItem
-     *
-     * @param id id of the item
-     * @param title title of the item
-     * @param upnp_class upnp_class of the item
-     */
-static RygelMediaItem* rygel_media_export_object_factory_real_get_item (RygelMediaExportObjectFactory* self G_GNUC_UNUSED, RygelMediaContainer* parent, const gchar* id, const gchar* title, const gchar* upnp_class) {
-	RygelMediaItem* result = NULL;
-	const gchar* _tmp0_;
-	const gchar* _tmp1_;
-	GQuark _tmp3_ = 0U;
-	g_return_val_if_fail (parent != NULL, NULL);
-	g_return_val_if_fail (id != NULL, NULL);
-	g_return_val_if_fail (title != NULL, NULL);
-	g_return_val_if_fail (upnp_class != NULL, NULL);
-	_tmp0_ = upnp_class;
-	_tmp1_ = _tmp0_;
-	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
-	if ((_tmp3_ == g_quark_from_string (RYGEL_MUSIC_ITEM_UPNP_CLASS)) || (_tmp3_ == g_quark_from_string (RYGEL_AUDIO_ITEM_UPNP_CLASS))) {
-		switch (0) {
-			default:
-			{
-				const gchar* _tmp4_;
-				RygelMediaContainer* _tmp5_;
-				const gchar* _tmp6_;
-				RygelMediaExportMusicItem* _tmp7_;
-				_tmp4_ = id;
-				_tmp5_ = parent;
-				_tmp6_ = title;
-				_tmp7_ = rygel_media_export_music_item_new (_tmp4_, _tmp5_, _tmp6_, RYGEL_MUSIC_ITEM_UPNP_CLASS);
-				result = (RygelMediaItem*) _tmp7_;
-				return result;
-			}
-		}
-	} else if (_tmp3_ == g_quark_from_string (RYGEL_VIDEO_ITEM_UPNP_CLASS)) {
-		switch (0) {
-			default:
-			{
-				const gchar* _tmp8_;
-				RygelMediaContainer* _tmp9_;
-				const gchar* _tmp10_;
-				RygelMediaExportVideoItem* _tmp11_;
-				_tmp8_ = id;
-				_tmp9_ = parent;
-				_tmp10_ = title;
-				_tmp11_ = rygel_media_export_video_item_new (_tmp8_, _tmp9_, _tmp10_, RYGEL_VIDEO_ITEM_UPNP_CLASS);
-				result = (RygelMediaItem*) _tmp11_;
-				return result;
-			}
-		}
-	} else if ((_tmp3_ == g_quark_from_string (RYGEL_PHOTO_ITEM_UPNP_CLASS)) || (_tmp3_ == g_quark_from_string (RYGEL_IMAGE_ITEM_UPNP_CLASS))) {
-		switch (0) {
-			default:
-			{
-				const gchar* _tmp12_;
-				RygelMediaContainer* _tmp13_;
-				const gchar* _tmp14_;
-				RygelMediaExportPhotoItem* _tmp15_;
-				_tmp12_ = id;
-				_tmp13_ = parent;
-				_tmp14_ = title;
-				_tmp15_ = rygel_media_export_photo_item_new (_tmp12_, _tmp13_, _tmp14_, RYGEL_PHOTO_ITEM_UPNP_CLASS);
-				result = (RygelMediaItem*) _tmp15_;
-				return result;
-			}
-		}
-	} else {
-		switch (0) {
-			default:
-			{
-				g_assert_not_reached ();
-			}
-		}
-	}
+ * Return a new instance of MediaItem
+ *
+ * @param id id of the item
+ * @param title title of the item
+ * @param upnp_class upnp_class of the item
+ */
+static RygelMediaItem *
+rygel_media_export_object_factory_real_get_item (RygelMediaExportObjectFactory *self G_GNUC_UNUSED,
+						 RygelMediaContainer *parent,
+						 const gchar         *id,
+						 const gchar         *title,
+						 const gchar         *upnp_class) {
+  g_return_val_if_fail (RYGEL_IS_MEDIA_CONTAINER (parent), NULL);
+  g_return_val_if_fail (id != NULL, NULL);
+  g_return_val_if_fail (title != NULL, NULL);
+  g_return_val_if_fail (upnp_class != NULL, NULL);
+
+  if (!g_strcmp0 (upnp_class, RYGEL_MUSIC_ITEM_UPNP_CLASS) || !g_strcmp0 (upnp_class, RYGEL_AUDIO_ITEM_UPNP_CLASS)) {
+    return RYGEL_MEDIA_ITEM (rygel_media_export_music_item_new (id, parent, title, RYGEL_MUSIC_ITEM_UPNP_CLASS));
+  }
+  if (!g_strcmp0 (upnp_class, RYGEL_VIDEO_ITEM_UPNP_CLASS)) {
+    return RYGEL_MEDIA_ITEM (rygel_media_export_video_item_new (id, parent, title, RYGEL_VIDEO_ITEM_UPNP_CLASS));
+  }
+  if (!g_strcmp0 (upnp_class, RYGEL_PHOTO_ITEM_UPNP_CLASS) || !g_strcmp0 (upnp_class, RYGEL_IMAGE_ITEM_UPNP_CLASS)) {
+    return RYGEL_MEDIA_ITEM (rygel_media_export_photo_item_new (id, parent, title, RYGEL_PHOTO_ITEM_UPNP_CLASS));
+  }
+  g_assert_not_reached ();
 }
 
+RygelMediaItem *
+rygel_media_export_object_factory_get_item (RygelMediaExportObjectFactory *self,
+					    RygelMediaContainer           *parent,
+					    const gchar                   *id,
+					    const gchar                   *title,
+					    const gchar                   *upnp_class) {
+  g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_OBJECT_FACTORY (self), NULL);
 
-RygelMediaItem* rygel_media_export_object_factory_get_item (RygelMediaExportObjectFactory* self, RygelMediaContainer* parent, const gchar* id, const gchar* title, const gchar* upnp_class) {
-	g_return_val_if_fail (self != NULL, NULL);
-	return RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_GET_CLASS (self)->get_item (self, parent, id, title, upnp_class);
+  return RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_GET_CLASS (self)->get_item (self, parent, id, title, upnp_class);
 }
 
-
-RygelMediaExportObjectFactory* rygel_media_export_object_factory_construct (GType object_type) {
-	RygelMediaExportObjectFactory * self = NULL;
-	self = (RygelMediaExportObjectFactory*) g_object_new (object_type, NULL);
-	return self;
+RygelMediaExportObjectFactory *
+rygel_media_export_object_factory_new (void) {
+  return RYGEL_MEDIA_EXPORT_OBJECT_FACTORY (g_object_new (RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, NULL));
 }
 
-
-RygelMediaExportObjectFactory* rygel_media_export_object_factory_new (void) {
-	return rygel_media_export_object_factory_construct (RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY);
-}
+static void
+rygel_media_export_object_factory_class_init (RygelMediaExportObjectFactoryClass *factory_class) {
 
 
-static void rygel_media_export_object_factory_class_init (RygelMediaExportObjectFactoryClass * klass) {
-	RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_CLASS (klass)->get_container = rygel_media_export_object_factory_real_get_container;
-	RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_CLASS (klass)->get_item = rygel_media_export_object_factory_real_get_item;
+  factory_class->get_container = rygel_media_export_object_factory_real_get_container;
+  factory_class->get_item = rygel_media_export_object_factory_real_get_item;
 }
 
-
-static void rygel_media_export_object_factory_init (RygelMediaExportObjectFactory * self G_GNUC_UNUSED) {
+static void
+rygel_media_export_object_factory_init (RygelMediaExportObjectFactory *self G_GNUC_UNUSED) {
 }
diff --git a/src/media-export/rygel-media-export-root-container.c b/src/media-export/rygel-media-export-root-container.c
index 1b0870c..5ccf950 100644
--- a/src/media-export/rygel-media-export-root-container.c
+++ b/src/media-export/rygel-media-export-root-container.c
@@ -95,7 +95,7 @@ rygel_media_export_root_container_new (void) {
 }
 
 RygelMediaContainer *
-rygel_media_export_root_container_get_instance () {
+rygel_media_export_root_container_get_instance (void) {
   if (!rygel_media_export_root_container_instance) {
     rygel_media_export_root_container_instance = RYGEL_MEDIA_CONTAINER (rygel_media_export_root_container_new ());
   }
diff --git a/src/media-export/rygel-media-export-root-container.h b/src/media-export/rygel-media-export-root-container.h
index b2168f3..f79d80e 100644
--- a/src/media-export/rygel-media-export-root-container.h
+++ b/src/media-export/rygel-media-export-root-container.h
@@ -55,7 +55,7 @@ GType
 rygel_media_export_root_container_get_type (void) G_GNUC_CONST;
 
 RygelMediaContainer *
-rygel_media_export_root_container_get_instance ();
+rygel_media_export_root_container_get_instance (void);
 
 RygelMediaContainer *
 rygel_media_export_root_container_get_filesystem_container (RygelMediaExportRootContainer *self);



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