[rygel-gst-0-10-plugins] cleanup RygelMediaExportMusicItem
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-gst-0-10-plugins] cleanup RygelMediaExportMusicItem
- Date: Wed, 30 Jan 2013 10:01:26 +0000 (UTC)
commit 81f730bb4a4ce4fd52b9290cff17e4f98733006d
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Jan 30 11:01:19 2013 +0100
cleanup RygelMediaExportMusicItem
src/media-export/rygel-media-export-music-item.c | 178 +++++++++-------------
1 files changed, 70 insertions(+), 108 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-music-item.c b/src/media-export/rygel-media-export-music-item.c
index 844d66b..b7bad1f 100644
--- a/src/media-export/rygel-media-export-music-item.c
+++ b/src/media-export/rygel-media-export-music-item.c
@@ -23,139 +23,101 @@
#include "rygel-media-export-music-item.h"
#include "rygel-media-export-media-cache.h"
-static void rygel_media_export_music_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface);
+static void rygel_media_export_music_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface *iface);
-G_DEFINE_TYPE_WITH_CODE (RygelMediaExportMusicItem,
- rygel_media_export_music_item,
- RYGEL_TYPE_MUSIC_ITEM,
- G_IMPLEMENT_INTERFACE (RYGEL_TYPE_UPDATABLE_OBJECT,
- rygel_media_export_music_item_rygel_updatable_object_interface_init))
+G_DEFINE_TYPE_WITH_CODE (RygelMediaExportMusicItem, rygel_media_export_music_item, RYGEL_TYPE_MUSIC_ITEM,
+ G_IMPLEMENT_INTERFACE (RYGEL_TYPE_UPDATABLE_OBJECT, rygel_media_export_music_item_rygel_updatable_object_interface_init))
typedef struct _RygelMediaExportMusicItemCommitData RygelMediaExportMusicItemCommitData;
struct _RygelMediaExportMusicItemCommitData {
- int _state_;
- GObject* _source_object_;
- GAsyncResult* _res_;
- GSimpleAsyncResult* _async_result;
- RygelMediaExportMusicItem* self;
- RygelMediaExportMediaCache* _tmp0_;
- RygelMediaExportMediaCache* cache;
- RygelMediaExportMediaCache* _tmp1_;
- GError * _inner_error_;
+ RygelMediaExportMusicItem *self;
+ GSimpleAsyncResult *async_result;
+ RygelMediaExportMediaCache *cache;
+ GError *error;
};
-static void rygel_media_export_music_item_real_commit_data_free (gpointer _data);
-static void rygel_media_export_music_item_real_commit (RygelUpdatableObject* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
-static gboolean rygel_media_export_music_item_real_commit_co (RygelMediaExportMusicItemCommitData* _data_);
-
-
-RygelMediaExportMusicItem* rygel_media_export_music_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class) {
- RygelMediaExportMusicItem * self = NULL;
- const gchar* _tmp0_;
- RygelMediaContainer* _tmp1_;
- const gchar* _tmp2_;
- const gchar* _tmp3_;
- g_return_val_if_fail (id != NULL, NULL);
- g_return_val_if_fail (parent != NULL, NULL);
- g_return_val_if_fail (title != NULL, NULL);
- g_return_val_if_fail (upnp_class != NULL, NULL);
- _tmp0_ = id;
- _tmp1_ = parent;
- _tmp2_ = title;
- _tmp3_ = upnp_class;
- self = (RygelMediaExportMusicItem*) rygel_music_item_construct (object_type, _tmp0_, _tmp1_, _tmp2_, _tmp3_);
- return self;
-}
+static void rygel_media_export_music_item_real_commit (RygelUpdatableObject *base, GAsyncReadyCallback callback_, gpointer user_data);
+
+/* TODO: Remove the construct function? */
+RygelMediaExportMusicItem *rygel_media_export_music_item_construct (GType object_type, const gchar *id, RygelMediaContainer *parent, const gchar *title, const gchar *upnp_class) {
+ RygelMediaExportMusicItem *self;
+ g_return_val_if_fail (id, NULL);
+ g_return_val_if_fail (parent, NULL);
+ g_return_val_if_fail (title, NULL);
+ g_return_val_if_fail (upnp_class, NULL);
-RygelMediaExportMusicItem* rygel_media_export_music_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class) {
- return rygel_media_export_music_item_construct (RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, id, parent, title, upnp_class);
+ return RYGEL_MEDIA_EXPORT_MUSIC_ITEM (rygel_music_item_construct (object_type, id, parent, title, upnp_class));
}
-static void rygel_media_export_music_item_real_commit_data_free (gpointer _data) {
- RygelMediaExportMusicItemCommitData* _data_;
- _data_ = _data;
- g_object_unref (_data_->self);
- g_slice_free (RygelMediaExportMusicItemCommitData, _data_);
+RygelMediaExportMusicItem *rygel_media_export_music_item_new (const gchar *id, RygelMediaContainer *parent, const gchar *title, const gchar *upnp_class) {
+ return rygel_media_export_music_item_construct (RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, id, parent, title, upnp_class);
}
-static void rygel_media_export_music_item_real_commit (RygelUpdatableObject* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
- RygelMediaExportMusicItem * self;
- RygelMediaExportMusicItemCommitData* _data_;
- RygelMediaExportMusicItem* _tmp0_;
- self = (RygelMediaExportMusicItem*) base;
- _data_ = g_slice_new0 (RygelMediaExportMusicItemCommitData);
- _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_music_item_real_commit);
- g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_music_item_real_commit_data_free);
- _tmp0_ = g_object_ref (self);
- _data_->self = _tmp0_;
- rygel_media_export_music_item_real_commit_co (_data_);
+static void rygel_media_export_music_item_real_commit (RygelUpdatableObject *base, GAsyncReadyCallback callback, gpointer user_data) {
+ RygelMediaExportMusicItem *self = RYGEL_MEDIA_EXPORT_MUSIC_ITEM (base);
+
+ g_return_if_fail (self);
+ g_return_if_fail (callback);
+
+ /* Create a data structure to hold our state
+ * during the async call.
+ */
+ RygelMediaExportMusicItemCommitData *data =
+ g_slice_new0 (RygelMediaExportMusicItemCommitData);
+ data->self = self;
+ g_object_ref (data->self);
+
+ /* Setup the async result.
+ */
+ data->async_result =
+ g_simple_async_result_new (G_OBJECT (self), callback, user_data,
+ rygel_media_export_music_item_real_commit);
+
+ data->cache =
+ rygel_media_export_media_cache_get_default (&data->error);
+
+ /* Do the work that could take a while.
+ */
+ rygel_media_export_media_cache_save_item (data->cache,
+ RYGEL_MEDIA_ITEM (data->self), &data->error);
+
+ /* Set the error in the async result, if necessary.
+ */
+ if (data->error) {
+ g_simple_async_result_set_from_error (data->async_result, data->error);
+ g_error_free (data->error);
+ }
+
+ /* Let the caller know that the async operation is finished,
+ * and that its result is now available.
+ */
+ g_simple_async_result_complete (data->async_result);
+
+ /* Free our data structure. */
+ g_object_unref (data->self);
+ g_object_unref (data->async_result);
+ g_object_unref (data->cache);
+ g_slice_free (RygelMediaExportMusicItemCommitData, data);
}
-static void rygel_media_export_music_item_real_commit_finish (RygelUpdatableObject* base G_GNUC_UNUSED, GAsyncResult* _res_, GError** error) {
+static void rygel_media_export_music_item_real_commit_finish (RygelUpdatableObject *base G_GNUC_UNUSED, GAsyncResult *_res_, GError **error) {
g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error);
}
-static gboolean rygel_media_export_music_item_real_commit_co (RygelMediaExportMusicItemCommitData* _data_) {
- switch (_data_->_state_) {
- case 0:
- goto _state_0;
- default:
- g_assert_not_reached ();
- }
- _state_0:
- _data_->_tmp0_ = NULL;
- _data_->_tmp0_ = rygel_media_export_media_cache_get_default (&_data_->_inner_error_);
- _data_->cache = _data_->_tmp0_;
- 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_->_tmp1_ = _data_->cache;
- rygel_media_export_media_cache_save_item (_data_->_tmp1_, (RygelMediaItem*) _data_->self, &_data_->_inner_error_);
- 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_->cache);
- 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_->cache);
- 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_music_item_class_init (RygelMediaExportMusicItemClass *klass G_GNUC_UNUSED) {
}
-static void rygel_media_export_music_item_class_init (RygelMediaExportMusicItemClass * klass G_GNUC_UNUSED) {
+static void rygel_media_export_music_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface *iface) {
+ iface->commit = rygel_media_export_music_item_real_commit;
+ iface->commit_finish = rygel_media_export_music_item_real_commit_finish;
}
-static void rygel_media_export_music_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface) {
- iface->commit = rygel_media_export_music_item_real_commit;
- iface->commit_finish = rygel_media_export_music_item_real_commit_finish;
-}
-
-
-static void rygel_media_export_music_item_init (RygelMediaExportMusicItem * self G_GNUC_UNUSED) {
+static void rygel_media_export_music_item_init (RygelMediaExportMusicItem *self G_GNUC_UNUSED) {
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]