[rygel-gst-0-10-plugins] Cleanup RygelMediaExportPlugin
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-gst-0-10-plugins] Cleanup RygelMediaExportPlugin
- Date: Wed, 30 Jan 2013 11:08:15 +0000 (UTC)
commit 3ed6dbb42b77a2132e7201c0dfda63faca836e33
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Jan 30 12:08:10 2013 +0100
Cleanup RygelMediaExportPlugin
src/media-export/rygel-media-export-plugin.c | 137 ++++----------------
src/media-export/rygel-media-export-plugin.h | 2 +-
.../rygel-media-export-root-container.c | 19 +---
.../rygel-media-export-root-container.h | 2 +-
4 files changed, 32 insertions(+), 128 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-plugin.c b/src/media-export/rygel-media-export-plugin.c
index c2aa945..04b9ac1 100644
--- a/src/media-export/rygel-media-export-plugin.c
+++ b/src/media-export/rygel-media-export-plugin.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2008-2009 Jens Georg <mail jensge org>.
- * Copyright (C) 2012 Intel Corporation.
+ * Copyright (C) 2012, 2013 Intel Corporation.
*
* This file is part of Rygel.
*
@@ -19,135 +19,54 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+
#include "rygel-media-export-plugin.h"
#include "rygel-media-export-root-container.h"
G_DEFINE_TYPE (RygelMediaExportPlugin, rygel_media_export_plugin, RYGEL_TYPE_MEDIA_SERVER_PLUGIN)
-typedef struct _Block1Data Block1Data;
-struct _Block1Data {
- int _ref_count_;
- RygelMediaExportPlugin* plugin;
- RygelPluginLoader* loader;
-};
-
-typedef struct _Block2Data Block2Data;
-struct _Block2Data {
- int _ref_count_;
- RygelPlugin* plugin;
- RygelPlugin* our_plugin;
-};
-
-static void block1_data_unref (void * _userdata_);
#define RYGEL_MEDIA_EXPORT_PLUGIN_NAME "MediaExport"
-RygelMediaExportPlugin* rygel_media_export_plugin_new (GError** error);
-RygelMediaExportPlugin* rygel_media_export_plugin_construct (GType object_type, GError** error);
-
-static void block1_data_unref (void * _userdata_) {
- Block1Data* _data1_;
- _data1_ = (Block1Data*) _userdata_;
- if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
- g_object_unref (_data1_->plugin);
- g_object_unref (_data1_->loader);
- g_slice_free (Block1Data, _data1_);
- }
-}
+RygelMediaExportPlugin *rygel_media_export_plugin_construct (GType object_type);
/**
* Simple plugin which exposes the media contents of a directory via UPnP.
*
*/
-void module_init (RygelPluginLoader* loader) {
- Block1Data* _data1_;
- RygelPluginLoader* _tmp0_;
- RygelPluginLoader* _tmp1_;
- RygelPluginLoader* _tmp2_;
- gboolean _tmp3_ = FALSE;
- GError * _inner_error_ = NULL;
- g_return_if_fail (loader != NULL);
- _data1_ = g_slice_new0 (Block1Data);
- _data1_->_ref_count_ = 1;
- _tmp0_ = loader;
- _tmp1_ = g_object_ref (_tmp0_);
- _data1_->loader = _tmp1_;
- _tmp2_ = _data1_->loader;
- _tmp3_ = rygel_plugin_loader_plugin_disabled (_tmp2_, RYGEL_MEDIA_EXPORT_PLUGIN_NAME);
- if (_tmp3_) {
- g_message ("rygel-media-export-plugin.vala:32: Plugin '%s' disabled by user, ignor" \
-"ing..", RYGEL_MEDIA_EXPORT_PLUGIN_NAME);
- block1_data_unref (_data1_);
- _data1_ = NULL;
- return;
- }
- {
- RygelMediaExportPlugin* _tmp4_;
- RygelMediaExportPlugin* _tmp5_;
- _tmp4_ = rygel_media_export_plugin_new (&_inner_error_);
- _tmp5_ = _tmp4_;
- if (_inner_error_ != NULL) {
- goto __catch0_g_error;
- }
- _data1_->plugin = _tmp5_;
- }
- goto __finally0;
- __catch0_g_error:
- {
- GError* _error_ = NULL;
- GError* _tmp6_;
- const gchar* _tmp7_;
- _error_ = _inner_error_;
- _inner_error_ = NULL;
- _tmp6_ = _error_;
- _tmp7_ = _tmp6_->message;
- g_warning ("rygel-media-export-plugin.vala:43: Failed to initialize plugin '%s': %" \
-"s. Ignoring..", RYGEL_MEDIA_EXPORT_PLUGIN_NAME, _tmp7_);
- g_error_free (_error_);
- block1_data_unref (_data1_);
- _data1_ = NULL;
- return;
- }
- __finally0:
- if (_inner_error_ != NULL) {
- block1_data_unref (_data1_);
- _data1_ = 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;
- }
- rygel_plugin_loader_add_plugin (loader, (RygelPlugin*) _data1_->plugin);
- block1_data_unref (_data1_);
+void module_init (RygelPluginLoader *loader) {
+ RygelMediaExportPlugin *plugin = NULL;
+
+ if (rygel_plugin_loader_plugin_disabled (loader, RYGEL_MEDIA_EXPORT_PLUGIN_NAME)) {
+ g_message ("rygel-media-export-plugin.c: Plugin '%s' disabled by user. Ignoring.", RYGEL_MEDIA_EXPORT_PLUGIN_NAME);
+ return;
+ }
+
+ /* Instantiate the plugin object */
+ plugin = rygel_media_export_plugin_new ();
+
+ rygel_plugin_loader_add_plugin (loader, RYGEL_PLUGIN (plugin));
}
-RygelMediaExportPlugin* rygel_media_export_plugin_construct (GType object_type, GError** error) {
- RygelMediaExportPlugin * self = NULL;
- RygelMediaContainer* _tmp0_ = NULL;
- RygelMediaContainer* _tmp1_;
- RygelMediaContainer* _tmp2_;
- GError * _inner_error_ = NULL;
- _tmp0_ = rygel_media_export_root_container_get_instance (&_inner_error_);
- _tmp1_ = _tmp0_;
- if (_inner_error_ != NULL) {
- g_propagate_error (error, _inner_error_);
- g_object_unref (self);
- return NULL;
- }
- _tmp2_ = _tmp1_;
- self = (RygelMediaExportPlugin*) rygel_media_server_plugin_construct (object_type, _tmp2_, RYGEL_MEDIA_EXPORT_PLUGIN_NAME, NULL, RYGEL_PLUGIN_CAPABILITIES_UPLOAD);
- g_object_unref (_tmp2_);
- return self;
+RygelMediaExportPlugin*
+rygel_media_export_plugin_construct (GType object_type) {
+
+ RygelMediaContainer *root = rygel_media_export_root_container_get_instance ();
+ return RYGEL_MEDIA_EXPORT_PLUGIN (rygel_media_server_plugin_construct (object_type,
+ root, RYGEL_MEDIA_EXPORT_PLUGIN_NAME, NULL, RYGEL_PLUGIN_CAPABILITIES_UPLOAD));
}
-RygelMediaExportPlugin* rygel_media_export_plugin_new (GError** error) {
- return rygel_media_export_plugin_construct (RYGEL_MEDIA_EXPORT_TYPE_PLUGIN, error);
+RygelMediaExportPlugin*
+rygel_media_export_plugin_new () {
+ return rygel_media_export_plugin_construct (RYGEL_MEDIA_EXPORT_TYPE_PLUGIN);
}
-static void rygel_media_export_plugin_class_init (RygelMediaExportPluginClass * klass) {
- rygel_media_export_plugin_parent_class = g_type_class_peek_parent (klass);
+static void
+rygel_media_export_plugin_class_init (RygelMediaExportPluginClass *klass) {
+ rygel_media_export_plugin_parent_class = g_type_class_peek_parent (klass);
}
-static void rygel_media_export_plugin_init (RygelMediaExportPlugin * self G_GNUC_UNUSED) {
+static void rygel_media_export_plugin_init (RygelMediaExportPlugin *self G_GNUC_UNUSED) {
}
diff --git a/src/media-export/rygel-media-export-plugin.h b/src/media-export/rygel-media-export-plugin.h
index d51a0c0..f2330a1 100644
--- a/src/media-export/rygel-media-export-plugin.h
+++ b/src/media-export/rygel-media-export-plugin.h
@@ -53,7 +53,7 @@ GType
rygel_media_export_plugin_get_type (void) G_GNUC_CONST;
RygelMediaExportPlugin *
-rygel_media_export_plugin_new (GError **error);
+rygel_media_export_plugin_new ();
void
module_init (RygelPluginLoader *loader);
diff --git a/src/media-export/rygel-media-export-root-container.c b/src/media-export/rygel-media-export-root-container.c
index 1b4111d..1b0870c 100644
--- a/src/media-export/rygel-media-export-root-container.c
+++ b/src/media-export/rygel-media-export-root-container.c
@@ -72,7 +72,6 @@ struct _RygelMediaExportRootContainerSearchData {
static RygelMediaContainer *rygel_media_export_root_container_instance = NULL;
-static GError *rygel_media_export_root_container_creation_error = NULL;
static RygelSearchableContainerIface *parent_searchable_container_iface = NULL;
#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_GET_PRIVATE(o) \
@@ -96,23 +95,9 @@ rygel_media_export_root_container_new (void) {
}
RygelMediaContainer *
-rygel_media_export_root_container_get_instance (GError **error) {
- GError *inner_error = NULL;
-
+rygel_media_export_root_container_get_instance () {
if (!rygel_media_export_root_container_instance) {
- RygelMediaExportRootContainer* root = rygel_media_export_root_container_new ();
- if (inner_error) {
- RygelMediaExportNullContainer *null_container = rygel_media_export_null_container_new ();
-
- rygel_media_export_root_container_instance = RYGEL_MEDIA_CONTAINER (null_container);
- rygel_media_export_root_container_creation_error = inner_error;
- inner_error = NULL;
- } else {
- rygel_media_export_root_container_instance = RYGEL_MEDIA_CONTAINER (root);
- }
- } else if (rygel_media_export_root_container_creation_error) {
- g_propagate_error (error, g_error_copy (rygel_media_export_root_container_creation_error));
- return NULL;
+ rygel_media_export_root_container_instance = RYGEL_MEDIA_CONTAINER (rygel_media_export_root_container_new ());
}
return rygel_media_export_root_container_instance;
diff --git a/src/media-export/rygel-media-export-root-container.h b/src/media-export/rygel-media-export-root-container.h
index 4daf86f..b2168f3 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 (GError **error);
+rygel_media_export_root_container_get_instance ();
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]