[rygel-gst-0-10-plugins] Finished cleanup of harvester.
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-gst-0-10-plugins] Finished cleanup of harvester.
- Date: Tue, 29 Jan 2013 10:10:05 +0000 (UTC)
commit fcd2706232f12de0e6b735027ec62a996e2e8532
Author: Krzesimir Nowak <krnowak openismus com>
Date: Tue Jan 29 11:09:34 2013 +0100
Finished cleanup of harvester.
src/media-export/rygel-media-export-harvester.c | 898 +++++++++++------------
1 files changed, 432 insertions(+), 466 deletions(-)
---
diff --git a/src/media-export/rygel-media-export-harvester.c b/src/media-export/rygel-media-export-harvester.c
index f17f96d..273d377 100644
--- a/src/media-export/rygel-media-export-harvester.c
+++ b/src/media-export/rygel-media-export-harvester.c
@@ -52,36 +52,303 @@ struct _RygelMediaExportHarvesterPrivate {
struct _Block3Data {
- int _ref_count_;
RygelMediaExportHarvester *self;
GFile *file;
};
-#define RYGEL_MEDIA_EXPORT_HARVESTER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvesterPrivate))
+#define RYGEL_MEDIA_EXPORT_HARVESTER_GET_PRIVATE(o) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), \
+ RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, \
+ RygelMediaExportHarvesterPrivate))
+
enum {
RYGEL_MEDIA_EXPORT_HARVESTER_DUMMY_PROPERTY,
RYGEL_MEDIA_EXPORT_HARVESTER_LOCATIONS,
RYGEL_MEDIA_EXPORT_HARVESTER_CANCELLABLE
};
+enum {
+ RYGEL_MEDIA_EXPORT_HARVESTER_SIGNAL_DONE,
+
+ RYGEL_MEDIA_EXPORT_HARVESTER_SIGNALS_COUNT
+};
+
+static guint signals [RYGEL_MEDIA_EXPORT_HARVESTER_SIGNALS_COUNT];
+
#define RYGEL_MEDIA_EXPORT_HARVESTER_FILE_CHANGE_DEFAULT_GRACE_PERIOD ((guint) 5)
-static void rygel_media_export_harvester_set_locations (RygelMediaExportHarvester* self, GeeArrayList* value);
-static void rygel_media_export_harvester_on_file_changed (RygelMediaExportHarvester* self, GFile* file, GFile* other, GFileMonitorEvent event);
-static void rygel_media_export_harvester_on_file_changed_rygel_media_export_recursive_file_monitor_changed (RygelMediaExportRecursiveFileMonitor* _sender, GFile* file, GFile* other_file, GFileMonitorEvent event_type, gpointer self);
-static void rygel_media_export_harvester_on_file_harvested (RygelMediaExportHarvester* self, RygelStateMachine* state_machine);
-static void rygel_media_export_harvester_on_file_harvested_rygel_state_machine_completed (RygelStateMachine* _sender, gpointer self);
-static void rygel_media_export_harvester_on_changes_done (RygelMediaExportHarvester* self, GFile* file, GError** error);
-static void rygel_media_export_harvester_on_file_removed (RygelMediaExportHarvester* self, GFile* file, GError** error);
-static void rygel_media_export_harvester_on_file_added (RygelMediaExportHarvester* self, GFile* file);
-static Block3Data* block3_data_ref (Block3Data* _data3_);
-static void block3_data_unref (void * _userdata_);
-static gboolean __lambda3_ (Block3Data* _data3_);
-static gboolean ___lambda3__gsource_func (gpointer self);
-static void rygel_media_export_harvester_finalize (GObject* obj);
-static void _vala_rygel_media_export_harvester_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
-static void _vala_rygel_media_export_harvester_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
+static void
+rygel_media_export_harvester_on_file_added (RygelMediaExportHarvester *self,
+ GFile *file) {
+ gchar *uri;
+ GError *error = NULL;
+ RygelMediaExportMediaCache *cache;
+ GFileInfo *info;
+ RygelMediaExportHarvesterPrivate *priv;
+
+ g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self));
+ g_return_if_fail (G_IS_FILE (file));
+
+ uri = g_file_get_uri (file);
+ g_debug ("Filesystem events settled for %s, scheduling extractionâ", uri);
+ g_free (uri);
+ cache = rygel_media_export_media_cache_get_default (&error);
+
+ if (error) {
+ g_warning (_("Failed to access media cache: %s"), error->message);
+ g_error_free (error);
+ error = NULL;
+
+ return;
+ }
+ priv = self->priv;
+ info = g_file_query_info (file,
+ G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ G_FILE_QUERY_INFO_NONE,
+ priv->cancellable,
+ &error);
+ if (error) {
+ g_warning ("Failed to query file: %s", error->message);
+ g_error_free (error);
+ error = NULL;
+
+ goto out;
+ }
+ if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY ||
+ g_str_has_prefix (g_file_info_get_content_type (info), "image/") ||
+ g_str_has_prefix (g_file_info_get_content_type (info), "video/") ||
+ g_str_has_prefix (g_file_info_get_content_type (info), "audio/") ||
+ g_strcmp0 (g_file_info_get_content_type (info), "application/ogg")) {
+ RygelMediaContainer *parent_container = NULL;
+ GFile *current = g_object_ref (file);
+ GeeAbstractCollection *abstract_locations = GEE_ABSTRACT_COLLECTION (priv->locations);
+
+ do {
+ GFile *parent = g_file_get_parent (current);
+ gchar *id = rygel_media_export_media_cache_get_id (parent);
+ RygelMediaObject *tmp_object = rygel_media_export_media_cache_get_object (cache, id, &error);
+
+ if (error) {
+ g_warning (_("Error fetching object '%s' from database: %s"),
+ id,
+ error->message);
+ g_free (id);
+ g_object_unref (parent);
+
+ g_error_free (error);
+ error = NULL;
+ goto inner_out;
+ }
+ g_free (id);
+ if (parent_container) {
+ g_object_unref (parent_container);
+ parent_container = NULL;
+ }
+ if (RYGEL_IS_MEDIA_CONTAINER (tmp_object)) {
+ parent_container = RYGEL_MEDIA_CONTAINER (tmp_object);
+ } else {
+ g_object_unref (tmp_object);
+ }
+ if (!parent_container) {
+ g_object_ref (parent);
+ g_object_unref (current);
+ current = parent;
+ }
+ g_object_unref (parent);
+ if (gee_abstract_collection_contains (abstract_locations, current)) {
+ RygelMediaObject* another_object = rygel_media_export_media_cache_get_object (cache,
+ RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID,
+ &error);
+
+ if (error) {
+ goto inner_out;
+ }
+ if (parent_container) {
+ g_object_unref (parent_container);
+ parent_container = NULL;
+ }
+ if (RYGEL_IS_MEDIA_CONTAINER (another_object)) {
+ parent_container = RYGEL_MEDIA_CONTAINER (another_object);
+ }
+ }
+ } while (!parent_container);
+ rygel_media_export_harvester_schedule (self, current, parent_container, NULL);
+ inner_out:
+
+ g_object_unref (current);
+ if (parent_container) {
+ g_object_unref (parent_container);
+ }
+ } else {
+ gchar* file_uri = g_file_get_uri (file);
+
+ g_debug ("%s is not eligible for extraction", file_uri);
+ g_free (file_uri);
+ }
+ out:
+ g_object_unref (cache);
+}
+
+static gboolean
+grace_period_gsource_func (gpointer user_data) {
+ Block3Data *data3 = (Block3Data *) user_data;
+
+ rygel_media_export_harvester_on_file_added (data3->self, data3->file);
+ return FALSE;
+}
+
+static void
+block3_data_free (gpointer user_data) {
+ Block3Data* data3 = (Block3Data*) user_data;
+
+ if (data3) {
+ g_object_unref (data3->file);
+ g_object_unref (data3->self);
+ g_slice_free (Block3Data, data3);
+ }
+}
+
+static void
+rygel_media_export_harvester_on_changes_done (RygelMediaExportHarvester *self,
+ GFile *file,
+ GError **error G_GNUC_UNUSED) {
+ Block3Data* data3;
+ GeeAbstractMap *abstract_grace_timers;
+ guint timeout;
+ RygelMediaExportHarvesterPrivate *priv;
+
+ g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self));
+ g_return_if_fail (G_IS_FILE (file));
+
+ data3 = g_slice_new0 (Block3Data);
+ data3->self = g_object_ref (self);
+ data3->file = g_object_ref (file);
+ priv = self->priv;
+ abstract_grace_timers = GEE_ABSTRACT_MAP (priv->extraction_grace_timers);
+ if (gee_abstract_map_has_key (abstract_grace_timers, file)) {
+ g_source_remove ((guint) ((guintptr) gee_abstract_map_get (abstract_grace_timers, file)));
+ } else {
+ gchar *uri = g_file_get_uri (file);
+ g_debug ("Starting grace timer for harvesting %sâ", uri);
+ g_free (uri);
+ }
+
+ timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT,
+ RYGEL_MEDIA_EXPORT_HARVESTER_FILE_CHANGE_DEFAULT_GRACE_PERIOD,
+ grace_period_gsource_func,
+ data3,
+ block3_data_free);
+ gee_abstract_map_set (abstract_grace_timers, file, (gpointer) ((guintptr) timeout));
+}
+
+static void
+rygel_media_export_harvester_on_file_removed (RygelMediaExportHarvester *self,
+ GFile *file,
+ GError **error) {
+ RygelMediaExportMediaCache *cache;
+ GError *inner_error;
+ GeeAbstractMap *abstract_grace_timers;
+ gchar *id;
+ RygelMediaObject *object;
+ RygelMediaContainer *parent;
+
+ g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self));
+ g_return_if_fail (G_IS_FILE (file));
+
+ inner_error = NULL;
+ cache = rygel_media_export_media_cache_get_default (&inner_error);
+ if (inner_error != NULL) {
+ g_propagate_error (error, inner_error);
+ return;
+ }
+ abstract_grace_timers = GEE_ABSTRACT_MAP (self->priv->extraction_grace_timers);
+ if (gee_abstract_map_has_key (abstract_grace_timers, file)) {
+ g_source_remove ((guint) ((guintptr) gee_abstract_map_get (abstract_grace_timers, file)));
+ gee_abstract_map_unset (abstract_grace_timers, file, NULL);
+ }
+ rygel_media_export_harvester_cancel (self, file);
+ id = rygel_media_export_media_cache_get_id (file);
+ object = rygel_media_export_media_cache_get_object (cache, id, &inner_error);
+
+ if (inner_error) {
+ g_warning ("Failed to get an object with id %s from database: %s",
+ id,
+ inner_error->message);
+ g_error_free (inner_error);
+ goto out;
+ }
+
+ parent = NULL;
+ while (object) {
+ RygelMediaContainer *tmp_parent = rygel_media_object_get_parent (object);
+
+ if (tmp_parent) {
+ g_object_ref (tmp_parent);
+ }
+ if (parent) {
+ g_object_unref (parent);
+ }
+ parent = tmp_parent;
+ rygel_media_export_media_cache_remove_object (cache, object, &inner_error);
+ if (inner_error) {
+ if (parent) {
+ g_object_unref (parent);
+ }
+ g_object_unref (object);
+ g_warning (_("Error removing object from database: %s"),
+ inner_error->message);
+ g_error_free (inner_error);
+
+ goto out;
+ }
+ if (!parent) {
+ break;
+ }
+ rygel_media_container_set_child_count (parent, rygel_media_container_get_child_count (parent) - 1);
+ if (rygel_media_container_get_child_count (parent)) {
+ break;
+ }
+ g_object_ref (parent);
+ g_object_unref (object);
+ object = RYGEL_MEDIA_OBJECT (parent);
+ }
+ if (parent) {
+ rygel_media_container_updated (parent, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
+ }
+ out:
+ if (parent) {
+ g_object_unref (parent);
+ }
+ if (object) {
+ g_object_unref (object);
+ }
+ g_object_unref (cache);
+ g_free (id);
+}
+
+static void
+rygel_media_export_harvester_on_file_changed (RygelMediaExportHarvester *self,
+ GFile *file,
+ GFile *other G_GNUC_UNUSED,
+ GFileMonitorEvent event) {
+ g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self));
+ g_return_if_fail (G_IS_FILE (file));
+
+ switch (event) {
+ case G_FILE_MONITOR_EVENT_CREATED:
+ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+ rygel_media_export_harvester_on_changes_done (self, file, NULL);
+ break;
+
+ case G_FILE_MONITOR_EVENT_DELETED:
+ rygel_media_export_harvester_on_file_removed (self, file, NULL);
+ break;
+
+ default:
+ break;
+ }
+}
static void
rygel_media_export_harvester_on_file_changed_rygel_media_export_recursive_file_monitor_changed (RygelMediaExportRecursiveFileMonitor *sender G_GNUC_UNUSED,
@@ -152,6 +419,36 @@ rygel_media_export_harvester_constructed (GObject *object)
NULL);
}
+/**
+ * Callback for finished harvester.
+ *
+ * Updates book-keeping hash.
+ * @param state_machine HarvestingTask sending the event
+ */
+static void
+rygel_media_export_harvester_on_file_harvested (RygelMediaExportHarvester *self,
+ RygelStateMachine *state_machine) {
+ RygelMediaExportHarvestingTask *task;
+ gchar *uri;
+ GFile *file;
+ RygelMediaExportHarvesterPrivate *priv;
+
+ g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self));
+ g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTING_TASK (state_machine));
+
+ task = RYGEL_MEDIA_EXPORT_HARVESTING_TASK (state_machine);
+ file = task->origin;
+ uri = g_file_get_uri (file);
+ g_message (_("'%s' harvested"), uri);
+ g_free (uri);
+
+ priv = self->priv;
+ gee_abstract_map_unset (GEE_ABSTRACT_MAP (priv->tasks), file, NULL);
+ if (gee_map_get_is_empty (GEE_MAP (priv->tasks))) {
+ g_signal_emit (self, signals[RYGEL_MEDIA_EXPORT_HARVESTER_SIGNAL_DONE], 0);
+ }
+}
+
static void
rygel_media_export_harvester_on_file_harvested_rygel_state_machine_completed (RygelStateMachine *sender,
gpointer user_data) {
@@ -241,429 +538,13 @@ rygel_media_export_harvester_cancel (RygelMediaExportHarvester *self,
}
}
-/**
- * Callback for finished harvester.
- *
- * Updates book-keeping hash.
- * @param state_machine HarvestingTask sending the event
- */
-static void
-rygel_media_export_harvester_on_file_harvested (RygelMediaExportHarvester *self,
- RygelStateMachine *state_machine) {
- RygelMediaExportHarvestingTask *task;
- gchar *uri;
- GFile *file;
- RygelMediaExportHarvesterPrivate *priv;
-
- g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self));
- g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTING_TASK (state_machine));
-
- task = RYGEL_MEDIA_EXPORT_HARVESTING_TASK (state_machine);
- file = task->origin;
- uri = g_file_get_uri (file);
- g_message (_("'%s' harvested"), uri);
- g_free (uri);
-
- priv = self->priv;
- gee_abstract_map_unset (GEE_ABSTRACT_MAP (priv->tasks), file, NULL);
- if (gee_map_get_is_empty (GEE_MAP (priv->tasks))) {
- g_signal_emit_by_name (self, "done");
- }
-}
-
-static void
-rygel_media_export_harvester_on_file_changed (RygelMediaExportHarvester *self,
- GFile *file,
- GFile *other G_GNUC_UNUSED,
- GFileMonitorEvent event) {
- g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self));
- g_return_if_fail (G_IS_FILE (file));
-
- switch (event) {
- case G_FILE_MONITOR_EVENT_CREATED:
- case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
- rygel_media_export_harvester_on_changes_done (self, file, NULL);
- break;
-
- case G_FILE_MONITOR_EVENT_DELETED:
- rygel_media_export_harvester_on_file_removed (self, file, NULL);
- break;
-
- default:
- break;
- }
-}
-
-static void
-rygel_media_export_harvester_on_file_added (RygelMediaExportHarvester *self,
- GFile *file) {
- gchar *uri;
- GError *error = NULL;
- RygelMediaExportMediaCache *cache;
- GFileInfo *info;
- RygelMediaExportHarvesterPrivate *priv;
-
- g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self));
- g_return_if_fail (G_IS_FILE (file));
-
- uri = g_file_get_uri (file);
- g_debug ("Filesystem events settled for %s, scheduling extractionâ", uri);
- g_free (uri);
- cache = rygel_media_export_media_cache_get_default (&error);
-
- if (error) {
- g_warning (_("Failed to access media cache: %s"), error->message);
- g_error_free (error);
- error = NULL;
-
- return;
- }
- priv = self->priv;
- info = g_file_query_info (file,
- G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
- G_FILE_QUERY_INFO_NONE,
- priv->cancellable,
- &error);
- if (error) {
- g_warning ("Failed to query file: %s", error->message);
- g_error_free (error);
- error = NULL;
-
- goto out;
- }
- if (g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY ||
- g_str_has_prefix (g_file_info_get_content_type (info), "image/") ||
- g_str_has_prefix (g_file_info_get_content_type (info), "video/") ||
- g_str_has_prefix (g_file_info_get_content_type (info), "audio/") ||
- g_strcmp0 (g_file_info_get_content_type (info), "application/ogg")) {
- RygelMediaContainer *parent_container = NULL;
- GFile *current = g_object_ref (file);
- GeeAbstractCollection *abstract_locations = GEE_ABSTRACT_COLLECTION (priv->locations);
-
- do {
- GFile *parent = g_file_get_parent (current);
- gchar *id = rygel_media_export_media_cache_get_id (parent);
- RygelMediaObject *tmp_object = rygel_media_export_media_cache_get_object (cache, id, &error);
-
- if (error) {
- g_warning (_("Error fetching object '%s' from database: %s"),
- id,
- error->message);
- g_free (id);
- g_object_unref (parent);
-
- g_error_free (error);
- error = NULL;
-
- goto inner_out;
- }
- g_free (id);
- if (parent_container) {
- g_object_unref (parent_container);
- parent_container = NULL;
- }
- if (RYGEL_IS_MEDIA_CONTAINER (tmp_object)) {
- parent_container = RYGEL_MEDIA_CONTAINER (tmp_object);
- } else {
- g_object_unref (tmp_object);
- }
- if (!parent_container) {
- g_object_ref (parent);
- g_object_unref (current);
- current = parent;
- }
- g_object_unref (parent);
- if (gee_abstract_collection_contains (abstract_locations, current)) {
- RygelMediaObject* another_object = rygel_media_export_media_cache_get_object (cache,
- RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID,
- &error);
-
- if (error) {
- goto inner_out;
- }
- if (parent_container) {
- g_object_unref (parent_container);
- parent_container = NULL;
- }
- if (RYGEL_IS_MEDIA_CONTAINER (another_object)) {
- parent_container = RYGEL_MEDIA_CONTAINER (another_object);
- }
- }
- } while (!parent_container);
- rygel_media_export_harvester_schedule (self, current, parent_container, NULL);
- inner_out:
+GeeArrayList *
+rygel_media_export_harvester_get_locations (RygelMediaExportHarvester *self) {
+ g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTER (self), NULL);
- g_object_unref (current);
- if (parent_container) {
- g_object_unref (parent_container);
- }
- } else {
- gchar* file_uri = g_file_get_uri (file);
-
- g_debug ("%s is not eligible for extraction", file_uri);
- g_free (file_uri);
- }
- out:
- g_object_unref (cache);
+ return self->priv->locations;
}
-
-static void rygel_media_export_harvester_on_file_removed (RygelMediaExportHarvester* self, GFile* file, GError** error) {
- RygelMediaExportMediaCache* _tmp0_ = NULL;
- RygelMediaExportMediaCache* cache;
- GeeHashMap* _tmp1_;
- GFile* _tmp2_;
- gboolean _tmp3_ = FALSE;
- GFile* _tmp9_;
- GError * _inner_error_ = NULL;
- g_return_if_fail (self != NULL);
- g_return_if_fail (file != NULL);
- _tmp0_ = rygel_media_export_media_cache_get_default (&_inner_error_);
- cache = _tmp0_;
- if (_inner_error_ != NULL) {
- g_propagate_error (error, _inner_error_);
- return;
- }
- _tmp1_ = self->priv->extraction_grace_timers;
- _tmp2_ = file;
- _tmp3_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp1_, _tmp2_);
- if (_tmp3_) {
- GeeHashMap* _tmp4_;
- GFile* _tmp5_;
- gpointer _tmp6_ = NULL;
- GeeHashMap* _tmp7_;
- GFile* _tmp8_;
- _tmp4_ = self->priv->extraction_grace_timers;
- _tmp5_ = file;
- _tmp6_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp4_, _tmp5_);
- g_source_remove ((guint) ((guintptr) _tmp6_));
- _tmp7_ = self->priv->extraction_grace_timers;
- _tmp8_ = file;
- gee_abstract_map_unset ((GeeAbstractMap*) _tmp7_, _tmp8_, NULL);
- }
- _tmp9_ = file;
- rygel_media_export_harvester_cancel (self, _tmp9_);
- {
- GFile* _tmp10_;
- gchar* _tmp11_ = NULL;
- gchar* id;
- const gchar* _tmp12_;
- RygelMediaObject* _tmp13_ = NULL;
- RygelMediaObject* object;
- RygelMediaContainer* _tmp14_;
- RygelMediaContainer* parent;
- RygelMediaContainer* _tmp27_;
- _tmp10_ = file;
- _tmp11_ = rygel_media_export_media_cache_get_id (_tmp10_);
- id = _tmp11_;
- _tmp12_ = id;
- _tmp13_ = rygel_media_export_media_cache_get_object (cache, _tmp12_, &_inner_error_);
- object = _tmp13_;
- if (_inner_error_ != NULL) {
- g_free (id);
- goto __catch49_g_error;
- }
- _tmp14_ = g_object_ref (G_TYPE_CHECK_INSTANCE_TYPE (NULL, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) NULL) : NULL);
- parent = _tmp14_;
- while (TRUE) {
- RygelMediaObject* _tmp15_;
- RygelMediaObject* _tmp16_;
- RygelMediaContainer* _tmp17_;
- RygelMediaContainer* _tmp18_;
- RygelMediaObject* _tmp19_;
- RygelMediaContainer* _tmp20_;
- RygelMediaContainer* _tmp21_;
- gint _tmp22_;
- RygelMediaContainer* _tmp23_;
- gint _tmp24_;
- RygelMediaContainer* _tmp25_;
- RygelMediaObject* _tmp26_;
- _tmp15_ = object;
- if (!(_tmp15_ != NULL)) {
- break;
- }
- _tmp16_ = object;
- _tmp17_ = rygel_media_object_get_parent (_tmp16_);
- _tmp18_ = g_object_ref (_tmp17_);
- g_object_unref (parent);
- parent = _tmp18_;
- _tmp19_ = object;
- rygel_media_export_media_cache_remove_object (cache, _tmp19_, &_inner_error_);
- if (_inner_error_ != NULL) {
- g_object_unref (parent);
- g_object_unref (object);
- g_free (id);
- goto __catch49_g_error;
- }
- _tmp20_ = parent;
- if (_tmp20_ == NULL) {
- break;
- }
- _tmp21_ = parent;
- _tmp22_ = rygel_media_container_get_child_count (_tmp21_);
- rygel_media_container_set_child_count (_tmp21_, _tmp22_ - 1);
- _tmp23_ = parent;
- _tmp24_ = rygel_media_container_get_child_count (_tmp23_);
- if (_tmp24_ != 0) {
- break;
- }
- _tmp25_ = parent;
- _tmp26_ = g_object_ref ((RygelMediaObject*) _tmp25_);
- g_object_unref (object);
- object = _tmp26_;
- }
- _tmp27_ = parent;
- if (_tmp27_ != NULL) {
- RygelMediaContainer* _tmp28_;
- _tmp28_ = parent;
- rygel_media_container_updated (_tmp28_, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
- }
- g_object_unref (parent);
- g_object_unref (object);
- g_free (id);
- }
- goto __finally49;
- __catch49_g_error:
- {
- GError* _error_ = NULL;
- const gchar* _tmp29_ = NULL;
- GError* _tmp30_;
- const gchar* _tmp31_;
- _error_ = _inner_error_;
- _inner_error_ = NULL;
- _tmp29_ = _ ("Error removing object from database: %s");
- _tmp30_ = _error_;
- _tmp31_ = _tmp30_->message;
- g_warning (_tmp29_, _tmp31_);
- g_error_free (_error_);
- }
- __finally49:
- if (_inner_error_ != NULL) {
- g_propagate_error (error, _inner_error_);
- g_object_unref (cache);
- return;
- }
- g_object_unref (cache);
-}
-
-
-static Block3Data* block3_data_ref (Block3Data* _data3_) {
- g_atomic_int_inc (&_data3_->_ref_count_);
- return _data3_;
-}
-
-
-static void block3_data_unref (void * _userdata_) {
- Block3Data* _data3_;
- _data3_ = (Block3Data*) _userdata_;
- if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
- RygelMediaExportHarvester * self;
- self = _data3_->self;
- g_object_unref (_data3_->file);
- g_object_unref (self);
- g_slice_free (Block3Data, _data3_);
- }
-}
-
-
-static gboolean __lambda3_ (Block3Data* _data3_) {
- RygelMediaExportHarvester * self;
- gboolean result = FALSE;
- GFile* _tmp0_;
- self = _data3_->self;
- _tmp0_ = _data3_->file;
- rygel_media_export_harvester_on_file_added (self, _tmp0_);
- result = FALSE;
- return result;
-}
-
-
-static gboolean ___lambda3__gsource_func (gpointer self) {
- gboolean result;
- result = __lambda3_ (self);
- return result;
-}
-
-
-static void rygel_media_export_harvester_on_changes_done (RygelMediaExportHarvester* self, GFile* file, GError** error G_GNUC_UNUSED) {
- Block3Data* _data3_;
- GFile* _tmp0_;
- GFile* _tmp1_;
- GeeHashMap* _tmp2_;
- GFile* _tmp3_;
- gboolean _tmp4_ = FALSE;
- GSourceFunc callback;
- void* callback_target;
- GDestroyNotify callback_target_destroy_notify;
- GSourceFunc _tmp11_;
- void* _tmp11__target;
- GDestroyNotify _tmp11__target_destroy_notify;
- guint _tmp12_ = 0U;
- guint timeout;
- GeeHashMap* _tmp13_;
- GFile* _tmp14_;
- g_return_if_fail (self != NULL);
- g_return_if_fail (file != NULL);
- _data3_ = g_slice_new0 (Block3Data);
- _data3_->_ref_count_ = 1;
- _data3_->self = g_object_ref (self);
- _tmp0_ = file;
- _tmp1_ = g_object_ref (_tmp0_);
- g_object_unref (_data3_->file);
- _data3_->file = _tmp1_;
- _tmp2_ = self->priv->extraction_grace_timers;
- _tmp3_ = _data3_->file;
- _tmp4_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp2_, _tmp3_);
- if (_tmp4_) {
- GeeHashMap* _tmp5_;
- GFile* _tmp6_;
- gpointer _tmp7_ = NULL;
- _tmp5_ = self->priv->extraction_grace_timers;
- _tmp6_ = _data3_->file;
- _tmp7_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp5_, _tmp6_);
- g_source_remove ((guint) ((guintptr) _tmp7_));
- } else {
- GFile* _tmp8_;
- gchar* _tmp9_ = NULL;
- gchar* _tmp10_;
- _tmp8_ = _data3_->file;
- _tmp9_ = g_file_get_uri (_tmp8_);
- _tmp10_ = _tmp9_;
- g_debug ("rygel-media-export-harvester.vala:242: Starting grace timer for harves" \
- "ting %sâ", _tmp10_);
- g_free (_tmp10_);
- }
- callback = ___lambda3__gsource_func;
- callback_target = block3_data_ref (_data3_);
- callback_target_destroy_notify = block3_data_unref;
- _tmp11_ = callback;
- _tmp11__target = callback_target;
- _tmp11__target_destroy_notify = callback_target_destroy_notify;
- callback_target_destroy_notify = NULL;
- _tmp12_ = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, RYGEL_MEDIA_EXPORT_HARVESTER_FILE_CHANGE_DEFAULT_GRACE_PERIOD, _tmp11_, _tmp11__target, _tmp11__target_destroy_notify);
- timeout = _tmp12_;
- _tmp13_ = self->priv->extraction_grace_timers;
- _tmp14_ = _data3_->file;
- gee_abstract_map_set ((GeeAbstractMap*) _tmp13_, _tmp14_, (gpointer) ((guintptr) timeout));
- (callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
- callback = NULL;
- callback_target = NULL;
- callback_target_destroy_notify = NULL;
- block3_data_unref (_data3_);
- _data3_ = NULL;
-}
-
-
-GeeArrayList* rygel_media_export_harvester_get_locations (RygelMediaExportHarvester* self) {
- GeeArrayList* result;
- GeeArrayList* _tmp0_;
- g_return_val_if_fail (self != NULL, NULL);
- _tmp0_ = self->priv->locations;
- result = _tmp0_;
- return result;
-}
-
-
static void
rygel_media_export_harvester_set_locations (RygelMediaExportHarvester *self,
GeeArrayList *value) {
@@ -701,60 +582,145 @@ rygel_media_export_harvester_set_locations (RygelMediaExportHarvester *self,
g_object_notify (G_OBJECT (self), "locations");
}
+static void
+rygel_media_export_harvester_dispose (GObject *object) {
+ RygelMediaExportHarvester *self = RYGEL_MEDIA_EXPORT_HARVESTER (object);
+ RygelMediaExportHarvesterPrivate *priv = self->priv;
-static void rygel_media_export_harvester_class_init (RygelMediaExportHarvesterClass * klass) {
- g_type_class_add_private (klass, sizeof (RygelMediaExportHarvesterPrivate));
- G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_harvester_get_property;
- G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_harvester_set_property;
- G_OBJECT_CLASS (klass)->finalize = rygel_media_export_harvester_finalize;
- G_OBJECT_CLASS (klass)->constructed = rygel_media_export_harvester_constructed;
- g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_HARVESTER_LOCATIONS, g_param_spec_object ("locations", "locations", "locations", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
- g_signal_new ("done", RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-}
+ if (priv->tasks) {
+ GeeHashMap *map = priv->tasks;
+ priv->tasks = NULL;
+ g_object_unref (map);
+ }
+ if (priv->extraction_grace_timers) {
+ GeeHashMap *map = priv->extraction_grace_timers;
-static void rygel_media_export_harvester_init (RygelMediaExportHarvester * self) {
- self->priv = RYGEL_MEDIA_EXPORT_HARVESTER_GET_PRIVATE (self);
-}
+ priv->extraction_grace_timers = NULL;
+ g_object_unref (map);
+ }
+ if (priv->extractor) {
+ RygelMediaExportMetadataExtractor *extractor = priv->extractor;
+ priv->extractor = NULL;
+ g_object_unref (extractor);
+ }
+ if (priv->monitor) {
+ RygelMediaExportRecursiveFileMonitor *monitor = priv->monitor;
-static void rygel_media_export_harvester_finalize (GObject* obj) {
- RygelMediaExportHarvester * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvester);
- g_object_unref (self->priv->tasks);
- g_object_unref (self->priv->extraction_grace_timers);
- g_object_unref (self->priv->extractor);
- g_object_unref (self->priv->monitor);
- g_object_unref (self->priv->cancellable);
- g_object_unref (self->priv->locations);
- G_OBJECT_CLASS (rygel_media_export_harvester_parent_class)->finalize (obj);
-}
+ priv->monitor = NULL;
+ g_object_unref (monitor);
+ }
+ if (priv->cancellable) {
+ GCancellable *cancellable = priv->cancellable;
+ priv->cancellable = NULL;
+ g_object_unref (cancellable);
+ }
+ if (priv->locations) {
+ GeeArrayList *locations = priv->locations;
+ priv->locations = NULL;
+ g_object_unref (locations);
+ }
+
+ G_OBJECT_CLASS (rygel_media_export_harvester_parent_class)->dispose (object);
+}
+
+static void
+rygel_media_export_harvester_get_property (GObject *object,
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec) {
+ RygelMediaExportHarvester *self = RYGEL_MEDIA_EXPORT_HARVESTER (object);
-static void _vala_rygel_media_export_harvester_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
- RygelMediaExportHarvester * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvester);
switch (property_id) {
case RYGEL_MEDIA_EXPORT_HARVESTER_LOCATIONS:
g_value_set_object (value, rygel_media_export_harvester_get_locations (self));
break;
+
+ case RYGEL_MEDIA_EXPORT_HARVESTER_CANCELLABLE:
+ g_value_set_object (value, self->priv->cancellable);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
+static void
+rygel_media_export_harvester_set_property (GObject *object,
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec) {
+ RygelMediaExportHarvester *self = RYGEL_MEDIA_EXPORT_HARVESTER (object);
-static void _vala_rygel_media_export_harvester_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
- RygelMediaExportHarvester * self;
- self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvester);
switch (property_id) {
case RYGEL_MEDIA_EXPORT_HARVESTER_LOCATIONS:
+ /* construct-only property */
rygel_media_export_harvester_set_locations (self, g_value_get_object (value));
break;
+
+ case RYGEL_MEDIA_EXPORT_HARVESTER_CANCELLABLE:
+ /* construct-only property */
+ self->priv->cancellable = g_value_dup_object (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
+
+static void
+rygel_media_export_harvester_class_init (RygelMediaExportHarvesterClass *harvester_class) {
+ GObjectClass *object_class = G_OBJECT_CLASS (harvester_class);
+
+ object_class->get_property = rygel_media_export_harvester_get_property;
+ object_class->set_property = rygel_media_export_harvester_set_property;
+ object_class->dispose = rygel_media_export_harvester_dispose;
+ object_class->constructed = rygel_media_export_harvester_constructed;
+ g_object_class_install_property (object_class,
+ RYGEL_MEDIA_EXPORT_HARVESTER_LOCATIONS,
+ g_param_spec_object ("locations",
+ "locations",
+ "locations",
+ GEE_TYPE_ARRAY_LIST,
+ 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,
+ RYGEL_MEDIA_EXPORT_HARVESTER_CANCELLABLE,
+ g_param_spec_object ("cancellable",
+ "cancellable",
+ "cancellable",
+ G_TYPE_CANCELLABLE,
+ G_PARAM_STATIC_NAME |
+ G_PARAM_STATIC_NICK |
+ G_PARAM_STATIC_BLURB |
+ G_PARAM_READABLE |
+ G_PARAM_WRITABLE |
+ G_PARAM_CONSTRUCT_ONLY));
+
+ signals[RYGEL_MEDIA_EXPORT_HARVESTER_SIGNAL_DONE] = g_signal_new ("done",
+ RYGEL_MEDIA_EXPORT_TYPE_HARVESTER,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ NULL, /* generic marshaller */
+ G_TYPE_NONE,
+ 0);
+
+ g_type_class_add_private (harvester_class,
+ sizeof (RygelMediaExportHarvesterPrivate));
+}
+
+static void
+rygel_media_export_harvester_init (RygelMediaExportHarvester *self) {
+ self->priv = RYGEL_MEDIA_EXPORT_HARVESTER_GET_PRIVATE (self);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]