[rygel-gst-0-10-plugins] Initial port to C. Does not build yet.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-gst-0-10-plugins] Initial port to C. Does not build yet.
- Date: Fri, 11 Jan 2013 09:17:29 +0000 (UTC)
commit 0bf4034456891180b6d6f455de89e3e4a654526d
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Jan 11 10:17:06 2013 +0100
Initial port to C. Does not build yet.
configure.ac | 28 +-
src/media-export/Makefile.am | 69 +-
src/media-export/rygel-media-export-collate.c | 3 +-
...-function.vala => rygel-media-export-collate.h} | 21 +-
.../rygel-media-export-database-cursor.c | 633 +++
.../rygel-media-export-database-cursor.h | 56 +
.../rygel-media-export-database-cursor.vala | 143 -
src/media-export/rygel-media-export-database.c | 680 +++
src/media-export/rygel-media-export-database.h | 61 +
src/media-export/rygel-media-export-database.vala | 214 -
src/media-export/rygel-media-export-db-container.c | 731 ++++
src/media-export/rygel-media-export-db-container.h | 59 +
.../rygel-media-export-db-container.vala | 99 -
src/media-export/rygel-media-export-dbus-service.c | 382 ++
src/media-export/rygel-media-export-dbus-service.h | 55 +
.../rygel-media-export-dbus-service.vala | 54 -
.../rygel-media-export-dummy-container.c | 189 +
.../rygel-media-export-dummy-container.h | 56 +
.../rygel-media-export-dummy-container.vala | 45 -
src/media-export/rygel-media-export-harvester.c | 1055 +++++
src/media-export/rygel-media-export-harvester.h | 61 +
src/media-export/rygel-media-export-harvester.vala | 256 --
.../rygel-media-export-harvesting-task.c | 1551 +++++++
.../rygel-media-export-harvesting-task.h | 57 +
.../rygel-media-export-harvesting-task.vala | 366 --
src/media-export/rygel-media-export-item-factory.c | 1040 +++++
src/media-export/rygel-media-export-item-factory.h | 46 +
src/media-export/rygel-media-export-item.vala | 268 --
src/media-export/rygel-media-export-jpeg-writer.c | 219 +
src/media-export/rygel-media-export-jpeg-writer.h | 61 +
.../rygel-media-export-jpeg-writer.vala | 66 -
.../rygel-media-export-leaf-query-container.c | 391 ++
.../rygel-media-export-leaf-query-container.vala | 53 -
.../rygel-media-export-media-cache-upgrader.c | 2179 ++++++++++
.../rygel-media-export-media-cache-upgrader.h | 56 +
.../rygel-media-export-media-cache-upgrader.vala | 368 --
src/media-export/rygel-media-export-media-cache.c | 4477 ++++++++++++++++++++
src/media-export/rygel-media-export-media-cache.h | 69 +
.../rygel-media-export-media-cache.vala | 896 ----
.../rygel-media-export-metadata-extractor.c | 431 ++
.../rygel-media-export-metadata-extractor.h | 62 +
.../rygel-media-export-metadata-extractor.vala | 155 -
src/media-export/rygel-media-export-music-item.c | 191 +
src/media-export/rygel-media-export-music-item.h | 62 +
.../rygel-media-export-music-item.vala | 43 -
.../rygel-media-export-node-query-container.c | 585 +++
.../rygel-media-export-node-query-container.vala | 91 -
.../rygel-media-export-null-container.c | 263 ++
.../rygel-media-export-null-container.h | 52 +
.../rygel-media-export-null-container.vala | 47 -
.../rygel-media-export-object-factory.c | 441 ++
.../rygel-media-export-object-factory.vala | 91 -
src/media-export/rygel-media-export-photo-item.c | 182 +
src/media-export/rygel-media-export-photo-item.h | 55 +
.../rygel-media-export-photo-item.vala | 37 -
src/media-export/rygel-media-export-plugin.c | 450 ++
src/media-export/rygel-media-export-plugin.h | 57 +
src/media-export/rygel-media-export-plugin.vala | 113 -
.../rygel-media-export-query-container-factory.c | 920 ++++
...rygel-media-export-query-container-factory.vala | 268 --
.../rygel-media-export-query-container.c | 364 ++
.../rygel-media-export-query-container.h | 57 +
.../rygel-media-export-query-container.vala | 90 -
.../rygel-media-export-recursive-file-monitor.c | 469 ++
.../rygel-media-export-recursive-file-monitor.h | 61 +
.../rygel-media-export-recursive-file-monitor.vala | 113 -
.../rygel-media-export-root-container.c | 2353 ++++++++++
.../rygel-media-export-root-container.h | 54 +
.../rygel-media-export-root-container.vala | 484 ---
src/media-export/rygel-media-export-sql-factory.c | 287 ++
src/media-export/rygel-media-export-sql-factory.h | 61 +
.../rygel-media-export-sql-factory.vala | 305 --
src/media-export/rygel-media-export-sql-function.c | 78 +
src/media-export/rygel-media-export-sql-function.h | 56 +
src/media-export/rygel-media-export-sql-operator.c | 190 +
src/media-export/rygel-media-export-sql-operator.h | 69 +
.../rygel-media-export-sql-operator.vala | 73 -
.../rygel-media-export-sqlite-wrapper.c | 235 +
.../rygel-media-export-sqlite-wrapper.h | 61 +
.../rygel-media-export-sqlite-wrapper.vala | 80 -
src/media-export/rygel-media-export-video-item.c | 187 +
src/media-export/rygel-media-export-video-item.h | 61 +
.../rygel-media-export-video-item.vala | 37 -
.../rygel-media-export-writable-db-container.c | 509 +++
.../rygel-media-export-writable-db-container.vala | 55 -
tests/Makefile.am | 4 +-
tests/test_simple.c | 23 +-
87 files changed, 23133 insertions(+), 4992 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 89be903..5fa2600 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@ AC_INIT([rygel-gst-0-10-plugins],
[http://live.gnome.org/Rygel])
AC_CONFIG_AUX_DIR([build-aux])
-AC_CONFIG_SRCDIR([src/media-export/rygel-media-export-plugin.vala])
+AC_CONFIG_SRCDIR([src/media-export/rygel-media-export-plugin.c])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
@@ -44,7 +44,7 @@ LIBSQLITE3_REQUIRED=3.5
RYGEL_BASE_MODULES='gupnp-1.0 >= $GUPNP_REQUIRED gee-0.8 >= $GEE_REQUIRED'
RYGEL_COMMON_MODULES="$RYGEL_BASE_MODULES gupnp-av-1.0 >= $GUPNP_AV_REQUIRED"
-PKG_CHECK_MODULES([RYGEL_PLUGIN_MEDIA_EXPORT_DEPS], [$RYGEL_COMMON_MODULES rygel-server-2.0 >= $LIBRYGEL_SERVER_REQUIRED gio-2.0 >= $GIO_REQUIRED gupnp-dlna-1.0 >= $GUPNP_DLNA_REQUIRED gstreamer-tag-0.10 >= $GSTREAMER_TAG_REQUIRED gstreamer-app-0.10 >= $GSTREAMER_TAG_REQUIRED sqlite3 >= $LIBSQLITE3_REQUIRED])
+PKG_CHECK_MODULES([DEPS], [$RYGEL_COMMON_MODULES rygel-server-2.0 >= $LIBRYGEL_SERVER_REQUIRED gio-2.0 >= $GIO_REQUIRED gupnp-dlna-1.0 >= $GUPNP_DLNA_REQUIRED gstreamer-tag-0.10 >= $GSTREAMER_TAG_REQUIRED gstreamer-app-0.10 >= $GSTREAMER_TAG_REQUIRED sqlite3 >= $LIBSQLITE3_REQUIRED])
AC_CHECK_HEADER([unistr.h],
AC_CHECK_LIB([unistring],
@@ -59,27 +59,6 @@ if test "x$have_unistring" = "xyes"; then
fi
-RYGEL_BASE_MODULES_VALAFLAGS='--pkg gupnp-1.0 --pkg gee-0.8'
-RYGEL_COMMON_MODULES_VALAFLAGS="$RYGEL_BASE_MODULES_VALAFLAGS --pkg gupnp-av-1.0"
-RYGEL_PLUGIN_MEDIA_EXPORT_DEPS_VALAFLAGS="$RYGEL_COMMON_MODULES_VALAFLAGS --pkg rygel-server-2.0 --pkg gupnp-1.0 --pkg gee-0.8 --pkg gio-2.0 --pkg gupnp-dlna-1.0 --pkg gstreamer-tag-0.10 --pkg gstreamer-app-0.10 --pkg sqlite3"
-AC_SUBST([RYGEL_PLUGIN_MEDIA_EXPORT_DEPS_VALAFLAGS])
-
-VALA_REQUIRED=0.16.1
-VALA_REQUIRED_MODULES='rygel-server-2.0 gupnp-1.0 gee-0.8 gio-2.0 gupnp-dlna-1.0 gstreamer-0.10 gstreamer-base-0.10 gstreamer-tag-0.10 gstreamer-app-0.10 sqlite3 posix'
-RYGEL_CHECK_VALA([$VALA_REQUIRED],
- [$VALA_REQUIRED_MODULES])
-
-dnl Debugging
-AC_ARG_ENABLE(debug,
- AS_HELP_STRING([--enable-debug],[enable debugging]),,
- enable_debug=no)
-if test "x$enable_debug" = "xyes"; then
- CFLAGS="$CFLAGS -O0 -g"
- RYGEL_DEBUG_VALAFLAGS="-g"
-fi
-
-AC_SUBST(RYGEL_DEBUG_VALAFLAGS)
-
dnl Strict compiler
AC_ARG_ENABLE(strict-cc,
AS_HELP_STRING([--enable-strict-cc],[enable strict C compiler]),,
@@ -90,8 +69,6 @@ else
CFLAGS="$CFLAGS -w"
fi
-VALAFLAGS="--target-glib=2.32 $VALAFLAGS"
-
dnl Gettext
GETTEXT_PACKAGE=rygel-gst-0-10-plugins
@@ -125,5 +102,4 @@ echo "
Source code location: ${srcdir}
Compiler: ${CC}
CFLAGS: ${CFLAGS}
- VALAFLAGS: ${VALAFLAGS}
"
diff --git a/src/media-export/Makefile.am b/src/media-export/Makefile.am
index 1fb90d4..6c49854 100644
--- a/src/media-export/Makefile.am
+++ b/src/media-export/Makefile.am
@@ -1,52 +1,41 @@
include $(top_srcdir)/data/common.am
-plugin_LTLIBRARIES = librygel-media-export-gst-0-10.la
-plugindir = $(libdir)/rygel-2.0/plugins
+export_LTLIBRARIES = librygel-media-export-gst-0-10.la
+exportdir = $(libdir)/rygel-2.0/exports
librygel_media_export_gst_0_10_la_SOURCES = \
- rygel-media-export-plugin.vala \
- rygel-media-export-database.vala \
- rygel-media-export-database-cursor.vala \
- rygel-media-export-sqlite-wrapper.vala \
- rygel-media-export-db-container.vala \
- rygel-media-export-sql-factory.vala \
- rygel-media-export-media-cache.vala \
- rygel-media-export-sql-operator.vala \
- rygel-media-export-sql-function.vala \
- rygel-media-export-media-cache-upgrader.vala \
- rygel-media-export-metadata-extractor.vala \
- rygel-media-export-null-container.vala \
- rygel-media-export-dummy-container.vala \
- rygel-media-export-root-container.vala \
- rygel-media-export-query-container.vala \
- rygel-media-export-query-container-factory.vala \
- rygel-media-export-node-query-container.vala \
- rygel-media-export-leaf-query-container.vala \
- rygel-media-export-dbus-service.vala \
- rygel-media-export-recursive-file-monitor.vala \
- rygel-media-export-harvester.vala \
- rygel-media-export-harvesting-task.vala \
- rygel-media-export-item.vala \
- rygel-media-export-jpeg-writer.vala \
- rygel-media-export-object-factory.vala \
- rygel-media-export-writable-db-container.vala \
- rygel-media-export-music-item.vala \
- rygel-media-export-video-item.vala \
- rygel-media-export-photo-item.vala \
- rygel-media-export-collate.c
-
-librygel_media_export_gst_0_10_la_VALAFLAGS = \
- $(RYGEL_PLUGIN_MEDIA_EXPORT_DEPS_VALAFLAGS)
+ rygel-media-export-collate.c \
+ rygel-media-export-database.c \
+ rygel-media-export-database-cursor.c \
+ rygel-media-export-db-container.c \
+ rygel-media-export-dbus-service.c \
+ rygel-media-export-dummy-container.c \
+ rygel-media-export-harvester.c \
+ rygel-media-export-harvesting-task.c \
+ rygel-media-export-item-factory.c \
+ rygel-media-export-media-cache.c \
+ rygel-media-export-media-cache-upgrader.c \
+ rygel-media-export-metadata-extractor.c \
+ rygel-media-export-music-item.c \
+ rygel-media-export-null-container.c \
+ rygel-media-export-photo-item.c \
+ rygel-media-export-plugin.c \
+ rygel-media-export-query-container.c \
+ rygel-media-export-root-container.c \
+ rygel-media-export-sql-factory.c \
+ rygel-media-export-sql-function.c \
+ rygel-media-export-sql-operator.c \
+ rygel-media-export-sqlite-wrapper.c \
+ rygel-media-export-video-item.c
librygel_media_export_gst_0_10_la_CFLAGS = \
- $(RYGEL_PLUGIN_MEDIA_EXPORT_DEPS_CFLAGS) \
- $(COLLATION_CFLAGS) \
+ -DG_LOG_DOMAIN='"MediaExport-GStreamer-0.10"' \
+ -DPRESET_DIR='"$(presetdir)"' \
-include config.h \
- -DG_LOG_DOMAIN='"MediaExport-gst-0-10"'
+ $(DEPS_CFLAGS)
librygel_media_export_gst_0_10_la_LIBADD = \
- $(RYGEL_PLUGIN_MEDIA_EXPORT_DEPS_LIBS) \
- $(COLLATION_LIBS)
+ $(DEPS_LIBS)
librygel_media_export_gst_0_10_la_LDFLAGS = $(RYGEL_PLUGIN_LINKER_FLAGS)
diff --git a/src/media-export/rygel-media-export-collate.c b/src/media-export/rygel-media-export-collate.c
index eccf527..1cfaf48 100644
--- a/src/media-export/rygel-media-export-collate.c
+++ b/src/media-export/rygel-media-export-collate.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2012 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
*
* Author: Jens Georg <mail jensge org>
*
@@ -20,7 +21,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include <glib.h>
+#include "rygel-media-export-collate.h"
#ifdef HAVE_UNISTRING
#include <unistr.h>
diff --git a/src/media-export/rygel-media-export-sql-function.vala b/src/media-export/rygel-media-export-collate.h
similarity index 69%
rename from src/media-export/rygel-media-export-sql-function.vala
rename to src/media-export/rygel-media-export-collate.h
index 0ff0a80..66de26c 100644
--- a/src/media-export/rygel-media-export-sql-function.vala
+++ b/src/media-export/rygel-media-export-collate.h
@@ -1,7 +1,5 @@
/*
- * Copyright (C) 2010 Jens Georg <mail jensge org>.
- *
- * Author: Jens Georg <mail jensge org>
+ * Copyright (C) 2012 Intel Corporation.
*
* This file is part of Rygel.
*
@@ -20,12 +18,13 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-internal class Rygel.MediaExport.SqlFunction : SqlOperator {
- public SqlFunction (string name, string arg) {
- base (name, arg);
- }
+#ifndef __RYGEL_GST_0_10_PLUGINS_MEDIA_EXPORT_COLLATE_H__
+#define __RYGEL_GST_0_10_PLUGINS_MEDIA_EXPORT_COLLATE_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+gint rygel_media_export_utf8_collate_str (const char *a, const char *b);
- public override string to_string () {
- return "%s(%s,?)".printf (name, arg);
- }
-}
+#endif /* __RYGEL_GST_0_10_PLUGINS_MEDIA_EXPORT_COLLATE_H__ */
diff --git a/src/media-export/rygel-media-export-database-cursor.c b/src/media-export/rygel-media-export-database-cursor.c
new file mode 100644
index 0000000..9e73b7c
--- /dev/null
+++ b/src/media-export/rygel-media-export-database-cursor.c
@@ -0,0 +1,633 @@
+/* rygel-media-export-database-cursor.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-database-cursor.vala, do not modify */
+
+/*
+ * Copyright (C) 2011 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#include "rygel-media-export-database-cursor.h"
+#include "rygel-media-export-database.h"
+#include <gobject/gvaluecollector.h>
+
+
+G_DEFINE_TYPE (RygelMediaExportDatabaseCursor, rygel_media_export_database_cursor, RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER)
+
+#define _sqlite3_finalize0(var) ((var == NULL) ? NULL : (var = (sqlite3_finalize (var), NULL)))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR (rygel_media_export_database_cursor_iterator_get_type ())
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIterator))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIteratorClass))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIteratorClass))
+
+typedef struct _RygelMediaExportDatabaseCursorIterator RygelMediaExportDatabaseCursorIterator;
+typedef struct _RygelMediaExportDatabaseCursorIteratorClass RygelMediaExportDatabaseCursorIteratorClass;
+typedef struct _RygelMediaExportDatabaseCursorIteratorPrivate RygelMediaExportDatabaseCursorIteratorPrivate;
+typedef struct _RygelMediaExportDatabaseCursorParamSpecIterator RygelMediaExportDatabaseCursorParamSpecIterator;
+
+struct _RygelMediaExportDatabaseCursorPrivate {
+ sqlite3_stmt* statement;
+ gint current_state;
+ gboolean dirty;
+};
+
+struct _RygelMediaExportDatabaseCursorIterator {
+ GTypeInstance parent_instance;
+ volatile int ref_count;
+ RygelMediaExportDatabaseCursorIteratorPrivate * priv;
+ RygelMediaExportDatabaseCursor* cursor;
+};
+
+struct _RygelMediaExportDatabaseCursorIteratorClass {
+ GTypeClass parent_class;
+ void (*finalize) (RygelMediaExportDatabaseCursorIterator *self);
+};
+
+struct _RygelMediaExportDatabaseCursorParamSpecIterator {
+ GParamSpec parent_instance;
+};
+
+
+static gpointer rygel_media_export_database_cursor_iterator_parent_class = NULL;
+
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_DUMMY_PROPERTY
+};
+GQuark rygel_media_export_database_error_quark (void);
+
+RygelMediaExportDatabaseCursor* rygel_media_export_database_cursor_construct (GType object_type, sqlite3* db, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_new_wrap (sqlite3* db);
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_construct_wrap (GType object_type, sqlite3* db);
+void rygel_media_export_sqlite_wrapper_throw_if_code_is_error (RygelMediaExportSqliteWrapper* self, gint sqlite_error, GError** error);
+void rygel_media_export_sqlite_wrapper_throw_if_db_has_error (RygelMediaExportSqliteWrapper* self, GError** error);
+gboolean rygel_media_export_database_cursor_has_next (RygelMediaExportDatabaseCursor* self);
+sqlite3_stmt* rygel_media_export_database_cursor_next (RygelMediaExportDatabaseCursor* self, GError** error);
+gpointer rygel_media_export_database_cursor_iterator_ref (gpointer instance);
+void rygel_media_export_database_cursor_iterator_unref (gpointer instance);
+GParamSpec* rygel_media_export_database_cursor_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
+void rygel_media_export_database_cursor_value_set_iterator (GValue* value, gpointer v_object);
+void rygel_media_export_database_cursor_value_take_iterator (GValue* value, gpointer v_object);
+gpointer rygel_media_export_database_cursor_value_get_iterator (const GValue* value);
+GType rygel_media_export_database_cursor_iterator_get_type (void) G_GNUC_CONST;
+RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator (RygelMediaExportDatabaseCursor* self);
+RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator_new (RygelMediaExportDatabaseCursor* cursor);
+RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator_construct (GType object_type, RygelMediaExportDatabaseCursor* cursor);
+enum {
+ RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_DUMMY_PROPERTY
+};
+gboolean rygel_media_export_database_cursor_iterator_next (RygelMediaExportDatabaseCursorIterator* self);
+sqlite3_stmt* rygel_media_export_database_cursor_iterator_get (RygelMediaExportDatabaseCursorIterator* self, GError** error);
+static void rygel_media_export_database_cursor_iterator_finalize (RygelMediaExportDatabaseCursorIterator* obj);
+static void rygel_media_export_database_cursor_finalize (GObject* obj);
+
+
+/**
+ * Prepare a SQLite statement from a SQL string
+ *
+ * This function uses the type of the GValue passed in values to determine
+ * which _bind function to use.
+ *
+ * Supported types are: int, long, int64, uint64, string and pointer.
+ * @note the only pointer supported is the null pointer as provided by
+ * Database null This is a special value to bind a column to NULL
+ *
+ * @param db SQLite database this cursor belongs to
+ * @param sql statement to execute
+ * @param values array of values to bind to the SQL statement or null if
+ * none
+ */
+RygelMediaExportDatabaseCursor* rygel_media_export_database_cursor_construct (GType object_type, sqlite3* db, const gchar* sql, GValue* arguments, int arguments_length1, GError** error) {
+ RygelMediaExportDatabaseCursor * self = NULL;
+ sqlite3* _tmp0_;
+ sqlite3* _tmp1_;
+ const gchar* _tmp2_;
+ sqlite3_stmt* _tmp3_ = NULL;
+ gint _tmp4_ = 0;
+ GValue* _tmp5_;
+ gint _tmp5__length1;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (db != NULL, NULL);
+ g_return_val_if_fail (sql != NULL, NULL);
+ _tmp0_ = db;
+ self = (RygelMediaExportDatabaseCursor*) rygel_media_export_sqlite_wrapper_construct_wrap (object_type, _tmp0_);
+ _tmp1_ = db;
+ _tmp2_ = sql;
+ _tmp4_ = sqlite3_prepare_v2 (_tmp1_, _tmp2_, -1, &_tmp3_, NULL);
+ _sqlite3_finalize0 (self->priv->statement);
+ self->priv->statement = _tmp3_;
+ rygel_media_export_sqlite_wrapper_throw_if_code_is_error ((RygelMediaExportSqliteWrapper*) self, _tmp4_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (self);
+ return NULL;
+ } else {
+ 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;
+ }
+ }
+ _tmp5_ = arguments;
+ _tmp5__length1 = arguments_length1;
+ if (_tmp5_ == NULL) {
+ return self;
+ }
+ {
+ gint i;
+ i = 1;
+ {
+ gboolean _tmp6_;
+ _tmp6_ = TRUE;
+ while (TRUE) {
+ gboolean _tmp7_;
+ gint _tmp9_;
+ GValue* _tmp10_;
+ gint _tmp10__length1;
+ GValue* _tmp11_;
+ gint _tmp11__length1;
+ gint _tmp12_;
+ GValue _tmp13_;
+ GValue current_value;
+ gboolean _tmp14_ = FALSE;
+ _tmp7_ = _tmp6_;
+ if (!_tmp7_) {
+ gint _tmp8_;
+ _tmp8_ = i;
+ i = _tmp8_ + 1;
+ }
+ _tmp6_ = FALSE;
+ _tmp9_ = i;
+ _tmp10_ = arguments;
+ _tmp10__length1 = arguments_length1;
+ if (!(_tmp9_ <= _tmp10__length1)) {
+ break;
+ }
+ _tmp11_ = arguments;
+ _tmp11__length1 = arguments_length1;
+ _tmp12_ = i;
+ _tmp13_ = _tmp11_[_tmp12_ - 1];
+ current_value = _tmp13_;
+ _tmp14_ = G_VALUE_HOLDS (¤t_value, G_TYPE_INT);
+ if (_tmp14_) {
+ sqlite3_stmt* _tmp15_;
+ gint _tmp16_;
+ gint _tmp17_ = 0;
+ _tmp15_ = self->priv->statement;
+ _tmp16_ = i;
+ _tmp17_ = g_value_get_int (¤t_value);
+ sqlite3_bind_int (_tmp15_, _tmp16_, _tmp17_);
+ } else {
+ gboolean _tmp18_ = FALSE;
+ _tmp18_ = G_VALUE_HOLDS (¤t_value, G_TYPE_INT64);
+ if (_tmp18_) {
+ sqlite3_stmt* _tmp19_;
+ gint _tmp20_;
+ gint64 _tmp21_ = 0LL;
+ _tmp19_ = self->priv->statement;
+ _tmp20_ = i;
+ _tmp21_ = g_value_get_int64 (¤t_value);
+ sqlite3_bind_int64 (_tmp19_, _tmp20_, _tmp21_);
+ } else {
+ gboolean _tmp22_ = FALSE;
+ _tmp22_ = G_VALUE_HOLDS (¤t_value, G_TYPE_UINT64);
+ if (_tmp22_) {
+ sqlite3_stmt* _tmp23_;
+ gint _tmp24_;
+ guint64 _tmp25_ = 0ULL;
+ _tmp23_ = self->priv->statement;
+ _tmp24_ = i;
+ _tmp25_ = g_value_get_uint64 (¤t_value);
+ sqlite3_bind_int64 (_tmp23_, _tmp24_, (gint64) _tmp25_);
+ } else {
+ gboolean _tmp26_ = FALSE;
+ _tmp26_ = G_VALUE_HOLDS (¤t_value, G_TYPE_LONG);
+ if (_tmp26_) {
+ sqlite3_stmt* _tmp27_;
+ gint _tmp28_;
+ glong _tmp29_ = 0L;
+ _tmp27_ = self->priv->statement;
+ _tmp28_ = i;
+ _tmp29_ = g_value_get_long (¤t_value);
+ sqlite3_bind_int64 (_tmp27_, _tmp28_, (gint64) _tmp29_);
+ } else {
+ gboolean _tmp30_ = FALSE;
+ _tmp30_ = G_VALUE_HOLDS (¤t_value, G_TYPE_STRING);
+ if (_tmp30_) {
+ sqlite3_stmt* _tmp31_;
+ gint _tmp32_;
+ const gchar* _tmp33_ = NULL;
+ gchar* _tmp34_;
+ GDestroyNotify _tmp35_;
+ _tmp31_ = self->priv->statement;
+ _tmp32_ = i;
+ _tmp33_ = g_value_get_string (¤t_value);
+ _tmp34_ = g_strdup (_tmp33_);
+ _tmp35_ = g_free;
+ sqlite3_bind_text (_tmp31_, _tmp32_, _tmp34_, -1, _tmp35_);
+ } else {
+ gboolean _tmp36_ = FALSE;
+ _tmp36_ = G_VALUE_HOLDS (¤t_value, G_TYPE_POINTER);
+ if (_tmp36_) {
+ void* _tmp37_ = NULL;
+ _tmp37_ = g_value_peek_pointer (¤t_value);
+ if (_tmp37_ == NULL) {
+ sqlite3_stmt* _tmp38_;
+ gint _tmp39_;
+ _tmp38_ = self->priv->statement;
+ _tmp39_ = i;
+ sqlite3_bind_null (_tmp38_, _tmp39_);
+ } else {
+ g_assert_not_reached ();
+ }
+ } else {
+ GType _tmp40_ = 0UL;
+ GType type;
+ const gchar* _tmp41_ = NULL;
+ const gchar* _tmp42_ = NULL;
+ _tmp40_ = G_VALUE_TYPE (¤t_value);
+ type = _tmp40_;
+ _tmp41_ = _ ("Unsupported type %s");
+ _tmp42_ = g_type_name (type);
+ g_warning (_tmp41_, _tmp42_);
+ g_assert_not_reached ();
+ }
+ }
+ }
+ }
+ }
+ }
+ rygel_media_export_sqlite_wrapper_throw_if_db_has_error ((RygelMediaExportSqliteWrapper*) self, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (self);
+ return NULL;
+ } else {
+ 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;
+ }
+ }
+ }
+ }
+ }
+ return self;
+}
+
+
+RygelMediaExportDatabaseCursor* rygel_media_export_database_cursor_new (sqlite3* db, const gchar* sql, GValue* arguments, int arguments_length1, GError** error) {
+ return rygel_media_export_database_cursor_construct (RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, db, sql, arguments, arguments_length1, error);
+}
+
+
+/**
+ * Check if the cursor has more rows left
+ *
+ * @return true if more rows left, false otherwise
+ */
+gboolean rygel_media_export_database_cursor_has_next (RygelMediaExportDatabaseCursor* self) {
+ gboolean result = FALSE;
+ gboolean _tmp0_;
+ gboolean _tmp3_ = FALSE;
+ gint _tmp4_;
+ gboolean _tmp6_;
+ g_return_val_if_fail (self != NULL, FALSE);
+ _tmp0_ = self->priv->dirty;
+ if (_tmp0_) {
+ sqlite3_stmt* _tmp1_;
+ gint _tmp2_ = 0;
+ _tmp1_ = self->priv->statement;
+ _tmp2_ = sqlite3_step (_tmp1_);
+ self->priv->current_state = _tmp2_;
+ self->priv->dirty = FALSE;
+ }
+ _tmp4_ = self->priv->current_state;
+ if (_tmp4_ == SQLITE_ROW) {
+ _tmp3_ = TRUE;
+ } else {
+ gint _tmp5_;
+ _tmp5_ = self->priv->current_state;
+ _tmp3_ = _tmp5_ == (-1);
+ }
+ _tmp6_ = _tmp3_;
+ result = _tmp6_;
+ return result;
+}
+
+
+/**
+ * Get the next row of this cursor.
+ *
+ * This function uses pointers instead of unowned because var doesn't work
+ * with unowned.
+ *
+ * @return a pointer to the current row
+ */
+sqlite3_stmt* rygel_media_export_database_cursor_next (RygelMediaExportDatabaseCursor* self, GError** error) {
+ sqlite3_stmt* result = NULL;
+ gint _tmp0_;
+ sqlite3_stmt* _tmp1_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ rygel_media_export_database_cursor_has_next (self);
+ _tmp0_ = self->priv->current_state;
+ rygel_media_export_sqlite_wrapper_throw_if_code_is_error ((RygelMediaExportSqliteWrapper*) self, _tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ } else {
+ 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;
+ }
+ }
+ self->priv->dirty = TRUE;
+ _tmp1_ = self->priv->statement;
+ result = _tmp1_;
+ return result;
+}
+
+
+/**
+ * Return a iterator to the cursor to use with foreach
+ *
+ * @return an iterator wrapping the cursor
+ */
+RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator (RygelMediaExportDatabaseCursor* self) {
+ RygelMediaExportDatabaseCursorIterator* result = NULL;
+ RygelMediaExportDatabaseCursorIterator* _tmp0_;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = rygel_media_export_database_cursor_iterator_new (self);
+ result = _tmp0_;
+ return result;
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator_construct (GType object_type, RygelMediaExportDatabaseCursor* cursor) {
+ RygelMediaExportDatabaseCursorIterator* self = NULL;
+ RygelMediaExportDatabaseCursor* _tmp0_;
+ RygelMediaExportDatabaseCursor* _tmp1_;
+ g_return_val_if_fail (cursor != NULL, NULL);
+ self = (RygelMediaExportDatabaseCursorIterator*) g_type_create_instance (object_type);
+ _tmp0_ = cursor;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (self->cursor);
+ self->cursor = _tmp1_;
+ return self;
+}
+
+
+RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator_new (RygelMediaExportDatabaseCursor* cursor) {
+ return rygel_media_export_database_cursor_iterator_construct (RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, cursor);
+}
+
+
+gboolean rygel_media_export_database_cursor_iterator_next (RygelMediaExportDatabaseCursorIterator* self) {
+ gboolean result = FALSE;
+ RygelMediaExportDatabaseCursor* _tmp0_;
+ gboolean _tmp1_ = FALSE;
+ g_return_val_if_fail (self != NULL, FALSE);
+ _tmp0_ = self->cursor;
+ _tmp1_ = rygel_media_export_database_cursor_has_next (_tmp0_);
+ result = _tmp1_;
+ return result;
+}
+
+
+sqlite3_stmt* rygel_media_export_database_cursor_iterator_get (RygelMediaExportDatabaseCursorIterator* self, GError** error) {
+ sqlite3_stmt* result = NULL;
+ RygelMediaExportDatabaseCursor* _tmp0_;
+ sqlite3_stmt* _tmp1_ = NULL;
+ sqlite3_stmt* _tmp2_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = self->cursor;
+ _tmp1_ = rygel_media_export_database_cursor_next (_tmp0_, &_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ } else {
+ 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;
+ }
+ }
+ result = _tmp2_;
+ return result;
+}
+
+
+static void rygel_media_export_database_cursor_value_iterator_init (GValue* value) {
+ value->data[0].v_pointer = NULL;
+}
+
+
+static void rygel_media_export_database_cursor_value_iterator_free_value (GValue* value) {
+ if (value->data[0].v_pointer) {
+ rygel_media_export_database_cursor_iterator_unref (value->data[0].v_pointer);
+ }
+}
+
+
+static void rygel_media_export_database_cursor_value_iterator_copy_value (const GValue* src_value, GValue* dest_value) {
+ if (src_value->data[0].v_pointer) {
+ dest_value->data[0].v_pointer = rygel_media_export_database_cursor_iterator_ref (src_value->data[0].v_pointer);
+ } else {
+ dest_value->data[0].v_pointer = NULL;
+ }
+}
+
+
+static gpointer rygel_media_export_database_cursor_value_iterator_peek_pointer (const GValue* value) {
+ return value->data[0].v_pointer;
+}
+
+
+static gchar* rygel_media_export_database_cursor_value_iterator_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
+ if (collect_values[0].v_pointer) {
+ RygelMediaExportDatabaseCursorIterator* object;
+ object = collect_values[0].v_pointer;
+ if (object->parent_instance.g_class == NULL) {
+ return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
+ } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
+ return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
+ }
+ value->data[0].v_pointer = rygel_media_export_database_cursor_iterator_ref (object);
+ } else {
+ value->data[0].v_pointer = NULL;
+ }
+ return NULL;
+}
+
+
+static gchar* rygel_media_export_database_cursor_value_iterator_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) {
+ RygelMediaExportDatabaseCursorIterator** object_p;
+ object_p = collect_values[0].v_pointer;
+ if (!object_p) {
+ return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
+ }
+ if (!value->data[0].v_pointer) {
+ *object_p = NULL;
+ } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
+ *object_p = value->data[0].v_pointer;
+ } else {
+ *object_p = rygel_media_export_database_cursor_iterator_ref (value->data[0].v_pointer);
+ }
+ return NULL;
+}
+
+
+GParamSpec* rygel_media_export_database_cursor_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
+ RygelMediaExportDatabaseCursorParamSpecIterator* spec;
+ g_return_val_if_fail (g_type_is_a (object_type, RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR), NULL);
+ spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
+ G_PARAM_SPEC (spec)->value_type = object_type;
+ return G_PARAM_SPEC (spec);
+}
+
+
+gpointer rygel_media_export_database_cursor_value_get_iterator (const GValue* value) {
+ g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR), NULL);
+ return value->data[0].v_pointer;
+}
+
+
+void rygel_media_export_database_cursor_value_set_iterator (GValue* value, gpointer v_object) {
+ RygelMediaExportDatabaseCursorIterator* old;
+ g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR));
+ old = value->data[0].v_pointer;
+ if (v_object) {
+ g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR));
+ g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
+ value->data[0].v_pointer = v_object;
+ rygel_media_export_database_cursor_iterator_ref (value->data[0].v_pointer);
+ } else {
+ value->data[0].v_pointer = NULL;
+ }
+ if (old) {
+ rygel_media_export_database_cursor_iterator_unref (old);
+ }
+}
+
+
+void rygel_media_export_database_cursor_value_take_iterator (GValue* value, gpointer v_object) {
+ RygelMediaExportDatabaseCursorIterator* old;
+ g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR));
+ old = value->data[0].v_pointer;
+ if (v_object) {
+ g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR));
+ g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
+ value->data[0].v_pointer = v_object;
+ } else {
+ value->data[0].v_pointer = NULL;
+ }
+ if (old) {
+ rygel_media_export_database_cursor_iterator_unref (old);
+ }
+}
+
+
+static void rygel_media_export_database_cursor_iterator_class_init (RygelMediaExportDatabaseCursorIteratorClass * klass) {
+ rygel_media_export_database_cursor_iterator_parent_class = g_type_class_peek_parent (klass);
+ RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_CLASS (klass)->finalize = rygel_media_export_database_cursor_iterator_finalize;
+}
+
+
+static void rygel_media_export_database_cursor_iterator_init (RygelMediaExportDatabaseCursorIterator * self) {
+ self->ref_count = 1;
+}
+
+
+static void rygel_media_export_database_cursor_iterator_finalize (RygelMediaExportDatabaseCursorIterator* obj) {
+ RygelMediaExportDatabaseCursorIterator * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIterator);
+ _g_object_unref0 (self->cursor);
+}
+
+
+GType rygel_media_export_database_cursor_iterator_get_type (void) {
+ static volatile gsize rygel_media_export_database_cursor_iterator_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_database_cursor_iterator_type_id__volatile)) {
+ static const GTypeValueTable g_define_type_value_table = { rygel_media_export_database_cursor_value_iterator_init, rygel_media_export_database_cursor_value_iterator_free_value, rygel_media_export_database_cursor_value_iterator_copy_value, rygel_media_export_database_cursor_value_iterator_peek_pointer, "p", rygel_media_export_database_cursor_value_iterator_collect_value, "p", rygel_media_export_database_cursor_value_iterator_lcopy_value };
+ static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportDatabaseCursorIteratorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_database_cursor_iterator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportDatabaseCursorIterator), 0, (GInstanceInitFunc) rygel_media_export_database_cursor_iterator_init, &g_define_type_value_table };
+ static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
+ GType rygel_media_export_database_cursor_iterator_type_id;
+ rygel_media_export_database_cursor_iterator_type_id = g_type_register_fundamental (g_type_fundamental_next (), "RygelMediaExportDatabaseCursorIterator", &g_define_type_info, &g_define_type_fundamental_info, 0);
+ g_once_init_leave (&rygel_media_export_database_cursor_iterator_type_id__volatile, rygel_media_export_database_cursor_iterator_type_id);
+ }
+ return rygel_media_export_database_cursor_iterator_type_id__volatile;
+}
+
+
+gpointer rygel_media_export_database_cursor_iterator_ref (gpointer instance) {
+ RygelMediaExportDatabaseCursorIterator* self;
+ self = instance;
+ g_atomic_int_inc (&self->ref_count);
+ return instance;
+}
+
+
+void rygel_media_export_database_cursor_iterator_unref (gpointer instance) {
+ RygelMediaExportDatabaseCursorIterator* self;
+ self = instance;
+ if (g_atomic_int_dec_and_test (&self->ref_count)) {
+ RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_GET_CLASS (self)->finalize (self);
+ g_type_free_instance ((GTypeInstance *) self);
+ }
+}
+
+
+static void rygel_media_export_database_cursor_class_init (RygelMediaExportDatabaseCursorClass * klass) {
+ rygel_media_export_database_cursor_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportDatabaseCursorPrivate));
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_database_cursor_finalize;
+}
+
+
+static void rygel_media_export_database_cursor_init (RygelMediaExportDatabaseCursor * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_GET_PRIVATE (self);
+ self->priv->current_state = -1;
+ self->priv->dirty = TRUE;
+}
+
+
+static void rygel_media_export_database_cursor_finalize (GObject* obj) {
+ RygelMediaExportDatabaseCursor * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursor);
+ _sqlite3_finalize0 (self->priv->statement);
+ G_OBJECT_CLASS (rygel_media_export_database_cursor_parent_class)->finalize (obj);
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-database-cursor.h b/src/media-export/rygel-media-export-database-cursor.h
new file mode 100644
index 0000000..171fa2c
--- /dev/null
+++ b/src/media-export/rygel-media-export-database-cursor.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DATABASE_CURSOR_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DATABASE_CURSOR_H__
+
+#include "rygel-media-export-sqlite-wrapper.h"
+#include <sqlite3.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR (rygel_media_export_database_cursor_get_type ())
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursor))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorClass))
+#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR))
+#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorClass))
+
+typedef struct _RygelMediaExportDatabaseCursor RygelMediaExportDatabaseCursor;
+typedef struct _RygelMediaExportDatabaseCursorClass RygelMediaExportDatabaseCursorClass;
+typedef struct _RygelMediaExportDatabaseCursorPrivate RygelMediaExportDatabaseCursorPrivate;
+
+struct _RygelMediaExportDatabaseCursor {
+ RygelMediaExportSqliteWrapper parent_instance;
+ RygelMediaExportDatabaseCursorPrivate *priv;
+};
+
+struct _RygelMediaExportDatabaseCursorClass {
+ RygelMediaExportSqliteWrapperClass parent_class;
+};
+
+GType rygel_media_export_database_cursor_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportDatabaseCursor* rygel_media_export_database_cursor_new (sqlite3* db, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DATABASE_CURSOR_H__ */
diff --git a/src/media-export/rygel-media-export-database.c b/src/media-export/rygel-media-export-database.c
new file mode 100644
index 0000000..6a64dbb
--- /dev/null
+++ b/src/media-export/rygel-media-export-database.c
@@ -0,0 +1,680 @@
+/*
+ * Copyright (C) 2009,2011 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-database.h"
+#include <sqlite3.h>
+
+/**
+ * This class is a thin wrapper around SQLite's database object.
+ *
+ * It adds statement preparation based on GValue and a cancellable exec
+ * function.
+ */
+
+G_DEFINE_TYPE (RygelMediaExportDatabase, rygel_media_export_database, RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER)
+
+
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR (rygel_media_export_database_cursor_get_type ())
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursor))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorClass))
+#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR))
+#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorClass))
+
+typedef struct _RygelMediaExportDatabaseCursor RygelMediaExportDatabaseCursor;
+typedef struct _RygelMediaExportDatabaseCursorClass RygelMediaExportDatabaseCursorClass;
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
+
+GQuark rygel_media_export_database_error_quark (void);
+gint rygel_media_export_utf8_collate_str (const gchar* a, const gchar* b);
+GType rygel_media_export_sqlite_wrapper_get_type (void) G_GNUC_CONST;
+
+static void rygel_media_export_database_utf8_contains (sqlite3_context* context, sqlite3_value** args, int args_length1);
+static gint rygel_media_export_database_utf8_collate (gint alen, void* a, gint blen, void* b);
+RygelMediaExportDatabase* rygel_media_export_database_new (const gchar* name, GError** error);
+RygelMediaExportDatabase* rygel_media_export_database_construct (GType object_type, const gchar* name, GError** error);
+
+void rygel_media_export_database_exec (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+sqlite3* rygel_media_export_sqlite_wrapper_get_db (RygelMediaExportSqliteWrapper* self);
+static void _rygel_media_export_database_utf8_contains_sqlite_user_func_callback (sqlite3_context* context, int values_length1, sqlite3_value** values);
+static gint _rygel_media_export_database_utf8_collate_sqlite_compare_callback (gpointer self, gint alen, void* a, gint blen, void* b);
+GType rygel_media_export_database_cursor_get_type (void) G_GNUC_CONST;
+RygelMediaExportDatabaseCursor* rygel_media_export_database_exec_cursor (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+RygelMediaExportDatabaseCursor* rygel_media_export_database_cursor_new (sqlite3* db, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+RygelMediaExportDatabaseCursor* rygel_media_export_database_cursor_construct (GType object_type, sqlite3* db, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+void rygel_media_export_sqlite_wrapper_throw_if_code_is_error (RygelMediaExportSqliteWrapper* self, gint sqlite_error, GError** error);
+gboolean rygel_media_export_database_cursor_has_next (RygelMediaExportDatabaseCursor* self);
+sqlite3_stmt* rygel_media_export_database_cursor_next (RygelMediaExportDatabaseCursor* self, GError** error);
+gint rygel_media_export_database_query_value (RygelMediaExportDatabase* self, const gchar* sql, GValue* args, int args_length1, GError** error);
+void rygel_media_export_database_analyze (RygelMediaExportDatabase* self);
+void rygel_media_export_database_null (GValue* result);
+void rygel_media_export_database_begin (RygelMediaExportDatabase* self, GError** error);
+void rygel_media_export_database_commit (RygelMediaExportDatabase* self, GError** error);
+void rygel_media_export_database_rollback (RygelMediaExportDatabase* self);
+
+
+GQuark rygel_media_export_database_error_quark (void) {
+ return g_quark_from_static_string ("rygel_media_export_database_error-quark");
+}
+
+
+/**
+ * Function to implement the custom SQL function 'contains'
+ */
+static void rygel_media_export_database_utf8_contains (sqlite3_context* context, sqlite3_value** args, int args_length1) {
+ sqlite3_value** _tmp0_;
+ gint _tmp0__length1;
+ sqlite3_value** _tmp1_;
+ gint _tmp1__length1;
+ sqlite3_value* _tmp2_;
+ const gchar* _tmp3_ = NULL;
+ sqlite3_value** _tmp5_;
+ gint _tmp5__length1;
+ sqlite3_value* _tmp6_;
+ const gchar* _tmp7_ = NULL;
+ gchar* _tmp8_ = NULL;
+ gchar* pattern;
+ const gchar* _tmp9_;
+ sqlite3_value** _tmp10_;
+ gint _tmp10__length1;
+ sqlite3_value* _tmp11_;
+ const gchar* _tmp12_ = NULL;
+ gboolean _tmp13_ = FALSE;
+ g_return_if_fail (context != NULL);
+ _tmp0_ = args;
+ _tmp0__length1 = args_length1;
+ g_return_if_fail (_tmp0__length1 == 2);
+ _tmp1_ = args;
+ _tmp1__length1 = args_length1;
+ _tmp2_ = _tmp1_[1];
+ _tmp3_ = sqlite3_value_text (_tmp2_);
+ if (_tmp3_ == NULL) {
+ sqlite3_context* _tmp4_;
+ _tmp4_ = context;
+ sqlite3_result_int (_tmp4_, 0);
+ return;
+ }
+ _tmp5_ = args;
+ _tmp5__length1 = args_length1;
+ _tmp6_ = _tmp5_[1];
+ _tmp7_ = sqlite3_value_text (_tmp6_);
+ _tmp8_ = g_regex_escape_string (_tmp7_, -1);
+ pattern = _tmp8_;
+ _tmp9_ = pattern;
+ _tmp10_ = args;
+ _tmp10__length1 = args_length1;
+ _tmp11_ = _tmp10_[0];
+ _tmp12_ = sqlite3_value_text (_tmp11_);
+ _tmp13_ = g_regex_match_simple (_tmp9_, _tmp12_, G_REGEX_CASELESS, 0);
+ if (_tmp13_) {
+ sqlite3_context* _tmp14_;
+ _tmp14_ = context;
+ sqlite3_result_int (_tmp14_, 1);
+ } else {
+ sqlite3_context* _tmp15_;
+ _tmp15_ = context;
+ sqlite3_result_int (_tmp15_, 0);
+ }
+ _g_free0 (pattern);
+}
+
+
+/**
+ * Function to implement the custom SQLite collation 'CASEFOLD'.
+ *
+ * Uses utf8 case-fold to compare the strings.
+ */
+static gint rygel_media_export_database_utf8_collate (gint alen, void* a, gint blen, void* b) {
+ gint result = 0;
+ void* _tmp0_;
+ guint8* _a;
+ gint _a_length1;
+ gint __a_size_;
+ gint _tmp1_;
+ gint _tmp2_;
+ void* _tmp3_;
+ guint8* _b;
+ gint _b_length1;
+ gint __b_size_;
+ gint _tmp4_;
+ gint _tmp5_;
+ gchar* _tmp6_;
+ gchar* str_a;
+ gchar* _tmp7_;
+ gchar* str_b;
+ gint _tmp8_ = 0;
+ _tmp0_ = a;
+ _a = (guint8*) _tmp0_;
+ _a_length1 = -1;
+ __a_size_ = _a_length1;
+ _tmp1_ = alen;
+ _a_length1 = _tmp1_;
+ _tmp2_ = _a_length1;
+ _tmp3_ = b;
+ _b = (guint8*) _tmp3_;
+ _b_length1 = -1;
+ __b_size_ = _b_length1;
+ _tmp4_ = blen;
+ _b_length1 = _tmp4_;
+ _tmp5_ = _b_length1;
+ _tmp6_ = g_strdup ((const gchar*) _a);
+ str_a = _tmp6_;
+ _tmp7_ = g_strdup ((const gchar*) _b);
+ str_b = _tmp7_;
+ _tmp8_ = rygel_media_export_utf8_collate_str (str_a, str_b);
+ result = _tmp8_;
+ _g_free0 (str_b);
+ _g_free0 (str_a);
+ return result;
+}
+
+
+/**
+ * Open a database in the user's cache directory as defined by XDG
+ *
+ * @param name of the database, used to build full path
+ * (<cache-dir>/rygel/<name>.db)
+ */
+static void _rygel_media_export_database_utf8_contains_sqlite_user_func_callback (sqlite3_context* context, int values_length1, sqlite3_value** values) {
+ rygel_media_export_database_utf8_contains (context, values, values_length1);
+}
+
+
+static gint _rygel_media_export_database_utf8_collate_sqlite_compare_callback (gpointer self, gint alen, void* a, gint blen, void* b) {
+ gint result;
+ result = rygel_media_export_database_utf8_collate (alen, a, blen, b);
+ return result;
+}
+
+
+RygelMediaExportDatabase* rygel_media_export_database_construct (GType object_type, const gchar* name, GError** error) {
+ RygelMediaExportDatabase * self = NULL;
+ const gchar* _tmp0_ = NULL;
+ gchar* _tmp1_ = NULL;
+ gchar* dirname;
+ const gchar* _tmp2_;
+ const gchar* _tmp3_;
+ const gchar* _tmp4_;
+ gchar* _tmp5_ = NULL;
+ gchar* _tmp6_;
+ gchar* _tmp7_ = NULL;
+ gchar* _tmp8_;
+ gchar* db_file;
+ const gchar* _tmp9_;
+ const gchar* _tmp10_;
+ sqlite3* _tmp11_;
+ sqlite3* _tmp12_;
+ sqlite3* _tmp13_;
+ sqlite3* _tmp14_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (name != NULL, NULL);
+ _tmp0_ = g_get_user_cache_dir ();
+ _tmp1_ = g_build_filename (_tmp0_, "rygel", NULL);
+ dirname = _tmp1_;
+ _tmp2_ = dirname;
+ g_mkdir_with_parents (_tmp2_, 0750);
+ _tmp3_ = dirname;
+ _tmp4_ = name;
+ _tmp5_ = g_strdup_printf ("%s.db", _tmp4_);
+ _tmp6_ = _tmp5_;
+ _tmp7_ = g_build_filename (_tmp3_, _tmp6_, NULL);
+ _tmp8_ = _tmp7_;
+ _g_free0 (_tmp6_);
+ db_file = _tmp8_;
+ _tmp9_ = db_file;
+ self = (RygelMediaExportDatabase*) rygel_media_export_sqlite_wrapper_construct (object_type, _tmp9_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ _g_object_unref0 (self);
+ return NULL;
+ } else {
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ 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;
+ }
+ }
+ _tmp10_ = db_file;
+ g_debug ("rygel-media-export-database.vala:97: Using database file %s", _tmp10_);
+ rygel_media_export_database_exec (self, "PRAGMA synchronous = OFF", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ _g_object_unref0 (self);
+ return NULL;
+ } else {
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ 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;
+ }
+ }
+ rygel_media_export_database_exec (self, "PRAGMA temp_store = MEMORY", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ _g_object_unref0 (self);
+ return NULL;
+ } else {
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ 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;
+ }
+ }
+ rygel_media_export_database_exec (self, "PRAGMA count_changes = OFF", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ _g_object_unref0 (self);
+ return NULL;
+ } else {
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ 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;
+ }
+ }
+ _tmp11_ = rygel_media_export_sqlite_wrapper_get_db ((RygelMediaExportSqliteWrapper*) self);
+ _tmp12_ = _tmp11_;
+ sqlite3_create_function (_tmp12_, "contains", 2, SQLITE_UTF8, NULL, _rygel_media_export_database_utf8_contains_sqlite_user_func_callback, NULL, NULL);
+ _tmp13_ = rygel_media_export_sqlite_wrapper_get_db ((RygelMediaExportSqliteWrapper*) self);
+ _tmp14_ = _tmp13_;
+ sqlite3_create_collation (_tmp14_, "CASEFOLD", SQLITE_UTF8, NULL, (int (*)(void *, int, const void *, int, const void *)) _rygel_media_export_database_utf8_collate_sqlite_compare_callback);
+ _g_free0 (db_file);
+ _g_free0 (dirname);
+ return self;
+}
+
+
+RygelMediaExportDatabase* rygel_media_export_database_new (const gchar* name, GError** error) {
+ return rygel_media_export_database_construct (RYGEL_MEDIA_EXPORT_TYPE_DATABASE, name, error);
+}
+
+
+/**
+ * SQL query function.
+ *
+ * Use for all queries that return a result set.
+ *
+ * @param sql The SQL query to run.
+ * @param args Values to bind in the SQL query or null.
+ * @throws DatabaseError if the underlying SQLite operation fails.
+ */
+RygelMediaExportDatabaseCursor* rygel_media_export_database_exec_cursor (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error) {
+ RygelMediaExportDatabaseCursor* result = NULL;
+ sqlite3* _tmp0_;
+ sqlite3* _tmp1_;
+ const gchar* _tmp2_;
+ GValue* _tmp3_;
+ gint _tmp3__length1;
+ RygelMediaExportDatabaseCursor* _tmp4_;
+ RygelMediaExportDatabaseCursor* _tmp5_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (sql != NULL, NULL);
+ _tmp0_ = rygel_media_export_sqlite_wrapper_get_db ((RygelMediaExportSqliteWrapper*) self);
+ _tmp1_ = _tmp0_;
+ _tmp2_ = sql;
+ _tmp3_ = arguments;
+ _tmp3__length1 = arguments_length1;
+ _tmp4_ = rygel_media_export_database_cursor_new (_tmp1_, _tmp2_, _tmp3_, _tmp3__length1, &_inner_error_);
+ _tmp5_ = _tmp4_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ } else {
+ 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;
+ }
+ }
+ result = _tmp5_;
+ return result;
+}
+
+
+/**
+ * Simple SQL query execution function.
+ *
+ * Use for all queries that don't return anything.
+ *
+ * @param sql The SQL query to run.
+ * @param args Values to bind in the SQL query or null.
+ * @throws DatabaseError if the underlying SQLite operation fails.
+ */
+static gint _sqlite3_exec (sqlite3* self, const gchar* sql, sqlite3_callback callback, void* callback_target, gchar** errmsg) {
+ gchar* _vala_errmsg = NULL;
+ gint result = 0;
+ const gchar* sqlite_errmsg = NULL;
+ const gchar* _tmp0_;
+ sqlite3_callback _tmp1_;
+ void* _tmp1__target;
+ const gchar* _tmp2_ = NULL;
+ gint _tmp3_ = 0;
+ gint ec;
+ const gchar* _tmp6_;
+ g_return_val_if_fail (self != NULL, 0);
+ g_return_val_if_fail (sql != NULL, 0);
+ _tmp0_ = sql;
+ _tmp1_ = callback;
+ _tmp1__target = callback_target;
+ _tmp3_ = sqlite3_exec (self, _tmp0_, _tmp1_, _tmp1__target, (char**) (&_tmp2_));
+ sqlite_errmsg = _tmp2_;
+ ec = _tmp3_;
+ if ((&_vala_errmsg) != NULL) {
+ const gchar* _tmp4_;
+ gchar* _tmp5_;
+ _tmp4_ = sqlite_errmsg;
+ _tmp5_ = g_strdup (_tmp4_);
+ _g_free0 (_vala_errmsg);
+ _vala_errmsg = _tmp5_;
+ }
+ _tmp6_ = sqlite_errmsg;
+ sqlite3_free ((void*) _tmp6_);
+ result = ec;
+ if (errmsg) {
+ *errmsg = _vala_errmsg;
+ } else {
+ _g_free0 (_vala_errmsg);
+ }
+ return result;
+}
+
+
+void rygel_media_export_database_exec (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error) {
+ GValue* _tmp0_;
+ gint _tmp0__length1;
+ const gchar* _tmp5_;
+ GValue* _tmp6_;
+ gint _tmp6__length1;
+ RygelMediaExportDatabaseCursor* _tmp7_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (sql != NULL);
+ _tmp0_ = arguments;
+ _tmp0__length1 = arguments_length1;
+ if (_tmp0_ == NULL) {
+ sqlite3* _tmp1_;
+ sqlite3* _tmp2_;
+ const gchar* _tmp3_;
+ gint _tmp4_ = 0;
+ _tmp1_ = rygel_media_export_sqlite_wrapper_get_db ((RygelMediaExportSqliteWrapper*) self);
+ _tmp2_ = _tmp1_;
+ _tmp3_ = sql;
+ _tmp4_ = _sqlite3_exec (_tmp2_, _tmp3_, NULL, NULL, NULL);
+ rygel_media_export_sqlite_wrapper_throw_if_code_is_error ((RygelMediaExportSqliteWrapper*) self, _tmp4_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+ return;
+ }
+ _tmp5_ = sql;
+ _tmp6_ = arguments;
+ _tmp6__length1 = arguments_length1;
+ _tmp7_ = rygel_media_export_database_exec_cursor (self, _tmp5_, _tmp6_, _tmp6__length1, &_inner_error_);
+ cursor = _tmp7_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+ while (TRUE) {
+ RygelMediaExportDatabaseCursor* _tmp8_;
+ gboolean _tmp9_ = FALSE;
+ RygelMediaExportDatabaseCursor* _tmp10_;
+ _tmp8_ = cursor;
+ _tmp9_ = rygel_media_export_database_cursor_has_next (_tmp8_);
+ if (!_tmp9_) {
+ break;
+ }
+ _tmp10_ = cursor;
+ rygel_media_export_database_cursor_next (_tmp10_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (cursor);
+ return;
+ } else {
+ _g_object_unref0 (cursor);
+ 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;
+ }
+ }
+ }
+ _g_object_unref0 (cursor);
+}
+
+
+/**
+ * Execute a SQL query that returns a single number.
+ *
+ * @param sql The SQL query to run.
+ * @param args Values to bind in the SQL query or null.
+ * @return The contents of the first row's column as an int.
+ * @throws DatabaseError if the underlying SQLite operation fails.
+ */
+gint rygel_media_export_database_query_value (RygelMediaExportDatabase* self, const gchar* sql, GValue* args, int args_length1, GError** error) {
+ gint result = 0;
+ const gchar* _tmp0_;
+ GValue* _tmp1_;
+ gint _tmp1__length1;
+ RygelMediaExportDatabaseCursor* _tmp2_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ RygelMediaExportDatabaseCursor* _tmp3_;
+ sqlite3_stmt* _tmp4_ = NULL;
+ sqlite3_stmt* statement;
+ sqlite3_stmt* _tmp5_;
+ gint _tmp6_ = 0;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, 0);
+ g_return_val_if_fail (sql != NULL, 0);
+ _tmp0_ = sql;
+ _tmp1_ = args;
+ _tmp1__length1 = args_length1;
+ _tmp2_ = rygel_media_export_database_exec_cursor (self, _tmp0_, _tmp1_, _tmp1__length1, &_inner_error_);
+ cursor = _tmp2_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return 0;
+ } else {
+ 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 0;
+ }
+ }
+ _tmp3_ = cursor;
+ _tmp4_ = rygel_media_export_database_cursor_next (_tmp3_, &_inner_error_);
+ statement = _tmp4_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (cursor);
+ return 0;
+ } else {
+ _g_object_unref0 (cursor);
+ 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 0;
+ }
+ }
+ _tmp5_ = statement;
+ _tmp6_ = sqlite3_column_int (_tmp5_, 0);
+ result = _tmp6_;
+ _g_object_unref0 (cursor);
+ return result;
+}
+
+
+/**
+ * Analyze triggers of database
+ */
+void rygel_media_export_database_analyze (RygelMediaExportDatabase* self) {
+ sqlite3* _tmp0_;
+ sqlite3* _tmp1_;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = rygel_media_export_sqlite_wrapper_get_db ((RygelMediaExportSqliteWrapper*) self);
+ _tmp1_ = _tmp0_;
+ _sqlite3_exec (_tmp1_, "ANALYZE", NULL, NULL, NULL);
+}
+
+
+/**
+ * Special GValue to pass to exec or exec_cursor to bind a column to
+ * NULL
+ */
+void rygel_media_export_database_null (GValue* result) {
+ GValue _tmp0_ = {0};
+ GValue v;
+ g_value_init (&_tmp0_, G_TYPE_POINTER);
+ v = _tmp0_;
+ g_value_set_pointer (&v, NULL);
+ *result = v;
+ return;
+}
+
+
+/**
+ * Start a transaction
+ */
+void rygel_media_export_database_begin (RygelMediaExportDatabase* self, GError** error) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ rygel_media_export_database_exec (self, "BEGIN", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+}
+
+
+/**
+ * Commit a transaction
+ */
+void rygel_media_export_database_commit (RygelMediaExportDatabase* self, GError** error) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ rygel_media_export_database_exec (self, "COMMIT", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+}
+
+
+/**
+ * Rollback a transaction
+ */
+void rygel_media_export_database_rollback (RygelMediaExportDatabase* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ rygel_media_export_database_exec (self, "ROLLBACK", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch2_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ }
+ goto __finally2;
+ __catch2_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp0_ = NULL;
+ GError* _tmp1_;
+ const gchar* _tmp2_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp0_ = _ ("Failed to roll back transaction: %s");
+ _tmp1_ = _error_;
+ _tmp2_ = _tmp1_->message;
+ g_critical (_tmp0_, _tmp2_);
+ _g_error_free0 (_error_);
+ }
+ __finally2:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_database_class_init (RygelMediaExportDatabaseClass * klass) {
+ rygel_media_export_database_parent_class = g_type_class_peek_parent (klass);
+}
+
+
+static void rygel_media_export_database_init (RygelMediaExportDatabase * self) {
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-database.h b/src/media-export/rygel-media-export-database.h
new file mode 100644
index 0000000..c3a82e2
--- /dev/null
+++ b/src/media-export/rygel-media-export-database.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DATABASE_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DATABASE_H__
+
+#include "rygel-media-export-sqlite-wrapper.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DATABASE (rygel_media_export_database_get_type ())
+#define RYGEL_MEDIA_EXPORT_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE, RygelMediaExportDatabase))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE, RygelMediaExportDatabaseClass))
+#define RYGEL_MEDIA_EXPORT_IS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE))
+#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE))
+#define RYGEL_MEDIA_EXPORT_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE, RygelMediaExportDatabaseClass))
+
+typedef struct _RygelMediaExportDatabase RygelMediaExportDatabase;
+typedef struct _RygelMediaExportDatabaseClass RygelMediaExportDatabaseClass;
+typedef struct _RygelMediaExportDatabasePrivate RygelMediaExportDatabasePrivate;
+
+struct _RygelMediaExportDatabase {
+ RygelMediaExportSqliteWrapper parent_instance;
+ RygelMediaExportDatabasePrivate *priv;
+};
+
+struct _RygelMediaExportDatabaseClass {
+ RygelMediaExportSqliteWrapperClass parent_class;
+};
+
+GType rygel_media_export_database_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportDatabase* rygel_media_export_database_new (const gchar* name, GError** error);
+
+typedef enum {
+ RYGEL_MEDIA_EXPORT_DATABASE_ERROR_IO_ERROR,
+ RYGEL_MEDIA_EXPORT_DATABASE_ERROR_SQLITE_ERROR
+} RygelMediaExportDatabaseError;
+#define RYGEL_MEDIA_EXPORT_DATABASE_ERROR rygel_media_export_database_error_quark ()
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DATABASE_H__ */
diff --git a/src/media-export/rygel-media-export-db-container.c b/src/media-export/rygel-media-export-db-container.c
new file mode 100644
index 0000000..4c7da12
--- /dev/null
+++ b/src/media-export/rygel-media-export-db-container.c
@@ -0,0 +1,731 @@
+/*
+ * Copyright (C) 2009 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-db-container.h"
+#include "rygel-media-export-database.h"
+
+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))
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+typedef struct _RygelMediaExportDbContainerGetChildrenData RygelMediaExportDbContainerGetChildrenData;
+#define _rygel_search_expression_unref0(var) ((var == NULL) ? NULL : (var = (rygel_search_expression_unref (var), NULL)))
+typedef struct _RygelMediaExportDbContainerSearchData RygelMediaExportDbContainerSearchData;
+typedef struct _RygelMediaExportDbContainerFindObjectData RygelMediaExportDbContainerFindObjectData;
+
+
+struct _RygelMediaExportDBContainerPrivate {
+ GeeArrayList* _search_classes;
+};
+
+struct _RygelMediaExportDbContainerGetChildrenData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportDBContainer* self;
+ guint offset;
+ guint max_count;
+ gchar* sort_criteria;
+ GCancellable* cancellable;
+ RygelMediaObjects* result;
+ RygelMediaExportMediaCache* _tmp0_;
+ const gchar* _tmp1_;
+ guint _tmp2_;
+ guint _tmp3_;
+ RygelMediaObjects* _tmp4_;
+ RygelMediaObjects* _tmp5_;
+ GError * _inner_error_;
+};
+
+struct _RygelMediaExportDbContainerSearchData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportDBContainer* self;
+ RygelSearchExpression* expression;
+ guint offset;
+ guint max_count;
+ guint total_matches;
+ gchar* sort_criteria;
+ GCancellable* cancellable;
+ RygelMediaObjects* result;
+ RygelMediaObjects* children;
+ RygelMediaExportMediaCache* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ const gchar* _tmp2_;
+ const gchar* _tmp3_;
+ const gchar* _tmp4_;
+ guint _tmp5_;
+ guint _tmp6_;
+ guint _tmp7_;
+ RygelMediaObjects* _tmp8_;
+ RygelMediaObjects* _tmp9_;
+ GError* _error_;
+ GError* _tmp10_;
+ RygelSearchExpression* _tmp11_;
+ guint _tmp12_;
+ guint _tmp13_;
+ const gchar* _tmp14_;
+ GCancellable* _tmp15_;
+ guint _tmp16_;
+ RygelMediaObjects* _tmp17_;
+ RygelMediaObjects* _tmp18_;
+ GError* _tmp19_;
+ GError* _tmp20_;
+ GError * _inner_error_;
+};
+
+struct _RygelMediaExportDbContainerFindObjectData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportDBContainer* self;
+ gchar* id;
+ GCancellable* cancellable;
+ RygelMediaObject* result;
+ RygelMediaExportMediaCache* _tmp0_;
+ const gchar* _tmp1_;
+ RygelMediaObject* _tmp2_;
+ RygelMediaObject* _tmp3_;
+ GError * _inner_error_;
+};
+
+
+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))
+
+enum {
+ 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);
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void __lambda2_ (RygelMediaExportDBContainer* self) {
+ rygel_media_export_db_container_count_children (self);
+}
+
+
+static void ___lambda2__rygel_media_container_container_updated (RygelMediaContainer* _sender, RygelMediaContainer* container, RygelMediaObject* object, RygelObjectEventType event_type, gboolean sub_tree_update, gpointer self) {
+ __lambda2_ (self);
+}
+
+
+RygelMediaExportDBContainer* rygel_media_export_db_container_construct (GType object_type, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title) {
+ RygelMediaExportDBContainer * self = NULL;
+ const gchar* _tmp0_;
+ const gchar* _tmp1_;
+ RygelMediaExportMediaCache* _tmp2_;
+ RygelMediaExportMediaCache* _tmp3_;
+ GeeArrayList* _tmp4_;
+ GeeArrayList* _tmp5_;
+ g_return_val_if_fail (media_db != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+ g_return_val_if_fail (title != NULL, NULL);
+ _tmp0_ = id;
+ _tmp1_ = title;
+ self = (RygelMediaExportDBContainer*) rygel_media_container_construct (object_type, _tmp0_, NULL, _tmp1_, 0);
+ _tmp2_ = media_db;
+ _tmp3_ = _g_object_ref0 (_tmp2_);
+ _g_object_unref0 (self->media_db);
+ self->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_);
+ _g_object_unref0 (_tmp5_);
+ g_signal_connect_object ((RygelMediaContainer*) self, "container-updated", (GCallback) ___lambda2__rygel_media_container_container_updated, self, 0);
+ rygel_media_export_db_container_count_children (self);
+ return self;
+}
+
+
+RygelMediaExportDBContainer* rygel_media_export_db_container_new (RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title) {
+ return rygel_media_export_db_container_construct (RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, media_db, id, title);
+}
+
+
+static void rygel_media_export_db_container_count_children (RygelMediaExportDBContainer* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportMediaCache* _tmp0_;
+ const gchar* _tmp1_;
+ const gchar* _tmp2_;
+ gint _tmp3_ = 0;
+ gint _tmp4_;
+ _tmp0_ = self->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_);
+ _tmp4_ = _tmp3_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch3_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ ((RygelMediaContainer*) self)->child_count = _tmp4_;
+ }
+ goto __finally3;
+ __catch3_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ GError* _tmp5_;
+ const gchar* _tmp6_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp5_ = _error_;
+ _tmp6_ = _tmp5_->message;
+ g_debug ("rygel-media-export-db-container.vala:43: Could not get child count fro" \
+"m database: %s", _tmp6_);
+ ((RygelMediaContainer*) self)->child_count = 0;
+ _g_error_free0 (_error_);
+ }
+ __finally3:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_db_container_real_get_children_data_free (gpointer _data) {
+ RygelMediaExportDbContainerGetChildrenData* _data_;
+ _data_ = _data;
+ _g_free0 (_data_->sort_criteria);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportDbContainerGetChildrenData, _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_) {
+ RygelMediaExportDBContainer * self;
+ RygelMediaExportDbContainerGetChildrenData* _data_;
+ RygelMediaExportDBContainer* _tmp0_;
+ guint _tmp1_;
+ guint _tmp2_;
+ const gchar* _tmp3_;
+ gchar* _tmp4_;
+ GCancellable* _tmp5_;
+ GCancellable* _tmp6_;
+ self = (RygelMediaExportDBContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportDbContainerGetChildrenData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_db_container_real_get_children);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_db_container_real_get_children_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = offset;
+ _data_->offset = _tmp1_;
+ _tmp2_ = max_count;
+ _data_->max_count = _tmp2_;
+ _tmp3_ = sort_criteria;
+ _tmp4_ = g_strdup (_tmp3_);
+ _g_free0 (_data_->sort_criteria);
+ _data_->sort_criteria = _tmp4_;
+ _tmp5_ = cancellable;
+ _tmp6_ = _g_object_ref0 (_tmp5_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp6_;
+ rygel_media_export_db_container_real_get_children_co (_data_);
+}
+
+
+static RygelMediaObjects* rygel_media_export_db_container_real_get_children_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaObjects* result;
+ RygelMediaExportDbContainerGetChildrenData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static gboolean rygel_media_export_db_container_real_get_children_co (RygelMediaExportDbContainerGetChildrenData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = _data_->self->media_db;
+ _data_->_tmp1_ = _data_->sort_criteria;
+ _data_->_tmp2_ = _data_->offset;
+ _data_->_tmp3_ = _data_->max_count;
+ _data_->_tmp4_ = NULL;
+ _data_->_tmp4_ = rygel_media_export_media_cache_get_children (_data_->_tmp0_, (RygelMediaContainer*) _data_->self, _data_->_tmp1_, (glong) _data_->_tmp2_, (glong) _data_->_tmp3_, &_data_->_inner_error_);
+ _data_->_tmp5_ = _data_->_tmp4_;
+ 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_->result = _data_->_tmp5_;
+ 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;
+ 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_db_container_real_search_data_free (gpointer _data) {
+ RygelMediaExportDbContainerSearchData* _data_;
+ _data_ = _data;
+ _rygel_search_expression_unref0 (_data_->expression);
+ _g_free0 (_data_->sort_criteria);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportDbContainerSearchData, _data_);
+}
+
+
+static gpointer _rygel_search_expression_ref0 (gpointer self) {
+ return self ? rygel_search_expression_ref (self) : NULL;
+}
+
+
+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_) {
+ RygelMediaExportDbContainerSearchData* _data_;
+ RygelMediaExportDBContainer* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ RygelSearchExpression* _tmp2_;
+ guint _tmp3_;
+ guint _tmp4_;
+ const gchar* _tmp5_;
+ gchar* _tmp6_;
+ GCancellable* _tmp7_;
+ GCancellable* _tmp8_;
+ _data_ = g_slice_new0 (RygelMediaExportDbContainerSearchData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_db_container_real_search);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_db_container_real_search_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = expression;
+ _tmp2_ = _rygel_search_expression_ref0 (_tmp1_);
+ _rygel_search_expression_unref0 (_data_->expression);
+ _data_->expression = _tmp2_;
+ _tmp3_ = offset;
+ _data_->offset = _tmp3_;
+ _tmp4_ = max_count;
+ _data_->max_count = _tmp4_;
+ _tmp5_ = sort_criteria;
+ _tmp6_ = g_strdup (_tmp5_);
+ _g_free0 (_data_->sort_criteria);
+ _data_->sort_criteria = _tmp6_;
+ _tmp7_ = cancellable;
+ _tmp8_ = _g_object_ref0 (_tmp7_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp8_;
+ rygel_media_export_db_container_real_search_co (_data_);
+}
+
+
+static RygelMediaObjects* rygel_media_export_db_container_real_search_finish (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error) {
+ RygelMediaObjects* result;
+ RygelMediaExportDbContainerSearchData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ if (total_matches) {
+ *total_matches = _data_->total_matches;
+ }
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static void rygel_media_export_db_container_search_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ RygelMediaExportDbContainerSearchData* _data_;
+ _data_ = _user_data_;
+ _data_->_source_object_ = source_object;
+ _data_->_res_ = _res_;
+ rygel_media_export_db_container_real_search_co (_data_);
+}
+
+
+static gpointer _g_error_copy0 (gpointer self) {
+ return self ? g_error_copy (self) : NULL;
+}
+
+
+static gboolean rygel_media_export_db_container_real_search_co (RygelMediaExportDbContainerSearchData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ case 1:
+ goto _state_1;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->children = NULL;
+ {
+ _data_->_tmp0_ = _data_->self->media_db;
+ _data_->_tmp1_ = _data_->expression;
+ _data_->_tmp2_ = rygel_media_object_get_id ((RygelMediaObject*) _data_->self);
+ _data_->_tmp3_ = _data_->_tmp2_;
+ _data_->_tmp4_ = _data_->sort_criteria;
+ _data_->_tmp5_ = _data_->offset;
+ _data_->_tmp6_ = _data_->max_count;
+ _data_->_tmp7_ = 0U;
+ _data_->_tmp8_ = NULL;
+ _data_->_tmp8_ = rygel_media_export_media_cache_get_objects_by_search_expression (_data_->_tmp0_, _data_->_tmp1_, _data_->_tmp3_, _data_->_tmp4_, _data_->_tmp5_, _data_->_tmp6_, &_data_->_tmp7_, &_data_->_inner_error_);
+ _data_->total_matches = _data_->_tmp7_;
+ _data_->_tmp9_ = _data_->_tmp8_;
+ if (_data_->_inner_error_ != NULL) {
+ if (_data_->_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR) {
+ goto __catch4_rygel_media_export_media_cache_error;
+ }
+ goto __finally4;
+ }
+ _g_object_unref0 (_data_->children);
+ _data_->children = _data_->_tmp9_;
+ }
+ goto __finally4;
+ __catch4_rygel_media_export_media_cache_error:
+ {
+ _data_->_error_ = _data_->_inner_error_;
+ _data_->_inner_error_ = NULL;
+ _data_->_tmp10_ = _data_->_error_;
+ if (g_error_matches (_data_->_tmp10_, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH)) {
+ _data_->_tmp11_ = _data_->expression;
+ _data_->_tmp12_ = _data_->offset;
+ _data_->_tmp13_ = _data_->max_count;
+ _data_->_tmp14_ = _data_->sort_criteria;
+ _data_->_tmp15_ = _data_->cancellable;
+ _data_->_tmp16_ = 0U;
+ _data_->_state_ = 1;
+ rygel_searchable_container_simple_search ((RygelSearchableContainer*) _data_->self, _data_->_tmp11_, _data_->_tmp12_, _data_->_tmp13_, _data_->_tmp14_, _data_->_tmp15_, rygel_media_export_db_container_search_ready, _data_);
+ return FALSE;
+ _state_1:
+ _data_->_tmp17_ = NULL;
+ _data_->_tmp17_ = rygel_searchable_container_simple_search_finish ((RygelSearchableContainer*) _data_->self, _data_->_res_, &_data_->_tmp16_, &_data_->_inner_error_);
+ _data_->total_matches = _data_->_tmp16_;
+ _data_->_tmp18_ = _data_->_tmp17_;
+ if (_data_->_inner_error_ != NULL) {
+ _g_error_free0 (_data_->_error_);
+ goto __finally4;
+ }
+ _g_object_unref0 (_data_->children);
+ _data_->children = _data_->_tmp18_;
+ } else {
+ _data_->_tmp19_ = _data_->_error_;
+ _data_->_tmp20_ = _g_error_copy0 (_data_->_tmp19_);
+ _data_->_inner_error_ = _data_->_tmp20_;
+ _g_error_free0 (_data_->_error_);
+ goto __finally4;
+ }
+ _g_error_free0 (_data_->_error_);
+ }
+ __finally4:
+ 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_unref0 (_data_->children);
+ 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_->result = _data_->children;
+ 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_unref0 (_data_->children);
+ 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;
+}
+
+
+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_) {
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS (self)->search (self, expression, offset, max_count, sort_criteria, cancellable, _callback_, _user_data_);
+}
+
+
+RygelMediaObjects* rygel_media_export_db_container_search_finish (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error) {
+ return RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS (self)->search_finish (self, _res_, total_matches, error);
+}
+
+
+static void rygel_media_export_db_container_real_find_object_data_free (gpointer _data) {
+ RygelMediaExportDbContainerFindObjectData* _data_;
+ _data_ = _data;
+ _g_free0 (_data_->id);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportDbContainerFindObjectData, _data_);
+}
+
+
+static void rygel_media_export_db_container_real_find_object (RygelMediaContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportDBContainer * self;
+ RygelMediaExportDbContainerFindObjectData* _data_;
+ RygelMediaExportDBContainer* _tmp0_;
+ const gchar* _tmp1_;
+ gchar* _tmp2_;
+ GCancellable* _tmp3_;
+ GCancellable* _tmp4_;
+ self = (RygelMediaExportDBContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportDbContainerFindObjectData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_db_container_real_find_object);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_db_container_real_find_object_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = id;
+ _tmp2_ = g_strdup (_tmp1_);
+ _g_free0 (_data_->id);
+ _data_->id = _tmp2_;
+ _tmp3_ = cancellable;
+ _tmp4_ = _g_object_ref0 (_tmp3_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp4_;
+ rygel_media_export_db_container_real_find_object_co (_data_);
+}
+
+
+static RygelMediaObject* rygel_media_export_db_container_real_find_object_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaObject* result;
+ RygelMediaExportDbContainerFindObjectData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static gboolean rygel_media_export_db_container_real_find_object_co (RygelMediaExportDbContainerFindObjectData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = _data_->self->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_);
+ _data_->_tmp3_ = _data_->_tmp2_;
+ 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_->result = _data_->_tmp3_;
+ 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;
+ 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 GeeArrayList* rygel_media_export_db_container_real_get_search_classes (RygelSearchableContainer* base) {
+ GeeArrayList* result;
+ RygelMediaExportDBContainer* self;
+ GeeArrayList* _tmp0_;
+ self = (RygelMediaExportDBContainer*) base;
+ _tmp0_ = self->priv->_search_classes;
+ result = _tmp0_;
+ return result;
+}
+
+
+static void rygel_media_export_db_container_real_set_search_classes (RygelSearchableContainer* base, GeeArrayList* value) {
+ RygelMediaExportDBContainer* self;
+ GeeArrayList* _tmp0_;
+ GeeArrayList* _tmp1_;
+ self = (RygelMediaExportDBContainer*) base;
+ _tmp0_ = value;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (self->priv->_search_classes);
+ self->priv->_search_classes = _tmp1_;
+ g_object_notify ((GObject *) self, "search-classes");
+}
+
+
+static void rygel_media_export_db_container_class_init (RygelMediaExportDBContainerClass * klass) {
+ rygel_media_export_db_container_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportDBContainerPrivate));
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children = rygel_media_export_db_container_real_get_children;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children_finish = rygel_media_export_db_container_real_get_children_finish;
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (klass)->search = rygel_media_export_db_container_real_search;
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (klass)->search_finish = rygel_media_export_db_container_real_search_finish;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->find_object = rygel_media_export_db_container_real_find_object;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->find_object_finish = rygel_media_export_db_container_real_find_object_finish;
+ G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_db_container_get_property;
+ G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_db_container_set_property;
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_db_container_finalize;
+ g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES, g_param_spec_object ("search-classes", "search-classes", "search-classes", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+}
+
+
+static void rygel_media_export_db_container_rygel_searchable_container_interface_init (RygelSearchableContainerIface * iface) {
+ rygel_media_export_db_container_rygel_searchable_container_parent_iface = g_type_interface_peek_parent (iface);
+ iface->search = (RygelMediaObjects* (*)(RygelSearchableContainer*, RygelSearchExpression*, guint, guint, guint*, const gchar*, GCancellable*, GError**)) rygel_media_export_db_container_search;
+ iface->search_finish = rygel_media_export_db_container_search_finish;
+ iface->get_search_classes = rygel_media_export_db_container_real_get_search_classes;
+ iface->set_search_classes = rygel_media_export_db_container_real_set_search_classes;
+}
+
+
+static void rygel_media_export_db_container_init (RygelMediaExportDBContainer * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_PRIVATE (self);
+}
+
+
+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_unref0 (self->media_db);
+ _g_object_unref0 (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;
+ }
+}
+
+
+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;
+ }
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-db-container.h b/src/media-export/rygel-media-export-db-container.h
new file mode 100644
index 0000000..e2d230b
--- /dev/null
+++ b/src/media-export/rygel-media-export-db-container.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DB_CONTAINER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DB_CONTAINER_H__
+
+#include "rygel-media-export-sqlite-wrapper.h"
+#include "rygel-media-export-media-cache.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER (rygel_media_export_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+
+typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
+typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
+typedef struct _RygelMediaExportDBContainerPrivate RygelMediaExportDBContainerPrivate;
+
+struct _RygelMediaExportDBContainer {
+ RygelMediaContainer parent_instance;
+ RygelMediaExportDBContainerPrivate *priv;
+ RygelMediaExportMediaCache* media_db; /* TODO: Move to priv. */
+};
+
+struct _RygelMediaExportDBContainerClass {
+ RygelMediaContainerClass parent_class;
+
+ void (*search) (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+ RygelMediaObjects* (*search_finish) (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error);
+};
+
+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);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DB_CONTAINER_H__ */
diff --git a/src/media-export/rygel-media-export-dbus-service.c b/src/media-export/rygel-media-export-dbus-service.c
new file mode 100644
index 0000000..bbd29a6
--- /dev/null
+++ b/src/media-export/rygel-media-export-dbus-service.c
@@ -0,0 +1,382 @@
+/* rygel-media-export-dbus-service.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-dbus-service.vala, do not modify */
+
+/*
+ * Copyright (C) 2009 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-dbus-service.h"
+#include "rygel-media-export-root-container.h"
+
+G_DEFINE_TYPE (RygelMediaExportDBusService, rygel_media_export_dbus_service, G_TYPE_OBJECT)
+
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+struct _RygelMediaExportDBusServicePrivate {
+ RygelMediaExportRootContainer* root_container;
+};
+
+guint rygel_media_export_dbus_service_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error);
+GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_root_container_get_type (void) G_GNUC_CONST;
+#define RYGEL_MEDIA_EXPORT_DBUS_SERVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, RygelMediaExportDBusServicePrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_DBUS_SERVICE_DUMMY_PROPERTY
+};
+#define RYGEL_MEDIA_EXPORT_DBUS_SERVICE_RYGEL_MEDIA_EXPORT_PATH "/org/gnome/Rygel/MediaExport1"
+
+RygelMediaExportDBusService* rygel_media_export_dbus_service_construct (GType object_type, RygelMediaExportRootContainer* root_container, GError** error);
+void rygel_media_export_dbus_service_AddUri (RygelMediaExportDBusService* self, const gchar* uri);
+void rygel_media_export_root_container_add_uri (RygelMediaExportRootContainer* self, const gchar* uri);
+void rygel_media_export_dbus_service_RemoveUri (RygelMediaExportDBusService* self, const gchar* uri);
+void rygel_media_export_root_container_remove_uri (RygelMediaExportRootContainer* self, const gchar* uri);
+gchar** rygel_media_export_dbus_service_GetUris (RygelMediaExportDBusService* self, int* result_length1);
+gchar** rygel_media_export_root_container_get_dynamic_uris (RygelMediaExportRootContainer* self, int* result_length1);
+static void rygel_media_export_dbus_service_finalize (GObject* obj);
+static void _dbus_rygel_media_export_dbus_service_AddUri (RygelMediaExportDBusService* self, GVariant* parameters, GDBusMethodInvocation* invocation);
+static void _dbus_rygel_media_export_dbus_service_RemoveUri (RygelMediaExportDBusService* self, GVariant* parameters, GDBusMethodInvocation* invocation);
+static void _dbus_rygel_media_export_dbus_service_GetUris (RygelMediaExportDBusService* self, GVariant* parameters, GDBusMethodInvocation* invocation);
+static void rygel_media_export_dbus_service_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data);
+static GVariant* rygel_media_export_dbus_service_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data);
+static gboolean rygel_media_export_dbus_service_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data);
+static void _rygel_media_export_dbus_service_unregister_object (gpointer user_data);
+static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
+
+static const GDBusArgInfo _rygel_media_export_dbus_service_dbus_arg_info_AddUri_uri = {-1, "uri", "s"};
+static const GDBusArgInfo * const _rygel_media_export_dbus_service_dbus_arg_info_AddUri_in[] = {&_rygel_media_export_dbus_service_dbus_arg_info_AddUri_uri, NULL};
+static const GDBusArgInfo * const _rygel_media_export_dbus_service_dbus_arg_info_AddUri_out[] = {NULL};
+static const GDBusMethodInfo _rygel_media_export_dbus_service_dbus_method_info_AddUri = {-1, "AddUri", (GDBusArgInfo **) (&_rygel_media_export_dbus_service_dbus_arg_info_AddUri_in), (GDBusArgInfo **) (&_rygel_media_export_dbus_service_dbus_arg_info_AddUri_out)};
+static const GDBusArgInfo _rygel_media_export_dbus_service_dbus_arg_info_RemoveUri_uri = {-1, "uri", "s"};
+static const GDBusArgInfo * const _rygel_media_export_dbus_service_dbus_arg_info_RemoveUri_in[] = {&_rygel_media_export_dbus_service_dbus_arg_info_RemoveUri_uri, NULL};
+static const GDBusArgInfo * const _rygel_media_export_dbus_service_dbus_arg_info_RemoveUri_out[] = {NULL};
+static const GDBusMethodInfo _rygel_media_export_dbus_service_dbus_method_info_RemoveUri = {-1, "RemoveUri", (GDBusArgInfo **) (&_rygel_media_export_dbus_service_dbus_arg_info_RemoveUri_in), (GDBusArgInfo **) (&_rygel_media_export_dbus_service_dbus_arg_info_RemoveUri_out)};
+static const GDBusArgInfo _rygel_media_export_dbus_service_dbus_arg_info_GetUris_result = {-1, "result", "as"};
+static const GDBusArgInfo * const _rygel_media_export_dbus_service_dbus_arg_info_GetUris_in[] = {NULL};
+static const GDBusArgInfo * const _rygel_media_export_dbus_service_dbus_arg_info_GetUris_out[] = {&_rygel_media_export_dbus_service_dbus_arg_info_GetUris_result, NULL};
+static const GDBusMethodInfo _rygel_media_export_dbus_service_dbus_method_info_GetUris = {-1, "GetUris", (GDBusArgInfo **) (&_rygel_media_export_dbus_service_dbus_arg_info_GetUris_in), (GDBusArgInfo **) (&_rygel_media_export_dbus_service_dbus_arg_info_GetUris_out)};
+static const GDBusMethodInfo * const _rygel_media_export_dbus_service_dbus_method_info[] = {&_rygel_media_export_dbus_service_dbus_method_info_AddUri, &_rygel_media_export_dbus_service_dbus_method_info_RemoveUri, &_rygel_media_export_dbus_service_dbus_method_info_GetUris, NULL};
+static const GDBusSignalInfo * const _rygel_media_export_dbus_service_dbus_signal_info[] = {NULL};
+static const GDBusPropertyInfo * const _rygel_media_export_dbus_service_dbus_property_info[] = {NULL};
+static const GDBusInterfaceInfo _rygel_media_export_dbus_service_dbus_interface_info = {-1, "org.gnome.Rygel.MediaExport1", (GDBusMethodInfo **) (&_rygel_media_export_dbus_service_dbus_method_info), (GDBusSignalInfo **) (&_rygel_media_export_dbus_service_dbus_signal_info), (GDBusPropertyInfo **) (&_rygel_media_export_dbus_service_dbus_property_info)};
+static const GDBusInterfaceVTable _rygel_media_export_dbus_service_dbus_interface_vtable = {rygel_media_export_dbus_service_dbus_interface_method_call, rygel_media_export_dbus_service_dbus_interface_get_property, rygel_media_export_dbus_service_dbus_interface_set_property};
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+RygelMediaExportDBusService* rygel_media_export_dbus_service_construct (GType object_type, RygelMediaExportRootContainer* root_container, GError** error) {
+ RygelMediaExportDBusService * self = NULL;
+ RygelMediaExportRootContainer* _tmp0_;
+ RygelMediaExportRootContainer* _tmp1_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (root_container != NULL, NULL);
+ self = (RygelMediaExportDBusService*) g_object_new (object_type, NULL);
+ _tmp0_ = root_container;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (self->priv->root_container);
+ self->priv->root_container = _tmp1_;
+ {
+ GDBusConnection* _tmp2_ = NULL;
+ GDBusConnection* connection;
+ GDBusConnection* _tmp3_;
+ gboolean _tmp4_ = FALSE;
+ _tmp2_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);
+ connection = _tmp2_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_IO_ERROR) {
+ goto __catch43_g_io_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp3_ = connection;
+ _tmp4_ = G_LIKELY (_tmp3_ != NULL);
+ if (_tmp4_) {
+ GDBusConnection* _tmp5_;
+ _tmp5_ = connection;
+ rygel_media_export_dbus_service_register_object (self, _tmp5_, RYGEL_MEDIA_EXPORT_DBUS_SERVICE_RYGEL_MEDIA_EXPORT_PATH, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (connection);
+ if (_inner_error_->domain == G_IO_ERROR) {
+ goto __catch43_g_io_error;
+ }
+ _g_object_unref0 (connection);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ }
+ _g_object_unref0 (connection);
+ }
+ goto __finally43;
+ __catch43_g_io_error:
+ {
+ GError* err = NULL;
+ const gchar* _tmp6_ = NULL;
+ GError* _tmp7_;
+ const gchar* _tmp8_;
+ err = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp6_ = _ ("Failed to attach to D-Bus session bus: %s");
+ _tmp7_ = err;
+ _tmp8_ = _tmp7_->message;
+ g_warning (_tmp6_, _tmp8_);
+ _g_error_free0 (err);
+ }
+ __finally43:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ return self;
+}
+
+
+RygelMediaExportDBusService* rygel_media_export_dbus_service_new (RygelMediaExportRootContainer* root_container, GError** error) {
+ return rygel_media_export_dbus_service_construct (RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, root_container, error);
+}
+
+
+void rygel_media_export_dbus_service_AddUri (RygelMediaExportDBusService* self, const gchar* uri) {
+ RygelMediaExportRootContainer* _tmp0_;
+ const gchar* _tmp1_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (uri != NULL);
+ _tmp0_ = self->priv->root_container;
+ _tmp1_ = uri;
+ rygel_media_export_root_container_add_uri (_tmp0_, _tmp1_);
+}
+
+
+void rygel_media_export_dbus_service_RemoveUri (RygelMediaExportDBusService* self, const gchar* uri) {
+ RygelMediaExportRootContainer* _tmp0_;
+ const gchar* _tmp1_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (uri != NULL);
+ _tmp0_ = self->priv->root_container;
+ _tmp1_ = uri;
+ rygel_media_export_root_container_remove_uri (_tmp0_, _tmp1_);
+}
+
+
+gchar** rygel_media_export_dbus_service_GetUris (RygelMediaExportDBusService* self, int* result_length1) {
+ gchar** result = NULL;
+ RygelMediaExportRootContainer* _tmp0_;
+ gint _tmp1_ = 0;
+ gchar** _tmp2_ = NULL;
+ gchar** _tmp3_;
+ gint _tmp3__length1;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = self->priv->root_container;
+ _tmp2_ = rygel_media_export_root_container_get_dynamic_uris (_tmp0_, &_tmp1_);
+ _tmp3_ = _tmp2_;
+ _tmp3__length1 = _tmp1_;
+ if (result_length1) {
+ *result_length1 = _tmp3__length1;
+ }
+ result = _tmp3_;
+ return result;
+}
+
+
+static void rygel_media_export_dbus_service_class_init (RygelMediaExportDBusServiceClass * klass) {
+ rygel_media_export_dbus_service_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportDBusServicePrivate));
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_dbus_service_finalize;
+}
+
+
+static void rygel_media_export_dbus_service_init (RygelMediaExportDBusService * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_DBUS_SERVICE_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_dbus_service_finalize (GObject* obj) {
+ RygelMediaExportDBusService * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, RygelMediaExportDBusService);
+ _g_object_unref0 (self->priv->root_container);
+ G_OBJECT_CLASS (rygel_media_export_dbus_service_parent_class)->finalize (obj);
+}
+
+
+static void _dbus_rygel_media_export_dbus_service_AddUri (RygelMediaExportDBusService* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
+ GError* error = NULL;
+ GVariantIter _arguments_iter;
+ gchar* uri = NULL;
+ GVariant* _tmp0_;
+ GDBusMessage* _reply_message;
+ GVariant* _reply;
+ GVariantBuilder _reply_builder;
+ g_variant_iter_init (&_arguments_iter, parameters);
+ _tmp0_ = g_variant_iter_next_value (&_arguments_iter);
+ uri = g_variant_dup_string (_tmp0_, NULL);
+ g_variant_unref (_tmp0_);
+ rygel_media_export_dbus_service_AddUri (self, uri);
+ _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
+ g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
+ _reply = g_variant_builder_end (&_reply_builder);
+ g_dbus_message_set_body (_reply_message, _reply);
+ _g_free0 (uri);
+ g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
+ g_object_unref (invocation);
+ g_object_unref (_reply_message);
+}
+
+
+static void _dbus_rygel_media_export_dbus_service_RemoveUri (RygelMediaExportDBusService* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
+ GError* error = NULL;
+ GVariantIter _arguments_iter;
+ gchar* uri = NULL;
+ GVariant* _tmp1_;
+ GDBusMessage* _reply_message;
+ GVariant* _reply;
+ GVariantBuilder _reply_builder;
+ g_variant_iter_init (&_arguments_iter, parameters);
+ _tmp1_ = g_variant_iter_next_value (&_arguments_iter);
+ uri = g_variant_dup_string (_tmp1_, NULL);
+ g_variant_unref (_tmp1_);
+ rygel_media_export_dbus_service_RemoveUri (self, uri);
+ _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
+ g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
+ _reply = g_variant_builder_end (&_reply_builder);
+ g_dbus_message_set_body (_reply_message, _reply);
+ _g_free0 (uri);
+ g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
+ g_object_unref (invocation);
+ g_object_unref (_reply_message);
+}
+
+
+static void _dbus_rygel_media_export_dbus_service_GetUris (RygelMediaExportDBusService* self, GVariant* parameters, GDBusMethodInvocation* invocation) {
+ GError* error = NULL;
+ GVariantIter _arguments_iter;
+ GDBusMessage* _reply_message;
+ GVariant* _reply;
+ GVariantBuilder _reply_builder;
+ gchar** result;
+ int result_length1 = 0;
+ gchar** _tmp2_;
+ GVariantBuilder _tmp3_;
+ int _tmp4_;
+ g_variant_iter_init (&_arguments_iter, parameters);
+ result = rygel_media_export_dbus_service_GetUris (self, &result_length1);
+ _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
+ g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
+ _tmp2_ = result;
+ g_variant_builder_init (&_tmp3_, G_VARIANT_TYPE ("as"));
+ for (_tmp4_ = 0; _tmp4_ < result_length1; _tmp4_++) {
+ g_variant_builder_add_value (&_tmp3_, g_variant_new_string (*_tmp2_));
+ _tmp2_++;
+ }
+ g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp3_));
+ result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_free), NULL);
+ _reply = g_variant_builder_end (&_reply_builder);
+ g_dbus_message_set_body (_reply_message, _reply);
+ g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
+ g_object_unref (invocation);
+ g_object_unref (_reply_message);
+}
+
+
+static void rygel_media_export_dbus_service_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data) {
+ gpointer* data;
+ gpointer object;
+ data = user_data;
+ object = data[0];
+ if (strcmp (method_name, "AddUri") == 0) {
+ _dbus_rygel_media_export_dbus_service_AddUri (object, parameters, invocation);
+ } else if (strcmp (method_name, "RemoveUri") == 0) {
+ _dbus_rygel_media_export_dbus_service_RemoveUri (object, parameters, invocation);
+ } else if (strcmp (method_name, "GetUris") == 0) {
+ _dbus_rygel_media_export_dbus_service_GetUris (object, parameters, invocation);
+ } else {
+ g_object_unref (invocation);
+ }
+}
+
+
+static GVariant* rygel_media_export_dbus_service_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data) {
+ gpointer* data;
+ gpointer object;
+ data = user_data;
+ object = data[0];
+ return NULL;
+}
+
+
+static gboolean rygel_media_export_dbus_service_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) {
+ gpointer* data;
+ gpointer object;
+ data = user_data;
+ object = data[0];
+ return FALSE;
+}
+
+
+guint rygel_media_export_dbus_service_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) {
+ guint result;
+ gpointer *data;
+ data = g_new (gpointer, 3);
+ data[0] = g_object_ref (object);
+ data[1] = g_object_ref (connection);
+ data[2] = g_strdup (path);
+ result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_rygel_media_export_dbus_service_dbus_interface_info), &_rygel_media_export_dbus_service_dbus_interface_vtable, data, _rygel_media_export_dbus_service_unregister_object, error);
+ if (!result) {
+ return 0;
+ }
+ return result;
+}
+
+
+static void _rygel_media_export_dbus_service_unregister_object (gpointer user_data) {
+ gpointer* data;
+ data = user_data;
+ g_object_unref (data[0]);
+ g_object_unref (data[1]);
+ g_free (data[2]);
+ g_free (data);
+}
+
+
+static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+ if ((array != NULL) && (destroy_func != NULL)) {
+ int i;
+ for (i = 0; i < array_length; i = i + 1) {
+ if (((gpointer*) array)[i] != NULL) {
+ destroy_func (((gpointer*) array)[i]);
+ }
+ }
+ }
+}
+
+
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+ _vala_array_destroy (array, array_length, destroy_func);
+ g_free (array);
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-dbus-service.h b/src/media-export/rygel-media-export-dbus-service.h
new file mode 100644
index 0000000..95196c2
--- /dev/null
+++ b/src/media-export/rygel-media-export-dbus-service.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DBUS_SERVICE_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DBUS_SERVICE_H__
+
+#include "rygel-media-export-root-container.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE (rygel_media_export_dbus_service_get_type ())
+#define RYGEL_MEDIA_EXPORT_DBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, RygelMediaExportDBusService))
+#define RYGEL_MEDIA_EXPORT_DBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, RygelMediaExportDBusServiceClass))
+#define RYGEL_MEDIA_EXPORT_IS_DBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE))
+#define RYGEL_MEDIA_EXPORT_IS_DBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE))
+#define RYGEL_MEDIA_EXPORT_DBUS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, RygelMediaExportDBusServiceClass))
+
+typedef struct _RygelMediaExportDBusService RygelMediaExportDBusService;
+typedef struct _RygelMediaExportDBusServiceClass RygelMediaExportDBusServiceClass;
+typedef struct _RygelMediaExportDBusServicePrivate RygelMediaExportDBusServicePrivate;
+
+struct _RygelMediaExportDBusService {
+ GObject parent_instance;
+ RygelMediaExportDBusServicePrivate *priv;
+};
+
+struct _RygelMediaExportDBusServiceClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_dbus_service_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportDBusService* rygel_media_export_dbus_service_new (RygelMediaExportRootContainer* root_container, GError** error);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DBUS_SERVICE_H__ */
diff --git a/src/media-export/rygel-media-export-dummy-container.c b/src/media-export/rygel-media-export-dummy-container.c
new file mode 100644
index 0000000..ef79cde
--- /dev/null
+++ b/src/media-export/rygel-media-export-dummy-container.c
@@ -0,0 +1,189 @@
+/* rygel-media-export-dummy-container.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-dummy-container.vala, do not modify */
+
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-dummy-container.h"
+#include "rygel-media-export-media-cache.h"
+
+G_DEFINE_TYPE (RygelMediaExportDummyContainer, rygel_media_export_dummy_container, RYGEL_MEDIA_EXPORT_TYPE_NULL_CONTAINER)
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
+
+RygelMediaExportDummyContainer* rygel_media_export_dummy_container_construct (GType object_type, GFile* file, RygelMediaContainer* parent);
+
+gchar* rygel_media_export_media_cache_get_id (GFile* file);
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
+GQuark rygel_media_export_database_error_quark (void);
+GeeArrayList* rygel_media_export_media_cache_get_child_ids (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
+void rygel_media_export_dummy_container_seen (RygelMediaExportDummyContainer* self, GFile* file);
+static void rygel_media_export_dummy_container_finalize (GObject* obj);
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+RygelMediaExportDummyContainer* rygel_media_export_dummy_container_construct (GType object_type, GFile* file, RygelMediaContainer* parent) {
+ RygelMediaExportDummyContainer * self = NULL;
+ GFile* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* _tmp2_;
+ GFile* _tmp3_;
+ gchar* _tmp4_ = NULL;
+ gchar* _tmp5_;
+ RygelMediaContainer* _tmp6_;
+ GFile* _tmp7_;
+ GFile* _tmp8_;
+ GeeArrayList* _tmp9_;
+ GFile* _tmp10_;
+ gchar* _tmp11_ = NULL;
+ gchar* _tmp12_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (file != NULL, NULL);
+ g_return_val_if_fail (parent != NULL, NULL);
+ self = (RygelMediaExportDummyContainer*) rygel_null_container_construct (object_type);
+ _tmp0_ = file;
+ _tmp1_ = rygel_media_export_media_cache_get_id (_tmp0_);
+ _tmp2_ = _tmp1_;
+ rygel_media_object_set_id ((RygelMediaObject*) self, _tmp2_);
+ _g_free0 (_tmp2_);
+ _tmp3_ = file;
+ _tmp4_ = g_file_get_basename (_tmp3_);
+ _tmp5_ = _tmp4_;
+ rygel_media_object_set_title ((RygelMediaObject*) self, _tmp5_);
+ _g_free0 (_tmp5_);
+ _tmp6_ = parent;
+ rygel_media_object_set_parent_ref ((RygelMediaObject*) self, _tmp6_);
+ _tmp7_ = file;
+ _tmp8_ = _g_object_ref0 (_tmp7_);
+ _g_object_unref0 (self->file);
+ self->file = _tmp8_;
+ _tmp9_ = ((RygelMediaObject*) self)->uris;
+ _tmp10_ = file;
+ _tmp11_ = g_file_get_uri (_tmp10_);
+ _tmp12_ = _tmp11_;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, _tmp12_);
+ _g_free0 (_tmp12_);
+ {
+ RygelMediaExportMediaCache* _tmp13_ = NULL;
+ RygelMediaExportMediaCache* _tmp14_;
+ RygelMediaExportMediaCache* _tmp15_;
+ const gchar* _tmp16_;
+ const gchar* _tmp17_;
+ GeeArrayList* _tmp18_ = NULL;
+ GeeArrayList* _tmp19_;
+ GeeArrayList* _tmp20_;
+ GeeList* _tmp21_;
+ gint _tmp22_;
+ gint _tmp23_;
+ _tmp13_ = rygel_media_export_media_cache_get_default (&_inner_error_);
+ _tmp14_ = _tmp13_;
+ if (_inner_error_ != NULL) {
+ goto __catch25_g_error;
+ }
+ _tmp15_ = _tmp14_;
+ _tmp16_ = rygel_media_object_get_id ((RygelMediaObject*) self);
+ _tmp17_ = _tmp16_;
+ _tmp18_ = rygel_media_export_media_cache_get_child_ids (_tmp15_, _tmp17_, &_inner_error_);
+ _tmp19_ = _tmp18_;
+ _g_object_unref0 (_tmp15_);
+ _tmp20_ = _tmp19_;
+ if (_inner_error_ != NULL) {
+ goto __catch25_g_error;
+ }
+ _g_object_unref0 (self->children);
+ self->children = (GeeList*) _tmp20_;
+ _tmp21_ = self->children;
+ _tmp22_ = gee_collection_get_size ((GeeCollection*) _tmp21_);
+ _tmp23_ = _tmp22_;
+ ((RygelMediaContainer*) self)->child_count = _tmp23_;
+ }
+ goto __finally25;
+ __catch25_g_error:
+ {
+ GError* _error_ = NULL;
+ GeeArrayList* _tmp24_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp24_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ _g_object_unref0 (self->children);
+ self->children = (GeeList*) _tmp24_;
+ ((RygelMediaContainer*) self)->child_count = 0;
+ _g_error_free0 (_error_);
+ }
+ __finally25:
+ if (_inner_error_ != 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 NULL;
+ }
+ return self;
+}
+
+
+RygelMediaExportDummyContainer* rygel_media_export_dummy_container_new (GFile* file, RygelMediaContainer* parent) {
+ return rygel_media_export_dummy_container_construct (RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, file, parent);
+}
+
+
+void rygel_media_export_dummy_container_seen (RygelMediaExportDummyContainer* self, GFile* file) {
+ GeeList* _tmp0_;
+ GFile* _tmp1_;
+ gchar* _tmp2_ = NULL;
+ gchar* _tmp3_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ _tmp0_ = self->children;
+ _tmp1_ = file;
+ _tmp2_ = rygel_media_export_media_cache_get_id (_tmp1_);
+ _tmp3_ = _tmp2_;
+ gee_collection_remove ((GeeCollection*) _tmp0_, _tmp3_);
+ _g_free0 (_tmp3_);
+}
+
+
+static void rygel_media_export_dummy_container_class_init (RygelMediaExportDummyContainerClass * klass) {
+ rygel_media_export_dummy_container_parent_class = g_type_class_peek_parent (klass);
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_dummy_container_finalize;
+}
+
+
+static void rygel_media_export_dummy_container_init (RygelMediaExportDummyContainer * self) {
+}
+
+
+static void rygel_media_export_dummy_container_finalize (GObject* obj) {
+ RygelMediaExportDummyContainer * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, RygelMediaExportDummyContainer);
+ _g_object_unref0 (self->file);
+ _g_object_unref0 (self->children);
+ G_OBJECT_CLASS (rygel_media_export_dummy_container_parent_class)->finalize (obj);
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-dummy-container.h b/src/media-export/rygel-media-export-dummy-container.h
new file mode 100644
index 0000000..26c8b43
--- /dev/null
+++ b/src/media-export/rygel-media-export-dummy-container.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DUMMY_CONTAINER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DUMMY_CONTAINER_H__
+
+#include "rygel-media-export-null-container.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER (rygel_media_export_dummy_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, RygelMediaExportDummyContainer))
+#define RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, RygelMediaExportDummyContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_DUMMY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_DUMMY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_DUMMY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER, RygelMediaExportDummyContainerClass))
+
+typedef struct _RygelMediaExportDummyContainer RygelMediaExportDummyContainer;
+typedef struct _RygelMediaExportDummyContainerClass RygelMediaExportDummyContainerClass;
+typedef struct _RygelMediaExportDummyContainerPrivate RygelMediaExportDummyContainerPrivate;
+
+struct _RygelMediaExportDummyContainer {
+ RygelMediaExportNullContainer parent_instance;
+ RygelMediaExportDummyContainerPrivate* priv;
+ GFile* file; //TODO: Move to priv.
+ GeeList* children; //TODO: Move to priv.
+};
+
+struct _RygelMediaExportDummyContainerClass {
+ RygelMediaExportNullContainerClass parent_class;
+};
+
+GType rygel_media_export_dummy_container_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportDummyContainer* rygel_media_export_dummy_container_new ();
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_DUMMY_CONTAINER_H__ */
diff --git a/src/media-export/rygel-media-export-harvester.c b/src/media-export/rygel-media-export-harvester.c
new file mode 100644
index 0000000..75b89b4
--- /dev/null
+++ b/src/media-export/rygel-media-export-harvester.c
@@ -0,0 +1,1055 @@
+/* rygel-media-export-harvester.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-harvester.vala, do not modify */
+
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-harvester.h"
+#include "rygel-media-export-harvesting-task.h"
+#include "rygel-media-export-database.h"
+#include "rygel-media-export-media-cache.h"
+
+/**
+ * This class takes care of the book-keeping of running and finished
+ * extraction tasks running within the media-export plugin
+ */
+
+G_DEFINE_TYPE (RygelMediaExportHarvester, rygel_media_export_harvester, G_TYPE_OBJECT)
+
+#define RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR (rygel_media_export_metadata_extractor_get_type ())
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractor))
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorClass))
+#define RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR))
+#define RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR))
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorClass))
+
+typedef struct _RygelMediaExportMetadataExtractor RygelMediaExportMetadataExtractor;
+typedef struct _RygelMediaExportMetadataExtractorClass RygelMediaExportMetadataExtractorClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR (rygel_media_export_recursive_file_monitor_get_type ())
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitor))
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitorClass))
+#define RYGEL_MEDIA_EXPORT_IS_RECURSIVE_FILE_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR))
+#define RYGEL_MEDIA_EXPORT_IS_RECURSIVE_FILE_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR))
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitorClass))
+
+typedef struct _RygelMediaExportRecursiveFileMonitor RygelMediaExportRecursiveFileMonitor;
+typedef struct _RygelMediaExportRecursiveFileMonitorClass RygelMediaExportRecursiveFileMonitorClass;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+typedef struct _RygelMediaExportHarvestingTaskPrivate RygelMediaExportHarvestingTaskPrivate;
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
+
+typedef struct _Block3Data Block3Data;
+
+
+struct _RygelMediaExportHarvesterPrivate {
+ GeeHashMap* tasks;
+ GeeHashMap* extraction_grace_timers;
+ RygelMediaExportMetadataExtractor* extractor;
+ RygelMediaExportRecursiveFileMonitor* monitor;
+ GCancellable* cancellable;
+ GeeArrayList* _locations;
+};
+
+
+struct _Block3Data {
+ int _ref_count_;
+ RygelMediaExportHarvester * self;
+ GFile* file;
+};
+
+GType rygel_media_export_metadata_extractor_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_recursive_file_monitor_get_type (void) G_GNUC_CONST;
+#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
+};
+#define RYGEL_MEDIA_EXPORT_HARVESTER_FILE_CHANGE_DEFAULT_GRACE_PERIOD ((guint) 5)
+
+RygelMediaExportHarvester* rygel_media_export_harvester_construct (GType object_type, GCancellable* cancellable, GeeArrayList* locations);
+static void rygel_media_export_harvester_set_locations (RygelMediaExportHarvester* self, GeeArrayList* value);
+GeeArrayList* rygel_media_export_harvester_get_locations (RygelMediaExportHarvester* self);
+RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_new (void);
+RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_construct (GType object_type);
+RygelMediaExportRecursiveFileMonitor* rygel_media_export_recursive_file_monitor_new (GCancellable* cancellable);
+RygelMediaExportRecursiveFileMonitor* rygel_media_export_recursive_file_monitor_construct (GType object_type, GCancellable* cancellable);
+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);
+void rygel_media_export_harvester_schedule (RygelMediaExportHarvester* self, GFile* file, RygelMediaContainer* parent, const gchar* flag);
+void rygel_media_export_harvester_cancel (RygelMediaExportHarvester* self, GFile* file);
+RygelMediaExportHarvestingTask* rygel_media_export_harvesting_task_new (RygelMediaExportMetadataExtractor* extractor, RygelMediaExportRecursiveFileMonitor* monitor, GFile* file, RygelMediaContainer* parent, const gchar* flag);
+RygelMediaExportHarvestingTask* rygel_media_export_harvesting_task_construct (GType object_type, RygelMediaExportMetadataExtractor* extractor, RygelMediaExportRecursiveFileMonitor* monitor, GFile* file, RygelMediaContainer* parent, const gchar* flag);
+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);
+void rygel_media_export_harvesting_task_cancel (RygelMediaExportHarvestingTask* 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);
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
+gchar* rygel_media_export_media_cache_get_id (GFile* file);
+GQuark rygel_media_export_database_error_quark (void);
+RygelMediaObject* rygel_media_export_media_cache_get_object (RygelMediaExportMediaCache* self, const gchar* object_id, GError** error);
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "Filesystem"
+GQuark rygel_media_export_media_cache_error_quark (void);
+void rygel_media_export_media_cache_remove_object (RygelMediaExportMediaCache* self, RygelMediaObject* object, GError** error);
+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);
+
+
+/**
+ * Create a new instance of the meta-data extraction manager.
+ */
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+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) {
+ rygel_media_export_harvester_on_file_changed (self, file, other_file, event_type);
+}
+
+
+RygelMediaExportHarvester* rygel_media_export_harvester_construct (GType object_type, GCancellable* cancellable, GeeArrayList* locations) {
+ RygelMediaExportHarvester * self = NULL;
+ GCancellable* _tmp0_;
+ GCancellable* _tmp1_;
+ GeeArrayList* _tmp2_;
+ GeeArrayList* _tmp3_;
+ RygelMediaExportMetadataExtractor* _tmp19_;
+ GCancellable* _tmp20_;
+ RygelMediaExportRecursiveFileMonitor* _tmp21_;
+ RygelMediaExportRecursiveFileMonitor* _tmp22_;
+ GeeHashMap* _tmp23_;
+ GeeHashMap* _tmp24_;
+ g_return_val_if_fail (cancellable != NULL, NULL);
+ g_return_val_if_fail (locations != NULL, NULL);
+ self = (RygelMediaExportHarvester*) g_object_new (object_type, NULL);
+ _tmp0_ = cancellable;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (self->priv->cancellable);
+ self->priv->cancellable = _tmp1_;
+ _tmp2_ = gee_array_list_new (G_TYPE_FILE, (GBoxedCopyFunc) g_object_ref, g_object_unref, (GeeEqualDataFunc) g_file_equal, NULL, NULL);
+ _tmp3_ = _tmp2_;
+ rygel_media_export_harvester_set_locations (self, _tmp3_);
+ _g_object_unref0 (_tmp3_);
+ {
+ GeeArrayList* _tmp4_;
+ GeeArrayList* _tmp5_;
+ GeeArrayList* _file_list;
+ GeeArrayList* _tmp6_;
+ gint _tmp7_;
+ gint _tmp8_;
+ gint _file_size;
+ gint _file_index;
+ _tmp4_ = locations;
+ _tmp5_ = _g_object_ref0 (_tmp4_);
+ _file_list = _tmp5_;
+ _tmp6_ = _file_list;
+ _tmp7_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp6_);
+ _tmp8_ = _tmp7_;
+ _file_size = _tmp8_;
+ _file_index = -1;
+ while (TRUE) {
+ gint _tmp9_;
+ gint _tmp10_;
+ gint _tmp11_;
+ GeeArrayList* _tmp12_;
+ gint _tmp13_;
+ gpointer _tmp14_ = NULL;
+ GFile* file;
+ GFile* _tmp15_;
+ gboolean _tmp16_ = FALSE;
+ _tmp9_ = _file_index;
+ _file_index = _tmp9_ + 1;
+ _tmp10_ = _file_index;
+ _tmp11_ = _file_size;
+ if (!(_tmp10_ < _tmp11_)) {
+ break;
+ }
+ _tmp12_ = _file_list;
+ _tmp13_ = _file_index;
+ _tmp14_ = gee_abstract_list_get ((GeeAbstractList*) _tmp12_, _tmp13_);
+ file = (GFile*) _tmp14_;
+ _tmp15_ = file;
+ _tmp16_ = g_file_query_exists (_tmp15_, NULL);
+ if (_tmp16_) {
+ GeeArrayList* _tmp17_;
+ GFile* _tmp18_;
+ _tmp17_ = self->priv->_locations;
+ _tmp18_ = file;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp18_);
+ }
+ _g_object_unref0 (file);
+ }
+ _g_object_unref0 (_file_list);
+ }
+ _tmp19_ = rygel_media_export_metadata_extractor_new ();
+ _g_object_unref0 (self->priv->extractor);
+ self->priv->extractor = _tmp19_;
+ _tmp20_ = cancellable;
+ _tmp21_ = rygel_media_export_recursive_file_monitor_new (_tmp20_);
+ _g_object_unref0 (self->priv->monitor);
+ self->priv->monitor = _tmp21_;
+ _tmp22_ = self->priv->monitor;
+ g_signal_connect_object (_tmp22_, "changed", (GCallback) _rygel_media_export_harvester_on_file_changed_rygel_media_export_recursive_file_monitor_changed, self, 0);
+ _tmp23_ = gee_hash_map_new (G_TYPE_FILE, (GBoxedCopyFunc) g_object_ref, g_object_unref, RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, (GBoxedCopyFunc) g_object_ref, g_object_unref, (GeeHashDataFunc) g_file_hash, NULL, NULL, (GeeEqualDataFunc) g_file_equal, NULL, NULL, NULL, NULL, NULL);
+ _g_object_unref0 (self->priv->tasks);
+ self->priv->tasks = _tmp23_;
+ _tmp24_ = gee_hash_map_new (G_TYPE_FILE, (GBoxedCopyFunc) g_object_ref, g_object_unref, G_TYPE_UINT, NULL, NULL, (GeeHashDataFunc) g_file_hash, NULL, NULL, (GeeEqualDataFunc) g_file_equal, NULL, NULL, NULL, NULL, NULL);
+ _g_object_unref0 (self->priv->extraction_grace_timers);
+ self->priv->extraction_grace_timers = _tmp24_;
+ return self;
+}
+
+
+RygelMediaExportHarvester* rygel_media_export_harvester_new (GCancellable* cancellable, GeeArrayList* locations) {
+ return rygel_media_export_harvester_construct (RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, cancellable, locations);
+}
+
+
+/**
+ * Put a file on queue for meta-data extraction
+ *
+ * @param file the file to investigate
+ * @param parent container of the filer to be harvested
+ * @param flag optional flag for the container to set in the database
+ */
+static void _rygel_media_export_harvester_on_file_harvested_rygel_state_machine_completed (RygelStateMachine* _sender, gpointer self) {
+ rygel_media_export_harvester_on_file_harvested (self, _sender);
+}
+
+
+void rygel_media_export_harvester_schedule (RygelMediaExportHarvester* self, GFile* file, RygelMediaContainer* parent, const gchar* flag) {
+ GeeHashMap* _tmp0_;
+ GFile* _tmp1_;
+ RygelMediaExportMetadataExtractor* _tmp2_;
+ GFile* _tmp4_;
+ RygelMediaExportMetadataExtractor* _tmp5_;
+ RygelMediaExportMetadataExtractor* _tmp6_;
+ RygelMediaExportRecursiveFileMonitor* _tmp7_;
+ GFile* _tmp8_;
+ RygelMediaContainer* _tmp9_;
+ const gchar* _tmp10_;
+ RygelMediaExportHarvestingTask* _tmp11_;
+ RygelMediaExportHarvestingTask* _tmp12_;
+ RygelMediaExportHarvestingTask* task;
+ RygelMediaExportHarvestingTask* _tmp13_;
+ GCancellable* _tmp14_;
+ RygelMediaExportHarvestingTask* _tmp15_;
+ GeeHashMap* _tmp16_;
+ GFile* _tmp17_;
+ RygelMediaExportHarvestingTask* _tmp18_;
+ RygelMediaExportHarvestingTask* _tmp19_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ g_return_if_fail (parent != NULL);
+ _tmp0_ = self->priv->extraction_grace_timers;
+ _tmp1_ = file;
+ gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, _tmp1_, NULL);
+ _tmp2_ = self->priv->extractor;
+ if (_tmp2_ == NULL) {
+ const gchar* _tmp3_ = NULL;
+ _tmp3_ = _ ("No metadata extractor available. Will not crawl.");
+ g_warning ("rygel-media-export-harvester.vala:78: %s", _tmp3_);
+ return;
+ }
+ _tmp4_ = file;
+ rygel_media_export_harvester_cancel (self, _tmp4_);
+ _tmp5_ = rygel_media_export_metadata_extractor_new ();
+ _tmp6_ = _tmp5_;
+ _tmp7_ = self->priv->monitor;
+ _tmp8_ = file;
+ _tmp9_ = parent;
+ _tmp10_ = flag;
+ _tmp11_ = rygel_media_export_harvesting_task_new (_tmp6_, _tmp7_, _tmp8_, _tmp9_, _tmp10_);
+ _tmp12_ = _tmp11_;
+ _g_object_unref0 (_tmp6_);
+ task = _tmp12_;
+ _tmp13_ = task;
+ _tmp14_ = self->priv->cancellable;
+ rygel_state_machine_set_cancellable ((RygelStateMachine*) _tmp13_, _tmp14_);
+ _tmp15_ = task;
+ g_signal_connect_object ((RygelStateMachine*) _tmp15_, "completed", (GCallback) _rygel_media_export_harvester_on_file_harvested_rygel_state_machine_completed, self, 0);
+ _tmp16_ = self->priv->tasks;
+ _tmp17_ = file;
+ _tmp18_ = task;
+ gee_abstract_map_set ((GeeAbstractMap*) _tmp16_, _tmp17_, _tmp18_);
+ _tmp19_ = task;
+ rygel_state_machine_run ((RygelStateMachine*) _tmp19_, NULL, NULL);
+ _g_object_unref0 (task);
+}
+
+
+/**
+ * Cancel a running meta-data extraction run
+ *
+ * @param file file cancel the current run for
+ */
+void rygel_media_export_harvester_cancel (RygelMediaExportHarvester* self, GFile* file) {
+ GeeHashMap* _tmp0_;
+ GFile* _tmp1_;
+ gboolean _tmp2_ = FALSE;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ _tmp0_ = self->priv->tasks;
+ _tmp1_ = file;
+ _tmp2_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp1_);
+ if (_tmp2_) {
+ GeeHashMap* _tmp3_;
+ GFile* _tmp4_;
+ gpointer _tmp5_ = NULL;
+ RygelMediaExportHarvestingTask* task;
+ RygelMediaExportHarvestingTask* _tmp6_;
+ guint _tmp7_ = 0U;
+ GeeHashMap* _tmp8_;
+ GFile* _tmp9_;
+ RygelMediaExportHarvestingTask* _tmp10_;
+ _tmp3_ = self->priv->tasks;
+ _tmp4_ = file;
+ _tmp5_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp4_);
+ task = (RygelMediaExportHarvestingTask*) _tmp5_;
+ _tmp6_ = task;
+ g_signal_parse_name ("completed", RYGEL_TYPE_STATE_MACHINE, &_tmp7_, NULL, FALSE);
+ g_signal_handlers_disconnect_matched ((RygelStateMachine*) _tmp6_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _rygel_media_export_harvester_on_file_harvested_rygel_state_machine_completed, self);
+ _tmp8_ = self->priv->tasks;
+ _tmp9_ = file;
+ gee_abstract_map_unset ((GeeAbstractMap*) _tmp8_, _tmp9_, NULL);
+ _tmp10_ = task;
+ rygel_media_export_harvesting_task_cancel (_tmp10_);
+ _g_object_unref0 (task);
+ }
+}
+
+
+/**
+ * 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) {
+ RygelStateMachine* _tmp0_;
+ RygelMediaExportHarvestingTask* _tmp1_;
+ RygelMediaExportHarvestingTask* task;
+ RygelMediaExportHarvestingTask* _tmp2_;
+ GFile* _tmp3_;
+ GFile* _tmp4_;
+ GFile* file;
+ const gchar* _tmp5_ = NULL;
+ GFile* _tmp6_;
+ gchar* _tmp7_ = NULL;
+ gchar* _tmp8_;
+ GeeHashMap* _tmp9_;
+ GFile* _tmp10_;
+ GeeHashMap* _tmp11_;
+ gboolean _tmp12_;
+ gboolean _tmp13_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (state_machine != NULL);
+ _tmp0_ = state_machine;
+ _tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK) ? ((RygelMediaExportHarvestingTask*) _tmp0_) : NULL);
+ task = _tmp1_;
+ _tmp2_ = task;
+ _tmp3_ = _tmp2_->origin;
+ _tmp4_ = _g_object_ref0 (_tmp3_);
+ file = _tmp4_;
+ _tmp5_ = _ ("'%s' harvested");
+ _tmp6_ = file;
+ _tmp7_ = g_file_get_uri (_tmp6_);
+ _tmp8_ = _tmp7_;
+ g_message (_tmp5_, _tmp8_);
+ _g_free0 (_tmp8_);
+ _tmp9_ = self->priv->tasks;
+ _tmp10_ = file;
+ gee_abstract_map_unset ((GeeAbstractMap*) _tmp9_, _tmp10_, NULL);
+ _tmp11_ = self->priv->tasks;
+ _tmp12_ = gee_map_get_is_empty ((GeeMap*) _tmp11_);
+ _tmp13_ = _tmp12_;
+ if (_tmp13_) {
+ g_signal_emit_by_name (self, "done");
+ }
+ _g_object_unref0 (file);
+ _g_object_unref0 (task);
+}
+
+
+static void rygel_media_export_harvester_on_file_changed (RygelMediaExportHarvester* self, GFile* file, GFile* other, GFileMonitorEvent event) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ {
+ GFileMonitorEvent _tmp0_;
+ _tmp0_ = event;
+ switch (_tmp0_) {
+ case G_FILE_MONITOR_EVENT_CREATED:
+ case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
+ {
+ GFile* _tmp1_;
+ _tmp1_ = file;
+ rygel_media_export_harvester_on_changes_done (self, _tmp1_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch46_g_error;
+ }
+ break;
+ }
+ case G_FILE_MONITOR_EVENT_DELETED:
+ {
+ GFile* _tmp2_;
+ _tmp2_ = file;
+ rygel_media_export_harvester_on_file_removed (self, _tmp2_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch46_g_error;
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ }
+ goto __finally46;
+ __catch46_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally46:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_harvester_on_file_added (RygelMediaExportHarvester* self, GFile* file) {
+ GFile* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* _tmp2_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ _tmp0_ = file;
+ _tmp1_ = g_file_get_uri (_tmp0_);
+ _tmp2_ = _tmp1_;
+ g_debug ("rygel-media-export-harvester.vala:147: Filesystem events settled for %" \
+"s, scheduling extractionâ", _tmp2_);
+ _g_free0 (_tmp2_);
+ {
+ RygelMediaExportMediaCache* _tmp3_ = NULL;
+ RygelMediaExportMediaCache* cache;
+ GFile* _tmp4_;
+ GCancellable* _tmp5_;
+ GFileInfo* _tmp6_ = NULL;
+ GFileInfo* info;
+ gboolean _tmp7_ = FALSE;
+ gboolean _tmp8_ = FALSE;
+ gboolean _tmp9_ = FALSE;
+ gboolean _tmp10_ = FALSE;
+ GFileInfo* _tmp11_;
+ GFileType _tmp12_ = 0;
+ gboolean _tmp16_;
+ gboolean _tmp20_;
+ gboolean _tmp24_;
+ gboolean _tmp27_;
+ _tmp3_ = rygel_media_export_media_cache_get_default (&_inner_error_);
+ cache = _tmp3_;
+ if (_inner_error_ != NULL) {
+ goto __catch47_g_error;
+ }
+ _tmp4_ = file;
+ _tmp5_ = self->priv->cancellable;
+ _tmp6_ = g_file_query_info (_tmp4_, G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, _tmp5_, &_inner_error_);
+ info = _tmp6_;
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (cache);
+ goto __catch47_g_error;
+ }
+ _tmp11_ = info;
+ _tmp12_ = g_file_info_get_file_type (_tmp11_);
+ if (_tmp12_ == G_FILE_TYPE_DIRECTORY) {
+ _tmp10_ = TRUE;
+ } else {
+ GFileInfo* _tmp13_;
+ const gchar* _tmp14_ = NULL;
+ gboolean _tmp15_ = FALSE;
+ _tmp13_ = info;
+ _tmp14_ = g_file_info_get_content_type (_tmp13_);
+ _tmp15_ = g_str_has_prefix (_tmp14_, "image/");
+ _tmp10_ = _tmp15_;
+ }
+ _tmp16_ = _tmp10_;
+ if (_tmp16_) {
+ _tmp9_ = TRUE;
+ } else {
+ GFileInfo* _tmp17_;
+ const gchar* _tmp18_ = NULL;
+ gboolean _tmp19_ = FALSE;
+ _tmp17_ = info;
+ _tmp18_ = g_file_info_get_content_type (_tmp17_);
+ _tmp19_ = g_str_has_prefix (_tmp18_, "video/");
+ _tmp9_ = _tmp19_;
+ }
+ _tmp20_ = _tmp9_;
+ if (_tmp20_) {
+ _tmp8_ = TRUE;
+ } else {
+ GFileInfo* _tmp21_;
+ const gchar* _tmp22_ = NULL;
+ gboolean _tmp23_ = FALSE;
+ _tmp21_ = info;
+ _tmp22_ = g_file_info_get_content_type (_tmp21_);
+ _tmp23_ = g_str_has_prefix (_tmp22_, "audio/");
+ _tmp8_ = _tmp23_;
+ }
+ _tmp24_ = _tmp8_;
+ if (_tmp24_) {
+ _tmp7_ = TRUE;
+ } else {
+ GFileInfo* _tmp25_;
+ const gchar* _tmp26_ = NULL;
+ _tmp25_ = info;
+ _tmp26_ = g_file_info_get_content_type (_tmp25_);
+ _tmp7_ = g_strcmp0 (_tmp26_, "application/ogg") == 0;
+ }
+ _tmp27_ = _tmp7_;
+ if (_tmp27_) {
+ gchar* id = NULL;
+ {
+ RygelMediaContainer* parent_container;
+ GFile* _tmp28_;
+ GFile* _tmp29_;
+ GFile* current;
+ GFile* _tmp50_;
+ RygelMediaContainer* _tmp51_;
+ parent_container = NULL;
+ _tmp28_ = file;
+ _tmp29_ = _g_object_ref0 (_tmp28_);
+ current = _tmp29_;
+ {
+ gboolean _tmp30_;
+ _tmp30_ = TRUE;
+ while (TRUE) {
+ gboolean _tmp31_;
+ GFile* _tmp33_;
+ GFile* _tmp34_ = NULL;
+ GFile* parent;
+ GFile* _tmp35_;
+ gchar* _tmp36_ = NULL;
+ RygelMediaExportMediaCache* _tmp37_;
+ const gchar* _tmp38_;
+ RygelMediaObject* _tmp39_ = NULL;
+ RygelMediaObject* _tmp40_;
+ RygelMediaContainer* _tmp41_;
+ GeeArrayList* _tmp44_;
+ GFile* _tmp45_;
+ gboolean _tmp46_ = FALSE;
+ _tmp31_ = _tmp30_;
+ if (!_tmp31_) {
+ RygelMediaContainer* _tmp32_;
+ _tmp32_ = parent_container;
+ if (!(_tmp32_ == NULL)) {
+ break;
+ }
+ }
+ _tmp30_ = FALSE;
+ _tmp33_ = current;
+ _tmp34_ = g_file_get_parent (_tmp33_);
+ parent = _tmp34_;
+ _tmp35_ = parent;
+ _tmp36_ = rygel_media_export_media_cache_get_id (_tmp35_);
+ _g_free0 (id);
+ id = _tmp36_;
+ _tmp37_ = cache;
+ _tmp38_ = id;
+ _tmp39_ = rygel_media_export_media_cache_get_object (_tmp37_, _tmp38_, &_inner_error_);
+ _tmp40_ = _tmp39_;
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (parent);
+ _g_object_unref0 (current);
+ _g_object_unref0 (parent_container);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch48_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (parent);
+ _g_object_unref0 (current);
+ _g_object_unref0 (parent_container);
+ _g_free0 (id);
+ _g_object_unref0 (info);
+ _g_object_unref0 (cache);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _g_object_unref0 (parent_container);
+ parent_container = G_TYPE_CHECK_INSTANCE_TYPE (_tmp40_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp40_) : NULL;
+ _tmp41_ = parent_container;
+ if (_tmp41_ == NULL) {
+ GFile* _tmp42_;
+ GFile* _tmp43_;
+ _tmp42_ = parent;
+ _tmp43_ = _g_object_ref0 (_tmp42_);
+ _g_object_unref0 (current);
+ current = _tmp43_;
+ }
+ _tmp44_ = self->priv->_locations;
+ _tmp45_ = current;
+ _tmp46_ = gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp44_, _tmp45_);
+ if (_tmp46_) {
+ RygelMediaExportMediaCache* _tmp47_;
+ RygelMediaObject* _tmp48_ = NULL;
+ RygelMediaObject* _tmp49_;
+ _tmp47_ = cache;
+ _tmp48_ = rygel_media_export_media_cache_get_object (_tmp47_, RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID, &_inner_error_);
+ _tmp49_ = _tmp48_;
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (parent);
+ _g_object_unref0 (current);
+ _g_object_unref0 (parent_container);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch48_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (parent);
+ _g_object_unref0 (current);
+ _g_object_unref0 (parent_container);
+ _g_free0 (id);
+ _g_object_unref0 (info);
+ _g_object_unref0 (cache);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _g_object_unref0 (parent_container);
+ parent_container = G_TYPE_CHECK_INSTANCE_TYPE (_tmp49_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp49_) : NULL;
+ _g_object_unref0 (parent);
+ break;
+ }
+ _g_object_unref0 (parent);
+ }
+ }
+ _tmp50_ = current;
+ _tmp51_ = parent_container;
+ rygel_media_export_harvester_schedule (self, _tmp50_, _tmp51_, NULL);
+ _g_object_unref0 (current);
+ _g_object_unref0 (parent_container);
+ }
+ goto __finally48;
+ __catch48_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp52_ = NULL;
+ const gchar* _tmp53_;
+ GError* _tmp54_;
+ const gchar* _tmp55_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp52_ = _ ("Error fetching object '%s' from database: %s");
+ _tmp53_ = id;
+ _tmp54_ = _error_;
+ _tmp55_ = _tmp54_->message;
+ g_warning (_tmp52_, _tmp53_, _tmp55_);
+ _g_error_free0 (_error_);
+ }
+ __finally48:
+ if (_inner_error_ != NULL) {
+ _g_free0 (id);
+ _g_object_unref0 (info);
+ _g_object_unref0 (cache);
+ goto __catch47_g_error;
+ }
+ _g_free0 (id);
+ } else {
+ GFile* _tmp56_;
+ gchar* _tmp57_ = NULL;
+ gchar* _tmp58_;
+ _tmp56_ = file;
+ _tmp57_ = g_file_get_uri (_tmp56_);
+ _tmp58_ = _tmp57_;
+ g_debug ("rygel-media-export-harvester.vala:191: %s is not eligible for extracti" \
+"on", _tmp58_);
+ _g_free0 (_tmp58_);
+ }
+ _g_object_unref0 (info);
+ _g_object_unref0 (cache);
+ }
+ goto __finally47;
+ __catch47_g_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp59_ = NULL;
+ GError* _tmp60_;
+ const gchar* _tmp61_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp59_ = _ ("Failed to access media cache: %s");
+ _tmp60_ = _error_;
+ _tmp61_ = _tmp60_->message;
+ g_warning (_tmp59_, _tmp61_);
+ _g_error_free0 (_error_);
+ }
+ __finally47:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+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_free0 (id);
+ goto __catch49_g_error;
+ }
+ _tmp14_ = _g_object_ref0 (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_ = _tmp16_->parent;
+ _tmp18_ = _g_object_ref0 (_tmp17_);
+ _g_object_unref0 (parent);
+ parent = _tmp18_;
+ _tmp19_ = object;
+ rygel_media_export_media_cache_remove_object (cache, _tmp19_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (parent);
+ _g_object_unref0 (object);
+ _g_free0 (id);
+ goto __catch49_g_error;
+ }
+ _tmp20_ = parent;
+ if (_tmp20_ == NULL) {
+ break;
+ }
+ _tmp21_ = parent;
+ _tmp22_ = _tmp21_->child_count;
+ _tmp21_->child_count = _tmp22_ - 1;
+ _tmp23_ = parent;
+ _tmp24_ = _tmp23_->child_count;
+ if (_tmp24_ != 0) {
+ break;
+ }
+ _tmp25_ = parent;
+ _tmp26_ = _g_object_ref0 ((RygelMediaObject*) _tmp25_);
+ _g_object_unref0 (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_unref0 (parent);
+ _g_object_unref0 (object);
+ _g_free0 (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_free0 (_error_);
+ }
+ __finally49:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (cache);
+ return;
+ }
+ _g_object_unref0 (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_unref0 (_data3_->file);
+ _g_object_unref0 (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) {
+ 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_ref0 (_tmp0_);
+ _g_object_unref0 (_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_free0 (_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) {
+ GeeArrayList* _tmp0_;
+ GeeArrayList* _tmp1_;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = value;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (self->priv->_locations);
+ self->priv->_locations = _tmp1_;
+ g_object_notify ((GObject *) self, "locations");
+}
+
+
+static void rygel_media_export_harvester_class_init (RygelMediaExportHarvesterClass * klass) {
+ rygel_media_export_harvester_parent_class = g_type_class_peek_parent (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_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);
+}
+
+
+static void rygel_media_export_harvester_init (RygelMediaExportHarvester * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_HARVESTER_GET_PRIVATE (self);
+}
+
+
+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_unref0 (self->priv->tasks);
+ _g_object_unref0 (self->priv->extraction_grace_timers);
+ _g_object_unref0 (self->priv->extractor);
+ _g_object_unref0 (self->priv->monitor);
+ _g_object_unref0 (self->priv->cancellable);
+ _g_object_unref0 (self->priv->_locations);
+ G_OBJECT_CLASS (rygel_media_export_harvester_parent_class)->finalize (obj);
+}
+
+
+
+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;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+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:
+ rygel_media_export_harvester_set_locations (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-harvester.h b/src/media-export/rygel-media-export-harvester.h
new file mode 100644
index 0000000..f5bad4b
--- /dev/null
+++ b/src/media-export/rygel-media-export-harvester.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_HARVESTER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_HARVESTER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_HARVESTER (rygel_media_export_harvester_get_type ())
+#define RYGEL_MEDIA_EXPORT_HARVESTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvester))
+#define RYGEL_MEDIA_EXPORT_HARVESTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvesterClass))
+#define RYGEL_MEDIA_EXPORT_IS_HARVESTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER))
+#define RYGEL_MEDIA_EXPORT_IS_HARVESTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER))
+#define RYGEL_MEDIA_EXPORT_HARVESTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvesterClass))
+
+typedef struct _RygelMediaExportHarvester RygelMediaExportHarvester;
+typedef struct _RygelMediaExportHarvesterClass RygelMediaExportHarvesterClass;
+typedef struct _RygelMediaExportHarvesterPrivate RygelMediaExportHarvesterPrivate;
+
+struct _RygelMediaExportHarvester {
+ GObject parent_instance;
+ RygelMediaExportHarvesterPrivate *priv;
+};
+
+struct _RygelMediaExportHarvesterClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_harvester_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportHarvester* rygel_media_export_harvester_new (GCancellable* cancellable, GeeArrayList* locations);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_HARVESTER_H__ */
diff --git a/src/media-export/rygel-media-export-harvesting-task.c b/src/media-export/rygel-media-export-harvesting-task.c
new file mode 100644
index 0000000..24bf67d
--- /dev/null
+++ b/src/media-export/rygel-media-export-harvesting-task.c
@@ -0,0 +1,1551 @@
+/* rygel-media-export-harvesting-task.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-harvesting-task.vala, do not modify */
+
+/*
+ * Copyright (C) 2009 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-harvesting-task.h"
+#include "rygel-media-export-database.h"
+#include "rygel-media-export-dummy-container.h"
+#include "rygel-media-export-media-cache.h"
+#include <libgupnp-dlna/gupnp-dlna-information.h>
+#include <glib/gi18n-lib.h>
+
+G_DEFINE_TYPE (RygelMediaExportHarvestingTask, rygel_media_export_harvesting_task, G_TYPE_OBJECT)
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR (rygel_media_export_metadata_extractor_get_type ())
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractor))
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorClass))
+#define RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR))
+#define RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR))
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorClass))
+
+typedef struct _RygelMediaExportMetadataExtractor RygelMediaExportMetadataExtractor;
+typedef struct _RygelMediaExportMetadataExtractorClass RygelMediaExportMetadataExtractorClass;
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR (rygel_media_export_recursive_file_monitor_get_type ())
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitor))
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitorClass))
+#define RYGEL_MEDIA_EXPORT_IS_RECURSIVE_FILE_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR))
+#define RYGEL_MEDIA_EXPORT_IS_RECURSIVE_FILE_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR))
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitorClass))
+
+typedef struct _RygelMediaExportRecursiveFileMonitor RygelMediaExportRecursiveFileMonitor;
+typedef struct _RygelMediaExportRecursiveFileMonitorClass RygelMediaExportRecursiveFileMonitorClass;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define __g_queue_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_queue_free__g_object_unref0_ (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+typedef struct _RygelMediaExportHarvestingTaskRunData RygelMediaExportHarvestingTaskRunData;
+
+
+#define __g_list_free__g_object_unref0_0(var) ((var == NULL) ? NULL : (var = (_g_list_free__g_object_unref0_ (var), NULL)))
+typedef struct _RygelMediaExportHarvestingTaskEnumerateDirectoryData RygelMediaExportHarvestingTaskEnumerateDirectoryData;
+
+struct _RygelMediaExportHarvestingTaskPrivate {
+ RygelMediaExportMetadataExtractor* extractor;
+ RygelMediaExportMediaCache* cache;
+ GQueue* containers;
+ GeeQueue* files;
+ RygelMediaExportRecursiveFileMonitor* monitor;
+ gchar* flag;
+ RygelMediaContainer* parent;
+ GCancellable* _cancellable;
+};
+
+struct _RygelMediaExportHarvestingTaskRunData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportHarvestingTask* self;
+ GFile* _tmp0_;
+ GCancellable* _tmp1_;
+ GCancellable* _tmp2_;
+ GFileInfo* _tmp3_;
+ GFileInfo* info;
+ GFile* _tmp4_;
+ RygelMediaContainer* _tmp5_;
+ gboolean _tmp6_;
+ GFileType _tmp7_;
+ GQueue* _tmp8_;
+ RygelMediaContainer* _tmp9_;
+ RygelMediaContainer* _tmp10_;
+ GError* _error_;
+ GError* _tmp11_;
+ const gchar* _tmp12_;
+ GFile* _tmp13_;
+ gchar* _tmp14_;
+ gchar* _tmp15_;
+ GError* _tmp16_;
+ const gchar* _tmp17_;
+ GFile* _tmp18_;
+ gchar* _tmp19_;
+ gchar* _tmp20_;
+ GError * _inner_error_;
+};
+
+
+struct _RygelMediaExportHarvestingTaskEnumerateDirectoryData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportHarvestingTask* self;
+ GQueue* _tmp0_;
+ gconstpointer _tmp1_;
+ GFile* _tmp2_;
+ GFile* _tmp3_;
+ GFile* directory;
+ GFile* _tmp4_;
+ GCancellable* _tmp5_;
+ GCancellable* _tmp6_;
+ GFileEnumerator* _tmp7_;
+ GFileEnumerator* enumerator;
+ GList* list;
+ gboolean _tmp8_;
+ gboolean _tmp9_;
+ GList* _tmp10_;
+ gboolean _tmp11_;
+ GFileEnumerator* _tmp12_;
+ GCancellable* _tmp13_;
+ GCancellable* _tmp14_;
+ GList* _tmp15_;
+ GList* _tmp16_;
+ GFileEnumerator* _tmp17_;
+ GCancellable* _tmp18_;
+ GCancellable* _tmp19_;
+ GError* err;
+ const gchar* _tmp20_;
+ GError* _tmp21_;
+ const gchar* _tmp22_;
+ GError * _inner_error_;
+};
+
+
+static RygelStateMachineIface* rygel_media_export_harvesting_task_rygel_state_machine_parent_iface = NULL;
+
+#define RYGEL_MEDIA_EXPORT_HARVESTING_TASK_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, RygelMediaExportHarvestingTaskPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_HARVESTING_TASK_DUMMY_PROPERTY,
+ RYGEL_MEDIA_EXPORT_HARVESTING_TASK_CANCELLABLE
+};
+static void _g_object_unref0_ (gpointer var);
+static void _g_queue_free__g_object_unref0_ (GQueue* self);
+#define RYGEL_MEDIA_EXPORT_HARVESTING_TASK_BATCH_SIZE 256
+#define RYGEL_MEDIA_EXPORT_HARVESTING_TASK_HARVESTER_ATTRIBUTES G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_STANDARD_TYPE "," G_FILE_ATTRIBUTE_TIME_MODIFIED "," G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE
+RygelMediaExportHarvestingTask* rygel_media_export_harvesting_task_new (RygelMediaExportMetadataExtractor* extractor, RygelMediaExportRecursiveFileMonitor* monitor, GFile* file, RygelMediaContainer* parent, const gchar* flag);
+RygelMediaExportHarvestingTask* rygel_media_export_harvesting_task_construct (GType object_type, RygelMediaExportMetadataExtractor* extractor, RygelMediaExportRecursiveFileMonitor* monitor, GFile* file, RygelMediaContainer* parent, const gchar* flag);
+RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
+static void rygel_media_export_harvesting_task_on_extracted_cb (RygelMediaExportHarvestingTask* self, GFile* file, GUPnPDLNAInformation* dlna, GFileInfo* file_info);
+static void _rygel_media_export_harvesting_task_on_extracted_cb_rygel_media_export_metadata_extractor_extraction_done (RygelMediaExportMetadataExtractor* _sender, GFile* file, GUPnPDLNAInformation* dlna, GFileInfo* file_info, gpointer self);
+static void rygel_media_export_harvesting_task_on_extractor_error_cb (RygelMediaExportHarvestingTask* self, GFile* file, GError* _error_);
+static void _rygel_media_export_harvesting_task_on_extractor_error_cb_rygel_media_export_metadata_extractor_error (RygelMediaExportMetadataExtractor* _sender, GFile* file, GError* err, gpointer self);
+void rygel_media_export_harvesting_task_cancel (RygelMediaExportHarvestingTask* self);
+static void rygel_media_export_harvesting_task_real_run_data_free (gpointer _data);
+static void rygel_media_export_harvesting_task_real_run (RygelStateMachine* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_harvesting_task_real_run_co (RygelMediaExportHarvestingTaskRunData* _data_);
+static void rygel_media_export_harvesting_task_run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+static gboolean rygel_media_export_harvesting_task_process_file (RygelMediaExportHarvestingTask* self, GFile* file, GFileInfo* info, RygelMediaContainer* parent);
+static gboolean rygel_media_export_harvesting_task_on_idle (RygelMediaExportHarvestingTask* self);
+static gboolean rygel_media_export_harvesting_task_push_if_changed_or_unknown (RygelMediaExportHarvestingTask* self, GFile* file, GFileInfo* info);
+GQuark rygel_media_export_database_error_quark (void);
+gboolean rygel_media_export_media_cache_exists (RygelMediaExportMediaCache* self, GFile* file, gint64* timestamp, gint64* size, GError** error);
+void rygel_media_export_recursive_file_monitor_add (RygelMediaExportRecursiveFileMonitor* self, GFile* file, GAsyncReadyCallback _callback_, gpointer _user_data_);
+void rygel_media_export_recursive_file_monitor_add_finish (RygelMediaExportRecursiveFileMonitor* self, GAsyncResult* _res_);
+RygelMediaExportDummyContainer* rygel_media_export_dummy_container_new (GFile* file, RygelMediaContainer* parent);
+RygelMediaExportDummyContainer* rygel_media_export_dummy_container_construct (GType object_type, GFile* file, RygelMediaContainer* parent);
+
+void rygel_media_export_media_cache_save_container (RygelMediaExportMediaCache* self, RygelMediaContainer* container, GError** error);
+static gboolean rygel_media_export_harvesting_task_process_children (RygelMediaExportHarvestingTask* self, GList* list);
+void rygel_media_export_dummy_container_seen (RygelMediaExportDummyContainer* self, GFile* file);
+static void rygel_media_export_harvesting_task_enumerate_directory_data_free (gpointer _data);
+static void rygel_media_export_harvesting_task_enumerate_directory (RygelMediaExportHarvestingTask* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static void rygel_media_export_harvesting_task_enumerate_directory_finish (RygelMediaExportHarvestingTask* self, GAsyncResult* _res_);
+static gboolean rygel_media_export_harvesting_task_enumerate_directory_co (RygelMediaExportHarvestingTaskEnumerateDirectoryData* _data_);
+static void rygel_media_export_harvesting_task_enumerate_directory_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+static void _g_list_free__g_object_unref0_ (GList* self);
+static void rygel_media_export_harvesting_task_cleanup_database (RygelMediaExportHarvestingTask* self);
+static void rygel_media_export_harvesting_task_do_update (RygelMediaExportHarvestingTask* self);
+void rygel_media_export_media_cache_remove_by_id (RygelMediaExportMediaCache* self, const gchar* id, GError** error);
+void rygel_media_export_metadata_extractor_extract (RygelMediaExportMetadataExtractor* self, GFile* file);
+void rygel_media_export_media_cache_flag_object (RygelMediaExportMediaCache* self, GFile* file, const gchar* flag, GError** error);
+RygelMediaItem* rygel_media_export_item_factory_create_simple (RygelMediaContainer* parent, GFile* file, GFileInfo* info);
+RygelMediaItem* rygel_media_export_item_factory_create_from_info (RygelMediaContainer* parent, GFile* file, GUPnPDLNAInformation* dlna_info, GFileInfo* file_info);
+void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
+gint rygel_media_export_media_cache_get_child_count (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
+static void rygel_media_export_harvesting_task_finalize (GObject* obj);
+static void _vala_rygel_media_export_harvesting_task_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
+static void _vala_rygel_media_export_harvesting_task_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
+
+
+static void _g_object_unref0_ (gpointer var) {
+ (var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
+}
+
+
+static void _g_queue_free__g_object_unref0_ (GQueue* self) {
+ g_queue_foreach (self, (GFunc) _g_object_unref0_, NULL);
+ g_queue_free (self);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void _rygel_media_export_harvesting_task_on_extracted_cb_rygel_media_export_metadata_extractor_extraction_done (RygelMediaExportMetadataExtractor* _sender, GFile* file, GUPnPDLNAInformation* dlna, GFileInfo* file_info, gpointer self) {
+ rygel_media_export_harvesting_task_on_extracted_cb (self, file, dlna, file_info);
+}
+
+
+static void _rygel_media_export_harvesting_task_on_extractor_error_cb_rygel_media_export_metadata_extractor_error (RygelMediaExportMetadataExtractor* _sender, GFile* file, GError* err, gpointer self) {
+ rygel_media_export_harvesting_task_on_extractor_error_cb (self, file, err);
+}
+
+
+RygelMediaExportHarvestingTask* rygel_media_export_harvesting_task_construct (GType object_type, RygelMediaExportMetadataExtractor* extractor, RygelMediaExportRecursiveFileMonitor* monitor, GFile* file, RygelMediaContainer* parent, const gchar* flag) {
+ RygelMediaExportHarvestingTask * self = NULL;
+ RygelMediaExportMetadataExtractor* _tmp0_;
+ RygelMediaExportMetadataExtractor* _tmp1_;
+ GFile* _tmp2_;
+ GFile* _tmp3_;
+ RygelMediaContainer* _tmp4_;
+ RygelMediaContainer* _tmp5_;
+ RygelMediaExportMetadataExtractor* _tmp8_;
+ RygelMediaExportMetadataExtractor* _tmp9_;
+ GeeLinkedList* _tmp10_;
+ GQueue* _tmp11_;
+ RygelMediaExportRecursiveFileMonitor* _tmp12_;
+ RygelMediaExportRecursiveFileMonitor* _tmp13_;
+ const gchar* _tmp14_;
+ gchar* _tmp15_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (extractor != NULL, NULL);
+ g_return_val_if_fail (monitor != NULL, NULL);
+ g_return_val_if_fail (file != NULL, NULL);
+ g_return_val_if_fail (parent != NULL, NULL);
+ self = (RygelMediaExportHarvestingTask*) g_object_new (object_type, NULL);
+ _tmp0_ = extractor;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (self->priv->extractor);
+ self->priv->extractor = _tmp1_;
+ _tmp2_ = file;
+ _tmp3_ = _g_object_ref0 (_tmp2_);
+ _g_object_unref0 (self->origin);
+ self->origin = _tmp3_;
+ _tmp4_ = parent;
+ _tmp5_ = _g_object_ref0 (_tmp4_);
+ _g_object_unref0 (self->priv->parent);
+ self->priv->parent = _tmp5_;
+ {
+ RygelMediaExportMediaCache* _tmp6_ = NULL;
+ RygelMediaExportMediaCache* _tmp7_;
+ _tmp6_ = rygel_media_export_media_cache_get_default (&_inner_error_);
+ _tmp7_ = _tmp6_;
+ if (_inner_error_ != NULL) {
+ goto __catch50_g_error;
+ }
+ _g_object_unref0 (self->priv->cache);
+ self->priv->cache = _tmp7_;
+ }
+ goto __finally50;
+ __catch50_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ g_assert_not_reached ();
+ _g_error_free0 (_error_);
+ }
+ __finally50:
+ if (_inner_error_ != 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 NULL;
+ }
+ _tmp8_ = self->priv->extractor;
+ g_signal_connect_object (_tmp8_, "extraction-done", (GCallback) _rygel_media_export_harvesting_task_on_extracted_cb_rygel_media_export_metadata_extractor_extraction_done, self, 0);
+ _tmp9_ = self->priv->extractor;
+ g_signal_connect_object (_tmp9_, "error", (GCallback) _rygel_media_export_harvesting_task_on_extractor_error_cb_rygel_media_export_metadata_extractor_error, self, 0);
+ _tmp10_ = gee_linked_list_new (G_TYPE_FILE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
+ _g_object_unref0 (self->priv->files);
+ self->priv->files = (GeeQueue*) _tmp10_;
+ _tmp11_ = g_queue_new ();
+ __g_queue_free__g_object_unref0_0 (self->priv->containers);
+ self->priv->containers = _tmp11_;
+ _tmp12_ = monitor;
+ _tmp13_ = _g_object_ref0 (_tmp12_);
+ _g_object_unref0 (self->priv->monitor);
+ self->priv->monitor = _tmp13_;
+ _tmp14_ = flag;
+ _tmp15_ = g_strdup (_tmp14_);
+ _g_free0 (self->priv->flag);
+ self->priv->flag = _tmp15_;
+ return self;
+}
+
+
+RygelMediaExportHarvestingTask* rygel_media_export_harvesting_task_new (RygelMediaExportMetadataExtractor* extractor, RygelMediaExportRecursiveFileMonitor* monitor, GFile* file, RygelMediaContainer* parent, const gchar* flag) {
+ return rygel_media_export_harvesting_task_construct (RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, extractor, monitor, file, parent, flag);
+}
+
+
+void rygel_media_export_harvesting_task_cancel (RygelMediaExportHarvestingTask* self) {
+ GCancellable* _tmp0_;
+ GCancellable* _tmp1_;
+ GCancellable* _tmp2_;
+ GCancellable* _tmp3_;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = g_cancellable_new ();
+ _tmp1_ = _tmp0_;
+ rygel_state_machine_set_cancellable ((RygelStateMachine*) self, _tmp1_);
+ _g_object_unref0 (_tmp1_);
+ _tmp2_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) self);
+ _tmp3_ = _tmp2_;
+ g_cancellable_cancel (_tmp3_);
+}
+
+
+static void rygel_media_export_harvesting_task_real_run_data_free (gpointer _data) {
+ RygelMediaExportHarvestingTaskRunData* _data_;
+ _data_ = _data;
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportHarvestingTaskRunData, _data_);
+}
+
+
+static void rygel_media_export_harvesting_task_real_run (RygelStateMachine* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportHarvestingTask * self;
+ RygelMediaExportHarvestingTaskRunData* _data_;
+ RygelMediaExportHarvestingTask* _tmp0_;
+ self = (RygelMediaExportHarvestingTask*) base;
+ _data_ = g_slice_new0 (RygelMediaExportHarvestingTaskRunData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_harvesting_task_real_run);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_harvesting_task_real_run_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ rygel_media_export_harvesting_task_real_run_co (_data_);
+}
+
+
+static void rygel_media_export_harvesting_task_real_run_finish (RygelStateMachine* base, GAsyncResult* _res_) {
+ RygelMediaExportHarvestingTaskRunData* _data_;
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+/**
+ * Extract all metainformation from a given file.
+ *
+ * What action will be taken depends on the arguments
+ * * file is a simple file. Then only information of this
+ * file will be extracted
+ * * file is a directory and recursive is false. The children
+ * of the directory (if not directories themselves) will be
+ * enqueued for extraction
+ * * file is a directory and recursive is true. ++ All ++ children
+ * of the directory will be enqueued for extraction, even directories
+ *
+ * No matter how many children are contained within file's hierarchy,
+ * only one event is sent when all the children are done.
+ */
+static void rygel_media_export_harvesting_task_run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ RygelMediaExportHarvestingTaskRunData* _data_;
+ _data_ = _user_data_;
+ _data_->_source_object_ = source_object;
+ _data_->_res_ = _res_;
+ rygel_media_export_harvesting_task_real_run_co (_data_);
+}
+
+
+static gboolean rygel_media_export_harvesting_task_real_run_co (RygelMediaExportHarvestingTaskRunData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ case 1:
+ goto _state_1;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ {
+ _data_->_tmp0_ = _data_->self->origin;
+ _data_->_tmp1_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) _data_->self);
+ _data_->_tmp2_ = _data_->_tmp1_;
+ _data_->_state_ = 1;
+ g_file_query_info_async (_data_->_tmp0_, RYGEL_MEDIA_EXPORT_HARVESTING_TASK_HARVESTER_ATTRIBUTES, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, _data_->_tmp2_, rygel_media_export_harvesting_task_run_ready, _data_);
+ return FALSE;
+ _state_1:
+ _data_->_tmp3_ = NULL;
+ _data_->_tmp3_ = g_file_query_info_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error_);
+ _data_->info = _data_->_tmp3_;
+ if (_data_->_inner_error_ != NULL) {
+ goto __catch51_g_error;
+ }
+ _data_->_tmp4_ = _data_->self->origin;
+ _data_->_tmp5_ = _data_->self->priv->parent;
+ _data_->_tmp6_ = FALSE;
+ _data_->_tmp6_ = rygel_media_export_harvesting_task_process_file (_data_->self, _data_->_tmp4_, _data_->info, _data_->_tmp5_);
+ if (_data_->_tmp6_) {
+ _data_->_tmp7_ = 0;
+ _data_->_tmp7_ = g_file_info_get_file_type (_data_->info);
+ if (_data_->_tmp7_ != G_FILE_TYPE_DIRECTORY) {
+ _data_->_tmp8_ = _data_->self->priv->containers;
+ _data_->_tmp9_ = _data_->self->priv->parent;
+ _data_->_tmp10_ = _g_object_ref0 (_data_->_tmp9_);
+ g_queue_push_tail (_data_->_tmp8_, _data_->_tmp10_);
+ }
+ rygel_media_export_harvesting_task_on_idle (_data_->self);
+ } else {
+ g_signal_emit_by_name ((RygelStateMachine*) _data_->self, "completed");
+ }
+ _g_object_unref0 (_data_->info);
+ }
+ goto __finally51;
+ __catch51_g_error:
+ {
+ _data_->_error_ = _data_->_inner_error_;
+ _data_->_inner_error_ = NULL;
+ _data_->_tmp11_ = _data_->_error_;
+ if (!g_error_matches (_data_->_tmp11_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
+ _data_->_tmp12_ = NULL;
+ _data_->_tmp12_ = _ ("Failed to harvest file %s: %s");
+ _data_->_tmp13_ = _data_->self->origin;
+ _data_->_tmp14_ = NULL;
+ _data_->_tmp14_ = g_file_get_uri (_data_->_tmp13_);
+ _data_->_tmp15_ = _data_->_tmp14_;
+ _data_->_tmp16_ = _data_->_error_;
+ _data_->_tmp17_ = _data_->_tmp16_->message;
+ g_warning (_data_->_tmp12_, _data_->_tmp15_, _data_->_tmp17_);
+ _g_free0 (_data_->_tmp15_);
+ } else {
+ _data_->_tmp18_ = _data_->self->origin;
+ _data_->_tmp19_ = NULL;
+ _data_->_tmp19_ = g_file_get_uri (_data_->_tmp18_);
+ _data_->_tmp20_ = _data_->_tmp19_;
+ g_debug ("rygel-media-export-harvesting-task.vala:116: Harvesting of uri %s was " \
+"cancelled", _data_->_tmp20_);
+ _g_free0 (_data_->_tmp20_);
+ }
+ g_signal_emit_by_name ((RygelStateMachine*) _data_->self, "completed");
+ _g_error_free0 (_data_->_error_);
+ }
+ __finally51:
+ if (_data_->_inner_error_ != NULL) {
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
+ g_clear_error (&_data_->_inner_error_);
+ return FALSE;
+ }
+ 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;
+}
+
+
+/**
+ * Add a file to the meta-data extraction queue.
+ *
+ * The file will only be added to the queue if one of the following
+ * conditions is met:
+ * - The file is not in the cache
+ * - The current mtime of the file is larger than the cached
+ * - The size has changed
+ * @param file to check
+ * @param info FileInfo of the file to check
+ * @return true, if the file has been queued, false otherwise.
+ */
+static gboolean rygel_media_export_harvesting_task_push_if_changed_or_unknown (RygelMediaExportHarvestingTask* self, GFile* file, GFileInfo* info) {
+ gboolean result = FALSE;
+ gint64 timestamp = 0LL;
+ gint64 size = 0LL;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
+ {
+ RygelMediaExportMediaCache* _tmp0_;
+ GFile* _tmp1_;
+ gint64 _tmp2_ = 0LL;
+ gint64 _tmp3_ = 0LL;
+ gboolean _tmp4_ = FALSE;
+ gboolean _tmp5_;
+ _tmp0_ = self->priv->cache;
+ _tmp1_ = file;
+ _tmp4_ = rygel_media_export_media_cache_exists (_tmp0_, _tmp1_, &_tmp2_, &_tmp3_, &_inner_error_);
+ timestamp = _tmp2_;
+ size = _tmp3_;
+ _tmp5_ = _tmp4_;
+ if (_inner_error_ != NULL) {
+ goto __catch52_g_error;
+ }
+ if (_tmp5_) {
+ GFileInfo* _tmp6_;
+ guint64 _tmp7_ = 0ULL;
+ gint64 mtime;
+ gboolean _tmp8_ = FALSE;
+ gint64 _tmp9_;
+ gint64 _tmp10_;
+ gboolean _tmp14_;
+ _tmp6_ = info;
+ _tmp7_ = g_file_info_get_attribute_uint64 (_tmp6_, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ mtime = (gint64) _tmp7_;
+ _tmp9_ = mtime;
+ _tmp10_ = timestamp;
+ if (_tmp9_ > _tmp10_) {
+ _tmp8_ = TRUE;
+ } else {
+ GFileInfo* _tmp11_;
+ gint64 _tmp12_ = 0LL;
+ gint64 _tmp13_;
+ _tmp11_ = info;
+ _tmp12_ = g_file_info_get_size (_tmp11_);
+ _tmp13_ = size;
+ _tmp8_ = _tmp12_ != _tmp13_;
+ }
+ _tmp14_ = _tmp8_;
+ if (_tmp14_) {
+ GeeQueue* _tmp15_;
+ GFile* _tmp16_;
+ _tmp15_ = self->priv->files;
+ _tmp16_ = file;
+ gee_queue_offer (_tmp15_, _tmp16_);
+ result = TRUE;
+ return result;
+ }
+ } else {
+ GeeQueue* _tmp17_;
+ GFile* _tmp18_;
+ _tmp17_ = self->priv->files;
+ _tmp18_ = file;
+ gee_queue_offer (_tmp17_, _tmp18_);
+ result = TRUE;
+ return result;
+ }
+ }
+ goto __finally52;
+ __catch52_g_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp19_ = NULL;
+ GError* _tmp20_;
+ const gchar* _tmp21_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp19_ = _ ("Failed to query database: %s");
+ _tmp20_ = _error_;
+ _tmp21_ = _tmp20_->message;
+ g_warning (_tmp19_, _tmp21_);
+ _g_error_free0 (_error_);
+ }
+ __finally52:
+ if (_inner_error_ != 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 FALSE;
+ }
+ result = FALSE;
+ return result;
+}
+
+
+static gchar string_get (const gchar* self, glong index) {
+ gchar result = '\0';
+ glong _tmp0_;
+ gchar _tmp1_;
+ g_return_val_if_fail (self != NULL, '\0');
+ _tmp0_ = index;
+ _tmp1_ = ((gchar*) self)[_tmp0_];
+ result = _tmp1_;
+ return result;
+}
+
+
+static gboolean rygel_media_export_harvesting_task_process_file (RygelMediaExportHarvestingTask* self, GFile* file, GFileInfo* info, RygelMediaContainer* parent) {
+ gboolean result = FALSE;
+ GFileInfo* _tmp0_;
+ const gchar* _tmp1_ = NULL;
+ gchar _tmp2_ = '\0';
+ GFileInfo* _tmp3_;
+ GFileType _tmp4_ = 0;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (parent != NULL, FALSE);
+ _tmp0_ = info;
+ _tmp1_ = g_file_info_get_name (_tmp0_);
+ _tmp2_ = string_get (_tmp1_, (glong) 0);
+ if (_tmp2_ == '.') {
+ result = FALSE;
+ return result;
+ }
+ _tmp3_ = info;
+ _tmp4_ = g_file_info_get_file_type (_tmp3_);
+ if (_tmp4_ == G_FILE_TYPE_DIRECTORY) {
+ RygelMediaExportRecursiveFileMonitor* _tmp5_;
+ GFile* _tmp6_;
+ GFile* _tmp7_;
+ RygelMediaContainer* _tmp8_;
+ RygelMediaExportDummyContainer* _tmp9_;
+ RygelMediaExportDummyContainer* container;
+ GQueue* _tmp10_;
+ RygelMediaExportDummyContainer* _tmp11_;
+ RygelMediaContainer* _tmp12_;
+ _tmp5_ = self->priv->monitor;
+ _tmp6_ = file;
+ rygel_media_export_recursive_file_monitor_add (_tmp5_, _tmp6_, NULL, NULL);
+ _tmp7_ = file;
+ _tmp8_ = parent;
+ _tmp9_ = rygel_media_export_dummy_container_new (_tmp7_, _tmp8_);
+ container = _tmp9_;
+ _tmp10_ = self->priv->containers;
+ _tmp11_ = container;
+ _tmp12_ = _g_object_ref0 ((RygelMediaContainer*) _tmp11_);
+ g_queue_push_tail (_tmp10_, _tmp12_);
+ {
+ RygelMediaExportMediaCache* _tmp13_;
+ RygelMediaExportDummyContainer* _tmp14_;
+ _tmp13_ = self->priv->cache;
+ _tmp14_ = container;
+ rygel_media_export_media_cache_save_container (_tmp13_, (RygelMediaContainer*) _tmp14_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch53_g_error;
+ }
+ }
+ goto __finally53;
+ __catch53_g_error:
+ {
+ GError* err = NULL;
+ const gchar* _tmp15_ = NULL;
+ GError* _tmp16_;
+ const gchar* _tmp17_;
+ err = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp15_ = _ ("Failed to update database: %s");
+ _tmp16_ = err;
+ _tmp17_ = _tmp16_->message;
+ g_warning (_tmp15_, _tmp17_);
+ result = FALSE;
+ _g_error_free0 (err);
+ _g_object_unref0 (container);
+ return result;
+ }
+ __finally53:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (container);
+ 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 FALSE;
+ }
+ result = TRUE;
+ _g_object_unref0 (container);
+ return result;
+ } else {
+ gboolean _tmp18_ = FALSE;
+ gboolean _tmp19_ = FALSE;
+ gboolean _tmp20_ = FALSE;
+ GFileInfo* _tmp21_;
+ const gchar* _tmp22_ = NULL;
+ gboolean _tmp23_ = FALSE;
+ gboolean _tmp27_;
+ gboolean _tmp31_;
+ gboolean _tmp34_;
+ _tmp21_ = info;
+ _tmp22_ = g_file_info_get_content_type (_tmp21_);
+ _tmp23_ = g_str_has_prefix (_tmp22_, "image/");
+ if (_tmp23_) {
+ _tmp20_ = TRUE;
+ } else {
+ GFileInfo* _tmp24_;
+ const gchar* _tmp25_ = NULL;
+ gboolean _tmp26_ = FALSE;
+ _tmp24_ = info;
+ _tmp25_ = g_file_info_get_content_type (_tmp24_);
+ _tmp26_ = g_str_has_prefix (_tmp25_, "video/");
+ _tmp20_ = _tmp26_;
+ }
+ _tmp27_ = _tmp20_;
+ if (_tmp27_) {
+ _tmp19_ = TRUE;
+ } else {
+ GFileInfo* _tmp28_;
+ const gchar* _tmp29_ = NULL;
+ gboolean _tmp30_ = FALSE;
+ _tmp28_ = info;
+ _tmp29_ = g_file_info_get_content_type (_tmp28_);
+ _tmp30_ = g_str_has_prefix (_tmp29_, "audio/");
+ _tmp19_ = _tmp30_;
+ }
+ _tmp31_ = _tmp19_;
+ if (_tmp31_) {
+ _tmp18_ = TRUE;
+ } else {
+ GFileInfo* _tmp32_;
+ const gchar* _tmp33_ = NULL;
+ _tmp32_ = info;
+ _tmp33_ = g_file_info_get_content_type (_tmp32_);
+ _tmp18_ = g_strcmp0 (_tmp33_, "application/ogg") == 0;
+ }
+ _tmp34_ = _tmp18_;
+ if (_tmp34_) {
+ GFile* _tmp35_;
+ GFileInfo* _tmp36_;
+ gboolean _tmp37_ = FALSE;
+ _tmp35_ = file;
+ _tmp36_ = info;
+ _tmp37_ = rygel_media_export_harvesting_task_push_if_changed_or_unknown (self, _tmp35_, _tmp36_);
+ result = _tmp37_;
+ return result;
+ }
+ result = FALSE;
+ return result;
+ }
+}
+
+
+static gboolean rygel_media_export_harvesting_task_process_children (RygelMediaExportHarvestingTask* self, GList* list) {
+ gboolean result = FALSE;
+ gboolean _tmp0_ = FALSE;
+ GList* _tmp1_;
+ gboolean _tmp5_;
+ GQueue* _tmp6_;
+ gconstpointer _tmp7_ = NULL;
+ RygelMediaExportDummyContainer* _tmp8_;
+ RygelMediaExportDummyContainer* container;
+ GList* _tmp9_;
+ g_return_val_if_fail (self != NULL, FALSE);
+ _tmp1_ = list;
+ if (_tmp1_ == NULL) {
+ _tmp0_ = TRUE;
+ } else {
+ GCancellable* _tmp2_;
+ GCancellable* _tmp3_;
+ gboolean _tmp4_ = FALSE;
+ _tmp2_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) self);
+ _tmp3_ = _tmp2_;
+ _tmp4_ = g_cancellable_is_cancelled (_tmp3_);
+ _tmp0_ = _tmp4_;
+ }
+ _tmp5_ = _tmp0_;
+ if (_tmp5_) {
+ result = FALSE;
+ return result;
+ }
+ _tmp6_ = self->priv->containers;
+ _tmp7_ = g_queue_peek_head (_tmp6_);
+ _tmp8_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE ((RygelMediaContainer*) _tmp7_, RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER) ? ((RygelMediaExportDummyContainer*) ((RygelMediaContainer*) _tmp7_)) : NULL);
+ container = _tmp8_;
+ _tmp9_ = list;
+ {
+ GList* info_collection = NULL;
+ GList* info_it = NULL;
+ info_collection = _tmp9_;
+ for (info_it = info_collection; info_it != NULL; info_it = info_it->next) {
+ GFileInfo* _tmp10_;
+ GFileInfo* info = NULL;
+ _tmp10_ = _g_object_ref0 ((GFileInfo*) info_it->data);
+ info = _tmp10_;
+ {
+ RygelMediaExportDummyContainer* _tmp11_;
+ GFile* _tmp12_;
+ GFileInfo* _tmp13_;
+ const gchar* _tmp14_ = NULL;
+ GFile* _tmp15_ = NULL;
+ GFile* file;
+ RygelMediaExportDummyContainer* _tmp16_;
+ GFile* _tmp17_;
+ GFile* _tmp18_;
+ GFileInfo* _tmp19_;
+ RygelMediaExportDummyContainer* _tmp20_;
+ _tmp11_ = container;
+ _tmp12_ = _tmp11_->file;
+ _tmp13_ = info;
+ _tmp14_ = g_file_info_get_name (_tmp13_);
+ _tmp15_ = g_file_get_child (_tmp12_, _tmp14_);
+ file = _tmp15_;
+ _tmp16_ = container;
+ _tmp17_ = file;
+ rygel_media_export_dummy_container_seen (_tmp16_, _tmp17_);
+ _tmp18_ = file;
+ _tmp19_ = info;
+ _tmp20_ = container;
+ rygel_media_export_harvesting_task_process_file (self, _tmp18_, _tmp19_, (RygelMediaContainer*) _tmp20_);
+ _g_object_unref0 (file);
+ _g_object_unref0 (info);
+ }
+ }
+ }
+ result = TRUE;
+ _g_object_unref0 (container);
+ return result;
+}
+
+
+static void rygel_media_export_harvesting_task_enumerate_directory_data_free (gpointer _data) {
+ RygelMediaExportHarvestingTaskEnumerateDirectoryData* _data_;
+ _data_ = _data;
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportHarvestingTaskEnumerateDirectoryData, _data_);
+}
+
+
+static void rygel_media_export_harvesting_task_enumerate_directory (RygelMediaExportHarvestingTask* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportHarvestingTaskEnumerateDirectoryData* _data_;
+ RygelMediaExportHarvestingTask* _tmp0_;
+ _data_ = g_slice_new0 (RygelMediaExportHarvestingTaskEnumerateDirectoryData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_harvesting_task_enumerate_directory);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_harvesting_task_enumerate_directory_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ rygel_media_export_harvesting_task_enumerate_directory_co (_data_);
+}
+
+
+static void rygel_media_export_harvesting_task_enumerate_directory_finish (RygelMediaExportHarvestingTask* self, GAsyncResult* _res_) {
+ RygelMediaExportHarvestingTaskEnumerateDirectoryData* _data_;
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static void rygel_media_export_harvesting_task_enumerate_directory_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ RygelMediaExportHarvestingTaskEnumerateDirectoryData* _data_;
+ _data_ = _user_data_;
+ _data_->_source_object_ = source_object;
+ _data_->_res_ = _res_;
+ rygel_media_export_harvesting_task_enumerate_directory_co (_data_);
+}
+
+
+static void _g_list_free__g_object_unref0_ (GList* self) {
+ g_list_foreach (self, (GFunc) _g_object_unref0_, NULL);
+ g_list_free (self);
+}
+
+
+static gboolean rygel_media_export_harvesting_task_enumerate_directory_co (RygelMediaExportHarvestingTaskEnumerateDirectoryData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ case 1:
+ goto _state_1;
+ case 2:
+ goto _state_2;
+ case 3:
+ goto _state_3;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = _data_->self->priv->containers;
+ _data_->_tmp1_ = NULL;
+ _data_->_tmp1_ = g_queue_peek_head (_data_->_tmp0_);
+ _data_->_tmp2_ = (G_TYPE_CHECK_INSTANCE_TYPE ((RygelMediaContainer*) _data_->_tmp1_, RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER) ? ((RygelMediaExportDummyContainer*) ((RygelMediaContainer*) _data_->_tmp1_)) : NULL)->file;
+ _data_->_tmp3_ = _g_object_ref0 (_data_->_tmp2_);
+ _data_->directory = _data_->_tmp3_;
+ {
+ _data_->_tmp4_ = _data_->directory;
+ _data_->_tmp5_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) _data_->self);
+ _data_->_tmp6_ = _data_->_tmp5_;
+ _data_->_state_ = 1;
+ g_file_enumerate_children_async (_data_->_tmp4_, RYGEL_MEDIA_EXPORT_HARVESTING_TASK_HARVESTER_ATTRIBUTES, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, _data_->_tmp6_, rygel_media_export_harvesting_task_enumerate_directory_ready, _data_);
+ return FALSE;
+ _state_1:
+ _data_->_tmp7_ = NULL;
+ _data_->_tmp7_ = g_file_enumerate_children_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error_);
+ _data_->enumerator = _data_->_tmp7_;
+ if (_data_->_inner_error_ != NULL) {
+ goto __catch54_g_error;
+ }
+ _data_->list = NULL;
+ {
+ _data_->_tmp8_ = TRUE;
+ while (TRUE) {
+ _data_->_tmp9_ = _data_->_tmp8_;
+ if (!_data_->_tmp9_) {
+ _data_->_tmp10_ = _data_->list;
+ _data_->_tmp11_ = FALSE;
+ _data_->_tmp11_ = rygel_media_export_harvesting_task_process_children (_data_->self, _data_->_tmp10_);
+ if (!_data_->_tmp11_) {
+ break;
+ }
+ }
+ _data_->_tmp8_ = FALSE;
+ _data_->_tmp12_ = _data_->enumerator;
+ _data_->_tmp13_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) _data_->self);
+ _data_->_tmp14_ = _data_->_tmp13_;
+ _data_->_state_ = 2;
+ g_file_enumerator_next_files_async (_data_->_tmp12_, RYGEL_MEDIA_EXPORT_HARVESTING_TASK_BATCH_SIZE, G_PRIORITY_DEFAULT, _data_->_tmp14_, rygel_media_export_harvesting_task_enumerate_directory_ready, _data_);
+ return FALSE;
+ _state_2:
+ _data_->_tmp15_ = NULL;
+ _data_->_tmp15_ = g_file_enumerator_next_files_finish (_data_->_tmp12_, _data_->_res_, &_data_->_inner_error_);
+ _data_->_tmp16_ = _data_->_tmp15_;
+ if (_data_->_inner_error_ != NULL) {
+ __g_list_free__g_object_unref0_0 (_data_->list);
+ _g_object_unref0 (_data_->enumerator);
+ goto __catch54_g_error;
+ }
+ __g_list_free__g_object_unref0_0 (_data_->list);
+ _data_->list = _data_->_tmp16_;
+ }
+ }
+ _data_->_tmp17_ = _data_->enumerator;
+ _data_->_tmp18_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) _data_->self);
+ _data_->_tmp19_ = _data_->_tmp18_;
+ _data_->_state_ = 3;
+ g_file_enumerator_close_async (_data_->_tmp17_, G_PRIORITY_DEFAULT, _data_->_tmp19_, rygel_media_export_harvesting_task_enumerate_directory_ready, _data_);
+ return FALSE;
+ _state_3:
+ g_file_enumerator_close_finish (_data_->_tmp17_, _data_->_res_, &_data_->_inner_error_);
+ if (_data_->_inner_error_ != NULL) {
+ __g_list_free__g_object_unref0_0 (_data_->list);
+ _g_object_unref0 (_data_->enumerator);
+ goto __catch54_g_error;
+ }
+ __g_list_free__g_object_unref0_0 (_data_->list);
+ _g_object_unref0 (_data_->enumerator);
+ }
+ goto __finally54;
+ __catch54_g_error:
+ {
+ _data_->err = _data_->_inner_error_;
+ _data_->_inner_error_ = NULL;
+ _data_->_tmp20_ = NULL;
+ _data_->_tmp20_ = _ ("failed to enumerate folder: %s");
+ _data_->_tmp21_ = _data_->err;
+ _data_->_tmp22_ = _data_->_tmp21_->message;
+ g_warning (_data_->_tmp20_, _data_->_tmp22_);
+ _g_error_free0 (_data_->err);
+ }
+ __finally54:
+ if (_data_->_inner_error_ != NULL) {
+ _g_object_unref0 (_data_->directory);
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
+ g_clear_error (&_data_->_inner_error_);
+ return FALSE;
+ }
+ rygel_media_export_harvesting_task_cleanup_database (_data_->self);
+ rygel_media_export_harvesting_task_do_update (_data_->self);
+ _g_object_unref0 (_data_->directory);
+ 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_harvesting_task_cleanup_database (RygelMediaExportHarvestingTask* self) {
+ GQueue* _tmp0_;
+ gconstpointer _tmp1_ = NULL;
+ RygelMediaExportDummyContainer* _tmp2_;
+ RygelMediaExportDummyContainer* container;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = self->priv->containers;
+ _tmp1_ = g_queue_peek_head (_tmp0_);
+ _tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE ((RygelMediaContainer*) _tmp1_, RYGEL_MEDIA_EXPORT_TYPE_DUMMY_CONTAINER) ? ((RygelMediaExportDummyContainer*) ((RygelMediaContainer*) _tmp1_)) : NULL);
+ container = _tmp2_;
+ {
+ {
+ RygelMediaExportDummyContainer* _tmp3_;
+ GeeList* _tmp4_;
+ GeeList* _tmp5_;
+ GeeList* _child_list;
+ GeeList* _tmp6_;
+ gint _tmp7_;
+ gint _tmp8_;
+ gint _child_size;
+ gint _child_index;
+ _tmp3_ = container;
+ _tmp4_ = _tmp3_->children;
+ _tmp5_ = _g_object_ref0 (_tmp4_);
+ _child_list = _tmp5_;
+ _tmp6_ = _child_list;
+ _tmp7_ = gee_collection_get_size ((GeeCollection*) _tmp6_);
+ _tmp8_ = _tmp7_;
+ _child_size = _tmp8_;
+ _child_index = -1;
+ while (TRUE) {
+ gint _tmp9_;
+ gint _tmp10_;
+ gint _tmp11_;
+ GeeList* _tmp12_;
+ gint _tmp13_;
+ gpointer _tmp14_ = NULL;
+ gchar* child;
+ RygelMediaExportMediaCache* _tmp15_;
+ const gchar* _tmp16_;
+ _tmp9_ = _child_index;
+ _child_index = _tmp9_ + 1;
+ _tmp10_ = _child_index;
+ _tmp11_ = _child_size;
+ if (!(_tmp10_ < _tmp11_)) {
+ break;
+ }
+ _tmp12_ = _child_list;
+ _tmp13_ = _child_index;
+ _tmp14_ = gee_list_get (_tmp12_, _tmp13_);
+ child = (gchar*) _tmp14_;
+ _tmp15_ = self->priv->cache;
+ _tmp16_ = child;
+ rygel_media_export_media_cache_remove_by_id (_tmp15_, _tmp16_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_free0 (child);
+ _g_object_unref0 (_child_list);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch55_rygel_media_export_database_error;
+ }
+ _g_free0 (child);
+ _g_object_unref0 (_child_list);
+ _g_object_unref0 (container);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _g_free0 (child);
+ }
+ _g_object_unref0 (_child_list);
+ }
+ }
+ goto __finally55;
+ __catch55_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp17_ = NULL;
+ RygelMediaExportDummyContainer* _tmp18_;
+ const gchar* _tmp19_;
+ const gchar* _tmp20_;
+ GError* _tmp21_;
+ const gchar* _tmp22_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp17_ = _ ("Failed to get children of container %s: %s");
+ _tmp18_ = container;
+ _tmp19_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp18_);
+ _tmp20_ = _tmp19_;
+ _tmp21_ = _error_;
+ _tmp22_ = _tmp21_->message;
+ g_warning (_tmp17_, _tmp20_, _tmp22_);
+ _g_error_free0 (_error_);
+ }
+ __finally55:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (container);
+ 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;
+ }
+ _g_object_unref0 (container);
+}
+
+
+static gboolean rygel_media_export_harvesting_task_on_idle (RygelMediaExportHarvestingTask* self) {
+ gboolean result = FALSE;
+ GCancellable* _tmp0_;
+ GCancellable* _tmp1_;
+ gboolean _tmp2_ = FALSE;
+ GeeQueue* _tmp3_;
+ gint _tmp4_;
+ gint _tmp5_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, FALSE);
+ _tmp0_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) self);
+ _tmp1_ = _tmp0_;
+ _tmp2_ = g_cancellable_is_cancelled (_tmp1_);
+ if (_tmp2_) {
+ g_signal_emit_by_name ((RygelStateMachine*) self, "completed");
+ result = FALSE;
+ return result;
+ }
+ _tmp3_ = self->priv->files;
+ _tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
+ _tmp5_ = _tmp4_;
+ if (_tmp5_ > 0) {
+ GeeQueue* _tmp6_;
+ gpointer _tmp7_ = NULL;
+ GFile* _tmp8_;
+ gchar* _tmp9_ = NULL;
+ gchar* _tmp10_;
+ RygelMediaExportMetadataExtractor* _tmp11_;
+ GeeQueue* _tmp12_;
+ gpointer _tmp13_ = NULL;
+ GFile* _tmp14_;
+ _tmp6_ = self->priv->files;
+ _tmp7_ = gee_queue_peek (_tmp6_);
+ _tmp8_ = (GFile*) _tmp7_;
+ _tmp9_ = g_file_get_uri (_tmp8_);
+ _tmp10_ = _tmp9_;
+ g_debug ("rygel-media-export-harvesting-task.vala:263: Scheduling file %s for me" \
+"ta-data extractionâ", _tmp10_);
+ _g_free0 (_tmp10_);
+ _g_object_unref0 (_tmp8_);
+ _tmp11_ = self->priv->extractor;
+ _tmp12_ = self->priv->files;
+ _tmp13_ = gee_queue_peek (_tmp12_);
+ _tmp14_ = (GFile*) _tmp13_;
+ rygel_media_export_metadata_extractor_extract (_tmp11_, _tmp14_);
+ _g_object_unref0 (_tmp14_);
+ } else {
+ GQueue* _tmp15_;
+ guint _tmp16_ = 0U;
+ _tmp15_ = self->priv->containers;
+ _tmp16_ = g_queue_get_length (_tmp15_);
+ if (_tmp16_ > ((guint) 0)) {
+ rygel_media_export_harvesting_task_enumerate_directory (self, NULL, NULL);
+ } else {
+ const gchar* _tmp17_;
+ RygelMediaContainer* _tmp21_;
+ RygelMediaContainer* _tmp22_;
+ _tmp17_ = self->priv->flag;
+ if (_tmp17_ != NULL) {
+ {
+ RygelMediaExportMediaCache* _tmp18_;
+ GFile* _tmp19_;
+ const gchar* _tmp20_;
+ _tmp18_ = self->priv->cache;
+ _tmp19_ = self->origin;
+ _tmp20_ = self->priv->flag;
+ rygel_media_export_media_cache_flag_object (_tmp18_, _tmp19_, _tmp20_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch56_g_error;
+ }
+ }
+ goto __finally56;
+ __catch56_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally56:
+ if (_inner_error_ != 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 FALSE;
+ }
+ }
+ _tmp21_ = self->priv->parent;
+ _tmp22_ = self->priv->parent;
+ rygel_media_container_updated (_tmp21_, (RygelMediaObject*) _tmp22_, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
+ g_signal_emit_by_name ((RygelStateMachine*) self, "completed");
+ }
+ }
+ result = FALSE;
+ return result;
+}
+
+
+static void rygel_media_export_harvesting_task_on_extracted_cb (RygelMediaExportHarvestingTask* self, GFile* file, GUPnPDLNAInformation* dlna, GFileInfo* file_info) {
+ GCancellable* _tmp0_;
+ GCancellable* _tmp1_;
+ gboolean _tmp2_ = FALSE;
+ GeeQueue* _tmp3_;
+ gpointer _tmp4_ = NULL;
+ GFile* entry;
+ gboolean _tmp5_ = FALSE;
+ GFile* _tmp6_;
+ gboolean _tmp9_;
+ RygelMediaItem* item = NULL;
+ GUPnPDLNAInformation* _tmp10_;
+ RygelMediaItem* _tmp22_;
+ GeeQueue* _tmp28_;
+ gpointer _tmp29_ = NULL;
+ GFile* _tmp30_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ g_return_if_fail (file_info != NULL);
+ _tmp0_ = rygel_state_machine_get_cancellable ((RygelStateMachine*) self);
+ _tmp1_ = _tmp0_;
+ _tmp2_ = g_cancellable_is_cancelled (_tmp1_);
+ if (_tmp2_) {
+ g_signal_emit_by_name ((RygelStateMachine*) self, "completed");
+ }
+ _tmp3_ = self->priv->files;
+ _tmp4_ = gee_queue_peek (_tmp3_);
+ entry = (GFile*) _tmp4_;
+ _tmp6_ = entry;
+ if (_tmp6_ == NULL) {
+ _tmp5_ = TRUE;
+ } else {
+ GFile* _tmp7_;
+ GFile* _tmp8_;
+ _tmp7_ = file;
+ _tmp8_ = entry;
+ _tmp5_ = _tmp7_ != _tmp8_;
+ }
+ _tmp9_ = _tmp5_;
+ if (_tmp9_) {
+ _g_object_unref0 (entry);
+ return;
+ }
+ _tmp10_ = dlna;
+ if (_tmp10_ == NULL) {
+ GQueue* _tmp11_;
+ gconstpointer _tmp12_ = NULL;
+ GFile* _tmp13_;
+ GFileInfo* _tmp14_;
+ RygelMediaItem* _tmp15_ = NULL;
+ _tmp11_ = self->priv->containers;
+ _tmp12_ = g_queue_peek_head (_tmp11_);
+ _tmp13_ = file;
+ _tmp14_ = file_info;
+ _tmp15_ = rygel_media_export_item_factory_create_simple ((RygelMediaContainer*) _tmp12_, _tmp13_, _tmp14_);
+ _g_object_unref0 (item);
+ item = _tmp15_;
+ } else {
+ GQueue* _tmp16_;
+ gconstpointer _tmp17_ = NULL;
+ GFile* _tmp18_;
+ GUPnPDLNAInformation* _tmp19_;
+ GFileInfo* _tmp20_;
+ RygelMediaItem* _tmp21_ = NULL;
+ _tmp16_ = self->priv->containers;
+ _tmp17_ = g_queue_peek_head (_tmp16_);
+ _tmp18_ = file;
+ _tmp19_ = dlna;
+ _tmp20_ = file_info;
+ _tmp21_ = rygel_media_export_item_factory_create_from_info ((RygelMediaContainer*) _tmp17_, _tmp18_, _tmp19_, _tmp20_);
+ _g_object_unref0 (item);
+ item = _tmp21_;
+ }
+ _tmp22_ = item;
+ if (_tmp22_ != NULL) {
+ RygelMediaItem* _tmp23_;
+ GQueue* _tmp24_;
+ gconstpointer _tmp25_ = NULL;
+ _tmp23_ = item;
+ _tmp24_ = self->priv->containers;
+ _tmp25_ = g_queue_peek_head (_tmp24_);
+ rygel_media_object_set_parent_ref ((RygelMediaObject*) _tmp23_, (RygelMediaContainer*) _tmp25_);
+ {
+ RygelMediaExportMediaCache* _tmp26_;
+ RygelMediaItem* _tmp27_;
+ _tmp26_ = self->priv->cache;
+ _tmp27_ = item;
+ rygel_media_export_media_cache_save_item (_tmp26_, _tmp27_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch57_g_error;
+ }
+ }
+ goto __finally57;
+ __catch57_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally57:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (item);
+ _g_object_unref0 (entry);
+ 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;
+ }
+ }
+ _tmp28_ = self->priv->files;
+ _tmp29_ = gee_queue_poll (_tmp28_);
+ _tmp30_ = (GFile*) _tmp29_;
+ _g_object_unref0 (_tmp30_);
+ rygel_media_export_harvesting_task_do_update (self);
+ _g_object_unref0 (item);
+ _g_object_unref0 (entry);
+}
+
+
+static void rygel_media_export_harvesting_task_on_extractor_error_cb (RygelMediaExportHarvestingTask* self, GFile* file, GError* _error_) {
+ GeeQueue* _tmp0_;
+ gpointer _tmp1_ = NULL;
+ GFile* entry;
+ gboolean _tmp2_ = FALSE;
+ GFile* _tmp3_;
+ gboolean _tmp6_;
+ GFile* _tmp7_;
+ gchar* _tmp8_ = NULL;
+ gchar* _tmp9_;
+ GError* _tmp10_;
+ const gchar* _tmp11_;
+ GeeQueue* _tmp12_;
+ gpointer _tmp13_ = NULL;
+ GFile* _tmp14_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ _tmp0_ = self->priv->files;
+ _tmp1_ = gee_queue_peek (_tmp0_);
+ entry = (GFile*) _tmp1_;
+ _tmp3_ = entry;
+ if (_tmp3_ == NULL) {
+ _tmp2_ = TRUE;
+ } else {
+ GFile* _tmp4_;
+ GFile* _tmp5_;
+ _tmp4_ = file;
+ _tmp5_ = entry;
+ _tmp2_ = _tmp4_ != _tmp5_;
+ }
+ _tmp6_ = _tmp2_;
+ if (_tmp6_) {
+ _g_object_unref0 (entry);
+ return;
+ }
+ _tmp7_ = file;
+ _tmp8_ = g_file_get_uri (_tmp7_);
+ _tmp9_ = _tmp8_;
+ _tmp10_ = _error_;
+ _tmp11_ = _tmp10_->message;
+ g_debug ("rygel-media-export-harvesting-task.vala:335: Skipping %s; extraction c" \
+"ompletely failed: %s", _tmp9_, _tmp11_);
+ _g_free0 (_tmp9_);
+ _tmp12_ = self->priv->files;
+ _tmp13_ = gee_queue_poll (_tmp12_);
+ _tmp14_ = (GFile*) _tmp13_;
+ _g_object_unref0 (_tmp14_);
+ rygel_media_export_harvesting_task_do_update (self);
+ _g_object_unref0 (entry);
+}
+
+
+/**
+ * If all files of a container were processed, notify the container
+ * about this and set the updating signal.
+ * Reschedule the iteration and extraction
+ */
+static void rygel_media_export_harvesting_task_do_update (RygelMediaExportHarvestingTask* self) {
+ gboolean _tmp0_ = FALSE;
+ GeeQueue* _tmp1_;
+ gint _tmp2_;
+ gint _tmp3_;
+ gboolean _tmp6_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ _tmp1_ = self->priv->files;
+ _tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
+ _tmp3_ = _tmp2_;
+ if (_tmp3_ == 0) {
+ GQueue* _tmp4_;
+ guint _tmp5_ = 0U;
+ _tmp4_ = self->priv->containers;
+ _tmp5_ = g_queue_get_length (_tmp4_);
+ _tmp0_ = _tmp5_ != ((guint) 0);
+ } else {
+ _tmp0_ = FALSE;
+ }
+ _tmp6_ = _tmp0_;
+ if (_tmp6_) {
+ GQueue* _tmp7_;
+ gconstpointer _tmp8_ = NULL;
+ RygelMediaContainer* _tmp9_;
+ RygelMediaContainer* container;
+ GQueue* _tmp26_;
+ gpointer _tmp27_ = NULL;
+ RygelMediaContainer* _tmp28_;
+ _tmp7_ = self->priv->containers;
+ _tmp8_ = g_queue_peek_head (_tmp7_);
+ _tmp9_ = _g_object_ref0 ((RygelMediaContainer*) _tmp8_);
+ container = _tmp9_;
+ {
+ RygelMediaExportMediaCache* _tmp10_ = NULL;
+ RygelMediaExportMediaCache* cache;
+ RygelMediaExportMediaCache* _tmp11_;
+ RygelMediaContainer* _tmp12_;
+ const gchar* _tmp13_;
+ const gchar* _tmp14_;
+ gint _tmp15_ = 0;
+ gint _tmp16_;
+ _tmp10_ = rygel_media_export_media_cache_get_default (&_inner_error_);
+ cache = _tmp10_;
+ if (_inner_error_ != NULL) {
+ goto __catch58_g_error;
+ }
+ _tmp11_ = cache;
+ _tmp12_ = container;
+ _tmp13_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp12_);
+ _tmp14_ = _tmp13_;
+ _tmp15_ = rygel_media_export_media_cache_get_child_count (_tmp11_, _tmp14_, &_inner_error_);
+ _tmp16_ = _tmp15_;
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (cache);
+ goto __catch58_g_error;
+ }
+ if (_tmp16_ > 0) {
+ GQueue* _tmp17_;
+ gconstpointer _tmp18_ = NULL;
+ RygelMediaContainer* _tmp19_;
+ RygelMediaContainer* head;
+ RygelMediaContainer* _tmp20_;
+ RygelMediaContainer* _tmp21_;
+ _tmp17_ = self->priv->containers;
+ _tmp18_ = g_queue_peek_head (_tmp17_);
+ _tmp19_ = _g_object_ref0 ((RygelMediaContainer*) _tmp18_);
+ head = _tmp19_;
+ _tmp20_ = head;
+ _tmp21_ = head;
+ rygel_media_container_updated (_tmp20_, (RygelMediaObject*) _tmp21_, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
+ _g_object_unref0 (head);
+ } else {
+ RygelMediaExportMediaCache* _tmp22_;
+ RygelMediaContainer* _tmp23_;
+ const gchar* _tmp24_;
+ const gchar* _tmp25_;
+ _tmp22_ = cache;
+ _tmp23_ = container;
+ _tmp24_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp23_);
+ _tmp25_ = _tmp24_;
+ rygel_media_export_media_cache_remove_by_id (_tmp22_, _tmp25_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (cache);
+ goto __catch58_g_error;
+ }
+ }
+ _g_object_unref0 (cache);
+ }
+ goto __finally58;
+ __catch58_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally58:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (container);
+ 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;
+ }
+ _tmp26_ = self->priv->containers;
+ _tmp27_ = g_queue_pop_head (_tmp26_);
+ _tmp28_ = (RygelMediaContainer*) _tmp27_;
+ _g_object_unref0 (_tmp28_);
+ _g_object_unref0 (container);
+ }
+ rygel_media_export_harvesting_task_on_idle (self);
+}
+
+
+static GCancellable* rygel_media_export_harvesting_task_real_get_cancellable (RygelStateMachine* base) {
+ GCancellable* result;
+ RygelMediaExportHarvestingTask* self;
+ GCancellable* _tmp0_;
+ self = (RygelMediaExportHarvestingTask*) base;
+ _tmp0_ = self->priv->_cancellable;
+ result = _tmp0_;
+ return result;
+}
+
+
+static void rygel_media_export_harvesting_task_real_set_cancellable (RygelStateMachine* base, GCancellable* value) {
+ RygelMediaExportHarvestingTask* self;
+ GCancellable* _tmp0_;
+ GCancellable* _tmp1_;
+ self = (RygelMediaExportHarvestingTask*) base;
+ _tmp0_ = value;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (self->priv->_cancellable);
+ self->priv->_cancellable = _tmp1_;
+ g_object_notify ((GObject *) self, "cancellable");
+}
+
+
+static void rygel_media_export_harvesting_task_class_init (RygelMediaExportHarvestingTaskClass * klass) {
+ rygel_media_export_harvesting_task_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportHarvestingTaskPrivate));
+ G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_harvesting_task_get_property;
+ G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_harvesting_task_set_property;
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_harvesting_task_finalize;
+ g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_HARVESTING_TASK_CANCELLABLE, g_param_spec_object ("cancellable", "cancellable", "cancellable", g_cancellable_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+}
+
+
+static void rygel_media_export_harvesting_task_rygel_state_machine_interface_init (RygelStateMachineIface * iface) {
+ rygel_media_export_harvesting_task_rygel_state_machine_parent_iface = g_type_interface_peek_parent (iface);
+ iface->run = (void (*)(RygelStateMachine*)) rygel_media_export_harvesting_task_real_run;
+ iface->run_finish = rygel_media_export_harvesting_task_real_run_finish;
+ iface->get_cancellable = rygel_media_export_harvesting_task_real_get_cancellable;
+ iface->set_cancellable = rygel_media_export_harvesting_task_real_set_cancellable;
+}
+
+
+static void rygel_media_export_harvesting_task_init (RygelMediaExportHarvestingTask * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_HARVESTING_TASK_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_harvesting_task_finalize (GObject* obj) {
+ RygelMediaExportHarvestingTask * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, RygelMediaExportHarvestingTask);
+ _g_object_unref0 (self->origin);
+ _g_object_unref0 (self->priv->extractor);
+ _g_object_unref0 (self->priv->cache);
+ __g_queue_free__g_object_unref0_0 (self->priv->containers);
+ _g_object_unref0 (self->priv->files);
+ _g_object_unref0 (self->priv->monitor);
+ _g_free0 (self->priv->flag);
+ _g_object_unref0 (self->priv->parent);
+ _g_object_unref0 (self->priv->_cancellable);
+ G_OBJECT_CLASS (rygel_media_export_harvesting_task_parent_class)->finalize (obj);
+}
+
+
+static void _vala_rygel_media_export_harvesting_task_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
+ RygelMediaExportHarvestingTask * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, RygelMediaExportHarvestingTask);
+ switch (property_id) {
+ case RYGEL_MEDIA_EXPORT_HARVESTING_TASK_CANCELLABLE:
+ g_value_set_object (value, rygel_state_machine_get_cancellable ((RygelStateMachine*) self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void _vala_rygel_media_export_harvesting_task_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
+ RygelMediaExportHarvestingTask * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, RygelMediaExportHarvestingTask);
+ switch (property_id) {
+ case RYGEL_MEDIA_EXPORT_HARVESTING_TASK_CANCELLABLE:
+ rygel_state_machine_set_cancellable ((RygelStateMachine*) 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-harvesting-task.h b/src/media-export/rygel-media-export-harvesting-task.h
new file mode 100644
index 0000000..f23b455
--- /dev/null
+++ b/src/media-export/rygel-media-export-harvesting-task.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_HARVESTING_TASK_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_HARVESTING_TASK_H__
+
+#include "rygel-media-export-metadata-extractor.h"
+#include "rygel-media-export-recursive-file-monitor.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK (rygel_media_export_harvesting_task_get_type ())
+#define RYGEL_MEDIA_EXPORT_HARVESTING_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, RygelMediaExportHarvestingTask))
+#define RYGEL_MEDIA_EXPORT_HARVESTING_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, RygelMediaExportHarvestingTaskClass))
+#define RYGEL_MEDIA_EXPORT_IS_HARVESTING_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK))
+#define RYGEL_MEDIA_EXPORT_IS_HARVESTING_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK))
+#define RYGEL_MEDIA_EXPORT_HARVESTING_TASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTING_TASK, RygelMediaExportHarvestingTaskClass))
+
+typedef struct _RygelMediaExportHarvestingTask RygelMediaExportHarvestingTask;
+typedef struct _RygelMediaExportHarvestingTaskClass RygelMediaExportHarvestingTaskClass;
+typedef struct _RygelMediaExportHarvestingTaskPrivate RygelMediaExportHarvestingTaskPrivate;
+
+struct _RygelMediaExportHarvestingTask {
+ GObject parent_instance;
+ RygelMediaExportHarvestingTaskPrivate *priv;
+ GFile* origin;
+};
+
+struct _RygelMediaExportHarvestingTaskClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_harvesting_task_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportHarvestingTask* rygel_media_export_harvesting_task_new (RygelMediaExportMetadataExtractor* extractor, RygelMediaExportRecursiveFileMonitor* monitor, GFile* file, RygelMediaContainer* parent, const gchar* flag);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_HARVESTING_TASK_H__ */
diff --git a/src/media-export/rygel-media-export-item-factory.c b/src/media-export/rygel-media-export-item-factory.c
new file mode 100644
index 0000000..5a15af3
--- /dev/null
+++ b/src/media-export/rygel-media-export-item-factory.c
@@ -0,0 +1,1040 @@
+/* rygel-media-export-item.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-item.vala, do not modify */
+
+/*
+ * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
+ * Copyright (C) 2008 Nokia Corporation.
+ *
+ * Author: Zeeshan Ali <zeenix gmail com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-item-factory.h"
+#include "rygel-media-export-jpeg-writer.h"
+#include <libgupnp-dlna/gupnp-dlna-information.h>
+#include <libgupnp-av/gupnp-av.h>
+#include <libgupnp-dlna/gupnp-dlna-information.h>
+#include <gst/pbutils/codec-utils.h>
+#include <gst/pbutils/descriptions.h>
+#include <gst/pbutils/encoding-profile.h>
+#include <gst/pbutils/encoding-target.h>
+#include <gst/pbutils/gstdiscoverer.h>
+#include <gst/pbutils/gstpluginsbaseversion.h>
+#include <gst/pbutils/install-plugins.h>
+#include <gst/pbutils/missing-plugins.h>
+#include <gst/pbutils/pbutils-enumtypes.h>
+#include <gst/pbutils/pbutils.h>
+#include <gst/gst.h>
+#include <gst/tag/gsttagdemux.h>
+#include <gst/tag/gsttagmux.h>
+#include <gst/tag/tag.h>
+#include <gst/tag/xmpwriter.h>
+
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+#define _gst_structure_free0(var) ((var == NULL) ? NULL : (var = (gst_structure_free (var), NULL)))
+typedef struct _RygelMediaExportMusicItemPrivate RygelMediaExportMusicItemPrivate;
+
+RygelMediaItem* rygel_media_export_item_factory_create_simple (RygelMediaContainer* parent, GFile* file, GFileInfo* info);
+gchar* rygel_media_export_media_cache_get_id (GFile* file);
+RygelMediaExportVideoItem* rygel_media_export_video_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+RygelMediaExportVideoItem* rygel_media_export_video_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+GType rygel_media_export_video_item_get_type (void) G_GNUC_CONST;
+RygelMediaExportPhotoItem* rygel_media_export_photo_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+RygelMediaExportPhotoItem* rygel_media_export_photo_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+GType rygel_media_export_photo_item_get_type (void) G_GNUC_CONST;
+RygelMediaExportMusicItem* rygel_media_export_music_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+RygelMediaExportMusicItem* rygel_media_export_music_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+GType rygel_media_export_music_item_get_type (void) G_GNUC_CONST;
+RygelMediaItem* rygel_media_export_item_factory_create_from_info (RygelMediaContainer* parent, GFile* file, GUPnPDLNAInformation* dlna_info, GFileInfo* file_info);
+static void _gst_mini_object_unref0_ (gpointer var);
+static void _g_list_free__gst_mini_object_unref0_ (GList* self);
+RygelMediaItem* rygel_media_export_item_factory_fill_photo_item (RygelMediaExportPhotoItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererVideoInfo* video_info, GFileInfo* file_info);
+RygelMediaItem* rygel_media_export_item_factory_fill_video_item (RygelMediaExportVideoItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererVideoInfo* video_info, GstDiscovererAudioInfo* audio_info, GFileInfo* file_info);
+RygelMediaItem* rygel_media_export_item_factory_fill_music_item (RygelMediaExportMusicItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererAudioInfo* audio_info, GFileInfo* file_info);
+void rygel_media_export_item_factory_fill_audio_item (RygelAudioItem* item, GUPnPDLNAInformation* dlna_info, GstDiscovererAudioInfo* audio_info);
+void rygel_media_export_item_factory_fill_media_item (RygelMediaItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GFileInfo* file_info);
+RygelMediaExportJPEGWriter* rygel_media_export_jpeg_writer_new (GError** error);
+RygelMediaExportJPEGWriter* rygel_media_export_jpeg_writer_construct (GType object_type, GError** error);
+GType rygel_media_export_jpeg_writer_get_type (void) G_GNUC_CONST;
+void rygel_media_export_jpeg_writer_write (RygelMediaExportJPEGWriter* self, GstBuffer* buffer, GFile* file);
+
+
+RygelMediaItem* rygel_media_export_item_factory_create_simple (RygelMediaContainer* parent, GFile* file, GFileInfo* info) {
+ RygelMediaItem* result = NULL;
+ GFileInfo* _tmp0_;
+ const gchar* _tmp1_ = NULL;
+ gchar* _tmp2_;
+ gchar* title;
+ RygelMediaItem* item = NULL;
+ GFileInfo* _tmp3_;
+ const gchar* _tmp4_ = NULL;
+ gchar* _tmp5_ = NULL;
+ gchar* mime;
+ const gchar* _tmp6_;
+ gboolean _tmp7_ = FALSE;
+ RygelMediaItem* _tmp28_;
+ const gchar* _tmp29_;
+ RygelMediaItem* _tmp30_;
+ GFileInfo* _tmp31_;
+ gint64 _tmp32_ = 0LL;
+ RygelMediaItem* _tmp33_;
+ GFileInfo* _tmp34_;
+ guint64 _tmp35_ = 0ULL;
+ RygelMediaItem* _tmp36_;
+ GFile* _tmp37_;
+ gchar* _tmp38_ = NULL;
+ gchar* _tmp39_;
+ g_return_val_if_fail (parent != NULL, NULL);
+ g_return_val_if_fail (file != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
+ _tmp0_ = info;
+ _tmp1_ = g_file_info_get_display_name (_tmp0_);
+ _tmp2_ = g_strdup (_tmp1_);
+ title = _tmp2_;
+ _tmp3_ = info;
+ _tmp4_ = g_file_info_get_content_type (_tmp3_);
+ _tmp5_ = g_content_type_get_mime_type (_tmp4_);
+ mime = _tmp5_;
+ _tmp6_ = mime;
+ _tmp7_ = g_str_has_prefix (_tmp6_, "video/");
+ if (_tmp7_) {
+ GFile* _tmp8_;
+ gchar* _tmp9_ = NULL;
+ gchar* _tmp10_;
+ RygelMediaContainer* _tmp11_;
+ const gchar* _tmp12_;
+ RygelMediaExportVideoItem* _tmp13_;
+ _tmp8_ = file;
+ _tmp9_ = rygel_media_export_media_cache_get_id (_tmp8_);
+ _tmp10_ = _tmp9_;
+ _tmp11_ = parent;
+ _tmp12_ = title;
+ _tmp13_ = rygel_media_export_video_item_new (_tmp10_, _tmp11_, _tmp12_, RYGEL_VIDEO_ITEM_UPNP_CLASS);
+ _g_object_unref0 (item);
+ item = (RygelMediaItem*) _tmp13_;
+ _g_free0 (_tmp10_);
+ } else {
+ const gchar* _tmp14_;
+ gboolean _tmp15_ = FALSE;
+ _tmp14_ = mime;
+ _tmp15_ = g_str_has_prefix (_tmp14_, "image/");
+ if (_tmp15_) {
+ GFile* _tmp16_;
+ gchar* _tmp17_ = NULL;
+ gchar* _tmp18_;
+ RygelMediaContainer* _tmp19_;
+ const gchar* _tmp20_;
+ RygelMediaExportPhotoItem* _tmp21_;
+ _tmp16_ = file;
+ _tmp17_ = rygel_media_export_media_cache_get_id (_tmp16_);
+ _tmp18_ = _tmp17_;
+ _tmp19_ = parent;
+ _tmp20_ = title;
+ _tmp21_ = rygel_media_export_photo_item_new (_tmp18_, _tmp19_, _tmp20_, RYGEL_PHOTO_ITEM_UPNP_CLASS);
+ _g_object_unref0 (item);
+ item = (RygelMediaItem*) _tmp21_;
+ _g_free0 (_tmp18_);
+ } else {
+ GFile* _tmp22_;
+ gchar* _tmp23_ = NULL;
+ gchar* _tmp24_;
+ RygelMediaContainer* _tmp25_;
+ const gchar* _tmp26_;
+ RygelMediaExportMusicItem* _tmp27_;
+ _tmp22_ = file;
+ _tmp23_ = rygel_media_export_media_cache_get_id (_tmp22_);
+ _tmp24_ = _tmp23_;
+ _tmp25_ = parent;
+ _tmp26_ = title;
+ _tmp27_ = rygel_media_export_music_item_new (_tmp24_, _tmp25_, _tmp26_, RYGEL_MUSIC_ITEM_UPNP_CLASS);
+ _g_object_unref0 (item);
+ item = (RygelMediaItem*) _tmp27_;
+ _g_free0 (_tmp24_);
+ }
+ }
+ _tmp28_ = item;
+ _tmp29_ = mime;
+ rygel_media_item_set_mime_type (_tmp28_, _tmp29_);
+ _tmp30_ = item;
+ _tmp31_ = info;
+ _tmp32_ = g_file_info_get_size (_tmp31_);
+ rygel_media_item_set_size (_tmp30_, (gint64) _tmp32_);
+ _tmp33_ = item;
+ _tmp34_ = info;
+ _tmp35_ = g_file_info_get_attribute_uint64 (_tmp34_, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ rygel_media_object_set_modified ((RygelMediaObject*) _tmp33_, _tmp35_);
+ _tmp36_ = item;
+ _tmp37_ = file;
+ _tmp38_ = g_file_get_uri (_tmp37_);
+ _tmp39_ = _tmp38_;
+ rygel_media_item_add_uri (_tmp36_, _tmp39_);
+ _g_free0 (_tmp39_);
+ result = item;
+ _g_free0 (mime);
+ _g_free0 (title);
+ return result;
+}
+
+
+static void _gst_mini_object_unref0_ (gpointer var) {
+ (var == NULL) ? NULL : (var = (gst_mini_object_unref (var), NULL));
+}
+
+
+static void _g_list_free__gst_mini_object_unref0_ (GList* self) {
+ g_list_foreach (self, (GFunc) _gst_mini_object_unref0_, NULL);
+ g_list_free (self);
+}
+
+
+static gpointer _gst_mini_object_ref0 (gpointer self) {
+ return self ? gst_mini_object_ref (self) : NULL;
+}
+
+
+RygelMediaItem* rygel_media_export_item_factory_create_from_info (RygelMediaContainer* parent, GFile* file, GUPnPDLNAInformation* dlna_info, GFileInfo* file_info) {
+ RygelMediaItem* result = NULL;
+ RygelMediaItem* item = NULL;
+ GFile* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* id;
+ GList* audio_streams = NULL;
+ GList* video_streams = NULL;
+ GUPnPDLNAInformation* _tmp2_;
+ GstDiscovererInfo* _tmp3_;
+ GstDiscovererInfo* _tmp4_;
+ GList* _tmp5_ = NULL;
+ GUPnPDLNAInformation* _tmp6_;
+ GstDiscovererInfo* _tmp7_;
+ GstDiscovererInfo* _tmp8_;
+ GList* _tmp9_ = NULL;
+ gboolean _tmp10_ = FALSE;
+ GList* _tmp11_;
+ gboolean _tmp13_;
+ gboolean _tmp17_ = FALSE;
+ GList* _tmp18_;
+ gboolean _tmp22_;
+ g_return_val_if_fail (parent != NULL, NULL);
+ g_return_val_if_fail (file != NULL, NULL);
+ g_return_val_if_fail (dlna_info != NULL, NULL);
+ g_return_val_if_fail (file_info != NULL, NULL);
+ _tmp0_ = file;
+ _tmp1_ = rygel_media_export_media_cache_get_id (_tmp0_);
+ id = _tmp1_;
+ _tmp2_ = dlna_info;
+ _tmp3_ = gupnp_dlna_information_get_info (_tmp2_);
+ _tmp4_ = _tmp3_;
+ _tmp5_ = gst_discoverer_info_get_audio_streams (_tmp4_);
+ __g_list_free__gst_mini_object_unref0_0 (audio_streams);
+ audio_streams = _tmp5_;
+ _tmp6_ = dlna_info;
+ _tmp7_ = gupnp_dlna_information_get_info (_tmp6_);
+ _tmp8_ = _tmp7_;
+ _tmp9_ = gst_discoverer_info_get_video_streams (_tmp8_);
+ __g_list_free__gst_mini_object_unref0_0 (video_streams);
+ video_streams = _tmp9_;
+ _tmp11_ = audio_streams;
+ if (_tmp11_ == NULL) {
+ GList* _tmp12_;
+ _tmp12_ = video_streams;
+ _tmp10_ = _tmp12_ == NULL;
+ } else {
+ _tmp10_ = FALSE;
+ }
+ _tmp13_ = _tmp10_;
+ if (_tmp13_) {
+ GFile* _tmp14_;
+ gchar* _tmp15_ = NULL;
+ gchar* _tmp16_;
+ _tmp14_ = file;
+ _tmp15_ = g_file_get_uri (_tmp14_);
+ _tmp16_ = _tmp15_;
+ g_debug ("%s had neither audio nor video/picture " "streams. Ignoring.", _tmp16_);
+ _g_free0 (_tmp16_);
+ result = NULL;
+ __g_list_free__gst_mini_object_unref0_0 (video_streams);
+ __g_list_free__gst_mini_object_unref0_0 (audio_streams);
+ _g_free0 (id);
+ _g_object_unref0 (item);
+ return result;
+ }
+ _tmp18_ = audio_streams;
+ if (_tmp18_ == NULL) {
+ GList* _tmp19_;
+ gconstpointer _tmp20_;
+ gboolean _tmp21_ = FALSE;
+ _tmp19_ = video_streams;
+ _tmp20_ = _tmp19_->data;
+ _tmp21_ = gst_discoverer_video_info_is_image ((GstDiscovererVideoInfo*) _tmp20_);
+ _tmp17_ = _tmp21_;
+ } else {
+ _tmp17_ = FALSE;
+ }
+ _tmp22_ = _tmp17_;
+ if (_tmp22_) {
+ const gchar* _tmp23_;
+ RygelMediaContainer* _tmp24_;
+ RygelMediaExportPhotoItem* _tmp25_;
+ RygelMediaItem* _tmp26_;
+ GFile* _tmp27_;
+ GUPnPDLNAInformation* _tmp28_;
+ GList* _tmp29_;
+ gconstpointer _tmp30_;
+ GFileInfo* _tmp31_;
+ RygelMediaItem* _tmp32_ = NULL;
+ _tmp23_ = id;
+ _tmp24_ = parent;
+ _tmp25_ = rygel_media_export_photo_item_new (_tmp23_, _tmp24_, "", RYGEL_PHOTO_ITEM_UPNP_CLASS);
+ _g_object_unref0 (item);
+ item = (RygelMediaItem*) _tmp25_;
+ _tmp26_ = item;
+ _tmp27_ = file;
+ _tmp28_ = dlna_info;
+ _tmp29_ = video_streams;
+ _tmp30_ = _tmp29_->data;
+ _tmp31_ = file_info;
+ _tmp32_ = rygel_media_export_item_factory_fill_photo_item (G_TYPE_CHECK_INSTANCE_TYPE (_tmp26_, RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM) ? ((RygelMediaExportPhotoItem*) _tmp26_) : NULL, _tmp27_, _tmp28_, (GstDiscovererVideoInfo*) _tmp30_, _tmp31_);
+ result = _tmp32_;
+ __g_list_free__gst_mini_object_unref0_0 (video_streams);
+ __g_list_free__gst_mini_object_unref0_0 (audio_streams);
+ _g_free0 (id);
+ _g_object_unref0 (item);
+ return result;
+ } else {
+ GList* _tmp33_;
+ _tmp33_ = video_streams;
+ if (_tmp33_ != NULL) {
+ const gchar* _tmp34_;
+ RygelMediaContainer* _tmp35_;
+ RygelMediaExportVideoItem* _tmp36_;
+ GstDiscovererAudioInfo* _tmp37_;
+ GstDiscovererAudioInfo* audio_info;
+ GList* _tmp38_;
+ RygelMediaItem* _tmp42_;
+ GFile* _tmp43_;
+ GUPnPDLNAInformation* _tmp44_;
+ GList* _tmp45_;
+ gconstpointer _tmp46_;
+ GstDiscovererAudioInfo* _tmp47_;
+ GFileInfo* _tmp48_;
+ RygelMediaItem* _tmp49_ = NULL;
+ _tmp34_ = id;
+ _tmp35_ = parent;
+ _tmp36_ = rygel_media_export_video_item_new (_tmp34_, _tmp35_, "", RYGEL_VIDEO_ITEM_UPNP_CLASS);
+ _g_object_unref0 (item);
+ item = (RygelMediaItem*) _tmp36_;
+ _tmp37_ = _gst_mini_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (NULL, GST_TYPE_DISCOVERER_AUDIO_INFO) ? ((GstDiscovererAudioInfo*) NULL) : NULL);
+ audio_info = _tmp37_;
+ _tmp38_ = audio_streams;
+ if (_tmp38_ != NULL) {
+ GList* _tmp39_;
+ gconstpointer _tmp40_;
+ GstDiscovererAudioInfo* _tmp41_;
+ _tmp39_ = audio_streams;
+ _tmp40_ = _tmp39_->data;
+ _tmp41_ = _gst_mini_object_ref0 ((GstDiscovererAudioInfo*) _tmp40_);
+ _gst_mini_object_unref0 (audio_info);
+ audio_info = _tmp41_;
+ }
+ _tmp42_ = item;
+ _tmp43_ = file;
+ _tmp44_ = dlna_info;
+ _tmp45_ = video_streams;
+ _tmp46_ = _tmp45_->data;
+ _tmp47_ = audio_info;
+ _tmp48_ = file_info;
+ _tmp49_ = rygel_media_export_item_factory_fill_video_item (G_TYPE_CHECK_INSTANCE_TYPE (_tmp42_, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM) ? ((RygelMediaExportVideoItem*) _tmp42_) : NULL, _tmp43_, _tmp44_, (GstDiscovererVideoInfo*) _tmp46_, _tmp47_, _tmp48_);
+ result = _tmp49_;
+ _gst_mini_object_unref0 (audio_info);
+ __g_list_free__gst_mini_object_unref0_0 (video_streams);
+ __g_list_free__gst_mini_object_unref0_0 (audio_streams);
+ _g_free0 (id);
+ _g_object_unref0 (item);
+ return result;
+ } else {
+ GList* _tmp50_;
+ _tmp50_ = audio_streams;
+ if (_tmp50_ != NULL) {
+ const gchar* _tmp51_;
+ RygelMediaContainer* _tmp52_;
+ RygelMediaExportMusicItem* _tmp53_;
+ RygelMediaItem* _tmp54_;
+ GFile* _tmp55_;
+ GUPnPDLNAInformation* _tmp56_;
+ GList* _tmp57_;
+ gconstpointer _tmp58_;
+ GFileInfo* _tmp59_;
+ RygelMediaItem* _tmp60_ = NULL;
+ _tmp51_ = id;
+ _tmp52_ = parent;
+ _tmp53_ = rygel_media_export_music_item_new (_tmp51_, _tmp52_, "", RYGEL_MUSIC_ITEM_UPNP_CLASS);
+ _g_object_unref0 (item);
+ item = (RygelMediaItem*) _tmp53_;
+ _tmp54_ = item;
+ _tmp55_ = file;
+ _tmp56_ = dlna_info;
+ _tmp57_ = audio_streams;
+ _tmp58_ = _tmp57_->data;
+ _tmp59_ = file_info;
+ _tmp60_ = rygel_media_export_item_factory_fill_music_item (G_TYPE_CHECK_INSTANCE_TYPE (_tmp54_, RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM) ? ((RygelMediaExportMusicItem*) _tmp54_) : NULL, _tmp55_, _tmp56_, (GstDiscovererAudioInfo*) _tmp58_, _tmp59_);
+ result = _tmp60_;
+ __g_list_free__gst_mini_object_unref0_0 (video_streams);
+ __g_list_free__gst_mini_object_unref0_0 (audio_streams);
+ _g_free0 (id);
+ _g_object_unref0 (item);
+ return result;
+ } else {
+ result = NULL;
+ __g_list_free__gst_mini_object_unref0_0 (video_streams);
+ __g_list_free__gst_mini_object_unref0_0 (audio_streams);
+ _g_free0 (id);
+ _g_object_unref0 (item);
+ return result;
+ }
+ }
+ }
+ __g_list_free__gst_mini_object_unref0_0 (video_streams);
+ __g_list_free__gst_mini_object_unref0_0 (audio_streams);
+ _g_free0 (id);
+ _g_object_unref0 (item);
+}
+
+
+void rygel_media_export_item_factory_fill_audio_item (RygelAudioItem* item, GUPnPDLNAInformation* dlna_info, GstDiscovererAudioInfo* audio_info) {
+ GUPnPDLNAInformation* _tmp0_;
+ GstDiscovererInfo* _tmp1_;
+ GstDiscovererInfo* _tmp2_;
+ GstClockTime _tmp3_ = 0ULL;
+ GstDiscovererAudioInfo* _tmp10_;
+ g_return_if_fail (item != NULL);
+ g_return_if_fail (dlna_info != NULL);
+ _tmp0_ = dlna_info;
+ _tmp1_ = gupnp_dlna_information_get_info (_tmp0_);
+ _tmp2_ = _tmp1_;
+ _tmp3_ = gst_discoverer_info_get_duration (_tmp2_);
+ if (_tmp3_ > ((GstClockTime) 0)) {
+ RygelAudioItem* _tmp4_;
+ GUPnPDLNAInformation* _tmp5_;
+ GstDiscovererInfo* _tmp6_;
+ GstDiscovererInfo* _tmp7_;
+ GstClockTime _tmp8_ = 0ULL;
+ _tmp4_ = item;
+ _tmp5_ = dlna_info;
+ _tmp6_ = gupnp_dlna_information_get_info (_tmp5_);
+ _tmp7_ = _tmp6_;
+ _tmp8_ = gst_discoverer_info_get_duration (_tmp7_);
+ rygel_audio_item_set_duration (_tmp4_, (glong) (_tmp8_ / GST_SECOND));
+ } else {
+ RygelAudioItem* _tmp9_;
+ _tmp9_ = item;
+ rygel_audio_item_set_duration (_tmp9_, (glong) (-1));
+ }
+ _tmp10_ = audio_info;
+ if (_tmp10_ != NULL) {
+ GstDiscovererAudioInfo* _tmp11_;
+ GstTagList* _tmp12_ = NULL;
+ RygelAudioItem* _tmp18_;
+ GstDiscovererAudioInfo* _tmp19_;
+ guint _tmp20_ = 0U;
+ RygelAudioItem* _tmp21_;
+ GstDiscovererAudioInfo* _tmp22_;
+ guint _tmp23_ = 0U;
+ _tmp11_ = audio_info;
+ _tmp12_ = gst_discoverer_stream_info_get_tags ((GstDiscovererStreamInfo*) _tmp11_);
+ if (_tmp12_ != NULL) {
+ guint tmp = 0U;
+ GstDiscovererAudioInfo* _tmp13_;
+ GstTagList* _tmp14_ = NULL;
+ guint _tmp15_ = 0U;
+ RygelAudioItem* _tmp16_;
+ guint _tmp17_;
+ _tmp13_ = audio_info;
+ _tmp14_ = gst_discoverer_stream_info_get_tags ((GstDiscovererStreamInfo*) _tmp13_);
+ gst_tag_list_get_uint (_tmp14_, GST_TAG_BITRATE, &_tmp15_);
+ tmp = _tmp15_;
+ _tmp16_ = item;
+ _tmp17_ = tmp;
+ rygel_audio_item_set_bitrate (_tmp16_, ((gint) _tmp17_) / 8);
+ }
+ _tmp18_ = item;
+ _tmp19_ = audio_info;
+ _tmp20_ = gst_discoverer_audio_info_get_channels (_tmp19_);
+ rygel_audio_item_set_channels (_tmp18_, (gint) _tmp20_);
+ _tmp21_ = item;
+ _tmp22_ = audio_info;
+ _tmp23_ = gst_discoverer_audio_info_get_sample_rate (_tmp22_);
+ rygel_audio_item_set_sample_freq (_tmp21_, (gint) _tmp23_);
+ }
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+RygelMediaItem* rygel_media_export_item_factory_fill_video_item (RygelMediaExportVideoItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererVideoInfo* video_info, GstDiscovererAudioInfo* audio_info, GFileInfo* file_info) {
+ RygelMediaItem* result = NULL;
+ RygelMediaExportVideoItem* _tmp0_;
+ GUPnPDLNAInformation* _tmp1_;
+ GstDiscovererAudioInfo* _tmp2_;
+ RygelMediaExportVideoItem* _tmp3_;
+ GFile* _tmp4_;
+ GUPnPDLNAInformation* _tmp5_;
+ GFileInfo* _tmp6_;
+ RygelMediaExportVideoItem* _tmp7_;
+ GstDiscovererVideoInfo* _tmp8_;
+ guint _tmp9_ = 0U;
+ RygelMediaExportVideoItem* _tmp10_;
+ GstDiscovererVideoInfo* _tmp11_;
+ guint _tmp12_ = 0U;
+ GstDiscovererVideoInfo* _tmp13_;
+ guint _tmp14_ = 0U;
+ gint color_depth;
+ gint _tmp15_ = 0;
+ gint _tmp16_;
+ RygelMediaExportVideoItem* _tmp18_;
+ gint _tmp19_;
+ RygelMediaExportVideoItem* _tmp20_;
+ RygelMediaItem* _tmp21_;
+ g_return_val_if_fail (item != NULL, NULL);
+ g_return_val_if_fail (file != NULL, NULL);
+ g_return_val_if_fail (dlna_info != NULL, NULL);
+ g_return_val_if_fail (video_info != NULL, NULL);
+ g_return_val_if_fail (file_info != NULL, NULL);
+ _tmp0_ = item;
+ _tmp1_ = dlna_info;
+ _tmp2_ = audio_info;
+ rygel_media_export_item_factory_fill_audio_item (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, RYGEL_TYPE_AUDIO_ITEM) ? ((RygelAudioItem*) _tmp0_) : NULL, _tmp1_, _tmp2_);
+ _tmp3_ = item;
+ _tmp4_ = file;
+ _tmp5_ = dlna_info;
+ _tmp6_ = file_info;
+ rygel_media_export_item_factory_fill_media_item ((RygelMediaItem*) _tmp3_, _tmp4_, _tmp5_, _tmp6_);
+ _tmp7_ = item;
+ _tmp8_ = video_info;
+ _tmp9_ = gst_discoverer_video_info_get_width (_tmp8_);
+ rygel_visual_item_set_width ((RygelVisualItem*) _tmp7_, (gint) _tmp9_);
+ _tmp10_ = item;
+ _tmp11_ = video_info;
+ _tmp12_ = gst_discoverer_video_info_get_height (_tmp11_);
+ rygel_visual_item_set_height ((RygelVisualItem*) _tmp10_, (gint) _tmp12_);
+ _tmp13_ = video_info;
+ _tmp14_ = gst_discoverer_video_info_get_depth (_tmp13_);
+ color_depth = (gint) _tmp14_;
+ _tmp16_ = color_depth;
+ if (_tmp16_ == 0) {
+ _tmp15_ = -1;
+ } else {
+ gint _tmp17_;
+ _tmp17_ = color_depth;
+ _tmp15_ = _tmp17_;
+ }
+ _tmp18_ = item;
+ _tmp19_ = _tmp15_;
+ rygel_visual_item_set_color_depth ((RygelVisualItem*) _tmp18_, _tmp19_);
+ _tmp20_ = item;
+ _tmp21_ = _g_object_ref0 ((RygelMediaItem*) _tmp20_);
+ result = _tmp21_;
+ return result;
+}
+
+
+RygelMediaItem* rygel_media_export_item_factory_fill_photo_item (RygelMediaExportPhotoItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererVideoInfo* video_info, GFileInfo* file_info) {
+ RygelMediaItem* result = NULL;
+ RygelMediaExportPhotoItem* _tmp0_;
+ GFile* _tmp1_;
+ GUPnPDLNAInformation* _tmp2_;
+ GFileInfo* _tmp3_;
+ RygelMediaExportPhotoItem* _tmp4_;
+ GstDiscovererVideoInfo* _tmp5_;
+ guint _tmp6_ = 0U;
+ RygelMediaExportPhotoItem* _tmp7_;
+ GstDiscovererVideoInfo* _tmp8_;
+ guint _tmp9_ = 0U;
+ GstDiscovererVideoInfo* _tmp10_;
+ guint _tmp11_ = 0U;
+ gint color_depth;
+ gint _tmp12_ = 0;
+ gint _tmp13_;
+ RygelMediaExportPhotoItem* _tmp15_;
+ gint _tmp16_;
+ RygelMediaExportPhotoItem* _tmp17_;
+ RygelMediaItem* _tmp18_;
+ g_return_val_if_fail (item != NULL, NULL);
+ g_return_val_if_fail (file != NULL, NULL);
+ g_return_val_if_fail (dlna_info != NULL, NULL);
+ g_return_val_if_fail (video_info != NULL, NULL);
+ g_return_val_if_fail (file_info != NULL, NULL);
+ _tmp0_ = item;
+ _tmp1_ = file;
+ _tmp2_ = dlna_info;
+ _tmp3_ = file_info;
+ rygel_media_export_item_factory_fill_media_item ((RygelMediaItem*) _tmp0_, _tmp1_, _tmp2_, _tmp3_);
+ _tmp4_ = item;
+ _tmp5_ = video_info;
+ _tmp6_ = gst_discoverer_video_info_get_width (_tmp5_);
+ rygel_visual_item_set_width ((RygelVisualItem*) _tmp4_, (gint) _tmp6_);
+ _tmp7_ = item;
+ _tmp8_ = video_info;
+ _tmp9_ = gst_discoverer_video_info_get_height (_tmp8_);
+ rygel_visual_item_set_height ((RygelVisualItem*) _tmp7_, (gint) _tmp9_);
+ _tmp10_ = video_info;
+ _tmp11_ = gst_discoverer_video_info_get_depth (_tmp10_);
+ color_depth = (gint) _tmp11_;
+ _tmp13_ = color_depth;
+ if (_tmp13_ == 0) {
+ _tmp12_ = -1;
+ } else {
+ gint _tmp14_;
+ _tmp14_ = color_depth;
+ _tmp12_ = _tmp14_;
+ }
+ _tmp15_ = item;
+ _tmp16_ = _tmp12_;
+ rygel_visual_item_set_color_depth ((RygelVisualItem*) _tmp15_, _tmp16_);
+ _tmp17_ = item;
+ _tmp18_ = _g_object_ref0 ((RygelMediaItem*) _tmp17_);
+ result = _tmp18_;
+ return result;
+}
+
+
+static gpointer _gst_structure_copy0 (gpointer self) {
+ return self ? gst_structure_copy (self) : NULL;
+}
+
+
+RygelMediaItem* rygel_media_export_item_factory_fill_music_item (RygelMediaExportMusicItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererAudioInfo* audio_info, GFileInfo* file_info) {
+ RygelMediaItem* result = NULL;
+ RygelMediaExportMusicItem* _tmp0_;
+ GUPnPDLNAInformation* _tmp1_;
+ GstDiscovererAudioInfo* _tmp2_;
+ RygelMediaExportMusicItem* _tmp3_;
+ GFile* _tmp4_;
+ GUPnPDLNAInformation* _tmp5_;
+ GFileInfo* _tmp6_;
+ GstDiscovererAudioInfo* _tmp7_;
+ RygelMediaExportMusicItem* _tmp64_;
+ RygelMediaItem* _tmp65_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (item != NULL, NULL);
+ g_return_val_if_fail (file != NULL, NULL);
+ g_return_val_if_fail (dlna_info != NULL, NULL);
+ g_return_val_if_fail (file_info != NULL, NULL);
+ _tmp0_ = item;
+ _tmp1_ = dlna_info;
+ _tmp2_ = audio_info;
+ rygel_media_export_item_factory_fill_audio_item (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, RYGEL_TYPE_AUDIO_ITEM) ? ((RygelAudioItem*) _tmp0_) : NULL, _tmp1_, _tmp2_);
+ _tmp3_ = item;
+ _tmp4_ = file;
+ _tmp5_ = dlna_info;
+ _tmp6_ = file_info;
+ rygel_media_export_item_factory_fill_media_item ((RygelMediaItem*) _tmp3_, _tmp4_, _tmp5_, _tmp6_);
+ _tmp7_ = audio_info;
+ if (_tmp7_ != NULL) {
+ GstDiscovererAudioInfo* _tmp8_;
+ GstTagList* _tmp9_ = NULL;
+ gchar* artist = NULL;
+ GUPnPDLNAInformation* _tmp29_;
+ GstDiscovererInfo* _tmp30_;
+ GstDiscovererInfo* _tmp31_;
+ GstTagList* _tmp32_ = NULL;
+ gchar* _tmp33_ = NULL;
+ RygelMediaExportMusicItem* _tmp34_;
+ const gchar* _tmp35_;
+ gchar* album = NULL;
+ GUPnPDLNAInformation* _tmp36_;
+ GstDiscovererInfo* _tmp37_;
+ GstDiscovererInfo* _tmp38_;
+ GstTagList* _tmp39_ = NULL;
+ gchar* _tmp40_ = NULL;
+ RygelMediaExportMusicItem* _tmp41_;
+ const gchar* _tmp42_;
+ gchar* genre = NULL;
+ GUPnPDLNAInformation* _tmp43_;
+ GstDiscovererInfo* _tmp44_;
+ GstDiscovererInfo* _tmp45_;
+ GstTagList* _tmp46_ = NULL;
+ gchar* _tmp47_ = NULL;
+ RygelMediaExportMusicItem* _tmp48_;
+ const gchar* _tmp49_;
+ guint tmp = 0U;
+ GUPnPDLNAInformation* _tmp50_;
+ GstDiscovererInfo* _tmp51_;
+ GstDiscovererInfo* _tmp52_;
+ GstTagList* _tmp53_ = NULL;
+ guint _tmp54_ = 0U;
+ RygelMediaExportMusicItem* _tmp55_;
+ guint _tmp56_;
+ GUPnPDLNAInformation* _tmp57_;
+ GstDiscovererInfo* _tmp58_;
+ GstDiscovererInfo* _tmp59_;
+ GstTagList* _tmp60_ = NULL;
+ guint _tmp61_ = 0U;
+ RygelMediaExportMusicItem* _tmp62_;
+ guint _tmp63_;
+ _tmp8_ = audio_info;
+ _tmp9_ = gst_discoverer_stream_info_get_tags ((GstDiscovererStreamInfo*) _tmp8_);
+ if (_tmp9_ != NULL) {
+ GstBuffer* buffer = NULL;
+ GstDiscovererAudioInfo* _tmp10_;
+ GstTagList* _tmp11_ = NULL;
+ GstBuffer* _tmp12_ = NULL;
+ GstBuffer* _tmp13_;
+ _tmp10_ = audio_info;
+ _tmp11_ = gst_discoverer_stream_info_get_tags ((GstDiscovererStreamInfo*) _tmp10_);
+ gst_tag_list_get_buffer (_tmp11_, GST_TAG_IMAGE, &_tmp12_);
+ buffer = _tmp12_;
+ _tmp13_ = buffer;
+ if (_tmp13_ != NULL) {
+ GstBuffer* _tmp14_;
+ GstCaps* _tmp15_;
+ const GstStructure* _tmp16_ = NULL;
+ GstStructure* _tmp17_;
+ GstStructure* structure;
+ gint image_type = 0;
+ const GstStructure* _tmp18_;
+ gint _tmp19_ = 0;
+ gint _tmp20_;
+ _tmp14_ = buffer;
+ _tmp15_ = _tmp14_->caps;
+ _tmp16_ = gst_caps_get_structure (_tmp15_, (guint) 0);
+ _tmp17_ = _gst_structure_copy0 (_tmp16_);
+ structure = _tmp17_;
+ _tmp18_ = structure;
+ gst_structure_get_enum (_tmp18_, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &_tmp19_);
+ image_type = _tmp19_;
+ _tmp20_ = image_type;
+ switch (_tmp20_) {
+ case GST_TAG_IMAGE_TYPE_UNDEFINED:
+ case GST_TAG_IMAGE_TYPE_FRONT_COVER:
+ {
+ RygelMediaArtStore* _tmp21_ = NULL;
+ RygelMediaArtStore* store;
+ RygelMediaArtStore* _tmp22_;
+ RygelMediaExportMusicItem* _tmp23_;
+ GFile* _tmp24_ = NULL;
+ GFile* thumb;
+ _tmp21_ = rygel_media_art_store_get_default ();
+ store = _tmp21_;
+ _tmp22_ = store;
+ _tmp23_ = item;
+ _tmp24_ = rygel_media_art_store_get_media_art_file (_tmp22_, "album", (RygelMusicItem*) _tmp23_, TRUE);
+ thumb = _tmp24_;
+ {
+ RygelMediaExportJPEGWriter* _tmp25_;
+ RygelMediaExportJPEGWriter* writer;
+ RygelMediaExportJPEGWriter* _tmp26_;
+ GstBuffer* _tmp27_;
+ GFile* _tmp28_;
+ _tmp25_ = rygel_media_export_jpeg_writer_new (&_inner_error_);
+ writer = _tmp25_;
+ if (_inner_error_ != NULL) {
+ goto __catch59_g_error;
+ }
+ _tmp26_ = writer;
+ _tmp27_ = buffer;
+ _tmp28_ = thumb;
+ rygel_media_export_jpeg_writer_write (_tmp26_, _tmp27_, _tmp28_);
+ _g_object_unref0 (writer);
+ }
+ goto __finally59;
+ __catch59_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally59:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (thumb);
+ _g_object_unref0 (store);
+ _gst_structure_free0 (structure);
+ 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;
+ }
+ _g_object_unref0 (thumb);
+ _g_object_unref0 (store);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ _gst_structure_free0 (structure);
+ }
+ }
+ _tmp29_ = dlna_info;
+ _tmp30_ = gupnp_dlna_information_get_info (_tmp29_);
+ _tmp31_ = _tmp30_;
+ _tmp32_ = gst_discoverer_info_get_tags (_tmp31_);
+ gst_tag_list_get_string (_tmp32_, GST_TAG_ARTIST, &_tmp33_);
+ _g_free0 (artist);
+ artist = _tmp33_;
+ _tmp34_ = item;
+ _tmp35_ = artist;
+ rygel_music_item_set_artist ((RygelMusicItem*) _tmp34_, _tmp35_);
+ _tmp36_ = dlna_info;
+ _tmp37_ = gupnp_dlna_information_get_info (_tmp36_);
+ _tmp38_ = _tmp37_;
+ _tmp39_ = gst_discoverer_info_get_tags (_tmp38_);
+ gst_tag_list_get_string (_tmp39_, GST_TAG_ALBUM, &_tmp40_);
+ _g_free0 (album);
+ album = _tmp40_;
+ _tmp41_ = item;
+ _tmp42_ = album;
+ rygel_music_item_set_album ((RygelMusicItem*) _tmp41_, _tmp42_);
+ _tmp43_ = dlna_info;
+ _tmp44_ = gupnp_dlna_information_get_info (_tmp43_);
+ _tmp45_ = _tmp44_;
+ _tmp46_ = gst_discoverer_info_get_tags (_tmp45_);
+ gst_tag_list_get_string (_tmp46_, GST_TAG_GENRE, &_tmp47_);
+ _g_free0 (genre);
+ genre = _tmp47_;
+ _tmp48_ = item;
+ _tmp49_ = genre;
+ rygel_music_item_set_genre ((RygelMusicItem*) _tmp48_, _tmp49_);
+ _tmp50_ = dlna_info;
+ _tmp51_ = gupnp_dlna_information_get_info (_tmp50_);
+ _tmp52_ = _tmp51_;
+ _tmp53_ = gst_discoverer_info_get_tags (_tmp52_);
+ gst_tag_list_get_uint (_tmp53_, GST_TAG_ALBUM_VOLUME_NUMBER, &_tmp54_);
+ tmp = _tmp54_;
+ _tmp55_ = item;
+ _tmp56_ = tmp;
+ _tmp55_->disc = (gint) _tmp56_;
+ _tmp57_ = dlna_info;
+ _tmp58_ = gupnp_dlna_information_get_info (_tmp57_);
+ _tmp59_ = _tmp58_;
+ _tmp60_ = gst_discoverer_info_get_tags (_tmp59_);
+ gst_tag_list_get_uint (_tmp60_, GST_TAG_TRACK_NUMBER, &_tmp61_);
+ tmp = _tmp61_;
+ _tmp62_ = item;
+ _tmp63_ = tmp;
+ rygel_music_item_set_track_number ((RygelMusicItem*) _tmp62_, (gint) _tmp63_);
+ _g_free0 (genre);
+ _g_free0 (album);
+ _g_free0 (artist);
+ }
+ _tmp64_ = item;
+ _tmp65_ = _g_object_ref0 ((RygelMediaItem*) _tmp64_);
+ result = _tmp65_;
+ return result;
+}
+
+
+void rygel_media_export_item_factory_fill_media_item (RygelMediaItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GFileInfo* file_info) {
+ gchar* title;
+ gboolean _tmp0_ = FALSE;
+ GUPnPDLNAInformation* _tmp1_;
+ GstDiscovererInfo* _tmp2_;
+ GstDiscovererInfo* _tmp3_;
+ GstTagList* _tmp4_ = NULL;
+ gboolean _tmp11_;
+ RygelMediaItem* _tmp15_;
+ const gchar* _tmp16_;
+ GUPnPDLNAInformation* _tmp17_;
+ GstDiscovererInfo* _tmp18_;
+ GstDiscovererInfo* _tmp19_;
+ GstTagList* _tmp20_ = NULL;
+ GFileInfo* _tmp32_;
+ guint64 _tmp33_ = 0ULL;
+ guint64 mtime;
+ RygelMediaItem* _tmp34_;
+ const gchar* _tmp35_;
+ const gchar* _tmp36_;
+ RygelMediaItem* _tmp42_;
+ GFileInfo* _tmp43_;
+ gint64 _tmp44_ = 0LL;
+ RygelMediaItem* _tmp45_;
+ guint64 _tmp46_;
+ GUPnPDLNAInformation* _tmp47_;
+ const gchar* _tmp48_;
+ const gchar* _tmp49_;
+ RygelMediaItem* _tmp63_;
+ GFile* _tmp64_;
+ gchar* _tmp65_ = NULL;
+ gchar* _tmp66_;
+ g_return_if_fail (item != NULL);
+ g_return_if_fail (file != NULL);
+ g_return_if_fail (dlna_info != NULL);
+ g_return_if_fail (file_info != NULL);
+ title = NULL;
+ _tmp1_ = dlna_info;
+ _tmp2_ = gupnp_dlna_information_get_info (_tmp1_);
+ _tmp3_ = _tmp2_;
+ _tmp4_ = gst_discoverer_info_get_tags (_tmp3_);
+ if (_tmp4_ == NULL) {
+ _tmp0_ = TRUE;
+ } else {
+ GUPnPDLNAInformation* _tmp5_;
+ GstDiscovererInfo* _tmp6_;
+ GstDiscovererInfo* _tmp7_;
+ GstTagList* _tmp8_ = NULL;
+ gchar* _tmp9_ = NULL;
+ gboolean _tmp10_ = FALSE;
+ _tmp5_ = dlna_info;
+ _tmp6_ = gupnp_dlna_information_get_info (_tmp5_);
+ _tmp7_ = _tmp6_;
+ _tmp8_ = gst_discoverer_info_get_tags (_tmp7_);
+ _tmp10_ = gst_tag_list_get_string (_tmp8_, GST_TAG_TITLE, &_tmp9_);
+ _g_free0 (title);
+ title = _tmp9_;
+ _tmp0_ = !_tmp10_;
+ }
+ _tmp11_ = _tmp0_;
+ if (_tmp11_) {
+ GFileInfo* _tmp12_;
+ const gchar* _tmp13_ = NULL;
+ gchar* _tmp14_;
+ _tmp12_ = file_info;
+ _tmp13_ = g_file_info_get_display_name (_tmp12_);
+ _tmp14_ = g_strdup (_tmp13_);
+ _g_free0 (title);
+ title = _tmp14_;
+ }
+ _tmp15_ = item;
+ _tmp16_ = title;
+ rygel_media_object_set_title ((RygelMediaObject*) _tmp15_, _tmp16_);
+ _tmp17_ = dlna_info;
+ _tmp18_ = gupnp_dlna_information_get_info (_tmp17_);
+ _tmp19_ = _tmp18_;
+ _tmp20_ = gst_discoverer_info_get_tags (_tmp19_);
+ if (_tmp20_ != NULL) {
+ GDate* date = NULL;
+ GUPnPDLNAInformation* _tmp21_;
+ GstDiscovererInfo* _tmp22_;
+ GstDiscovererInfo* _tmp23_;
+ GstTagList* _tmp24_ = NULL;
+ GDate* _tmp25_ = NULL;
+ gboolean _tmp26_ = FALSE;
+ _tmp21_ = dlna_info;
+ _tmp22_ = gupnp_dlna_information_get_info (_tmp21_);
+ _tmp23_ = _tmp22_;
+ _tmp24_ = gst_discoverer_info_get_tags (_tmp23_);
+ _tmp26_ = gst_tag_list_get_date (_tmp24_, GST_TAG_DATE, &_tmp25_);
+ _g_free0 (date);
+ date = _tmp25_;
+ if (_tmp26_) {
+ gchar* _tmp27_ = NULL;
+ gchar* datestr;
+ gint datestr_length1;
+ gint _datestr_size_;
+ GDate* _tmp28_;
+ gchar* _tmp29_;
+ gint _tmp29__length1;
+ RygelMediaItem* _tmp30_;
+ gchar* _tmp31_;
+ gint _tmp31__length1;
+ _tmp27_ = g_new0 (gchar, 30);
+ datestr = _tmp27_;
+ datestr_length1 = 30;
+ _datestr_size_ = datestr_length1;
+ _tmp28_ = date;
+ _tmp29_ = datestr;
+ _tmp29__length1 = datestr_length1;
+ g_date_strftime (_tmp29_, _tmp29__length1, "%F", _tmp28_);
+ _tmp30_ = item;
+ _tmp31_ = datestr;
+ _tmp31__length1 = datestr_length1;
+ rygel_media_item_set_date (_tmp30_, (const gchar*) _tmp31_);
+ datestr = (g_free (datestr), NULL);
+ }
+ _g_free0 (date);
+ }
+ _tmp32_ = file_info;
+ _tmp33_ = g_file_info_get_attribute_uint64 (_tmp32_, G_FILE_ATTRIBUTE_TIME_MODIFIED);
+ mtime = _tmp33_;
+ _tmp34_ = item;
+ _tmp35_ = rygel_media_item_get_date (_tmp34_);
+ _tmp36_ = _tmp35_;
+ if (_tmp36_ == NULL) {
+ guint64 _tmp37_;
+ GTimeVal _tmp38_ = {0};
+ GTimeVal tv;
+ RygelMediaItem* _tmp39_;
+ gchar* _tmp40_ = NULL;
+ gchar* _tmp41_;
+ _tmp37_ = mtime;
+ _tmp38_.tv_sec = (glong) _tmp37_;
+ _tmp38_.tv_usec = (glong) 0;
+ tv = _tmp38_;
+ _tmp39_ = item;
+ _tmp40_ = g_time_val_to_iso8601 (&tv);
+ _tmp41_ = _tmp40_;
+ rygel_media_item_set_date (_tmp39_, _tmp41_);
+ _g_free0 (_tmp41_);
+ }
+ _tmp42_ = item;
+ _tmp43_ = file_info;
+ _tmp44_ = g_file_info_get_size (_tmp43_);
+ rygel_media_item_set_size (_tmp42_, (gint64) _tmp44_);
+ _tmp45_ = item;
+ _tmp46_ = mtime;
+ rygel_media_object_set_modified ((RygelMediaObject*) _tmp45_, (guint64) ((gint64) _tmp46_));
+ _tmp47_ = dlna_info;
+ _tmp48_ = gupnp_dlna_information_get_name (_tmp47_);
+ _tmp49_ = _tmp48_;
+ if (_tmp49_ != NULL) {
+ RygelMediaItem* _tmp50_;
+ GUPnPDLNAInformation* _tmp51_;
+ const gchar* _tmp52_;
+ const gchar* _tmp53_;
+ RygelMediaItem* _tmp54_;
+ GUPnPDLNAInformation* _tmp55_;
+ const gchar* _tmp56_;
+ const gchar* _tmp57_;
+ _tmp50_ = item;
+ _tmp51_ = dlna_info;
+ _tmp52_ = gupnp_dlna_information_get_name (_tmp51_);
+ _tmp53_ = _tmp52_;
+ rygel_media_item_set_dlna_profile (_tmp50_, _tmp53_);
+ _tmp54_ = item;
+ _tmp55_ = dlna_info;
+ _tmp56_ = gupnp_dlna_information_get_mime (_tmp55_);
+ _tmp57_ = _tmp56_;
+ rygel_media_item_set_mime_type (_tmp54_, _tmp57_);
+ } else {
+ RygelMediaItem* _tmp58_;
+ GFileInfo* _tmp59_;
+ const gchar* _tmp60_ = NULL;
+ gchar* _tmp61_ = NULL;
+ gchar* _tmp62_;
+ _tmp58_ = item;
+ _tmp59_ = file_info;
+ _tmp60_ = g_file_info_get_content_type (_tmp59_);
+ _tmp61_ = g_content_type_get_mime_type (_tmp60_);
+ _tmp62_ = _tmp61_;
+ rygel_media_item_set_mime_type (_tmp58_, _tmp62_);
+ _g_free0 (_tmp62_);
+ }
+ _tmp63_ = item;
+ _tmp64_ = file;
+ _tmp65_ = g_file_get_uri (_tmp64_);
+ _tmp66_ = _tmp65_;
+ rygel_media_item_add_uri (_tmp63_, _tmp66_);
+ _g_free0 (_tmp66_);
+ _g_free0 (title);
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-item-factory.h b/src/media-export/rygel-media-export-item-factory.h
new file mode 100644
index 0000000..5a1a983
--- /dev/null
+++ b/src/media-export/rygel-media-export-item-factory.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_ITEM_FACTORY_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_ITEM_FACTORY_H__
+
+#include "rygel-media-export-music-item.h"
+#include "rygel-media-export-photo-item.h"
+#include "rygel-media-export-video-item.h"
+#include <rygel-server.h>
+#include <libgupnp-dlna/gupnp-dlna-information.h>
+
+G_BEGIN_DECLS
+
+
+RygelMediaItem* rygel_media_export_item_factory_create_simple (RygelMediaContainer* parent, GFile* file, GFileInfo* info);
+gchar* rygel_media_export_media_cache_get_id (GFile* file);
+RygelMediaItem* rygel_media_export_item_factory_create_playlist_item (GFile* file, RygelMediaContainer* parent, const gchar* fallback_title);
+RygelMediaItem* rygel_media_export_item_factory_create_from_info (RygelMediaContainer* parent, GFile* file, GUPnPDLNAInformation* dlna_info, GFileInfo* file_info);
+RygelMediaItem* rygel_media_export_item_factory_fill_photo_item (RygelMediaExportPhotoItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererVideoInfo* video_info, GFileInfo* file_info);
+RygelMediaItem* rygel_media_export_item_factory_fill_video_item (RygelMediaExportVideoItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererVideoInfo* video_info, GstDiscovererAudioInfo* audio_info, GFileInfo* file_info);
+RygelMediaItem* rygel_media_export_item_factory_fill_music_item (RygelMediaExportMusicItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GstDiscovererAudioInfo* audio_info, GFileInfo* file_info);
+void rygel_media_export_item_factory_fill_audio_item (RygelAudioItem* item, GUPnPDLNAInformation* dlna_info, GstDiscovererAudioInfo* audio_info);
+void rygel_media_export_item_factory_fill_media_item (RygelMediaItem* item, GFile* file, GUPnPDLNAInformation* dlna_info, GFileInfo* file_info);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_ITEM_FACTORY_H__ */
diff --git a/src/media-export/rygel-media-export-jpeg-writer.c b/src/media-export/rygel-media-export-jpeg-writer.c
new file mode 100644
index 0000000..64f9584
--- /dev/null
+++ b/src/media-export/rygel-media-export-jpeg-writer.c
@@ -0,0 +1,219 @@
+/* rygel-media-export-jpeg-writer.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-jpeg-writer.vala, do not modify */
+
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-jpeg-writer.h"
+#include <gst/app/gstappsrc.h>
+
+/**
+ * Utility class to write media-art content to JPEG files
+ *
+ * This uses a gstreamer pipeline to transcode the image tag as contained in
+ * MP3 files. This class is single-shot, use and then throw away.
+ */
+
+G_DEFINE_TYPE (RygelMediaExportJPEGWriter, rygel_media_export_jpeg_writer, G_TYPE_OBJECT)
+
+
+#define _gst_object_unref0(var) ((var == NULL) ? NULL : (var = (gst_object_unref (var), NULL)))
+#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+struct _RygelMediaExportJPEGWriterPrivate {
+ GstBin* bin;
+ GstAppSrc* appsrc;
+ GMainLoop* loop;
+ GstElement* sink;
+};
+
+#define RYGEL_MEDIA_EXPORT_JPEG_WRITER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER, RygelMediaExportJPEGWriterPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_JPEG_WRITER_DUMMY_PROPERTY
+};
+RygelMediaExportJPEGWriter* rygel_media_export_jpeg_writer_new (GError** error);
+RygelMediaExportJPEGWriter* rygel_media_export_jpeg_writer_construct (GType object_type, GError** error);
+static void __lambda4_ (RygelMediaExportJPEGWriter* self);
+static void ___lambda4__gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self);
+static void __lambda5_ (RygelMediaExportJPEGWriter* self);
+static void ___lambda5__gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self);
+void rygel_media_export_jpeg_writer_write (RygelMediaExportJPEGWriter* self, GstBuffer* buffer, GFile* file);
+static inline void _dynamic_set_file0 (GstElement* obj, GFile* value);
+static void rygel_media_export_jpeg_writer_finalize (GObject* obj);
+
+
+static void __lambda4_ (RygelMediaExportJPEGWriter* self) {
+ GMainLoop* _tmp0_;
+ _tmp0_ = self->priv->loop;
+ g_main_loop_quit (_tmp0_);
+}
+
+
+static void ___lambda4__gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self) {
+ __lambda4_ (self);
+}
+
+
+static void __lambda5_ (RygelMediaExportJPEGWriter* self) {
+ GMainLoop* _tmp0_;
+ _tmp0_ = self->priv->loop;
+ g_main_loop_quit (_tmp0_);
+}
+
+
+static void ___lambda5__gst_bus_message (GstBus* _sender, GstMessage* message, gpointer self) {
+ __lambda5_ (self);
+}
+
+
+RygelMediaExportJPEGWriter* rygel_media_export_jpeg_writer_construct (GType object_type, GError** error) {
+ RygelMediaExportJPEGWriter * self = NULL;
+ GstElement* _tmp0_ = NULL;
+ GstElement* _tmp1_;
+ GstBin* _tmp2_;
+ GstElement* _tmp3_ = NULL;
+ GstBin* _tmp4_;
+ GstElement* _tmp5_ = NULL;
+ GstBin* _tmp6_;
+ GstBus* _tmp7_ = NULL;
+ GstBus* bus;
+ GstBus* _tmp8_;
+ GstBus* _tmp9_;
+ GstBus* _tmp10_;
+ GMainLoop* _tmp11_;
+ GError * _inner_error_ = NULL;
+ self = (RygelMediaExportJPEGWriter*) g_object_new (object_type, NULL);
+ _tmp0_ = gst_parse_launch ("appsrc name=src ! decodebin2 ! " "ffmpegcolorspace ! " "jpegenc ! giosink name=sink", &_inner_error_);
+ _tmp1_ = _tmp0_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ _gst_object_unref0 (self->priv->bin);
+ self->priv->bin = G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GST_TYPE_BIN) ? ((GstBin*) _tmp1_) : NULL;
+ _tmp2_ = self->priv->bin;
+ _tmp3_ = gst_bin_get_by_name (_tmp2_, "src");
+ _gst_object_unref0 (self->priv->appsrc);
+ self->priv->appsrc = G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, GST_TYPE_APP_SRC) ? ((GstAppSrc*) _tmp3_) : NULL;
+ _tmp4_ = self->priv->bin;
+ _tmp5_ = gst_bin_get_by_name (_tmp4_, "sink");
+ _gst_object_unref0 (self->priv->sink);
+ self->priv->sink = _tmp5_;
+ _tmp6_ = self->priv->bin;
+ _tmp7_ = gst_element_get_bus ((GstElement*) _tmp6_);
+ bus = _tmp7_;
+ _tmp8_ = bus;
+ gst_bus_add_signal_watch (_tmp8_);
+ _tmp9_ = bus;
+ g_signal_connect_object (_tmp9_, "message::eos", (GCallback) ___lambda4__gst_bus_message, self, 0);
+ _tmp10_ = bus;
+ g_signal_connect_object (_tmp10_, "message::error", (GCallback) ___lambda5__gst_bus_message, self, 0);
+ _tmp11_ = g_main_loop_new (NULL, FALSE);
+ _g_main_loop_unref0 (self->priv->loop);
+ self->priv->loop = _tmp11_;
+ _gst_object_unref0 (bus);
+ return self;
+}
+
+
+RygelMediaExportJPEGWriter* rygel_media_export_jpeg_writer_new (GError** error) {
+ return rygel_media_export_jpeg_writer_construct (RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER, error);
+}
+
+
+/**
+ * Write a Gst.Buffer as retrieved from the Gst.TagList to disk.
+ *
+ * @param buffer The Gst.Buffer as obtained from tag list
+ * @param file A GLib.File pointing to the target location
+ *
+ * FIXME This uses a nested main-loop to block which is ugly.
+ */
+static inline void _dynamic_set_file0 (GstElement* obj, GFile* value) {
+ g_object_set (obj, "file", value, NULL);
+}
+
+
+static gpointer _gst_buffer_ref0 (gpointer self) {
+ return self ? gst_buffer_ref (self) : NULL;
+}
+
+
+void rygel_media_export_jpeg_writer_write (RygelMediaExportJPEGWriter* self, GstBuffer* buffer, GFile* file) {
+ GstElement* _tmp0_;
+ GFile* _tmp1_;
+ GstAppSrc* _tmp2_;
+ GstBuffer* _tmp3_;
+ GstBuffer* _tmp4_;
+ GstAppSrc* _tmp5_;
+ GstBin* _tmp6_;
+ GMainLoop* _tmp7_;
+ GstBin* _tmp8_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (buffer != NULL);
+ g_return_if_fail (file != NULL);
+ _tmp0_ = self->priv->sink;
+ _tmp1_ = file;
+ _dynamic_set_file0 (_tmp0_, _tmp1_);
+ _tmp2_ = self->priv->appsrc;
+ _tmp3_ = buffer;
+ _tmp4_ = _gst_buffer_ref0 (_tmp3_);
+ gst_app_src_push_buffer (_tmp2_, _tmp4_);
+ _tmp5_ = self->priv->appsrc;
+ gst_app_src_end_of_stream (_tmp5_);
+ _tmp6_ = self->priv->bin;
+ gst_element_set_state ((GstElement*) _tmp6_, GST_STATE_PLAYING);
+ _tmp7_ = self->priv->loop;
+ g_main_loop_run (_tmp7_);
+ _tmp8_ = self->priv->bin;
+ gst_element_set_state ((GstElement*) _tmp8_, GST_STATE_NULL);
+}
+
+
+static void rygel_media_export_jpeg_writer_class_init (RygelMediaExportJPEGWriterClass * klass) {
+ rygel_media_export_jpeg_writer_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportJPEGWriterPrivate));
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_jpeg_writer_finalize;
+}
+
+
+static void rygel_media_export_jpeg_writer_init (RygelMediaExportJPEGWriter * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_JPEG_WRITER_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_jpeg_writer_finalize (GObject* obj) {
+ RygelMediaExportJPEGWriter * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER, RygelMediaExportJPEGWriter);
+ _gst_object_unref0 (self->priv->bin);
+ _gst_object_unref0 (self->priv->appsrc);
+ _g_main_loop_unref0 (self->priv->loop);
+ _gst_object_unref0 (self->priv->sink);
+ G_OBJECT_CLASS (rygel_media_export_jpeg_writer_parent_class)->finalize (obj);
+}
+
+
+
+
+
diff --git a/src/media-export/rygel-media-export-jpeg-writer.h b/src/media-export/rygel-media-export-jpeg-writer.h
new file mode 100644
index 0000000..95feca3
--- /dev/null
+++ b/src/media-export/rygel-media-export-jpeg-writer.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_JPEG_WRITER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_JPEG_WRITER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER (rygel_media_export_jpeg_writer_get_type ())
+#define RYGEL_MEDIA_EXPORT_JPEG_WRITER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER, RygelMediaExportJPEGWriter))
+#define RYGEL_MEDIA_EXPORT_JPEG_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER, RygelMediaExportJPEGWriterClass))
+#define RYGEL_MEDIA_EXPORT_IS_JPEG_WRITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER))
+#define RYGEL_MEDIA_EXPORT_IS_JPEG_WRITER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER))
+#define RYGEL_MEDIA_EXPORT_JPEG_WRITER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_JPEG_WRITER, RygelMediaExportJPEGWriterClass))
+
+typedef struct _RygelMediaExportJPEGWriter RygelMediaExportJPEGWriter;
+typedef struct _RygelMediaExportJPEGWriterClass RygelMediaExportJPEGWriterClass;
+typedef struct _RygelMediaExportJPEGWriterPrivate RygelMediaExportJPEGWriterPrivate;
+
+struct _RygelMediaExportJPEGWriter {
+ GObject parent_instance;
+ RygelMediaExportJPEGWriterPrivate *priv;
+};
+
+struct _RygelMediaExportJPEGWriterClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_jpeg_writer_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportJPEGWriter* rygel_media_export_jpeg_writer_new (GError** error);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_JPEG_WRITER_H__ */
diff --git a/src/media-export/rygel-media-export-leaf-query-container.c b/src/media-export/rygel-media-export-leaf-query-container.c
new file mode 100644
index 0000000..467e51e
--- /dev/null
+++ b/src/media-export/rygel-media-export-leaf-query-container.c
@@ -0,0 +1,391 @@
+/* rygel-media-export-leaf-query-container.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-leaf-query-container.vala, do not modify */
+
+/*
+ * Copyright (C) 2011 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <rygel-server.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gee.h>
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER (rygel_media_export_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+
+typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
+typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
+typedef struct _RygelMediaExportDBContainerPrivate RygelMediaExportDBContainerPrivate;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE (rygel_media_export_media_cache_get_type ())
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+
+typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
+typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER (rygel_media_export_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainer))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+
+typedef struct _RygelMediaExportQueryContainer RygelMediaExportQueryContainer;
+typedef struct _RygelMediaExportQueryContainerClass RygelMediaExportQueryContainerClass;
+typedef struct _RygelMediaExportQueryContainerPrivate RygelMediaExportQueryContainerPrivate;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER (rygel_media_export_leaf_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_LEAF_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER, RygelMediaExportLeafQueryContainer))
+#define RYGEL_MEDIA_EXPORT_LEAF_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER, RygelMediaExportLeafQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_LEAF_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_LEAF_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_LEAF_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER, RygelMediaExportLeafQueryContainerClass))
+
+typedef struct _RygelMediaExportLeafQueryContainer RygelMediaExportLeafQueryContainer;
+typedef struct _RygelMediaExportLeafQueryContainerClass RygelMediaExportLeafQueryContainerClass;
+typedef struct _RygelMediaExportLeafQueryContainerPrivate RygelMediaExportLeafQueryContainerPrivate;
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+typedef struct _RygelMediaExportLeafQueryContainerGetChildrenData RygelMediaExportLeafQueryContainerGetChildrenData;
+
+struct _RygelMediaExportDBContainer {
+ RygelMediaContainer parent_instance;
+ RygelMediaExportDBContainerPrivate * priv;
+ RygelMediaExportMediaCache* media_db;
+};
+
+struct _RygelMediaExportDBContainerClass {
+ RygelMediaContainerClass parent_class;
+ void (*search) (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+ RygelMediaObjects* (*search_finish) (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error);
+};
+
+struct _RygelMediaExportQueryContainer {
+ RygelMediaExportDBContainer parent_instance;
+ RygelMediaExportQueryContainerPrivate * priv;
+ RygelSearchExpression* expression;
+};
+
+struct _RygelMediaExportQueryContainerClass {
+ RygelMediaExportDBContainerClass parent_class;
+ gint (*count_children) (RygelMediaExportQueryContainer* self, GError** error);
+};
+
+struct _RygelMediaExportLeafQueryContainer {
+ RygelMediaExportQueryContainer parent_instance;
+ RygelMediaExportLeafQueryContainerPrivate * priv;
+};
+
+struct _RygelMediaExportLeafQueryContainerClass {
+ RygelMediaExportQueryContainerClass parent_class;
+};
+
+struct _RygelMediaExportLeafQueryContainerGetChildrenData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportLeafQueryContainer* self;
+ guint offset;
+ guint max_count;
+ gchar* sort_criteria;
+ GCancellable* cancellable;
+ RygelMediaObjects* result;
+ guint total_matches;
+ guint _tmp0_;
+ guint _tmp1_;
+ const gchar* _tmp2_;
+ GCancellable* _tmp3_;
+ guint _tmp4_;
+ RygelMediaObjects* _tmp5_;
+ RygelMediaObjects* children;
+ RygelMediaObjects* _tmp6_;
+ RygelMediaObjects* _child_list;
+ RygelMediaObjects* _tmp7_;
+ gint _tmp8_;
+ gint _tmp9_;
+ gint _child_size;
+ gint _child_index;
+ gint _tmp10_;
+ gint _tmp11_;
+ gint _tmp12_;
+ RygelMediaObjects* _tmp13_;
+ gint _tmp14_;
+ gpointer _tmp15_;
+ RygelMediaObject* child;
+ RygelMediaObject* _tmp16_;
+ GError * _inner_error_;
+};
+
+
+static gpointer rygel_media_export_leaf_query_container_parent_class = NULL;
+
+GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_query_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_leaf_query_container_get_type (void) G_GNUC_CONST;
+enum {
+ RYGEL_MEDIA_EXPORT_LEAF_QUERY_CONTAINER_DUMMY_PROPERTY
+};
+RygelMediaExportLeafQueryContainer* rygel_media_export_leaf_query_container_new (RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name);
+RygelMediaExportLeafQueryContainer* rygel_media_export_leaf_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name);
+RygelMediaExportQueryContainer* rygel_media_export_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name);
+static void rygel_media_export_leaf_query_container_real_get_children_data_free (gpointer _data);
+static void rygel_media_export_leaf_query_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_leaf_query_container_real_get_children_co (RygelMediaExportLeafQueryContainerGetChildrenData* _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 void rygel_media_export_leaf_query_container_get_children_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+static gint rygel_media_export_leaf_query_container_real_count_children (RygelMediaExportQueryContainer* base, GError** error);
+glong rygel_media_export_media_cache_get_object_count_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, GError** error);
+
+
+RygelMediaExportLeafQueryContainer* rygel_media_export_leaf_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name) {
+ RygelMediaExportLeafQueryContainer * self = NULL;
+ RygelMediaExportMediaCache* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ const gchar* _tmp2_;
+ const gchar* _tmp3_;
+ g_return_val_if_fail (cache != NULL, NULL);
+ g_return_val_if_fail (expression != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ _tmp0_ = cache;
+ _tmp1_ = expression;
+ _tmp2_ = id;
+ _tmp3_ = name;
+ self = (RygelMediaExportLeafQueryContainer*) rygel_media_export_query_container_construct (object_type, _tmp0_, _tmp1_, _tmp2_, _tmp3_);
+ return self;
+}
+
+
+RygelMediaExportLeafQueryContainer* rygel_media_export_leaf_query_container_new (RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name) {
+ return rygel_media_export_leaf_query_container_construct (RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER, cache, expression, id, name);
+}
+
+
+static void rygel_media_export_leaf_query_container_real_get_children_data_free (gpointer _data) {
+ RygelMediaExportLeafQueryContainerGetChildrenData* _data_;
+ _data_ = _data;
+ _g_free0 (_data_->sort_criteria);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportLeafQueryContainerGetChildrenData, _data_);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void rygel_media_export_leaf_query_container_real_get_children (RygelMediaContainer* base, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportLeafQueryContainer * self;
+ RygelMediaExportLeafQueryContainerGetChildrenData* _data_;
+ RygelMediaExportLeafQueryContainer* _tmp0_;
+ guint _tmp1_;
+ guint _tmp2_;
+ const gchar* _tmp3_;
+ gchar* _tmp4_;
+ GCancellable* _tmp5_;
+ GCancellable* _tmp6_;
+ self = (RygelMediaExportLeafQueryContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportLeafQueryContainerGetChildrenData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_leaf_query_container_real_get_children);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_leaf_query_container_real_get_children_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = offset;
+ _data_->offset = _tmp1_;
+ _tmp2_ = max_count;
+ _data_->max_count = _tmp2_;
+ _tmp3_ = sort_criteria;
+ _tmp4_ = g_strdup (_tmp3_);
+ _g_free0 (_data_->sort_criteria);
+ _data_->sort_criteria = _tmp4_;
+ _tmp5_ = cancellable;
+ _tmp6_ = _g_object_ref0 (_tmp5_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp6_;
+ rygel_media_export_leaf_query_container_real_get_children_co (_data_);
+}
+
+
+static RygelMediaObjects* rygel_media_export_leaf_query_container_real_get_children_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaObjects* result;
+ RygelMediaExportLeafQueryContainerGetChildrenData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static void rygel_media_export_leaf_query_container_get_children_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ RygelMediaExportLeafQueryContainerGetChildrenData* _data_;
+ _data_ = _user_data_;
+ _data_->_source_object_ = source_object;
+ _data_->_res_ = _res_;
+ rygel_media_export_leaf_query_container_real_get_children_co (_data_);
+}
+
+
+static gboolean rygel_media_export_leaf_query_container_real_get_children_co (RygelMediaExportLeafQueryContainerGetChildrenData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ case 1:
+ goto _state_1;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = _data_->offset;
+ _data_->_tmp1_ = _data_->max_count;
+ _data_->_tmp2_ = _data_->sort_criteria;
+ _data_->_tmp3_ = _data_->cancellable;
+ _data_->_tmp4_ = 0U;
+ _data_->_state_ = 1;
+ rygel_media_export_db_container_search ((RygelMediaExportDBContainer*) _data_->self, NULL, _data_->_tmp0_, _data_->_tmp1_, _data_->_tmp2_, _data_->_tmp3_, rygel_media_export_leaf_query_container_get_children_ready, _data_);
+ return FALSE;
+ _state_1:
+ _data_->_tmp5_ = NULL;
+ _data_->_tmp5_ = rygel_media_export_db_container_search_finish ((RygelMediaExportDBContainer*) _data_->self, _data_->_res_, &_data_->_tmp4_, &_data_->_inner_error_);
+ _data_->total_matches = _data_->_tmp4_;
+ _data_->children = _data_->_tmp5_;
+ 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_->_tmp6_ = _g_object_ref0 (_data_->children);
+ _data_->_child_list = _data_->_tmp6_;
+ _data_->_tmp7_ = _data_->_child_list;
+ _data_->_tmp8_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp7_);
+ _data_->_tmp9_ = _data_->_tmp8_;
+ _data_->_child_size = _data_->_tmp9_;
+ _data_->_child_index = -1;
+ while (TRUE) {
+ _data_->_tmp10_ = _data_->_child_index;
+ _data_->_child_index = _data_->_tmp10_ + 1;
+ _data_->_tmp11_ = _data_->_child_index;
+ _data_->_tmp12_ = _data_->_child_size;
+ if (!(_data_->_tmp11_ < _data_->_tmp12_)) {
+ break;
+ }
+ _data_->_tmp13_ = _data_->_child_list;
+ _data_->_tmp14_ = _data_->_child_index;
+ _data_->_tmp15_ = NULL;
+ _data_->_tmp15_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp13_, _data_->_tmp14_);
+ _data_->child = (RygelMediaObject*) _data_->_tmp15_;
+ _data_->_tmp16_ = _data_->child;
+ _data_->_tmp16_->parent = (RygelMediaContainer*) _data_->self;
+ _g_object_unref0 (_data_->child);
+ }
+ _g_object_unref0 (_data_->_child_list);
+ }
+ _data_->result = _data_->children;
+ 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_unref0 (_data_->children);
+ 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 gint rygel_media_export_leaf_query_container_real_count_children (RygelMediaExportQueryContainer* base, GError** error) {
+ RygelMediaExportLeafQueryContainer * self;
+ gint result = 0;
+ RygelMediaExportMediaCache* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ glong _tmp2_ = 0L;
+ glong _tmp3_;
+ GError * _inner_error_ = NULL;
+ self = (RygelMediaExportLeafQueryContainer*) base;
+ _tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp1_ = ((RygelMediaExportQueryContainer*) self)->expression;
+ _tmp2_ = rygel_media_export_media_cache_get_object_count_by_search_expression (_tmp0_, _tmp1_, NULL, &_inner_error_);
+ _tmp3_ = _tmp2_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return 0;
+ }
+ result = (gint) _tmp3_;
+ return result;
+}
+
+
+static void rygel_media_export_leaf_query_container_class_init (RygelMediaExportLeafQueryContainerClass * klass) {
+ rygel_media_export_leaf_query_container_parent_class = g_type_class_peek_parent (klass);
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children = rygel_media_export_leaf_query_container_real_get_children;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children_finish = rygel_media_export_leaf_query_container_real_get_children_finish;
+ RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS (klass)->count_children = rygel_media_export_leaf_query_container_real_count_children;
+}
+
+
+static void rygel_media_export_leaf_query_container_init (RygelMediaExportLeafQueryContainer * self) {
+}
+
+
+GType rygel_media_export_leaf_query_container_get_type (void) {
+ static volatile gsize rygel_media_export_leaf_query_container_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_leaf_query_container_type_id__volatile)) {
+ static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportLeafQueryContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_leaf_query_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportLeafQueryContainer), 0, (GInstanceInitFunc) rygel_media_export_leaf_query_container_init, NULL };
+ GType rygel_media_export_leaf_query_container_type_id;
+ rygel_media_export_leaf_query_container_type_id = g_type_register_static (RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, "RygelMediaExportLeafQueryContainer", &g_define_type_info, 0);
+ g_once_init_leave (&rygel_media_export_leaf_query_container_type_id__volatile, rygel_media_export_leaf_query_container_type_id);
+ }
+ return rygel_media_export_leaf_query_container_type_id__volatile;
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-media-cache-upgrader.c b/src/media-export/rygel-media-export-media-cache-upgrader.c
new file mode 100644
index 0000000..55591e8
--- /dev/null
+++ b/src/media-export/rygel-media-export-media-cache-upgrader.c
@@ -0,0 +1,2179 @@
+/* rygel-media-export-media-cache-upgrader.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-media-cache-upgrader.vala, do not modify */
+
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-media-cache-upgrader.h"
+#include "rygel-media-export-media-cache.h"
+#include "rygel-media-export-database-cursor.h"
+
+
+G_DEFINE_TYPE (RygelMediaExportMediaCacheUpgrader, rygel_media_export_media_cache_upgrader, G_TYPE_OBJECT)
+
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY (rygel_media_export_sql_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactory))
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY))
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactoryClass))
+
+typedef struct _RygelMediaExportSQLFactory RygelMediaExportSQLFactory;
+typedef struct _RygelMediaExportSQLFactoryClass RygelMediaExportSQLFactoryClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_STRING (rygel_media_export_sql_string_get_type ())
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR (rygel_media_export_database_cursor_iterator_get_type ())
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIterator))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIteratorClass))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIteratorClass))
+
+typedef struct _RygelMediaExportDatabaseCursorIterator RygelMediaExportDatabaseCursorIterator;
+typedef struct _RygelMediaExportDatabaseCursorIteratorClass RygelMediaExportDatabaseCursorIteratorClass;
+#define _rygel_media_export_database_cursor_iterator_unref0(var) ((var == NULL) ? NULL : (var = (rygel_media_export_database_cursor_iterator_unref (var), NULL)))
+typedef struct _RygelMediaExportParamSpecMediaCacheUpgrader RygelMediaExportParamSpecMediaCacheUpgrader;
+
+struct _RygelMediaExportMediaCacheUpgraderPrivate {
+ RygelMediaExportDatabase* database;
+ RygelMediaExportSQLFactory* sql;
+};
+
+typedef enum {
+ RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS
+} RygelMediaExportSQLString;
+
+struct _RygelMediaExportParamSpecMediaCacheUpgrader {
+ GParamSpec parent_instance;
+};
+
+
+gpointer rygel_media_export_media_cache_upgrader_ref (gpointer instance);
+void rygel_media_export_media_cache_upgrader_unref (gpointer instance);
+GParamSpec* rygel_media_export_param_spec_media_cache_upgrader (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
+void rygel_media_export_value_set_media_cache_upgrader (GValue* value, gpointer v_object);
+void rygel_media_export_value_take_media_cache_upgrader (GValue* value, gpointer v_object);
+gpointer rygel_media_export_value_get_media_cache_upgrader (const GValue* value);
+GType rygel_media_export_media_cache_upgrader_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_sqlite_wrapper_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_database_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_sql_factory_get_type (void) G_GNUC_CONST;
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgraderPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_DUMMY_PROPERTY
+};
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_2 "UPDATE meta_data SET object_fk = " "(SELECT upnp_id FROM Object WHERE metadata_fk = meta_data.id)"
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_3 "ALTER TABLE Object ADD timestamp INTEGER"
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_4 "UPDATE Object SET timestamp = 0"
+RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_new (RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql);
+RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_construct (GType object_type, RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql);
+gboolean rygel_media_export_media_cache_upgrader_needs_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint* current_version, GError** error);
+GQuark rygel_media_export_database_error_quark (void);
+gint rygel_media_export_database_query_value (RygelMediaExportDatabase* self, const gchar* sql, GValue* args, int args_length1, GError** error);
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION "11"
+void rygel_media_export_media_cache_upgrader_fix_schema (RygelMediaExportMediaCacheUpgrader* self, GError** error);
+void rygel_media_export_database_begin (RygelMediaExportDatabase* self, GError** error);
+void rygel_media_export_database_exec (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+GType rygel_media_export_sql_string_get_type (void) G_GNUC_CONST;
+const gchar* rygel_media_export_sql_factory_make (RygelMediaExportSQLFactory* self, RygelMediaExportSQLString query);
+void rygel_media_export_database_commit (RygelMediaExportDatabase* self, GError** error);
+void rygel_media_export_database_rollback (RygelMediaExportDatabase* self);
+void rygel_media_export_media_cache_upgrader_ensure_indices (RygelMediaExportMediaCacheUpgrader* self);
+void rygel_media_export_database_analyze (RygelMediaExportDatabase* self);
+void rygel_media_export_media_cache_upgrader_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint old_version);
+static void rygel_media_export_media_cache_upgrader_update_v3_v4 (RygelMediaExportMediaCacheUpgrader* self);
+static void rygel_media_export_media_cache_upgrader_update_v4_v5 (RygelMediaExportMediaCacheUpgrader* self);
+static void rygel_media_export_media_cache_upgrader_update_v5_v6 (RygelMediaExportMediaCacheUpgrader* self);
+static void rygel_media_export_media_cache_upgrader_update_v6_v7 (RygelMediaExportMediaCacheUpgrader* self);
+static void rygel_media_export_media_cache_upgrader_update_v7_v8 (RygelMediaExportMediaCacheUpgrader* self);
+static void rygel_media_export_media_cache_upgrader_update_v8_v9 (RygelMediaExportMediaCacheUpgrader* self);
+static void rygel_media_export_media_cache_upgrader_update_v9_v10 (RygelMediaExportMediaCacheUpgrader* self);
+static void rygel_media_export_media_cache_upgrader_update_v10_v11 (RygelMediaExportMediaCacheUpgrader* self);
+static void rygel_media_export_media_cache_upgrader_force_reindex (RygelMediaExportMediaCacheUpgrader* self, GError** error);
+GType rygel_media_export_database_cursor_get_type (void) G_GNUC_CONST;
+RygelMediaExportDatabaseCursor* rygel_media_export_database_exec_cursor (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+static void _vala_GValue_array_free (GValue* array, gint array_length);
+gpointer rygel_media_export_database_cursor_iterator_ref (gpointer instance);
+void rygel_media_export_database_cursor_iterator_unref (gpointer instance);
+GParamSpec* rygel_media_export_database_cursor_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
+void rygel_media_export_database_cursor_value_set_iterator (GValue* value, gpointer v_object);
+void rygel_media_export_database_cursor_value_take_iterator (GValue* value, gpointer v_object);
+gpointer rygel_media_export_database_cursor_value_get_iterator (const GValue* value);
+GType rygel_media_export_database_cursor_iterator_get_type (void) G_GNUC_CONST;
+RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator (RygelMediaExportDatabaseCursor* self);
+gboolean rygel_media_export_database_cursor_iterator_next (RygelMediaExportDatabaseCursorIterator* self);
+sqlite3_stmt* rygel_media_export_database_cursor_iterator_get (RygelMediaExportDatabaseCursorIterator* self, GError** error);
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "virtual-container:"
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "Filesystem"
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_NAME "Files & Folders"
+static void rygel_media_export_media_cache_upgrader_finalize (RygelMediaExportMediaCacheUpgrader* obj);
+
+
+RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_construct (GType object_type, RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql) {
+ RygelMediaExportMediaCacheUpgrader* self = NULL;
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportSQLFactory* _tmp1_;
+ g_return_val_if_fail (database != NULL, NULL);
+ g_return_val_if_fail (sql != NULL, NULL);
+ self = (RygelMediaExportMediaCacheUpgrader*) g_type_create_instance (object_type);
+ _tmp0_ = database;
+ self->priv->database = _tmp0_;
+ _tmp1_ = sql;
+ self->priv->sql = _tmp1_;
+ return self;
+}
+
+
+RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_new (RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql) {
+ return rygel_media_export_media_cache_upgrader_construct (RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, database, sql);
+}
+
+
+gboolean rygel_media_export_media_cache_upgrader_needs_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint* current_version, GError** error) {
+ gint _vala_current_version = 0;
+ gboolean result = FALSE;
+ RygelMediaExportDatabase* _tmp0_;
+ gint _tmp1_ = 0;
+ gint _tmp2_;
+ gint _tmp3_;
+ gint _tmp4_ = 0;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, FALSE);
+ _tmp0_ = self->priv->database;
+ _tmp1_ = rygel_media_export_database_query_value (_tmp0_, "SELECT version FROM schema_info", NULL, 0, &_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return FALSE;
+ }
+ _vala_current_version = _tmp2_;
+ _tmp3_ = _vala_current_version;
+ _tmp4_ = atoi (RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION);
+ result = _tmp3_ < _tmp4_;
+ if (current_version) {
+ *current_version = _vala_current_version;
+ }
+ return result;
+}
+
+
+void rygel_media_export_media_cache_upgrader_fix_schema (RygelMediaExportMediaCacheUpgrader* self, GError** error) {
+ RygelMediaExportDatabase* _tmp0_;
+ gint _tmp1_ = 0;
+ gint matching_schema_count;
+ gint _tmp2_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = self->priv->database;
+ _tmp1_ = rygel_media_export_database_query_value (_tmp0_, "SELECT count(*) FROM " "sqlite_master WHERE sql " "LIKE 'CREATE TABLE Meta_Data" "%object_fk TEXT UNIQUE%'", NULL, 0, &_inner_error_);
+ matching_schema_count = _tmp1_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ }
+ _tmp2_ = matching_schema_count;
+ if (_tmp2_ == 0) {
+ {
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportDatabase* _tmp5_;
+ RygelMediaExportDatabase* _tmp6_;
+ RygelMediaExportSQLFactory* _tmp7_;
+ const gchar* _tmp8_ = NULL;
+ RygelMediaExportDatabase* _tmp9_;
+ g_message ("rygel-media-export-media-cache-upgrader.vala:58: Found faulty schema, " \
+"forcing full reindex");
+ _tmp3_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp3_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch12_g_error;
+ }
+ _tmp4_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp4_, "DELETE FROM Object WHERE upnp_id IN (" "SELECT DISTINCT object_fk FROM meta_data)", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch12_g_error;
+ }
+ _tmp5_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp5_, "DROP TABLE Meta_Data", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch12_g_error;
+ }
+ _tmp6_ = self->priv->database;
+ _tmp7_ = self->priv->sql;
+ _tmp8_ = rygel_media_export_sql_factory_make (_tmp7_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA);
+ rygel_media_export_database_exec (_tmp6_, _tmp8_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch12_g_error;
+ }
+ _tmp9_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp9_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch12_g_error;
+ }
+ }
+ goto __finally12;
+ __catch12_g_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp10_;
+ GError* _tmp11_;
+ const gchar* _tmp12_;
+ gchar* _tmp13_;
+ gchar* _tmp14_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp10_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp10_);
+ _tmp11_ = _error_;
+ _tmp12_ = _tmp11_->message;
+ _tmp13_ = g_strconcat ("Failed to force reindex to fix database: ", _tmp12_, NULL);
+ _tmp14_ = _tmp13_;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:67: %s", _tmp14_);
+ _g_free0 (_tmp14_);
+ _g_error_free0 (_error_);
+ }
+ __finally12:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ }
+ }
+}
+
+
+void rygel_media_export_media_cache_upgrader_ensure_indices (RygelMediaExportMediaCacheUpgrader* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportSQLFactory* _tmp1_;
+ const gchar* _tmp2_ = NULL;
+ RygelMediaExportDatabase* _tmp3_;
+ _tmp0_ = self->priv->database;
+ _tmp1_ = self->priv->sql;
+ _tmp2_ = rygel_media_export_sql_factory_make (_tmp1_, RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON);
+ rygel_media_export_database_exec (_tmp0_, _tmp2_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch13_g_error;
+ }
+ _tmp3_ = self->priv->database;
+ rygel_media_export_database_analyze (_tmp3_);
+ }
+ goto __finally13;
+ __catch13_g_error:
+ {
+ GError* _error_ = NULL;
+ GError* _tmp4_;
+ const gchar* _tmp5_;
+ gchar* _tmp6_;
+ gchar* _tmp7_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp4_ = _error_;
+ _tmp5_ = _tmp4_->message;
+ _tmp6_ = g_strconcat ("Failed to create indices: ", _tmp5_, NULL);
+ _tmp7_ = _tmp6_;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:78: %s", _tmp7_);
+ _g_free0 (_tmp7_);
+ _g_error_free0 (_error_);
+ }
+ __finally13:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+void rygel_media_export_media_cache_upgrader_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint old_version) {
+ gint _tmp0_ = 0;
+ gint current_version;
+ g_return_if_fail (self != NULL);
+ g_debug ("rygel-media-export-media-cache-upgrader.vala:84: Older schema detected" \
+". Upgrading...");
+ _tmp0_ = atoi (RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION);
+ current_version = _tmp0_;
+ while (TRUE) {
+ gint _tmp1_;
+ gint _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ _tmp1_ = old_version;
+ _tmp2_ = current_version;
+ if (!(_tmp1_ < _tmp2_)) {
+ break;
+ }
+ _tmp3_ = self->priv->database;
+ if (_tmp3_ != NULL) {
+ gint _tmp4_;
+ gint _tmp5_;
+ _tmp4_ = old_version;
+ switch (_tmp4_) {
+ case 3:
+ {
+ rygel_media_export_media_cache_upgrader_update_v3_v4 (self);
+ break;
+ }
+ case 4:
+ {
+ rygel_media_export_media_cache_upgrader_update_v4_v5 (self);
+ break;
+ }
+ case 5:
+ {
+ rygel_media_export_media_cache_upgrader_update_v5_v6 (self);
+ break;
+ }
+ case 6:
+ {
+ rygel_media_export_media_cache_upgrader_update_v6_v7 (self);
+ break;
+ }
+ case 7:
+ {
+ rygel_media_export_media_cache_upgrader_update_v7_v8 (self);
+ break;
+ }
+ case 8:
+ {
+ rygel_media_export_media_cache_upgrader_update_v8_v9 (self);
+ break;
+ }
+ case 9:
+ {
+ rygel_media_export_media_cache_upgrader_update_v9_v10 (self);
+ break;
+ }
+ case 10:
+ {
+ rygel_media_export_media_cache_upgrader_update_v10_v11 (self);
+ break;
+ }
+ default:
+ {
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:114: Cannot upgrade");
+ self->priv->database = NULL;
+ break;
+ }
+ }
+ _tmp5_ = old_version;
+ old_version = _tmp5_ + 1;
+ }
+ }
+}
+
+
+static void rygel_media_export_media_cache_upgrader_force_reindex (RygelMediaExportMediaCacheUpgrader* self, GError** error) {
+ RygelMediaExportDatabase* _tmp0_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp0_, "UPDATE Object SET timestamp = 0", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+}
+
+
+static void rygel_media_export_media_cache_upgrader_update_v3_v4 (RygelMediaExportMediaCacheUpgrader* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ RygelMediaExportSQLFactory* _tmp3_;
+ const gchar* _tmp4_ = NULL;
+ RygelMediaExportDatabase* _tmp5_;
+ RygelMediaExportDatabase* _tmp6_;
+ RygelMediaExportDatabase* _tmp7_;
+ RygelMediaExportDatabase* _tmp8_;
+ RygelMediaExportDatabase* _tmp9_;
+ RygelMediaExportSQLFactory* _tmp10_;
+ const gchar* _tmp11_ = NULL;
+ RygelMediaExportDatabase* _tmp12_;
+ RygelMediaExportDatabase* _tmp13_;
+ _tmp0_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp1_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp1_, "ALTER TABLE Meta_Data RENAME TO _Meta_Data", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp2_ = self->priv->database;
+ _tmp3_ = self->priv->sql;
+ _tmp4_ = rygel_media_export_sql_factory_make (_tmp3_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA);
+ rygel_media_export_database_exec (_tmp2_, _tmp4_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp5_, "INSERT INTO meta_data (size, mime_type, " "duration, width, height, class, author, album, " "date, bitrate, sample_freq, bits_per_sample, " "channels, track, color_depth, object_fk) SELECT " "size, mime_type, duration, width, height, class, " "author, album, date, bitrate, sample_freq, " "bits_per_sample, channels, track, color_depth, " "o.upnp_id FROM _Meta_Data JOIN object o " "ON id = o.metadata_fk", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp6_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp6_, "DROP TABLE _Meta_Data", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp7_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp7_, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_3, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp8_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp8_, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_UPDATE_V3_V4_STRING_4, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp9_ = self->priv->database;
+ _tmp10_ = self->priv->sql;
+ _tmp11_ = rygel_media_export_sql_factory_make (_tmp10_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON);
+ rygel_media_export_database_exec (_tmp9_, _tmp11_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp12_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp12_, "UPDATE schema_info SET version = '4'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp13_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp13_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch14_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ }
+ goto __finally14;
+ __catch14_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp14_;
+ GError* _tmp15_;
+ const gchar* _tmp16_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp14_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp14_);
+ _tmp15_ = _error_;
+ _tmp16_ = _tmp15_->message;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:149: Database upgrade fai" \
+"led: %s", _tmp16_);
+ self->priv->database = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally14:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void _vala_GValue_array_free (GValue* array, gint array_length) {
+ if (array != NULL) {
+ int i;
+ for (i = 0; i < array_length; i = i + 1) {
+ g_value_unset (&array[i]);
+ }
+ }
+ g_free (array);
+}
+
+
+static void rygel_media_export_media_cache_upgrader_update_v4_v5 (RygelMediaExportMediaCacheUpgrader* self) {
+ GeeLinkedList* _tmp0_;
+ GeeQueue* queue;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ queue = (GeeQueue*) _tmp0_;
+ {
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportSQLFactory* _tmp4_;
+ const gchar* _tmp5_ = NULL;
+ RygelMediaExportDatabase* _tmp6_;
+ RygelMediaExportDatabase* _tmp7_;
+ RygelMediaExportDatabase* _tmp8_;
+ RygelMediaExportDatabase* _tmp9_;
+ RygelMediaExportSQLFactory* _tmp10_;
+ const gchar* _tmp11_ = NULL;
+ RygelMediaExportDatabase* _tmp12_;
+ RygelMediaExportDatabase* _tmp13_;
+ GeeQueue* _tmp14_;
+ RygelMediaExportDatabase* _tmp36_;
+ RygelMediaExportDatabase* _tmp37_;
+ RygelMediaExportDatabase* _tmp38_;
+ RygelMediaExportSQLFactory* _tmp39_;
+ const gchar* _tmp40_ = NULL;
+ RygelMediaExportDatabase* _tmp41_;
+ RygelMediaExportSQLFactory* _tmp42_;
+ const gchar* _tmp43_ = NULL;
+ RygelMediaExportDatabase* _tmp44_;
+ RygelMediaExportDatabase* _tmp45_;
+ RygelMediaExportDatabase* _tmp46_;
+ RygelMediaExportDatabase* _tmp47_;
+ _tmp1_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp1_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp2_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp2_, "DROP TRIGGER IF EXISTS trgr_delete_children", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp3_ = self->priv->database;
+ _tmp4_ = self->priv->sql;
+ _tmp5_ = rygel_media_export_sql_factory_make (_tmp4_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE);
+ rygel_media_export_database_exec (_tmp3_, _tmp5_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp6_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp6_, "ALTER TABLE Object RENAME TO _Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp7_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp7_, "CREATE TABLE Object AS SELECT * FROM _Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp8_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp8_, "DELETE FROM Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp9_ = self->priv->database;
+ _tmp10_ = self->priv->sql;
+ _tmp11_ = rygel_media_export_sql_factory_make (_tmp10_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
+ rygel_media_export_database_exec (_tmp9_, _tmp11_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp12_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp12_, "INSERT INTO _Object (upnp_id, type_fk, title, " "timestamp) VALUES ('0', 0, 'Root', 0)", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp13_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp13_, "INSERT INTO Object (upnp_id, type_fk, title, " "timestamp) VALUES ('0', 0, 'Root', 0)", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp14_ = queue;
+ gee_queue_offer (_tmp14_, "0");
+ while (TRUE) {
+ GeeQueue* _tmp15_;
+ gboolean _tmp16_;
+ gboolean _tmp17_;
+ GeeQueue* _tmp18_;
+ gpointer _tmp19_ = NULL;
+ GValue _tmp20_ = {0};
+ GValue* _tmp21_ = NULL;
+ GValue* args;
+ gint args_length1;
+ gint _args_size_;
+ RygelMediaExportDatabase* _tmp22_;
+ GValue* _tmp23_;
+ gint _tmp23__length1;
+ RygelMediaExportDatabaseCursor* _tmp24_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ RygelMediaExportDatabase* _tmp34_;
+ GValue* _tmp35_;
+ gint _tmp35__length1;
+ _tmp15_ = queue;
+ _tmp16_ = gee_collection_get_is_empty ((GeeCollection*) _tmp15_);
+ _tmp17_ = _tmp16_;
+ if (!(!_tmp17_)) {
+ break;
+ }
+ _tmp18_ = queue;
+ _tmp19_ = gee_queue_poll (_tmp18_);
+ g_value_init (&_tmp20_, G_TYPE_STRING);
+ g_value_take_string (&_tmp20_, (gchar*) _tmp19_);
+ _tmp21_ = g_new0 (GValue, 1);
+ _tmp21_[0] = _tmp20_;
+ args = _tmp21_;
+ args_length1 = 1;
+ _args_size_ = args_length1;
+ _tmp22_ = self->priv->database;
+ _tmp23_ = args;
+ _tmp23__length1 = args_length1;
+ _tmp24_ = rygel_media_export_database_exec_cursor (_tmp22_, "SELECT upnp_id FROM _Object WHERE " "parent = ?", _tmp23_, _tmp23__length1, &_inner_error_);
+ cursor = _tmp24_;
+ if (_inner_error_ != NULL) {
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp25_;
+ RygelMediaExportDatabaseCursorIterator* _tmp26_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp25_ = cursor;
+ _tmp26_ = rygel_media_export_database_cursor_iterator (_tmp25_);
+ _statement_it = _tmp26_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp27_;
+ gboolean _tmp28_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp29_;
+ sqlite3_stmt* _tmp30_ = NULL;
+ sqlite3_stmt* statement;
+ GeeQueue* _tmp31_;
+ sqlite3_stmt* _tmp32_;
+ const gchar* _tmp33_ = NULL;
+ _tmp27_ = _statement_it;
+ _tmp28_ = rygel_media_export_database_cursor_iterator_next (_tmp27_);
+ if (!_tmp28_) {
+ break;
+ }
+ _tmp29_ = _statement_it;
+ _tmp30_ = rygel_media_export_database_cursor_iterator_get (_tmp29_, &_inner_error_);
+ statement = _tmp30_;
+ if (_inner_error_ != NULL) {
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp31_ = queue;
+ _tmp32_ = statement;
+ _tmp33_ = sqlite3_column_text (_tmp32_, 0);
+ gee_queue_offer (_tmp31_, _tmp33_);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ _tmp34_ = self->priv->database;
+ _tmp35_ = args;
+ _tmp35__length1 = args_length1;
+ rygel_media_export_database_exec (_tmp34_, "INSERT INTO Object SELECT * FROM _OBJECT " "WHERE parent = ?", _tmp35_, _tmp35__length1, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ }
+ _tmp36_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp36_, "DROP TABLE Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp37_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp37_, "ALTER TABLE _Object RENAME TO Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp38_ = self->priv->database;
+ _tmp39_ = self->priv->sql;
+ _tmp40_ = rygel_media_export_sql_factory_make (_tmp39_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
+ rygel_media_export_database_exec (_tmp38_, _tmp40_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp41_ = self->priv->database;
+ _tmp42_ = self->priv->sql;
+ _tmp43_ = rygel_media_export_sql_factory_make (_tmp42_, RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON);
+ rygel_media_export_database_exec (_tmp41_, _tmp43_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp44_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp44_, "UPDATE schema_info SET version = '5'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp45_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp45_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp46_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp46_, "VACUUM", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch15_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp47_ = self->priv->database;
+ rygel_media_export_database_analyze (_tmp47_);
+ }
+ goto __finally15;
+ __catch15_rygel_media_export_database_error:
+ {
+ GError* err = NULL;
+ RygelMediaExportDatabase* _tmp48_;
+ GError* _tmp49_;
+ const gchar* _tmp50_;
+ err = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp48_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp48_);
+ _tmp49_ = err;
+ _tmp50_ = _tmp49_->message;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:197: Database upgrade fai" \
+"led: %s", _tmp50_);
+ self->priv->database = NULL;
+ _g_error_free0 (err);
+ }
+ __finally15:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ 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;
+ }
+ _g_object_unref0 (queue);
+}
+
+
+static void rygel_media_export_media_cache_upgrader_update_v5_v6 (RygelMediaExportMediaCacheUpgrader* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportDatabase* _tmp5_;
+ RygelMediaExportDatabase* _tmp6_;
+ RygelMediaExportDatabase* _tmp7_;
+ RygelMediaExportDatabase* _tmp8_;
+ RygelMediaExportDatabase* _tmp9_;
+ RygelMediaExportDatabase* _tmp10_;
+ _tmp0_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp1_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp1_, "DROP TABLE object_type", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp2_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp2_, "DROP TRIGGER IF EXISTS trgr_delete_uris", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp3_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp3_, "ALTER TABLE Object ADD COLUMN uri TEXT", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp4_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp4_, "UPDATE Object SET uri = (SELECT uri " "FROM uri WHERE Uri.object_fk == Object.upnp_id LIMIT 1)", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp5_, "DROP INDEX IF EXISTS idx_uri_fk", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp6_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp6_, "DROP TABLE Uri", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp7_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp7_, "UPDATE schema_info SET version = '6'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp8_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp8_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp9_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp9_, "VACUUM", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch16_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp10_ = self->priv->database;
+ rygel_media_export_database_analyze (_tmp10_);
+ }
+ goto __finally16;
+ __catch16_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp11_;
+ GError* _tmp12_;
+ const gchar* _tmp13_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp11_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp11_);
+ _tmp12_ = _error_;
+ _tmp13_ = _tmp12_->message;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:218: Database upgrade fai" \
+"led: %s", _tmp13_);
+ self->priv->database = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally16:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_media_cache_upgrader_update_v6_v7 (RygelMediaExportMediaCacheUpgrader* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportDatabase* _tmp5_;
+ _tmp0_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch17_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp1_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp1_, "ALTER TABLE meta_data ADD COLUMN dlna_profile TEXT", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch17_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp2_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp2_, "UPDATE schema_info SET version = '7'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch17_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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_media_export_media_cache_upgrader_force_reindex (self, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch17_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp3_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp3_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch17_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp4_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp4_, "VACUUM", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch17_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = self->priv->database;
+ rygel_media_export_database_analyze (_tmp5_);
+ }
+ goto __finally17;
+ __catch17_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp6_;
+ GError* _tmp7_;
+ const gchar* _tmp8_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp6_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp6_);
+ _tmp7_ = _error_;
+ _tmp8_ = _tmp7_->message;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:234: Database upgrade fai" \
+"led: %s", _tmp8_);
+ self->priv->database = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally17:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_media_cache_upgrader_update_v7_v8 (RygelMediaExportMediaCacheUpgrader* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportDatabase* _tmp5_;
+ RygelMediaExportDatabase* _tmp6_;
+ _tmp0_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch18_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp1_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp1_, "ALTER TABLE object ADD COLUMN flags TEXT", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch18_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp2_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp2_, "ALTER TABLE meta_data ADD COLUMN genre TEXT", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch18_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp3_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp3_, "UPDATE schema_info SET version = '8'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch18_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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_media_export_media_cache_upgrader_force_reindex (self, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch18_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp4_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp4_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch18_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp5_, "VACUUM", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch18_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp6_ = self->priv->database;
+ rygel_media_export_database_analyze (_tmp6_);
+ }
+ goto __finally18;
+ __catch18_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp7_;
+ GError* _tmp8_;
+ const gchar* _tmp9_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp7_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp7_);
+ _tmp8_ = _error_;
+ _tmp9_ = _tmp8_->message;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:251: Database upgrade fai" \
+"led: %s", _tmp9_);
+ self->priv->database = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally18:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_media_cache_upgrader_update_v8_v9 (RygelMediaExportMediaCacheUpgrader* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportSQLFactory* _tmp5_;
+ const gchar* _tmp6_ = NULL;
+ RygelMediaExportDatabase* _tmp7_;
+ RygelMediaExportDatabase* _tmp8_;
+ RygelMediaExportSQLFactory* _tmp9_;
+ const gchar* _tmp10_ = NULL;
+ RygelMediaExportDatabase* _tmp11_;
+ RygelMediaExportDatabase* _tmp12_;
+ RygelMediaExportDatabase* _tmp13_;
+ RygelMediaExportDatabase* _tmp14_;
+ _tmp0_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp1_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp1_, "DROP TRIGGER trgr_update_closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp2_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp2_, "DROP TRIGGER trgr_delete_closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp3_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp3_, "ALTER TABLE Closure RENAME TO _Closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp4_ = self->priv->database;
+ _tmp5_ = self->priv->sql;
+ _tmp6_ = rygel_media_export_sql_factory_make (_tmp5_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE);
+ rygel_media_export_database_exec (_tmp4_, _tmp6_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp7_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp7_, "INSERT INTO Closure (ancestor, " "descendant, depth) SELECT DISTINCT " "ancestor, descendant, depth FROM " "_Closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp8_ = self->priv->database;
+ _tmp9_ = self->priv->sql;
+ _tmp10_ = rygel_media_export_sql_factory_make (_tmp9_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
+ rygel_media_export_database_exec (_tmp8_, _tmp10_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp11_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp11_, "DROP TABLE _Closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp12_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp12_, "UPDATE schema_info SET version = '9'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp13_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp13_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp14_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp14_, "VACUUM", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch19_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ }
+ goto __finally19;
+ __catch19_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp15_;
+ GError* _tmp16_;
+ const gchar* _tmp17_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp15_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp15_);
+ _tmp16_ = _error_;
+ _tmp17_ = _tmp16_->message;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:274: Database upgrade fai" \
+"led: %s", _tmp17_);
+ self->priv->database = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally19:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_media_cache_upgrader_update_v9_v10 (RygelMediaExportMediaCacheUpgrader* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ GeeLinkedList* _tmp0_;
+ GeeLinkedList* queue;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportDatabase* _tmp5_;
+ RygelMediaExportDatabase* _tmp6_;
+ RygelMediaExportDatabase* _tmp7_;
+ RygelMediaExportDatabase* _tmp8_;
+ RygelMediaExportDatabase* _tmp9_;
+ RygelMediaExportDatabase* _tmp10_;
+ const gchar* _tmp11_ = NULL;
+ gchar* _tmp12_;
+ gchar* _tmp13_;
+ gchar* _tmp14_;
+ gchar* _tmp15_;
+ RygelMediaExportDatabase* _tmp16_;
+ RygelMediaExportDatabase* _tmp17_;
+ RygelMediaExportDatabase* _tmp18_;
+ RygelMediaExportDatabase* _tmp19_;
+ RygelMediaExportDatabase* _tmp20_;
+ RygelMediaExportSQLFactory* _tmp21_;
+ const gchar* _tmp22_ = NULL;
+ RygelMediaExportDatabase* _tmp23_;
+ RygelMediaExportSQLFactory* _tmp24_;
+ const gchar* _tmp25_ = NULL;
+ RygelMediaExportDatabase* _tmp26_;
+ GeeLinkedList* _tmp27_;
+ RygelMediaExportDatabase* _tmp49_;
+ RygelMediaExportDatabase* _tmp50_;
+ RygelMediaExportDatabase* _tmp51_;
+ RygelMediaExportSQLFactory* _tmp52_;
+ const gchar* _tmp53_ = NULL;
+ RygelMediaExportDatabase* _tmp54_;
+ RygelMediaExportSQLFactory* _tmp55_;
+ const gchar* _tmp56_ = NULL;
+ RygelMediaExportDatabase* _tmp57_;
+ RygelMediaExportSQLFactory* _tmp58_;
+ const gchar* _tmp59_ = NULL;
+ RygelMediaExportDatabase* _tmp60_;
+ RygelMediaExportDatabase* _tmp61_;
+ RygelMediaExportDatabase* _tmp62_;
+ RygelMediaExportDatabase* _tmp63_;
+ _tmp0_ = gee_linked_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ queue = _tmp0_;
+ _tmp1_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp1_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp2_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp2_, "DELETE FROM Object WHERE upnp_id LIKE '" RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "%'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp3_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp3_, "DROP TRIGGER trgr_update_closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp4_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp4_, "DROP TRIGGER trgr_delete_closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp5_, "DROP INDEX idx_parent", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp6_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp6_, "DROP INDEX idx_meta_data_fk", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp7_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp7_, "DROP INDEX IF EXISTS idx_closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp8_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp8_, "DROP TABLE Closure", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp9_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp9_, "DROP TRIGGER trgr_delete_metadata", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp10_ = self->priv->database;
+ _tmp11_ = _ (RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_NAME);
+ _tmp12_ = g_strconcat ("INSERT OR REPLACE INTO Object (parent, upnp_id, " "type_fk, title, timestamp) VALUES " "('0', '" RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "', 0, '", _tmp11_, NULL);
+ _tmp13_ = _tmp12_;
+ _tmp14_ = g_strconcat (_tmp13_, "', 0)", NULL);
+ _tmp15_ = _tmp14_;
+ rygel_media_export_database_exec (_tmp10_, _tmp15_, NULL, 0, &_inner_error_);
+ _g_free0 (_tmp15_);
+ _g_free0 (_tmp13_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp16_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp16_, "UPDATE Object SET parent = '" RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "' WHERE parent = '0' AND upnp_id " "NOT LIKE 'virtual-%' AND upnp_id " "<> '" RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp17_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp17_, "ALTER TABLE Object RENAME TO _Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp18_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp18_, "CREATE TABLE Object AS SELECT * FROM _Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp19_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp19_, "DELETE FROM Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp20_ = self->priv->database;
+ _tmp21_ = self->priv->sql;
+ _tmp22_ = rygel_media_export_sql_factory_make (_tmp21_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE);
+ rygel_media_export_database_exec (_tmp20_, _tmp22_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp23_ = self->priv->database;
+ _tmp24_ = self->priv->sql;
+ _tmp25_ = rygel_media_export_sql_factory_make (_tmp24_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
+ rygel_media_export_database_exec (_tmp23_, _tmp25_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp26_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp26_, "INSERT INTO Closure (ancestor, descendant, " "depth) VALUES ('0','0',0)", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp27_ = queue;
+ gee_queue_offer ((GeeQueue*) _tmp27_, "0");
+ while (TRUE) {
+ GeeLinkedList* _tmp28_;
+ gboolean _tmp29_;
+ gboolean _tmp30_;
+ GeeLinkedList* _tmp31_;
+ gpointer _tmp32_ = NULL;
+ GValue _tmp33_ = {0};
+ GValue* _tmp34_ = NULL;
+ GValue* args;
+ gint args_length1;
+ gint _args_size_;
+ RygelMediaExportDatabase* _tmp35_;
+ GValue* _tmp36_;
+ gint _tmp36__length1;
+ RygelMediaExportDatabaseCursor* _tmp37_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ RygelMediaExportDatabase* _tmp47_;
+ GValue* _tmp48_;
+ gint _tmp48__length1;
+ _tmp28_ = queue;
+ _tmp29_ = gee_collection_get_is_empty ((GeeCollection*) _tmp28_);
+ _tmp30_ = _tmp29_;
+ if (!(!_tmp30_)) {
+ break;
+ }
+ _tmp31_ = queue;
+ _tmp32_ = gee_queue_poll ((GeeQueue*) _tmp31_);
+ g_value_init (&_tmp33_, G_TYPE_STRING);
+ g_value_take_string (&_tmp33_, (gchar*) _tmp32_);
+ _tmp34_ = g_new0 (GValue, 1);
+ _tmp34_[0] = _tmp33_;
+ args = _tmp34_;
+ args_length1 = 1;
+ _args_size_ = args_length1;
+ _tmp35_ = self->priv->database;
+ _tmp36_ = args;
+ _tmp36__length1 = args_length1;
+ _tmp37_ = rygel_media_export_database_exec_cursor (_tmp35_, "SELECT upnp_id FROM _Object WHERE " "parent = ?", _tmp36_, _tmp36__length1, &_inner_error_);
+ cursor = _tmp37_;
+ if (_inner_error_ != NULL) {
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp38_;
+ RygelMediaExportDatabaseCursorIterator* _tmp39_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp38_ = cursor;
+ _tmp39_ = rygel_media_export_database_cursor_iterator (_tmp38_);
+ _statement_it = _tmp39_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp40_;
+ gboolean _tmp41_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp42_;
+ sqlite3_stmt* _tmp43_ = NULL;
+ sqlite3_stmt* statement;
+ GeeLinkedList* _tmp44_;
+ sqlite3_stmt* _tmp45_;
+ const gchar* _tmp46_ = NULL;
+ _tmp40_ = _statement_it;
+ _tmp41_ = rygel_media_export_database_cursor_iterator_next (_tmp40_);
+ if (!_tmp41_) {
+ break;
+ }
+ _tmp42_ = _statement_it;
+ _tmp43_ = rygel_media_export_database_cursor_iterator_get (_tmp42_, &_inner_error_);
+ statement = _tmp43_;
+ if (_inner_error_ != NULL) {
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp44_ = queue;
+ _tmp45_ = statement;
+ _tmp46_ = sqlite3_column_text (_tmp45_, 0);
+ gee_queue_offer ((GeeQueue*) _tmp44_, _tmp46_);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ _tmp47_ = self->priv->database;
+ _tmp48_ = args;
+ _tmp48__length1 = args_length1;
+ rygel_media_export_database_exec (_tmp47_, "INSERT INTO Object SELECT * FROM _Object " "WHERE parent = ?", _tmp48_, _tmp48__length1, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ }
+ _tmp49_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp49_, "DROP TABLE Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp50_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp50_, "ALTER TABLE _Object RENAME TO Object", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp51_ = self->priv->database;
+ _tmp52_ = self->priv->sql;
+ _tmp53_ = rygel_media_export_sql_factory_make (_tmp52_, RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON);
+ rygel_media_export_database_exec (_tmp51_, _tmp53_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp54_ = self->priv->database;
+ _tmp55_ = self->priv->sql;
+ _tmp56_ = rygel_media_export_sql_factory_make (_tmp55_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON);
+ rygel_media_export_database_exec (_tmp54_, _tmp56_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp57_ = self->priv->database;
+ _tmp58_ = self->priv->sql;
+ _tmp59_ = rygel_media_export_sql_factory_make (_tmp58_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
+ rygel_media_export_database_exec (_tmp57_, _tmp59_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp60_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp60_, "UPDATE schema_info SET version = '10'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp61_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp61_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp62_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp62_, "VACUUM", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (queue);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch20_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (queue);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp63_ = self->priv->database;
+ rygel_media_export_database_analyze (_tmp63_);
+ _g_object_unref0 (queue);
+ }
+ goto __finally20;
+ __catch20_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp64_;
+ GError* _tmp65_;
+ const gchar* _tmp66_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp64_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp64_);
+ _tmp65_ = _error_;
+ _tmp66_ = _tmp65_->message;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:343: Database upgrade fai" \
+"led: %s", _tmp66_);
+ self->priv->database = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally20:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_media_cache_upgrader_update_v10_v11 (RygelMediaExportMediaCacheUpgrader* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportDatabase* _tmp5_;
+ RygelMediaExportDatabase* _tmp6_;
+ _tmp0_ = self->priv->database;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch21_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp1_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp1_, "ALTER TABLE Meta_Data " " ADD COLUMN disc INTEGER", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch21_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp2_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp2_, "UPDATE Object SET timestamp = 0 WHERE " " upnp_id IN (" "SELECT object_fk FROM Meta_Data WHERE " " class LIKE 'object.item.audioItem.%')", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch21_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp3_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp3_, "UPDATE schema_info SET version = '11'", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch21_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp4_ = self->priv->database;
+ rygel_media_export_database_commit (_tmp4_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch21_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = self->priv->database;
+ rygel_media_export_database_exec (_tmp5_, "VACUUM", NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch21_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp6_ = self->priv->database;
+ rygel_media_export_database_analyze (_tmp6_);
+ }
+ goto __finally21;
+ __catch21_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp7_;
+ GError* _tmp8_;
+ const gchar* _tmp9_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp7_ = self->priv->database;
+ rygel_media_export_database_rollback (_tmp7_);
+ _tmp8_ = _error_;
+ _tmp9_ = _tmp8_->message;
+ g_warning ("rygel-media-export-media-cache-upgrader.vala:364: Database upgrade fai" \
+"led: %s", _tmp9_);
+ self->priv->database = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally21:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void rygel_media_export_value_media_cache_upgrader_init (GValue* value) {
+ value->data[0].v_pointer = NULL;
+}
+
+
+static void rygel_media_export_value_media_cache_upgrader_free_value (GValue* value) {
+ if (value->data[0].v_pointer) {
+ rygel_media_export_media_cache_upgrader_unref (value->data[0].v_pointer);
+ }
+}
+
+
+static void rygel_media_export_value_media_cache_upgrader_copy_value (const GValue* src_value, GValue* dest_value) {
+ if (src_value->data[0].v_pointer) {
+ dest_value->data[0].v_pointer = rygel_media_export_media_cache_upgrader_ref (src_value->data[0].v_pointer);
+ } else {
+ dest_value->data[0].v_pointer = NULL;
+ }
+}
+
+GParamSpec* rygel_media_export_param_spec_media_cache_upgrader (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) {
+ RygelMediaExportParamSpecMediaCacheUpgrader* spec;
+ g_return_val_if_fail (g_type_is_a (object_type, RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER), NULL);
+ spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
+ G_PARAM_SPEC (spec)->value_type = object_type;
+ return G_PARAM_SPEC (spec);
+}
+
+
+gpointer rygel_media_export_value_get_media_cache_upgrader (const GValue* value) {
+ g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER), NULL);
+ return value->data[0].v_pointer;
+}
+
+
+void rygel_media_export_value_set_media_cache_upgrader (GValue* value, gpointer v_object) {
+ RygelMediaExportMediaCacheUpgrader* old;
+ g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER));
+ old = value->data[0].v_pointer;
+ if (v_object) {
+ g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER));
+ g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
+ value->data[0].v_pointer = v_object;
+ rygel_media_export_media_cache_upgrader_ref (value->data[0].v_pointer);
+ } else {
+ value->data[0].v_pointer = NULL;
+ }
+ if (old) {
+ rygel_media_export_media_cache_upgrader_unref (old);
+ }
+}
+
+
+void rygel_media_export_value_take_media_cache_upgrader (GValue* value, gpointer v_object) {
+ RygelMediaExportMediaCacheUpgrader* old;
+ g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER));
+ old = value->data[0].v_pointer;
+ if (v_object) {
+ g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER));
+ g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
+ value->data[0].v_pointer = v_object;
+ } else {
+ value->data[0].v_pointer = NULL;
+ }
+ if (old) {
+ rygel_media_export_media_cache_upgrader_unref (old);
+ }
+}
+
+
+static void rygel_media_export_media_cache_upgrader_class_init (RygelMediaExportMediaCacheUpgraderClass * klass) {
+ rygel_media_export_media_cache_upgrader_parent_class = g_type_class_peek_parent (klass);
+
+ g_type_class_add_private (klass, sizeof (RygelMediaExportMediaCacheUpgraderPrivate));
+}
+
+
+static void rygel_media_export_media_cache_upgrader_init (RygelMediaExportMediaCacheUpgrader * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_GET_PRIVATE (self);
+ self->ref_count = 1;
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-media-cache-upgrader.h b/src/media-export/rygel-media-export-media-cache-upgrader.h
new file mode 100644
index 0000000..ca7fb8f
--- /dev/null
+++ b/src/media-export/rygel-media-export-media-cache-upgrader.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_H__
+
+#include "rygel-media-export-database.h"
+#include "rygel-media-export-sql-factory.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER (rygel_media_export_media_cache_upgrader_get_type ())
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgrader))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgraderClass))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgraderClass))
+
+typedef struct _RygelMediaExportMediaCacheUpgrader RygelMediaExportMediaCacheUpgrader;
+typedef struct _RygelMediaExportMediaCacheUpgraderClass RygelMediaExportMediaCacheUpgraderClass;
+typedef struct _RygelMediaExportMediaCacheUpgraderPrivate RygelMediaExportMediaCacheUpgraderPrivate;
+
+struct _RygelMediaExportMediaCacheUpgrader {
+ GObject parent_instance;
+ volatile int ref_count;
+ RygelMediaExportMediaCacheUpgraderPrivate * priv;
+};
+
+struct _RygelMediaExportMediaCacheUpgraderClass {
+ GObjectClass parent_class;
+};
+GType rygel_media_export_media_cache_upgrader_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_new (RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_H__ */
diff --git a/src/media-export/rygel-media-export-media-cache.c b/src/media-export/rygel-media-export-media-cache.c
new file mode 100644
index 0000000..37289a6
--- /dev/null
+++ b/src/media-export/rygel-media-export-media-cache.c
@@ -0,0 +1,4477 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-media-cache.h"
+#include "rygel-media-export-database.h"
+#include <sqlite3.h>
+
+
+/**
+ * Persistent storage of media objects
+ *
+ * MediaExportDB is a sqlite3 backed persistent storage of media objects
+ */
+
+G_DEFINE_TYPE (RygelMediaExportMediaCache, rygel_media_export_media_cache, G_TYPE_OBJECT)
+
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_OBJECT_TYPE (rygel_media_export_object_type_get_type ())
+
+#define RYGEL_MEDIA_EXPORT_TYPE_EXISTS_CACHE_ENTRY (rygel_media_export_exists_cache_entry_get_type ())
+typedef struct _RygelMediaExportExistsCacheEntry RygelMediaExportExistsCacheEntry;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY (rygel_media_export_object_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactory))
+#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY))
+#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactoryClass))
+
+typedef struct _RygelMediaExportObjectFactory RygelMediaExportObjectFactory;
+typedef struct _RygelMediaExportObjectFactoryClass RygelMediaExportObjectFactoryClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY (rygel_media_export_sql_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactory))
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY))
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactoryClass))
+
+typedef struct _RygelMediaExportSQLFactory RygelMediaExportSQLFactory;
+typedef struct _RygelMediaExportSQLFactoryClass RygelMediaExportSQLFactoryClass;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_STRING (rygel_media_export_sql_string_get_type ())
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR (rygel_media_export_database_cursor_get_type ())
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursor))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorClass))
+#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR))
+#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorClass))
+
+typedef struct _RygelMediaExportDatabaseCursor RygelMediaExportDatabaseCursor;
+typedef struct _RygelMediaExportDatabaseCursorClass RygelMediaExportDatabaseCursorClass;
+
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR (rygel_media_export_database_cursor_iterator_get_type ())
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIterator))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIteratorClass))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR))
+#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIteratorClass))
+
+typedef struct _RygelMediaExportDatabaseCursorIterator RygelMediaExportDatabaseCursorIterator;
+typedef struct _RygelMediaExportDatabaseCursorIteratorClass RygelMediaExportDatabaseCursorIteratorClass;
+#define _rygel_media_export_database_cursor_iterator_unref0(var) ((var == NULL) ? NULL : (var = (rygel_media_export_database_cursor_iterator_unref (var), NULL)))
+#define _rygel_media_export_exists_cache_entry_free0(var) ((var == NULL) ? NULL : (var = (rygel_media_export_exists_cache_entry_free (var), NULL)))
+#define _g_value_array_free0(var) ((var == NULL) ? NULL : (var = (g_value_array_free (var), NULL)))
+#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DETAIL_COLUMN (rygel_media_export_detail_column_get_type ())
+
+#define RYGEL_TYPE_NULL_CONTAINER (rygel_null_container_get_type ())
+#define RYGEL_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainer))
+#define RYGEL_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainerClass))
+#define RYGEL_IS_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_NULL_CONTAINER))
+#define RYGEL_IS_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_NULL_CONTAINER))
+#define RYGEL_NULL_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainerClass))
+
+typedef struct _RygelNullContainer RygelNullContainer;
+typedef struct _RygelNullContainerClass RygelNullContainerClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER (rygel_media_export_media_cache_upgrader_get_type ())
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgrader))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgraderClass))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgraderClass))
+
+typedef struct _RygelMediaExportMediaCacheUpgrader RygelMediaExportMediaCacheUpgrader;
+typedef struct _RygelMediaExportMediaCacheUpgraderClass RygelMediaExportMediaCacheUpgraderClass;
+#define _rygel_media_export_media_cache_upgrader_unref0(var) ((var == NULL) ? NULL : (var = (rygel_media_export_media_cache_upgrader_unref (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM (rygel_media_export_music_item_get_type ())
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItem))
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItemClass))
+#define RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM))
+#define RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM))
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItemClass))
+
+typedef struct _RygelMediaExportMusicItem RygelMediaExportMusicItem;
+typedef struct _RygelMediaExportMusicItemClass RygelMediaExportMusicItemClass;
+typedef struct _RygelMediaExportMusicItemPrivate RygelMediaExportMusicItemPrivate;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM (rygel_media_export_video_item_get_type ())
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItem))
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItemClass))
+#define RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM))
+#define RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM))
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItemClass))
+
+typedef struct _RygelMediaExportVideoItem RygelMediaExportVideoItem;
+typedef struct _RygelMediaExportVideoItemClass RygelMediaExportVideoItemClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER (rygel_media_export_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+
+typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
+typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR (rygel_media_export_sql_operator_get_type ())
+#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperator))
+#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperatorClass))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_OPERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_OPERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR))
+#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperatorClass))
+
+typedef struct _RygelMediaExportSqlOperator RygelMediaExportSqlOperator;
+typedef struct _RygelMediaExportSqlOperatorClass RygelMediaExportSqlOperatorClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION (rygel_media_export_sql_function_get_type ())
+#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunction))
+#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunctionClass))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION))
+#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunctionClass))
+
+typedef struct _RygelMediaExportSqlFunction RygelMediaExportSqlFunction;
+typedef struct _RygelMediaExportSqlFunctionClass RygelMediaExportSqlFunctionClass;
+#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
+
+typedef enum {
+ RYGEL_MEDIA_EXPORT_OBJECT_TYPE_CONTAINER,
+ RYGEL_MEDIA_EXPORT_OBJECT_TYPE_ITEM
+} RygelMediaExportObjectType;
+
+struct _RygelMediaExportExistsCacheEntry {
+ gint64 mtime;
+ gint64 size;
+};
+
+
+struct _RygelMediaExportMediaCachePrivate {
+ RygelMediaExportDatabase* db;
+ RygelMediaExportObjectFactory* factory;
+ RygelMediaExportSQLFactory* sql;
+ GeeHashMap* exists_cache;
+};
+
+typedef enum {
+ RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS
+} RygelMediaExportSQLString;
+
+typedef enum {
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TYPE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TITLE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SIZE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_MIME_TYPE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_WIDTH,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_HEIGHT,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CLASS,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ALBUM,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DATE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITRATE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SAMPLE_FREQ,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITS_PER_SAMPLE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CHANNELS,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TRACK,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_COLOR_DEPTH,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DURATION,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_PARENT,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TIMESTAMP,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_URI,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DLNA_PROFILE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_GENRE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DISC
+} RygelMediaExportDetailColumn;
+
+struct _RygelMediaExportMusicItem {
+ RygelMusicItem parent_instance;
+ RygelMediaExportMusicItemPrivate * priv;
+ gint disc;
+};
+
+struct _RygelMediaExportMusicItemClass {
+ RygelMusicItemClass parent_class;
+};
+
+
+static RygelMediaExportMediaCache* rygel_media_export_media_cache_instance;
+static RygelMediaExportMediaCache* rygel_media_export_media_cache_instance = NULL;
+
+GQuark rygel_media_export_media_cache_error_quark (void);
+GType rygel_media_export_object_type_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_exists_cache_entry_get_type (void) G_GNUC_CONST;
+RygelMediaExportExistsCacheEntry* rygel_media_export_exists_cache_entry_dup (const RygelMediaExportExistsCacheEntry* self);
+void rygel_media_export_exists_cache_entry_free (RygelMediaExportExistsCacheEntry* self);
+GType rygel_media_export_sqlite_wrapper_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_database_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_object_factory_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_sql_factory_get_type (void) G_GNUC_CONST;
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCachePrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE_DUMMY_PROPERTY
+};
+
+static RygelMediaExportMediaCache* rygel_media_export_media_cache_construct (GType object_type, GError** error);
+RygelMediaExportSQLFactory* rygel_media_export_sql_factory_new (void);
+RygelMediaExportSQLFactory* rygel_media_export_sql_factory_construct (GType object_type);
+static void rygel_media_export_media_cache_open_db (RygelMediaExportMediaCache* self, const gchar* name, GError** error);
+RygelMediaExportObjectFactory* rygel_media_export_object_factory_new (void);
+RygelMediaExportObjectFactory* rygel_media_export_object_factory_construct (GType object_type);
+GQuark rygel_media_export_database_error_quark (void);
+static void rygel_media_export_media_cache_get_exists_cache (RygelMediaExportMediaCache* self, GError** error);
+gchar* rygel_media_export_media_cache_get_id (GFile* file);
+RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
+void rygel_media_export_media_cache_remove_by_id (RygelMediaExportMediaCache* self, const gchar* id, GError** error);
+void rygel_media_export_database_exec (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+GType rygel_media_export_sql_string_get_type (void) G_GNUC_CONST;
+const gchar* rygel_media_export_sql_factory_make (RygelMediaExportSQLFactory* self, RygelMediaExportSQLString query);
+static void _vala_GValue_array_free (GValue* array, gint array_length);
+void rygel_media_export_media_cache_remove_object (RygelMediaExportMediaCache* self, RygelMediaObject* object, GError** error);
+void rygel_media_export_media_cache_save_container (RygelMediaExportMediaCache* self, RygelMediaContainer* container, GError** error);
+void rygel_media_export_database_begin (RygelMediaExportDatabase* self, GError** error);
+static void rygel_media_export_media_cache_create_object (RygelMediaExportMediaCache* self, RygelMediaObject* item, GError** error);
+void rygel_media_export_database_commit (RygelMediaExportDatabase* self, GError** error);
+void rygel_media_export_database_rollback (RygelMediaExportDatabase* self);
+void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
+static void rygel_media_export_media_cache_save_metadata (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
+RygelMediaObject* rygel_media_export_media_cache_get_object (RygelMediaExportMediaCache* self, const gchar* object_id, GError** error);
+GType rygel_media_export_database_cursor_get_type (void) G_GNUC_CONST;
+static RygelMediaExportDatabaseCursor* rygel_media_export_media_cache_exec_cursor (RygelMediaExportMediaCache* self, RygelMediaExportSQLString id, GValue* values, int values_length1, GError** error);
+gpointer rygel_media_export_database_cursor_iterator_ref (gpointer instance);
+void rygel_media_export_database_cursor_iterator_unref (gpointer instance);
+GParamSpec* rygel_media_export_database_cursor_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
+void rygel_media_export_database_cursor_value_set_iterator (GValue* value, gpointer v_object);
+void rygel_media_export_database_cursor_value_take_iterator (GValue* value, gpointer v_object);
+gpointer rygel_media_export_database_cursor_value_get_iterator (const GValue* value);
+GType rygel_media_export_database_cursor_iterator_get_type (void) G_GNUC_CONST;
+RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator (RygelMediaExportDatabaseCursor* self);
+gboolean rygel_media_export_database_cursor_iterator_next (RygelMediaExportDatabaseCursorIterator* self);
+sqlite3_stmt* rygel_media_export_database_cursor_iterator_get (RygelMediaExportDatabaseCursorIterator* self, GError** error);
+static RygelMediaObject* rygel_media_export_media_cache_get_object_from_statement (RygelMediaExportMediaCache* self, RygelMediaContainer* parent, sqlite3_stmt* statement);
+RygelMediaContainer* rygel_media_export_media_cache_get_container (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
+gint rygel_media_export_media_cache_get_child_count (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
+static gint rygel_media_export_media_cache_query_value (RygelMediaExportMediaCache* self, RygelMediaExportSQLString id, GValue* values, int values_length1, GError** error);
+gboolean rygel_media_export_media_cache_exists (RygelMediaExportMediaCache* self, GFile* file, gint64* timestamp, gint64* size, GError** error);
+sqlite3_stmt* rygel_media_export_database_cursor_next (RygelMediaExportDatabaseCursor* self, GError** error);
+RygelMediaObjects* rygel_media_export_media_cache_get_children (RygelMediaExportMediaCache* self, RygelMediaContainer* container, const gchar* sort_criteria, glong offset, glong max_count, GError** error);
+static gchar* rygel_media_export_media_cache_translate_sort_criteria (RygelMediaExportMediaCache* self, const gchar* sort_criteria);
+RygelMediaExportDatabaseCursor* rygel_media_export_database_exec_cursor (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
+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);
+static gchar* rygel_media_export_media_cache_translate_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, GValueArray* args, const gchar* prefix, GError** error);
+static guint rygel_media_export_media_cache_modify_limit (RygelMediaExportMediaCache* self, guint max_count);
+glong rygel_media_export_media_cache_get_object_count_by_filter (RygelMediaExportMediaCache* self, const gchar* filter, GValueArray* args, const gchar* container_id, GError** error);
+RygelMediaObjects* rygel_media_export_media_cache_get_objects_by_filter (RygelMediaExportMediaCache* self, const gchar* filter, GValueArray* args, const gchar* container_id, const gchar* sort_criteria, glong offset, glong max_count, GError** error);
+glong rygel_media_export_media_cache_get_object_count_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, GError** error);
+static GValue* _g_value_dup (GValue* self);
+static void _vala_GValue_free (GValue* self);
+gint rygel_media_export_database_query_value (RygelMediaExportDatabase* self, const gchar* sql, GValue* args, int args_length1, GError** error);
+GType rygel_media_export_detail_column_get_type (void) G_GNUC_CONST;
+RygelNullContainer* rygel_null_container_new (void);
+RygelNullContainer* rygel_null_container_construct (GType object_type);
+GType rygel_null_container_get_type (void) G_GNUC_CONST;
+void rygel_media_export_media_cache_debug_statistics (RygelMediaExportMediaCache* self);
+GeeArrayList* rygel_media_export_media_cache_get_child_ids (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
+GeeList* rygel_media_export_media_cache_get_meta_data_column_by_filter (RygelMediaExportMediaCache* self, const gchar* column, const gchar* filter, GValueArray* args, glong offset, glong max_count, GError** error);
+GeeList* rygel_media_export_media_cache_get_object_attribute_by_search_expression (RygelMediaExportMediaCache* self, const gchar* attribute, RygelSearchExpression* expression, glong offset, guint max_count, GError** error);
+static gchar* rygel_media_export_media_cache_map_operand_to_column (RygelMediaExportMediaCache* self, const gchar* operand, gchar** collate, GError** error);
+void rygel_media_export_media_cache_flag_object (RygelMediaExportMediaCache* self, GFile* file, const gchar* flag, GError** error);
+GeeList* rygel_media_export_media_cache_get_flagged_uris (RygelMediaExportMediaCache* self, const gchar* flag, GError** error);
+RygelMediaExportDatabase* rygel_media_export_database_new (const gchar* name, GError** error);
+RygelMediaExportDatabase* rygel_media_export_database_construct (GType object_type, const gchar* name, GError** error);
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION "11"
+RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_new (RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql);
+RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_construct (GType object_type, RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql);
+gpointer rygel_media_export_media_cache_upgrader_ref (gpointer instance);
+void rygel_media_export_media_cache_upgrader_unref (gpointer instance);
+GParamSpec* rygel_media_export_param_spec_media_cache_upgrader (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
+void rygel_media_export_value_set_media_cache_upgrader (GValue* value, gpointer v_object);
+void rygel_media_export_value_take_media_cache_upgrader (GValue* value, gpointer v_object);
+gpointer rygel_media_export_value_get_media_cache_upgrader (const GValue* value);
+GType rygel_media_export_media_cache_upgrader_get_type (void) G_GNUC_CONST;
+gboolean rygel_media_export_media_cache_upgrader_needs_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint* current_version, GError** error);
+void rygel_media_export_media_cache_upgrader_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint old_version);
+void rygel_media_export_media_cache_upgrader_fix_schema (RygelMediaExportMediaCacheUpgrader* self, GError** error);
+void rygel_media_export_media_cache_upgrader_ensure_indices (RygelMediaExportMediaCacheUpgrader* self);
+static gboolean rygel_media_export_media_cache_create_schema (RygelMediaExportMediaCache* self);
+void rygel_media_export_database_null (GValue* result);
+GType rygel_media_export_music_item_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_video_item_get_type (void) G_GNUC_CONST;
+void rygel_media_export_database_analyze (RygelMediaExportDatabase* self);
+GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+RygelMediaExportDBContainer* rygel_media_export_object_factory_get_container (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title, guint child_count, const gchar* uri);
+RygelMediaItem* rygel_media_export_object_factory_get_item (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, RygelMediaContainer* parent, const gchar* id, const gchar* title, const gchar* upnp_class);
+static void rygel_media_export_media_cache_fill_item (RygelMediaExportMediaCache* self, sqlite3_stmt* statement, RygelMediaItem* item);
+static gchar* rygel_media_export_media_cache_search_expression_to_sql (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, GValueArray* args, GError** error);
+static gchar* rygel_media_export_media_cache_logical_expression_to_sql (RygelMediaExportMediaCache* self, RygelLogicalExpression* expression, GValueArray* args, GError** error);
+static gchar* rygel_media_export_media_cache_relational_expression_to_sql (RygelMediaExportMediaCache* self, RygelRelationalExpression* exp, GValueArray* args, GError** error);
+GType rygel_media_export_sql_operator_get_type (void) G_GNUC_CONST;
+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_construct_from_search_criteria_op (GType object_type, GUPnPSearchCriteriaOp op, const gchar* arg, const gchar* collate);
+RygelMediaExportSqlFunction* rygel_media_export_sql_function_new (const gchar* name, const gchar* arg);
+RygelMediaExportSqlFunction* rygel_media_export_sql_function_construct (GType object_type, const gchar* name, const gchar* arg);
+GType rygel_media_export_sql_function_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_construct (GType object_type, const gchar* name, const gchar* arg, const gchar* collate);
+gchar* rygel_media_export_sql_operator_to_string (RygelMediaExportSqlOperator* self);
+static void rygel_media_export_media_cache_finalize (GObject* obj);
+static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
+static gint _vala_array_length (gpointer array);
+
+
+GQuark rygel_media_export_media_cache_error_quark (void) {
+ return g_quark_from_static_string ("rygel_media_export_media_cache_error-quark");
+}
+
+
+GType rygel_media_export_object_type_get_type (void) {
+ static volatile gsize rygel_media_export_object_type_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_object_type_type_id__volatile)) {
+ static const GEnumValue values[] = {{RYGEL_MEDIA_EXPORT_OBJECT_TYPE_CONTAINER, "RYGEL_MEDIA_EXPORT_OBJECT_TYPE_CONTAINER", "container"}, {RYGEL_MEDIA_EXPORT_OBJECT_TYPE_ITEM, "RYGEL_MEDIA_EXPORT_OBJECT_TYPE_ITEM", "item"}, {0, NULL, NULL}};
+ GType rygel_media_export_object_type_type_id;
+ rygel_media_export_object_type_type_id = g_enum_register_static ("RygelMediaExportObjectType", values);
+ g_once_init_leave (&rygel_media_export_object_type_type_id__volatile, rygel_media_export_object_type_type_id);
+ }
+ return rygel_media_export_object_type_type_id__volatile;
+}
+
+
+RygelMediaExportExistsCacheEntry* rygel_media_export_exists_cache_entry_dup (const RygelMediaExportExistsCacheEntry* self) {
+ RygelMediaExportExistsCacheEntry* dup;
+ dup = g_new0 (RygelMediaExportExistsCacheEntry, 1);
+ memcpy (dup, self, sizeof (RygelMediaExportExistsCacheEntry));
+ return dup;
+}
+
+
+void rygel_media_export_exists_cache_entry_free (RygelMediaExportExistsCacheEntry* self) {
+ g_free (self);
+}
+
+
+GType rygel_media_export_exists_cache_entry_get_type (void) {
+ static volatile gsize rygel_media_export_exists_cache_entry_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_exists_cache_entry_type_id__volatile)) {
+ GType rygel_media_export_exists_cache_entry_type_id;
+ rygel_media_export_exists_cache_entry_type_id = g_boxed_type_register_static ("RygelMediaExportExistsCacheEntry", (GBoxedCopyFunc) rygel_media_export_exists_cache_entry_dup, (GBoxedFreeFunc) rygel_media_export_exists_cache_entry_free);
+ g_once_init_leave (&rygel_media_export_exists_cache_entry_type_id__volatile, rygel_media_export_exists_cache_entry_type_id);
+ }
+ return rygel_media_export_exists_cache_entry_type_id__volatile;
+}
+
+
+static RygelMediaExportMediaCache* rygel_media_export_media_cache_construct (GType object_type, GError** error) {
+ RygelMediaExportMediaCache * self = NULL;
+ RygelMediaExportSQLFactory* _tmp0_;
+ RygelMediaExportObjectFactory* _tmp1_;
+ GError * _inner_error_ = NULL;
+ self = (RygelMediaExportMediaCache*) g_object_new (object_type, NULL);
+ _tmp0_ = rygel_media_export_sql_factory_new ();
+ _g_object_unref0 (self->priv->sql);
+ self->priv->sql = _tmp0_;
+ rygel_media_export_media_cache_open_db (self, "media-export", &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ _tmp1_ = rygel_media_export_object_factory_new ();
+ _g_object_unref0 (self->priv->factory);
+ self->priv->factory = _tmp1_;
+ rygel_media_export_media_cache_get_exists_cache (self, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ return self;
+}
+
+
+RygelMediaExportMediaCache*
+rygel_media_export_media_cache_new (GError** error) {
+ return rygel_media_export_media_cache_construct (RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, error);
+}
+
+
+gchar* rygel_media_export_media_cache_get_id (GFile* file) {
+ gchar* result = NULL;
+ GFile* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* _tmp2_;
+ gchar* _tmp3_ = NULL;
+ gchar* _tmp4_;
+ g_return_val_if_fail (file != NULL, NULL);
+ _tmp0_ = file;
+ _tmp1_ = g_file_get_uri (_tmp0_);
+ _tmp2_ = _tmp1_;
+ _tmp3_ = g_compute_checksum_for_string (G_CHECKSUM_MD5, _tmp2_, (gsize) (-1));
+ _tmp4_ = _tmp3_;
+ _g_free0 (_tmp2_);
+ result = _tmp4_;
+ return result;
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error) {
+ RygelMediaExportMediaCache* result = NULL;
+ RygelMediaExportMediaCache* _tmp0_;
+ RygelMediaExportMediaCache* _tmp3_;
+ RygelMediaExportMediaCache* _tmp4_;
+ GError * _inner_error_ = NULL;
+ _tmp0_ = rygel_media_export_media_cache_instance;
+ if (_tmp0_ == NULL) {
+ RygelMediaExportMediaCache* _tmp1_;
+ RygelMediaExportMediaCache* _tmp2_;
+ _tmp1_ = rygel_media_export_media_cache_new (&_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ }
+ _g_object_unref0 (rygel_media_export_media_cache_instance);
+ rygel_media_export_media_cache_instance = _tmp2_;
+ }
+ _tmp3_ = rygel_media_export_media_cache_instance;
+ _tmp4_ = _g_object_ref0 (_tmp3_);
+ result = _tmp4_;
+ return result;
+}
+
+
+static void _vala_GValue_array_free (GValue* array, gint array_length) {
+ if (array != NULL) {
+ int i;
+ for (i = 0; i < array_length; i = i + 1) {
+ g_value_unset (&array[i]);
+ }
+ }
+ g_free (array);
+}
+
+
+void rygel_media_export_media_cache_remove_by_id (RygelMediaExportMediaCache* self, const gchar* id, GError** error) {
+ const gchar* _tmp0_;
+ GValue _tmp1_ = {0};
+ GValue* _tmp2_ = NULL;
+ GValue* values;
+ gint values_length1;
+ gint _values_size_;
+ RygelMediaExportDatabase* _tmp3_;
+ RygelMediaExportSQLFactory* _tmp4_;
+ const gchar* _tmp5_ = NULL;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (id != NULL);
+ _tmp0_ = id;
+ g_value_init (&_tmp1_, G_TYPE_STRING);
+ g_value_set_string (&_tmp1_, _tmp0_);
+ _tmp2_ = g_new0 (GValue, 1);
+ _tmp2_[0] = _tmp1_;
+ values = _tmp2_;
+ values_length1 = 1;
+ _values_size_ = values_length1;
+ _tmp3_ = self->priv->db;
+ _tmp4_ = self->priv->sql;
+ _tmp5_ = rygel_media_export_sql_factory_make (_tmp4_, RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE);
+ rygel_media_export_database_exec (_tmp3_, _tmp5_, values, values_length1, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return;
+ } else {
+ values = (_vala_GValue_array_free (values, values_length1), 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;
+ }
+ }
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+}
+
+
+void rygel_media_export_media_cache_remove_object (RygelMediaExportMediaCache* self, RygelMediaObject* object, GError** error) {
+ RygelMediaObject* _tmp0_;
+ const gchar* _tmp1_;
+ const gchar* _tmp2_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (object != NULL);
+ _tmp0_ = object;
+ _tmp1_ = rygel_media_object_get_id (_tmp0_);
+ _tmp2_ = _tmp1_;
+ rygel_media_export_media_cache_remove_by_id (self, _tmp2_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if ((_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) || (_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR)) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+}
+
+
+static gpointer _g_error_copy0 (gpointer self) {
+ return self ? g_error_copy (self) : NULL;
+}
+
+
+void rygel_media_export_media_cache_save_container (RygelMediaExportMediaCache* self, RygelMediaContainer* container, GError** error) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (container != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaContainer* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ _tmp0_ = self->priv->db;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch5_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp1_ = container;
+ rygel_media_export_media_cache_create_object (self, (RygelMediaObject*) _tmp1_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch5_rygel_media_export_database_error;
+ }
+ goto __finally5;
+ }
+ _tmp2_ = self->priv->db;
+ rygel_media_export_database_commit (_tmp2_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch5_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ }
+ goto __finally5;
+ __catch5_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ RygelMediaExportDatabase* _tmp3_;
+ GError* _tmp4_;
+ GError* _tmp5_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp3_ = self->priv->db;
+ rygel_media_export_database_rollback (_tmp3_);
+ _tmp4_ = _error_;
+ _tmp5_ = _g_error_copy0 (_tmp4_);
+ _inner_error_ = _tmp5_;
+ _g_error_free0 (_error_);
+ goto __finally5;
+ }
+ __finally5:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ }
+}
+
+
+void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (item != NULL);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaItem* _tmp1_;
+ RygelMediaItem* _tmp2_;
+ RygelMediaExportDatabase* _tmp3_;
+ _tmp0_ = self->priv->db;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch6_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp1_ = item;
+ rygel_media_export_media_cache_save_metadata (self, _tmp1_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch6_rygel_media_export_database_error;
+ }
+ goto __finally6;
+ }
+ _tmp2_ = item;
+ rygel_media_export_media_cache_create_object (self, (RygelMediaObject*) _tmp2_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch6_rygel_media_export_database_error;
+ }
+ goto __finally6;
+ }
+ _tmp3_ = self->priv->db;
+ rygel_media_export_database_commit (_tmp3_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch6_rygel_media_export_database_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ }
+ goto __finally6;
+ __catch6_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp4_ = NULL;
+ RygelMediaItem* _tmp5_;
+ const gchar* _tmp6_;
+ const gchar* _tmp7_;
+ GError* _tmp8_;
+ const gchar* _tmp9_;
+ RygelMediaExportDatabase* _tmp10_;
+ GError* _tmp11_;
+ GError* _tmp12_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp4_ = _ ("Failed to add item with ID %s: %s");
+ _tmp5_ = item;
+ _tmp6_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp5_);
+ _tmp7_ = _tmp6_;
+ _tmp8_ = _error_;
+ _tmp9_ = _tmp8_->message;
+ g_warning (_tmp4_, _tmp7_, _tmp9_);
+ _tmp10_ = self->priv->db;
+ rygel_media_export_database_rollback (_tmp10_);
+ _tmp11_ = _error_;
+ _tmp12_ = _g_error_copy0 (_tmp11_);
+ _inner_error_ = _tmp12_;
+ _g_error_free0 (_error_);
+ goto __finally6;
+ }
+ __finally6:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ }
+}
+
+
+RygelMediaObject* rygel_media_export_media_cache_get_object (RygelMediaExportMediaCache* self, const gchar* object_id, GError** error) {
+ RygelMediaObject* result = NULL;
+ const gchar* _tmp0_;
+ GValue _tmp1_ = {0};
+ GValue* _tmp2_ = NULL;
+ GValue* values;
+ gint values_length1;
+ gint _values_size_;
+ RygelMediaObject* parent;
+ GValue* _tmp3_;
+ gint _tmp3__length1;
+ RygelMediaExportDatabaseCursor* _tmp4_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (object_id != NULL, NULL);
+ _tmp0_ = object_id;
+ g_value_init (&_tmp1_, G_TYPE_STRING);
+ g_value_set_string (&_tmp1_, _tmp0_);
+ _tmp2_ = g_new0 (GValue, 1);
+ _tmp2_[0] = _tmp1_;
+ values = _tmp2_;
+ values_length1 = 1;
+ _values_size_ = values_length1;
+ parent = NULL;
+ _tmp3_ = values;
+ _tmp3__length1 = values_length1;
+ _tmp4_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT, _tmp3_, _tmp3__length1, &_inner_error_);
+ cursor = _tmp4_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (parent);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return NULL;
+ } else {
+ _g_object_unref0 (parent);
+ values = (_vala_GValue_array_free (values, values_length1), 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 NULL;
+ }
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp5_;
+ RygelMediaExportDatabaseCursorIterator* _tmp6_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp5_ = cursor;
+ _tmp6_ = rygel_media_export_database_cursor_iterator (_tmp5_);
+ _statement_it = _tmp6_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp7_;
+ gboolean _tmp8_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp9_;
+ sqlite3_stmt* _tmp10_ = NULL;
+ sqlite3_stmt* statement;
+ RygelMediaObject* _tmp11_;
+ RygelMediaContainer* _tmp12_;
+ RygelMediaContainer* parent_container;
+ RygelMediaContainer* _tmp13_;
+ sqlite3_stmt* _tmp14_;
+ RygelMediaObject* _tmp15_ = NULL;
+ RygelMediaObject* object;
+ RygelMediaObject* _tmp16_;
+ RygelMediaContainer* _tmp17_;
+ RygelMediaObject* _tmp18_;
+ RygelMediaObject* _tmp19_;
+ _tmp7_ = _statement_it;
+ _tmp8_ = rygel_media_export_database_cursor_iterator_next (_tmp7_);
+ if (!_tmp8_) {
+ break;
+ }
+ _tmp9_ = _statement_it;
+ _tmp10_ = rygel_media_export_database_cursor_iterator_get (_tmp9_, &_inner_error_);
+ statement = _tmp10_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ _g_object_unref0 (parent);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return NULL;
+ } else {
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ _g_object_unref0 (parent);
+ values = (_vala_GValue_array_free (values, values_length1), 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 NULL;
+ }
+ }
+ _tmp11_ = parent;
+ _tmp12_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp11_) : NULL);
+ parent_container = _tmp12_;
+ _tmp13_ = parent_container;
+ _tmp14_ = statement;
+ _tmp15_ = rygel_media_export_media_cache_get_object_from_statement (self, _tmp13_, _tmp14_);
+ object = _tmp15_;
+ _tmp16_ = object;
+ _tmp17_ = parent_container;
+ rygel_media_object_set_parent_ref (_tmp16_, _tmp17_);
+ _tmp18_ = object;
+ _tmp19_ = _g_object_ref0 (_tmp18_);
+ _g_object_unref0 (parent);
+ parent = _tmp19_;
+ _g_object_unref0 (object);
+ _g_object_unref0 (parent_container);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ result = parent;
+ _g_object_unref0 (cursor);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return result;
+}
+
+
+RygelMediaContainer* rygel_media_export_media_cache_get_container (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error) {
+ RygelMediaContainer* result = NULL;
+ const gchar* _tmp0_;
+ RygelMediaObject* _tmp1_ = NULL;
+ RygelMediaObject* object;
+ gboolean _tmp2_ = FALSE;
+ RygelMediaObject* _tmp3_;
+ gboolean _tmp5_;
+ RygelMediaObject* _tmp8_;
+ RygelMediaContainer* _tmp9_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (container_id != NULL, NULL);
+ _tmp0_ = container_id;
+ _tmp1_ = rygel_media_export_media_cache_get_object (self, _tmp0_, &_inner_error_);
+ object = _tmp1_;
+ if (_inner_error_ != NULL) {
+ if ((_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) || (_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR)) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ } else {
+ 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;
+ }
+ }
+ _tmp3_ = object;
+ if (_tmp3_ != NULL) {
+ RygelMediaObject* _tmp4_;
+ _tmp4_ = object;
+ _tmp2_ = !G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, RYGEL_TYPE_MEDIA_CONTAINER);
+ } else {
+ _tmp2_ = FALSE;
+ }
+ _tmp5_ = _tmp2_;
+ if (_tmp5_) {
+ const gchar* _tmp6_;
+ GError* _tmp7_;
+ _tmp6_ = container_id;
+ _tmp7_ = g_error_new (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_INVALID_TYPE, "Object with id %s is " "not a MediaContainer", _tmp6_);
+ _inner_error_ = _tmp7_;
+ if ((_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) || (_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR)) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (object);
+ return NULL;
+ } else {
+ _g_object_unref0 (object);
+ 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_ = object;
+ _tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp8_) : NULL);
+ result = _tmp9_;
+ _g_object_unref0 (object);
+ return result;
+}
+
+
+gint rygel_media_export_media_cache_get_child_count (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error) {
+ gint result = 0;
+ const gchar* _tmp0_;
+ GValue _tmp1_ = {0};
+ GValue* _tmp2_ = NULL;
+ GValue* values;
+ gint values_length1;
+ gint _values_size_;
+ gint _tmp3_ = 0;
+ gint _tmp4_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, 0);
+ g_return_val_if_fail (container_id != NULL, 0);
+ _tmp0_ = container_id;
+ g_value_init (&_tmp1_, G_TYPE_STRING);
+ g_value_set_string (&_tmp1_, _tmp0_);
+ _tmp2_ = g_new0 (GValue, 1);
+ _tmp2_[0] = _tmp1_;
+ values = _tmp2_;
+ values_length1 = 1;
+ _values_size_ = values_length1;
+ _tmp3_ = rygel_media_export_media_cache_query_value (self, RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT, values, values_length1, &_inner_error_);
+ _tmp4_ = _tmp3_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return 0;
+ } else {
+ values = (_vala_GValue_array_free (values, values_length1), 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 0;
+ }
+ }
+ result = _tmp4_;
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return result;
+}
+
+
+gboolean rygel_media_export_media_cache_exists (RygelMediaExportMediaCache* self, GFile* file, gint64* timestamp, gint64* size, GError** error) {
+ gint64 _vala_timestamp = 0LL;
+ gint64 _vala_size = 0LL;
+ gboolean result = FALSE;
+ GFile* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* uri;
+ const gchar* _tmp2_;
+ GValue _tmp3_ = {0};
+ GValue* _tmp4_ = NULL;
+ GValue* values;
+ gint values_length1;
+ gint _values_size_;
+ GeeHashMap* _tmp5_;
+ const gchar* _tmp6_;
+ gboolean _tmp7_ = FALSE;
+ GValue* _tmp17_;
+ gint _tmp17__length1;
+ RygelMediaExportDatabaseCursor* _tmp18_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ RygelMediaExportDatabaseCursor* _tmp19_;
+ sqlite3_stmt* _tmp20_ = NULL;
+ sqlite3_stmt* statement;
+ sqlite3_stmt* _tmp21_;
+ gint64 _tmp22_ = 0LL;
+ sqlite3_stmt* _tmp23_;
+ gint64 _tmp24_ = 0LL;
+ sqlite3_stmt* _tmp25_;
+ gint _tmp26_ = 0;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+ _tmp0_ = file;
+ _tmp1_ = g_file_get_uri (_tmp0_);
+ uri = _tmp1_;
+ _tmp2_ = uri;
+ g_value_init (&_tmp3_, G_TYPE_STRING);
+ g_value_set_string (&_tmp3_, _tmp2_);
+ _tmp4_ = g_new0 (GValue, 1);
+ _tmp4_[0] = _tmp3_;
+ values = _tmp4_;
+ values_length1 = 1;
+ _values_size_ = values_length1;
+ _tmp5_ = self->priv->exists_cache;
+ _tmp6_ = uri;
+ _tmp7_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp5_, _tmp6_);
+ if (_tmp7_) {
+ GeeHashMap* _tmp8_;
+ const gchar* _tmp9_;
+ gpointer _tmp10_ = NULL;
+ RygelMediaExportExistsCacheEntry* entry;
+ GeeHashMap* _tmp11_;
+ const gchar* _tmp12_;
+ RygelMediaExportExistsCacheEntry* _tmp13_;
+ gint64 _tmp14_;
+ RygelMediaExportExistsCacheEntry* _tmp15_;
+ gint64 _tmp16_;
+ _tmp8_ = self->priv->exists_cache;
+ _tmp9_ = uri;
+ _tmp10_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp8_, _tmp9_);
+ entry = (RygelMediaExportExistsCacheEntry*) _tmp10_;
+ _tmp11_ = self->priv->exists_cache;
+ _tmp12_ = uri;
+ gee_abstract_map_unset ((GeeAbstractMap*) _tmp11_, _tmp12_, NULL);
+ _tmp13_ = entry;
+ _tmp14_ = (*_tmp13_).mtime;
+ _vala_timestamp = _tmp14_;
+ _tmp15_ = entry;
+ _tmp16_ = (*_tmp15_).size;
+ _vala_size = _tmp16_;
+ result = TRUE;
+ _rygel_media_export_exists_cache_entry_free0 (entry);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_free0 (uri);
+ if (timestamp) {
+ *timestamp = _vala_timestamp;
+ }
+ if (size) {
+ *size = _vala_size;
+ }
+ return result;
+ }
+ _tmp17_ = values;
+ _tmp17__length1 = values_length1;
+ _tmp18_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS, _tmp17_, _tmp17__length1, &_inner_error_);
+ cursor = _tmp18_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_free0 (uri);
+ return FALSE;
+ } else {
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_free0 (uri);
+ 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 FALSE;
+ }
+ }
+ _tmp19_ = cursor;
+ _tmp20_ = rygel_media_export_database_cursor_next (_tmp19_, &_inner_error_);
+ statement = _tmp20_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (cursor);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_free0 (uri);
+ return FALSE;
+ } else {
+ _g_object_unref0 (cursor);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_free0 (uri);
+ 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 FALSE;
+ }
+ }
+ _tmp21_ = statement;
+ _tmp22_ = sqlite3_column_int64 (_tmp21_, 1);
+ _vala_timestamp = _tmp22_;
+ _tmp23_ = statement;
+ _tmp24_ = sqlite3_column_int64 (_tmp23_, 2);
+ _vala_size = _tmp24_;
+ _tmp25_ = statement;
+ _tmp26_ = sqlite3_column_int (_tmp25_, 0);
+ result = _tmp26_ == 1;
+ _g_object_unref0 (cursor);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_free0 (uri);
+ if (timestamp) {
+ *timestamp = _vala_timestamp;
+ }
+ if (size) {
+ *size = _vala_size;
+ }
+ return result;
+}
+
+
+RygelMediaObjects* rygel_media_export_media_cache_get_children (RygelMediaExportMediaCache* self, RygelMediaContainer* container, const gchar* sort_criteria, glong offset, glong max_count, GError** error) {
+ RygelMediaObjects* result = NULL;
+ RygelMediaObjects* _tmp0_;
+ RygelMediaObjects* children;
+ RygelMediaContainer* _tmp1_;
+ const gchar* _tmp2_;
+ const gchar* _tmp3_;
+ GValue _tmp4_ = {0};
+ glong _tmp5_;
+ GValue _tmp6_ = {0};
+ glong _tmp7_;
+ GValue _tmp8_ = {0};
+ GValue* _tmp9_ = NULL;
+ GValue* values;
+ gint values_length1;
+ gint _values_size_;
+ RygelMediaExportSQLFactory* _tmp10_;
+ const gchar* _tmp11_ = NULL;
+ gchar* _tmp12_;
+ gchar* sql;
+ const gchar* _tmp13_;
+ gchar* _tmp14_ = NULL;
+ gchar* sort_order;
+ RygelMediaExportDatabase* _tmp15_;
+ const gchar* _tmp16_;
+ const gchar* _tmp17_;
+ gchar* _tmp18_ = NULL;
+ gchar* _tmp19_;
+ GValue* _tmp20_;
+ gint _tmp20__length1;
+ RygelMediaExportDatabaseCursor* _tmp21_ = NULL;
+ RygelMediaExportDatabaseCursor* _tmp22_;
+ RygelMediaExportDatabaseCursor* cursor;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (container != NULL, NULL);
+ g_return_val_if_fail (sort_criteria != NULL, NULL);
+ _tmp0_ = rygel_media_objects_new ();
+ children = _tmp0_;
+ _tmp1_ = container;
+ _tmp2_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp1_);
+ _tmp3_ = _tmp2_;
+ g_value_init (&_tmp4_, G_TYPE_STRING);
+ g_value_set_string (&_tmp4_, _tmp3_);
+ _tmp5_ = offset;
+ g_value_init (&_tmp6_, G_TYPE_LONG);
+ g_value_set_long (&_tmp6_, _tmp5_);
+ _tmp7_ = max_count;
+ g_value_init (&_tmp8_, G_TYPE_LONG);
+ g_value_set_long (&_tmp8_, _tmp7_);
+ _tmp9_ = g_new0 (GValue, 3);
+ _tmp9_[0] = _tmp4_;
+ _tmp9_[1] = _tmp6_;
+ _tmp9_[2] = _tmp8_;
+ values = _tmp9_;
+ values_length1 = 3;
+ _values_size_ = values_length1;
+ _tmp10_ = self->priv->sql;
+ _tmp11_ = rygel_media_export_sql_factory_make (_tmp10_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN);
+ _tmp12_ = g_strdup (_tmp11_);
+ sql = _tmp12_;
+ _tmp13_ = sort_criteria;
+ _tmp14_ = rygel_media_export_media_cache_translate_sort_criteria (self, _tmp13_);
+ sort_order = _tmp14_;
+ _tmp15_ = self->priv->db;
+ _tmp16_ = sql;
+ _tmp17_ = sort_order;
+ _tmp18_ = g_strdup_printf (_tmp16_, _tmp17_);
+ _tmp19_ = _tmp18_;
+ _tmp20_ = values;
+ _tmp20__length1 = values_length1;
+ _tmp21_ = rygel_media_export_database_exec_cursor (_tmp15_, _tmp19_, _tmp20_, _tmp20__length1, &_inner_error_);
+ _tmp22_ = _tmp21_;
+ _g_free0 (_tmp19_);
+ cursor = _tmp22_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (sort_order);
+ _g_free0 (sql);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_object_unref0 (children);
+ return NULL;
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp23_;
+ RygelMediaExportDatabaseCursorIterator* _tmp24_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp23_ = cursor;
+ _tmp24_ = rygel_media_export_database_cursor_iterator (_tmp23_);
+ _statement_it = _tmp24_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp25_;
+ gboolean _tmp26_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp27_;
+ sqlite3_stmt* _tmp28_ = NULL;
+ sqlite3_stmt* statement;
+ RygelMediaObjects* _tmp29_;
+ RygelMediaContainer* _tmp30_;
+ sqlite3_stmt* _tmp31_;
+ RygelMediaObject* _tmp32_ = NULL;
+ RygelMediaObject* _tmp33_;
+ RygelMediaObjects* _tmp34_;
+ gpointer _tmp35_ = NULL;
+ RygelMediaObject* _tmp36_;
+ RygelMediaContainer* _tmp37_;
+ _tmp25_ = _statement_it;
+ _tmp26_ = rygel_media_export_database_cursor_iterator_next (_tmp25_);
+ if (!_tmp26_) {
+ break;
+ }
+ _tmp27_ = _statement_it;
+ _tmp28_ = rygel_media_export_database_cursor_iterator_get (_tmp27_, &_inner_error_);
+ statement = _tmp28_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ _g_free0 (sort_order);
+ _g_free0 (sql);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_object_unref0 (children);
+ return NULL;
+ }
+ _tmp29_ = children;
+ _tmp30_ = container;
+ _tmp31_ = statement;
+ _tmp32_ = rygel_media_export_media_cache_get_object_from_statement (self, _tmp30_, _tmp31_);
+ _tmp33_ = _tmp32_;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp29_, _tmp33_);
+ _g_object_unref0 (_tmp33_);
+ _tmp34_ = children;
+ _tmp35_ = gee_list_last ((GeeList*) _tmp34_);
+ _tmp36_ = (RygelMediaObject*) _tmp35_;
+ _tmp37_ = container;
+ rygel_media_object_set_parent_ref (_tmp36_, _tmp37_);
+ _g_object_unref0 (_tmp36_);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ result = children;
+ _g_object_unref0 (cursor);
+ _g_free0 (sort_order);
+ _g_free0 (sql);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return result;
+}
+
+
+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) {
+ guint _vala_total_matches = 0U;
+ RygelMediaObjects* result = NULL;
+ GValueArray* _tmp0_;
+ GValueArray* args;
+ RygelSearchExpression* _tmp1_;
+ GValueArray* _tmp2_;
+ gchar* _tmp3_ = NULL;
+ gchar* filter;
+ RygelSearchExpression* _tmp4_;
+ guint _tmp9_;
+ guint _tmp10_ = 0U;
+ guint max_objects;
+ const gchar* _tmp11_;
+ GValueArray* _tmp12_;
+ const gchar* _tmp13_;
+ glong _tmp14_ = 0L;
+ glong _tmp15_;
+ const gchar* _tmp16_;
+ GValueArray* _tmp17_;
+ const gchar* _tmp18_;
+ const gchar* _tmp19_;
+ guint _tmp20_;
+ guint _tmp21_;
+ RygelMediaObjects* _tmp22_ = NULL;
+ RygelMediaObjects* _tmp23_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (sort_criteria != NULL, NULL);
+ _tmp0_ = g_value_array_new ((guint) 0);
+ args = _tmp0_;
+ _tmp1_ = expression;
+ _tmp2_ = args;
+ _tmp3_ = rygel_media_export_media_cache_translate_search_expression (self, _tmp1_, _tmp2_, "WHERE", &_inner_error_);
+ filter = _tmp3_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_value_array_free0 (args);
+ return NULL;
+ }
+ _tmp4_ = expression;
+ if (_tmp4_ != NULL) {
+ RygelSearchExpression* _tmp5_;
+ gchar* _tmp6_ = NULL;
+ gchar* _tmp7_;
+ const gchar* _tmp8_;
+ _tmp5_ = expression;
+ _tmp6_ = rygel_search_expression_to_string (_tmp5_);
+ _tmp7_ = _tmp6_;
+ g_debug ("rygel-media-export-media-cache.vala:218: Original search: %s", _tmp7_);
+ _g_free0 (_tmp7_);
+ _tmp8_ = filter;
+ g_debug ("rygel-media-export-media-cache.vala:219: Parsed search expression: %s", _tmp8_);
+ }
+ _tmp9_ = max_count;
+ _tmp10_ = rygel_media_export_media_cache_modify_limit (self, _tmp9_);
+ max_objects = _tmp10_;
+ _tmp11_ = filter;
+ _tmp12_ = args;
+ _tmp13_ = container_id;
+ _tmp14_ = rygel_media_export_media_cache_get_object_count_by_filter (self, _tmp11_, _tmp12_, _tmp13_, &_inner_error_);
+ _tmp15_ = _tmp14_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (filter);
+ _g_value_array_free0 (args);
+ return NULL;
+ }
+ _vala_total_matches = (guint) _tmp15_;
+ _tmp16_ = filter;
+ _tmp17_ = args;
+ _tmp18_ = container_id;
+ _tmp19_ = sort_criteria;
+ _tmp20_ = offset;
+ _tmp21_ = max_objects;
+ _tmp22_ = rygel_media_export_media_cache_get_objects_by_filter (self, _tmp16_, _tmp17_, _tmp18_, _tmp19_, (glong) _tmp20_, (glong) _tmp21_, &_inner_error_);
+ _tmp23_ = _tmp22_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (filter);
+ _g_value_array_free0 (args);
+ return NULL;
+ }
+ result = _tmp23_;
+ _g_free0 (filter);
+ _g_value_array_free0 (args);
+ if (total_matches) {
+ *total_matches = _vala_total_matches;
+ }
+ return result;
+}
+
+
+static GValue* _g_value_dup (GValue* self) {
+ return g_boxed_copy (G_TYPE_VALUE, self);
+}
+
+
+static gpointer __g_value_dup0 (gpointer self) {
+ return self ? _g_value_dup (self) : NULL;
+}
+
+
+static void _vala_GValue_free (GValue* self) {
+ g_value_unset (self);
+ g_free (self);
+}
+
+
+glong rygel_media_export_media_cache_get_object_count_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, GError** error) {
+ glong result = 0L;
+ GValueArray* _tmp0_;
+ GValueArray* args;
+ RygelSearchExpression* _tmp1_;
+ GValueArray* _tmp2_;
+ gchar* _tmp3_ = NULL;
+ gchar* filter;
+ RygelSearchExpression* _tmp4_;
+ const gchar* _tmp29_;
+ GValueArray* _tmp30_;
+ const gchar* _tmp31_;
+ glong _tmp32_ = 0L;
+ glong _tmp33_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, 0L);
+ _tmp0_ = g_value_array_new ((guint) 0);
+ args = _tmp0_;
+ _tmp1_ = expression;
+ _tmp2_ = args;
+ _tmp3_ = rygel_media_export_media_cache_translate_search_expression (self, _tmp1_, _tmp2_, "WHERE", &_inner_error_);
+ filter = _tmp3_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_value_array_free0 (args);
+ return 0L;
+ }
+ _tmp4_ = expression;
+ if (_tmp4_ != NULL) {
+ RygelSearchExpression* _tmp5_;
+ gchar* _tmp6_ = NULL;
+ gchar* _tmp7_;
+ const gchar* _tmp8_;
+ _tmp5_ = expression;
+ _tmp6_ = rygel_search_expression_to_string (_tmp5_);
+ _tmp7_ = _tmp6_;
+ g_debug ("rygel-media-export-media-cache.vala:243: Original search: %s", _tmp7_);
+ _g_free0 (_tmp7_);
+ _tmp8_ = filter;
+ g_debug ("rygel-media-export-media-cache.vala:244: Parsed search expression: %s", _tmp8_);
+ }
+ {
+ gint i;
+ i = 0;
+ {
+ gboolean _tmp9_;
+ _tmp9_ = TRUE;
+ while (TRUE) {
+ gboolean _tmp10_;
+ gint _tmp12_;
+ GValueArray* _tmp13_;
+ guint _tmp14_;
+ GValueArray* _tmp15_;
+ gint _tmp16_;
+ GValue* _tmp17_ = NULL;
+ GValue* _tmp18_;
+ GValue* arg;
+ gchar* _tmp19_ = NULL;
+ GValue* _tmp20_;
+ gboolean _tmp21_ = FALSE;
+ gint _tmp27_;
+ const gchar* _tmp28_;
+ _tmp10_ = _tmp9_;
+ if (!_tmp10_) {
+ gint _tmp11_;
+ _tmp11_ = i;
+ i = _tmp11_ + 1;
+ }
+ _tmp9_ = FALSE;
+ _tmp12_ = i;
+ _tmp13_ = args;
+ _tmp14_ = _tmp13_->n_values;
+ if (!(((guint) _tmp12_) < _tmp14_)) {
+ break;
+ }
+ _tmp15_ = args;
+ _tmp16_ = i;
+ _tmp17_ = g_value_array_get_nth (_tmp15_, (guint) _tmp16_);
+ _tmp18_ = __g_value_dup0 (_tmp17_);
+ arg = _tmp18_;
+ _tmp20_ = arg;
+ _tmp21_ = G_VALUE_HOLDS (_tmp20_, G_TYPE_STRING);
+ if (_tmp21_) {
+ GValue* _tmp22_;
+ const gchar* _tmp23_ = NULL;
+ gchar* _tmp24_;
+ _tmp22_ = arg;
+ _tmp23_ = g_value_get_string (_tmp22_);
+ _tmp24_ = g_strdup (_tmp23_);
+ _g_free0 (_tmp19_);
+ _tmp19_ = _tmp24_;
+ } else {
+ GValue* _tmp25_;
+ gchar* _tmp26_ = NULL;
+ _tmp25_ = arg;
+ _tmp26_ = g_strdup_value_contents (_tmp25_);
+ _g_free0 (_tmp19_);
+ _tmp19_ = _tmp26_;
+ }
+ _tmp27_ = i;
+ _tmp28_ = _tmp19_;
+ g_debug ("rygel-media-export-media-cache.vala:249: Arg %d: %s", _tmp27_, _tmp28_);
+ _g_free0 (_tmp19_);
+ __vala_GValue_free0 (arg);
+ }
+ }
+ }
+ _tmp29_ = filter;
+ _tmp30_ = args;
+ _tmp31_ = container_id;
+ _tmp32_ = rygel_media_export_media_cache_get_object_count_by_filter (self, _tmp29_, _tmp30_, _tmp31_, &_inner_error_);
+ _tmp33_ = _tmp32_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (filter);
+ _g_value_array_free0 (args);
+ return 0L;
+ }
+ result = _tmp33_;
+ _g_free0 (filter);
+ _g_value_array_free0 (args);
+ return result;
+}
+
+
+glong rygel_media_export_media_cache_get_object_count_by_filter (RygelMediaExportMediaCache* self, const gchar* filter, GValueArray* args, const gchar* container_id, GError** error) {
+ glong result = 0L;
+ const gchar* _tmp0_;
+ GValueArray* _tmp5_;
+ guint _tmp6_;
+ const gchar* pattern = NULL;
+ RygelMediaExportSQLString string_id = 0;
+ const gchar* _tmp7_;
+ RygelMediaExportSQLFactory* _tmp8_;
+ RygelMediaExportSQLString _tmp9_;
+ const gchar* _tmp10_ = NULL;
+ RygelMediaExportDatabase* _tmp11_;
+ const gchar* _tmp12_;
+ gchar* _tmp13_ = NULL;
+ gchar* _tmp14_;
+ GValueArray* _tmp15_;
+ GValue* _tmp16_;
+ gint _tmp16__length1;
+ gint _tmp17_ = 0;
+ gint _tmp18_;
+ gint _tmp19_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, 0L);
+ g_return_val_if_fail (filter != NULL, 0L);
+ g_return_val_if_fail (args != NULL, 0L);
+ _tmp0_ = container_id;
+ if (_tmp0_ != NULL) {
+ const gchar* _tmp1_;
+ GValue _tmp2_ = {0};
+ GValue v;
+ GValueArray* _tmp3_;
+ GValue _tmp4_;
+ _tmp1_ = container_id;
+ g_value_init (&_tmp2_, G_TYPE_STRING);
+ g_value_set_string (&_tmp2_, _tmp1_);
+ v = _tmp2_;
+ _tmp3_ = args;
+ _tmp4_ = v;
+ g_value_array_prepend (_tmp3_, &_tmp4_);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ }
+ _tmp5_ = args;
+ _tmp6_ = _tmp5_->n_values;
+ g_debug ("rygel-media-export-media-cache.vala:269: Parameters to bind: %u", _tmp6_);
+ _tmp7_ = container_id;
+ if (_tmp7_ != NULL) {
+ string_id = RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR;
+ } else {
+ string_id = RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER;
+ }
+ _tmp8_ = self->priv->sql;
+ _tmp9_ = string_id;
+ _tmp10_ = rygel_media_export_sql_factory_make (_tmp8_, _tmp9_);
+ pattern = _tmp10_;
+ _tmp11_ = self->priv->db;
+ _tmp12_ = filter;
+ _tmp13_ = g_strdup_printf (pattern, _tmp12_);
+ _tmp14_ = _tmp13_;
+ _tmp15_ = args;
+ _tmp16_ = _tmp15_->values;
+ _tmp16__length1 = (gint) _tmp15_->n_values;
+ _tmp17_ = rygel_media_export_database_query_value (_tmp11_, _tmp14_, _tmp16_, _tmp16__length1, &_inner_error_);
+ _tmp18_ = _tmp17_;
+ _g_free0 (_tmp14_);
+ _tmp19_ = _tmp18_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return 0L;
+ }
+ result = (glong) _tmp19_;
+ return result;
+}
+
+
+RygelMediaObjects* rygel_media_export_media_cache_get_objects_by_filter (RygelMediaExportMediaCache* self, const gchar* filter, GValueArray* args, const gchar* container_id, const gchar* sort_criteria, glong offset, glong max_count, GError** error) {
+ RygelMediaObjects* result = NULL;
+ RygelMediaObjects* _tmp0_;
+ RygelMediaObjects* children;
+ glong _tmp1_;
+ GValue _tmp2_ = {0};
+ GValue v;
+ GValueArray* _tmp3_;
+ GValue _tmp4_;
+ glong _tmp5_;
+ GValue _tmp6_ = {0};
+ GValueArray* _tmp7_;
+ GValue _tmp8_;
+ RygelMediaContainer* parent;
+ GValueArray* _tmp9_;
+ guint _tmp10_;
+ const gchar* sql = NULL;
+ const gchar* _tmp31_;
+ const gchar* _tmp36_;
+ gchar* _tmp37_ = NULL;
+ gchar* sort_order;
+ RygelMediaExportDatabase* _tmp38_;
+ const gchar* _tmp39_;
+ const gchar* _tmp40_;
+ const gchar* _tmp41_;
+ gchar* _tmp42_ = NULL;
+ gchar* _tmp43_;
+ GValueArray* _tmp44_;
+ GValue* _tmp45_;
+ gint _tmp45__length1;
+ RygelMediaExportDatabaseCursor* _tmp46_ = NULL;
+ RygelMediaExportDatabaseCursor* _tmp47_;
+ RygelMediaExportDatabaseCursor* cursor;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (filter != NULL, NULL);
+ g_return_val_if_fail (args != NULL, NULL);
+ g_return_val_if_fail (sort_criteria != NULL, NULL);
+ _tmp0_ = rygel_media_objects_new ();
+ children = _tmp0_;
+ _tmp1_ = offset;
+ g_value_init (&_tmp2_, G_TYPE_LONG);
+ g_value_set_long (&_tmp2_, _tmp1_);
+ v = _tmp2_;
+ _tmp3_ = args;
+ _tmp4_ = v;
+ g_value_array_append (_tmp3_, &_tmp4_);
+ _tmp5_ = max_count;
+ g_value_init (&_tmp6_, G_TYPE_LONG);
+ g_value_set_long (&_tmp6_, _tmp5_);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ v = _tmp6_;
+ _tmp7_ = args;
+ _tmp8_ = v;
+ g_value_array_append (_tmp7_, &_tmp8_);
+ parent = NULL;
+ _tmp9_ = args;
+ _tmp10_ = _tmp9_->n_values;
+ g_debug ("rygel-media-export-media-cache.vala:296: Parameters to bind: %u", _tmp10_);
+ {
+ gint i;
+ i = 0;
+ {
+ gboolean _tmp11_;
+ _tmp11_ = TRUE;
+ while (TRUE) {
+ gboolean _tmp12_;
+ gint _tmp14_;
+ GValueArray* _tmp15_;
+ guint _tmp16_;
+ GValueArray* _tmp17_;
+ gint _tmp18_;
+ GValue* _tmp19_ = NULL;
+ GValue* _tmp20_;
+ GValue* arg;
+ gchar* _tmp21_ = NULL;
+ GValue* _tmp22_;
+ gboolean _tmp23_ = FALSE;
+ gint _tmp29_;
+ const gchar* _tmp30_;
+ _tmp12_ = _tmp11_;
+ if (!_tmp12_) {
+ gint _tmp13_;
+ _tmp13_ = i;
+ i = _tmp13_ + 1;
+ }
+ _tmp11_ = FALSE;
+ _tmp14_ = i;
+ _tmp15_ = args;
+ _tmp16_ = _tmp15_->n_values;
+ if (!(((guint) _tmp14_) < _tmp16_)) {
+ break;
+ }
+ _tmp17_ = args;
+ _tmp18_ = i;
+ _tmp19_ = g_value_array_get_nth (_tmp17_, (guint) _tmp18_);
+ _tmp20_ = __g_value_dup0 (_tmp19_);
+ arg = _tmp20_;
+ _tmp22_ = arg;
+ _tmp23_ = G_VALUE_HOLDS (_tmp22_, G_TYPE_STRING);
+ if (_tmp23_) {
+ GValue* _tmp24_;
+ const gchar* _tmp25_ = NULL;
+ gchar* _tmp26_;
+ _tmp24_ = arg;
+ _tmp25_ = g_value_get_string (_tmp24_);
+ _tmp26_ = g_strdup (_tmp25_);
+ _g_free0 (_tmp21_);
+ _tmp21_ = _tmp26_;
+ } else {
+ GValue* _tmp27_;
+ gchar* _tmp28_ = NULL;
+ _tmp27_ = arg;
+ _tmp28_ = g_strdup_value_contents (_tmp27_);
+ _g_free0 (_tmp21_);
+ _tmp21_ = _tmp28_;
+ }
+ _tmp29_ = i;
+ _tmp30_ = _tmp21_;
+ g_debug ("rygel-media-export-media-cache.vala:299: Arg %d: %s", _tmp29_, _tmp30_);
+ _g_free0 (_tmp21_);
+ __vala_GValue_free0 (arg);
+ }
+ }
+ }
+ _tmp31_ = container_id;
+ if (_tmp31_ != NULL) {
+ RygelMediaExportSQLFactory* _tmp32_;
+ const gchar* _tmp33_ = NULL;
+ _tmp32_ = self->priv->sql;
+ _tmp33_ = rygel_media_export_sql_factory_make (_tmp32_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR);
+ sql = _tmp33_;
+ } else {
+ RygelMediaExportSQLFactory* _tmp34_;
+ const gchar* _tmp35_ = NULL;
+ _tmp34_ = self->priv->sql;
+ _tmp35_ = rygel_media_export_sql_factory_make (_tmp34_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER);
+ sql = _tmp35_;
+ }
+ _tmp36_ = sort_criteria;
+ _tmp37_ = rygel_media_export_media_cache_translate_sort_criteria (self, _tmp36_);
+ sort_order = _tmp37_;
+ _tmp38_ = self->priv->db;
+ _tmp39_ = sql;
+ _tmp40_ = filter;
+ _tmp41_ = sort_order;
+ _tmp42_ = g_strdup_printf (_tmp39_, _tmp40_, _tmp41_);
+ _tmp43_ = _tmp42_;
+ _tmp44_ = args;
+ _tmp45_ = _tmp44_->values;
+ _tmp45__length1 = (gint) _tmp44_->n_values;
+ _tmp46_ = rygel_media_export_database_exec_cursor (_tmp38_, _tmp43_, _tmp45_, _tmp45__length1, &_inner_error_);
+ _tmp47_ = _tmp46_;
+ _g_free0 (_tmp43_);
+ cursor = _tmp47_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (sort_order);
+ _g_object_unref0 (parent);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ _g_object_unref0 (children);
+ return NULL;
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp48_;
+ RygelMediaExportDatabaseCursorIterator* _tmp49_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp48_ = cursor;
+ _tmp49_ = rygel_media_export_database_cursor_iterator (_tmp48_);
+ _statement_it = _tmp49_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp50_;
+ gboolean _tmp51_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp52_;
+ sqlite3_stmt* _tmp53_ = NULL;
+ sqlite3_stmt* statement;
+ sqlite3_stmt* _tmp54_;
+ const gchar* _tmp55_ = NULL;
+ const gchar* parent_id;
+ gboolean _tmp56_ = FALSE;
+ RygelMediaContainer* _tmp57_;
+ gboolean _tmp62_;
+ RygelMediaContainer* _tmp66_;
+ _tmp50_ = _statement_it;
+ _tmp51_ = rygel_media_export_database_cursor_iterator_next (_tmp50_);
+ if (!_tmp51_) {
+ break;
+ }
+ _tmp52_ = _statement_it;
+ _tmp53_ = rygel_media_export_database_cursor_iterator_get (_tmp52_, &_inner_error_);
+ statement = _tmp53_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ _g_free0 (sort_order);
+ _g_object_unref0 (parent);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ _g_object_unref0 (children);
+ return NULL;
+ }
+ _tmp54_ = statement;
+ _tmp55_ = sqlite3_column_text (_tmp54_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_PARENT);
+ parent_id = _tmp55_;
+ _tmp57_ = parent;
+ if (_tmp57_ == NULL) {
+ _tmp56_ = TRUE;
+ } else {
+ const gchar* _tmp58_;
+ RygelMediaContainer* _tmp59_;
+ const gchar* _tmp60_;
+ const gchar* _tmp61_;
+ _tmp58_ = parent_id;
+ _tmp59_ = parent;
+ _tmp60_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp59_);
+ _tmp61_ = _tmp60_;
+ _tmp56_ = g_strcmp0 (_tmp58_, _tmp61_) != 0;
+ }
+ _tmp62_ = _tmp56_;
+ if (_tmp62_) {
+ RygelNullContainer* _tmp63_;
+ RygelMediaContainer* _tmp64_;
+ const gchar* _tmp65_;
+ _tmp63_ = rygel_null_container_new ();
+ _g_object_unref0 (parent);
+ parent = (RygelMediaContainer*) _tmp63_;
+ _tmp64_ = parent;
+ _tmp65_ = parent_id;
+ rygel_media_object_set_id ((RygelMediaObject*) _tmp64_, _tmp65_);
+ }
+ _tmp66_ = parent;
+ if (_tmp66_ != NULL) {
+ RygelMediaObjects* _tmp67_;
+ RygelMediaContainer* _tmp68_;
+ sqlite3_stmt* _tmp69_;
+ RygelMediaObject* _tmp70_ = NULL;
+ RygelMediaObject* _tmp71_;
+ RygelMediaObjects* _tmp72_;
+ gpointer _tmp73_ = NULL;
+ RygelMediaObject* _tmp74_;
+ RygelMediaContainer* _tmp75_;
+ _tmp67_ = children;
+ _tmp68_ = parent;
+ _tmp69_ = statement;
+ _tmp70_ = rygel_media_export_media_cache_get_object_from_statement (self, _tmp68_, _tmp69_);
+ _tmp71_ = _tmp70_;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp67_, _tmp71_);
+ _g_object_unref0 (_tmp71_);
+ _tmp72_ = children;
+ _tmp73_ = gee_list_last ((GeeList*) _tmp72_);
+ _tmp74_ = (RygelMediaObject*) _tmp73_;
+ _tmp75_ = parent;
+ rygel_media_object_set_parent_ref (_tmp74_, _tmp75_);
+ _g_object_unref0 (_tmp74_);
+ } else {
+ sqlite3_stmt* _tmp76_;
+ const gchar* _tmp77_ = NULL;
+ const gchar* _tmp78_;
+ _tmp76_ = statement;
+ _tmp77_ = sqlite3_column_text (_tmp76_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID);
+ _tmp78_ = parent_id;
+ g_warning ("Inconsistent database: item %s " "has no parent %s", _tmp77_, _tmp78_);
+ }
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ result = children;
+ _g_object_unref0 (cursor);
+ _g_free0 (sort_order);
+ _g_object_unref0 (parent);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ return result;
+}
+
+
+void rygel_media_export_media_cache_debug_statistics (RygelMediaExportMediaCache* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ RygelMediaExportDatabaseCursor* _tmp0_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ g_debug ("rygel-media-export-media-cache.vala:339: Database statistics:");
+ _tmp0_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS, NULL, 0, &_inner_error_);
+ cursor = _tmp0_;
+ if (_inner_error_ != NULL) {
+ goto __catch7_g_error;
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp1_;
+ RygelMediaExportDatabaseCursorIterator* _tmp2_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp1_ = cursor;
+ _tmp2_ = rygel_media_export_database_cursor_iterator (_tmp1_);
+ _statement_it = _tmp2_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp3_;
+ gboolean _tmp4_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp5_;
+ sqlite3_stmt* _tmp6_ = NULL;
+ sqlite3_stmt* statement;
+ sqlite3_stmt* _tmp7_;
+ const gchar* _tmp8_ = NULL;
+ sqlite3_stmt* _tmp9_;
+ gint _tmp10_ = 0;
+ _tmp3_ = _statement_it;
+ _tmp4_ = rygel_media_export_database_cursor_iterator_next (_tmp3_);
+ if (!_tmp4_) {
+ break;
+ }
+ _tmp5_ = _statement_it;
+ _tmp6_ = rygel_media_export_database_cursor_iterator_get (_tmp5_, &_inner_error_);
+ statement = _tmp6_;
+ if (_inner_error_ != NULL) {
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ goto __catch7_g_error;
+ }
+ _tmp7_ = statement;
+ _tmp8_ = sqlite3_column_text (_tmp7_, 0);
+ _tmp9_ = statement;
+ _tmp10_ = sqlite3_column_int (_tmp9_, 1);
+ g_debug ("rygel-media-export-media-cache.vala:342: %s: %d", _tmp8_, _tmp10_);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ _g_object_unref0 (cursor);
+ }
+ goto __finally7;
+ __catch7_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally7:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+GeeArrayList* rygel_media_export_media_cache_get_child_ids (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error) {
+ GeeArrayList* result = NULL;
+ GeeArrayList* _tmp0_;
+ GeeArrayList* children;
+ const gchar* _tmp1_;
+ GValue _tmp2_ = {0};
+ GValue* _tmp3_ = NULL;
+ GValue* values;
+ gint values_length1;
+ gint _values_size_;
+ GValue* _tmp4_;
+ gint _tmp4__length1;
+ RygelMediaExportDatabaseCursor* _tmp5_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (container_id != NULL, NULL);
+ _tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ children = _tmp0_;
+ _tmp1_ = container_id;
+ g_value_init (&_tmp2_, G_TYPE_STRING);
+ g_value_set_string (&_tmp2_, _tmp1_);
+ _tmp3_ = g_new0 (GValue, 1);
+ _tmp3_[0] = _tmp2_;
+ values = _tmp3_;
+ values_length1 = 1;
+ _values_size_ = values_length1;
+ _tmp4_ = values;
+ _tmp4__length1 = values_length1;
+ _tmp5_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS, _tmp4_, _tmp4__length1, &_inner_error_);
+ cursor = _tmp5_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_object_unref0 (children);
+ return NULL;
+ } else {
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_object_unref0 (children);
+ 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;
+ }
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp6_;
+ RygelMediaExportDatabaseCursorIterator* _tmp7_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp6_ = cursor;
+ _tmp7_ = rygel_media_export_database_cursor_iterator (_tmp6_);
+ _statement_it = _tmp7_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp8_;
+ gboolean _tmp9_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp10_;
+ sqlite3_stmt* _tmp11_ = NULL;
+ sqlite3_stmt* statement;
+ GeeArrayList* _tmp12_;
+ sqlite3_stmt* _tmp13_;
+ const gchar* _tmp14_ = NULL;
+ _tmp8_ = _statement_it;
+ _tmp9_ = rygel_media_export_database_cursor_iterator_next (_tmp8_);
+ if (!_tmp9_) {
+ break;
+ }
+ _tmp10_ = _statement_it;
+ _tmp11_ = rygel_media_export_database_cursor_iterator_get (_tmp10_, &_inner_error_);
+ statement = _tmp11_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_object_unref0 (children);
+ return NULL;
+ } else {
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_object_unref0 (children);
+ 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;
+ }
+ }
+ _tmp12_ = children;
+ _tmp13_ = statement;
+ _tmp14_ = sqlite3_column_text (_tmp13_, 0);
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, _tmp14_);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ result = children;
+ _g_object_unref0 (cursor);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return result;
+}
+
+
+GeeList* rygel_media_export_media_cache_get_meta_data_column_by_filter (RygelMediaExportMediaCache* self, const gchar* column, const gchar* filter, GValueArray* args, glong offset, glong max_count, GError** error) {
+ GeeList* result = NULL;
+ glong _tmp0_;
+ GValue _tmp1_ = {0};
+ GValue v;
+ GValueArray* _tmp2_;
+ GValue _tmp3_;
+ glong _tmp4_;
+ GValue _tmp5_ = {0};
+ GValueArray* _tmp6_;
+ GValue _tmp7_;
+ GeeArrayList* _tmp8_;
+ GeeArrayList* data;
+ RygelMediaExportSQLFactory* _tmp9_;
+ const gchar* _tmp10_ = NULL;
+ const gchar* sql;
+ RygelMediaExportDatabase* _tmp11_;
+ const gchar* _tmp12_;
+ const gchar* _tmp13_;
+ const gchar* _tmp14_;
+ gchar* _tmp15_ = NULL;
+ gchar* _tmp16_;
+ GValueArray* _tmp17_;
+ GValue* _tmp18_;
+ gint _tmp18__length1;
+ RygelMediaExportDatabaseCursor* _tmp19_ = NULL;
+ RygelMediaExportDatabaseCursor* _tmp20_;
+ RygelMediaExportDatabaseCursor* cursor;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (column != NULL, NULL);
+ g_return_val_if_fail (filter != NULL, NULL);
+ g_return_val_if_fail (args != NULL, NULL);
+ _tmp0_ = offset;
+ g_value_init (&_tmp1_, G_TYPE_LONG);
+ g_value_set_long (&_tmp1_, _tmp0_);
+ v = _tmp1_;
+ _tmp2_ = args;
+ _tmp3_ = v;
+ g_value_array_append (_tmp2_, &_tmp3_);
+ _tmp4_ = max_count;
+ g_value_init (&_tmp5_, G_TYPE_LONG);
+ g_value_set_long (&_tmp5_, _tmp4_);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ v = _tmp5_;
+ _tmp6_ = args;
+ _tmp7_ = v;
+ g_value_array_append (_tmp6_, &_tmp7_);
+ _tmp8_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ data = _tmp8_;
+ _tmp9_ = self->priv->sql;
+ _tmp10_ = rygel_media_export_sql_factory_make (_tmp9_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN);
+ sql = _tmp10_;
+ _tmp11_ = self->priv->db;
+ _tmp12_ = sql;
+ _tmp13_ = column;
+ _tmp14_ = filter;
+ _tmp15_ = g_strdup_printf (_tmp12_, _tmp13_, _tmp14_);
+ _tmp16_ = _tmp15_;
+ _tmp17_ = args;
+ _tmp18_ = _tmp17_->values;
+ _tmp18__length1 = (gint) _tmp17_->n_values;
+ _tmp19_ = rygel_media_export_database_exec_cursor (_tmp11_, _tmp16_, _tmp18_, _tmp18__length1, &_inner_error_);
+ _tmp20_ = _tmp19_;
+ _g_free0 (_tmp16_);
+ cursor = _tmp20_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (data);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ return NULL;
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp21_;
+ RygelMediaExportDatabaseCursorIterator* _tmp22_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp21_ = cursor;
+ _tmp22_ = rygel_media_export_database_cursor_iterator (_tmp21_);
+ _statement_it = _tmp22_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp23_;
+ gboolean _tmp24_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp25_;
+ sqlite3_stmt* _tmp26_ = NULL;
+ sqlite3_stmt* statement;
+ GeeArrayList* _tmp27_;
+ sqlite3_stmt* _tmp28_;
+ const gchar* _tmp29_ = NULL;
+ _tmp23_ = _statement_it;
+ _tmp24_ = rygel_media_export_database_cursor_iterator_next (_tmp23_);
+ if (!_tmp24_) {
+ break;
+ }
+ _tmp25_ = _statement_it;
+ _tmp26_ = rygel_media_export_database_cursor_iterator_get (_tmp25_, &_inner_error_);
+ statement = _tmp26_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ _g_object_unref0 (data);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ return NULL;
+ }
+ _tmp27_ = data;
+ _tmp28_ = statement;
+ _tmp29_ = sqlite3_column_text (_tmp28_, 0);
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp27_, _tmp29_);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ result = (GeeList*) data;
+ _g_object_unref0 (cursor);
+ G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
+ return result;
+}
+
+
+GeeList* rygel_media_export_media_cache_get_object_attribute_by_search_expression (RygelMediaExportMediaCache* self, const gchar* attribute, RygelSearchExpression* expression, glong offset, guint max_count, GError** error) {
+ GeeList* result = NULL;
+ GValueArray* _tmp0_;
+ GValueArray* args;
+ RygelSearchExpression* _tmp1_;
+ GValueArray* _tmp2_;
+ gchar* _tmp3_ = NULL;
+ gchar* filter;
+ const gchar* _tmp4_;
+ const gchar* _tmp5_;
+ gchar* _tmp6_ = NULL;
+ gchar* column;
+ guint _tmp7_;
+ guint _tmp8_ = 0U;
+ guint max_objects;
+ const gchar* _tmp9_;
+ const gchar* _tmp10_;
+ GValueArray* _tmp11_;
+ glong _tmp12_;
+ guint _tmp13_;
+ GeeList* _tmp14_ = NULL;
+ GeeList* _tmp15_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (attribute != NULL, NULL);
+ _tmp0_ = g_value_array_new ((guint) 0);
+ args = _tmp0_;
+ _tmp1_ = expression;
+ _tmp2_ = args;
+ _tmp3_ = rygel_media_export_media_cache_translate_search_expression (self, _tmp1_, _tmp2_, "AND", &_inner_error_);
+ filter = _tmp3_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_value_array_free0 (args);
+ return NULL;
+ }
+ _tmp4_ = filter;
+ g_debug ("rygel-media-export-media-cache.vala:397: Parsed filter: %s", _tmp4_);
+ _tmp5_ = attribute;
+ _tmp6_ = rygel_media_export_media_cache_map_operand_to_column (self, _tmp5_, NULL, &_inner_error_);
+ column = _tmp6_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (filter);
+ _g_value_array_free0 (args);
+ return NULL;
+ }
+ _tmp7_ = max_count;
+ _tmp8_ = rygel_media_export_media_cache_modify_limit (self, _tmp7_);
+ max_objects = _tmp8_;
+ _tmp9_ = column;
+ _tmp10_ = filter;
+ _tmp11_ = args;
+ _tmp12_ = offset;
+ _tmp13_ = max_objects;
+ _tmp14_ = rygel_media_export_media_cache_get_meta_data_column_by_filter (self, _tmp9_, _tmp10_, _tmp11_, _tmp12_, (glong) _tmp13_, &_inner_error_);
+ _tmp15_ = _tmp14_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (column);
+ _g_free0 (filter);
+ _g_value_array_free0 (args);
+ return NULL;
+ }
+ result = _tmp15_;
+ _g_free0 (column);
+ _g_free0 (filter);
+ _g_value_array_free0 (args);
+ return result;
+}
+
+
+void rygel_media_export_media_cache_flag_object (RygelMediaExportMediaCache* self, GFile* file, const gchar* flag, GError** error) {
+ const gchar* _tmp0_;
+ GValue _tmp1_ = {0};
+ GFile* _tmp2_;
+ gchar* _tmp3_ = NULL;
+ GValue _tmp4_ = {0};
+ GValue* _tmp5_ = NULL;
+ GValue* args;
+ gint args_length1;
+ gint _args_size_;
+ RygelMediaExportDatabase* _tmp6_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ g_return_if_fail (flag != NULL);
+ _tmp0_ = flag;
+ g_value_init (&_tmp1_, G_TYPE_STRING);
+ g_value_set_string (&_tmp1_, _tmp0_);
+ _tmp2_ = file;
+ _tmp3_ = g_file_get_uri (_tmp2_);
+ g_value_init (&_tmp4_, G_TYPE_STRING);
+ g_value_take_string (&_tmp4_, _tmp3_);
+ _tmp5_ = g_new0 (GValue, 2);
+ _tmp5_[0] = _tmp1_;
+ _tmp5_[1] = _tmp4_;
+ args = _tmp5_;
+ args_length1 = 2;
+ _args_size_ = args_length1;
+ _tmp6_ = self->priv->db;
+ rygel_media_export_database_exec (_tmp6_, "UPDATE Object SET flags = ? WHERE uri = ?", args, args_length1, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ return;
+ }
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+}
+
+
+GeeList* rygel_media_export_media_cache_get_flagged_uris (RygelMediaExportMediaCache* self, const gchar* flag, GError** error) {
+ GeeList* result = NULL;
+ GeeArrayList* _tmp0_;
+ GeeArrayList* uris;
+ static const char query[] = "SELECT uri FROM object WHERE flags = ?";
+ const gchar* _tmp1_;
+ GValue _tmp2_ = {0};
+ GValue* _tmp3_ = NULL;
+ GValue* args;
+ gint args_length1;
+ gint _args_size_;
+ RygelMediaExportDatabase* _tmp4_;
+ GValue* _tmp5_;
+ gint _tmp5__length1;
+ RygelMediaExportDatabaseCursor* _tmp6_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (flag != NULL, NULL);
+ _tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ uris = _tmp0_;
+ _tmp1_ = flag;
+ g_value_init (&_tmp2_, G_TYPE_STRING);
+ g_value_set_string (&_tmp2_, _tmp1_);
+ _tmp3_ = g_new0 (GValue, 1);
+ _tmp3_[0] = _tmp2_;
+ args = _tmp3_;
+ args_length1 = 1;
+ _args_size_ = args_length1;
+ _tmp4_ = self->priv->db;
+ _tmp5_ = args;
+ _tmp5__length1 = args_length1;
+ _tmp6_ = rygel_media_export_database_exec_cursor (_tmp4_, query, _tmp5_, _tmp5__length1, &_inner_error_);
+ cursor = _tmp6_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (uris);
+ return NULL;
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp7_;
+ RygelMediaExportDatabaseCursorIterator* _tmp8_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp7_ = cursor;
+ _tmp8_ = rygel_media_export_database_cursor_iterator (_tmp7_);
+ _statement_it = _tmp8_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp9_;
+ gboolean _tmp10_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp11_;
+ sqlite3_stmt* _tmp12_ = NULL;
+ sqlite3_stmt* statement;
+ GeeArrayList* _tmp13_;
+ sqlite3_stmt* _tmp14_;
+ const gchar* _tmp15_ = NULL;
+ _tmp9_ = _statement_it;
+ _tmp10_ = rygel_media_export_database_cursor_iterator_next (_tmp9_);
+ if (!_tmp10_) {
+ break;
+ }
+ _tmp11_ = _statement_it;
+ _tmp12_ = rygel_media_export_database_cursor_iterator_get (_tmp11_, &_inner_error_);
+ statement = _tmp12_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ _g_object_unref0 (uris);
+ return NULL;
+ }
+ _tmp13_ = uris;
+ _tmp14_ = statement;
+ _tmp15_ = sqlite3_column_text (_tmp14_, 0);
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp13_, _tmp15_);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ result = (GeeList*) uris;
+ _g_object_unref0 (cursor);
+ args = (_vala_GValue_array_free (args, args_length1), NULL);
+ return result;
+}
+
+
+static void rygel_media_export_media_cache_get_exists_cache (RygelMediaExportMediaCache* self, GError** error) {
+ GeeHashMap* _tmp0_;
+ RygelMediaExportDatabaseCursor* _tmp1_ = NULL;
+ RygelMediaExportDatabaseCursor* cursor;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, RYGEL_MEDIA_EXPORT_TYPE_EXISTS_CACHE_ENTRY, (GBoxedCopyFunc) rygel_media_export_exists_cache_entry_dup, rygel_media_export_exists_cache_entry_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ _g_object_unref0 (self->priv->exists_cache);
+ self->priv->exists_cache = _tmp0_;
+ _tmp1_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE, NULL, 0, &_inner_error_);
+ cursor = _tmp1_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+ {
+ RygelMediaExportDatabaseCursor* _tmp2_;
+ RygelMediaExportDatabaseCursorIterator* _tmp3_ = NULL;
+ RygelMediaExportDatabaseCursorIterator* _statement_it;
+ _tmp2_ = cursor;
+ _tmp3_ = rygel_media_export_database_cursor_iterator (_tmp2_);
+ _statement_it = _tmp3_;
+ while (TRUE) {
+ RygelMediaExportDatabaseCursorIterator* _tmp4_;
+ gboolean _tmp5_ = FALSE;
+ RygelMediaExportDatabaseCursorIterator* _tmp6_;
+ sqlite3_stmt* _tmp7_ = NULL;
+ sqlite3_stmt* statement;
+ RygelMediaExportExistsCacheEntry entry = {0};
+ sqlite3_stmt* _tmp8_;
+ gint64 _tmp9_ = 0LL;
+ sqlite3_stmt* _tmp10_;
+ gint64 _tmp11_ = 0LL;
+ GeeHashMap* _tmp12_;
+ sqlite3_stmt* _tmp13_;
+ const gchar* _tmp14_ = NULL;
+ RygelMediaExportExistsCacheEntry _tmp15_;
+ _tmp4_ = _statement_it;
+ _tmp5_ = rygel_media_export_database_cursor_iterator_next (_tmp4_);
+ if (!_tmp5_) {
+ break;
+ }
+ _tmp6_ = _statement_it;
+ _tmp7_ = rygel_media_export_database_cursor_iterator_get (_tmp6_, &_inner_error_);
+ statement = _tmp7_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ return;
+ } else {
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ _g_object_unref0 (cursor);
+ 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;
+ }
+ }
+ memset (&entry, 0, sizeof (RygelMediaExportExistsCacheEntry));
+ _tmp8_ = statement;
+ _tmp9_ = sqlite3_column_int64 (_tmp8_, 1);
+ entry.mtime = _tmp9_;
+ _tmp10_ = statement;
+ _tmp11_ = sqlite3_column_int64 (_tmp10_, 0);
+ entry.size = _tmp11_;
+ _tmp12_ = self->priv->exists_cache;
+ _tmp13_ = statement;
+ _tmp14_ = sqlite3_column_text (_tmp13_, 2);
+ _tmp15_ = entry;
+ gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, _tmp14_, &_tmp15_);
+ }
+ _rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
+ }
+ _g_object_unref0 (cursor);
+}
+
+
+static guint rygel_media_export_media_cache_modify_limit (RygelMediaExportMediaCache* self, guint max_count) {
+ guint result = 0U;
+ guint _tmp0_;
+ g_return_val_if_fail (self != NULL, 0U);
+ _tmp0_ = max_count;
+ if (_tmp0_ == ((guint) 0)) {
+ result = (guint) (-1);
+ return result;
+ } else {
+ guint _tmp1_;
+ _tmp1_ = max_count;
+ result = _tmp1_;
+ return result;
+ }
+}
+
+
+static void rygel_media_export_media_cache_open_db (RygelMediaExportMediaCache* self, const gchar* name, GError** error) {
+ const gchar* _tmp0_;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportDatabase* _tmp2_;
+ gint old_version;
+ gint _tmp3_ = 0;
+ gint current_version;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (name != NULL);
+ _tmp0_ = name;
+ _tmp1_ = rygel_media_export_database_new (_tmp0_, &_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ }
+ _g_object_unref0 (self->priv->db);
+ self->priv->db = _tmp2_;
+ old_version = -1;
+ _tmp3_ = atoi (RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION);
+ current_version = _tmp3_;
+ {
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportSQLFactory* _tmp5_;
+ RygelMediaExportMediaCacheUpgrader* _tmp6_;
+ RygelMediaExportMediaCacheUpgrader* upgrader;
+ RygelMediaExportMediaCacheUpgrader* _tmp7_;
+ gint _tmp8_ = 0;
+ gboolean _tmp9_ = FALSE;
+ gboolean _tmp10_;
+ RygelMediaExportMediaCacheUpgrader* _tmp19_;
+ _tmp4_ = self->priv->db;
+ _tmp5_ = self->priv->sql;
+ _tmp6_ = rygel_media_export_media_cache_upgrader_new (_tmp4_, _tmp5_);
+ upgrader = _tmp6_;
+ _tmp7_ = upgrader;
+ _tmp9_ = rygel_media_export_media_cache_upgrader_needs_upgrade (_tmp7_, &_tmp8_, &_inner_error_);
+ old_version = _tmp8_;
+ _tmp10_ = _tmp9_;
+ if (_inner_error_ != NULL) {
+ _rygel_media_export_media_cache_upgrader_unref0 (upgrader);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch8_rygel_media_export_database_error;
+ }
+ goto __finally8;
+ }
+ if (_tmp10_) {
+ RygelMediaExportMediaCacheUpgrader* _tmp11_;
+ gint _tmp12_;
+ _tmp11_ = upgrader;
+ _tmp12_ = old_version;
+ rygel_media_export_media_cache_upgrader_upgrade (_tmp11_, _tmp12_);
+ } else {
+ gint _tmp13_;
+ gint _tmp14_;
+ _tmp13_ = old_version;
+ _tmp14_ = current_version;
+ if (_tmp13_ == _tmp14_) {
+ RygelMediaExportMediaCacheUpgrader* _tmp15_;
+ _tmp15_ = upgrader;
+ rygel_media_export_media_cache_upgrader_fix_schema (_tmp15_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ _rygel_media_export_media_cache_upgrader_unref0 (upgrader);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch8_rygel_media_export_database_error;
+ }
+ goto __finally8;
+ }
+ } else {
+ gint _tmp16_;
+ gint _tmp17_;
+ GError* _tmp18_;
+ _tmp16_ = old_version;
+ _tmp17_ = current_version;
+ g_warning ("The version \"%d\" of the detected database" " is newer than our supported version \"%d\"", _tmp16_, _tmp17_);
+ _g_object_unref0 (self->priv->db);
+ self->priv->db = NULL;
+ _tmp18_ = g_error_new_literal (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_GENERAL_ERROR, "Database format" " not supported");
+ _inner_error_ = _tmp18_;
+ _rygel_media_export_media_cache_upgrader_unref0 (upgrader);
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch8_rygel_media_export_database_error;
+ }
+ goto __finally8;
+ }
+ }
+ _tmp19_ = upgrader;
+ rygel_media_export_media_cache_upgrader_ensure_indices (_tmp19_);
+ _rygel_media_export_media_cache_upgrader_unref0 (upgrader);
+ }
+ goto __finally8;
+ __catch8_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ g_debug ("rygel-media-export-media-cache.vala:471: %s", "Could not find schema version;" " checking for empty database...");
+ {
+ RygelMediaExportDatabase* _tmp20_;
+ gint _tmp21_ = 0;
+ gint rows;
+ gint _tmp22_;
+ _tmp20_ = self->priv->db;
+ _tmp21_ = rygel_media_export_database_query_value (_tmp20_, "SELECT count(type) FROM " "sqlite_master WHERE rowid=1", NULL, 0, &_inner_error_);
+ rows = _tmp21_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch9_rygel_media_export_database_error;
+ }
+ _g_error_free0 (_error_);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp22_ = rows;
+ if (_tmp22_ == 0) {
+ gboolean _tmp23_ = FALSE;
+ g_debug ("rygel-media-export-media-cache.vala:477: Empty database, creating new " \
+"schema version %s", RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION);
+ _tmp23_ = rygel_media_export_media_cache_create_schema (self);
+ if (!_tmp23_) {
+ _g_object_unref0 (self->priv->db);
+ self->priv->db = NULL;
+ _g_error_free0 (_error_);
+ return;
+ }
+ } else {
+ g_warning ("rygel-media-export-media-cache.vala:485: Incompatible schema... cannot" \
+" proceed");
+ _g_object_unref0 (self->priv->db);
+ self->priv->db = NULL;
+ _g_error_free0 (_error_);
+ return;
+ }
+ }
+ goto __finally9;
+ __catch9_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ GError* _tmp24_;
+ const gchar* _tmp25_;
+ GError* _tmp26_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp24_ = _error_;
+ _tmp25_ = _tmp24_->message;
+ g_warning ("rygel-media-export-media-cache.vala:491: Something weird going on: %s", _tmp25_);
+ _g_object_unref0 (self->priv->db);
+ self->priv->db = NULL;
+ _tmp26_ = g_error_new_literal (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_GENERAL_ERROR, "Invalid database");
+ _inner_error_ = _tmp26_;
+ _g_error_free0 (_error_);
+ goto __finally9;
+ }
+ __finally9:
+ if (_inner_error_ != NULL) {
+ _g_error_free0 (_error_);
+ goto __finally8;
+ }
+ _g_error_free0 (_error_);
+ }
+ __finally8:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ }
+}
+
+
+static void rygel_media_export_media_cache_save_metadata (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error) {
+ RygelMediaItem* _tmp0_;
+ gint64 _tmp1_;
+ gint64 _tmp2_;
+ GValue _tmp3_ = {0};
+ RygelMediaItem* _tmp4_;
+ const gchar* _tmp5_;
+ const gchar* _tmp6_;
+ GValue _tmp7_ = {0};
+ GValue _tmp8_ = {0};
+ GValue _tmp9_ = {0};
+ RygelMediaItem* _tmp10_;
+ const gchar* _tmp11_;
+ const gchar* _tmp12_;
+ GValue _tmp13_ = {0};
+ GValue _tmp14_ = {0};
+ GValue _tmp15_ = {0};
+ RygelMediaItem* _tmp16_;
+ const gchar* _tmp17_;
+ const gchar* _tmp18_;
+ GValue _tmp19_ = {0};
+ GValue _tmp20_ = {0};
+ GValue _tmp21_ = {0};
+ GValue _tmp22_ = {0};
+ GValue _tmp23_ = {0};
+ GValue _tmp24_ = {0};
+ GValue _tmp25_ = {0};
+ GValue _tmp26_ = {0};
+ RygelMediaItem* _tmp27_;
+ const gchar* _tmp28_;
+ const gchar* _tmp29_;
+ GValue _tmp30_ = {0};
+ RygelMediaItem* _tmp31_;
+ const gchar* _tmp32_;
+ const gchar* _tmp33_;
+ GValue _tmp34_ = {0};
+ GValue _tmp35_ = {0};
+ GValue _tmp36_ = {0};
+ GValue* _tmp37_ = NULL;
+ GValue* values;
+ gint values_length1;
+ gint _values_size_;
+ RygelMediaItem* _tmp38_;
+ RygelMediaItem* _tmp103_;
+ RygelMediaExportDatabase* _tmp133_;
+ RygelMediaExportSQLFactory* _tmp134_;
+ const gchar* _tmp135_ = NULL;
+ GValue* _tmp136_;
+ gint _tmp136__length1;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (item != NULL);
+ _tmp0_ = item;
+ _tmp1_ = rygel_media_item_get_size (_tmp0_);
+ _tmp2_ = _tmp1_;
+ g_value_init (&_tmp3_, G_TYPE_INT64);
+ g_value_set_int64 (&_tmp3_, _tmp2_);
+ _tmp4_ = item;
+ _tmp5_ = rygel_media_item_get_mime_type (_tmp4_);
+ _tmp6_ = _tmp5_;
+ g_value_init (&_tmp7_, G_TYPE_STRING);
+ g_value_set_string (&_tmp7_, _tmp6_);
+ g_value_init (&_tmp8_, G_TYPE_INT);
+ g_value_set_int (&_tmp8_, -1);
+ g_value_init (&_tmp9_, G_TYPE_INT);
+ g_value_set_int (&_tmp9_, -1);
+ _tmp10_ = item;
+ _tmp11_ = rygel_media_object_get_upnp_class ((RygelMediaObject*) _tmp10_);
+ _tmp12_ = _tmp11_;
+ g_value_init (&_tmp13_, G_TYPE_STRING);
+ g_value_set_string (&_tmp13_, _tmp12_);
+ rygel_media_export_database_null (&_tmp14_);
+ rygel_media_export_database_null (&_tmp15_);
+ _tmp16_ = item;
+ _tmp17_ = rygel_media_item_get_date (_tmp16_);
+ _tmp18_ = _tmp17_;
+ g_value_init (&_tmp19_, G_TYPE_STRING);
+ g_value_set_string (&_tmp19_, _tmp18_);
+ g_value_init (&_tmp20_, G_TYPE_INT);
+ g_value_set_int (&_tmp20_, -1);
+ g_value_init (&_tmp21_, G_TYPE_INT);
+ g_value_set_int (&_tmp21_, -1);
+ g_value_init (&_tmp22_, G_TYPE_INT);
+ g_value_set_int (&_tmp22_, -1);
+ g_value_init (&_tmp23_, G_TYPE_INT);
+ g_value_set_int (&_tmp23_, -1);
+ g_value_init (&_tmp24_, G_TYPE_INT);
+ g_value_set_int (&_tmp24_, -1);
+ g_value_init (&_tmp25_, G_TYPE_INT);
+ g_value_set_int (&_tmp25_, -1);
+ g_value_init (&_tmp26_, G_TYPE_INT);
+ g_value_set_int (&_tmp26_, -1);
+ _tmp27_ = item;
+ _tmp28_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp27_);
+ _tmp29_ = _tmp28_;
+ g_value_init (&_tmp30_, G_TYPE_STRING);
+ g_value_set_string (&_tmp30_, _tmp29_);
+ _tmp31_ = item;
+ _tmp32_ = rygel_media_item_get_dlna_profile (_tmp31_);
+ _tmp33_ = _tmp32_;
+ g_value_init (&_tmp34_, G_TYPE_STRING);
+ g_value_set_string (&_tmp34_, _tmp33_);
+ rygel_media_export_database_null (&_tmp35_);
+ g_value_init (&_tmp36_, G_TYPE_INT);
+ g_value_set_int (&_tmp36_, -1);
+ _tmp37_ = g_new0 (GValue, 19);
+ _tmp37_[0] = _tmp3_;
+ _tmp37_[1] = _tmp7_;
+ _tmp37_[2] = _tmp8_;
+ _tmp37_[3] = _tmp9_;
+ _tmp37_[4] = _tmp13_;
+ _tmp37_[5] = _tmp14_;
+ _tmp37_[6] = _tmp15_;
+ _tmp37_[7] = _tmp19_;
+ _tmp37_[8] = _tmp20_;
+ _tmp37_[9] = _tmp21_;
+ _tmp37_[10] = _tmp22_;
+ _tmp37_[11] = _tmp23_;
+ _tmp37_[12] = _tmp24_;
+ _tmp37_[13] = _tmp25_;
+ _tmp37_[14] = _tmp26_;
+ _tmp37_[15] = _tmp30_;
+ _tmp37_[16] = _tmp34_;
+ _tmp37_[17] = _tmp35_;
+ _tmp37_[18] = _tmp36_;
+ values = _tmp37_;
+ values_length1 = 19;
+ _values_size_ = values_length1;
+ _tmp38_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp38_, RYGEL_TYPE_AUDIO_ITEM)) {
+ RygelMediaItem* _tmp39_;
+ RygelAudioItem* _tmp40_;
+ RygelAudioItem* audio_item;
+ GValue* _tmp41_;
+ gint _tmp41__length1;
+ RygelAudioItem* _tmp42_;
+ glong _tmp43_;
+ glong _tmp44_;
+ GValue _tmp45_ = {0};
+ GValue _tmp46_;
+ GValue* _tmp47_;
+ gint _tmp47__length1;
+ RygelAudioItem* _tmp48_;
+ gint _tmp49_;
+ gint _tmp50_;
+ GValue _tmp51_ = {0};
+ GValue _tmp52_;
+ GValue* _tmp53_;
+ gint _tmp53__length1;
+ RygelAudioItem* _tmp54_;
+ gint _tmp55_;
+ gint _tmp56_;
+ GValue _tmp57_ = {0};
+ GValue _tmp58_;
+ GValue* _tmp59_;
+ gint _tmp59__length1;
+ RygelAudioItem* _tmp60_;
+ gint _tmp61_;
+ gint _tmp62_;
+ GValue _tmp63_ = {0};
+ GValue _tmp64_;
+ GValue* _tmp65_;
+ gint _tmp65__length1;
+ RygelAudioItem* _tmp66_;
+ gint _tmp67_;
+ gint _tmp68_;
+ GValue _tmp69_ = {0};
+ GValue _tmp70_;
+ RygelMediaItem* _tmp71_;
+ _tmp39_ = item;
+ _tmp40_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp39_, RYGEL_TYPE_AUDIO_ITEM) ? ((RygelAudioItem*) _tmp39_) : NULL);
+ audio_item = _tmp40_;
+ _tmp41_ = values;
+ _tmp41__length1 = values_length1;
+ _tmp42_ = audio_item;
+ _tmp43_ = rygel_audio_item_get_duration (_tmp42_);
+ _tmp44_ = _tmp43_;
+ g_value_init (&_tmp45_, G_TYPE_LONG);
+ g_value_set_long (&_tmp45_, _tmp44_);
+ G_IS_VALUE (&_tmp41_[14]) ? (g_value_unset (&_tmp41_[14]), NULL) : NULL;
+ _tmp41_[14] = _tmp45_;
+ _tmp46_ = _tmp41_[14];
+ _tmp47_ = values;
+ _tmp47__length1 = values_length1;
+ _tmp48_ = audio_item;
+ _tmp49_ = rygel_audio_item_get_bitrate (_tmp48_);
+ _tmp50_ = _tmp49_;
+ g_value_init (&_tmp51_, G_TYPE_INT);
+ g_value_set_int (&_tmp51_, _tmp50_);
+ G_IS_VALUE (&_tmp47_[8]) ? (g_value_unset (&_tmp47_[8]), NULL) : NULL;
+ _tmp47_[8] = _tmp51_;
+ _tmp52_ = _tmp47_[8];
+ _tmp53_ = values;
+ _tmp53__length1 = values_length1;
+ _tmp54_ = audio_item;
+ _tmp55_ = rygel_audio_item_get_sample_freq (_tmp54_);
+ _tmp56_ = _tmp55_;
+ g_value_init (&_tmp57_, G_TYPE_INT);
+ g_value_set_int (&_tmp57_, _tmp56_);
+ G_IS_VALUE (&_tmp53_[9]) ? (g_value_unset (&_tmp53_[9]), NULL) : NULL;
+ _tmp53_[9] = _tmp57_;
+ _tmp58_ = _tmp53_[9];
+ _tmp59_ = values;
+ _tmp59__length1 = values_length1;
+ _tmp60_ = audio_item;
+ _tmp61_ = rygel_audio_item_get_bits_per_sample (_tmp60_);
+ _tmp62_ = _tmp61_;
+ g_value_init (&_tmp63_, G_TYPE_INT);
+ g_value_set_int (&_tmp63_, _tmp62_);
+ G_IS_VALUE (&_tmp59_[10]) ? (g_value_unset (&_tmp59_[10]), NULL) : NULL;
+ _tmp59_[10] = _tmp63_;
+ _tmp64_ = _tmp59_[10];
+ _tmp65_ = values;
+ _tmp65__length1 = values_length1;
+ _tmp66_ = audio_item;
+ _tmp67_ = rygel_audio_item_get_channels (_tmp66_);
+ _tmp68_ = _tmp67_;
+ g_value_init (&_tmp69_, G_TYPE_INT);
+ g_value_set_int (&_tmp69_, _tmp68_);
+ G_IS_VALUE (&_tmp65_[11]) ? (g_value_unset (&_tmp65_[11]), NULL) : NULL;
+ _tmp65_[11] = _tmp69_;
+ _tmp70_ = _tmp65_[11];
+ _tmp71_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp71_, RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM)) {
+ RygelMediaItem* _tmp72_;
+ RygelMediaExportMusicItem* _tmp73_;
+ RygelMediaExportMusicItem* music_item;
+ GValue* _tmp74_;
+ gint _tmp74__length1;
+ RygelMediaExportMusicItem* _tmp75_;
+ const gchar* _tmp76_;
+ const gchar* _tmp77_;
+ GValue _tmp78_ = {0};
+ GValue _tmp79_;
+ GValue* _tmp80_;
+ gint _tmp80__length1;
+ RygelMediaExportMusicItem* _tmp81_;
+ const gchar* _tmp82_;
+ const gchar* _tmp83_;
+ GValue _tmp84_ = {0};
+ GValue _tmp85_;
+ GValue* _tmp86_;
+ gint _tmp86__length1;
+ RygelMediaExportMusicItem* _tmp87_;
+ const gchar* _tmp88_;
+ const gchar* _tmp89_;
+ GValue _tmp90_ = {0};
+ GValue _tmp91_;
+ GValue* _tmp92_;
+ gint _tmp92__length1;
+ RygelMediaExportMusicItem* _tmp93_;
+ gint _tmp94_;
+ gint _tmp95_;
+ GValue _tmp96_ = {0};
+ GValue _tmp97_;
+ GValue* _tmp98_;
+ gint _tmp98__length1;
+ RygelMediaExportMusicItem* _tmp99_;
+ gint _tmp100_;
+ GValue _tmp101_ = {0};
+ GValue _tmp102_;
+ _tmp72_ = item;
+ _tmp73_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp72_, RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM) ? ((RygelMediaExportMusicItem*) _tmp72_) : NULL);
+ music_item = _tmp73_;
+ _tmp74_ = values;
+ _tmp74__length1 = values_length1;
+ _tmp75_ = music_item;
+ _tmp76_ = rygel_music_item_get_artist ((RygelMusicItem*) _tmp75_);
+ _tmp77_ = _tmp76_;
+ g_value_init (&_tmp78_, G_TYPE_STRING);
+ g_value_set_string (&_tmp78_, _tmp77_);
+ G_IS_VALUE (&_tmp74_[5]) ? (g_value_unset (&_tmp74_[5]), NULL) : NULL;
+ _tmp74_[5] = _tmp78_;
+ _tmp79_ = _tmp74_[5];
+ _tmp80_ = values;
+ _tmp80__length1 = values_length1;
+ _tmp81_ = music_item;
+ _tmp82_ = rygel_music_item_get_album ((RygelMusicItem*) _tmp81_);
+ _tmp83_ = _tmp82_;
+ g_value_init (&_tmp84_, G_TYPE_STRING);
+ g_value_set_string (&_tmp84_, _tmp83_);
+ G_IS_VALUE (&_tmp80_[6]) ? (g_value_unset (&_tmp80_[6]), NULL) : NULL;
+ _tmp80_[6] = _tmp84_;
+ _tmp85_ = _tmp80_[6];
+ _tmp86_ = values;
+ _tmp86__length1 = values_length1;
+ _tmp87_ = music_item;
+ _tmp88_ = rygel_music_item_get_genre ((RygelMusicItem*) _tmp87_);
+ _tmp89_ = _tmp88_;
+ g_value_init (&_tmp90_, G_TYPE_STRING);
+ g_value_set_string (&_tmp90_, _tmp89_);
+ G_IS_VALUE (&_tmp86_[17]) ? (g_value_unset (&_tmp86_[17]), NULL) : NULL;
+ _tmp86_[17] = _tmp90_;
+ _tmp91_ = _tmp86_[17];
+ _tmp92_ = values;
+ _tmp92__length1 = values_length1;
+ _tmp93_ = music_item;
+ _tmp94_ = rygel_music_item_get_track_number ((RygelMusicItem*) _tmp93_);
+ _tmp95_ = _tmp94_;
+ g_value_init (&_tmp96_, G_TYPE_INT);
+ g_value_set_int (&_tmp96_, _tmp95_);
+ G_IS_VALUE (&_tmp92_[12]) ? (g_value_unset (&_tmp92_[12]), NULL) : NULL;
+ _tmp92_[12] = _tmp96_;
+ _tmp97_ = _tmp92_[12];
+ _tmp98_ = values;
+ _tmp98__length1 = values_length1;
+ _tmp99_ = music_item;
+ _tmp100_ = _tmp99_->disc;
+ g_value_init (&_tmp101_, G_TYPE_INT);
+ g_value_set_int (&_tmp101_, _tmp100_);
+ G_IS_VALUE (&_tmp98_[18]) ? (g_value_unset (&_tmp98_[18]), NULL) : NULL;
+ _tmp98_[18] = _tmp101_;
+ _tmp102_ = _tmp98_[18];
+ _g_object_unref0 (music_item);
+ }
+ _g_object_unref0 (audio_item);
+ }
+ _tmp103_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp103_, RYGEL_TYPE_VISUAL_ITEM)) {
+ RygelMediaItem* _tmp104_;
+ RygelVisualItem* _tmp105_;
+ RygelVisualItem* visual_item;
+ GValue* _tmp106_;
+ gint _tmp106__length1;
+ RygelVisualItem* _tmp107_;
+ gint _tmp108_;
+ gint _tmp109_;
+ GValue _tmp110_ = {0};
+ GValue _tmp111_;
+ GValue* _tmp112_;
+ gint _tmp112__length1;
+ RygelVisualItem* _tmp113_;
+ gint _tmp114_;
+ gint _tmp115_;
+ GValue _tmp116_ = {0};
+ GValue _tmp117_;
+ GValue* _tmp118_;
+ gint _tmp118__length1;
+ RygelVisualItem* _tmp119_;
+ gint _tmp120_;
+ gint _tmp121_;
+ GValue _tmp122_ = {0};
+ GValue _tmp123_;
+ RygelMediaItem* _tmp124_;
+ _tmp104_ = item;
+ _tmp105_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp104_, RYGEL_TYPE_VISUAL_ITEM) ? ((RygelVisualItem*) _tmp104_) : NULL);
+ visual_item = _tmp105_;
+ _tmp106_ = values;
+ _tmp106__length1 = values_length1;
+ _tmp107_ = visual_item;
+ _tmp108_ = rygel_visual_item_get_width (_tmp107_);
+ _tmp109_ = _tmp108_;
+ g_value_init (&_tmp110_, G_TYPE_INT);
+ g_value_set_int (&_tmp110_, _tmp109_);
+ G_IS_VALUE (&_tmp106_[2]) ? (g_value_unset (&_tmp106_[2]), NULL) : NULL;
+ _tmp106_[2] = _tmp110_;
+ _tmp111_ = _tmp106_[2];
+ _tmp112_ = values;
+ _tmp112__length1 = values_length1;
+ _tmp113_ = visual_item;
+ _tmp114_ = rygel_visual_item_get_height (_tmp113_);
+ _tmp115_ = _tmp114_;
+ g_value_init (&_tmp116_, G_TYPE_INT);
+ g_value_set_int (&_tmp116_, _tmp115_);
+ G_IS_VALUE (&_tmp112_[3]) ? (g_value_unset (&_tmp112_[3]), NULL) : NULL;
+ _tmp112_[3] = _tmp116_;
+ _tmp117_ = _tmp112_[3];
+ _tmp118_ = values;
+ _tmp118__length1 = values_length1;
+ _tmp119_ = visual_item;
+ _tmp120_ = rygel_visual_item_get_color_depth (_tmp119_);
+ _tmp121_ = _tmp120_;
+ g_value_init (&_tmp122_, G_TYPE_INT);
+ g_value_set_int (&_tmp122_, _tmp121_);
+ G_IS_VALUE (&_tmp118_[13]) ? (g_value_unset (&_tmp118_[13]), NULL) : NULL;
+ _tmp118_[13] = _tmp122_;
+ _tmp123_ = _tmp118_[13];
+ _tmp124_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp124_, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM)) {
+ RygelMediaItem* _tmp125_;
+ RygelMediaExportVideoItem* _tmp126_;
+ RygelMediaExportVideoItem* video_item;
+ GValue* _tmp127_;
+ gint _tmp127__length1;
+ RygelMediaExportVideoItem* _tmp128_;
+ const gchar* _tmp129_;
+ const gchar* _tmp130_;
+ GValue _tmp131_ = {0};
+ GValue _tmp132_;
+ _tmp125_ = item;
+ _tmp126_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp125_, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM) ? ((RygelMediaExportVideoItem*) _tmp125_) : NULL);
+ video_item = _tmp126_;
+ _tmp127_ = values;
+ _tmp127__length1 = values_length1;
+ _tmp128_ = video_item;
+ _tmp129_ = rygel_video_item_get_author ((RygelVideoItem*) _tmp128_);
+ _tmp130_ = _tmp129_;
+ g_value_init (&_tmp131_, G_TYPE_STRING);
+ g_value_set_string (&_tmp131_, _tmp130_);
+ G_IS_VALUE (&_tmp127_[5]) ? (g_value_unset (&_tmp127_[5]), NULL) : NULL;
+ _tmp127_[5] = _tmp131_;
+ _tmp132_ = _tmp127_[5];
+ _g_object_unref0 (video_item);
+ }
+ _g_object_unref0 (visual_item);
+ }
+ _tmp133_ = self->priv->db;
+ _tmp134_ = self->priv->sql;
+ _tmp135_ = rygel_media_export_sql_factory_make (_tmp134_, RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA);
+ _tmp136_ = values;
+ _tmp136__length1 = values_length1;
+ rygel_media_export_database_exec (_tmp133_, _tmp135_, _tmp136_, _tmp136__length1, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ return;
+ }
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+}
+
+
+static void rygel_media_export_media_cache_create_object (RygelMediaExportMediaCache* self, RygelMediaObject* item, GError** error) {
+ gint type;
+ GValue parent = {0};
+ RygelMediaObject* _tmp0_;
+ RygelMediaObject* _tmp1_;
+ RygelMediaContainer* _tmp2_;
+ gchar* _tmp9_ = NULL;
+ RygelMediaObject* _tmp10_;
+ GeeArrayList* _tmp11_;
+ gint _tmp12_;
+ gint _tmp13_;
+ RygelMediaObject* _tmp17_;
+ const gchar* _tmp18_;
+ const gchar* _tmp19_;
+ GValue _tmp20_ = {0};
+ RygelMediaObject* _tmp21_;
+ const gchar* _tmp22_;
+ const gchar* _tmp23_;
+ GValue _tmp24_ = {0};
+ gint _tmp25_;
+ GValue _tmp26_ = {0};
+ GValue _tmp27_;
+ GValue _tmp28_ = {0};
+ RygelMediaObject* _tmp29_;
+ guint64 _tmp30_;
+ guint64 _tmp31_;
+ GValue _tmp32_ = {0};
+ const gchar* _tmp33_;
+ GValue _tmp34_ = {0};
+ GValue* _tmp35_ = NULL;
+ GValue* values;
+ gint values_length1;
+ gint _values_size_;
+ RygelMediaExportDatabase* _tmp36_;
+ RygelMediaExportSQLFactory* _tmp37_;
+ const gchar* _tmp38_ = NULL;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (item != NULL);
+ type = (gint) RYGEL_MEDIA_EXPORT_OBJECT_TYPE_CONTAINER;
+ _tmp0_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, RYGEL_TYPE_MEDIA_ITEM)) {
+ type = (gint) RYGEL_MEDIA_EXPORT_OBJECT_TYPE_ITEM;
+ }
+ _tmp1_ = item;
+ _tmp2_ = _tmp1_->parent;
+ if (_tmp2_ == NULL) {
+ GValue _tmp3_ = {0};
+ rygel_media_export_database_null (&_tmp3_);
+ G_IS_VALUE (&parent) ? (g_value_unset (&parent), NULL) : NULL;
+ parent = _tmp3_;
+ } else {
+ RygelMediaObject* _tmp4_;
+ RygelMediaContainer* _tmp5_;
+ const gchar* _tmp6_;
+ const gchar* _tmp7_;
+ GValue _tmp8_ = {0};
+ _tmp4_ = item;
+ _tmp5_ = _tmp4_->parent;
+ _tmp6_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp5_);
+ _tmp7_ = _tmp6_;
+ g_value_init (&_tmp8_, G_TYPE_STRING);
+ g_value_set_string (&_tmp8_, _tmp7_);
+ G_IS_VALUE (&parent) ? (g_value_unset (&parent), NULL) : NULL;
+ parent = _tmp8_;
+ }
+ _tmp10_ = item;
+ _tmp11_ = _tmp10_->uris;
+ _tmp12_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp11_);
+ _tmp13_ = _tmp12_;
+ if (_tmp13_ == 0) {
+ _g_free0 (_tmp9_);
+ _tmp9_ = NULL;
+ } else {
+ RygelMediaObject* _tmp14_;
+ GeeArrayList* _tmp15_;
+ gpointer _tmp16_ = NULL;
+ _tmp14_ = item;
+ _tmp15_ = _tmp14_->uris;
+ _tmp16_ = gee_abstract_list_get ((GeeAbstractList*) _tmp15_, 0);
+ _g_free0 (_tmp9_);
+ _tmp9_ = (gchar*) _tmp16_;
+ }
+ _tmp17_ = item;
+ _tmp18_ = rygel_media_object_get_id (_tmp17_);
+ _tmp19_ = _tmp18_;
+ g_value_init (&_tmp20_, G_TYPE_STRING);
+ g_value_set_string (&_tmp20_, _tmp19_);
+ _tmp21_ = item;
+ _tmp22_ = rygel_media_object_get_title (_tmp21_);
+ _tmp23_ = _tmp22_;
+ g_value_init (&_tmp24_, G_TYPE_STRING);
+ g_value_set_string (&_tmp24_, _tmp23_);
+ _tmp25_ = type;
+ g_value_init (&_tmp26_, G_TYPE_INT);
+ g_value_set_int (&_tmp26_, _tmp25_);
+ _tmp27_ = parent;
+ if (G_IS_VALUE (&_tmp27_)) {
+ g_value_init (&_tmp28_, G_VALUE_TYPE (&_tmp27_));
+ g_value_copy (&_tmp27_, &_tmp28_);
+ } else {
+ _tmp28_ = _tmp27_;
+ }
+ _tmp29_ = item;
+ _tmp30_ = rygel_media_object_get_modified (_tmp29_);
+ _tmp31_ = _tmp30_;
+ g_value_init (&_tmp32_, G_TYPE_UINT64);
+ g_value_set_uint64 (&_tmp32_, _tmp31_);
+ _tmp33_ = _tmp9_;
+ g_value_init (&_tmp34_, G_TYPE_STRING);
+ g_value_set_string (&_tmp34_, _tmp33_);
+ _tmp35_ = g_new0 (GValue, 6);
+ _tmp35_[0] = _tmp20_;
+ _tmp35_[1] = _tmp24_;
+ _tmp35_[2] = _tmp26_;
+ _tmp35_[3] = _tmp28_;
+ _tmp35_[4] = _tmp32_;
+ _tmp35_[5] = _tmp34_;
+ values = _tmp35_;
+ values_length1 = 6;
+ _values_size_ = values_length1;
+ _tmp36_ = self->priv->db;
+ _tmp37_ = self->priv->sql;
+ _tmp38_ = rygel_media_export_sql_factory_make (_tmp37_, RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT);
+ rygel_media_export_database_exec (_tmp36_, _tmp38_, values, values_length1, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_free0 (_tmp9_);
+ G_IS_VALUE (&parent) ? (g_value_unset (&parent), NULL) : NULL;
+ return;
+ }
+ values = (_vala_GValue_array_free (values, values_length1), NULL);
+ _g_free0 (_tmp9_);
+ G_IS_VALUE (&parent) ? (g_value_unset (&parent), NULL) : NULL;
+}
+
+
+/**
+ * Create the current schema.
+ *
+ * If schema creation fails, schema will be rolled back
+ * completely.
+ *
+ * @returns: true on success, false on failure
+ */
+static gboolean rygel_media_export_media_cache_create_schema (RygelMediaExportMediaCache* self) {
+ gboolean result = FALSE;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, FALSE);
+ {
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportDatabase* _tmp1_;
+ RygelMediaExportSQLFactory* _tmp2_;
+ const gchar* _tmp3_ = NULL;
+ RygelMediaExportDatabase* _tmp4_;
+ RygelMediaExportSQLFactory* _tmp5_;
+ const gchar* _tmp6_ = NULL;
+ RygelMediaExportDatabase* _tmp7_;
+ RygelMediaExportSQLFactory* _tmp8_;
+ const gchar* _tmp9_ = NULL;
+ RygelMediaExportDatabase* _tmp10_;
+ RygelMediaExportSQLFactory* _tmp11_;
+ const gchar* _tmp12_ = NULL;
+ RygelMediaExportDatabase* _tmp13_;
+ RygelMediaExportSQLFactory* _tmp14_;
+ const gchar* _tmp15_ = NULL;
+ RygelMediaExportDatabase* _tmp16_;
+ RygelMediaExportDatabase* _tmp17_;
+ _tmp0_ = self->priv->db;
+ rygel_media_export_database_begin (_tmp0_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch10_g_error;
+ }
+ _tmp1_ = self->priv->db;
+ _tmp2_ = self->priv->sql;
+ _tmp3_ = rygel_media_export_sql_factory_make (_tmp2_, RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA);
+ rygel_media_export_database_exec (_tmp1_, _tmp3_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch10_g_error;
+ }
+ _tmp4_ = self->priv->db;
+ _tmp5_ = self->priv->sql;
+ _tmp6_ = rygel_media_export_sql_factory_make (_tmp5_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON);
+ rygel_media_export_database_exec (_tmp4_, _tmp6_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch10_g_error;
+ }
+ _tmp7_ = self->priv->db;
+ _tmp8_ = self->priv->sql;
+ _tmp9_ = rygel_media_export_sql_factory_make (_tmp8_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE);
+ rygel_media_export_database_exec (_tmp7_, _tmp9_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch10_g_error;
+ }
+ _tmp10_ = self->priv->db;
+ _tmp11_ = self->priv->sql;
+ _tmp12_ = rygel_media_export_sql_factory_make (_tmp11_, RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON);
+ rygel_media_export_database_exec (_tmp10_, _tmp12_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch10_g_error;
+ }
+ _tmp13_ = self->priv->db;
+ _tmp14_ = self->priv->sql;
+ _tmp15_ = rygel_media_export_sql_factory_make (_tmp14_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
+ rygel_media_export_database_exec (_tmp13_, _tmp15_, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch10_g_error;
+ }
+ _tmp16_ = self->priv->db;
+ rygel_media_export_database_commit (_tmp16_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch10_g_error;
+ }
+ _tmp17_ = self->priv->db;
+ rygel_media_export_database_analyze (_tmp17_);
+ result = TRUE;
+ return result;
+ }
+ goto __finally10;
+ __catch10_g_error:
+ {
+ GError* err = NULL;
+ GError* _tmp18_;
+ const gchar* _tmp19_;
+ RygelMediaExportDatabase* _tmp20_;
+ err = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp18_ = err;
+ _tmp19_ = _tmp18_->message;
+ g_warning ("rygel-media-export-media-cache.vala:597: Failed to create schema: %s", _tmp19_);
+ _tmp20_ = self->priv->db;
+ rygel_media_export_database_rollback (_tmp20_);
+ _g_error_free0 (err);
+ }
+ __finally10:
+ if (_inner_error_ != 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 FALSE;
+ }
+ result = FALSE;
+ return result;
+}
+
+
+static RygelMediaObject* rygel_media_export_media_cache_get_object_from_statement (RygelMediaExportMediaCache* self, RygelMediaContainer* parent, sqlite3_stmt* statement) {
+ RygelMediaObject* result = NULL;
+ RygelMediaObject* object;
+ sqlite3_stmt* _tmp0_;
+ const gchar* _tmp1_ = NULL;
+ const gchar* title;
+ sqlite3_stmt* _tmp2_;
+ const gchar* _tmp3_ = NULL;
+ const gchar* object_id;
+ sqlite3_stmt* _tmp4_;
+ const gchar* _tmp5_ = NULL;
+ const gchar* uri;
+ sqlite3_stmt* _tmp6_;
+ gint _tmp7_ = 0;
+ RygelMediaObject* _tmp32_;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (statement != NULL, NULL);
+ object = NULL;
+ _tmp0_ = statement;
+ _tmp1_ = sqlite3_column_text (_tmp0_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TITLE);
+ title = _tmp1_;
+ _tmp2_ = statement;
+ _tmp3_ = sqlite3_column_text (_tmp2_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID);
+ object_id = _tmp3_;
+ _tmp4_ = statement;
+ _tmp5_ = sqlite3_column_text (_tmp4_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_URI);
+ uri = _tmp5_;
+ _tmp6_ = statement;
+ _tmp7_ = sqlite3_column_int (_tmp6_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TYPE);
+ switch (_tmp7_) {
+ case 0:
+ {
+ RygelMediaExportObjectFactory* _tmp8_;
+ const gchar* _tmp9_;
+ const gchar* _tmp10_;
+ const gchar* _tmp11_;
+ RygelMediaExportDBContainer* _tmp12_ = NULL;
+ RygelMediaObject* _tmp13_;
+ RygelMediaContainer* _tmp14_;
+ RygelMediaContainer* container;
+ const gchar* _tmp15_;
+ _tmp8_ = self->priv->factory;
+ _tmp9_ = object_id;
+ _tmp10_ = title;
+ _tmp11_ = uri;
+ _tmp12_ = rygel_media_export_object_factory_get_container (_tmp8_, self, _tmp9_, _tmp10_, (guint) 0, _tmp11_);
+ _g_object_unref0 (object);
+ object = (RygelMediaObject*) _tmp12_;
+ _tmp13_ = object;
+ _tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp13_) : NULL);
+ container = _tmp14_;
+ _tmp15_ = uri;
+ if (_tmp15_ != NULL) {
+ RygelMediaContainer* _tmp16_;
+ GeeArrayList* _tmp17_;
+ const gchar* _tmp18_;
+ _tmp16_ = container;
+ _tmp17_ = ((RygelMediaObject*) _tmp16_)->uris;
+ _tmp18_ = uri;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp18_);
+ }
+ _g_object_unref0 (container);
+ break;
+ }
+ case 1:
+ {
+ sqlite3_stmt* _tmp19_;
+ const gchar* _tmp20_ = NULL;
+ const gchar* upnp_class;
+ RygelMediaExportObjectFactory* _tmp21_;
+ RygelMediaContainer* _tmp22_;
+ const gchar* _tmp23_;
+ const gchar* _tmp24_;
+ const gchar* _tmp25_;
+ RygelMediaItem* _tmp26_ = NULL;
+ sqlite3_stmt* _tmp27_;
+ RygelMediaObject* _tmp28_;
+ const gchar* _tmp29_;
+ _tmp19_ = statement;
+ _tmp20_ = sqlite3_column_text (_tmp19_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CLASS);
+ upnp_class = _tmp20_;
+ _tmp21_ = self->priv->factory;
+ _tmp22_ = parent;
+ _tmp23_ = object_id;
+ _tmp24_ = title;
+ _tmp25_ = upnp_class;
+ _tmp26_ = rygel_media_export_object_factory_get_item (_tmp21_, self, _tmp22_, _tmp23_, _tmp24_, _tmp25_);
+ _g_object_unref0 (object);
+ object = (RygelMediaObject*) _tmp26_;
+ _tmp27_ = statement;
+ _tmp28_ = object;
+ rygel_media_export_media_cache_fill_item (self, _tmp27_, G_TYPE_CHECK_INSTANCE_TYPE (_tmp28_, RYGEL_TYPE_MEDIA_ITEM) ? ((RygelMediaItem*) _tmp28_) : NULL);
+ _tmp29_ = uri;
+ if (_tmp29_ != NULL) {
+ RygelMediaObject* _tmp30_;
+ const gchar* _tmp31_;
+ _tmp30_ = object;
+ _tmp31_ = uri;
+ rygel_media_item_add_uri (G_TYPE_CHECK_INSTANCE_TYPE (_tmp30_, RYGEL_TYPE_MEDIA_ITEM) ? ((RygelMediaItem*) _tmp30_) : NULL, _tmp31_);
+ }
+ break;
+ }
+ default:
+ {
+ g_assert_not_reached ();
+ }
+ }
+ _tmp32_ = object;
+ if (_tmp32_ != NULL) {
+ RygelMediaObject* _tmp33_;
+ sqlite3_stmt* _tmp34_;
+ gint64 _tmp35_ = 0LL;
+ gboolean _tmp36_ = FALSE;
+ RygelMediaObject* _tmp37_;
+ guint64 _tmp38_;
+ guint64 _tmp39_;
+ gint64 _tmp40_;
+ gboolean _tmp42_;
+ _tmp33_ = object;
+ _tmp34_ = statement;
+ _tmp35_ = sqlite3_column_int64 (_tmp34_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TIMESTAMP);
+ rygel_media_object_set_modified (_tmp33_, (guint64) _tmp35_);
+ _tmp37_ = object;
+ _tmp38_ = rygel_media_object_get_modified (_tmp37_);
+ _tmp39_ = _tmp38_;
+ _tmp40_ = G_MAXINT64;
+ if (_tmp39_ == ((guint64) _tmp40_)) {
+ RygelMediaObject* _tmp41_;
+ _tmp41_ = object;
+ _tmp36_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp41_, RYGEL_TYPE_MEDIA_ITEM);
+ } else {
+ _tmp36_ = FALSE;
+ }
+ _tmp42_ = _tmp36_;
+ if (_tmp42_) {
+ RygelMediaObject* _tmp43_;
+ RygelMediaObject* _tmp44_;
+ _tmp43_ = object;
+ rygel_media_object_set_modified (_tmp43_, (guint64) 0);
+ _tmp44_ = object;
+ rygel_media_item_set_place_holder (G_TYPE_CHECK_INSTANCE_TYPE (_tmp44_, RYGEL_TYPE_MEDIA_ITEM) ? ((RygelMediaItem*) _tmp44_) : NULL, TRUE);
+ }
+ }
+ result = object;
+ return result;
+}
+
+
+static void rygel_media_export_media_cache_fill_item (RygelMediaExportMediaCache* self, sqlite3_stmt* statement, RygelMediaItem* item) {
+ RygelMediaItem* _tmp0_;
+ sqlite3_stmt* _tmp1_;
+ const gchar* _tmp2_ = NULL;
+ RygelMediaItem* _tmp3_;
+ sqlite3_stmt* _tmp4_;
+ const gchar* _tmp5_ = NULL;
+ RygelMediaItem* _tmp6_;
+ sqlite3_stmt* _tmp7_;
+ const gchar* _tmp8_ = NULL;
+ RygelMediaItem* _tmp9_;
+ sqlite3_stmt* _tmp10_;
+ gint64 _tmp11_ = 0LL;
+ RygelMediaItem* _tmp12_;
+ RygelMediaItem* _tmp46_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (statement != NULL);
+ g_return_if_fail (item != NULL);
+ _tmp0_ = item;
+ _tmp1_ = statement;
+ _tmp2_ = sqlite3_column_text (_tmp1_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DATE);
+ rygel_media_item_set_date (_tmp0_, _tmp2_);
+ _tmp3_ = item;
+ _tmp4_ = statement;
+ _tmp5_ = sqlite3_column_text (_tmp4_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_MIME_TYPE);
+ rygel_media_item_set_mime_type (_tmp3_, _tmp5_);
+ _tmp6_ = item;
+ _tmp7_ = statement;
+ _tmp8_ = sqlite3_column_text (_tmp7_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DLNA_PROFILE);
+ rygel_media_item_set_dlna_profile (_tmp6_, _tmp8_);
+ _tmp9_ = item;
+ _tmp10_ = statement;
+ _tmp11_ = sqlite3_column_int64 (_tmp10_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SIZE);
+ rygel_media_item_set_size (_tmp9_, _tmp11_);
+ _tmp12_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp12_, RYGEL_TYPE_AUDIO_ITEM)) {
+ RygelMediaItem* _tmp13_;
+ RygelAudioItem* _tmp14_;
+ RygelAudioItem* audio_item;
+ RygelAudioItem* _tmp15_;
+ sqlite3_stmt* _tmp16_;
+ gint64 _tmp17_ = 0LL;
+ RygelAudioItem* _tmp18_;
+ sqlite3_stmt* _tmp19_;
+ gint _tmp20_ = 0;
+ RygelAudioItem* _tmp21_;
+ sqlite3_stmt* _tmp22_;
+ gint _tmp23_ = 0;
+ RygelAudioItem* _tmp24_;
+ sqlite3_stmt* _tmp25_;
+ gint _tmp26_ = 0;
+ RygelAudioItem* _tmp27_;
+ sqlite3_stmt* _tmp28_;
+ gint _tmp29_ = 0;
+ RygelMediaItem* _tmp30_;
+ _tmp13_ = item;
+ _tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, RYGEL_TYPE_AUDIO_ITEM) ? ((RygelAudioItem*) _tmp13_) : NULL);
+ audio_item = _tmp14_;
+ _tmp15_ = audio_item;
+ _tmp16_ = statement;
+ _tmp17_ = sqlite3_column_int64 (_tmp16_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DURATION);
+ rygel_audio_item_set_duration (_tmp15_, (glong) _tmp17_);
+ _tmp18_ = audio_item;
+ _tmp19_ = statement;
+ _tmp20_ = sqlite3_column_int (_tmp19_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITRATE);
+ rygel_audio_item_set_bitrate (_tmp18_, _tmp20_);
+ _tmp21_ = audio_item;
+ _tmp22_ = statement;
+ _tmp23_ = sqlite3_column_int (_tmp22_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SAMPLE_FREQ);
+ rygel_audio_item_set_sample_freq (_tmp21_, _tmp23_);
+ _tmp24_ = audio_item;
+ _tmp25_ = statement;
+ _tmp26_ = sqlite3_column_int (_tmp25_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITS_PER_SAMPLE);
+ rygel_audio_item_set_bits_per_sample (_tmp24_, _tmp26_);
+ _tmp27_ = audio_item;
+ _tmp28_ = statement;
+ _tmp29_ = sqlite3_column_int (_tmp28_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CHANNELS);
+ rygel_audio_item_set_channels (_tmp27_, _tmp29_);
+ _tmp30_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp30_, RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM)) {
+ RygelMediaItem* _tmp31_;
+ RygelMediaExportMusicItem* _tmp32_;
+ RygelMediaExportMusicItem* music_item;
+ RygelMediaExportMusicItem* _tmp33_;
+ sqlite3_stmt* _tmp34_;
+ const gchar* _tmp35_ = NULL;
+ RygelMediaExportMusicItem* _tmp36_;
+ sqlite3_stmt* _tmp37_;
+ const gchar* _tmp38_ = NULL;
+ RygelMediaExportMusicItem* _tmp39_;
+ sqlite3_stmt* _tmp40_;
+ const gchar* _tmp41_ = NULL;
+ RygelMediaExportMusicItem* _tmp42_;
+ sqlite3_stmt* _tmp43_;
+ gint _tmp44_ = 0;
+ RygelMediaExportMusicItem* _tmp45_;
+ _tmp31_ = item;
+ _tmp32_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp31_, RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM) ? ((RygelMediaExportMusicItem*) _tmp31_) : NULL);
+ music_item = _tmp32_;
+ _tmp33_ = music_item;
+ _tmp34_ = statement;
+ _tmp35_ = sqlite3_column_text (_tmp34_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR);
+ rygel_music_item_set_artist ((RygelMusicItem*) _tmp33_, _tmp35_);
+ _tmp36_ = music_item;
+ _tmp37_ = statement;
+ _tmp38_ = sqlite3_column_text (_tmp37_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ALBUM);
+ rygel_music_item_set_album ((RygelMusicItem*) _tmp36_, _tmp38_);
+ _tmp39_ = music_item;
+ _tmp40_ = statement;
+ _tmp41_ = sqlite3_column_text (_tmp40_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_GENRE);
+ rygel_music_item_set_genre ((RygelMusicItem*) _tmp39_, _tmp41_);
+ _tmp42_ = music_item;
+ _tmp43_ = statement;
+ _tmp44_ = sqlite3_column_int (_tmp43_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TRACK);
+ rygel_music_item_set_track_number ((RygelMusicItem*) _tmp42_, _tmp44_);
+ _tmp45_ = music_item;
+ rygel_music_item_lookup_album_art ((RygelMusicItem*) _tmp45_);
+ _g_object_unref0 (music_item);
+ }
+ _g_object_unref0 (audio_item);
+ }
+ _tmp46_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp46_, RYGEL_TYPE_VISUAL_ITEM)) {
+ RygelMediaItem* _tmp47_;
+ RygelVisualItem* _tmp48_;
+ RygelVisualItem* visual_item;
+ RygelVisualItem* _tmp49_;
+ sqlite3_stmt* _tmp50_;
+ gint _tmp51_ = 0;
+ RygelVisualItem* _tmp52_;
+ sqlite3_stmt* _tmp53_;
+ gint _tmp54_ = 0;
+ RygelVisualItem* _tmp55_;
+ sqlite3_stmt* _tmp56_;
+ gint _tmp57_ = 0;
+ RygelMediaItem* _tmp58_;
+ _tmp47_ = item;
+ _tmp48_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp47_, RYGEL_TYPE_VISUAL_ITEM) ? ((RygelVisualItem*) _tmp47_) : NULL);
+ visual_item = _tmp48_;
+ _tmp49_ = visual_item;
+ _tmp50_ = statement;
+ _tmp51_ = sqlite3_column_int (_tmp50_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_WIDTH);
+ rygel_visual_item_set_width (_tmp49_, _tmp51_);
+ _tmp52_ = visual_item;
+ _tmp53_ = statement;
+ _tmp54_ = sqlite3_column_int (_tmp53_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_HEIGHT);
+ rygel_visual_item_set_height (_tmp52_, _tmp54_);
+ _tmp55_ = visual_item;
+ _tmp56_ = statement;
+ _tmp57_ = sqlite3_column_int (_tmp56_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_COLOR_DEPTH);
+ rygel_visual_item_set_color_depth (_tmp55_, _tmp57_);
+ _tmp58_ = item;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp58_, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM)) {
+ RygelMediaItem* _tmp59_;
+ RygelMediaExportVideoItem* _tmp60_;
+ RygelMediaExportVideoItem* video_item;
+ RygelMediaExportVideoItem* _tmp61_;
+ sqlite3_stmt* _tmp62_;
+ const gchar* _tmp63_ = NULL;
+ _tmp59_ = item;
+ _tmp60_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp59_, RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM) ? ((RygelMediaExportVideoItem*) _tmp59_) : NULL);
+ video_item = _tmp60_;
+ _tmp61_ = video_item;
+ _tmp62_ = statement;
+ _tmp63_ = sqlite3_column_text (_tmp62_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR);
+ rygel_video_item_set_author ((RygelVideoItem*) _tmp61_, _tmp63_);
+ _g_object_unref0 (video_item);
+ }
+ _g_object_unref0 (visual_item);
+ }
+}
+
+
+static gchar* rygel_media_export_media_cache_translate_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, GValueArray* args, const gchar* prefix, GError** error) {
+ gchar* result = NULL;
+ RygelSearchExpression* _tmp0_;
+ RygelSearchExpression* _tmp2_;
+ GValueArray* _tmp3_;
+ gchar* _tmp4_ = NULL;
+ gchar* filter;
+ const gchar* _tmp5_;
+ const gchar* _tmp6_;
+ gchar* _tmp7_ = NULL;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (args != NULL, NULL);
+ g_return_val_if_fail (prefix != NULL, NULL);
+ _tmp0_ = expression;
+ if (_tmp0_ == NULL) {
+ gchar* _tmp1_;
+ _tmp1_ = g_strdup ("");
+ result = _tmp1_;
+ return result;
+ }
+ _tmp2_ = expression;
+ _tmp3_ = args;
+ _tmp4_ = rygel_media_export_media_cache_search_expression_to_sql (self, _tmp2_, _tmp3_, &_inner_error_);
+ filter = _tmp4_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ }
+ _tmp5_ = prefix;
+ _tmp6_ = filter;
+ _tmp7_ = g_strdup_printf (" %s %s", _tmp5_, _tmp6_);
+ result = _tmp7_;
+ _g_free0 (filter);
+ return result;
+}
+
+
+static gchar* rygel_media_export_media_cache_search_expression_to_sql (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, GValueArray* args, GError** error) {
+ gchar* result = NULL;
+ RygelSearchExpression* _tmp0_;
+ RygelSearchExpression* _tmp2_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (args != NULL, NULL);
+ _tmp0_ = expression;
+ if (_tmp0_ == NULL) {
+ gchar* _tmp1_;
+ _tmp1_ = g_strdup ("");
+ result = _tmp1_;
+ return result;
+ }
+ _tmp2_ = expression;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, RYGEL_TYPE_LOGICAL_EXPRESSION)) {
+ RygelSearchExpression* _tmp3_;
+ GValueArray* _tmp4_;
+ gchar* _tmp5_ = NULL;
+ gchar* _tmp6_;
+ _tmp3_ = expression;
+ _tmp4_ = args;
+ _tmp5_ = rygel_media_export_media_cache_logical_expression_to_sql (self, G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, RYGEL_TYPE_LOGICAL_EXPRESSION) ? ((RygelLogicalExpression*) _tmp3_) : NULL, _tmp4_, &_inner_error_);
+ _tmp6_ = _tmp5_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ }
+ result = _tmp6_;
+ return result;
+ } else {
+ RygelSearchExpression* _tmp7_;
+ GValueArray* _tmp8_;
+ gchar* _tmp9_ = NULL;
+ gchar* _tmp10_;
+ _tmp7_ = expression;
+ _tmp8_ = args;
+ _tmp9_ = rygel_media_export_media_cache_relational_expression_to_sql (self, G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, RYGEL_TYPE_RELATIONAL_EXPRESSION) ? ((RygelRelationalExpression*) _tmp7_) : NULL, _tmp8_, &_inner_error_);
+ _tmp10_ = _tmp9_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ }
+ result = _tmp10_;
+ return result;
+ }
+}
+
+
+static gchar* rygel_media_export_media_cache_logical_expression_to_sql (RygelMediaExportMediaCache* self, RygelLogicalExpression* expression, GValueArray* args, GError** error) {
+ gchar* result = NULL;
+ RygelLogicalExpression* _tmp0_;
+ gconstpointer _tmp1_;
+ GValueArray* _tmp2_;
+ gchar* _tmp3_ = NULL;
+ gchar* left_sql_string;
+ RygelLogicalExpression* _tmp4_;
+ gconstpointer _tmp5_;
+ GValueArray* _tmp6_;
+ gchar* _tmp7_ = NULL;
+ gchar* right_sql_string;
+ gchar* _tmp8_;
+ gchar* operator_sql_string;
+ RygelLogicalExpression* _tmp9_;
+ gconstpointer _tmp10_;
+ const gchar* _tmp12_;
+ const gchar* _tmp13_;
+ const gchar* _tmp14_;
+ gchar* _tmp15_ = NULL;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (args != NULL, NULL);
+ _tmp0_ = expression;
+ _tmp1_ = ((RygelSearchExpression*) _tmp0_)->operand1;
+ _tmp2_ = args;
+ _tmp3_ = rygel_media_export_media_cache_search_expression_to_sql (self, (RygelSearchExpression*) _tmp1_, _tmp2_, &_inner_error_);
+ left_sql_string = _tmp3_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ }
+ _tmp4_ = expression;
+ _tmp5_ = ((RygelSearchExpression*) _tmp4_)->operand2;
+ _tmp6_ = args;
+ _tmp7_ = rygel_media_export_media_cache_search_expression_to_sql (self, (RygelSearchExpression*) _tmp5_, _tmp6_, &_inner_error_);
+ right_sql_string = _tmp7_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (left_sql_string);
+ return NULL;
+ }
+ _tmp8_ = g_strdup ("OR");
+ operator_sql_string = _tmp8_;
+ _tmp9_ = expression;
+ _tmp10_ = ((RygelSearchExpression*) _tmp9_)->op;
+ if (((RygelLogicalOperator) ((gintptr) _tmp10_)) == RYGEL_LOGICAL_OPERATOR_AND) {
+ gchar* _tmp11_;
+ _tmp11_ = g_strdup ("AND");
+ _g_free0 (operator_sql_string);
+ operator_sql_string = _tmp11_;
+ }
+ _tmp12_ = left_sql_string;
+ _tmp13_ = operator_sql_string;
+ _tmp14_ = right_sql_string;
+ _tmp15_ = g_strdup_printf ("(%s %s %s)", _tmp12_, _tmp13_, _tmp14_);
+ result = _tmp15_;
+ _g_free0 (operator_sql_string);
+ _g_free0 (right_sql_string);
+ _g_free0 (left_sql_string);
+ return result;
+}
+
+
+static gchar* rygel_media_export_media_cache_map_operand_to_column (RygelMediaExportMediaCache* self, const gchar* operand, gchar** collate, GError** error) {
+ gchar* _vala_collate = NULL;
+ gchar* result = NULL;
+ gchar* column;
+ gboolean use_collation;
+ const gchar* _tmp0_;
+ const gchar* _tmp1_;
+ GQuark _tmp3_ = 0U;
+ static GQuark _tmp2_label0 = 0;
+ static GQuark _tmp2_label1 = 0;
+ static GQuark _tmp2_label2 = 0;
+ static GQuark _tmp2_label3 = 0;
+ static GQuark _tmp2_label4 = 0;
+ static GQuark _tmp2_label5 = 0;
+ static GQuark _tmp2_label6 = 0;
+ static GQuark _tmp2_label7 = 0;
+ static GQuark _tmp2_label8 = 0;
+ static GQuark _tmp2_label9 = 0;
+ static GQuark _tmp2_label10 = 0;
+ static GQuark _tmp2_label11 = 0;
+ static GQuark _tmp2_label12 = 0;
+ static GQuark _tmp2_label13 = 0;
+ static GQuark _tmp2_label14 = 0;
+ gboolean _tmp21_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (operand != NULL, NULL);
+ column = NULL;
+ use_collation = FALSE;
+ _tmp0_ = operand;
+ _tmp1_ = _tmp0_;
+ _tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
+ if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("res")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp4_;
+ _tmp4_ = g_strdup ("o.uri");
+ _g_free0 (column);
+ column = _tmp4_;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("res duration")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp5_;
+ _tmp5_ = g_strdup ("m.duration");
+ _g_free0 (column);
+ column = _tmp5_;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("@refID")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp6_;
+ _tmp6_ = g_strdup ("NULL");
+ _g_free0 (column);
+ column = _tmp6_;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("@id")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp7_;
+ _tmp7_ = g_strdup ("o.upnp_id");
+ _g_free0 (column);
+ column = _tmp7_;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("@parentID")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp8_;
+ _tmp8_ = g_strdup ("o.parent");
+ _g_free0 (column);
+ column = _tmp8_;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("upnp:class")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp9_;
+ _tmp9_ = g_strdup ("m.class");
+ _g_free0 (column);
+ column = _tmp9_;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label6) ? _tmp2_label6 : (_tmp2_label6 = g_quark_from_static_string ("dc:title")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp10_;
+ _tmp10_ = g_strdup ("o.title");
+ _g_free0 (column);
+ column = _tmp10_;
+ use_collation = TRUE;
+ break;
+ }
+ }
+ } else if ((_tmp3_ == ((0 != _tmp2_label7) ? _tmp2_label7 : (_tmp2_label7 = g_quark_from_static_string ("upnp:artist")))) || (_tmp3_ == ((0 != _tmp2_label8) ? _tmp2_label8 : (_tmp2_label8 = g_quark_from_static_string ("dc:creator"))))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp11_;
+ _tmp11_ = g_strdup ("m.author");
+ _g_free0 (column);
+ column = _tmp11_;
+ use_collation = TRUE;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label9) ? _tmp2_label9 : (_tmp2_label9 = g_quark_from_static_string ("dc:date")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp12_;
+ _tmp12_ = g_strdup ("strftime(\"%Y\", m.date)");
+ _g_free0 (column);
+ column = _tmp12_;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label10) ? _tmp2_label10 : (_tmp2_label10 = g_quark_from_static_string ("upnp:album")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp13_;
+ _tmp13_ = g_strdup ("m.album");
+ _g_free0 (column);
+ column = _tmp13_;
+ use_collation = TRUE;
+ break;
+ }
+ }
+ } else if ((_tmp3_ == ((0 != _tmp2_label11) ? _tmp2_label11 : (_tmp2_label11 = g_quark_from_static_string ("upnp:genre")))) || (_tmp3_ == ((0 != _tmp2_label12) ? _tmp2_label12 : (_tmp2_label12 = g_quark_from_static_string ("dc:genre"))))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp14_;
+ _tmp14_ = g_strdup ("m.genre");
+ _g_free0 (column);
+ column = _tmp14_;
+ use_collation = TRUE;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label13) ? _tmp2_label13 : (_tmp2_label13 = g_quark_from_static_string ("upnp:originalTrackNumber")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp15_;
+ _tmp15_ = g_strdup ("m.track");
+ _g_free0 (column);
+ column = _tmp15_;
+ break;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label14) ? _tmp2_label14 : (_tmp2_label14 = g_quark_from_static_string ("rygel:originalVolumeNumber")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp16_;
+ _tmp16_ = g_strdup ("m.disc");
+ _g_free0 (column);
+ column = _tmp16_;
+ break;
+ }
+ }
+ } else {
+ switch (0) {
+ default:
+ {
+ const gchar* _tmp17_;
+ gchar* _tmp18_ = NULL;
+ gchar* message;
+ const gchar* _tmp19_;
+ GError* _tmp20_;
+ _tmp17_ = operand;
+ _tmp18_ = g_strdup_printf ("Unsupported column %s", _tmp17_);
+ message = _tmp18_;
+ _tmp19_ = message;
+ _tmp20_ = g_error_new_literal (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH, _tmp19_);
+ _inner_error_ = _tmp20_;
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (message);
+ _g_free0 (column);
+ return NULL;
+ }
+ }
+ }
+ _tmp21_ = use_collation;
+ if (_tmp21_) {
+ gchar* _tmp22_;
+ _tmp22_ = g_strdup ("COLLATE CASEFOLD");
+ _g_free0 (_vala_collate);
+ _vala_collate = _tmp22_;
+ } else {
+ gchar* _tmp23_;
+ _tmp23_ = g_strdup ("");
+ _g_free0 (_vala_collate);
+ _vala_collate = _tmp23_;
+ }
+ result = column;
+ if (collate) {
+ *collate = _vala_collate;
+ } else {
+ _g_free0 (_vala_collate);
+ }
+ return result;
+}
+
+
+static gchar* rygel_media_export_media_cache_relational_expression_to_sql (RygelMediaExportMediaCache* self, RygelRelationalExpression* exp, GValueArray* args, GError** error) {
+ gchar* result = NULL;
+ GValue* v;
+ gchar* collate;
+ RygelRelationalExpression* _tmp0_;
+ gconstpointer _tmp1_;
+ gchar* _tmp2_ = NULL;
+ gchar* _tmp3_ = NULL;
+ gchar* column;
+ RygelMediaExportSqlOperator* operator = NULL;
+ RygelRelationalExpression* _tmp4_;
+ gconstpointer _tmp5_;
+ GValue* _tmp40_;
+ RygelMediaExportSqlOperator* _tmp44_;
+ gchar* _tmp45_ = NULL;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (args != NULL, NULL);
+ v = NULL;
+ collate = NULL;
+ _tmp0_ = exp;
+ _tmp1_ = ((RygelSearchExpression*) _tmp0_)->operand1;
+ _tmp3_ = rygel_media_export_media_cache_map_operand_to_column (self, (const gchar*) _tmp1_, &_tmp2_, &_inner_error_);
+ _g_free0 (collate);
+ collate = _tmp2_;
+ column = _tmp3_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (collate);
+ __vala_GValue_free0 (v);
+ return NULL;
+ }
+ _tmp4_ = exp;
+ _tmp5_ = ((RygelSearchExpression*) _tmp4_)->op;
+ switch ((GUPnPSearchCriteriaOp) ((gintptr) _tmp5_)) {
+ case GUPNP_SEARCH_CRITERIA_OP_EXISTS:
+ {
+ gchar* sql_function = NULL;
+ RygelRelationalExpression* _tmp6_;
+ gconstpointer _tmp7_;
+ const gchar* _tmp10_;
+ const gchar* _tmp11_;
+ const gchar* _tmp12_;
+ gchar* _tmp13_ = NULL;
+ _tmp6_ = exp;
+ _tmp7_ = ((RygelSearchExpression*) _tmp6_)->operand2;
+ if (g_strcmp0 ((const gchar*) _tmp7_, "true") == 0) {
+ gchar* _tmp8_;
+ _tmp8_ = g_strdup ("%s IS NOT NULL AND %s != ''");
+ _g_free0 (sql_function);
+ sql_function = _tmp8_;
+ } else {
+ gchar* _tmp9_;
+ _tmp9_ = g_strdup ("%s IS NULL OR %s = ''");
+ _g_free0 (sql_function);
+ sql_function = _tmp9_;
+ }
+ _tmp10_ = sql_function;
+ _tmp11_ = column;
+ _tmp12_ = column;
+ _tmp13_ = g_strdup_printf (_tmp10_, _tmp11_, _tmp12_);
+ result = _tmp13_;
+ _g_free0 (sql_function);
+ _g_object_unref0 (operator);
+ _g_free0 (column);
+ _g_free0 (collate);
+ __vala_GValue_free0 (v);
+ return result;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_EQ:
+ case GUPNP_SEARCH_CRITERIA_OP_NEQ:
+ case GUPNP_SEARCH_CRITERIA_OP_LESS:
+ case GUPNP_SEARCH_CRITERIA_OP_LEQ:
+ case GUPNP_SEARCH_CRITERIA_OP_GREATER:
+ case GUPNP_SEARCH_CRITERIA_OP_GEQ:
+ {
+ RygelRelationalExpression* _tmp14_;
+ gconstpointer _tmp15_;
+ GValue* _tmp16_ = NULL;
+ RygelRelationalExpression* _tmp17_;
+ gconstpointer _tmp18_;
+ const gchar* _tmp19_;
+ const gchar* _tmp20_;
+ RygelMediaExportSqlOperator* _tmp21_;
+ _tmp14_ = exp;
+ _tmp15_ = ((RygelSearchExpression*) _tmp14_)->operand2;
+ _tmp16_ = g_new0 (GValue, 1);
+ g_value_init (_tmp16_, G_TYPE_STRING);
+ g_value_set_string (_tmp16_, (const gchar*) _tmp15_);
+ __vala_GValue_free0 (v);
+ v = _tmp16_;
+ _tmp17_ = exp;
+ _tmp18_ = ((RygelSearchExpression*) _tmp17_)->op;
+ _tmp19_ = column;
+ _tmp20_ = collate;
+ _tmp21_ = rygel_media_export_sql_operator_new_from_search_criteria_op ((GUPnPSearchCriteriaOp) ((gintptr) _tmp18_), _tmp19_, _tmp20_);
+ _g_object_unref0 (operator);
+ operator = _tmp21_;
+ break;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_CONTAINS:
+ {
+ const gchar* _tmp22_;
+ RygelMediaExportSqlFunction* _tmp23_;
+ RygelRelationalExpression* _tmp24_;
+ gconstpointer _tmp25_;
+ GValue* _tmp26_ = NULL;
+ _tmp22_ = column;
+ _tmp23_ = rygel_media_export_sql_function_new ("contains", _tmp22_);
+ _g_object_unref0 (operator);
+ operator = (RygelMediaExportSqlOperator*) _tmp23_;
+ _tmp24_ = exp;
+ _tmp25_ = ((RygelSearchExpression*) _tmp24_)->operand2;
+ _tmp26_ = g_new0 (GValue, 1);
+ g_value_init (_tmp26_, G_TYPE_STRING);
+ g_value_set_string (_tmp26_, (const gchar*) _tmp25_);
+ __vala_GValue_free0 (v);
+ v = _tmp26_;
+ break;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_DOES_NOT_CONTAIN:
+ {
+ const gchar* _tmp27_;
+ RygelMediaExportSqlFunction* _tmp28_;
+ RygelRelationalExpression* _tmp29_;
+ gconstpointer _tmp30_;
+ GValue* _tmp31_ = NULL;
+ _tmp27_ = column;
+ _tmp28_ = rygel_media_export_sql_function_new ("NOT contains", _tmp27_);
+ _g_object_unref0 (operator);
+ operator = (RygelMediaExportSqlOperator*) _tmp28_;
+ _tmp29_ = exp;
+ _tmp30_ = ((RygelSearchExpression*) _tmp29_)->operand2;
+ _tmp31_ = g_new0 (GValue, 1);
+ g_value_init (_tmp31_, G_TYPE_STRING);
+ g_value_set_string (_tmp31_, (const gchar*) _tmp30_);
+ __vala_GValue_free0 (v);
+ v = _tmp31_;
+ break;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_DERIVED_FROM:
+ {
+ const gchar* _tmp32_;
+ RygelMediaExportSqlOperator* _tmp33_;
+ RygelRelationalExpression* _tmp34_;
+ gconstpointer _tmp35_;
+ gchar* _tmp36_ = NULL;
+ GValue* _tmp37_ = NULL;
+ _tmp32_ = column;
+ _tmp33_ = rygel_media_export_sql_operator_new ("LIKE", _tmp32_, "");
+ _g_object_unref0 (operator);
+ operator = _tmp33_;
+ _tmp34_ = exp;
+ _tmp35_ = ((RygelSearchExpression*) _tmp34_)->operand2;
+ _tmp36_ = g_strdup_printf ("%s%%", (const gchar*) _tmp35_);
+ _tmp37_ = g_new0 (GValue, 1);
+ g_value_init (_tmp37_, G_TYPE_STRING);
+ g_value_take_string (_tmp37_, _tmp36_);
+ __vala_GValue_free0 (v);
+ v = _tmp37_;
+ break;
+ }
+ default:
+ {
+ RygelRelationalExpression* _tmp38_;
+ gconstpointer _tmp39_;
+ _tmp38_ = exp;
+ _tmp39_ = ((RygelSearchExpression*) _tmp38_)->op;
+ g_warning ("rygel-media-export-media-cache.vala:851: Unsupported op %d", (gint) ((GUPnPSearchCriteriaOp) ((gintptr) _tmp39_)));
+ result = NULL;
+ _g_object_unref0 (operator);
+ _g_free0 (column);
+ _g_free0 (collate);
+ __vala_GValue_free0 (v);
+ return result;
+ }
+ }
+ _tmp40_ = v;
+ if (_tmp40_ != NULL) {
+ GValueArray* _tmp41_;
+ GValue* _tmp42_;
+ GValue _tmp43_;
+ _tmp41_ = args;
+ _tmp42_ = v;
+ _tmp43_ = *_tmp42_;
+ g_value_array_append (_tmp41_, &_tmp43_);
+ }
+ _tmp44_ = operator;
+ _tmp45_ = rygel_media_export_sql_operator_to_string (_tmp44_);
+ result = _tmp45_;
+ _g_object_unref0 (operator);
+ _g_free0 (column);
+ _g_free0 (collate);
+ __vala_GValue_free0 (v);
+ return result;
+}
+
+
+static RygelMediaExportDatabaseCursor* rygel_media_export_media_cache_exec_cursor (RygelMediaExportMediaCache* self, RygelMediaExportSQLString id, GValue* values, int values_length1, GError** error) {
+ RygelMediaExportDatabaseCursor* result = NULL;
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportSQLFactory* _tmp1_;
+ RygelMediaExportSQLString _tmp2_;
+ const gchar* _tmp3_ = NULL;
+ GValue* _tmp4_;
+ gint _tmp4__length1;
+ RygelMediaExportDatabaseCursor* _tmp5_ = NULL;
+ RygelMediaExportDatabaseCursor* _tmp6_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = self->priv->db;
+ _tmp1_ = self->priv->sql;
+ _tmp2_ = id;
+ _tmp3_ = rygel_media_export_sql_factory_make (_tmp1_, _tmp2_);
+ _tmp4_ = values;
+ _tmp4__length1 = values_length1;
+ _tmp5_ = rygel_media_export_database_exec_cursor (_tmp0_, _tmp3_, _tmp4_, _tmp4__length1, &_inner_error_);
+ _tmp6_ = _tmp5_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ } else {
+ 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;
+ }
+ }
+ result = _tmp6_;
+ return result;
+}
+
+
+static gint rygel_media_export_media_cache_query_value (RygelMediaExportMediaCache* self, RygelMediaExportSQLString id, GValue* values, int values_length1, GError** error) {
+ gint result = 0;
+ RygelMediaExportDatabase* _tmp0_;
+ RygelMediaExportSQLFactory* _tmp1_;
+ RygelMediaExportSQLString _tmp2_;
+ const gchar* _tmp3_ = NULL;
+ GValue* _tmp4_;
+ gint _tmp4__length1;
+ gint _tmp5_ = 0;
+ gint _tmp6_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, 0);
+ _tmp0_ = self->priv->db;
+ _tmp1_ = self->priv->sql;
+ _tmp2_ = id;
+ _tmp3_ = rygel_media_export_sql_factory_make (_tmp1_, _tmp2_);
+ _tmp4_ = values;
+ _tmp4__length1 = values_length1;
+ _tmp5_ = rygel_media_export_database_query_value (_tmp0_, _tmp3_, _tmp4_, _tmp4__length1, &_inner_error_);
+ _tmp6_ = _tmp5_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return 0;
+ } else {
+ 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 0;
+ }
+ }
+ result = _tmp6_;
+ return result;
+}
+
+
+static gchar* string_slice (const gchar* self, glong start, glong end) {
+ gchar* result = NULL;
+ gint _tmp0_;
+ gint _tmp1_;
+ glong string_length;
+ glong _tmp2_;
+ glong _tmp5_;
+ gboolean _tmp8_ = FALSE;
+ glong _tmp9_;
+ gboolean _tmp12_;
+ gboolean _tmp13_ = FALSE;
+ glong _tmp14_;
+ gboolean _tmp17_;
+ glong _tmp18_;
+ glong _tmp19_;
+ glong _tmp20_;
+ glong _tmp21_;
+ glong _tmp22_;
+ gchar* _tmp23_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = strlen (self);
+ _tmp1_ = _tmp0_;
+ string_length = (glong) _tmp1_;
+ _tmp2_ = start;
+ if (_tmp2_ < ((glong) 0)) {
+ glong _tmp3_;
+ glong _tmp4_;
+ _tmp3_ = string_length;
+ _tmp4_ = start;
+ start = _tmp3_ + _tmp4_;
+ }
+ _tmp5_ = end;
+ if (_tmp5_ < ((glong) 0)) {
+ glong _tmp6_;
+ glong _tmp7_;
+ _tmp6_ = string_length;
+ _tmp7_ = end;
+ end = _tmp6_ + _tmp7_;
+ }
+ _tmp9_ = start;
+ if (_tmp9_ >= ((glong) 0)) {
+ glong _tmp10_;
+ glong _tmp11_;
+ _tmp10_ = start;
+ _tmp11_ = string_length;
+ _tmp8_ = _tmp10_ <= _tmp11_;
+ } else {
+ _tmp8_ = FALSE;
+ }
+ _tmp12_ = _tmp8_;
+ g_return_val_if_fail (_tmp12_, NULL);
+ _tmp14_ = end;
+ if (_tmp14_ >= ((glong) 0)) {
+ glong _tmp15_;
+ glong _tmp16_;
+ _tmp15_ = end;
+ _tmp16_ = string_length;
+ _tmp13_ = _tmp15_ <= _tmp16_;
+ } else {
+ _tmp13_ = FALSE;
+ }
+ _tmp17_ = _tmp13_;
+ g_return_val_if_fail (_tmp17_, NULL);
+ _tmp18_ = start;
+ _tmp19_ = end;
+ g_return_val_if_fail (_tmp18_ <= _tmp19_, NULL);
+ _tmp20_ = start;
+ _tmp21_ = end;
+ _tmp22_ = start;
+ _tmp23_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) (_tmp21_ - _tmp22_));
+ result = _tmp23_;
+ return result;
+}
+
+
+static gchar string_get (const gchar* self, glong index) {
+ gchar result = '\0';
+ glong _tmp0_;
+ gchar _tmp1_;
+ g_return_val_if_fail (self != NULL, '\0');
+ _tmp0_ = index;
+ _tmp1_ = ((gchar*) self)[_tmp0_];
+ result = _tmp1_;
+ return result;
+}
+
+
+static gchar* rygel_media_export_media_cache_translate_sort_criteria (RygelMediaExportMediaCache* self, const gchar* sort_criteria) {
+ gchar* result = NULL;
+ gchar* collate = NULL;
+ GString* _tmp0_;
+ GString* builder;
+ const gchar* _tmp1_;
+ gchar** _tmp2_;
+ gchar** _tmp3_ = NULL;
+ gchar** fields;
+ gint fields_length1;
+ gint _fields_size_;
+ gchar** _tmp4_;
+ gint _tmp4__length1;
+ GString* _tmp27_;
+ const gchar* _tmp28_;
+ gchar* _tmp29_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (sort_criteria != NULL, NULL);
+ _tmp0_ = g_string_new ("ORDER BY ");
+ builder = _tmp0_;
+ _tmp1_ = sort_criteria;
+ _tmp3_ = _tmp2_ = g_strsplit (_tmp1_, ",", 0);
+ fields = _tmp3_;
+ fields_length1 = _vala_array_length (_tmp2_);
+ _fields_size_ = fields_length1;
+ _tmp4_ = fields;
+ _tmp4__length1 = fields_length1;
+ {
+ gchar** field_collection = NULL;
+ gint field_collection_length1 = 0;
+ gint _field_collection_size_ = 0;
+ gint field_it = 0;
+ field_collection = _tmp4_;
+ field_collection_length1 = _tmp4__length1;
+ for (field_it = 0; field_it < _tmp4__length1; field_it = field_it + 1) {
+ gchar* _tmp5_;
+ gchar* field = NULL;
+ _tmp5_ = g_strdup (field_collection[field_it]);
+ field = _tmp5_;
+ {
+ {
+ const gchar* _tmp6_;
+ const gchar* _tmp7_;
+ gint _tmp8_;
+ gint _tmp9_;
+ gchar* _tmp10_ = NULL;
+ gchar* _tmp11_;
+ gchar* _tmp12_ = NULL;
+ gchar* _tmp13_ = NULL;
+ gchar* _tmp14_;
+ gchar* column;
+ const gchar* _tmp15_;
+ gchar** _tmp16_;
+ gint _tmp16__length1;
+ const gchar* _tmp17_;
+ const gchar* _tmp19_ = NULL;
+ const gchar* _tmp20_;
+ gchar _tmp21_ = '\0';
+ GString* _tmp22_;
+ const gchar* _tmp23_;
+ const gchar* _tmp24_;
+ const gchar* _tmp25_;
+ _tmp6_ = field;
+ _tmp7_ = field;
+ _tmp8_ = strlen (_tmp7_);
+ _tmp9_ = _tmp8_;
+ _tmp10_ = string_slice (_tmp6_, (glong) 1, (glong) _tmp9_);
+ _tmp11_ = _tmp10_;
+ _tmp13_ = rygel_media_export_media_cache_map_operand_to_column (self, _tmp11_, &_tmp12_, &_inner_error_);
+ _g_free0 (collate);
+ collate = _tmp12_;
+ _tmp14_ = _tmp13_;
+ _g_free0 (_tmp11_);
+ column = _tmp14_;
+ if (_inner_error_ != NULL) {
+ goto __catch11_g_error;
+ }
+ _tmp15_ = field;
+ _tmp16_ = fields;
+ _tmp16__length1 = fields_length1;
+ _tmp17_ = _tmp16_[0];
+ if (g_strcmp0 (_tmp15_, _tmp17_) != 0) {
+ GString* _tmp18_;
+ _tmp18_ = builder;
+ g_string_append (_tmp18_, ",");
+ }
+ _tmp20_ = field;
+ _tmp21_ = string_get (_tmp20_, (glong) 0);
+ if (_tmp21_ == '-') {
+ _tmp19_ = "DESC";
+ } else {
+ _tmp19_ = "ASC";
+ }
+ _tmp22_ = builder;
+ _tmp23_ = column;
+ _tmp24_ = collate;
+ _tmp25_ = _tmp19_;
+ g_string_append_printf (_tmp22_, "%s %s %s ", _tmp23_, _tmp24_, _tmp25_);
+ _g_free0 (column);
+ }
+ goto __finally11;
+ __catch11_g_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp26_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp26_ = field;
+ g_warning ("rygel-media-export-media-cache.vala:890: Skipping nsupported field: %s", _tmp26_);
+ _g_error_free0 (_error_);
+ }
+ __finally11:
+ if (_inner_error_ != NULL) {
+ _g_free0 (field);
+ fields = (_vala_array_free (fields, fields_length1, (GDestroyNotify) g_free), NULL);
+ _g_string_free0 (builder);
+ _g_free0 (collate);
+ 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;
+ }
+ _g_free0 (field);
+ }
+ }
+ }
+ _tmp27_ = builder;
+ _tmp28_ = _tmp27_->str;
+ _tmp29_ = g_strdup (_tmp28_);
+ result = _tmp29_;
+ fields = (_vala_array_free (fields, fields_length1, (GDestroyNotify) g_free), NULL);
+ _g_string_free0 (builder);
+ _g_free0 (collate);
+ return result;
+}
+
+
+static void rygel_media_export_media_cache_class_init (RygelMediaExportMediaCacheClass * klass) {
+ rygel_media_export_media_cache_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportMediaCachePrivate));
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_media_cache_finalize;
+}
+
+
+static void rygel_media_export_media_cache_init (RygelMediaExportMediaCache * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_media_cache_finalize (GObject* obj) {
+ RygelMediaExportMediaCache * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache);
+ _g_object_unref0 (self->priv->db);
+ _g_object_unref0 (self->priv->factory);
+ _g_object_unref0 (self->priv->sql);
+ _g_object_unref0 (self->priv->exists_cache);
+ G_OBJECT_CLASS (rygel_media_export_media_cache_parent_class)->finalize (obj);
+}
+
+static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+ if ((array != NULL) && (destroy_func != NULL)) {
+ int i;
+ for (i = 0; i < array_length; i = i + 1) {
+ if (((gpointer*) array)[i] != NULL) {
+ destroy_func (((gpointer*) array)[i]);
+ }
+ }
+ }
+}
+
+
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+ _vala_array_destroy (array, array_length, destroy_func);
+ g_free (array);
+}
+
+
+static gint _vala_array_length (gpointer array) {
+ int length;
+ length = 0;
+ if (array) {
+ while (((gpointer*) array)[length]) {
+ length++;
+ }
+ }
+ return length;
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-media-cache.h b/src/media-export/rygel-media-export-media-cache.h
new file mode 100644
index 0000000..7b34dc3
--- /dev/null
+++ b/src/media-export/rygel-media-export-media-cache.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MEDIA_CACHE_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MEDIA_CACHE_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE (rygel_media_export_media_cache_get_type ())
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+
+typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
+typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;
+typedef struct _RygelMediaExportMediaCachePrivate RygelMediaExportMediaCachePrivate;
+
+struct _RygelMediaExportMediaCache {
+ GObject parent_instance;
+ RygelMediaExportMediaCachePrivate *priv;
+};
+
+struct _RygelMediaExportMediaCacheClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportMediaCache* rygel_media_export_media_cache_new (GError** error);
+
+typedef enum {
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_SQLITE_ERROR,
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_GENERAL_ERROR,
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_INVALID_TYPE,
+ RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH
+} RygelMediaExportMediaCacheError;
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR rygel_media_export_media_cache_error_quark ()
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MEDIA_CACHE_H__ */
diff --git a/src/media-export/rygel-media-export-metadata-extractor.c b/src/media-export/rygel-media-export-metadata-extractor.c
new file mode 100644
index 0000000..cf54ab8
--- /dev/null
+++ b/src/media-export/rygel-media-export-metadata-extractor.c
@@ -0,0 +1,431 @@
+/* rygel-media-export-metadata-extractor.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-metadata-extractor.vala, do not modify */
+
+/*
+ * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2009 Jens Georg <mail jensge org>.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-harvesting-task.h"
+#include <libgupnp-dlna/gupnp-dlna-discoverer.h>
+#include <libgupnp-dlna/gupnp-dlna-information.h>
+#include <gst/pbutils/pbutils.h>
+#include <glib/gi18n-lib.h>
+
+G_DEFINE_TYPE (RygelMediaExportMetadataExtractor, rygel_media_export_metadata_extractor, G_TYPE_OBJECT)
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+struct _RygelMediaExportMetadataExtractorPrivate {
+ GUPnPDLNADiscoverer* discoverer;
+ GeeHashMap* file_hash;
+ guint64 timeout;
+ gboolean extract_metadata;
+};
+
+GType rygel_media_export_metadata_extractor_get_type (void) G_GNUC_CONST;
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorPrivate))
+
+RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_construct (GType object_type);
+void rygel_media_export_metadata_extractor_extract (RygelMediaExportMetadataExtractor* self, GFile* file);
+static void rygel_media_export_metadata_extractor_on_done (RygelMediaExportMetadataExtractor* self, GUPnPDLNAInformation* dlna, GError* err);
+static void _rygel_media_export_metadata_extractor_on_done_gupnp_dlna_discoverer_done (GUPnPDLNADiscoverer* _sender, GUPnPDLNAInformation* dlna, GError* err, gpointer self);
+static void rygel_media_export_metadata_extractor_extract_basic_information (RygelMediaExportMetadataExtractor* self, GFile* file, GUPnPDLNAInformation* dlna);
+static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_OBJECT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
+static void g_cclosure_user_marshal_VOID__OBJECT_POINTER (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
+static void rygel_media_export_metadata_extractor_finalize (GObject* obj);
+
+
+RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_construct (GType object_type) {
+ RygelMediaExportMetadataExtractor * self = NULL;
+ GeeHashMap* _tmp0_;
+ RygelMetaConfig* _tmp1_ = NULL;
+ RygelMetaConfig* config;
+ gboolean _tmp4_;
+ GError * _inner_error_ = NULL;
+ self = (RygelMediaExportMetadataExtractor*) g_object_new (object_type, NULL);
+ _tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_FILE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ _g_object_unref0 (self->priv->file_hash);
+ self->priv->file_hash = _tmp0_;
+ _tmp1_ = rygel_meta_config_get_default ();
+ config = _tmp1_;
+ {
+ gboolean _tmp2_ = FALSE;
+ gboolean _tmp3_;
+ _tmp2_ = rygel_configuration_get_bool ((RygelConfiguration*) config, "MediaExport", "extract-metadata", &_inner_error_);
+ _tmp3_ = _tmp2_;
+ if (_inner_error_ != NULL) {
+ goto __catch22_g_error;
+ }
+ self->priv->extract_metadata = _tmp3_;
+ }
+ goto __finally22;
+ __catch22_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ self->priv->extract_metadata = TRUE;
+ _g_error_free0 (_error_);
+ }
+ __finally22:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (config);
+ 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;
+ }
+ _tmp4_ = self->priv->extract_metadata;
+ if (_tmp4_) {
+ }
+ _g_object_unref0 (config);
+ return self;
+}
+
+
+RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_new (void) {
+ return rygel_media_export_metadata_extractor_construct (RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR);
+}
+
+
+static void _rygel_media_export_metadata_extractor_on_done_gupnp_dlna_discoverer_done (GUPnPDLNADiscoverer* _sender, GUPnPDLNAInformation* dlna, GError* err, gpointer self) {
+ rygel_media_export_metadata_extractor_on_done (self, dlna, err);
+}
+
+
+void rygel_media_export_metadata_extractor_extract (RygelMediaExportMetadataExtractor* self, GFile* file) {
+ gboolean _tmp0_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ _tmp0_ = self->priv->extract_metadata;
+ if (_tmp0_) {
+ GFile* _tmp1_;
+ gchar* _tmp2_ = NULL;
+ gchar* uri;
+ GeeHashMap* _tmp3_;
+ const gchar* _tmp4_;
+ GFile* _tmp5_;
+ guint64 _tmp6_;
+ GstClockTime gst_timeout;
+ GstClockTime _tmp7_;
+ GUPnPDLNADiscoverer* _tmp8_;
+ GUPnPDLNADiscoverer* _tmp9_;
+ GUPnPDLNADiscoverer* _tmp10_;
+ GUPnPDLNADiscoverer* _tmp11_;
+ const gchar* _tmp12_;
+ _tmp1_ = file;
+ _tmp2_ = g_file_get_uri (_tmp1_);
+ uri = _tmp2_;
+ _tmp3_ = self->priv->file_hash;
+ _tmp4_ = uri;
+ _tmp5_ = file;
+ gee_abstract_map_set ((GeeAbstractMap*) _tmp3_, _tmp4_, _tmp5_);
+ _tmp6_ = self->priv->timeout;
+ gst_timeout = (GstClockTime) (_tmp6_ * GST_SECOND);
+ _tmp7_ = gst_timeout;
+ _tmp8_ = gupnp_dlna_discoverer_new (_tmp7_, TRUE, TRUE);
+ _g_object_unref0 (self->priv->discoverer);
+ self->priv->discoverer = _tmp8_;
+ _tmp9_ = self->priv->discoverer;
+ g_signal_connect_object (_tmp9_, "done", (GCallback) _rygel_media_export_metadata_extractor_on_done_gupnp_dlna_discoverer_done, self, 0);
+ _tmp10_ = self->priv->discoverer;
+ gst_discoverer_start ((GstDiscoverer*) _tmp10_);
+ _tmp11_ = self->priv->discoverer;
+ _tmp12_ = uri;
+ gupnp_dlna_discoverer_discover_uri (_tmp11_, _tmp12_);
+ _g_free0 (uri);
+ } else {
+ GFile* _tmp13_;
+ _tmp13_ = file;
+ rygel_media_export_metadata_extractor_extract_basic_information (self, _tmp13_, NULL);
+ }
+}
+
+
+static void rygel_media_export_metadata_extractor_on_done (RygelMediaExportMetadataExtractor* self, GUPnPDLNAInformation* dlna, GError* err) {
+ GUPnPDLNADiscoverer* _tmp0_;
+ guint _tmp1_ = 0U;
+ GeeHashMap* _tmp2_;
+ GUPnPDLNAInformation* _tmp3_;
+ GstDiscovererInfo* _tmp4_;
+ GstDiscovererInfo* _tmp5_;
+ const gchar* _tmp6_ = NULL;
+ gpointer _tmp7_ = NULL;
+ GFile* file;
+ GFile* _tmp8_;
+ GeeHashMap* _tmp13_;
+ GUPnPDLNAInformation* _tmp14_;
+ GstDiscovererInfo* _tmp15_;
+ GstDiscovererInfo* _tmp16_;
+ const gchar* _tmp17_ = NULL;
+ GUPnPDLNAInformation* _tmp18_;
+ GstDiscovererInfo* _tmp19_;
+ GstDiscovererInfo* _tmp20_;
+ GstDiscovererResult _tmp21_ = 0;
+ GFile* _tmp31_;
+ GUPnPDLNAInformation* _tmp32_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (dlna != NULL);
+ _tmp0_ = self->priv->discoverer;
+ g_signal_parse_name ("done", GUPNP_TYPE_DLNA_DISCOVERER, &_tmp1_, NULL, FALSE);
+ g_signal_handlers_disconnect_matched (_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _rygel_media_export_metadata_extractor_on_done_gupnp_dlna_discoverer_done, self);
+ _g_object_unref0 (self->priv->discoverer);
+ self->priv->discoverer = NULL;
+ _tmp2_ = self->priv->file_hash;
+ _tmp3_ = dlna;
+ _tmp4_ = gupnp_dlna_information_get_info (_tmp3_);
+ _tmp5_ = _tmp4_;
+ _tmp6_ = gst_discoverer_info_get_uri (_tmp5_);
+ _tmp7_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp2_, _tmp6_);
+ file = (GFile*) _tmp7_;
+ _tmp8_ = file;
+ if (_tmp8_ == NULL) {
+ GUPnPDLNAInformation* _tmp9_;
+ GstDiscovererInfo* _tmp10_;
+ GstDiscovererInfo* _tmp11_;
+ const gchar* _tmp12_ = NULL;
+ _tmp9_ = dlna;
+ _tmp10_ = gupnp_dlna_information_get_info (_tmp9_);
+ _tmp11_ = _tmp10_;
+ _tmp12_ = gst_discoverer_info_get_uri (_tmp11_);
+ g_warning ("rygel-media-export-metadata-extractor.vala:96: File %s already handled" \
+", ignoring event", _tmp12_);
+ _g_object_unref0 (file);
+ return;
+ }
+ _tmp13_ = self->priv->file_hash;
+ _tmp14_ = dlna;
+ _tmp15_ = gupnp_dlna_information_get_info (_tmp14_);
+ _tmp16_ = _tmp15_;
+ _tmp17_ = gst_discoverer_info_get_uri (_tmp16_);
+ gee_abstract_map_unset ((GeeAbstractMap*) _tmp13_, _tmp17_, NULL);
+ _tmp18_ = dlna;
+ _tmp19_ = gupnp_dlna_information_get_info (_tmp18_);
+ _tmp20_ = _tmp19_;
+ _tmp21_ = gst_discoverer_info_get_result (_tmp20_);
+ if ((_tmp21_ & GST_DISCOVERER_TIMEOUT) != 0) {
+ GFile* _tmp22_;
+ gchar* _tmp23_ = NULL;
+ gchar* _tmp24_;
+ _tmp22_ = file;
+ _tmp23_ = g_file_get_uri (_tmp22_);
+ _tmp24_ = _tmp23_;
+ g_debug ("rygel-media-export-metadata-extractor.vala:105: Extraction timed out o" \
+"n %s", _tmp24_);
+ _g_free0 (_tmp24_);
+ dlna = NULL;
+ } else {
+ GUPnPDLNAInformation* _tmp25_;
+ GstDiscovererInfo* _tmp26_;
+ GstDiscovererInfo* _tmp27_;
+ GstDiscovererResult _tmp28_ = 0;
+ _tmp25_ = dlna;
+ _tmp26_ = gupnp_dlna_information_get_info (_tmp25_);
+ _tmp27_ = _tmp26_;
+ _tmp28_ = gst_discoverer_info_get_result (_tmp27_);
+ if ((_tmp28_ & GST_DISCOVERER_ERROR) != 0) {
+ GFile* _tmp29_;
+ GError* _tmp30_;
+ _tmp29_ = file;
+ _tmp30_ = err;
+ g_signal_emit_by_name (self, "error", _tmp29_, _tmp30_);
+ _g_object_unref0 (file);
+ return;
+ }
+ }
+ _tmp31_ = file;
+ _tmp32_ = dlna;
+ rygel_media_export_metadata_extractor_extract_basic_information (self, _tmp31_, _tmp32_);
+ _g_object_unref0 (file);
+}
+
+
+static gpointer _g_error_copy0 (gpointer self) {
+ return self ? g_error_copy (self) : NULL;
+}
+
+
+static void rygel_media_export_metadata_extractor_extract_basic_information (RygelMediaExportMetadataExtractor* self, GFile* file, GUPnPDLNAInformation* dlna) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ {
+ GFileInfo* file_info = NULL;
+ GFile* _tmp11_;
+ GUPnPDLNAInformation* _tmp12_;
+ {
+ GFile* _tmp0_;
+ GFileInfo* _tmp1_ = NULL;
+ GFileInfo* _tmp2_;
+ _tmp0_ = file;
+ _tmp1_ = g_file_query_info (_tmp0_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE "," G_FILE_ATTRIBUTE_STANDARD_SIZE "," G_FILE_ATTRIBUTE_TIME_MODIFIED "," G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ goto __catch24_g_error;
+ }
+ _g_object_unref0 (file_info);
+ file_info = _tmp2_;
+ }
+ goto __finally24;
+ __catch24_g_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp3_ = NULL;
+ GFile* _tmp4_;
+ gchar* _tmp5_ = NULL;
+ gchar* _tmp6_;
+ GFile* _tmp7_;
+ GError* _tmp8_;
+ GError* _tmp9_;
+ GError* _tmp10_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp3_ = _ ("Failed to query content type for '%s'");
+ _tmp4_ = file;
+ _tmp5_ = g_file_get_uri (_tmp4_);
+ _tmp6_ = _tmp5_;
+ g_warning (_tmp3_, _tmp6_);
+ _g_free0 (_tmp6_);
+ _tmp7_ = file;
+ _tmp8_ = _error_;
+ g_signal_emit_by_name (self, "error", _tmp7_, _tmp8_);
+ _tmp9_ = _error_;
+ _tmp10_ = _g_error_copy0 (_tmp9_);
+ _inner_error_ = _tmp10_;
+ _g_error_free0 (_error_);
+ goto __finally24;
+ }
+ __finally24:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (file_info);
+ goto __catch23_g_error;
+ }
+ _tmp11_ = file;
+ _tmp12_ = dlna;
+ g_signal_emit_by_name (self, "extraction-done", _tmp11_, _tmp12_, file_info);
+ _g_object_unref0 (file_info);
+ }
+ goto __finally23;
+ __catch23_g_error:
+ {
+ GError* _error_ = NULL;
+ GFile* _tmp13_;
+ gchar* _tmp14_ = NULL;
+ gchar* _tmp15_;
+ GError* _tmp16_;
+ const gchar* _tmp17_;
+ GFile* _tmp18_;
+ GError* _tmp19_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp13_ = file;
+ _tmp14_ = g_file_get_uri (_tmp13_);
+ _tmp15_ = _tmp14_;
+ _tmp16_ = _error_;
+ _tmp17_ = _tmp16_->message;
+ g_debug ("rygel-media-export-metadata-extractor.vala:147: Failed to extract basi" \
+"c metadata from %s: %s", _tmp15_, _tmp17_);
+ _g_free0 (_tmp15_);
+ _tmp18_ = file;
+ _tmp19_ = _error_;
+ g_signal_emit_by_name (self, "error", _tmp18_, _tmp19_);
+ _g_error_free0 (_error_);
+ }
+ __finally23:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_OBJECT (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
+ typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT_OBJECT) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer arg_3, gpointer data2);
+ register GMarshalFunc_VOID__OBJECT_OBJECT_OBJECT callback;
+ register GCClosure * cc;
+ register gpointer data1;
+ register gpointer data2;
+ cc = (GCClosure *) closure;
+ g_return_if_fail (n_param_values == 4);
+ if (G_CCLOSURE_SWAP_DATA (closure)) {
+ data1 = closure->data;
+ data2 = param_values->data[0].v_pointer;
+ } else {
+ data1 = param_values->data[0].v_pointer;
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__OBJECT_OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);
+ callback (data1, g_value_get_object (param_values + 1), g_value_get_object (param_values + 2), g_value_get_object (param_values + 3), data2);
+}
+
+
+static void g_cclosure_user_marshal_VOID__OBJECT_POINTER (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
+ typedef void (*GMarshalFunc_VOID__OBJECT_POINTER) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
+ register GMarshalFunc_VOID__OBJECT_POINTER callback;
+ register GCClosure * cc;
+ register gpointer data1;
+ register gpointer data2;
+ cc = (GCClosure *) closure;
+ g_return_if_fail (n_param_values == 3);
+ if (G_CCLOSURE_SWAP_DATA (closure)) {
+ data1 = closure->data;
+ data2 = param_values->data[0].v_pointer;
+ } else {
+ data1 = param_values->data[0].v_pointer;
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__OBJECT_POINTER) (marshal_data ? marshal_data : cc->callback);
+ callback (data1, g_value_get_object (param_values + 1), g_value_get_pointer (param_values + 2), data2);
+}
+
+
+static void rygel_media_export_metadata_extractor_class_init (RygelMediaExportMetadataExtractorClass * klass) {
+ rygel_media_export_metadata_extractor_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportMetadataExtractorPrivate));
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_metadata_extractor_finalize;
+ g_signal_new ("extraction_done", RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT_OBJECT, G_TYPE_NONE, 3, G_TYPE_FILE, GUPNP_TYPE_DLNA_INFORMATION, g_file_info_get_type ());
+ /**
+ * Signalize that an error occured during metadata extraction
+ */
+ g_signal_new ("error", RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2, G_TYPE_FILE, G_TYPE_POINTER);
+}
+
+
+static void rygel_media_export_metadata_extractor_init (RygelMediaExportMetadataExtractor * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_PRIVATE (self);
+ self->priv->timeout = (guint64) 10;
+}
+
+
+static void rygel_media_export_metadata_extractor_finalize (GObject* obj) {
+ RygelMediaExportMetadataExtractor * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractor);
+ _g_object_unref0 (self->priv->discoverer);
+ _g_object_unref0 (self->priv->file_hash);
+ G_OBJECT_CLASS (rygel_media_export_metadata_extractor_parent_class)->finalize (obj);
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-metadata-extractor.h b/src/media-export/rygel-media-export-metadata-extractor.h
new file mode 100644
index 0000000..af3b19d
--- /dev/null
+++ b/src/media-export/rygel-media-export-metadata-extractor.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_METADATA_EXTRACTOR_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_METADATA_EXTRACTOR_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR (rygel_media_export_metadata_extractor_get_type ())
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractor))
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorClass))
+#define RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR))
+#define RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR))
+#define RYGEL_MEDIA_EXPORT_METADATA_EXTRACTOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_METADATA_EXTRACTOR, RygelMediaExportMetadataExtractorClass))
+
+typedef struct _RygelMediaExportMetadataExtractor RygelMediaExportMetadataExtractor;
+typedef struct _RygelMediaExportMetadataExtractorClass RygelMediaExportMetadataExtractorClass;
+typedef struct _RygelMediaExportMetadataExtractorPrivate RygelMediaExportMetadataExtractorPrivate;
+
+struct _RygelMediaExportMetadataExtractor {
+ GObject parent_instance;
+ RygelMediaExportMetadataExtractorPrivate *priv;
+ GFile* origin;
+};
+
+struct _RygelMediaExportMetadataExtractorClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_metadata_extractor_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportMetadataExtractor* rygel_media_export_metadata_extractor_new ();
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_METADATA_EXTRACTOR_H__ */
diff --git a/src/media-export/rygel-media-export-music-item.c b/src/media-export/rygel-media-export-music-item.c
new file mode 100644
index 0000000..0c3497f
--- /dev/null
+++ b/src/media-export/rygel-media-export-music-item.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2012 Jens Georg <mail jensge org>.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#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);
+
+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))
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+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_;
+};
+
+
+static RygelUpdatableObjectIface* rygel_media_export_music_item_rygel_updatable_object_parent_iface = NULL;
+
+RygelMediaExportMusicItem* rygel_media_export_music_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+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_);
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
+void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
+static void rygel_media_export_music_item_finalize (GObject* obj);
+
+
+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;
+}
+
+
+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_data_free (gpointer _data) {
+ RygelMediaExportMusicItemCommitData* _data_;
+ _data_ = _data;
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportMusicItemCommitData, _data_);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+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_ref0 (self);
+ _data_->self = _tmp0_;
+ rygel_media_export_music_item_real_commit_co (_data_);
+}
+
+
+static void rygel_media_export_music_item_real_commit_finish (RygelUpdatableObject* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaExportMusicItemCommitData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+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_unref0 (_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_unref0 (_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) {
+ rygel_media_export_music_item_parent_class = g_type_class_peek_parent (klass);
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_music_item_finalize;
+}
+
+static void rygel_media_export_music_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface) {
+ rygel_media_export_music_item_rygel_updatable_object_parent_iface = g_type_interface_peek_parent (iface);
+ iface->commit = (void (*)(RygelUpdatableObject*, GError**)) 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) {
+}
+
+
+static void rygel_media_export_music_item_finalize (GObject* obj) {
+ RygelMediaExportMusicItem * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItem);
+ G_OBJECT_CLASS (rygel_media_export_music_item_parent_class)->finalize (obj);
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-music-item.h b/src/media-export/rygel-media-export-music-item.h
new file mode 100644
index 0000000..494a4a9
--- /dev/null
+++ b/src/media-export/rygel-media-export-music-item.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MUSIC_ITEM_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MUSIC_ITEM_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM (rygel_media_export_music_item_get_type ())
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItem))
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItemClass))
+#define RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM))
+#define RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM))
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItemClass))
+
+typedef struct _RygelMediaExportMusicItem RygelMediaExportMusicItem;
+typedef struct _RygelMediaExportMusicItemClass RygelMediaExportMusicItemClass;
+typedef struct _RygelMediaExportMusicItemPrivate RygelMediaExportMusicItemPrivate;
+
+struct _RygelMediaExportMusicItem {
+ RygelMusicItem parent_instance;
+ RygelMediaExportMusicItemPrivate *priv;
+ gint disc; //TODO: Move to priv.
+};
+
+struct _RygelMediaExportMusicItemClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_music_item_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportMusicItem* rygel_media_export_music_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_MUSIC_ITEM_H__ */
diff --git a/src/media-export/rygel-media-export-node-query-container.c b/src/media-export/rygel-media-export-node-query-container.c
new file mode 100644
index 0000000..af75216
--- /dev/null
+++ b/src/media-export/rygel-media-export-node-query-container.c
@@ -0,0 +1,585 @@
+/* rygel-media-export-node-query-container.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-node-query-container.vala, do not modify */
+
+/*
+ * Copyright (C) 2011 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <rygel-server.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gee.h>
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER (rygel_media_export_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+
+typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
+typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
+typedef struct _RygelMediaExportDBContainerPrivate RygelMediaExportDBContainerPrivate;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE (rygel_media_export_media_cache_get_type ())
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+
+typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
+typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER (rygel_media_export_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainer))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+
+typedef struct _RygelMediaExportQueryContainer RygelMediaExportQueryContainer;
+typedef struct _RygelMediaExportQueryContainerClass RygelMediaExportQueryContainerClass;
+typedef struct _RygelMediaExportQueryContainerPrivate RygelMediaExportQueryContainerPrivate;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER (rygel_media_export_node_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainer))
+#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_NODE_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_NODE_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainerClass))
+
+typedef struct _RygelMediaExportNodeQueryContainer RygelMediaExportNodeQueryContainer;
+typedef struct _RygelMediaExportNodeQueryContainerClass RygelMediaExportNodeQueryContainerClass;
+typedef struct _RygelMediaExportNodeQueryContainerPrivate RygelMediaExportNodeQueryContainerPrivate;
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY (rygel_media_export_query_container_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactory))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
+
+typedef struct _RygelMediaExportQueryContainerFactory RygelMediaExportQueryContainerFactory;
+typedef struct _RygelMediaExportQueryContainerFactoryClass RygelMediaExportQueryContainerFactoryClass;
+typedef struct _RygelMediaExportNodeQueryContainerGetChildrenData RygelMediaExportNodeQueryContainerGetChildrenData;
+
+struct _RygelMediaExportDBContainer {
+ RygelMediaContainer parent_instance;
+ RygelMediaExportDBContainerPrivate * priv;
+ RygelMediaExportMediaCache* media_db;
+};
+
+struct _RygelMediaExportDBContainerClass {
+ RygelMediaContainerClass parent_class;
+ void (*search) (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+ RygelMediaObjects* (*search_finish) (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error);
+};
+
+struct _RygelMediaExportQueryContainer {
+ RygelMediaExportDBContainer parent_instance;
+ RygelMediaExportQueryContainerPrivate * priv;
+ RygelSearchExpression* expression;
+};
+
+struct _RygelMediaExportQueryContainerClass {
+ RygelMediaExportDBContainerClass parent_class;
+ gint (*count_children) (RygelMediaExportQueryContainer* self, GError** error);
+};
+
+struct _RygelMediaExportNodeQueryContainer {
+ RygelMediaExportQueryContainer parent_instance;
+ RygelMediaExportNodeQueryContainerPrivate * priv;
+};
+
+struct _RygelMediaExportNodeQueryContainerClass {
+ RygelMediaExportQueryContainerClass parent_class;
+};
+
+struct _RygelMediaExportNodeQueryContainerPrivate {
+ gchar* template;
+ gchar* attribute;
+};
+
+struct _RygelMediaExportNodeQueryContainerGetChildrenData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportNodeQueryContainer* self;
+ guint offset;
+ guint max_count;
+ gchar* sort_criteria;
+ GCancellable* cancellable;
+ RygelMediaObjects* result;
+ RygelMediaObjects* _tmp0_;
+ RygelMediaObjects* children;
+ RygelMediaExportMediaCache* _tmp1_;
+ const gchar* _tmp2_;
+ RygelSearchExpression* _tmp3_;
+ guint _tmp4_;
+ guint _tmp5_;
+ GeeList* _tmp6_;
+ GeeList* data;
+ GeeList* _tmp7_;
+ GeeList* _meta_data_list;
+ GeeList* _tmp8_;
+ gint _tmp9_;
+ gint _tmp10_;
+ gint _meta_data_size;
+ gint _meta_data_index;
+ gint _tmp11_;
+ gint _tmp12_;
+ gint _tmp13_;
+ GeeList* _tmp14_;
+ gint _tmp15_;
+ gpointer _tmp16_;
+ gchar* meta_data;
+ const gchar* _tmp17_;
+ gchar* _tmp18_;
+ gchar* new_id;
+ const gchar* _tmp19_;
+ const gchar* _tmp20_;
+ gchar* _tmp21_;
+ RygelMediaExportQueryContainerFactory* _tmp22_;
+ RygelMediaExportQueryContainerFactory* factory;
+ RygelMediaExportQueryContainerFactory* _tmp23_;
+ RygelMediaExportMediaCache* _tmp24_;
+ const gchar* _tmp25_;
+ const gchar* _tmp26_;
+ RygelMediaExportQueryContainer* _tmp27_;
+ RygelMediaExportQueryContainer* container;
+ RygelMediaExportQueryContainer* _tmp28_;
+ RygelMediaExportQueryContainer* _tmp29_;
+ GError * _inner_error_;
+};
+
+
+static gpointer rygel_media_export_node_query_container_parent_class = NULL;
+
+GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_query_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_node_query_container_get_type (void) G_GNUC_CONST;
+#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainerPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_DUMMY_PROPERTY
+};
+RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_new (RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute);
+RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute);
+RygelMediaExportQueryContainer* rygel_media_export_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name);
+gint rygel_media_export_query_container_count_children (RygelMediaExportQueryContainer* self, GError** error);
+static void rygel_media_export_node_query_container_real_get_children_data_free (gpointer _data);
+static void rygel_media_export_node_query_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_node_query_container_real_get_children_co (RygelMediaExportNodeQueryContainerGetChildrenData* _data_);
+GeeList* rygel_media_export_media_cache_get_object_attribute_by_search_expression (RygelMediaExportMediaCache* self, const gchar* attribute, RygelSearchExpression* expression, glong offset, guint max_count, GError** error);
+GType rygel_media_export_query_container_factory_get_type (void) G_GNUC_CONST;
+RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_get_default (void);
+RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_description (RygelMediaExportQueryContainerFactory* self, RygelMediaExportMediaCache* cache, const gchar* definition, const gchar* name);
+static gint rygel_media_export_node_query_container_real_count_children (RygelMediaExportQueryContainer* base, GError** error);
+static void rygel_media_export_node_query_container_finalize (GObject* obj);
+
+
+RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute) {
+ RygelMediaExportNodeQueryContainer * self = NULL;
+ RygelMediaExportMediaCache* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ const gchar* _tmp2_;
+ const gchar* _tmp3_;
+ const gchar* _tmp4_;
+ gchar* _tmp5_;
+ const gchar* _tmp6_;
+ gchar* _tmp7_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (cache != NULL, NULL);
+ g_return_val_if_fail (expression != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (template != NULL, NULL);
+ g_return_val_if_fail (attribute != NULL, NULL);
+ _tmp0_ = cache;
+ _tmp1_ = expression;
+ _tmp2_ = id;
+ _tmp3_ = name;
+ self = (RygelMediaExportNodeQueryContainer*) rygel_media_export_query_container_construct (object_type, _tmp0_, _tmp1_, _tmp2_, _tmp3_);
+ _tmp4_ = template;
+ _tmp5_ = g_strdup (_tmp4_);
+ _g_free0 (self->priv->template);
+ self->priv->template = _tmp5_;
+ _tmp6_ = attribute;
+ _tmp7_ = g_strdup (_tmp6_);
+ _g_free0 (self->priv->attribute);
+ self->priv->attribute = _tmp7_;
+ {
+ gint _tmp8_ = 0;
+ gint _tmp9_;
+ _tmp8_ = rygel_media_export_query_container_count_children ((RygelMediaExportQueryContainer*) self, &_inner_error_);
+ _tmp9_ = _tmp8_;
+ if (_inner_error_ != NULL) {
+ goto __catch41_g_error;
+ }
+ ((RygelMediaContainer*) self)->child_count = _tmp9_;
+ }
+ goto __finally41;
+ __catch41_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally41:
+ if (_inner_error_ != 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 NULL;
+ }
+ return self;
+}
+
+
+RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_new (RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute) {
+ return rygel_media_export_node_query_container_construct (RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, cache, expression, id, name, template, attribute);
+}
+
+
+static void rygel_media_export_node_query_container_real_get_children_data_free (gpointer _data) {
+ RygelMediaExportNodeQueryContainerGetChildrenData* _data_;
+ _data_ = _data;
+ _g_free0 (_data_->sort_criteria);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportNodeQueryContainerGetChildrenData, _data_);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void rygel_media_export_node_query_container_real_get_children (RygelMediaContainer* base, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportNodeQueryContainer * self;
+ RygelMediaExportNodeQueryContainerGetChildrenData* _data_;
+ RygelMediaExportNodeQueryContainer* _tmp0_;
+ guint _tmp1_;
+ guint _tmp2_;
+ const gchar* _tmp3_;
+ gchar* _tmp4_;
+ GCancellable* _tmp5_;
+ GCancellable* _tmp6_;
+ self = (RygelMediaExportNodeQueryContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportNodeQueryContainerGetChildrenData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_node_query_container_real_get_children);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_node_query_container_real_get_children_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = offset;
+ _data_->offset = _tmp1_;
+ _tmp2_ = max_count;
+ _data_->max_count = _tmp2_;
+ _tmp3_ = sort_criteria;
+ _tmp4_ = g_strdup (_tmp3_);
+ _g_free0 (_data_->sort_criteria);
+ _data_->sort_criteria = _tmp4_;
+ _tmp5_ = cancellable;
+ _tmp6_ = _g_object_ref0 (_tmp5_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp6_;
+ rygel_media_export_node_query_container_real_get_children_co (_data_);
+}
+
+
+static RygelMediaObjects* rygel_media_export_node_query_container_real_get_children_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaObjects* result;
+ RygelMediaExportNodeQueryContainerGetChildrenData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
+ gchar* result = NULL;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (old != NULL, NULL);
+ g_return_val_if_fail (replacement != NULL, NULL);
+ {
+ const gchar* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* _tmp2_;
+ GRegex* _tmp3_;
+ GRegex* _tmp4_;
+ GRegex* regex;
+ GRegex* _tmp5_;
+ const gchar* _tmp6_;
+ gchar* _tmp7_ = NULL;
+ gchar* _tmp8_;
+ _tmp0_ = old;
+ _tmp1_ = g_regex_escape_string (_tmp0_, -1);
+ _tmp2_ = _tmp1_;
+ _tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
+ _tmp4_ = _tmp3_;
+ _g_free0 (_tmp2_);
+ regex = _tmp4_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_REGEX_ERROR) {
+ goto __catch42_g_regex_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = regex;
+ _tmp6_ = replacement;
+ _tmp7_ = g_regex_replace_literal (_tmp5_, self, (gssize) (-1), 0, _tmp6_, 0, &_inner_error_);
+ _tmp8_ = _tmp7_;
+ if (_inner_error_ != NULL) {
+ _g_regex_unref0 (regex);
+ if (_inner_error_->domain == G_REGEX_ERROR) {
+ goto __catch42_g_regex_error;
+ }
+ _g_regex_unref0 (regex);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ result = _tmp8_;
+ _g_regex_unref0 (regex);
+ return result;
+ }
+ goto __finally42;
+ __catch42_g_regex_error:
+ {
+ GError* e = NULL;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ g_assert_not_reached ();
+ _g_error_free0 (e);
+ }
+ __finally42:
+ if (_inner_error_ != 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 NULL;
+ }
+}
+
+
+static gboolean rygel_media_export_node_query_container_real_get_children_co (RygelMediaExportNodeQueryContainerGetChildrenData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = rygel_media_objects_new ();
+ _data_->children = _data_->_tmp0_;
+ _data_->_tmp1_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp2_ = _data_->self->priv->attribute;
+ _data_->_tmp3_ = ((RygelMediaExportQueryContainer*) _data_->self)->expression;
+ _data_->_tmp4_ = _data_->offset;
+ _data_->_tmp5_ = _data_->max_count;
+ _data_->_tmp6_ = NULL;
+ _data_->_tmp6_ = rygel_media_export_media_cache_get_object_attribute_by_search_expression (_data_->_tmp1_, _data_->_tmp2_, _data_->_tmp3_, (glong) _data_->_tmp4_, _data_->_tmp5_, &_data_->_inner_error_);
+ _data_->data = _data_->_tmp6_;
+ 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_unref0 (_data_->children);
+ 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_->_tmp7_ = _g_object_ref0 (_data_->data);
+ _data_->_meta_data_list = _data_->_tmp7_;
+ _data_->_tmp8_ = _data_->_meta_data_list;
+ _data_->_tmp9_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp8_);
+ _data_->_tmp10_ = _data_->_tmp9_;
+ _data_->_meta_data_size = _data_->_tmp10_;
+ _data_->_meta_data_index = -1;
+ while (TRUE) {
+ _data_->_tmp11_ = _data_->_meta_data_index;
+ _data_->_meta_data_index = _data_->_tmp11_ + 1;
+ _data_->_tmp12_ = _data_->_meta_data_index;
+ _data_->_tmp13_ = _data_->_meta_data_size;
+ if (!(_data_->_tmp12_ < _data_->_tmp13_)) {
+ break;
+ }
+ _data_->_tmp14_ = _data_->_meta_data_list;
+ _data_->_tmp15_ = _data_->_meta_data_index;
+ _data_->_tmp16_ = NULL;
+ _data_->_tmp16_ = gee_list_get (_data_->_tmp14_, _data_->_tmp15_);
+ _data_->meta_data = (gchar*) _data_->_tmp16_;
+ _data_->_tmp17_ = _data_->meta_data;
+ _data_->_tmp18_ = NULL;
+ _data_->_tmp18_ = g_uri_escape_string (_data_->_tmp17_, "", TRUE);
+ _data_->new_id = _data_->_tmp18_;
+ _data_->_tmp19_ = _data_->self->priv->template;
+ _data_->_tmp20_ = _data_->new_id;
+ _data_->_tmp21_ = NULL;
+ _data_->_tmp21_ = string_replace (_data_->_tmp19_, "%s", _data_->_tmp20_);
+ _g_free0 (_data_->new_id);
+ _data_->new_id = _data_->_tmp21_;
+ _data_->_tmp22_ = NULL;
+ _data_->_tmp22_ = rygel_media_export_query_container_factory_get_default ();
+ _data_->factory = _data_->_tmp22_;
+ _data_->_tmp23_ = _data_->factory;
+ _data_->_tmp24_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp25_ = _data_->new_id;
+ _data_->_tmp26_ = _data_->meta_data;
+ _data_->_tmp27_ = NULL;
+ _data_->_tmp27_ = rygel_media_export_query_container_factory_create_from_description (_data_->_tmp23_, _data_->_tmp24_, _data_->_tmp25_, _data_->_tmp26_);
+ _data_->container = _data_->_tmp27_;
+ _data_->_tmp28_ = _data_->container;
+ ((RygelMediaObject*) _data_->_tmp28_)->parent = (RygelMediaContainer*) _data_->self;
+ _data_->_tmp29_ = _data_->container;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _data_->children, (RygelMediaObject*) _data_->_tmp29_);
+ _g_object_unref0 (_data_->container);
+ _g_object_unref0 (_data_->factory);
+ _g_free0 (_data_->new_id);
+ _g_free0 (_data_->meta_data);
+ }
+ _g_object_unref0 (_data_->_meta_data_list);
+ }
+ _data_->result = _data_->children;
+ _g_object_unref0 (_data_->data);
+ 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_unref0 (_data_->data);
+ _g_object_unref0 (_data_->children);
+ 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 gint rygel_media_export_node_query_container_real_count_children (RygelMediaExportQueryContainer* base, GError** error) {
+ RygelMediaExportNodeQueryContainer * self;
+ gint result = 0;
+ gboolean _tmp0_ = FALSE;
+ const gchar* _tmp1_;
+ gboolean _tmp3_;
+ RygelMediaExportMediaCache* _tmp4_;
+ const gchar* _tmp5_;
+ RygelSearchExpression* _tmp6_;
+ GeeList* _tmp7_ = NULL;
+ GeeList* data;
+ GeeList* _tmp8_;
+ gint _tmp9_;
+ gint _tmp10_;
+ GError * _inner_error_ = NULL;
+ self = (RygelMediaExportNodeQueryContainer*) base;
+ _tmp1_ = self->priv->attribute;
+ if (_tmp1_ == NULL) {
+ _tmp0_ = TRUE;
+ } else {
+ RygelSearchExpression* _tmp2_;
+ _tmp2_ = ((RygelMediaExportQueryContainer*) self)->expression;
+ _tmp0_ = _tmp2_ == NULL;
+ }
+ _tmp3_ = _tmp0_;
+ if (_tmp3_) {
+ result = 0;
+ return result;
+ }
+ _tmp4_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp5_ = self->priv->attribute;
+ _tmp6_ = ((RygelMediaExportQueryContainer*) self)->expression;
+ _tmp7_ = rygel_media_export_media_cache_get_object_attribute_by_search_expression (_tmp4_, _tmp5_, _tmp6_, (glong) 0, (guint) (-1), &_inner_error_);
+ data = _tmp7_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return 0;
+ }
+ _tmp8_ = data;
+ _tmp9_ = gee_collection_get_size ((GeeCollection*) _tmp8_);
+ _tmp10_ = _tmp9_;
+ result = _tmp10_;
+ _g_object_unref0 (data);
+ return result;
+}
+
+
+static void rygel_media_export_node_query_container_class_init (RygelMediaExportNodeQueryContainerClass * klass) {
+ rygel_media_export_node_query_container_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportNodeQueryContainerPrivate));
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children = rygel_media_export_node_query_container_real_get_children;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children_finish = rygel_media_export_node_query_container_real_get_children_finish;
+ RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS (klass)->count_children = rygel_media_export_node_query_container_real_count_children;
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_node_query_container_finalize;
+}
+
+
+static void rygel_media_export_node_query_container_init (RygelMediaExportNodeQueryContainer * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_node_query_container_finalize (GObject* obj) {
+ RygelMediaExportNodeQueryContainer * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainer);
+ _g_free0 (self->priv->template);
+ _g_free0 (self->priv->attribute);
+ G_OBJECT_CLASS (rygel_media_export_node_query_container_parent_class)->finalize (obj);
+}
+
+
+GType rygel_media_export_node_query_container_get_type (void) {
+ static volatile gsize rygel_media_export_node_query_container_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_node_query_container_type_id__volatile)) {
+ static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportNodeQueryContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_node_query_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportNodeQueryContainer), 0, (GInstanceInitFunc) rygel_media_export_node_query_container_init, NULL };
+ GType rygel_media_export_node_query_container_type_id;
+ rygel_media_export_node_query_container_type_id = g_type_register_static (RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, "RygelMediaExportNodeQueryContainer", &g_define_type_info, 0);
+ g_once_init_leave (&rygel_media_export_node_query_container_type_id__volatile, rygel_media_export_node_query_container_type_id);
+ }
+ return rygel_media_export_node_query_container_type_id__volatile;
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-null-container.c b/src/media-export/rygel-media-export-null-container.c
new file mode 100644
index 0000000..6167c84
--- /dev/null
+++ b/src/media-export/rygel-media-export-null-container.c
@@ -0,0 +1,263 @@
+/* rygel-media-export-null-container.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-null-container.vala, do not modify */
+
+/*
+ * Copyright (C) 2009 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#include "rygel-media-export-null-container.h"
+
+/**
+ * This is an empty container used to satisfy rygel if no mediadb could be
+ * created
+ */
+
+G_DEFINE_TYPE (RygelMediaExportNullContainer, rygel_media_export_null_container, RYGEL_TYPE_MEDIA_CONTAINER)
+
+typedef struct _RygelMediaExportNullContainerGetChildrenData RygelMediaExportNullContainerGetChildrenData;
+
+struct _RygelMediaExportNullContainerGetChildrenData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportNullContainer* self;
+ guint offset;
+ guint max_count;
+ gchar* sort_criteria;
+ GCancellable* cancellable;
+ RygelMediaObjects* result;
+ RygelMediaObjects* _tmp0_;
+};
+
+typedef struct _RygelMediaExportNullContainerFindObjectData RygelMediaExportNullContainerFindObjectData;
+
+struct _RygelMediaExportNullContainerFindObjectData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportNullContainer* self;
+ gchar* id;
+ GCancellable* cancellable;
+ RygelMediaObject* result;
+};
+
+
+RygelMediaExportNullContainer* rygel_media_export_null_container_construct (GType object_type);
+static void rygel_media_export_null_container_real_get_children_data_free (gpointer _data);
+static void rygel_media_export_null_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_null_container_real_get_children_co (RygelMediaExportNullContainerGetChildrenData* _data_);
+static void rygel_media_export_null_container_real_find_object_data_free (gpointer _data);
+static void rygel_media_export_null_container_real_find_object (RygelMediaContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_null_container_real_find_object_co (RygelMediaExportNullContainerFindObjectData* _data_);
+
+
+RygelMediaExportNullContainer* rygel_media_export_null_container_construct (GType object_type) {
+ RygelMediaExportNullContainer * self = NULL;
+ self = (RygelMediaExportNullContainer*) rygel_media_container_construct_root (object_type, "MediaExport", 0);
+ return self;
+}
+
+
+RygelMediaExportNullContainer* rygel_media_export_null_container_new (void) {
+ return rygel_media_export_null_container_construct (RYGEL_MEDIA_EXPORT_TYPE_NULL_CONTAINER);
+}
+
+
+static void rygel_media_export_null_container_real_get_children_data_free (gpointer _data) {
+ RygelMediaExportNullContainerGetChildrenData* _data_;
+ _data_ = _data;
+ _g_free0 (_data_->sort_criteria);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportNullContainerGetChildrenData, _data_);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void rygel_media_export_null_container_real_get_children (RygelMediaContainer* base, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportNullContainer * self;
+ RygelMediaExportNullContainerGetChildrenData* _data_;
+ RygelMediaExportNullContainer* _tmp0_;
+ guint _tmp1_;
+ guint _tmp2_;
+ const gchar* _tmp3_;
+ gchar* _tmp4_;
+ GCancellable* _tmp5_;
+ GCancellable* _tmp6_;
+ self = (RygelMediaExportNullContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportNullContainerGetChildrenData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_null_container_real_get_children);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_null_container_real_get_children_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = offset;
+ _data_->offset = _tmp1_;
+ _tmp2_ = max_count;
+ _data_->max_count = _tmp2_;
+ _tmp3_ = sort_criteria;
+ _tmp4_ = g_strdup (_tmp3_);
+ _g_free0 (_data_->sort_criteria);
+ _data_->sort_criteria = _tmp4_;
+ _tmp5_ = cancellable;
+ _tmp6_ = _g_object_ref0 (_tmp5_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp6_;
+ rygel_media_export_null_container_real_get_children_co (_data_);
+}
+
+
+static RygelMediaObjects* rygel_media_export_null_container_real_get_children_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaObjects* result;
+ RygelMediaExportNullContainerGetChildrenData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static gboolean rygel_media_export_null_container_real_get_children_co (RygelMediaExportNullContainerGetChildrenData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = rygel_media_objects_new ();
+ _data_->result = _data_->_tmp0_;
+ 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;
+ 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_null_container_real_find_object_data_free (gpointer _data) {
+ RygelMediaExportNullContainerFindObjectData* _data_;
+ _data_ = _data;
+ _g_free0 (_data_->id);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportNullContainerFindObjectData, _data_);
+}
+
+
+static void rygel_media_export_null_container_real_find_object (RygelMediaContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportNullContainer * self;
+ RygelMediaExportNullContainerFindObjectData* _data_;
+ RygelMediaExportNullContainer* _tmp0_;
+ const gchar* _tmp1_;
+ gchar* _tmp2_;
+ GCancellable* _tmp3_;
+ GCancellable* _tmp4_;
+ self = (RygelMediaExportNullContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportNullContainerFindObjectData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_null_container_real_find_object);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_null_container_real_find_object_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = id;
+ _tmp2_ = g_strdup (_tmp1_);
+ _g_free0 (_data_->id);
+ _data_->id = _tmp2_;
+ _tmp3_ = cancellable;
+ _tmp4_ = _g_object_ref0 (_tmp3_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp4_;
+ rygel_media_export_null_container_real_find_object_co (_data_);
+}
+
+
+static RygelMediaObject* rygel_media_export_null_container_real_find_object_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaObject* result;
+ RygelMediaExportNullContainerFindObjectData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static gboolean rygel_media_export_null_container_real_find_object_co (RygelMediaExportNullContainerFindObjectData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->result = NULL;
+ 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;
+ 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_null_container_class_init (RygelMediaExportNullContainerClass * klass) {
+ rygel_media_export_null_container_parent_class = g_type_class_peek_parent (klass);
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children = rygel_media_export_null_container_real_get_children;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->get_children_finish = rygel_media_export_null_container_real_get_children_finish;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->find_object = rygel_media_export_null_container_real_find_object;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->find_object_finish = rygel_media_export_null_container_real_find_object_finish;
+}
+
+
+static void rygel_media_export_null_container_init (RygelMediaExportNullContainer * self) {
+}
+
+
+
+
diff --git a/src/media-export/rygel-media-export-null-container.h b/src/media-export/rygel-media-export-null-container.h
new file mode 100644
index 0000000..919a469
--- /dev/null
+++ b/src/media-export/rygel-media-export-null-container.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_NULL_CONTAINER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_NULL_CONTAINER_H__
+
+#include <rygel-server.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_NULL_CONTAINER (rygel_media_export_null_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_NULL_CONTAINER, RygelMediaExportNullContainer))
+#define RYGEL_MEDIA_EXPORT_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_NULL_CONTAINER, RygelMediaExportNullContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_NULL_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_NULL_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_NULL_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_NULL_CONTAINER, RygelMediaExportNullContainerClass))
+
+typedef struct _RygelMediaExportNullContainer RygelMediaExportNullContainer;
+typedef struct _RygelMediaExportNullContainerClass RygelMediaExportNullContainerClass;
+
+struct _RygelMediaExportNullContainer {
+ RygelMediaContainer parent_instance;
+};
+
+struct _RygelMediaExportNullContainerClass {
+ RygelMediaContainerClass parent_class;
+};
+
+GType rygel_media_export_null_container_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportNullContainer* rygel_media_export_null_container_new ();
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_NULL_CONTAINER_H__ */
diff --git a/src/media-export/rygel-media-export-object-factory.c b/src/media-export/rygel-media-export-object-factory.c
new file mode 100644
index 0000000..b87f5da
--- /dev/null
+++ b/src/media-export/rygel-media-export-object-factory.c
@@ -0,0 +1,441 @@
+/* rygel-media-export-object-factory.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-object-factory.vala, do not modify */
+
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-server.h>
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY (rygel_media_export_object_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactory))
+#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY))
+#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactoryClass))
+
+typedef struct _RygelMediaExportObjectFactory RygelMediaExportObjectFactory;
+typedef struct _RygelMediaExportObjectFactoryClass RygelMediaExportObjectFactoryClass;
+typedef struct _RygelMediaExportObjectFactoryPrivate RygelMediaExportObjectFactoryPrivate;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE (rygel_media_export_media_cache_get_type ())
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+
+typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
+typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER (rygel_media_export_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+
+typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
+typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER (rygel_media_export_root_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, RygelMediaExportRootContainer))
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, RygelMediaExportRootContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, RygelMediaExportRootContainerClass))
+
+typedef struct _RygelMediaExportRootContainer RygelMediaExportRootContainer;
+typedef struct _RygelMediaExportRootContainerClass RygelMediaExportRootContainerClass;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY (rygel_media_export_query_container_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactory))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
+
+typedef struct _RygelMediaExportQueryContainerFactory RygelMediaExportQueryContainerFactory;
+typedef struct _RygelMediaExportQueryContainerFactoryClass RygelMediaExportQueryContainerFactoryClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER (rygel_media_export_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainer))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+
+typedef struct _RygelMediaExportQueryContainer RygelMediaExportQueryContainer;
+typedef struct _RygelMediaExportQueryContainerClass RygelMediaExportQueryContainerClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER (rygel_media_export_writable_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer))
+#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_WRITABLE_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_WRITABLE_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainerClass))
+
+typedef struct _RygelMediaExportWritableDbContainer RygelMediaExportWritableDbContainer;
+typedef struct _RygelMediaExportWritableDbContainerClass RygelMediaExportWritableDbContainerClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM (rygel_media_export_music_item_get_type ())
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItem))
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItemClass))
+#define RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM))
+#define RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM))
+#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItemClass))
+
+typedef struct _RygelMediaExportMusicItem RygelMediaExportMusicItem;
+typedef struct _RygelMediaExportMusicItemClass RygelMediaExportMusicItemClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM (rygel_media_export_video_item_get_type ())
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItem))
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItemClass))
+#define RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM))
+#define RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM))
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItemClass))
+
+typedef struct _RygelMediaExportVideoItem RygelMediaExportVideoItem;
+typedef struct _RygelMediaExportVideoItemClass RygelMediaExportVideoItemClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM (rygel_media_export_photo_item_get_type ())
+#define RYGEL_MEDIA_EXPORT_PHOTO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM, RygelMediaExportPhotoItem))
+#define RYGEL_MEDIA_EXPORT_PHOTO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM, RygelMediaExportPhotoItemClass))
+#define RYGEL_MEDIA_EXPORT_IS_PHOTO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM))
+#define RYGEL_MEDIA_EXPORT_IS_PHOTO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM))
+#define RYGEL_MEDIA_EXPORT_PHOTO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM, RygelMediaExportPhotoItemClass))
+
+typedef struct _RygelMediaExportPhotoItem RygelMediaExportPhotoItem;
+typedef struct _RygelMediaExportPhotoItemClass RygelMediaExportPhotoItemClass;
+
+struct _RygelMediaExportObjectFactory {
+ GObject parent_instance;
+ RygelMediaExportObjectFactoryPrivate * priv;
+};
+
+struct _RygelMediaExportObjectFactoryClass {
+ GObjectClass parent_class;
+ RygelMediaExportDBContainer* (*get_container) (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title, guint child_count, const gchar* uri);
+ RygelMediaItem* (*get_item) (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, RygelMediaContainer* parent, const gchar* id, const gchar* title, const gchar* upnp_class);
+};
+
+
+static gpointer rygel_media_export_object_factory_parent_class = NULL;
+
+GType rygel_media_export_object_factory_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+enum {
+ RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_DUMMY_PROPERTY
+};
+RygelMediaExportDBContainer* rygel_media_export_object_factory_get_container (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title, guint child_count, const gchar* uri);
+static RygelMediaExportDBContainer* rygel_media_export_object_factory_real_get_container (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title, guint child_count, const gchar* uri);
+RygelMediaContainer* rygel_media_export_root_container_get_instance (GError** error);
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "Filesystem"
+GType rygel_media_export_root_container_get_type (void) G_GNUC_CONST;
+RygelMediaContainer* rygel_media_export_root_container_get_filesystem_container (RygelMediaExportRootContainer* self);
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "virtual-container:"
+GType rygel_media_export_query_container_factory_get_type (void) G_GNUC_CONST;
+RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_get_default (void);
+GType rygel_media_export_query_container_get_type (void) G_GNUC_CONST;
+RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_id (RygelMediaExportQueryContainerFactory* self, RygelMediaExportMediaCache* cache, const gchar* id, const gchar* name);
+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);
+RygelMediaExportWritableDbContainer* rygel_media_export_writable_db_container_new (RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title);
+RygelMediaExportWritableDbContainer* rygel_media_export_writable_db_container_construct (GType object_type, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title);
+GType rygel_media_export_writable_db_container_get_type (void) G_GNUC_CONST;
+RygelMediaItem* rygel_media_export_object_factory_get_item (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, RygelMediaContainer* parent, const gchar* id, const gchar* title, const gchar* upnp_class);
+static RygelMediaItem* rygel_media_export_object_factory_real_get_item (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, RygelMediaContainer* parent, const gchar* id, const gchar* title, const gchar* upnp_class);
+RygelMediaExportMusicItem* rygel_media_export_music_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+RygelMediaExportMusicItem* rygel_media_export_music_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+GType rygel_media_export_music_item_get_type (void) G_GNUC_CONST;
+RygelMediaExportVideoItem* rygel_media_export_video_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+RygelMediaExportVideoItem* rygel_media_export_video_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+GType rygel_media_export_video_item_get_type (void) G_GNUC_CONST;
+RygelMediaExportPhotoItem* rygel_media_export_photo_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+RygelMediaExportPhotoItem* rygel_media_export_photo_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+GType rygel_media_export_photo_item_get_type (void) G_GNUC_CONST;
+RygelMediaExportObjectFactory* rygel_media_export_object_factory_new (void);
+RygelMediaExportObjectFactory* rygel_media_export_object_factory_construct (GType object_type);
+
+
+/**
+ * Return a new instance of DBContainer
+ *
+ * @param media_db instance of MediaDB
+ * @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, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title, guint child_count, const gchar* uri) {
+ RygelMediaExportDBContainer* result = NULL;
+ const gchar* _tmp0_;
+ const gchar* _tmp8_;
+ gboolean _tmp9_ = FALSE;
+ const gchar* _tmp16_;
+ RygelMediaExportMediaCache* _tmp21_;
+ const gchar* _tmp22_;
+ const gchar* _tmp23_;
+ RygelMediaExportWritableDbContainer* _tmp24_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (media_db != NULL, 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_free0 (_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_unref0 (root_container);
+ return result;
+ }
+ goto __finally61;
+ __catch61_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ g_assert_not_reached ();
+ _g_error_free0 (_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_;
+ RygelMediaExportMediaCache* _tmp12_;
+ const gchar* _tmp13_;
+ const gchar* _tmp14_;
+ RygelMediaExportQueryContainer* _tmp15_ = NULL;
+ _tmp10_ = rygel_media_export_query_container_factory_get_default ();
+ factory = _tmp10_;
+ _tmp11_ = factory;
+ _tmp12_ = media_db;
+ _tmp13_ = id;
+ _tmp14_ = title;
+ _tmp15_ = rygel_media_export_query_container_factory_create_from_id (_tmp11_, _tmp12_, _tmp13_, _tmp14_);
+ result = (RygelMediaExportDBContainer*) _tmp15_;
+ _g_object_unref0 (factory);
+ return result;
+ }
+ _tmp16_ = uri;
+ if (_tmp16_ == NULL) {
+ RygelMediaExportMediaCache* _tmp17_;
+ const gchar* _tmp18_;
+ const gchar* _tmp19_;
+ RygelMediaExportDBContainer* _tmp20_;
+ _tmp17_ = media_db;
+ _tmp18_ = id;
+ _tmp19_ = title;
+ _tmp20_ = rygel_media_export_db_container_new (_tmp17_, _tmp18_, _tmp19_);
+ result = _tmp20_;
+ return result;
+ }
+ _tmp21_ = media_db;
+ _tmp22_ = id;
+ _tmp23_ = title;
+ _tmp24_ = rygel_media_export_writable_db_container_new (_tmp21_, _tmp22_, _tmp23_);
+ result = (RygelMediaExportDBContainer*) _tmp24_;
+ return result;
+}
+
+
+RygelMediaExportDBContainer* rygel_media_export_object_factory_get_container (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, 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, media_db, id, title, child_count, uri);
+}
+
+
+/**
+ * Return a new instance of MediaItem
+ *
+ * @param media_db instance of MediaDB
+ * @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, RygelMediaExportMediaCache* media_db, 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 (media_db != NULL, NULL);
+ 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 ();
+ }
+ }
+ }
+}
+
+
+RygelMediaItem* rygel_media_export_object_factory_get_item (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, 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, media_db, 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_construct (RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY);
+}
+
+
+static void rygel_media_export_object_factory_class_init (RygelMediaExportObjectFactoryClass * klass) {
+ rygel_media_export_object_factory_parent_class = g_type_class_peek_parent (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;
+}
+
+
+static void rygel_media_export_object_factory_init (RygelMediaExportObjectFactory * self) {
+}
+
+
+GType rygel_media_export_object_factory_get_type (void) {
+ static volatile gsize rygel_media_export_object_factory_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_object_factory_type_id__volatile)) {
+ static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportObjectFactoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_object_factory_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportObjectFactory), 0, (GInstanceInitFunc) rygel_media_export_object_factory_init, NULL };
+ GType rygel_media_export_object_factory_type_id;
+ rygel_media_export_object_factory_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelMediaExportObjectFactory", &g_define_type_info, 0);
+ g_once_init_leave (&rygel_media_export_object_factory_type_id__volatile, rygel_media_export_object_factory_type_id);
+ }
+ return rygel_media_export_object_factory_type_id__volatile;
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-photo-item.c b/src/media-export/rygel-media-export-photo-item.c
new file mode 100644
index 0000000..8e86f1c
--- /dev/null
+++ b/src/media-export/rygel-media-export-photo-item.c
@@ -0,0 +1,182 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-photo-item.h"
+#include "rygel-media-export-media-cache.h"
+
+
+static void rygel_media_export_photo_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface);
+
+G_DEFINE_TYPE_WITH_CODE (RygelMediaExportPhotoItem, rygel_media_export_photo_item, RYGEL_TYPE_PHOTO_ITEM,
+ G_IMPLEMENT_INTERFACE (RYGEL_TYPE_UPDATABLE_OBJECT, rygel_media_export_photo_item_rygel_updatable_object_interface_init))
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+typedef struct _RygelMediaExportPhotoItemCommitData RygelMediaExportPhotoItemCommitData;
+
+struct _RygelMediaExportPhotoItemCommitData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportPhotoItem* self;
+ RygelMediaExportMediaCache* _tmp0_;
+ RygelMediaExportMediaCache* cache;
+ RygelMediaExportMediaCache* _tmp1_;
+ GError * _inner_error_;
+};
+
+static RygelUpdatableObjectIface* rygel_media_export_photo_item_rygel_updatable_object_parent_iface = NULL;
+
+RygelMediaExportPhotoItem* rygel_media_export_photo_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+static void rygel_media_export_photo_item_real_commit_data_free (gpointer _data);
+static void rygel_media_export_photo_item_real_commit (RygelUpdatableObject* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_photo_item_real_commit_co (RygelMediaExportPhotoItemCommitData* _data_);
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
+void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
+
+
+RygelMediaExportPhotoItem* rygel_media_export_photo_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class) {
+ RygelMediaExportPhotoItem * 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 = (RygelMediaExportPhotoItem*) rygel_photo_item_construct (object_type, _tmp0_, _tmp1_, _tmp2_, _tmp3_);
+ return self;
+}
+
+
+RygelMediaExportPhotoItem* rygel_media_export_photo_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class) {
+ return rygel_media_export_photo_item_construct (RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM, id, parent, title, upnp_class);
+}
+
+
+static void rygel_media_export_photo_item_real_commit_data_free (gpointer _data) {
+ RygelMediaExportPhotoItemCommitData* _data_;
+ _data_ = _data;
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportPhotoItemCommitData, _data_);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void rygel_media_export_photo_item_real_commit (RygelUpdatableObject* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportPhotoItem * self;
+ RygelMediaExportPhotoItemCommitData* _data_;
+ RygelMediaExportPhotoItem* _tmp0_;
+ self = (RygelMediaExportPhotoItem*) base;
+ _data_ = g_slice_new0 (RygelMediaExportPhotoItemCommitData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_photo_item_real_commit);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_photo_item_real_commit_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ rygel_media_export_photo_item_real_commit_co (_data_);
+}
+
+
+static void rygel_media_export_photo_item_real_commit_finish (RygelUpdatableObject* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaExportPhotoItemCommitData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static gboolean rygel_media_export_photo_item_real_commit_co (RygelMediaExportPhotoItemCommitData* _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_unref0 (_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_unref0 (_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_photo_item_class_init (RygelMediaExportPhotoItemClass * klass) {
+ rygel_media_export_photo_item_parent_class = g_type_class_peek_parent (klass);
+}
+
+
+static void rygel_media_export_photo_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface) {
+ rygel_media_export_photo_item_rygel_updatable_object_parent_iface = g_type_interface_peek_parent (iface);
+ iface->commit = (void (*)(RygelUpdatableObject*, GError**)) rygel_media_export_photo_item_real_commit;
+ iface->commit_finish = rygel_media_export_photo_item_real_commit_finish;
+}
+
+
+static void rygel_media_export_photo_item_init (RygelMediaExportPhotoItem * self) {
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-photo-item.h b/src/media-export/rygel-media-export-photo-item.h
new file mode 100644
index 0000000..e81b8df
--- /dev/null
+++ b/src/media-export/rygel-media-export-photo-item.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_PHOTO_ITEM_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_PHOTO_ITEM_H__
+
+#include <rygel-server.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM (rygel_media_export_photo_item_get_type ())
+#define RYGEL_MEDIA_EXPORT_PHOTO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM, RygelMediaExportPhotoItem))
+#define RYGEL_MEDIA_EXPORT_PHOTO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM, RygelMediaExportPhotoItemClass))
+#define RYGEL_MEDIA_EXPORT_IS_PHOTO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM))
+#define RYGEL_MEDIA_EXPORT_IS_PHOTO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM))
+#define RYGEL_MEDIA_EXPORT_PHOTO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_PHOTO_ITEM, RygelMediaExportPhotoItemClass))
+
+typedef struct _RygelMediaExportPhotoItem RygelMediaExportPhotoItem;
+typedef struct _RygelMediaExportPhotoItemClass RygelMediaExportPhotoItemClass;
+typedef struct _RygelMediaExportPhotoItemPrivate RygelMediaExportPhotoItemPrivate;
+
+struct _RygelMediaExportPhotoItem {
+ RygelPhotoItem parent_instance;
+ RygelMediaExportPhotoItemPrivate *priv;
+};
+
+struct _RygelMediaExportPhotoItemClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_photo_item_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportPhotoItem* rygel_media_export_photo_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_PHOTO_ITEM_H__ */
diff --git a/src/media-export/rygel-media-export-plugin.c b/src/media-export/rygel-media-export-plugin.c
new file mode 100644
index 0000000..a0203e7
--- /dev/null
+++ b/src/media-export/rygel-media-export-plugin.c
@@ -0,0 +1,450 @@
+/*
+ * Copyright (C) 2008-2009 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * 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;
+};
+
+
+#define TRACKER_PLUGIN "Tracker"
+
+static Block1Data* block1_data_ref (Block1Data* _data1_);
+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 gboolean __lambda7_ (Block1Data* _data1_);
+void on_plugin_available (RygelPlugin* plugin, RygelPlugin* our_plugin);
+static void __lambda9_ (Block1Data* _data1_, RygelPlugin* new_plugin);
+static void ___lambda9__rygel_plugin_loader_plugin_available (RygelPluginLoader* _sender, RygelPlugin* plugin, gpointer self);
+static gboolean ___lambda7__gsource_func (gpointer self);
+static Block2Data* block2_data_ref (Block2Data* _data2_);
+static void block2_data_unref (void * _userdata_);
+static void ____lambda8_ (Block2Data* _data2_);
+void shutdown_media_export (void);
+static void _____lambda8__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self);
+
+/**
+ * Simple plugin which exposes the media contents of a directory via UPnP.
+ *
+ */
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static Block1Data* block1_data_ref (Block1Data* _data1_) {
+ g_atomic_int_inc (&_data1_->_ref_count_);
+ return _data1_;
+}
+
+
+static void block1_data_unref (void * _userdata_) {
+ Block1Data* _data1_;
+ _data1_ = (Block1Data*) _userdata_;
+ if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
+ _g_object_unref0 (_data1_->plugin);
+ _g_object_unref0 (_data1_->loader);
+ g_slice_free (Block1Data, _data1_);
+ }
+}
+
+
+static void __lambda9_ (Block1Data* _data1_, RygelPlugin* new_plugin) {
+ RygelPlugin* _tmp0_;
+ RygelMediaExportPlugin* _tmp1_;
+ g_return_if_fail (new_plugin != NULL);
+ _tmp0_ = new_plugin;
+ _tmp1_ = _data1_->plugin;
+ on_plugin_available (_tmp0_, (RygelPlugin*) _tmp1_);
+}
+
+
+static void ___lambda9__rygel_plugin_loader_plugin_available (RygelPluginLoader* _sender, RygelPlugin* plugin, gpointer self) {
+ __lambda9_ (self, plugin);
+}
+
+
+static gboolean __lambda7_ (Block1Data* _data1_) {
+ gboolean result = FALSE;
+ RygelPluginLoader* _tmp11_;
+ {
+ RygelPluginLoader* _tmp0_;
+ GeeCollection* _tmp1_ = NULL;
+ GeeCollection* _tmp2_;
+ GeeIterator* _tmp3_ = NULL;
+ GeeIterator* _tmp4_;
+ GeeIterator* _loaded_plugin_it;
+ _tmp0_ = _data1_->loader;
+ _tmp1_ = rygel_plugin_loader_list_plugins (_tmp0_);
+ _tmp2_ = _tmp1_;
+ _tmp3_ = gee_iterable_iterator ((GeeIterable*) _tmp2_);
+ _tmp4_ = _tmp3_;
+ _g_object_unref0 (_tmp2_);
+ _loaded_plugin_it = _tmp4_;
+ while (TRUE) {
+ GeeIterator* _tmp5_;
+ gboolean _tmp6_ = FALSE;
+ GeeIterator* _tmp7_;
+ gpointer _tmp8_ = NULL;
+ RygelPlugin* loaded_plugin;
+ RygelPlugin* _tmp9_;
+ RygelMediaExportPlugin* _tmp10_;
+ _tmp5_ = _loaded_plugin_it;
+ _tmp6_ = gee_iterator_next (_tmp5_);
+ if (!_tmp6_) {
+ break;
+ }
+ _tmp7_ = _loaded_plugin_it;
+ _tmp8_ = gee_iterator_get (_tmp7_);
+ loaded_plugin = (RygelPlugin*) _tmp8_;
+ _tmp9_ = loaded_plugin;
+ _tmp10_ = _data1_->plugin;
+ on_plugin_available (_tmp9_, (RygelPlugin*) _tmp10_);
+ _g_object_unref0 (loaded_plugin);
+ }
+ _g_object_unref0 (_loaded_plugin_it);
+ }
+ _tmp11_ = _data1_->loader;
+ g_signal_connect_data (_tmp11_, "plugin-available", (GCallback) ___lambda9__rygel_plugin_loader_plugin_available, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
+ result = FALSE;
+ return result;
+}
+
+
+static gboolean ___lambda7__gsource_func (gpointer self) {
+ gboolean result;
+ result = __lambda7_ (self);
+ return result;
+}
+
+
+void module_init (RygelPluginLoader* loader) {
+ Block1Data* _data1_;
+ RygelPluginLoader* _tmp0_;
+ RygelPluginLoader* _tmp1_;
+ RygelPluginLoader* _tmp2_;
+ gboolean _tmp3_ = FALSE;
+ RygelPluginLoader* _tmp8_;
+ RygelMediaExportPlugin* _tmp9_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (loader != NULL);
+ _data1_ = g_slice_new0 (Block1Data);
+ _data1_->_ref_count_ = 1;
+ _tmp0_ = loader;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (_data1_->loader);
+ _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;
+ }
+ _g_object_unref0 (_data1_->plugin);
+ _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_free0 (_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;
+ }
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda7__gsource_func, block1_data_ref (_data1_), block1_data_unref);
+ _tmp8_ = _data1_->loader;
+ _tmp9_ = _data1_->plugin;
+ rygel_plugin_loader_add_plugin (_tmp8_, (RygelPlugin*) _tmp9_);
+ block1_data_unref (_data1_);
+ _data1_ = NULL;
+}
+
+
+static Block2Data* block2_data_ref (Block2Data* _data2_) {
+ g_atomic_int_inc (&_data2_->_ref_count_);
+ return _data2_;
+}
+
+
+static void block2_data_unref (void * _userdata_) {
+ Block2Data* _data2_;
+ _data2_ = (Block2Data*) _userdata_;
+ if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
+ _g_object_unref0 (_data2_->plugin);
+ _g_object_unref0 (_data2_->our_plugin);
+ g_slice_free (Block2Data, _data2_);
+ }
+}
+
+
+static void ____lambda8_ (Block2Data* _data2_) {
+ RygelPlugin* _tmp0_;
+ gboolean _tmp1_;
+ gboolean _tmp2_;
+ _tmp0_ = _data2_->plugin;
+ _tmp1_ = rygel_plugin_get_active (_tmp0_);
+ _tmp2_ = _tmp1_;
+ if (_tmp2_) {
+ RygelPlugin* _tmp3_;
+ RygelPlugin* _tmp4_;
+ gboolean _tmp5_;
+ gboolean _tmp6_;
+ shutdown_media_export ();
+ _tmp3_ = _data2_->our_plugin;
+ _tmp4_ = _data2_->plugin;
+ _tmp5_ = rygel_plugin_get_active (_tmp4_);
+ _tmp6_ = _tmp5_;
+ rygel_plugin_set_active (_tmp3_, !_tmp6_);
+ }
+}
+
+
+static void _____lambda8__g_object_notify (GObject* _sender, GParamSpec* pspec, gpointer self) {
+ ____lambda8_ (self);
+}
+
+
+void on_plugin_available (RygelPlugin* plugin, RygelPlugin* our_plugin) {
+ Block2Data* _data2_;
+ RygelPlugin* _tmp0_;
+ RygelPlugin* _tmp1_;
+ RygelPlugin* _tmp2_;
+ RygelPlugin* _tmp3_;
+ RygelPlugin* _tmp4_;
+ const gchar* _tmp5_;
+ const gchar* _tmp6_;
+ g_return_if_fail (plugin != NULL);
+ g_return_if_fail (our_plugin != NULL);
+ _data2_ = g_slice_new0 (Block2Data);
+ _data2_->_ref_count_ = 1;
+ _tmp0_ = plugin;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (_data2_->plugin);
+ _data2_->plugin = _tmp1_;
+ _tmp2_ = our_plugin;
+ _tmp3_ = _g_object_ref0 (_tmp2_);
+ _g_object_unref0 (_data2_->our_plugin);
+ _data2_->our_plugin = _tmp3_;
+ _tmp4_ = _data2_->plugin;
+ _tmp5_ = rygel_plugin_get_name (_tmp4_);
+ _tmp6_ = _tmp5_;
+ if (g_strcmp0 (_tmp6_, TRACKER_PLUGIN) == 0) {
+ gboolean _tmp7_ = FALSE;
+ RygelPlugin* _tmp8_;
+ gboolean _tmp9_;
+ gboolean _tmp10_;
+ gboolean _tmp14_;
+ _tmp8_ = _data2_->our_plugin;
+ _tmp9_ = rygel_plugin_get_active (_tmp8_);
+ _tmp10_ = _tmp9_;
+ if (_tmp10_) {
+ RygelPlugin* _tmp11_;
+ gboolean _tmp12_;
+ gboolean _tmp13_;
+ _tmp11_ = _data2_->plugin;
+ _tmp12_ = rygel_plugin_get_active (_tmp11_);
+ _tmp13_ = _tmp12_;
+ _tmp7_ = !_tmp13_;
+ } else {
+ _tmp7_ = FALSE;
+ }
+ _tmp14_ = _tmp7_;
+ if (_tmp14_) {
+ RygelPlugin* _tmp15_;
+ _tmp15_ = _data2_->plugin;
+ g_signal_connect_data ((GObject*) _tmp15_, "notify::active", (GCallback) _____lambda8__g_object_notify, block2_data_ref (_data2_), (GClosureNotify) block2_data_unref, 0);
+ } else {
+ RygelPlugin* _tmp16_;
+ gboolean _tmp17_;
+ gboolean _tmp18_;
+ RygelPlugin* _tmp19_;
+ gboolean _tmp20_;
+ gboolean _tmp21_;
+ _tmp16_ = _data2_->our_plugin;
+ _tmp17_ = rygel_plugin_get_active (_tmp16_);
+ _tmp18_ = _tmp17_;
+ _tmp19_ = _data2_->plugin;
+ _tmp20_ = rygel_plugin_get_active (_tmp19_);
+ _tmp21_ = _tmp20_;
+ if (_tmp18_ == _tmp21_) {
+ RygelPlugin* _tmp22_;
+ gboolean _tmp23_;
+ gboolean _tmp24_;
+ RygelPlugin* _tmp25_;
+ RygelPlugin* _tmp26_;
+ gboolean _tmp27_;
+ gboolean _tmp28_;
+ _tmp22_ = _data2_->plugin;
+ _tmp23_ = rygel_plugin_get_active (_tmp22_);
+ _tmp24_ = _tmp23_;
+ if (_tmp24_) {
+ shutdown_media_export ();
+ } else {
+ g_message ("rygel-media-export-plugin.vala:79: Plugin '%s' inactivate, activating " \
+"'%s' plugin", TRACKER_PLUGIN, RYGEL_MEDIA_EXPORT_PLUGIN_NAME);
+ }
+ _tmp25_ = _data2_->our_plugin;
+ _tmp26_ = _data2_->plugin;
+ _tmp27_ = rygel_plugin_get_active (_tmp26_);
+ _tmp28_ = _tmp27_;
+ rygel_plugin_set_active (_tmp25_, !_tmp28_);
+ }
+ }
+ }
+ block2_data_unref (_data2_);
+ _data2_ = NULL;
+}
+
+
+void shutdown_media_export (void) {
+ GError * _inner_error_ = NULL;
+ g_message ("rygel-media-export-plugin.vala:89: Deactivating plugin '%s' in favor o" \
+"f plugin '%s'", RYGEL_MEDIA_EXPORT_PLUGIN_NAME, TRACKER_PLUGIN);
+ {
+ RygelMetaConfig* _tmp0_ = NULL;
+ RygelMetaConfig* config;
+ RygelMetaConfig* _tmp1_;
+ gboolean _tmp2_ = FALSE;
+ gboolean enabled;
+ gboolean _tmp3_;
+ _tmp0_ = rygel_meta_config_get_default ();
+ config = _tmp0_;
+ _tmp1_ = config;
+ _tmp2_ = rygel_configuration_get_bool ((RygelConfiguration*) _tmp1_, "MediaExport", "enabled", &_inner_error_);
+ enabled = _tmp2_;
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (config);
+ goto __catch1_g_error;
+ }
+ _tmp3_ = enabled;
+ if (_tmp3_) {
+ RygelMediaContainer* _tmp4_ = NULL;
+ RygelMediaContainer* _tmp5_;
+ RygelMediaExportRootContainer* root;
+ RygelMediaExportRootContainer* _tmp6_;
+ _tmp4_ = rygel_media_export_root_container_get_instance (&_inner_error_);
+ _tmp5_ = _tmp4_;
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (config);
+ goto __catch1_g_error;
+ }
+ root = G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER) ? ((RygelMediaExportRootContainer*) _tmp5_) : NULL;
+ _tmp6_ = root;
+ rygel_media_export_root_container_shutdown (_tmp6_);
+ _g_object_unref0 (root);
+ }
+ _g_object_unref0 (config);
+ }
+ goto __finally1;
+ __catch1_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally1:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+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_unref0 (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_unref0 (_tmp2_);
+ return self;
+}
+
+
+RygelMediaExportPlugin* rygel_media_export_plugin_new (GError** error) {
+ return rygel_media_export_plugin_construct (RYGEL_MEDIA_EXPORT_TYPE_PLUGIN, error);
+}
+
+
+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) {
+}
+
+
diff --git a/src/media-export/rygel-media-export-plugin.h b/src/media-export/rygel-media-export-plugin.h
new file mode 100644
index 0000000..f7b4e90
--- /dev/null
+++ b/src/media-export/rygel-media-export-plugin.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_PLUGIN_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_PLUGIN_H__
+
+#include "rygel-media-export-db-container.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_PLUGIN (rygel_media_export_plugin_get_type ())
+#define RYGEL_MEDIA_EXPORT_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_PLUGIN, RygelMediaExportPlugin))
+#define RYGEL_MEDIA_EXPORT_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_PLUGIN, RygelMediaExportPluginClass))
+#define RYGEL_MEDIA_EXPORT_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_PLUGIN))
+#define RYGEL_MEDIA_EXPORT_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_PLUGIN))
+#define RYGEL_MEDIA_EXPORT_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_PLUGIN, RygelMediaExportPluginClass))
+
+typedef struct _RygelMediaExportPlugin RygelMediaExportPlugin;
+typedef struct _RygelMediaExportPluginClass RygelMediaExportPluginClass;
+typedef struct _RygelMediaExportPluginPrivate RygelMediaExportPluginPrivate;
+
+struct _RygelMediaExportPlugin {
+ RygelMediaEngine parent_instance;
+ RygelMediaExportPluginPrivate *priv;
+};
+
+struct _RygelMediaExportPluginClass {
+ RygelMediaEngineClass parent_class;
+};
+
+GType rygel_media_export_plugin_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportPlugin* rygel_media_export_plugin_new (GError** error);
+
+void module_init (RygelPluginLoader* loader);
+
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_PLUGIN_H__ */
diff --git a/src/media-export/rygel-media-export-query-container-factory.c b/src/media-export/rygel-media-export-query-container-factory.c
new file mode 100644
index 0000000..90a3ab4
--- /dev/null
+++ b/src/media-export/rygel-media-export-query-container-factory.c
@@ -0,0 +1,920 @@
+/* rygel-media-export-query-container-factory.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-query-container-factory.vala, do not modify */
+
+/*
+ * Copyright (C) 2011 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gee.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-server.h>
+#include <libgupnp-av/gupnp-av.h>
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY (rygel_media_export_query_container_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactory))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
+
+typedef struct _RygelMediaExportQueryContainerFactory RygelMediaExportQueryContainerFactory;
+typedef struct _RygelMediaExportQueryContainerFactoryClass RygelMediaExportQueryContainerFactoryClass;
+typedef struct _RygelMediaExportQueryContainerFactoryPrivate RygelMediaExportQueryContainerFactoryPrivate;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE (rygel_media_export_media_cache_get_type ())
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+
+typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
+typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER (rygel_media_export_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+
+typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
+typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER (rygel_media_export_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainer))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+
+typedef struct _RygelMediaExportQueryContainer RygelMediaExportQueryContainer;
+typedef struct _RygelMediaExportQueryContainerClass RygelMediaExportQueryContainerClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER (rygel_media_export_leaf_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_LEAF_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER, RygelMediaExportLeafQueryContainer))
+#define RYGEL_MEDIA_EXPORT_LEAF_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER, RygelMediaExportLeafQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_LEAF_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_LEAF_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_LEAF_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_LEAF_QUERY_CONTAINER, RygelMediaExportLeafQueryContainerClass))
+
+typedef struct _RygelMediaExportLeafQueryContainer RygelMediaExportLeafQueryContainer;
+typedef struct _RygelMediaExportLeafQueryContainerClass RygelMediaExportLeafQueryContainerClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER (rygel_media_export_node_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainer))
+#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_NODE_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_NODE_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainerClass))
+
+typedef struct _RygelMediaExportNodeQueryContainer RygelMediaExportNodeQueryContainer;
+typedef struct _RygelMediaExportNodeQueryContainerClass RygelMediaExportNodeQueryContainerClass;
+#define _rygel_search_expression_unref0(var) ((var == NULL) ? NULL : (var = (rygel_search_expression_unref (var), NULL)))
+
+struct _RygelMediaExportQueryContainerFactory {
+ GObject parent_instance;
+ RygelMediaExportQueryContainerFactoryPrivate * priv;
+};
+
+struct _RygelMediaExportQueryContainerFactoryClass {
+ GObjectClass parent_class;
+};
+
+struct _RygelMediaExportQueryContainerFactoryPrivate {
+ GeeHashMap* virtual_container_map;
+};
+
+
+static gpointer rygel_media_export_query_container_factory_parent_class = NULL;
+static RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_instance;
+static RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_instance = NULL;
+
+GType rygel_media_export_query_container_factory_get_type (void) G_GNUC_CONST;
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_DUMMY_PROPERTY
+};
+RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_get_default (void);
+static RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_new (void);
+static RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_construct (GType object_type);
+void rygel_media_export_query_container_factory_register_id (RygelMediaExportQueryContainerFactory* self, gchar** id);
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "virtual-container:"
+gchar* rygel_media_export_query_container_factory_get_virtual_container_definition (RygelMediaExportQueryContainerFactory* self, const gchar* hash);
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_query_container_get_type (void) G_GNUC_CONST;
+RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_id (RygelMediaExportQueryContainerFactory* self, RygelMediaExportMediaCache* cache, const gchar* id, const gchar* name);
+RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_description (RygelMediaExportQueryContainerFactory* self, RygelMediaExportMediaCache* cache, const gchar* definition, const gchar* name);
+static RygelSearchExpression* rygel_media_export_query_container_factory_parse_description (RygelMediaExportQueryContainerFactory* self, const gchar* description, gchar** pattern, gchar** attribute, gchar** upnp_class, gchar** name);
+RygelMediaExportLeafQueryContainer* rygel_media_export_leaf_query_container_new (RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name);
+RygelMediaExportLeafQueryContainer* rygel_media_export_leaf_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name);
+GType rygel_media_export_leaf_query_container_get_type (void) G_GNUC_CONST;
+RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_new (RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute);
+RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute);
+GType rygel_media_export_node_query_container_get_type (void) G_GNUC_CONST;
+static gchar* rygel_media_export_query_container_factory_map_upnp_class (RygelMediaExportQueryContainerFactory* self, const gchar* attribute);
+static void rygel_media_export_query_container_factory_update_search_expression (RygelMediaExportQueryContainerFactory* self, RygelSearchExpression** expression, const gchar* key, const gchar* value);
+static void rygel_media_export_query_container_factory_finalize (GObject* obj);
+static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
+static gint _vala_array_length (gpointer array);
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_get_default (void) {
+ RygelMediaExportQueryContainerFactory* result = NULL;
+ RygelMediaExportQueryContainerFactory* _tmp0_;
+ gboolean _tmp1_ = FALSE;
+ RygelMediaExportQueryContainerFactory* _tmp3_;
+ RygelMediaExportQueryContainerFactory* _tmp4_;
+ _tmp0_ = rygel_media_export_query_container_factory_instance;
+ _tmp1_ = G_UNLIKELY (_tmp0_ == NULL);
+ if (_tmp1_) {
+ RygelMediaExportQueryContainerFactory* _tmp2_;
+ _tmp2_ = rygel_media_export_query_container_factory_new ();
+ _g_object_unref0 (rygel_media_export_query_container_factory_instance);
+ rygel_media_export_query_container_factory_instance = _tmp2_;
+ }
+ _tmp3_ = rygel_media_export_query_container_factory_instance;
+ _tmp4_ = _g_object_ref0 (_tmp3_);
+ result = _tmp4_;
+ return result;
+}
+
+
+static RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_construct (GType object_type) {
+ RygelMediaExportQueryContainerFactory * self = NULL;
+ GeeHashMap* _tmp0_;
+ self = (RygelMediaExportQueryContainerFactory*) g_object_new (object_type, NULL);
+ _tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ _g_object_unref0 (self->priv->virtual_container_map);
+ self->priv->virtual_container_map = _tmp0_;
+ return self;
+}
+
+
+static RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_new (void) {
+ return rygel_media_export_query_container_factory_construct (RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY);
+}
+
+
+/**
+ * Register a plaintext description for a query container. The passed
+ * string will be modified to the checksum id of the container.
+ *
+ * @param id Originally contains the plaintext id which is replaced with
+ * the hashed id on return.
+ */
+void rygel_media_export_query_container_factory_register_id (RygelMediaExportQueryContainerFactory* self, gchar** id) {
+ const gchar* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* md5;
+ GeeHashMap* _tmp2_;
+ const gchar* _tmp3_;
+ gboolean _tmp4_ = FALSE;
+ const gchar* _tmp10_;
+ gchar* _tmp11_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (*id != NULL);
+ _tmp0_ = *id;
+ _tmp1_ = g_compute_checksum_for_string (G_CHECKSUM_MD5, _tmp0_, (gsize) (-1));
+ md5 = _tmp1_;
+ _tmp2_ = self->priv->virtual_container_map;
+ _tmp3_ = md5;
+ _tmp4_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp2_, _tmp3_);
+ if (!_tmp4_) {
+ GeeHashMap* _tmp5_;
+ const gchar* _tmp6_;
+ const gchar* _tmp7_;
+ const gchar* _tmp8_;
+ const gchar* _tmp9_;
+ _tmp5_ = self->priv->virtual_container_map;
+ _tmp6_ = md5;
+ _tmp7_ = *id;
+ gee_abstract_map_set ((GeeAbstractMap*) _tmp5_, _tmp6_, _tmp7_);
+ _tmp8_ = md5;
+ _tmp9_ = *id;
+ g_debug ("rygel-media-export-query-container-factory.vala:58: Registering %s for" \
+" %s", _tmp8_, _tmp9_);
+ }
+ _tmp10_ = md5;
+ _tmp11_ = g_strconcat (RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX, _tmp10_, NULL);
+ _g_free0 (*id);
+ *id = _tmp11_;
+ _g_free0 (md5);
+}
+
+
+/**
+ * Get the plaintext definition from a hashed id.
+ *
+ * Inverse function of register_id().
+ *
+ * @param hash A hashed id
+ * @return the plaintext defintion of the virtual folder
+ */
+static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
+ gchar* result = NULL;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (old != NULL, NULL);
+ g_return_val_if_fail (replacement != NULL, NULL);
+ {
+ const gchar* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* _tmp2_;
+ GRegex* _tmp3_;
+ GRegex* _tmp4_;
+ GRegex* regex;
+ GRegex* _tmp5_;
+ const gchar* _tmp6_;
+ gchar* _tmp7_ = NULL;
+ gchar* _tmp8_;
+ _tmp0_ = old;
+ _tmp1_ = g_regex_escape_string (_tmp0_, -1);
+ _tmp2_ = _tmp1_;
+ _tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
+ _tmp4_ = _tmp3_;
+ _g_free0 (_tmp2_);
+ regex = _tmp4_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_REGEX_ERROR) {
+ goto __catch40_g_regex_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = regex;
+ _tmp6_ = replacement;
+ _tmp7_ = g_regex_replace_literal (_tmp5_, self, (gssize) (-1), 0, _tmp6_, 0, &_inner_error_);
+ _tmp8_ = _tmp7_;
+ if (_inner_error_ != NULL) {
+ _g_regex_unref0 (regex);
+ if (_inner_error_->domain == G_REGEX_ERROR) {
+ goto __catch40_g_regex_error;
+ }
+ _g_regex_unref0 (regex);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ result = _tmp8_;
+ _g_regex_unref0 (regex);
+ return result;
+ }
+ goto __finally40;
+ __catch40_g_regex_error:
+ {
+ GError* e = NULL;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ g_assert_not_reached ();
+ _g_error_free0 (e);
+ }
+ __finally40:
+ if (_inner_error_ != 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 NULL;
+ }
+}
+
+
+gchar* rygel_media_export_query_container_factory_get_virtual_container_definition (RygelMediaExportQueryContainerFactory* self, const gchar* hash) {
+ gchar* result = NULL;
+ const gchar* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* id;
+ GeeHashMap* _tmp2_;
+ gpointer _tmp3_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (hash != NULL, NULL);
+ _tmp0_ = hash;
+ _tmp1_ = string_replace (_tmp0_, RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX, "");
+ id = _tmp1_;
+ _tmp2_ = self->priv->virtual_container_map;
+ _tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp2_, id);
+ result = (gchar*) _tmp3_;
+ _g_free0 (id);
+ return result;
+}
+
+
+/**
+ * Factory method.
+ *
+ * Create a QueryContainer directly from MD5 hashed id.
+ *
+ * @param cache An instance of the meta-data cache
+ * @param id The hashed id of the container
+ * @param name An the title of the container. If not supplied, it will
+ * be derived from the plain-text description of the
+ * container
+ * @return A new instance of QueryContainer or null if id does not exist
+ */
+RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_id (RygelMediaExportQueryContainerFactory* self, RygelMediaExportMediaCache* cache, const gchar* id, const gchar* name) {
+ RygelMediaExportQueryContainer* result = NULL;
+ const gchar* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* definition;
+ const gchar* _tmp2_;
+ RygelMediaExportMediaCache* _tmp3_;
+ const gchar* _tmp4_;
+ const gchar* _tmp5_;
+ RygelMediaExportQueryContainer* _tmp6_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (cache != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ _tmp0_ = id;
+ _tmp1_ = rygel_media_export_query_container_factory_get_virtual_container_definition (self, _tmp0_);
+ definition = _tmp1_;
+ _tmp2_ = definition;
+ if (_tmp2_ == NULL) {
+ result = NULL;
+ _g_free0 (definition);
+ return result;
+ }
+ _tmp3_ = cache;
+ _tmp4_ = definition;
+ _tmp5_ = name;
+ _tmp6_ = rygel_media_export_query_container_factory_create_from_description (self, _tmp3_, _tmp4_, _tmp5_);
+ result = _tmp6_;
+ _g_free0 (definition);
+ return result;
+}
+
+
+/**
+ * Factory method.
+ *
+ * Create a QueryContainer from a plain-text description string.
+ *
+ * @param cache An instance of the meta-data cache
+ * @param definition Plain-text defintion of the query-container
+ * @param name The title of the container. If not supplied, it
+ * will be derived from the plain-text description of
+ * the container
+ * @return A new instance of QueryContainer
+ */
+RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_description (RygelMediaExportQueryContainerFactory* self, RygelMediaExportMediaCache* cache, const gchar* definition, const gchar* name) {
+ RygelMediaExportQueryContainer* result = NULL;
+ const gchar* _tmp0_;
+ gchar* _tmp1_;
+ gchar* title;
+ gchar* attribute;
+ gchar* pattern;
+ gchar* upnp_class;
+ const gchar* _tmp2_;
+ gchar* _tmp3_;
+ gchar* id;
+ RygelMediaExportQueryContainer* container = NULL;
+ const gchar* _tmp4_;
+ gchar* _tmp5_ = NULL;
+ gchar* _tmp6_ = NULL;
+ gchar* _tmp7_ = NULL;
+ RygelSearchExpression* _tmp8_ = NULL;
+ RygelSearchExpression* expression;
+ gboolean _tmp9_ = FALSE;
+ const gchar* _tmp10_;
+ gboolean _tmp12_;
+ const gchar* _tmp25_;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (cache != NULL, NULL);
+ g_return_val_if_fail (definition != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ _tmp0_ = name;
+ _tmp1_ = g_strdup (_tmp0_);
+ title = _tmp1_;
+ attribute = NULL;
+ pattern = NULL;
+ upnp_class = NULL;
+ _tmp2_ = definition;
+ _tmp3_ = g_strdup (_tmp2_);
+ id = _tmp3_;
+ rygel_media_export_query_container_factory_register_id (self, &id);
+ _tmp4_ = definition;
+ _tmp8_ = rygel_media_export_query_container_factory_parse_description (self, _tmp4_, &_tmp5_, &_tmp6_, &_tmp7_, &title);
+ _g_free0 (pattern);
+ pattern = _tmp5_;
+ _g_free0 (attribute);
+ attribute = _tmp6_;
+ _g_free0 (upnp_class);
+ upnp_class = _tmp7_;
+ expression = _tmp8_;
+ _tmp10_ = pattern;
+ if (_tmp10_ == NULL) {
+ _tmp9_ = TRUE;
+ } else {
+ const gchar* _tmp11_;
+ _tmp11_ = pattern;
+ _tmp9_ = g_strcmp0 (_tmp11_, "") == 0;
+ }
+ _tmp12_ = _tmp9_;
+ if (_tmp12_) {
+ RygelMediaExportMediaCache* _tmp13_;
+ RygelSearchExpression* _tmp14_;
+ const gchar* _tmp15_;
+ const gchar* _tmp16_;
+ RygelMediaExportLeafQueryContainer* _tmp17_;
+ _tmp13_ = cache;
+ _tmp14_ = expression;
+ _tmp15_ = id;
+ _tmp16_ = title;
+ _tmp17_ = rygel_media_export_leaf_query_container_new (_tmp13_, _tmp14_, _tmp15_, _tmp16_);
+ _g_object_unref0 (container);
+ container = (RygelMediaExportQueryContainer*) _tmp17_;
+ } else {
+ RygelMediaExportMediaCache* _tmp18_;
+ RygelSearchExpression* _tmp19_;
+ const gchar* _tmp20_;
+ const gchar* _tmp21_;
+ const gchar* _tmp22_;
+ const gchar* _tmp23_;
+ RygelMediaExportNodeQueryContainer* _tmp24_;
+ _tmp18_ = cache;
+ _tmp19_ = expression;
+ _tmp20_ = id;
+ _tmp21_ = title;
+ _tmp22_ = pattern;
+ _tmp23_ = attribute;
+ _tmp24_ = rygel_media_export_node_query_container_new (_tmp18_, _tmp19_, _tmp20_, _tmp21_, _tmp22_, _tmp23_);
+ _g_object_unref0 (container);
+ container = (RygelMediaExportQueryContainer*) _tmp24_;
+ }
+ _tmp25_ = upnp_class;
+ if (_tmp25_ != NULL) {
+ RygelMediaExportQueryContainer* _tmp26_;
+ const gchar* _tmp27_;
+ const gchar* _tmp28_;
+ _tmp26_ = container;
+ _tmp27_ = upnp_class;
+ rygel_media_object_set_upnp_class ((RygelMediaObject*) _tmp26_, _tmp27_);
+ _tmp28_ = upnp_class;
+ if (g_strcmp0 (_tmp28_, RYGEL_MEDIA_CONTAINER_MUSIC_ALBUM) == 0) {
+ RygelMediaExportQueryContainer* _tmp29_;
+ _tmp29_ = container;
+ rygel_media_container_set_sort_criteria ((RygelMediaContainer*) _tmp29_, RYGEL_MEDIA_CONTAINER_ALBUM_SORT_CRITERIA);
+ }
+ }
+ result = container;
+ _rygel_search_expression_unref0 (expression);
+ _g_free0 (id);
+ _g_free0 (upnp_class);
+ _g_free0 (pattern);
+ _g_free0 (attribute);
+ _g_free0 (title);
+ return result;
+}
+
+
+/**
+ * Map a DIDL attribute to a UPnP container class.
+ *
+ * @return A matching UPnP class for the attribute or null if it can't be
+ * mapped.
+ */
+static gchar* rygel_media_export_query_container_factory_map_upnp_class (RygelMediaExportQueryContainerFactory* self, const gchar* attribute) {
+ gchar* result = NULL;
+ const gchar* _tmp0_;
+ const gchar* _tmp1_;
+ GQuark _tmp3_ = 0U;
+ static GQuark _tmp2_label0 = 0;
+ static GQuark _tmp2_label1 = 0;
+ static GQuark _tmp2_label2 = 0;
+ static GQuark _tmp2_label3 = 0;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (attribute != NULL, NULL);
+ _tmp0_ = attribute;
+ _tmp1_ = _tmp0_;
+ _tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
+ if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("upnp:album")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp4_;
+ _tmp4_ = g_strdup (RYGEL_MEDIA_CONTAINER_MUSIC_ALBUM);
+ result = _tmp4_;
+ return result;
+ }
+ }
+ } else if ((_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("dc:creator")))) || (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("upnp:artist"))))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp5_;
+ _tmp5_ = g_strdup (RYGEL_MEDIA_CONTAINER_MUSIC_ARTIST);
+ result = _tmp5_;
+ return result;
+ }
+ }
+ } else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("dc:genre")))) {
+ switch (0) {
+ default:
+ {
+ gchar* _tmp6_;
+ _tmp6_ = g_strdup (RYGEL_MEDIA_CONTAINER_MUSIC_GENRE);
+ result = _tmp6_;
+ return result;
+ }
+ }
+ } else {
+ switch (0) {
+ default:
+ {
+ result = NULL;
+ return result;
+ }
+ }
+ }
+}
+
+
+/**
+ * Parse a plaintext container description into a search expression.
+ *
+ * Also generates a name for the container and other meta-data necessary
+ * for node containers.
+ *
+ * @param description The plaintext container description
+ * @param pattern Contains the pattern used for child containers if
+ * descrption is for a node container, null otherwise.
+ * @param attribute Contains the UPnP attribute the container describes.
+ * @param name If passed empty, name will be generated from the
+ * description.
+ * @return A SearchExpression corresponding to the non-variable part of
+ * the description.
+ */
+static gpointer _rygel_search_expression_ref0 (gpointer self) {
+ return self ? rygel_search_expression_ref (self) : NULL;
+}
+
+
+static RygelSearchExpression* rygel_media_export_query_container_factory_parse_description (RygelMediaExportQueryContainerFactory* self, const gchar* description, gchar** pattern, gchar** attribute, gchar** upnp_class, gchar** name) {
+ gchar* _vala_pattern = NULL;
+ gchar* _vala_attribute = NULL;
+ gchar* _vala_upnp_class = NULL;
+ RygelSearchExpression* result = NULL;
+ const gchar* _tmp0_;
+ gchar** _tmp1_;
+ gchar** _tmp2_ = NULL;
+ gchar** args;
+ gint args_length1;
+ gint _args_size_;
+ RygelSearchExpression* _tmp3_;
+ RygelSearchExpression* expression;
+ gint i;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (description != NULL, NULL);
+ g_return_val_if_fail (*name != NULL, NULL);
+ _tmp0_ = description;
+ _tmp2_ = _tmp1_ = g_strsplit (_tmp0_, ",", 0);
+ args = _tmp2_;
+ args_length1 = _vala_array_length (_tmp1_);
+ _args_size_ = args_length1;
+ _tmp3_ = _rygel_search_expression_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (NULL, RYGEL_TYPE_SEARCH_EXPRESSION) ? ((RygelSearchExpression*) NULL) : NULL);
+ expression = _tmp3_;
+ _g_free0 (_vala_pattern);
+ _vala_pattern = NULL;
+ _g_free0 (_vala_attribute);
+ _vala_attribute = NULL;
+ _g_free0 (_vala_upnp_class);
+ _vala_upnp_class = NULL;
+ i = 0;
+ while (TRUE) {
+ gint _tmp4_;
+ gchar** _tmp5_;
+ gint _tmp5__length1;
+ const gchar* _tmp6_;
+ gchar* _tmp7_;
+ gchar* previous_attribute;
+ gchar** _tmp8_;
+ gint _tmp8__length1;
+ gint _tmp9_;
+ const gchar* _tmp10_;
+ gchar* _tmp11_ = NULL;
+ const gchar* _tmp12_;
+ gchar* _tmp13_ = NULL;
+ gchar** _tmp14_;
+ gint _tmp14__length1;
+ gint _tmp15_;
+ const gchar* _tmp16_;
+ gint _tmp43_;
+ _tmp4_ = i;
+ _tmp5_ = args;
+ _tmp5__length1 = args_length1;
+ if (!(_tmp4_ < _tmp5__length1)) {
+ break;
+ }
+ _tmp6_ = _vala_attribute;
+ _tmp7_ = g_strdup (_tmp6_);
+ previous_attribute = _tmp7_;
+ _tmp8_ = args;
+ _tmp8__length1 = args_length1;
+ _tmp9_ = i;
+ _tmp10_ = _tmp8_[_tmp9_];
+ _tmp11_ = string_replace (_tmp10_, RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX, "");
+ _g_free0 (_vala_attribute);
+ _vala_attribute = _tmp11_;
+ _tmp12_ = _vala_attribute;
+ _tmp13_ = g_uri_unescape_string (_tmp12_, NULL);
+ _g_free0 (_vala_attribute);
+ _vala_attribute = _tmp13_;
+ _tmp14_ = args;
+ _tmp14__length1 = args_length1;
+ _tmp15_ = i;
+ _tmp16_ = _tmp14_[_tmp15_ + 1];
+ if (g_strcmp0 (_tmp16_, "?") != 0) {
+ gchar** _tmp17_;
+ gint _tmp17__length1;
+ gint _tmp18_;
+ const gchar* _tmp19_;
+ gchar** _tmp20_;
+ gint _tmp20__length1;
+ gint _tmp21_;
+ const gchar* _tmp22_;
+ gint _tmp23_;
+ gchar** _tmp24_;
+ gint _tmp24__length1;
+ _tmp17_ = args;
+ _tmp17__length1 = args_length1;
+ _tmp18_ = i;
+ _tmp19_ = _tmp17_[_tmp18_];
+ _tmp20_ = args;
+ _tmp20__length1 = args_length1;
+ _tmp21_ = i;
+ _tmp22_ = _tmp20_[_tmp21_ + 1];
+ rygel_media_export_query_container_factory_update_search_expression (self, &expression, _tmp19_, _tmp22_);
+ _tmp23_ = i;
+ _tmp24_ = args;
+ _tmp24__length1 = args_length1;
+ if ((_tmp23_ + 2) == _tmp24__length1) {
+ const gchar* _tmp25_;
+ gchar* _tmp26_ = NULL;
+ _tmp25_ = _vala_attribute;
+ _tmp26_ = rygel_media_export_query_container_factory_map_upnp_class (self, _tmp25_);
+ _g_free0 (_vala_upnp_class);
+ _vala_upnp_class = _tmp26_;
+ }
+ } else {
+ gchar** _tmp27_;
+ gint _tmp27__length1;
+ gint _tmp28_;
+ gchar* _tmp29_;
+ gchar* _tmp30_;
+ gchar** _tmp31_;
+ gint _tmp31__length1;
+ gchar* _tmp32_ = NULL;
+ const gchar* _tmp33_;
+ gchar* _tmp34_ = NULL;
+ gboolean _tmp35_ = FALSE;
+ const gchar* _tmp36_;
+ gboolean _tmp38_;
+ _tmp27_ = args;
+ _tmp27__length1 = args_length1;
+ _tmp28_ = i;
+ _tmp29_ = g_strdup ("%s");
+ _g_free0 (_tmp27_[_tmp28_ + 1]);
+ _tmp27_[_tmp28_ + 1] = _tmp29_;
+ _tmp30_ = _tmp27_[_tmp28_ + 1];
+ _tmp31_ = args;
+ _tmp31__length1 = args_length1;
+ _tmp32_ = g_strjoinv (",", _tmp31_);
+ _g_free0 (_vala_pattern);
+ _vala_pattern = _tmp32_;
+ _tmp33_ = previous_attribute;
+ _tmp34_ = rygel_media_export_query_container_factory_map_upnp_class (self, _tmp33_);
+ _g_free0 (_vala_upnp_class);
+ _vala_upnp_class = _tmp34_;
+ _tmp36_ = *name;
+ if (g_strcmp0 (_tmp36_, "") == 0) {
+ gint _tmp37_;
+ _tmp37_ = i;
+ _tmp35_ = _tmp37_ > 0;
+ } else {
+ _tmp35_ = FALSE;
+ }
+ _tmp38_ = _tmp35_;
+ if (_tmp38_) {
+ gchar** _tmp39_;
+ gint _tmp39__length1;
+ gint _tmp40_;
+ const gchar* _tmp41_;
+ gchar* _tmp42_ = NULL;
+ _tmp39_ = args;
+ _tmp39__length1 = args_length1;
+ _tmp40_ = i;
+ _tmp41_ = _tmp39_[_tmp40_ - 1];
+ _tmp42_ = g_uri_unescape_string (_tmp41_, NULL);
+ _g_free0 (*name);
+ *name = _tmp42_;
+ }
+ _g_free0 (previous_attribute);
+ break;
+ }
+ _tmp43_ = i;
+ i = _tmp43_ + 2;
+ _g_free0 (previous_attribute);
+ }
+ result = expression;
+ args = (_vala_array_free (args, args_length1, (GDestroyNotify) g_free), NULL);
+ if (pattern) {
+ *pattern = _vala_pattern;
+ } else {
+ _g_free0 (_vala_pattern);
+ }
+ if (attribute) {
+ *attribute = _vala_attribute;
+ } else {
+ _g_free0 (_vala_attribute);
+ }
+ if (upnp_class) {
+ *upnp_class = _vala_upnp_class;
+ } else {
+ _g_free0 (_vala_upnp_class);
+ }
+ return result;
+}
+
+
+/**
+ * Update a SearchExpression with a new key = value condition.
+ *
+ * Will modifiy the passed expression to (expression AND (key = value))
+ *
+ * @param expression The expression to update or null to create a new one
+ * @param key Key of the key/value condition
+ * @param value Value of the key/value condition
+ */
+static void rygel_media_export_query_container_factory_update_search_expression (RygelMediaExportQueryContainerFactory* self, RygelSearchExpression** expression, const gchar* key, const gchar* value) {
+ RygelRelationalExpression* _tmp0_;
+ RygelRelationalExpression* subexpression;
+ const gchar* _tmp1_;
+ gchar* _tmp2_ = NULL;
+ gchar* clean_key;
+ RygelRelationalExpression* _tmp3_;
+ const gchar* _tmp4_;
+ gchar* _tmp5_ = NULL;
+ RygelRelationalExpression* _tmp6_;
+ RygelRelationalExpression* _tmp7_;
+ const gchar* _tmp8_;
+ gchar* _tmp9_ = NULL;
+ RygelSearchExpression* _tmp10_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (key != NULL);
+ g_return_if_fail (value != NULL);
+ _tmp0_ = rygel_relational_expression_new ();
+ subexpression = _tmp0_;
+ _tmp1_ = key;
+ _tmp2_ = string_replace (_tmp1_, RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX, "");
+ clean_key = _tmp2_;
+ _tmp3_ = subexpression;
+ _tmp4_ = clean_key;
+ _tmp5_ = g_uri_unescape_string (_tmp4_, NULL);
+ _g_free0 (((RygelSearchExpression*) _tmp3_)->operand1);
+ ((RygelSearchExpression*) _tmp3_)->operand1 = _tmp5_;
+ _tmp6_ = subexpression;
+ ((RygelSearchExpression*) _tmp6_)->op = (gpointer) ((gintptr) GUPNP_SEARCH_CRITERIA_OP_EQ);
+ _tmp7_ = subexpression;
+ _tmp8_ = value;
+ _tmp9_ = g_uri_unescape_string (_tmp8_, NULL);
+ _g_free0 (((RygelSearchExpression*) _tmp7_)->operand2);
+ ((RygelSearchExpression*) _tmp7_)->operand2 = _tmp9_;
+ _tmp10_ = *expression;
+ if (_tmp10_ != NULL) {
+ RygelLogicalExpression* _tmp11_;
+ RygelLogicalExpression* conjunction;
+ RygelLogicalExpression* _tmp12_;
+ RygelSearchExpression* _tmp13_;
+ RygelSearchExpression* _tmp14_;
+ RygelLogicalExpression* _tmp15_;
+ RygelRelationalExpression* _tmp16_;
+ RygelSearchExpression* _tmp17_;
+ RygelLogicalExpression* _tmp18_;
+ RygelLogicalExpression* _tmp19_;
+ RygelSearchExpression* _tmp20_;
+ _tmp11_ = rygel_logical_expression_new ();
+ conjunction = _tmp11_;
+ _tmp12_ = conjunction;
+ _tmp13_ = *expression;
+ _tmp14_ = _rygel_search_expression_ref0 (_tmp13_);
+ _rygel_search_expression_unref0 (((RygelSearchExpression*) _tmp12_)->operand1);
+ ((RygelSearchExpression*) _tmp12_)->operand1 = _tmp14_;
+ _tmp15_ = conjunction;
+ _tmp16_ = subexpression;
+ _tmp17_ = _rygel_search_expression_ref0 ((RygelSearchExpression*) _tmp16_);
+ _rygel_search_expression_unref0 (((RygelSearchExpression*) _tmp15_)->operand2);
+ ((RygelSearchExpression*) _tmp15_)->operand2 = _tmp17_;
+ _tmp18_ = conjunction;
+ ((RygelSearchExpression*) _tmp18_)->op = (gpointer) ((gintptr) RYGEL_LOGICAL_OPERATOR_AND);
+ _tmp19_ = conjunction;
+ _tmp20_ = _rygel_search_expression_ref0 ((RygelSearchExpression*) _tmp19_);
+ _rygel_search_expression_unref0 (*expression);
+ *expression = _tmp20_;
+ _rygel_search_expression_unref0 (conjunction);
+ } else {
+ RygelRelationalExpression* _tmp21_;
+ RygelSearchExpression* _tmp22_;
+ _tmp21_ = subexpression;
+ _tmp22_ = _rygel_search_expression_ref0 ((RygelSearchExpression*) _tmp21_);
+ _rygel_search_expression_unref0 (*expression);
+ *expression = _tmp22_;
+ }
+ _g_free0 (clean_key);
+ _rygel_search_expression_unref0 (subexpression);
+}
+
+
+static void rygel_media_export_query_container_factory_class_init (RygelMediaExportQueryContainerFactoryClass * klass) {
+ rygel_media_export_query_container_factory_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportQueryContainerFactoryPrivate));
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_query_container_factory_finalize;
+}
+
+
+static void rygel_media_export_query_container_factory_init (RygelMediaExportQueryContainerFactory * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_query_container_factory_finalize (GObject* obj) {
+ RygelMediaExportQueryContainerFactory * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactory);
+ _g_object_unref0 (self->priv->virtual_container_map);
+ G_OBJECT_CLASS (rygel_media_export_query_container_factory_parent_class)->finalize (obj);
+}
+
+
+GType rygel_media_export_query_container_factory_get_type (void) {
+ static volatile gsize rygel_media_export_query_container_factory_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_query_container_factory_type_id__volatile)) {
+ static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportQueryContainerFactoryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_query_container_factory_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportQueryContainerFactory), 0, (GInstanceInitFunc) rygel_media_export_query_container_factory_init, NULL };
+ GType rygel_media_export_query_container_factory_type_id;
+ rygel_media_export_query_container_factory_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelMediaExportQueryContainerFactory", &g_define_type_info, 0);
+ g_once_init_leave (&rygel_media_export_query_container_factory_type_id__volatile, rygel_media_export_query_container_factory_type_id);
+ }
+ return rygel_media_export_query_container_factory_type_id__volatile;
+}
+
+
+static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+ if ((array != NULL) && (destroy_func != NULL)) {
+ int i;
+ for (i = 0; i < array_length; i = i + 1) {
+ if (((gpointer*) array)[i] != NULL) {
+ destroy_func (((gpointer*) array)[i]);
+ }
+ }
+ }
+}
+
+
+static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
+ _vala_array_destroy (array, array_length, destroy_func);
+ g_free (array);
+}
+
+
+static gint _vala_array_length (gpointer array) {
+ int length;
+ length = 0;
+ if (array) {
+ while (((gpointer*) array)[length]) {
+ length++;
+ }
+ }
+ return length;
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-query-container.c b/src/media-export/rygel-media-export-query-container.c
new file mode 100644
index 0000000..191ae53
--- /dev/null
+++ b/src/media-export/rygel-media-export-query-container.c
@@ -0,0 +1,364 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-query-container.h"
+
+G_DEFINE_TYPE (RygelMediaExportQueryContainer, rygel_media_export_query_container, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER)
+
+#define _rygel_search_expression_unref0(var) ((var == NULL) ? NULL : (var = (rygel_search_expression_unref (var), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+typedef struct _RygelMediaExportQueryContainerSearchData RygelMediaExportQueryContainerSearchData;
+
+
+struct _RygelMediaExportQueryContainerSearchData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportQueryContainer* self;
+ RygelSearchExpression* expression;
+ guint offset;
+ guint max_count;
+ guint total_matches;
+ gchar* sort_criteria;
+ GCancellable* cancellable;
+ RygelMediaObjects* result;
+ RygelMediaObjects* children;
+ RygelSearchExpression* combined_expression;
+ RygelSearchExpression* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ RygelSearchExpression* _tmp2_;
+ RygelLogicalExpression* _tmp3_;
+ RygelLogicalExpression* local_expression;
+ RygelLogicalExpression* _tmp4_;
+ RygelSearchExpression* _tmp5_;
+ RygelSearchExpression* _tmp6_;
+ RygelLogicalExpression* _tmp7_;
+ RygelLogicalExpression* _tmp8_;
+ RygelSearchExpression* _tmp9_;
+ RygelSearchExpression* _tmp10_;
+ RygelLogicalExpression* _tmp11_;
+ RygelSearchExpression* _tmp12_;
+ RygelMediaExportMediaCache* _tmp13_;
+ RygelSearchExpression* _tmp14_;
+ const gchar* _tmp15_;
+ guint _tmp16_;
+ guint _tmp17_;
+ guint _tmp18_;
+ RygelMediaObjects* _tmp19_;
+ RygelMediaObjects* _tmp20_;
+ GError* _error_;
+ GError* _tmp21_;
+ RygelMediaObjects* _tmp22_;
+ GError* _tmp23_;
+ GError* _tmp24_;
+ GError * _inner_error_;
+};
+
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "virtual-container:"
+RygelMediaExportQueryContainer* rygel_media_export_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name);
+
+gint rygel_media_export_query_container_count_children (RygelMediaExportQueryContainer* self, GError** error);
+static void rygel_media_export_query_container_real_search_data_free (gpointer _data);
+static void rygel_media_export_query_container_real_search (RygelMediaExportDBContainer* base, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_query_container_real_search_co (RygelMediaExportQueryContainerSearchData* _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 gint rygel_media_export_query_container_real_count_children (RygelMediaExportQueryContainer* self, GError** error);
+static void rygel_media_export_query_container_finalize (GObject* obj);
+
+
+static gpointer _rygel_search_expression_ref0 (gpointer self) {
+ return self ? rygel_search_expression_ref (self) : NULL;
+}
+
+
+RygelMediaExportQueryContainer* rygel_media_export_query_container_construct (GType object_type, RygelMediaExportMediaCache* cache, RygelSearchExpression* expression, const gchar* id, const gchar* name) {
+ RygelMediaExportQueryContainer * self = NULL;
+ RygelMediaExportMediaCache* _tmp0_;
+ const gchar* _tmp1_;
+ const gchar* _tmp2_;
+ RygelSearchExpression* _tmp3_;
+ RygelSearchExpression* _tmp4_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (cache != NULL, NULL);
+ g_return_val_if_fail (expression != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+ _tmp0_ = cache;
+ _tmp1_ = id;
+ _tmp2_ = name;
+ self = (RygelMediaExportQueryContainer*) rygel_media_export_db_container_construct (object_type, _tmp0_, _tmp1_, _tmp2_);
+ _tmp3_ = expression;
+ _tmp4_ = _rygel_search_expression_ref0 (_tmp3_);
+ _rygel_search_expression_unref0 (self->expression);
+ self->expression = _tmp4_;
+ {
+ gint _tmp5_ = 0;
+ gint _tmp6_;
+ _tmp5_ = rygel_media_export_query_container_count_children (self, &_inner_error_);
+ _tmp6_ = _tmp5_;
+ if (_inner_error_ != NULL) {
+ goto __catch38_g_error;
+ }
+ ((RygelMediaContainer*) self)->child_count = _tmp6_;
+ }
+ goto __finally38;
+ __catch38_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ ((RygelMediaContainer*) self)->child_count = 0;
+ _g_error_free0 (_error_);
+ }
+ __finally38:
+ if (_inner_error_ != 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 NULL;
+ }
+ return self;
+}
+
+
+static void rygel_media_export_query_container_real_search_data_free (gpointer _data) {
+ RygelMediaExportQueryContainerSearchData* _data_;
+ _data_ = _data;
+ _rygel_search_expression_unref0 (_data_->expression);
+ _g_free0 (_data_->sort_criteria);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportQueryContainerSearchData, _data_);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void rygel_media_export_query_container_real_search (RygelMediaExportDBContainer* base, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportQueryContainer * self;
+ RygelMediaExportQueryContainerSearchData* _data_;
+ RygelMediaExportQueryContainer* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ RygelSearchExpression* _tmp2_;
+ guint _tmp3_;
+ guint _tmp4_;
+ const gchar* _tmp5_;
+ gchar* _tmp6_;
+ GCancellable* _tmp7_;
+ GCancellable* _tmp8_;
+ self = (RygelMediaExportQueryContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportQueryContainerSearchData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_query_container_real_search);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_query_container_real_search_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = expression;
+ _tmp2_ = _rygel_search_expression_ref0 (_tmp1_);
+ _rygel_search_expression_unref0 (_data_->expression);
+ _data_->expression = _tmp2_;
+ _tmp3_ = offset;
+ _data_->offset = _tmp3_;
+ _tmp4_ = max_count;
+ _data_->max_count = _tmp4_;
+ _tmp5_ = sort_criteria;
+ _tmp6_ = g_strdup (_tmp5_);
+ _g_free0 (_data_->sort_criteria);
+ _data_->sort_criteria = _tmp6_;
+ _tmp7_ = cancellable;
+ _tmp8_ = _g_object_ref0 (_tmp7_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp8_;
+ rygel_media_export_query_container_real_search_co (_data_);
+}
+
+
+static RygelMediaObjects* rygel_media_export_query_container_real_search_finish (RygelMediaExportDBContainer* base, GAsyncResult* _res_, guint* total_matches, GError** error) {
+ RygelMediaObjects* result;
+ RygelMediaExportQueryContainerSearchData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ if (total_matches) {
+ *total_matches = _data_->total_matches;
+ }
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static gpointer _g_error_copy0 (gpointer self) {
+ return self ? g_error_copy (self) : NULL;
+}
+
+
+static gboolean rygel_media_export_query_container_real_search_co (RygelMediaExportQueryContainerSearchData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->children = NULL;
+ _data_->_tmp0_ = _data_->expression;
+ if (_data_->_tmp0_ == NULL) {
+ _data_->_tmp1_ = _data_->self->expression;
+ _data_->_tmp2_ = _rygel_search_expression_ref0 (_data_->_tmp1_);
+ _rygel_search_expression_unref0 (_data_->combined_expression);
+ _data_->combined_expression = _data_->_tmp2_;
+ } else {
+ _data_->_tmp3_ = rygel_logical_expression_new ();
+ _data_->local_expression = _data_->_tmp3_;
+ _data_->_tmp4_ = _data_->local_expression;
+ _data_->_tmp5_ = _data_->self->expression;
+ _data_->_tmp6_ = _rygel_search_expression_ref0 (_data_->_tmp5_);
+ _rygel_search_expression_unref0 (((RygelSearchExpression*) _data_->_tmp4_)->operand1);
+ ((RygelSearchExpression*) _data_->_tmp4_)->operand1 = _data_->_tmp6_;
+ _data_->_tmp7_ = _data_->local_expression;
+ ((RygelSearchExpression*) _data_->_tmp7_)->op = (gpointer) ((gintptr) RYGEL_LOGICAL_OPERATOR_AND);
+ _data_->_tmp8_ = _data_->local_expression;
+ _data_->_tmp9_ = _data_->expression;
+ _data_->_tmp10_ = _rygel_search_expression_ref0 (_data_->_tmp9_);
+ _rygel_search_expression_unref0 (((RygelSearchExpression*) _data_->_tmp8_)->operand2);
+ ((RygelSearchExpression*) _data_->_tmp8_)->operand2 = _data_->_tmp10_;
+ _data_->_tmp11_ = _data_->local_expression;
+ _data_->_tmp12_ = _rygel_search_expression_ref0 ((RygelSearchExpression*) _data_->_tmp11_);
+ _rygel_search_expression_unref0 (_data_->combined_expression);
+ _data_->combined_expression = _data_->_tmp12_;
+ _rygel_search_expression_unref0 (_data_->local_expression);
+ }
+ {
+ _data_->_tmp13_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp14_ = _data_->combined_expression;
+ _data_->_tmp15_ = _data_->sort_criteria;
+ _data_->_tmp16_ = _data_->offset;
+ _data_->_tmp17_ = _data_->max_count;
+ _data_->_tmp18_ = 0U;
+ _data_->_tmp19_ = NULL;
+ _data_->_tmp19_ = rygel_media_export_media_cache_get_objects_by_search_expression (_data_->_tmp13_, _data_->_tmp14_, NULL, _data_->_tmp15_, _data_->_tmp16_, _data_->_tmp17_, &_data_->_tmp18_, &_data_->_inner_error_);
+ _data_->total_matches = _data_->_tmp18_;
+ _data_->_tmp20_ = _data_->_tmp19_;
+ if (_data_->_inner_error_ != NULL) {
+ if (_data_->_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR) {
+ goto __catch39_rygel_media_export_media_cache_error;
+ }
+ goto __finally39;
+ }
+ _g_object_unref0 (_data_->children);
+ _data_->children = _data_->_tmp20_;
+ }
+ goto __finally39;
+ __catch39_rygel_media_export_media_cache_error:
+ {
+ _data_->_error_ = _data_->_inner_error_;
+ _data_->_inner_error_ = NULL;
+ _data_->_tmp21_ = _data_->_error_;
+ if (g_error_matches (_data_->_tmp21_, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH)) {
+ _data_->_tmp22_ = rygel_media_objects_new ();
+ _g_object_unref0 (_data_->children);
+ _data_->children = _data_->_tmp22_;
+ _data_->total_matches = (guint) 0;
+ } else {
+ _data_->_tmp23_ = _data_->_error_;
+ _data_->_tmp24_ = _g_error_copy0 (_data_->_tmp23_);
+ _data_->_inner_error_ = _data_->_tmp24_;
+ _g_error_free0 (_data_->_error_);
+ goto __finally39;
+ }
+ _g_error_free0 (_data_->_error_);
+ }
+ __finally39:
+ if (_data_->_inner_error_ != NULL) {
+ g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
+ g_error_free (_data_->_inner_error_);
+ _rygel_search_expression_unref0 (_data_->combined_expression);
+ _g_object_unref0 (_data_->children);
+ 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_->result = _data_->children;
+ _rygel_search_expression_unref0 (_data_->combined_expression);
+ 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;
+ _rygel_search_expression_unref0 (_data_->combined_expression);
+ _g_object_unref0 (_data_->children);
+ 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 gint rygel_media_export_query_container_real_count_children (RygelMediaExportQueryContainer* self, GError** error) {
+ g_critical ("Type `%s' does not implement abstract method `rygel_media_export_query_container_count_children'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
+ return 0;
+}
+
+
+gint rygel_media_export_query_container_count_children (RygelMediaExportQueryContainer* self, GError** error) {
+ g_return_val_if_fail (self != NULL, 0);
+ return RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_GET_CLASS (self)->count_children (self, error);
+}
+
+
+static void rygel_media_export_query_container_class_init (RygelMediaExportQueryContainerClass * klass) {
+ rygel_media_export_query_container_parent_class = g_type_class_peek_parent (klass);
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (klass)->search = rygel_media_export_query_container_real_search;
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (klass)->search_finish = rygel_media_export_query_container_real_search_finish;
+ RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS (klass)->count_children = rygel_media_export_query_container_real_count_children;
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_query_container_finalize;
+}
+
+
+static void rygel_media_export_query_container_init (RygelMediaExportQueryContainer * self) {
+}
+
+
+static void rygel_media_export_query_container_finalize (GObject* obj) {
+ RygelMediaExportQueryContainer * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainer);
+ _rygel_search_expression_unref0 (self->expression);
+ G_OBJECT_CLASS (rygel_media_export_query_container_parent_class)->finalize (obj);
+}
+
+
diff --git a/src/media-export/rygel-media-export-query-container.h b/src/media-export/rygel-media-export-query-container.h
new file mode 100644
index 0000000..2590c1d
--- /dev/null
+++ b/src/media-export/rygel-media-export-query-container.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_QUERY_CONTAINER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_QUERY_CONTAINER_H__
+
+#include "rygel-media-export-db-container.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER (rygel_media_export_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainer))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+
+typedef struct _RygelMediaExportQueryContainer RygelMediaExportQueryContainer;
+typedef struct _RygelMediaExportQueryContainerClass RygelMediaExportQueryContainerClass;
+typedef struct _RygelMediaExportQueryContainerPrivate RygelMediaExportQueryContainerPrivate;
+
+struct _RygelMediaExportQueryContainer {
+ RygelMediaExportDBContainer parent_instance;
+ RygelMediaExportQueryContainerPrivate * priv;
+ RygelSearchExpression* expression;
+};
+
+struct _RygelMediaExportQueryContainerClass {
+ RygelMediaExportDBContainerClass parent_class;
+ gint (*count_children) (RygelMediaExportQueryContainer* self, GError** error);
+};
+
+GType rygel_media_export_query_container_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportQueryContainer* rygel_media_export_query_container_new (RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_QUERY_CONTAINER_H__ */
diff --git a/src/media-export/rygel-media-export-recursive-file-monitor.c b/src/media-export/rygel-media-export-recursive-file-monitor.c
new file mode 100644
index 0000000..fad79cf
--- /dev/null
+++ b/src/media-export/rygel-media-export-recursive-file-monitor.c
@@ -0,0 +1,469 @@
+/* rygel-media-export-recursive-file-monitor.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-recursive-file-monitor.vala, do not modify */
+
+/*
+ * Copyright (C) 2009 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#include "rygel-media-export-recursive-file-monitor.h"
+#include <glib/gi18n-lib.h>
+
+G_DEFINE_TYPE (RygelMediaExportRecursiveFileMonitor, rygel_media_export_recursive_file_monitor, G_TYPE_OBJECT)
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+typedef struct _RygelMediaExportRecursiveFileMonitorAddData RygelMediaExportRecursiveFileMonitorAddData;
+
+
+struct _RygelMediaExportRecursiveFileMonitorPrivate {
+ GCancellable* cancellable;
+ GeeHashMap* monitors;
+ gboolean monitor_changes;
+};
+
+struct _RygelMediaExportRecursiveFileMonitorAddData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportRecursiveFileMonitor* self;
+ GFile* file;
+ gboolean _tmp0_;
+ gboolean _tmp1_;
+ GeeHashMap* _tmp2_;
+ GFile* _tmp3_;
+ gboolean _tmp4_;
+ gboolean _tmp5_;
+ GFile* _tmp6_;
+ GFileInfo* _tmp7_;
+ GFileInfo* info;
+ GFileInfo* _tmp8_;
+ GFileType _tmp9_;
+ GFile* _tmp10_;
+ GCancellable* _tmp11_;
+ GFileMonitor* _tmp12_;
+ GFileMonitor* file_monitor;
+ GeeHashMap* _tmp13_;
+ GFile* _tmp14_;
+ GFileMonitor* _tmp15_;
+ GFileMonitor* _tmp16_;
+ GError* err;
+ const gchar* _tmp17_;
+ GFile* _tmp18_;
+ gchar* _tmp19_;
+ gchar* _tmp20_;
+ GError * _inner_error_;
+};
+
+
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitorPrivate))
+
+RygelMediaExportRecursiveFileMonitor* rygel_media_export_recursive_file_monitor_construct (GType object_type, GCancellable* cancellable);
+void rygel_media_export_recursive_file_monitor_cancel (RygelMediaExportRecursiveFileMonitor* self);
+static void _rygel_media_export_recursive_file_monitor_cancel_g_cancellable_cancelled (GCancellable* _sender, gpointer self);
+void rygel_media_export_recursive_file_monitor_on_monitor_changed (RygelMediaExportRecursiveFileMonitor* self, GFile* file, GFile* other_file, GFileMonitorEvent event_type);
+void rygel_media_export_recursive_file_monitor_add (RygelMediaExportRecursiveFileMonitor* self, GFile* file, GAsyncReadyCallback _callback_, gpointer _user_data_);
+void rygel_media_export_recursive_file_monitor_add_finish (RygelMediaExportRecursiveFileMonitor* self, GAsyncResult* _res_);
+static void _rygel_media_export_recursive_file_monitor_on_monitor_changed_g_file_monitor_changed (GFileMonitor* _sender, GFile* file, GFile* other_file, GFileMonitorEvent event_type, gpointer self);
+static void rygel_media_export_recursive_file_monitor_add_data_free (gpointer _data);
+static gboolean rygel_media_export_recursive_file_monitor_add_co (RygelMediaExportRecursiveFileMonitorAddData* _data_);
+static void rygel_media_export_recursive_file_monitor_add_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_ENUM (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data);
+static void rygel_media_export_recursive_file_monitor_finalize (GObject* obj);
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void _rygel_media_export_recursive_file_monitor_cancel_g_cancellable_cancelled (GCancellable* _sender, gpointer self) {
+ rygel_media_export_recursive_file_monitor_cancel (self);
+}
+
+
+RygelMediaExportRecursiveFileMonitor* rygel_media_export_recursive_file_monitor_construct (GType object_type, GCancellable* cancellable) {
+ RygelMediaExportRecursiveFileMonitor * self = NULL;
+ gboolean _tmp3_;
+ GCancellable* _tmp5_;
+ GCancellable* _tmp6_;
+ GeeHashMap* _tmp7_;
+ GCancellable* _tmp8_;
+ GError * _inner_error_ = NULL;
+ self = (RygelMediaExportRecursiveFileMonitor*) g_object_new (object_type, NULL);
+ self->priv->monitor_changes = TRUE;
+ {
+ RygelMetaConfig* _tmp0_ = NULL;
+ RygelMetaConfig* config;
+ gboolean _tmp1_ = FALSE;
+ gboolean _tmp2_;
+ _tmp0_ = rygel_meta_config_get_default ();
+ config = _tmp0_;
+ _tmp1_ = rygel_configuration_get_bool ((RygelConfiguration*) config, "MediaExport", "monitor-changes", &_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (config);
+ goto __catch44_g_error;
+ }
+ self->priv->monitor_changes = _tmp2_;
+ _g_object_unref0 (config);
+ }
+ goto __finally44;
+ __catch44_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ self->priv->monitor_changes = TRUE;
+ _g_error_free0 (_error_);
+ }
+ __finally44:
+ if (_inner_error_ != 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 NULL;
+ }
+ _tmp3_ = self->priv->monitor_changes;
+ if (!_tmp3_) {
+ const gchar* _tmp4_ = NULL;
+ _tmp4_ = _ ("Will not monitor file changes");
+ g_message ("rygel-media-export-recursive-file-monitor.vala:40: %s", _tmp4_);
+ }
+ _tmp5_ = cancellable;
+ _tmp6_ = _g_object_ref0 (_tmp5_);
+ _g_object_unref0 (self->priv->cancellable);
+ self->priv->cancellable = _tmp6_;
+ _tmp7_ = gee_hash_map_new (G_TYPE_FILE, (GBoxedCopyFunc) g_object_ref, g_object_unref, g_file_monitor_get_type (), (GBoxedCopyFunc) g_object_ref, g_object_unref, (GeeHashDataFunc) g_file_hash, NULL, NULL, (GeeEqualDataFunc) g_file_equal, NULL, NULL, NULL, NULL, NULL);
+ _g_object_unref0 (self->priv->monitors);
+ self->priv->monitors = _tmp7_;
+ _tmp8_ = cancellable;
+ if (_tmp8_ != NULL) {
+ GCancellable* _tmp9_;
+ _tmp9_ = cancellable;
+ g_signal_connect_object (_tmp9_, "cancelled", (GCallback) _rygel_media_export_recursive_file_monitor_cancel_g_cancellable_cancelled, self, 0);
+ }
+ return self;
+}
+
+
+RygelMediaExportRecursiveFileMonitor* rygel_media_export_recursive_file_monitor_new (GCancellable* cancellable) {
+ return rygel_media_export_recursive_file_monitor_construct (RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, cancellable);
+}
+
+
+static void _rygel_media_export_recursive_file_monitor_on_monitor_changed_g_file_monitor_changed (GFileMonitor* _sender, GFile* file, GFile* other_file, GFileMonitorEvent event_type, gpointer self) {
+ rygel_media_export_recursive_file_monitor_on_monitor_changed (self, file, other_file, event_type);
+}
+
+
+void rygel_media_export_recursive_file_monitor_on_monitor_changed (RygelMediaExportRecursiveFileMonitor* self, GFile* file, GFile* other_file, GFileMonitorEvent event_type) {
+ GFile* _tmp0_;
+ GFile* _tmp1_;
+ GFileMonitorEvent _tmp2_;
+ GFileMonitorEvent _tmp3_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (file != NULL);
+ _tmp0_ = file;
+ _tmp1_ = other_file;
+ _tmp2_ = event_type;
+ g_signal_emit_by_name (self, "changed", _tmp0_, _tmp1_, _tmp2_);
+ _tmp3_ = event_type;
+ switch (_tmp3_) {
+ case G_FILE_MONITOR_EVENT_CREATED:
+ {
+ GFile* _tmp4_;
+ _tmp4_ = file;
+ rygel_media_export_recursive_file_monitor_add (self, _tmp4_, NULL, NULL);
+ break;
+ }
+ case G_FILE_MONITOR_EVENT_DELETED:
+ {
+ GeeHashMap* _tmp5_;
+ GFile* _tmp6_;
+ gpointer _tmp7_ = NULL;
+ GFileMonitor* file_monitor;
+ GFileMonitor* _tmp8_;
+ _tmp5_ = self->priv->monitors;
+ _tmp6_ = file;
+ _tmp7_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp5_, _tmp6_);
+ file_monitor = (GFileMonitor*) _tmp7_;
+ _tmp8_ = file_monitor;
+ if (_tmp8_ != NULL) {
+ GFile* _tmp9_;
+ gchar* _tmp10_ = NULL;
+ gchar* _tmp11_;
+ GeeHashMap* _tmp12_;
+ GFile* _tmp13_;
+ GFileMonitor* _tmp14_;
+ GFileMonitor* _tmp15_;
+ guint _tmp16_ = 0U;
+ _tmp9_ = file;
+ _tmp10_ = g_file_get_uri (_tmp9_);
+ _tmp11_ = _tmp10_;
+ g_debug ("rygel-media-export-recursive-file-monitor.vala:64: Folder %s gone; rem" \
+"oving watch", _tmp11_);
+ _g_free0 (_tmp11_);
+ _tmp12_ = self->priv->monitors;
+ _tmp13_ = file;
+ gee_abstract_map_unset ((GeeAbstractMap*) _tmp12_, _tmp13_, NULL);
+ _tmp14_ = file_monitor;
+ g_file_monitor_cancel (_tmp14_);
+ _tmp15_ = file_monitor;
+ g_signal_parse_name ("changed", g_file_monitor_get_type (), &_tmp16_, NULL, FALSE);
+ g_signal_handlers_disconnect_matched (_tmp15_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp16_, 0, NULL, (GCallback) _rygel_media_export_recursive_file_monitor_on_monitor_changed_g_file_monitor_changed, self);
+ }
+ _g_object_unref0 (file_monitor);
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+}
+
+
+static void rygel_media_export_recursive_file_monitor_add_data_free (gpointer _data) {
+ RygelMediaExportRecursiveFileMonitorAddData* _data_;
+ _data_ = _data;
+ _g_object_unref0 (_data_->file);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportRecursiveFileMonitorAddData, _data_);
+}
+
+
+void rygel_media_export_recursive_file_monitor_add (RygelMediaExportRecursiveFileMonitor* self, GFile* file, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportRecursiveFileMonitorAddData* _data_;
+ RygelMediaExportRecursiveFileMonitor* _tmp0_;
+ GFile* _tmp1_;
+ GFile* _tmp2_;
+ _data_ = g_slice_new0 (RygelMediaExportRecursiveFileMonitorAddData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_recursive_file_monitor_add);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_recursive_file_monitor_add_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = file;
+ _tmp2_ = _g_object_ref0 (_tmp1_);
+ _g_object_unref0 (_data_->file);
+ _data_->file = _tmp2_;
+ rygel_media_export_recursive_file_monitor_add_co (_data_);
+}
+
+
+void rygel_media_export_recursive_file_monitor_add_finish (RygelMediaExportRecursiveFileMonitor* self, GAsyncResult* _res_) {
+ RygelMediaExportRecursiveFileMonitorAddData* _data_;
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static void rygel_media_export_recursive_file_monitor_add_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ RygelMediaExportRecursiveFileMonitorAddData* _data_;
+ _data_ = _user_data_;
+ _data_->_source_object_ = source_object;
+ _data_->_res_ = _res_;
+ rygel_media_export_recursive_file_monitor_add_co (_data_);
+}
+
+
+static gboolean rygel_media_export_recursive_file_monitor_add_co (RygelMediaExportRecursiveFileMonitorAddData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ case 1:
+ goto _state_1;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp1_ = _data_->self->priv->monitor_changes;
+ if (!_data_->_tmp1_) {
+ _data_->_tmp0_ = TRUE;
+ } else {
+ _data_->_tmp2_ = _data_->self->priv->monitors;
+ _data_->_tmp3_ = _data_->file;
+ _data_->_tmp4_ = FALSE;
+ _data_->_tmp4_ = gee_abstract_map_has_key ((GeeAbstractMap*) _data_->_tmp2_, _data_->_tmp3_);
+ _data_->_tmp0_ = _data_->_tmp4_;
+ }
+ _data_->_tmp5_ = _data_->_tmp0_;
+ if (_data_->_tmp5_) {
+ 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_->_tmp6_ = _data_->file;
+ _data_->_state_ = 1;
+ g_file_query_info_async (_data_->_tmp6_, G_FILE_ATTRIBUTE_STANDARD_TYPE, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, NULL, rygel_media_export_recursive_file_monitor_add_ready, _data_);
+ return FALSE;
+ _state_1:
+ _data_->_tmp7_ = NULL;
+ _data_->_tmp7_ = g_file_query_info_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error_);
+ _data_->info = _data_->_tmp7_;
+ if (_data_->_inner_error_ != NULL) {
+ goto __catch45_g_error;
+ }
+ _data_->_tmp8_ = _data_->info;
+ _data_->_tmp9_ = 0;
+ _data_->_tmp9_ = g_file_info_get_file_type (_data_->_tmp8_);
+ if (_data_->_tmp9_ == G_FILE_TYPE_DIRECTORY) {
+ _data_->_tmp10_ = _data_->file;
+ _data_->_tmp11_ = _data_->self->priv->cancellable;
+ _data_->_tmp12_ = NULL;
+ _data_->_tmp12_ = g_file_monitor_directory (_data_->_tmp10_, G_FILE_MONITOR_NONE, _data_->_tmp11_, &_data_->_inner_error_);
+ _data_->file_monitor = _data_->_tmp12_;
+ if (_data_->_inner_error_ != NULL) {
+ _g_object_unref0 (_data_->info);
+ goto __catch45_g_error;
+ }
+ _data_->_tmp13_ = _data_->self->priv->monitors;
+ _data_->_tmp14_ = _data_->file;
+ _data_->_tmp15_ = _data_->file_monitor;
+ gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp13_, _data_->_tmp14_, _data_->_tmp15_);
+ _data_->_tmp16_ = _data_->file_monitor;
+ g_signal_connect_object (_data_->_tmp16_, "changed", (GCallback) _rygel_media_export_recursive_file_monitor_on_monitor_changed_g_file_monitor_changed, _data_->self, 0);
+ _g_object_unref0 (_data_->file_monitor);
+ }
+ _g_object_unref0 (_data_->info);
+ }
+ goto __finally45;
+ __catch45_g_error:
+ {
+ _data_->err = _data_->_inner_error_;
+ _data_->_inner_error_ = NULL;
+ _data_->_tmp17_ = NULL;
+ _data_->_tmp17_ = _ ("Failed to get file info for %s");
+ _data_->_tmp18_ = _data_->file;
+ _data_->_tmp19_ = NULL;
+ _data_->_tmp19_ = g_file_get_uri (_data_->_tmp18_);
+ _data_->_tmp20_ = _data_->_tmp19_;
+ g_warning (_data_->_tmp17_, _data_->_tmp20_);
+ _g_free0 (_data_->_tmp20_);
+ _g_error_free0 (_data_->err);
+ }
+ __finally45:
+ if (_data_->_inner_error_ != NULL) {
+ g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
+ g_clear_error (&_data_->_inner_error_);
+ return FALSE;
+ }
+ 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;
+}
+
+
+void rygel_media_export_recursive_file_monitor_cancel (RygelMediaExportRecursiveFileMonitor* self) {
+ GeeHashMap* _tmp11_;
+ g_return_if_fail (self != NULL);
+ {
+ GeeHashMap* _tmp0_;
+ GeeCollection* _tmp1_;
+ GeeCollection* _tmp2_;
+ GeeCollection* _tmp3_;
+ GeeIterator* _tmp4_ = NULL;
+ GeeIterator* _tmp5_;
+ GeeIterator* _monitor_it;
+ _tmp0_ = self->priv->monitors;
+ _tmp1_ = gee_abstract_map_get_values ((GeeMap*) _tmp0_);
+ _tmp2_ = _tmp1_;
+ _tmp3_ = _tmp2_;
+ _tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
+ _tmp5_ = _tmp4_;
+ _g_object_unref0 (_tmp3_);
+ _monitor_it = _tmp5_;
+ while (TRUE) {
+ GeeIterator* _tmp6_;
+ gboolean _tmp7_ = FALSE;
+ GeeIterator* _tmp8_;
+ gpointer _tmp9_ = NULL;
+ GFileMonitor* monitor;
+ GFileMonitor* _tmp10_;
+ _tmp6_ = _monitor_it;
+ _tmp7_ = gee_iterator_next (_tmp6_);
+ if (!_tmp7_) {
+ break;
+ }
+ _tmp8_ = _monitor_it;
+ _tmp9_ = gee_iterator_get (_tmp8_);
+ monitor = (GFileMonitor*) _tmp9_;
+ _tmp10_ = monitor;
+ g_file_monitor_cancel (_tmp10_);
+ _g_object_unref0 (monitor);
+ }
+ _g_object_unref0 (_monitor_it);
+ }
+ _tmp11_ = self->priv->monitors;
+ gee_abstract_map_clear ((GeeAbstractMap*) _tmp11_);
+}
+
+
+static void g_cclosure_user_marshal_VOID__OBJECT_OBJECT_ENUM (GClosure * closure, GValue * return_value, guint n_param_values, const GValue * param_values, gpointer invocation_hint, gpointer marshal_data) {
+ typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT_ENUM) (gpointer data1, gpointer arg_1, gpointer arg_2, gint arg_3, gpointer data2);
+ register GMarshalFunc_VOID__OBJECT_OBJECT_ENUM callback;
+ register GCClosure * cc;
+ register gpointer data1;
+ register gpointer data2;
+ cc = (GCClosure *) closure;
+ g_return_if_fail (n_param_values == 4);
+ if (G_CCLOSURE_SWAP_DATA (closure)) {
+ data1 = closure->data;
+ data2 = param_values->data[0].v_pointer;
+ } else {
+ data1 = param_values->data[0].v_pointer;
+ data2 = closure->data;
+ }
+ callback = (GMarshalFunc_VOID__OBJECT_OBJECT_ENUM) (marshal_data ? marshal_data : cc->callback);
+ callback (data1, g_value_get_object (param_values + 1), g_value_get_object (param_values + 2), g_value_get_enum (param_values + 3), data2);
+}
+
+
+static void rygel_media_export_recursive_file_monitor_class_init (RygelMediaExportRecursiveFileMonitorClass * klass) {
+ rygel_media_export_recursive_file_monitor_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportRecursiveFileMonitorPrivate));
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_recursive_file_monitor_finalize;
+ g_signal_new ("changed", RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_OBJECT_ENUM, G_TYPE_NONE, 3, G_TYPE_FILE, G_TYPE_FILE, g_file_monitor_event_get_type ());
+}
+
+
+static void rygel_media_export_recursive_file_monitor_init (RygelMediaExportRecursiveFileMonitor * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_recursive_file_monitor_finalize (GObject* obj) {
+ RygelMediaExportRecursiveFileMonitor * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitor);
+ _g_object_unref0 (self->priv->cancellable);
+ _g_object_unref0 (self->priv->monitors);
+ G_OBJECT_CLASS (rygel_media_export_recursive_file_monitor_parent_class)->finalize (obj);
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-recursive-file-monitor.h b/src/media-export/rygel-media-export-recursive-file-monitor.h
new file mode 100644
index 0000000..330ac3d
--- /dev/null
+++ b/src/media-export/rygel-media-export-recursive-file-monitor.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR (rygel_media_export_recursive_file_monitor_get_type ())
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitor))
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitorClass))
+#define RYGEL_MEDIA_EXPORT_IS_RECURSIVE_FILE_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR))
+#define RYGEL_MEDIA_EXPORT_IS_RECURSIVE_FILE_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR))
+#define RYGEL_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_RECURSIVE_FILE_MONITOR, RygelMediaExportRecursiveFileMonitorClass))
+
+typedef struct _RygelMediaExportRecursiveFileMonitor RygelMediaExportRecursiveFileMonitor;
+typedef struct _RygelMediaExportRecursiveFileMonitorClass RygelMediaExportRecursiveFileMonitorClass;
+typedef struct _RygelMediaExportRecursiveFileMonitorPrivate RygelMediaExportRecursiveFileMonitorPrivate;
+
+struct _RygelMediaExportRecursiveFileMonitor {
+ GObject parent_instance;
+ RygelMediaExportRecursiveFileMonitorPrivate *priv;
+};
+
+struct _RygelMediaExportRecursiveFileMonitorClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_recursive_file_monitor_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportRecursiveFileMonitor* rygel_media_export_recursive_file_monitor_new (GCancellable* cancellable);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_RECURSIVE_FILE_MONITOR_H__ */
diff --git a/src/media-export/rygel-media-export-root-container.c b/src/media-export/rygel-media-export-root-container.c
new file mode 100644
index 0000000..6cfaa14
--- /dev/null
+++ b/src/media-export/rygel-media-export-root-container.c
@@ -0,0 +1,2353 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-root-container.h"
+#include "rygel-media-export-database.h"
+
+/**
+ * Represents the root container.
+ */
+
+G_DEFINE_TYPE (RygelMediaExportRootContainer, rygel_media_export_root_container, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER)
+
+#define RYGEL_MEDIA_EXPORT_TYPE_FOLDER_DEFINITION (rygel_media_export_folder_definition_get_type ())
+typedef struct _RygelMediaExportFolderDefinition RygelMediaExportFolderDefinition;
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE (rygel_media_export_dbus_service_get_type ())
+#define RYGEL_MEDIA_EXPORT_DBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, RygelMediaExportDBusService))
+#define RYGEL_MEDIA_EXPORT_DBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, RygelMediaExportDBusServiceClass))
+#define RYGEL_MEDIA_EXPORT_IS_DBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE))
+#define RYGEL_MEDIA_EXPORT_IS_DBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE))
+#define RYGEL_MEDIA_EXPORT_DBUS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DBUS_SERVICE, RygelMediaExportDBusServiceClass))
+
+typedef struct _RygelMediaExportDBusService RygelMediaExportDBusService;
+typedef struct _RygelMediaExportDBusServiceClass RygelMediaExportDBusServiceClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_HARVESTER (rygel_media_export_harvester_get_type ())
+#define RYGEL_MEDIA_EXPORT_HARVESTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvester))
+#define RYGEL_MEDIA_EXPORT_HARVESTER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvesterClass))
+#define RYGEL_MEDIA_EXPORT_IS_HARVESTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER))
+#define RYGEL_MEDIA_EXPORT_IS_HARVESTER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER))
+#define RYGEL_MEDIA_EXPORT_HARVESTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_HARVESTER, RygelMediaExportHarvesterClass))
+
+typedef struct _RygelMediaExportHarvester RygelMediaExportHarvester;
+typedef struct _RygelMediaExportHarvesterClass RygelMediaExportHarvesterClass;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+#define RYGEL_TYPE_NULL_CONTAINER (rygel_null_container_get_type ())
+#define RYGEL_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainer))
+#define RYGEL_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainerClass))
+#define RYGEL_IS_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_NULL_CONTAINER))
+#define RYGEL_IS_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_NULL_CONTAINER))
+#define RYGEL_NULL_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainerClass))
+
+typedef struct _RygelNullContainer RygelNullContainer;
+typedef struct _RygelNullContainerClass RygelNullContainerClass;
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY (rygel_media_export_query_container_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactory))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
+
+typedef struct _RygelMediaExportQueryContainerFactory RygelMediaExportQueryContainerFactory;
+typedef struct _RygelMediaExportQueryContainerFactoryClass RygelMediaExportQueryContainerFactoryClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER (rygel_media_export_query_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainer))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
+
+typedef struct _RygelMediaExportQueryContainer RygelMediaExportQueryContainer;
+typedef struct _RygelMediaExportQueryContainerClass RygelMediaExportQueryContainerClass;
+typedef struct _RygelMediaExportRootContainerFindObjectData RygelMediaExportRootContainerFindObjectData;
+#define _rygel_search_expression_unref0(var) ((var == NULL) ? NULL : (var = (rygel_search_expression_unref (var), NULL)))
+typedef struct _RygelMediaExportRootContainerSearchData RygelMediaExportRootContainerSearchData;
+#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
+
+struct _RygelMediaExportFolderDefinition {
+ gchar* title;
+ gchar* definition;
+};
+
+
+struct _RygelMediaExportRootContainerPrivate {
+ RygelMediaExportDBusService* service;
+ RygelMediaExportHarvester* harvester;
+ GCancellable* cancellable;
+ RygelMediaContainer* filesystem_container;
+ gulong harvester_signal_id;
+};
+
+struct _RygelMediaExportRootContainerFindObjectData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportRootContainer* self;
+ gchar* id;
+ GCancellable* cancellable;
+ RygelMediaObject* result;
+ const gchar* _tmp0_;
+ GCancellable* _tmp1_;
+ RygelMediaObject* _tmp2_;
+ RygelMediaObject* object;
+ gboolean _tmp3_;
+ const gchar* _tmp4_;
+ gboolean _tmp5_;
+ gboolean _tmp6_;
+ RygelMediaExportQueryContainerFactory* _tmp7_;
+ RygelMediaExportQueryContainerFactory* factory;
+ RygelMediaExportQueryContainerFactory* _tmp8_;
+ RygelMediaExportMediaCache* _tmp9_;
+ const gchar* _tmp10_;
+ RygelMediaExportQueryContainer* _tmp11_;
+ RygelMediaExportQueryContainer* container;
+ RygelMediaExportQueryContainer* _tmp12_;
+ RygelMediaExportQueryContainer* _tmp13_;
+ GError * _inner_error_;
+};
+
+struct _RygelMediaExportRootContainerSearchData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportRootContainer* self;
+ RygelSearchExpression* expression;
+ guint offset;
+ guint max_count;
+ guint total_matches;
+ gchar* sort_criteria;
+ GCancellable* cancellable;
+ RygelMediaObjects* result;
+ RygelSearchExpression* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ guint _tmp2_;
+ guint _tmp3_;
+ const gchar* _tmp4_;
+ GCancellable* _tmp5_;
+ guint _tmp6_;
+ RygelMediaObjects* _tmp7_;
+ RygelMediaObjects* _tmp8_;
+ RygelMediaObjects* list;
+ RygelMediaContainer* query_container;
+ gchar* upnp_class;
+ RygelSearchExpression* _tmp9_;
+ RygelSearchExpression* _tmp10_;
+ RygelRelationalExpression* _tmp11_;
+ RygelRelationalExpression* relational_expression;
+ RygelRelationalExpression* _tmp12_;
+ RygelMediaExportQueryContainer* _tmp13_;
+ RygelRelationalExpression* _tmp14_;
+ gconstpointer _tmp15_;
+ gchar* _tmp16_;
+ RygelSearchExpression* _tmp17_;
+ RygelMediaContainer* _tmp18_;
+ gboolean _tmp19_;
+ RygelMediaContainer* _tmp20_;
+ RygelMediaContainer* _tmp21_;
+ guint _tmp22_;
+ guint _tmp23_;
+ const gchar* _tmp24_;
+ GCancellable* _tmp25_;
+ RygelMediaObjects* _tmp26_;
+ RygelMediaObjects* _tmp27_;
+ RygelMediaContainer* _tmp28_;
+ gint _tmp29_;
+ const gchar* _tmp30_;
+ RygelMediaObjects* _tmp31_;
+ RygelMediaObjects* _tmp32_;
+ RygelMediaObjects* _object_list;
+ RygelMediaObjects* _tmp33_;
+ gint _tmp34_;
+ gint _tmp35_;
+ gint _object_size;
+ gint _object_index;
+ gint _tmp36_;
+ gint _tmp37_;
+ gint _tmp38_;
+ RygelMediaObjects* _tmp39_;
+ gint _tmp40_;
+ gpointer _tmp41_;
+ RygelMediaObject* object;
+ RygelMediaObject* _tmp42_;
+ const gchar* _tmp43_;
+ RygelSearchExpression* _tmp44_;
+ guint _tmp45_;
+ guint _tmp46_;
+ const gchar* _tmp47_;
+ GCancellable* _tmp48_;
+ guint _tmp49_;
+ RygelMediaObjects* _tmp50_;
+ RygelMediaObjects* _tmp51_;
+ GError * _inner_error_;
+};
+
+
+static RygelMediaContainer* rygel_media_export_root_container_instance;
+static RygelMediaContainer* rygel_media_export_root_container_instance = NULL;
+static GError* rygel_media_export_root_container_creation_error;
+static GError* rygel_media_export_root_container_creation_error = NULL;
+
+GType rygel_media_export_folder_definition_get_type (void) G_GNUC_CONST;
+RygelMediaExportFolderDefinition* rygel_media_export_folder_definition_dup (const RygelMediaExportFolderDefinition* self);
+void rygel_media_export_folder_definition_free (RygelMediaExportFolderDefinition* self);
+void rygel_media_export_folder_definition_copy (const RygelMediaExportFolderDefinition* self, RygelMediaExportFolderDefinition* dest);
+void rygel_media_export_folder_definition_destroy (RygelMediaExportFolderDefinition* self);
+GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_root_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_dbus_service_get_type (void) G_GNUC_CONST;
+guint rygel_media_export_dbus_service_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error);
+GType rygel_media_export_harvester_get_type (void) G_GNUC_CONST;
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, RygelMediaExportRootContainerPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_DUMMY_PROPERTY
+};
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_NAME "Files & Folders"
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID "Filesystem"
+#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "virtual-container:"
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_SEARCH_CONTAINER_PREFIX RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX "upnp:class," RYGEL_MUSIC_ITEM_UPNP_CLASS ","
+RygelMediaContainer* rygel_media_export_root_container_get_instance (GError** error);
+static RygelMediaExportRootContainer* rygel_media_export_root_container_construct (GType object_type, GError** error);
+RygelNullContainer* rygel_null_container_new (void);
+RygelNullContainer* rygel_null_container_construct (GType object_type);
+GType rygel_null_container_get_type (void) G_GNUC_CONST;
+RygelMediaContainer* rygel_media_export_root_container_get_filesystem_container (RygelMediaExportRootContainer* self);
+void rygel_media_export_root_container_shutdown (RygelMediaExportRootContainer* self);
+void rygel_media_export_root_container_add_uri (RygelMediaExportRootContainer* self, const gchar* uri);
+void rygel_media_export_harvester_schedule (RygelMediaExportHarvester* self, GFile* file, RygelMediaContainer* parent, const gchar* flag);
+void rygel_media_export_root_container_remove_uri (RygelMediaExportRootContainer* self, const gchar* uri);
+gchar* rygel_media_export_media_cache_get_id (GFile* file);
+void rygel_media_export_harvester_cancel (RygelMediaExportHarvester* self, GFile* file);
+GQuark rygel_media_export_database_error_quark (void);
+void rygel_media_export_media_cache_remove_by_id (RygelMediaExportMediaCache* self, const gchar* id, GError** error);
+gchar** rygel_media_export_root_container_get_dynamic_uris (RygelMediaExportRootContainer* self, int* result_length1);
+GeeList* rygel_media_export_media_cache_get_flagged_uris (RygelMediaExportMediaCache* self, const gchar* flag, GError** error);
+static void rygel_media_export_root_container_real_find_object_data_free (gpointer _data);
+static void rygel_media_export_root_container_real_find_object (RygelMediaContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_root_container_real_find_object_co (RygelMediaExportRootContainerFindObjectData* _data_);
+static void rygel_media_export_root_container_find_object_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+GType rygel_media_export_query_container_factory_get_type (void) G_GNUC_CONST;
+RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_get_default (void);
+GType rygel_media_export_query_container_get_type (void) G_GNUC_CONST;
+RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_id (RygelMediaExportQueryContainerFactory* self, RygelMediaExportMediaCache* cache, const gchar* id, const gchar* name);
+static void rygel_media_export_root_container_real_search_data_free (gpointer _data);
+static void rygel_media_export_root_container_real_search (RygelMediaExportDBContainer* base, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_root_container_real_search_co (RygelMediaExportRootContainerSearchData* _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 void rygel_media_export_root_container_search_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
+static RygelMediaExportQueryContainer* rygel_media_export_root_container_search_to_virtual_container (RygelMediaExportRootContainer* self, RygelRelationalExpression* expression);
+static gboolean rygel_media_export_root_container_is_search_in_virtual_container (RygelMediaExportRootContainer* self, RygelSearchExpression* expression, RygelMediaContainer** container);
+static GeeArrayList* rygel_media_export_root_container_get_shared_uris (RygelMediaExportRootContainer* self);
+RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_description (RygelMediaExportQueryContainerFactory* self, RygelMediaExportMediaCache* cache, const gchar* definition, const gchar* name);
+gchar* rygel_media_export_query_container_factory_get_virtual_container_definition (RygelMediaExportQueryContainerFactory* self, const gchar* hash);
+
+RygelMediaExportDBusService* rygel_media_export_dbus_service_new (RygelMediaExportRootContainer* root_container, GError** error);
+RygelMediaExportDBusService* rygel_media_export_dbus_service_construct (GType object_type, RygelMediaExportRootContainer* root_container, GError** error);
+void rygel_media_export_media_cache_save_container (RygelMediaExportMediaCache* self, RygelMediaContainer* container, GError** error);
+GeeArrayList* rygel_media_export_media_cache_get_child_ids (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
+RygelMediaExportHarvester* rygel_media_export_harvester_new (GCancellable* cancellable, GeeArrayList* locations);
+RygelMediaExportHarvester* rygel_media_export_harvester_construct (GType object_type, GCancellable* cancellable, GeeArrayList* locations);
+static void rygel_media_export_root_container_on_initial_harvesting_done (RygelMediaExportRootContainer* self);
+static void _rygel_media_export_root_container_on_initial_harvesting_done_rygel_media_export_harvester_done (RygelMediaExportHarvester* _sender, gpointer self);
+GeeArrayList* rygel_media_export_harvester_get_locations (RygelMediaExportHarvester* self);
+void rygel_media_export_media_cache_debug_statistics (RygelMediaExportMediaCache* self);
+static void rygel_media_export_root_container_add_default_virtual_folders (RygelMediaExportRootContainer* self);
+static void __lambda6_ (RygelMediaExportRootContainer* self);
+static void ___lambda6__rygel_media_container_container_updated (RygelMediaContainer* _sender, RygelMediaContainer* container, RygelMediaObject* object, RygelObjectEventType event_type, gboolean sub_tree_update, gpointer self);
+static void rygel_media_export_root_container_add_virtual_containers_for_class (RygelMediaExportRootContainer* self, const gchar* parent, const gchar* item_class, RygelMediaExportFolderDefinition* definitions, int definitions_length1, GError** error);
+static void rygel_media_export_root_container_add_folder_definition (RygelMediaExportRootContainer* self, RygelMediaContainer* container, const gchar* item_class, RygelMediaExportFolderDefinition* definition, GError** error);
+gint rygel_media_export_media_cache_get_child_count (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
+static void rygel_media_export_root_container_finalize (GObject* obj);
+
+const RygelMediaExportFolderDefinition VIRTUAL_FOLDERS_DEFAULT[2] = {{"Year", "dc:date,?"}, {"All", ""}};
+const RygelMediaExportFolderDefinition VIRTUAL_FOLDERS_MUSIC[3] = {{"Artist", "upnp:artist,?,upnp:album,?"}, {"Album", "upnp:album,?"}, {"Genre", "dc:genre,?"}};
+
+void rygel_media_export_folder_definition_copy (const RygelMediaExportFolderDefinition* self, RygelMediaExportFolderDefinition* dest) {
+ const gchar* _tmp0_;
+ gchar* _tmp1_;
+ const gchar* _tmp2_;
+ gchar* _tmp3_;
+ _tmp0_ = (*self).title;
+ _tmp1_ = g_strdup (_tmp0_);
+ _g_free0 ((*dest).title);
+ (*dest).title = _tmp1_;
+ _tmp2_ = (*self).definition;
+ _tmp3_ = g_strdup (_tmp2_);
+ _g_free0 ((*dest).definition);
+ (*dest).definition = _tmp3_;
+}
+
+
+void rygel_media_export_folder_definition_destroy (RygelMediaExportFolderDefinition* self) {
+ _g_free0 ((*self).title);
+ _g_free0 ((*self).definition);
+}
+
+
+RygelMediaExportFolderDefinition* rygel_media_export_folder_definition_dup (const RygelMediaExportFolderDefinition* self) {
+ RygelMediaExportFolderDefinition* dup;
+ dup = g_new0 (RygelMediaExportFolderDefinition, 1);
+ rygel_media_export_folder_definition_copy (self, dup);
+ return dup;
+}
+
+
+void rygel_media_export_folder_definition_free (RygelMediaExportFolderDefinition* self) {
+ rygel_media_export_folder_definition_destroy (self);
+ g_free (self);
+}
+
+
+GType rygel_media_export_folder_definition_get_type (void) {
+ static volatile gsize rygel_media_export_folder_definition_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_folder_definition_type_id__volatile)) {
+ GType rygel_media_export_folder_definition_type_id;
+ rygel_media_export_folder_definition_type_id = g_boxed_type_register_static ("RygelMediaExportFolderDefinition", (GBoxedCopyFunc) rygel_media_export_folder_definition_dup, (GBoxedFreeFunc) rygel_media_export_folder_definition_free);
+ g_once_init_leave (&rygel_media_export_folder_definition_type_id__volatile, rygel_media_export_folder_definition_type_id);
+ }
+ return rygel_media_export_folder_definition_type_id__volatile;
+}
+
+
+static gpointer _g_error_copy0 (gpointer self) {
+ return self ? g_error_copy (self) : NULL;
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+RygelMediaContainer* rygel_media_export_root_container_get_instance (GError** error) {
+ RygelMediaContainer* result = NULL;
+ RygelMediaContainer* _tmp0_;
+ RygelMediaContainer* _tmp9_;
+ RygelMediaContainer* _tmp10_;
+ GError * _inner_error_ = NULL;
+ _tmp0_ = rygel_media_export_root_container_instance;
+ if (_tmp0_ == NULL) {
+ {
+ RygelMediaExportRootContainer* _tmp1_;
+ RygelMediaExportRootContainer* _tmp2_;
+ _tmp1_ = rygel_media_export_root_container_new (&_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ goto __catch26_g_error;
+ }
+ _g_object_unref0 (rygel_media_export_root_container_instance);
+ rygel_media_export_root_container_instance = (RygelMediaContainer*) _tmp2_;
+ }
+ goto __finally26;
+ __catch26_g_error:
+ {
+ GError* _error_ = NULL;
+ RygelNullContainer* _tmp3_;
+ GError* _tmp4_;
+ GError* _tmp5_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp3_ = rygel_null_container_new ();
+ _g_object_unref0 (rygel_media_export_root_container_instance);
+ rygel_media_export_root_container_instance = (RygelMediaContainer*) _tmp3_;
+ _tmp4_ = _error_;
+ _tmp5_ = _g_error_copy0 (_tmp4_);
+ _g_error_free0 (rygel_media_export_root_container_creation_error);
+ rygel_media_export_root_container_creation_error = _tmp5_;
+ _g_error_free0 (_error_);
+ }
+ __finally26:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ }
+ } else {
+ GError* _tmp6_;
+ _tmp6_ = rygel_media_export_root_container_creation_error;
+ if (_tmp6_ != NULL) {
+ GError* _tmp7_;
+ GError* _tmp8_;
+ _tmp7_ = rygel_media_export_root_container_creation_error;
+ _tmp8_ = _g_error_copy0 (_tmp7_);
+ _inner_error_ = _tmp8_;
+ g_propagate_error (error, _inner_error_);
+ return NULL;
+ }
+ }
+ _tmp9_ = rygel_media_export_root_container_instance;
+ _tmp10_ = _g_object_ref0 (_tmp9_);
+ result = _tmp10_;
+ return result;
+}
+
+
+RygelMediaContainer* rygel_media_export_root_container_get_filesystem_container (RygelMediaExportRootContainer* self) {
+ RygelMediaContainer* result = NULL;
+ RygelMediaContainer* _tmp0_;
+ RygelMediaContainer* _tmp1_;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = self->priv->filesystem_container;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ result = _tmp1_;
+ return result;
+}
+
+
+void rygel_media_export_root_container_shutdown (RygelMediaExportRootContainer* self) {
+ GCancellable* _tmp0_;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = self->priv->cancellable;
+ g_cancellable_cancel (_tmp0_);
+}
+
+
+void rygel_media_export_root_container_add_uri (RygelMediaExportRootContainer* self, const gchar* uri) {
+ const gchar* _tmp0_;
+ GFile* _tmp1_ = NULL;
+ GFile* file;
+ RygelMediaExportHarvester* _tmp2_;
+ RygelMediaContainer* _tmp3_;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (uri != NULL);
+ _tmp0_ = uri;
+ _tmp1_ = g_file_new_for_commandline_arg (_tmp0_);
+ file = _tmp1_;
+ _tmp2_ = self->priv->harvester;
+ _tmp3_ = self->priv->filesystem_container;
+ rygel_media_export_harvester_schedule (_tmp2_, file, _tmp3_, "DBUS");
+ _g_object_unref0 (file);
+}
+
+
+void rygel_media_export_root_container_remove_uri (RygelMediaExportRootContainer* self, const gchar* uri) {
+ const gchar* _tmp0_;
+ GFile* _tmp1_ = NULL;
+ GFile* file;
+ gchar* _tmp2_ = NULL;
+ gchar* id;
+ RygelMediaExportHarvester* _tmp3_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (uri != NULL);
+ _tmp0_ = uri;
+ _tmp1_ = g_file_new_for_commandline_arg (_tmp0_);
+ file = _tmp1_;
+ _tmp2_ = rygel_media_export_media_cache_get_id (file);
+ id = _tmp2_;
+ _tmp3_ = self->priv->harvester;
+ rygel_media_export_harvester_cancel (_tmp3_, file);
+ {
+ RygelMediaExportMediaCache* _tmp4_;
+ _tmp4_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ rygel_media_export_media_cache_remove_by_id (_tmp4_, id, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch27_g_error;
+ }
+ }
+ goto __finally27;
+ __catch27_g_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp5_ = NULL;
+ GError* _tmp6_;
+ const gchar* _tmp7_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp5_ = _ ("Failed to remove URI: %s");
+ _tmp6_ = _error_;
+ _tmp7_ = _tmp6_->message;
+ g_warning (_tmp5_, _tmp7_);
+ _g_error_free0 (_error_);
+ }
+ __finally27:
+ if (_inner_error_ != NULL) {
+ _g_free0 (id);
+ _g_object_unref0 (file);
+ 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;
+ }
+ _g_free0 (id);
+ _g_object_unref0 (file);
+}
+
+
+gchar** rygel_media_export_root_container_get_dynamic_uris (RygelMediaExportRootContainer* self, int* result_length1) {
+ gchar** result = NULL;
+ gchar** _tmp5_ = NULL;
+ gchar** _tmp6_;
+ gint _tmp6__length1;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ {
+ RygelMediaExportMediaCache* _tmp0_;
+ GeeList* _tmp1_ = NULL;
+ GeeList* uris;
+ gint _tmp2_ = 0;
+ gpointer* _tmp3_ = NULL;
+ gchar** _tmp4_;
+ gint _tmp4__length1;
+ _tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp1_ = rygel_media_export_media_cache_get_flagged_uris (_tmp0_, "DBUS", &_inner_error_);
+ uris = _tmp1_;
+ if (_inner_error_ != NULL) {
+ goto __catch28_g_error;
+ }
+ _tmp3_ = gee_collection_to_array ((GeeCollection*) uris, &_tmp2_);
+ _tmp4_ = _tmp3_;
+ _tmp4__length1 = _tmp2_;
+ if (result_length1) {
+ *result_length1 = _tmp4__length1;
+ }
+ result = _tmp4_;
+ _g_object_unref0 (uris);
+ return result;
+ }
+ goto __finally28;
+ __catch28_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally28:
+ if (_inner_error_ != 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 NULL;
+ }
+ _tmp5_ = g_new0 (gchar*, 0 + 1);
+ _tmp6_ = _tmp5_;
+ _tmp6__length1 = 0;
+ if (result_length1) {
+ *result_length1 = _tmp6__length1;
+ }
+ result = _tmp6_;
+ return result;
+}
+
+
+static void rygel_media_export_root_container_real_find_object_data_free (gpointer _data) {
+ RygelMediaExportRootContainerFindObjectData* _data_;
+ _data_ = _data;
+ _g_free0 (_data_->id);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportRootContainerFindObjectData, _data_);
+}
+
+
+static void rygel_media_export_root_container_real_find_object (RygelMediaContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportRootContainer * self;
+ RygelMediaExportRootContainerFindObjectData* _data_;
+ RygelMediaExportRootContainer* _tmp0_;
+ const gchar* _tmp1_;
+ gchar* _tmp2_;
+ GCancellable* _tmp3_;
+ GCancellable* _tmp4_;
+ self = (RygelMediaExportRootContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportRootContainerFindObjectData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_root_container_real_find_object);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_root_container_real_find_object_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = id;
+ _tmp2_ = g_strdup (_tmp1_);
+ _g_free0 (_data_->id);
+ _data_->id = _tmp2_;
+ _tmp3_ = cancellable;
+ _tmp4_ = _g_object_ref0 (_tmp3_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp4_;
+ rygel_media_export_root_container_real_find_object_co (_data_);
+}
+
+
+static RygelMediaObject* rygel_media_export_root_container_real_find_object_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaObject* result;
+ RygelMediaExportRootContainerFindObjectData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static void rygel_media_export_root_container_find_object_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ RygelMediaExportRootContainerFindObjectData* _data_;
+ _data_ = _user_data_;
+ _data_->_source_object_ = source_object;
+ _data_->_res_ = _res_;
+ rygel_media_export_root_container_real_find_object_co (_data_);
+}
+
+
+static gboolean rygel_media_export_root_container_real_find_object_co (RygelMediaExportRootContainerFindObjectData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ case 1:
+ goto _state_1;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = _data_->id;
+ _data_->_tmp1_ = _data_->cancellable;
+ _data_->_state_ = 1;
+ RYGEL_MEDIA_CONTAINER_CLASS (rygel_media_export_root_container_parent_class)->find_object ((RygelMediaContainer*) G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer), _data_->_tmp0_, _data_->_tmp1_, rygel_media_export_root_container_find_object_ready, _data_);
+ return FALSE;
+ _state_1:
+ _data_->_tmp2_ = NULL;
+ _data_->_tmp2_ = RYGEL_MEDIA_CONTAINER_CLASS (rygel_media_export_root_container_parent_class)->find_object_finish ((RygelMediaContainer*) G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer), _data_->_res_, &_data_->_inner_error_);
+ _data_->object = _data_->_tmp2_;
+ 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;
+ }
+ if (_data_->object == NULL) {
+ _data_->_tmp4_ = _data_->id;
+ _data_->_tmp5_ = FALSE;
+ _data_->_tmp5_ = g_str_has_prefix (_data_->_tmp4_, RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX);
+ _data_->_tmp3_ = _data_->_tmp5_;
+ } else {
+ _data_->_tmp3_ = FALSE;
+ }
+ _data_->_tmp6_ = _data_->_tmp3_;
+ if (_data_->_tmp6_) {
+ _data_->_tmp7_ = NULL;
+ _data_->_tmp7_ = rygel_media_export_query_container_factory_get_default ();
+ _data_->factory = _data_->_tmp7_;
+ _data_->_tmp8_ = _data_->factory;
+ _data_->_tmp9_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp10_ = _data_->id;
+ _data_->_tmp11_ = NULL;
+ _data_->_tmp11_ = rygel_media_export_query_container_factory_create_from_id (_data_->_tmp8_, _data_->_tmp9_, _data_->_tmp10_, "");
+ _data_->container = _data_->_tmp11_;
+ _data_->_tmp12_ = _data_->container;
+ if (_data_->_tmp12_ != NULL) {
+ _data_->_tmp13_ = _data_->container;
+ ((RygelMediaObject*) _data_->_tmp13_)->parent = (RygelMediaContainer*) _data_->self;
+ }
+ _data_->result = (RygelMediaObject*) _data_->container;
+ _g_object_unref0 (_data_->factory);
+ _g_object_unref0 (_data_->object);
+ 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_->result = _data_->object;
+ 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_unref0 (_data_->object);
+ 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_root_container_real_search_data_free (gpointer _data) {
+ RygelMediaExportRootContainerSearchData* _data_;
+ _data_ = _data;
+ _rygel_search_expression_unref0 (_data_->expression);
+ _g_free0 (_data_->sort_criteria);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->result);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportRootContainerSearchData, _data_);
+}
+
+
+static gpointer _rygel_search_expression_ref0 (gpointer self) {
+ return self ? rygel_search_expression_ref (self) : NULL;
+}
+
+
+static void rygel_media_export_root_container_real_search (RygelMediaExportDBContainer* base, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportRootContainer * self;
+ RygelMediaExportRootContainerSearchData* _data_;
+ RygelMediaExportRootContainer* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ RygelSearchExpression* _tmp2_;
+ guint _tmp3_;
+ guint _tmp4_;
+ const gchar* _tmp5_;
+ gchar* _tmp6_;
+ GCancellable* _tmp7_;
+ GCancellable* _tmp8_;
+ self = (RygelMediaExportRootContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportRootContainerSearchData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_root_container_real_search);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_root_container_real_search_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = expression;
+ _tmp2_ = _rygel_search_expression_ref0 (_tmp1_);
+ _rygel_search_expression_unref0 (_data_->expression);
+ _data_->expression = _tmp2_;
+ _tmp3_ = offset;
+ _data_->offset = _tmp3_;
+ _tmp4_ = max_count;
+ _data_->max_count = _tmp4_;
+ _tmp5_ = sort_criteria;
+ _tmp6_ = g_strdup (_tmp5_);
+ _g_free0 (_data_->sort_criteria);
+ _data_->sort_criteria = _tmp6_;
+ _tmp7_ = cancellable;
+ _tmp8_ = _g_object_ref0 (_tmp7_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp8_;
+ rygel_media_export_root_container_real_search_co (_data_);
+}
+
+
+static RygelMediaObjects* rygel_media_export_root_container_real_search_finish (RygelMediaExportDBContainer* base, GAsyncResult* _res_, guint* total_matches, GError** error) {
+ RygelMediaObjects* result;
+ RygelMediaExportRootContainerSearchData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return NULL;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+ if (total_matches) {
+ *total_matches = _data_->total_matches;
+ }
+ result = _data_->result;
+ _data_->result = NULL;
+ return result;
+}
+
+
+static void rygel_media_export_root_container_search_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
+ RygelMediaExportRootContainerSearchData* _data_;
+ _data_ = _user_data_;
+ _data_->_source_object_ = source_object;
+ _data_->_res_ = _res_;
+ rygel_media_export_root_container_real_search_co (_data_);
+}
+
+
+static gboolean rygel_media_export_root_container_real_search_co (RygelMediaExportRootContainerSearchData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ case 1:
+ goto _state_1;
+ case 2:
+ goto _state_2;
+ case 3:
+ goto _state_3;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = _data_->expression;
+ if (_data_->_tmp0_ == NULL) {
+ _data_->_tmp1_ = _data_->expression;
+ _data_->_tmp2_ = _data_->offset;
+ _data_->_tmp3_ = _data_->max_count;
+ _data_->_tmp4_ = _data_->sort_criteria;
+ _data_->_tmp5_ = _data_->cancellable;
+ _data_->_tmp6_ = 0U;
+ _data_->_state_ = 1;
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (rygel_media_export_root_container_parent_class)->search (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer), _data_->_tmp1_, _data_->_tmp2_, _data_->_tmp3_, _data_->_tmp4_, _data_->_tmp5_, rygel_media_export_root_container_search_ready, _data_);
+ return FALSE;
+ _state_1:
+ _data_->_tmp7_ = NULL;
+ _data_->_tmp7_ = RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (rygel_media_export_root_container_parent_class)->search_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer), _data_->_res_, &_data_->_tmp6_, &_data_->_inner_error_);
+ _data_->total_matches = _data_->_tmp6_;
+ _data_->_tmp8_ = _data_->_tmp7_;
+ 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_->result = _data_->_tmp8_;
+ 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_->query_container = NULL;
+ _data_->upnp_class = NULL;
+ _data_->_tmp9_ = _data_->expression;
+ if (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp9_, RYGEL_TYPE_RELATIONAL_EXPRESSION)) {
+ _data_->_tmp10_ = _data_->expression;
+ _data_->_tmp11_ = _rygel_search_expression_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp10_, RYGEL_TYPE_RELATIONAL_EXPRESSION) ? ((RygelRelationalExpression*) _data_->_tmp10_) : NULL);
+ _data_->relational_expression = _data_->_tmp11_;
+ _data_->_tmp12_ = _data_->relational_expression;
+ _data_->_tmp13_ = NULL;
+ _data_->_tmp13_ = rygel_media_export_root_container_search_to_virtual_container (_data_->self, _data_->_tmp12_);
+ _g_object_unref0 (_data_->query_container);
+ _data_->query_container = (RygelMediaContainer*) _data_->_tmp13_;
+ _data_->_tmp14_ = _data_->relational_expression;
+ _data_->_tmp15_ = ((RygelSearchExpression*) _data_->_tmp14_)->operand2;
+ _data_->_tmp16_ = g_strdup ((const gchar*) _data_->_tmp15_);
+ _g_free0 (_data_->upnp_class);
+ _data_->upnp_class = _data_->_tmp16_;
+ _rygel_search_expression_unref0 (_data_->relational_expression);
+ } else {
+ _data_->_tmp17_ = _data_->expression;
+ _data_->_tmp18_ = NULL;
+ _data_->_tmp19_ = FALSE;
+ _data_->_tmp19_ = rygel_media_export_root_container_is_search_in_virtual_container (_data_->self, _data_->_tmp17_, &_data_->_tmp18_);
+ _g_object_unref0 (_data_->query_container);
+ _data_->query_container = _data_->_tmp18_;
+ if (_data_->_tmp19_) {
+ }
+ }
+ _data_->_tmp20_ = _data_->query_container;
+ if (_data_->_tmp20_ != NULL) {
+ _data_->_tmp21_ = _data_->query_container;
+ _data_->_tmp22_ = _data_->offset;
+ _data_->_tmp23_ = _data_->max_count;
+ _data_->_tmp24_ = _data_->sort_criteria;
+ _data_->_tmp25_ = _data_->cancellable;
+ _data_->_state_ = 2;
+ rygel_media_container_get_children (_data_->_tmp21_, _data_->_tmp22_, _data_->_tmp23_, _data_->_tmp24_, _data_->_tmp25_, rygel_media_export_root_container_search_ready, _data_);
+ return FALSE;
+ _state_2:
+ _data_->_tmp26_ = NULL;
+ _data_->_tmp26_ = rygel_media_container_get_children_finish (_data_->_tmp21_, _data_->_res_, &_data_->_inner_error_);
+ _data_->_tmp27_ = _data_->_tmp26_;
+ 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_free0 (_data_->upnp_class);
+ _g_object_unref0 (_data_->query_container);
+ _g_object_unref0 (_data_->list);
+ 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_unref0 (_data_->list);
+ _data_->list = _data_->_tmp27_;
+ _data_->_tmp28_ = _data_->query_container;
+ _data_->_tmp29_ = _data_->_tmp28_->child_count;
+ _data_->total_matches = (guint) _data_->_tmp29_;
+ _data_->_tmp30_ = _data_->upnp_class;
+ if (_data_->_tmp30_ != NULL) {
+ {
+ _data_->_tmp31_ = _data_->list;
+ _data_->_tmp32_ = _g_object_ref0 (_data_->_tmp31_);
+ _data_->_object_list = _data_->_tmp32_;
+ _data_->_tmp33_ = _data_->_object_list;
+ _data_->_tmp34_ = gee_abstract_collection_get_size ((GeeCollection*) _data_->_tmp33_);
+ _data_->_tmp35_ = _data_->_tmp34_;
+ _data_->_object_size = _data_->_tmp35_;
+ _data_->_object_index = -1;
+ while (TRUE) {
+ _data_->_tmp36_ = _data_->_object_index;
+ _data_->_object_index = _data_->_tmp36_ + 1;
+ _data_->_tmp37_ = _data_->_object_index;
+ _data_->_tmp38_ = _data_->_object_size;
+ if (!(_data_->_tmp37_ < _data_->_tmp38_)) {
+ break;
+ }
+ _data_->_tmp39_ = _data_->_object_list;
+ _data_->_tmp40_ = _data_->_object_index;
+ _data_->_tmp41_ = NULL;
+ _data_->_tmp41_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp39_, _data_->_tmp40_);
+ _data_->object = (RygelMediaObject*) _data_->_tmp41_;
+ _data_->_tmp42_ = _data_->object;
+ _data_->_tmp43_ = _data_->upnp_class;
+ rygel_media_object_set_upnp_class (_data_->_tmp42_, _data_->_tmp43_);
+ _g_object_unref0 (_data_->object);
+ }
+ _g_object_unref0 (_data_->_object_list);
+ }
+ }
+ _data_->result = _data_->list;
+ _g_free0 (_data_->upnp_class);
+ _g_object_unref0 (_data_->query_container);
+ 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;
+ } else {
+ _data_->_tmp44_ = _data_->expression;
+ _data_->_tmp45_ = _data_->offset;
+ _data_->_tmp46_ = _data_->max_count;
+ _data_->_tmp47_ = _data_->sort_criteria;
+ _data_->_tmp48_ = _data_->cancellable;
+ _data_->_tmp49_ = 0U;
+ _data_->_state_ = 3;
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (rygel_media_export_root_container_parent_class)->search (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer), _data_->_tmp44_, _data_->_tmp45_, _data_->_tmp46_, _data_->_tmp47_, _data_->_tmp48_, rygel_media_export_root_container_search_ready, _data_);
+ return FALSE;
+ _state_3:
+ _data_->_tmp50_ = NULL;
+ _data_->_tmp50_ = RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (rygel_media_export_root_container_parent_class)->search_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer), _data_->_res_, &_data_->_tmp49_, &_data_->_inner_error_);
+ _data_->total_matches = _data_->_tmp49_;
+ _data_->_tmp51_ = _data_->_tmp50_;
+ 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_free0 (_data_->upnp_class);
+ _g_object_unref0 (_data_->query_container);
+ _g_object_unref0 (_data_->list);
+ 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_->result = _data_->_tmp51_;
+ _g_free0 (_data_->upnp_class);
+ _g_object_unref0 (_data_->query_container);
+ _g_object_unref0 (_data_->list);
+ 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_free0 (_data_->upnp_class);
+ _g_object_unref0 (_data_->query_container);
+ _g_object_unref0 (_data_->list);
+ 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 gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
+ gchar* result = NULL;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (old != NULL, NULL);
+ g_return_val_if_fail (replacement != NULL, NULL);
+ {
+ const gchar* _tmp0_;
+ gchar* _tmp1_ = NULL;
+ gchar* _tmp2_;
+ GRegex* _tmp3_;
+ GRegex* _tmp4_;
+ GRegex* regex;
+ GRegex* _tmp5_;
+ const gchar* _tmp6_;
+ gchar* _tmp7_ = NULL;
+ gchar* _tmp8_;
+ _tmp0_ = old;
+ _tmp1_ = g_regex_escape_string (_tmp0_, -1);
+ _tmp2_ = _tmp1_;
+ _tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
+ _tmp4_ = _tmp3_;
+ _g_free0 (_tmp2_);
+ regex = _tmp4_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == G_REGEX_ERROR) {
+ goto __catch31_g_regex_error;
+ }
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _tmp5_ = regex;
+ _tmp6_ = replacement;
+ _tmp7_ = g_regex_replace_literal (_tmp5_, self, (gssize) (-1), 0, _tmp6_, 0, &_inner_error_);
+ _tmp8_ = _tmp7_;
+ if (_inner_error_ != NULL) {
+ _g_regex_unref0 (regex);
+ if (_inner_error_->domain == G_REGEX_ERROR) {
+ goto __catch31_g_regex_error;
+ }
+ _g_regex_unref0 (regex);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ result = _tmp8_;
+ _g_regex_unref0 (regex);
+ return result;
+ }
+ goto __finally31;
+ __catch31_g_regex_error:
+ {
+ GError* e = NULL;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ g_assert_not_reached ();
+ _g_error_free0 (e);
+ }
+ __finally31:
+ if (_inner_error_ != 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 NULL;
+ }
+}
+
+
+static GeeArrayList* rygel_media_export_root_container_get_shared_uris (RygelMediaExportRootContainer* self) {
+ GeeArrayList* result = NULL;
+ GeeArrayList* uris = NULL;
+ GeeArrayList* actual_uris = NULL;
+ RygelMetaConfig* _tmp0_ = NULL;
+ RygelMetaConfig* config;
+ GeeArrayList* _tmp9_;
+ const gchar* _tmp10_ = NULL;
+ GFile* _tmp11_ = NULL;
+ GFile* home_dir;
+ const gchar* _tmp12_ = NULL;
+ const gchar* pictures_dir;
+ const gchar* _tmp13_ = NULL;
+ const gchar* videos_dir;
+ const gchar* _tmp14_ = NULL;
+ const gchar* music_dir;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = rygel_meta_config_get_default ();
+ config = _tmp0_;
+ {
+ GeeArrayList* _tmp1_ = NULL;
+ GeeArrayList* _tmp2_;
+ _tmp1_ = rygel_configuration_get_string_list ((RygelConfiguration*) config, "MediaExport", "uris", &_inner_error_);
+ _tmp2_ = _tmp1_;
+ if (_inner_error_ != NULL) {
+ goto __catch29_g_error;
+ }
+ _g_object_unref0 (uris);
+ uris = _tmp2_;
+ }
+ goto __finally29;
+ __catch29_g_error:
+ {
+ GError* _error_ = NULL;
+ GeeArrayList* _tmp3_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp3_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ _g_object_unref0 (uris);
+ uris = _tmp3_;
+ _g_error_free0 (_error_);
+ }
+ __finally29:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (config);
+ _g_object_unref0 (actual_uris);
+ _g_object_unref0 (uris);
+ 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;
+ }
+ {
+ RygelMediaExportMediaCache* _tmp4_;
+ GeeList* _tmp5_ = NULL;
+ GeeList* _tmp6_;
+ GeeArrayList* _tmp7_;
+ GeeList* _tmp8_;
+ _tmp4_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp5_ = rygel_media_export_media_cache_get_flagged_uris (_tmp4_, "DBUS", &_inner_error_);
+ _tmp6_ = _tmp5_;
+ if (_inner_error_ != NULL) {
+ goto __catch30_g_error;
+ }
+ _tmp7_ = uris;
+ _tmp8_ = _tmp6_;
+ gee_array_list_add_all (_tmp7_, (GeeCollection*) _tmp8_);
+ _g_object_unref0 (_tmp8_);
+ }
+ goto __finally30;
+ __catch30_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally30:
+ if (_inner_error_ != NULL) {
+ _g_object_unref0 (config);
+ _g_object_unref0 (actual_uris);
+ _g_object_unref0 (uris);
+ 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;
+ }
+ _tmp9_ = gee_array_list_new (G_TYPE_FILE, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL);
+ _g_object_unref0 (actual_uris);
+ actual_uris = _tmp9_;
+ _tmp10_ = g_get_home_dir ();
+ _tmp11_ = g_file_new_for_path (_tmp10_);
+ home_dir = _tmp11_;
+ _tmp12_ = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES);
+ pictures_dir = _tmp12_;
+ _tmp13_ = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
+ videos_dir = _tmp13_;
+ _tmp14_ = g_get_user_special_dir (G_USER_DIRECTORY_MUSIC);
+ music_dir = _tmp14_;
+ {
+ GeeArrayList* _tmp15_;
+ GeeArrayList* _tmp16_;
+ GeeArrayList* _uri_list;
+ GeeArrayList* _tmp17_;
+ gint _tmp18_;
+ gint _tmp19_;
+ gint _uri_size;
+ gint _uri_index;
+ _tmp15_ = uris;
+ _tmp16_ = _g_object_ref0 (_tmp15_);
+ _uri_list = _tmp16_;
+ _tmp17_ = _uri_list;
+ _tmp18_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp17_);
+ _tmp19_ = _tmp18_;
+ _uri_size = _tmp19_;
+ _uri_index = -1;
+ while (TRUE) {
+ gint _tmp20_;
+ gint _tmp21_;
+ gint _tmp22_;
+ GeeArrayList* _tmp23_;
+ gint _tmp24_;
+ gpointer _tmp25_ = NULL;
+ gchar* uri;
+ const gchar* _tmp26_;
+ GFile* _tmp27_ = NULL;
+ GFile* file;
+ GFile* _tmp28_;
+ GFile* _tmp29_;
+ gboolean _tmp30_ = FALSE;
+ GeeArrayList* _tmp52_;
+ GFile* _tmp53_;
+ _tmp20_ = _uri_index;
+ _uri_index = _tmp20_ + 1;
+ _tmp21_ = _uri_index;
+ _tmp22_ = _uri_size;
+ if (!(_tmp21_ < _tmp22_)) {
+ break;
+ }
+ _tmp23_ = _uri_list;
+ _tmp24_ = _uri_index;
+ _tmp25_ = gee_abstract_list_get ((GeeAbstractList*) _tmp23_, _tmp24_);
+ uri = (gchar*) _tmp25_;
+ _tmp26_ = uri;
+ _tmp27_ = g_file_new_for_commandline_arg (_tmp26_);
+ file = _tmp27_;
+ _tmp28_ = file;
+ _tmp29_ = home_dir;
+ _tmp30_ = G_LIKELY (_tmp28_ != _tmp29_);
+ if (_tmp30_) {
+ const gchar* _tmp31_;
+ gchar* _tmp32_;
+ gchar* actual_uri;
+ const gchar* _tmp33_;
+ gboolean _tmp34_ = FALSE;
+ const gchar* _tmp38_;
+ gboolean _tmp39_ = FALSE;
+ const gchar* _tmp43_;
+ gboolean _tmp44_ = FALSE;
+ const gchar* _tmp48_;
+ GFile* _tmp49_ = NULL;
+ GFile* _tmp50_;
+ GFile* _tmp51_;
+ _tmp31_ = uri;
+ _tmp32_ = g_strdup (_tmp31_);
+ actual_uri = _tmp32_;
+ _tmp33_ = pictures_dir;
+ _tmp34_ = G_LIKELY (_tmp33_ != NULL);
+ if (_tmp34_) {
+ const gchar* _tmp35_;
+ const gchar* _tmp36_;
+ gchar* _tmp37_ = NULL;
+ _tmp35_ = actual_uri;
+ _tmp36_ = pictures_dir;
+ _tmp37_ = string_replace (_tmp35_, "@PICTURES@", _tmp36_);
+ _g_free0 (actual_uri);
+ actual_uri = _tmp37_;
+ }
+ _tmp38_ = videos_dir;
+ _tmp39_ = G_LIKELY (_tmp38_ != NULL);
+ if (_tmp39_) {
+ const gchar* _tmp40_;
+ const gchar* _tmp41_;
+ gchar* _tmp42_ = NULL;
+ _tmp40_ = actual_uri;
+ _tmp41_ = videos_dir;
+ _tmp42_ = string_replace (_tmp40_, "@VIDEOS@", _tmp41_);
+ _g_free0 (actual_uri);
+ actual_uri = _tmp42_;
+ }
+ _tmp43_ = music_dir;
+ _tmp44_ = G_LIKELY (_tmp43_ != NULL);
+ if (_tmp44_) {
+ const gchar* _tmp45_;
+ const gchar* _tmp46_;
+ gchar* _tmp47_ = NULL;
+ _tmp45_ = actual_uri;
+ _tmp46_ = music_dir;
+ _tmp47_ = string_replace (_tmp45_, "@MUSIC@", _tmp46_);
+ _g_free0 (actual_uri);
+ actual_uri = _tmp47_;
+ }
+ _tmp48_ = actual_uri;
+ _tmp49_ = g_file_new_for_commandline_arg (_tmp48_);
+ _g_object_unref0 (file);
+ file = _tmp49_;
+ _tmp50_ = file;
+ _tmp51_ = home_dir;
+ if (_tmp50_ == _tmp51_) {
+ _g_free0 (actual_uri);
+ _g_object_unref0 (file);
+ _g_free0 (uri);
+ continue;
+ }
+ _g_free0 (actual_uri);
+ }
+ _tmp52_ = actual_uris;
+ _tmp53_ = file;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp52_, _tmp53_);
+ _g_object_unref0 (file);
+ _g_free0 (uri);
+ }
+ _g_object_unref0 (_uri_list);
+ }
+ result = actual_uris;
+ _g_object_unref0 (home_dir);
+ _g_object_unref0 (config);
+ _g_object_unref0 (uris);
+ return result;
+}
+
+
+static RygelMediaExportQueryContainer* rygel_media_export_root_container_search_to_virtual_container (RygelMediaExportRootContainer* self, RygelRelationalExpression* expression) {
+ RygelMediaExportQueryContainer* result = NULL;
+ gboolean _tmp0_ = FALSE;
+ RygelRelationalExpression* _tmp1_;
+ gconstpointer _tmp2_;
+ gboolean _tmp5_;
+ g_return_val_if_fail (self != NULL, NULL);
+ g_return_val_if_fail (expression != NULL, NULL);
+ _tmp1_ = expression;
+ _tmp2_ = ((RygelSearchExpression*) _tmp1_)->operand1;
+ if (g_strcmp0 ((const gchar*) _tmp2_, "upnp:class") == 0) {
+ RygelRelationalExpression* _tmp3_;
+ gconstpointer _tmp4_;
+ _tmp3_ = expression;
+ _tmp4_ = ((RygelSearchExpression*) _tmp3_)->op;
+ _tmp0_ = ((GUPnPSearchCriteriaOp) ((gintptr) _tmp4_)) == GUPNP_SEARCH_CRITERIA_OP_EQ;
+ } else {
+ _tmp0_ = FALSE;
+ }
+ _tmp5_ = _tmp0_;
+ if (_tmp5_) {
+ gchar* _tmp6_;
+ gchar* id;
+ RygelRelationalExpression* _tmp7_;
+ gconstpointer _tmp8_;
+ const gchar* _tmp9_;
+ GQuark _tmp11_ = 0U;
+ static GQuark _tmp10_label0 = 0;
+ static GQuark _tmp10_label1 = 0;
+ static GQuark _tmp10_label2 = 0;
+ RygelMediaExportQueryContainerFactory* _tmp18_ = NULL;
+ RygelMediaExportQueryContainerFactory* factory;
+ RygelMediaExportQueryContainerFactory* _tmp19_;
+ RygelMediaExportMediaCache* _tmp20_;
+ const gchar* _tmp21_;
+ RygelMediaExportQueryContainer* _tmp22_ = NULL;
+ _tmp6_ = g_strdup (RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_SEARCH_CONTAINER_PREFIX);
+ id = _tmp6_;
+ _tmp7_ = expression;
+ _tmp8_ = ((RygelSearchExpression*) _tmp7_)->operand2;
+ _tmp9_ = (const gchar*) _tmp8_;
+ _tmp11_ = (NULL == _tmp9_) ? 0 : g_quark_from_string (_tmp9_);
+ if (_tmp11_ == ((0 != _tmp10_label0) ? _tmp10_label0 : (_tmp10_label0 = g_quark_from_static_string ("object.container.album.musicAlbum")))) {
+ switch (0) {
+ default:
+ {
+ const gchar* _tmp12_;
+ gchar* _tmp13_;
+ _tmp12_ = id;
+ _tmp13_ = g_strconcat (_tmp12_, "upnp:album,?", NULL);
+ _g_free0 (id);
+ id = _tmp13_;
+ break;
+ }
+ }
+ } else if (_tmp11_ == ((0 != _tmp10_label1) ? _tmp10_label1 : (_tmp10_label1 = g_quark_from_static_string ("object.container.person.musicArtist")))) {
+ switch (0) {
+ default:
+ {
+ const gchar* _tmp14_;
+ gchar* _tmp15_;
+ _tmp14_ = id;
+ _tmp15_ = g_strconcat (_tmp14_, "dc:creator,?,upnp:album,?", NULL);
+ _g_free0 (id);
+ id = _tmp15_;
+ break;
+ }
+ }
+ } else if (_tmp11_ == ((0 != _tmp10_label2) ? _tmp10_label2 : (_tmp10_label2 = g_quark_from_static_string ("object.container.genre.musicGenre")))) {
+ switch (0) {
+ default:
+ {
+ const gchar* _tmp16_;
+ gchar* _tmp17_;
+ _tmp16_ = id;
+ _tmp17_ = g_strconcat (_tmp16_, "dc:genre,?", NULL);
+ _g_free0 (id);
+ id = _tmp17_;
+ break;
+ }
+ }
+ } else {
+ switch (0) {
+ default:
+ {
+ result = NULL;
+ _g_free0 (id);
+ return result;
+ }
+ }
+ }
+ _tmp18_ = rygel_media_export_query_container_factory_get_default ();
+ factory = _tmp18_;
+ _tmp19_ = factory;
+ _tmp20_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp21_ = id;
+ _tmp22_ = rygel_media_export_query_container_factory_create_from_description (_tmp19_, _tmp20_, _tmp21_, "");
+ result = _tmp22_;
+ _g_object_unref0 (factory);
+ _g_free0 (id);
+ return result;
+ }
+ result = NULL;
+ return result;
+}
+
+
+/**
+ * Check if a passed search expression is a simple search in a virtual
+ * container.
+ *
+ * @param expression the expression to check
+ * @param new_id contains the id of the virtual container constructed from
+ * the search
+ * @param upnp_class contains the class of the container the search was
+ * looking in
+ * @return true if it was a search in virtual container, false otherwise.
+ * @note This works single level only. Enough to satisfy Xbox music
+ * browsing, but may need refinement
+ */
+static gboolean rygel_media_export_root_container_is_search_in_virtual_container (RygelMediaExportRootContainer* self, RygelSearchExpression* expression, RygelMediaContainer** container) {
+ RygelMediaContainer* _vala_container = NULL;
+ gboolean result = FALSE;
+ RygelRelationalExpression* virtual_expression;
+ RygelMediaExportQueryContainer* query_container = NULL;
+ RygelSearchExpression* _tmp0_;
+ RygelSearchExpression* _tmp1_;
+ RygelLogicalExpression* _tmp2_;
+ RygelLogicalExpression* logical_expression;
+ gboolean _tmp3_ = FALSE;
+ gboolean _tmp4_ = FALSE;
+ RygelLogicalExpression* _tmp5_;
+ gconstpointer _tmp6_;
+ gboolean _tmp9_;
+ gboolean _tmp12_;
+ RygelLogicalExpression* _tmp13_;
+ gconstpointer _tmp14_;
+ RygelRelationalExpression* _tmp15_;
+ RygelRelationalExpression* left_expression;
+ RygelLogicalExpression* _tmp16_;
+ gconstpointer _tmp17_;
+ RygelRelationalExpression* _tmp18_;
+ RygelRelationalExpression* right_expression;
+ RygelRelationalExpression* _tmp19_;
+ RygelMediaExportQueryContainer* _tmp20_ = NULL;
+ RygelMediaExportQueryContainer* _tmp21_;
+ RygelMediaExportQueryContainerFactory* _tmp29_ = NULL;
+ RygelMediaExportQueryContainerFactory* factory;
+ RygelMediaExportQueryContainerFactory* _tmp30_;
+ RygelMediaExportQueryContainer* _tmp31_;
+ const gchar* _tmp32_;
+ const gchar* _tmp33_;
+ gchar* _tmp34_ = NULL;
+ gchar* plaintext_id;
+ const gchar* _tmp35_;
+ gchar* _tmp36_ = NULL;
+ gchar* last_argument;
+ RygelRelationalExpression* _tmp37_;
+ gconstpointer _tmp38_;
+ gchar* _tmp39_ = NULL;
+ gchar* escaped_detail;
+ RygelRelationalExpression* _tmp40_;
+ gconstpointer _tmp41_;
+ const gchar* _tmp42_;
+ const gchar* _tmp43_;
+ gchar* _tmp44_ = NULL;
+ gchar* new_id;
+ RygelMediaExportQueryContainerFactory* _tmp45_;
+ RygelMediaExportMediaCache* _tmp46_;
+ const gchar* _tmp47_;
+ RygelMediaExportQueryContainer* _tmp48_ = NULL;
+ g_return_val_if_fail (self != NULL, FALSE);
+ g_return_val_if_fail (expression != NULL, FALSE);
+ virtual_expression = NULL;
+ _g_object_unref0 (_vala_container);
+ _vala_container = NULL;
+ _tmp0_ = expression;
+ if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, RYGEL_TYPE_LOGICAL_EXPRESSION)) {
+ result = FALSE;
+ _g_object_unref0 (query_container);
+ _rygel_search_expression_unref0 (virtual_expression);
+ if (container) {
+ *container = _vala_container;
+ } else {
+ _g_object_unref0 (_vala_container);
+ }
+ return result;
+ }
+ _tmp1_ = expression;
+ _tmp2_ = _rygel_search_expression_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, RYGEL_TYPE_LOGICAL_EXPRESSION) ? ((RygelLogicalExpression*) _tmp1_) : NULL);
+ logical_expression = _tmp2_;
+ _tmp5_ = logical_expression;
+ _tmp6_ = ((RygelSearchExpression*) _tmp5_)->operand1;
+ if (G_TYPE_CHECK_INSTANCE_TYPE ((RygelSearchExpression*) _tmp6_, RYGEL_TYPE_RELATIONAL_EXPRESSION)) {
+ RygelLogicalExpression* _tmp7_;
+ gconstpointer _tmp8_;
+ _tmp7_ = logical_expression;
+ _tmp8_ = ((RygelSearchExpression*) _tmp7_)->operand2;
+ _tmp4_ = G_TYPE_CHECK_INSTANCE_TYPE ((RygelSearchExpression*) _tmp8_, RYGEL_TYPE_RELATIONAL_EXPRESSION);
+ } else {
+ _tmp4_ = FALSE;
+ }
+ _tmp9_ = _tmp4_;
+ if (_tmp9_) {
+ RygelLogicalExpression* _tmp10_;
+ gconstpointer _tmp11_;
+ _tmp10_ = logical_expression;
+ _tmp11_ = ((RygelSearchExpression*) _tmp10_)->op;
+ _tmp3_ = ((RygelLogicalOperator) ((gintptr) _tmp11_)) == RYGEL_LOGICAL_OPERATOR_AND;
+ } else {
+ _tmp3_ = FALSE;
+ }
+ _tmp12_ = _tmp3_;
+ if (!_tmp12_) {
+ result = FALSE;
+ _rygel_search_expression_unref0 (logical_expression);
+ _g_object_unref0 (query_container);
+ _rygel_search_expression_unref0 (virtual_expression);
+ if (container) {
+ *container = _vala_container;
+ } else {
+ _g_object_unref0 (_vala_container);
+ }
+ return result;
+ }
+ _tmp13_ = logical_expression;
+ _tmp14_ = ((RygelSearchExpression*) _tmp13_)->operand1;
+ _tmp15_ = _rygel_search_expression_ref0 (G_TYPE_CHECK_INSTANCE_TYPE ((RygelSearchExpression*) _tmp14_, RYGEL_TYPE_RELATIONAL_EXPRESSION) ? ((RygelRelationalExpression*) ((RygelSearchExpression*) _tmp14_)) : NULL);
+ left_expression = _tmp15_;
+ _tmp16_ = logical_expression;
+ _tmp17_ = ((RygelSearchExpression*) _tmp16_)->operand2;
+ _tmp18_ = _rygel_search_expression_ref0 (G_TYPE_CHECK_INSTANCE_TYPE ((RygelSearchExpression*) _tmp17_, RYGEL_TYPE_RELATIONAL_EXPRESSION) ? ((RygelRelationalExpression*) ((RygelSearchExpression*) _tmp17_)) : NULL);
+ right_expression = _tmp18_;
+ _tmp19_ = left_expression;
+ _tmp20_ = rygel_media_export_root_container_search_to_virtual_container (self, _tmp19_);
+ _g_object_unref0 (query_container);
+ query_container = _tmp20_;
+ _tmp21_ = query_container;
+ if (_tmp21_ == NULL) {
+ RygelRelationalExpression* _tmp22_;
+ RygelMediaExportQueryContainer* _tmp23_ = NULL;
+ RygelMediaExportQueryContainer* _tmp24_;
+ _tmp22_ = right_expression;
+ _tmp23_ = rygel_media_export_root_container_search_to_virtual_container (self, _tmp22_);
+ _g_object_unref0 (query_container);
+ query_container = _tmp23_;
+ _tmp24_ = query_container;
+ if (_tmp24_ != NULL) {
+ RygelRelationalExpression* _tmp25_;
+ RygelRelationalExpression* _tmp26_;
+ _tmp25_ = left_expression;
+ _tmp26_ = _rygel_search_expression_ref0 (_tmp25_);
+ _rygel_search_expression_unref0 (virtual_expression);
+ virtual_expression = _tmp26_;
+ } else {
+ result = FALSE;
+ _rygel_search_expression_unref0 (right_expression);
+ _rygel_search_expression_unref0 (left_expression);
+ _rygel_search_expression_unref0 (logical_expression);
+ _g_object_unref0 (query_container);
+ _rygel_search_expression_unref0 (virtual_expression);
+ if (container) {
+ *container = _vala_container;
+ } else {
+ _g_object_unref0 (_vala_container);
+ }
+ return result;
+ }
+ } else {
+ RygelRelationalExpression* _tmp27_;
+ RygelRelationalExpression* _tmp28_;
+ _tmp27_ = right_expression;
+ _tmp28_ = _rygel_search_expression_ref0 (_tmp27_);
+ _rygel_search_expression_unref0 (virtual_expression);
+ virtual_expression = _tmp28_;
+ }
+ _tmp29_ = rygel_media_export_query_container_factory_get_default ();
+ factory = _tmp29_;
+ _tmp30_ = factory;
+ _tmp31_ = query_container;
+ _tmp32_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp31_);
+ _tmp33_ = _tmp32_;
+ _tmp34_ = rygel_media_export_query_container_factory_get_virtual_container_definition (_tmp30_, _tmp33_);
+ plaintext_id = _tmp34_;
+ _tmp35_ = plaintext_id;
+ _tmp36_ = string_replace (_tmp35_, RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX, "");
+ last_argument = _tmp36_;
+ _tmp37_ = virtual_expression;
+ _tmp38_ = ((RygelSearchExpression*) _tmp37_)->operand2;
+ _tmp39_ = g_uri_escape_string ((const gchar*) _tmp38_, "", TRUE);
+ escaped_detail = _tmp39_;
+ _tmp40_ = virtual_expression;
+ _tmp41_ = ((RygelSearchExpression*) _tmp40_)->operand1;
+ _tmp42_ = escaped_detail;
+ _tmp43_ = last_argument;
+ _tmp44_ = g_strdup_printf ("%s%s,%s,%s", RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX, (const gchar*) _tmp41_, _tmp42_, _tmp43_);
+ new_id = _tmp44_;
+ _tmp45_ = factory;
+ _tmp46_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp47_ = new_id;
+ _tmp48_ = rygel_media_export_query_container_factory_create_from_description (_tmp45_, _tmp46_, _tmp47_, "");
+ _g_object_unref0 (_vala_container);
+ _vala_container = (RygelMediaContainer*) _tmp48_;
+ result = TRUE;
+ _g_free0 (new_id);
+ _g_free0 (escaped_detail);
+ _g_free0 (last_argument);
+ _g_free0 (plaintext_id);
+ _g_object_unref0 (factory);
+ _rygel_search_expression_unref0 (right_expression);
+ _rygel_search_expression_unref0 (left_expression);
+ _rygel_search_expression_unref0 (logical_expression);
+ _g_object_unref0 (query_container);
+ _rygel_search_expression_unref0 (virtual_expression);
+ if (container) {
+ *container = _vala_container;
+ } else {
+ _g_object_unref0 (_vala_container);
+ }
+ return result;
+}
+
+
+/**
+ * Create a new root container.
+ */
+static void _rygel_media_export_root_container_on_initial_harvesting_done_rygel_media_export_harvester_done (RygelMediaExportHarvester* _sender, gpointer self) {
+ rygel_media_export_root_container_on_initial_harvesting_done (self);
+}
+
+
+static RygelMediaExportRootContainer* rygel_media_export_root_container_construct (GType object_type, GError** error) {
+ RygelMediaExportRootContainer * self = NULL;
+ RygelMediaExportMediaCache* _tmp0_ = NULL;
+ RygelMediaExportMediaCache* db;
+ const gchar* _tmp1_ = NULL;
+ GCancellable* _tmp2_;
+ GeeArrayList* ids = NULL;
+ GCancellable* _tmp19_;
+ GeeArrayList* _tmp20_ = NULL;
+ GeeArrayList* _tmp21_;
+ RygelMediaExportHarvester* _tmp22_;
+ RygelMediaExportHarvester* _tmp23_;
+ gulong _tmp24_ = 0UL;
+ GError * _inner_error_ = NULL;
+ _tmp0_ = rygel_media_export_media_cache_get_default (&_inner_error_);
+ db = _tmp0_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ _tmp1_ = _ ("@REALNAME@'s media");
+ self = (RygelMediaExportRootContainer*) rygel_media_export_db_container_construct (object_type, db, "0", _tmp1_);
+ _tmp2_ = g_cancellable_new ();
+ _g_object_unref0 (self->priv->cancellable);
+ self->priv->cancellable = _tmp2_;
+ {
+ RygelMediaExportDBusService* _tmp3_;
+ RygelMediaExportDBusService* _tmp4_;
+ _tmp3_ = rygel_media_export_dbus_service_new (self, &_inner_error_);
+ _tmp4_ = _tmp3_;
+ if (_inner_error_ != NULL) {
+ goto __catch32_g_error;
+ }
+ _g_object_unref0 (self->priv->service);
+ self->priv->service = _tmp4_;
+ }
+ goto __finally32;
+ __catch32_g_error:
+ {
+ GError* err = NULL;
+ const gchar* _tmp5_ = NULL;
+ GError* _tmp6_;
+ const gchar* _tmp7_;
+ err = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp5_ = _ ("Failed to create MediaExport D-Bus service: %s");
+ _tmp6_ = err;
+ _tmp7_ = _tmp6_->message;
+ g_warning (_tmp5_, _tmp7_);
+ _g_error_free0 (err);
+ }
+ __finally32:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (db);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ {
+ RygelMediaExportMediaCache* _tmp8_;
+ _tmp8_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ rygel_media_export_media_cache_save_container (_tmp8_, (RygelMediaContainer*) self, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch33_g_error;
+ }
+ }
+ goto __finally33;
+ __catch33_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally33:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (db);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ {
+ RygelMediaExportMediaCache* _tmp9_;
+ const gchar* _tmp10_ = NULL;
+ RygelMediaExportDBContainer* _tmp11_;
+ RygelMediaContainer* _tmp12_;
+ RygelMediaExportMediaCache* _tmp13_;
+ RygelMediaContainer* _tmp14_;
+ _tmp9_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp10_ = _ (RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_NAME);
+ _tmp11_ = rygel_media_export_db_container_new (_tmp9_, RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID, _tmp10_);
+ _g_object_unref0 (self->priv->filesystem_container);
+ self->priv->filesystem_container = (RygelMediaContainer*) _tmp11_;
+ _tmp12_ = self->priv->filesystem_container;
+ ((RygelMediaObject*) _tmp12_)->parent = (RygelMediaContainer*) self;
+ _tmp13_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp14_ = self->priv->filesystem_container;
+ rygel_media_export_media_cache_save_container (_tmp13_, _tmp14_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch34_g_error;
+ }
+ }
+ goto __finally34;
+ __catch34_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally34:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (db);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ {
+ RygelMediaExportMediaCache* _tmp15_;
+ GeeArrayList* _tmp16_ = NULL;
+ GeeArrayList* _tmp17_;
+ _tmp15_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp16_ = rygel_media_export_media_cache_get_child_ids (_tmp15_, RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_FILESYSTEM_FOLDER_ID, &_inner_error_);
+ _tmp17_ = _tmp16_;
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch35_rygel_media_export_database_error;
+ }
+ _g_object_unref0 (ids);
+ _g_object_unref0 (db);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ _g_object_unref0 (ids);
+ ids = _tmp17_;
+ }
+ goto __finally35;
+ __catch35_rygel_media_export_database_error:
+ {
+ GError* e = NULL;
+ GeeArrayList* _tmp18_;
+ e = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp18_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ _g_object_unref0 (ids);
+ ids = _tmp18_;
+ _g_error_free0 (e);
+ }
+ __finally35:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (ids);
+ _g_object_unref0 (db);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ _tmp19_ = self->priv->cancellable;
+ _tmp20_ = rygel_media_export_root_container_get_shared_uris (self);
+ _tmp21_ = _tmp20_;
+ _tmp22_ = rygel_media_export_harvester_new (_tmp19_, _tmp21_);
+ _g_object_unref0 (self->priv->harvester);
+ self->priv->harvester = _tmp22_;
+ _g_object_unref0 (_tmp21_);
+ _tmp23_ = self->priv->harvester;
+ _tmp24_ = g_signal_connect_object (_tmp23_, "done", (GCallback) _rygel_media_export_root_container_on_initial_harvesting_done_rygel_media_export_harvester_done, self, 0);
+ self->priv->harvester_signal_id = _tmp24_;
+ {
+ RygelMediaExportHarvester* _tmp25_;
+ GeeArrayList* _tmp26_;
+ GeeArrayList* _tmp27_;
+ GeeArrayList* _tmp28_;
+ GeeArrayList* _file_list;
+ GeeArrayList* _tmp29_;
+ gint _tmp30_;
+ gint _tmp31_;
+ gint _file_size;
+ gint _file_index;
+ _tmp25_ = self->priv->harvester;
+ _tmp26_ = rygel_media_export_harvester_get_locations (_tmp25_);
+ _tmp27_ = _tmp26_;
+ _tmp28_ = _g_object_ref0 (_tmp27_);
+ _file_list = _tmp28_;
+ _tmp29_ = _file_list;
+ _tmp30_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp29_);
+ _tmp31_ = _tmp30_;
+ _file_size = _tmp31_;
+ _file_index = -1;
+ while (TRUE) {
+ gint _tmp32_;
+ gint _tmp33_;
+ gint _tmp34_;
+ GeeArrayList* _tmp35_;
+ gint _tmp36_;
+ gpointer _tmp37_ = NULL;
+ GFile* file;
+ GeeArrayList* _tmp38_;
+ GFile* _tmp39_;
+ gchar* _tmp40_ = NULL;
+ gchar* _tmp41_;
+ RygelMediaExportHarvester* _tmp42_;
+ GFile* _tmp43_;
+ RygelMediaContainer* _tmp44_;
+ _tmp32_ = _file_index;
+ _file_index = _tmp32_ + 1;
+ _tmp33_ = _file_index;
+ _tmp34_ = _file_size;
+ if (!(_tmp33_ < _tmp34_)) {
+ break;
+ }
+ _tmp35_ = _file_list;
+ _tmp36_ = _file_index;
+ _tmp37_ = gee_abstract_list_get ((GeeAbstractList*) _tmp35_, _tmp36_);
+ file = (GFile*) _tmp37_;
+ _tmp38_ = ids;
+ _tmp39_ = file;
+ _tmp40_ = rygel_media_export_media_cache_get_id (_tmp39_);
+ _tmp41_ = _tmp40_;
+ gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp38_, _tmp41_);
+ _g_free0 (_tmp41_);
+ _tmp42_ = self->priv->harvester;
+ _tmp43_ = file;
+ _tmp44_ = self->priv->filesystem_container;
+ rygel_media_export_harvester_schedule (_tmp42_, _tmp43_, _tmp44_, NULL);
+ _g_object_unref0 (file);
+ }
+ _g_object_unref0 (_file_list);
+ }
+ {
+ GeeArrayList* _tmp45_;
+ GeeArrayList* _tmp46_;
+ GeeArrayList* _id_list;
+ GeeArrayList* _tmp47_;
+ gint _tmp48_;
+ gint _tmp49_;
+ gint _id_size;
+ gint _id_index;
+ _tmp45_ = ids;
+ _tmp46_ = _g_object_ref0 (_tmp45_);
+ _id_list = _tmp46_;
+ _tmp47_ = _id_list;
+ _tmp48_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp47_);
+ _tmp49_ = _tmp48_;
+ _id_size = _tmp49_;
+ _id_index = -1;
+ while (TRUE) {
+ gint _tmp50_;
+ gint _tmp51_;
+ gint _tmp52_;
+ GeeArrayList* _tmp53_;
+ gint _tmp54_;
+ gpointer _tmp55_ = NULL;
+ gchar* id;
+ const gchar* _tmp56_;
+ _tmp50_ = _id_index;
+ _id_index = _tmp50_ + 1;
+ _tmp51_ = _id_index;
+ _tmp52_ = _id_size;
+ if (!(_tmp51_ < _tmp52_)) {
+ break;
+ }
+ _tmp53_ = _id_list;
+ _tmp54_ = _id_index;
+ _tmp55_ = gee_abstract_list_get ((GeeAbstractList*) _tmp53_, _tmp54_);
+ id = (gchar*) _tmp55_;
+ _tmp56_ = id;
+ g_debug ("rygel-media-export-root-container.vala:397: ID %s no longer in config;" \
+" deleting...", _tmp56_);
+ {
+ RygelMediaExportMediaCache* _tmp57_;
+ const gchar* _tmp58_;
+ _tmp57_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp58_ = id;
+ rygel_media_export_media_cache_remove_by_id (_tmp57_, _tmp58_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ goto __catch36_rygel_media_export_database_error;
+ }
+ _g_free0 (id);
+ _g_object_unref0 (_id_list);
+ _g_object_unref0 (ids);
+ _g_object_unref0 (db);
+ g_critical ("file %s: line %d: unexpected 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;
+ }
+ }
+ goto __finally36;
+ __catch36_rygel_media_export_database_error:
+ {
+ GError* _error_ = NULL;
+ const gchar* _tmp59_ = NULL;
+ GError* _tmp60_;
+ const gchar* _tmp61_;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _tmp59_ = _ ("Failed to remove entry: %s");
+ _tmp60_ = _error_;
+ _tmp61_ = _tmp60_->message;
+ g_warning (_tmp59_, _tmp61_);
+ _g_error_free0 (_error_);
+ }
+ __finally36:
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_free0 (id);
+ _g_object_unref0 (_id_list);
+ _g_object_unref0 (ids);
+ _g_object_unref0 (db);
+ _g_object_unref0 (self);
+ return NULL;
+ }
+ _g_free0 (id);
+ }
+ _g_object_unref0 (_id_list);
+ }
+ rygel_media_container_updated ((RygelMediaContainer*) self, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
+ _g_object_unref0 (ids);
+ _g_object_unref0 (db);
+ return self;
+}
+
+
+RygelMediaExportRootContainer*
+rygel_media_export_root_container_new (GError** error) {
+ return rygel_media_export_root_container_construct (RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, error);
+}
+
+
+static void __lambda6_ (RygelMediaExportRootContainer* self) {
+ rygel_media_export_root_container_add_default_virtual_folders (self);
+ rygel_media_container_updated ((RygelMediaContainer*) self, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
+}
+
+
+static void ___lambda6__rygel_media_container_container_updated (RygelMediaContainer* _sender, RygelMediaContainer* container, RygelMediaObject* object, RygelObjectEventType event_type, gboolean sub_tree_update, gpointer self) {
+ __lambda6_ (self);
+}
+
+
+static void rygel_media_export_root_container_on_initial_harvesting_done (RygelMediaExportRootContainer* self) {
+ RygelMediaExportHarvester* _tmp0_;
+ gulong _tmp1_;
+ RygelMediaExportMediaCache* _tmp2_;
+ RygelMediaContainer* _tmp3_;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = self->priv->harvester;
+ _tmp1_ = self->priv->harvester_signal_id;
+ g_signal_handler_disconnect ((GObject*) _tmp0_, _tmp1_);
+ _tmp2_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ rygel_media_export_media_cache_debug_statistics (_tmp2_);
+ rygel_media_export_root_container_add_default_virtual_folders (self);
+ rygel_media_container_updated ((RygelMediaContainer*) self, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
+ _tmp3_ = self->priv->filesystem_container;
+ g_signal_connect_object (_tmp3_, "container-updated", (GCallback) ___lambda6__rygel_media_container_container_updated, self, 0);
+}
+
+
+static void rygel_media_export_root_container_add_default_virtual_folders (RygelMediaExportRootContainer* self) {
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ {
+ const gchar* _tmp0_ = NULL;
+ const gchar* _tmp1_ = NULL;
+ const gchar* _tmp2_ = NULL;
+ _tmp0_ = _ ("Music");
+ rygel_media_export_root_container_add_virtual_containers_for_class (self, _tmp0_, RYGEL_MUSIC_ITEM_UPNP_CLASS, VIRTUAL_FOLDERS_MUSIC, G_N_ELEMENTS (VIRTUAL_FOLDERS_MUSIC), &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch37_g_error;
+ }
+ _tmp1_ = _ ("Pictures");
+ rygel_media_export_root_container_add_virtual_containers_for_class (self, _tmp1_, RYGEL_PHOTO_ITEM_UPNP_CLASS, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch37_g_error;
+ }
+ _tmp2_ = _ ("Videos");
+ rygel_media_export_root_container_add_virtual_containers_for_class (self, _tmp2_, RYGEL_VIDEO_ITEM_UPNP_CLASS, NULL, 0, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ goto __catch37_g_error;
+ }
+ }
+ goto __finally37;
+ __catch37_g_error:
+ {
+ GError* _error_ = NULL;
+ _error_ = _inner_error_;
+ _inner_error_ = NULL;
+ _g_error_free0 (_error_);
+ }
+ __finally37:
+ if (_inner_error_ != 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;
+ }
+}
+
+
+static gchar* string_slice (const gchar* self, glong start, glong end) {
+ gchar* result = NULL;
+ gint _tmp0_;
+ gint _tmp1_;
+ glong string_length;
+ glong _tmp2_;
+ glong _tmp5_;
+ gboolean _tmp8_ = FALSE;
+ glong _tmp9_;
+ gboolean _tmp12_;
+ gboolean _tmp13_ = FALSE;
+ glong _tmp14_;
+ gboolean _tmp17_;
+ glong _tmp18_;
+ glong _tmp19_;
+ glong _tmp20_;
+ glong _tmp21_;
+ glong _tmp22_;
+ gchar* _tmp23_ = NULL;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = strlen (self);
+ _tmp1_ = _tmp0_;
+ string_length = (glong) _tmp1_;
+ _tmp2_ = start;
+ if (_tmp2_ < ((glong) 0)) {
+ glong _tmp3_;
+ glong _tmp4_;
+ _tmp3_ = string_length;
+ _tmp4_ = start;
+ start = _tmp3_ + _tmp4_;
+ }
+ _tmp5_ = end;
+ if (_tmp5_ < ((glong) 0)) {
+ glong _tmp6_;
+ glong _tmp7_;
+ _tmp6_ = string_length;
+ _tmp7_ = end;
+ end = _tmp6_ + _tmp7_;
+ }
+ _tmp9_ = start;
+ if (_tmp9_ >= ((glong) 0)) {
+ glong _tmp10_;
+ glong _tmp11_;
+ _tmp10_ = start;
+ _tmp11_ = string_length;
+ _tmp8_ = _tmp10_ <= _tmp11_;
+ } else {
+ _tmp8_ = FALSE;
+ }
+ _tmp12_ = _tmp8_;
+ g_return_val_if_fail (_tmp12_, NULL);
+ _tmp14_ = end;
+ if (_tmp14_ >= ((glong) 0)) {
+ glong _tmp15_;
+ glong _tmp16_;
+ _tmp15_ = end;
+ _tmp16_ = string_length;
+ _tmp13_ = _tmp15_ <= _tmp16_;
+ } else {
+ _tmp13_ = FALSE;
+ }
+ _tmp17_ = _tmp13_;
+ g_return_val_if_fail (_tmp17_, NULL);
+ _tmp18_ = start;
+ _tmp19_ = end;
+ g_return_val_if_fail (_tmp18_ <= _tmp19_, NULL);
+ _tmp20_ = start;
+ _tmp21_ = end;
+ _tmp22_ = start;
+ _tmp23_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) (_tmp21_ - _tmp22_));
+ result = _tmp23_;
+ return result;
+}
+
+
+static void rygel_media_export_root_container_add_folder_definition (RygelMediaExportRootContainer* self, RygelMediaContainer* container, const gchar* item_class, RygelMediaExportFolderDefinition* definition, GError** error) {
+ const gchar* _tmp0_;
+ RygelMediaExportFolderDefinition _tmp1_;
+ const gchar* _tmp2_;
+ gchar* _tmp3_ = NULL;
+ gchar* id;
+ const gchar* _tmp4_;
+ gboolean _tmp5_ = FALSE;
+ RygelMediaExportQueryContainerFactory* _tmp8_ = NULL;
+ RygelMediaExportQueryContainerFactory* factory;
+ RygelMediaExportQueryContainerFactory* _tmp9_;
+ RygelMediaExportMediaCache* _tmp10_;
+ const gchar* _tmp11_;
+ RygelMediaExportFolderDefinition _tmp12_;
+ const gchar* _tmp13_;
+ const gchar* _tmp14_ = NULL;
+ RygelMediaExportQueryContainer* _tmp15_ = NULL;
+ RygelMediaExportQueryContainer* query_container;
+ RygelMediaExportQueryContainer* _tmp16_;
+ gint _tmp17_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (container != NULL);
+ g_return_if_fail (item_class != NULL);
+ g_return_if_fail (definition != NULL);
+ _tmp0_ = item_class;
+ _tmp1_ = *definition;
+ _tmp2_ = _tmp1_.definition;
+ _tmp3_ = g_strdup_printf ("%supnp:class,%s,%s", RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_PREFIX, _tmp0_, _tmp2_);
+ id = _tmp3_;
+ _tmp4_ = id;
+ _tmp5_ = g_str_has_suffix (_tmp4_, ",");
+ if (_tmp5_) {
+ const gchar* _tmp6_;
+ gchar* _tmp7_ = NULL;
+ _tmp6_ = id;
+ _tmp7_ = string_slice (_tmp6_, (glong) 0, (glong) (-1));
+ _g_free0 (id);
+ id = _tmp7_;
+ }
+ _tmp8_ = rygel_media_export_query_container_factory_get_default ();
+ factory = _tmp8_;
+ _tmp9_ = factory;
+ _tmp10_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp11_ = id;
+ _tmp12_ = *definition;
+ _tmp13_ = _tmp12_.title;
+ _tmp14_ = _ (_tmp13_);
+ _tmp15_ = rygel_media_export_query_container_factory_create_from_description (_tmp9_, _tmp10_, _tmp11_, _tmp14_);
+ query_container = _tmp15_;
+ _tmp16_ = query_container;
+ _tmp17_ = ((RygelMediaContainer*) _tmp16_)->child_count;
+ if (_tmp17_ > 0) {
+ RygelMediaExportQueryContainer* _tmp18_;
+ RygelMediaContainer* _tmp19_;
+ RygelMediaExportMediaCache* _tmp20_;
+ RygelMediaExportQueryContainer* _tmp21_;
+ _tmp18_ = query_container;
+ _tmp19_ = container;
+ ((RygelMediaObject*) _tmp18_)->parent = _tmp19_;
+ _tmp20_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp21_ = query_container;
+ rygel_media_export_media_cache_save_container (_tmp20_, (RygelMediaContainer*) _tmp21_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (query_container);
+ _g_object_unref0 (factory);
+ _g_free0 (id);
+ return;
+ }
+ } else {
+ RygelMediaExportMediaCache* _tmp22_;
+ const gchar* _tmp23_;
+ _tmp22_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp23_ = id;
+ rygel_media_export_media_cache_remove_by_id (_tmp22_, _tmp23_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (query_container);
+ _g_object_unref0 (factory);
+ _g_free0 (id);
+ return;
+ }
+ }
+ _g_object_unref0 (query_container);
+ _g_object_unref0 (factory);
+ _g_free0 (id);
+}
+
+
+static void rygel_media_export_root_container_add_virtual_containers_for_class (RygelMediaExportRootContainer* self, const gchar* parent, const gchar* item_class, RygelMediaExportFolderDefinition* definitions, int definitions_length1, GError** error) {
+ RygelNullContainer* _tmp0_;
+ RygelNullContainer* container;
+ RygelNullContainer* _tmp1_;
+ RygelNullContainer* _tmp2_;
+ const gchar* _tmp3_;
+ RygelNullContainer* _tmp4_;
+ const gchar* _tmp5_;
+ gchar* _tmp6_;
+ gchar* _tmp7_;
+ RygelMediaExportMediaCache* _tmp8_;
+ RygelNullContainer* _tmp9_;
+ RygelMediaExportFolderDefinition* _tmp13_;
+ gint _tmp13__length1;
+ RygelMediaExportMediaCache* _tmp19_;
+ RygelNullContainer* _tmp20_;
+ const gchar* _tmp21_;
+ const gchar* _tmp22_;
+ gint _tmp23_ = 0;
+ gint _tmp24_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ g_return_if_fail (parent != NULL);
+ g_return_if_fail (item_class != NULL);
+ _tmp0_ = rygel_null_container_new ();
+ container = _tmp0_;
+ _tmp1_ = container;
+ ((RygelMediaObject*) _tmp1_)->parent = (RygelMediaContainer*) self;
+ _tmp2_ = container;
+ _tmp3_ = parent;
+ rygel_media_object_set_title ((RygelMediaObject*) _tmp2_, _tmp3_);
+ _tmp4_ = container;
+ _tmp5_ = item_class;
+ _tmp6_ = g_strconcat ("virtual-parent:", _tmp5_, NULL);
+ _tmp7_ = _tmp6_;
+ rygel_media_object_set_id ((RygelMediaObject*) _tmp4_, _tmp7_);
+ _g_free0 (_tmp7_);
+ _tmp8_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp9_ = container;
+ rygel_media_export_media_cache_save_container (_tmp8_, (RygelMediaContainer*) _tmp9_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (container);
+ return;
+ }
+ {
+ RygelMediaExportFolderDefinition* definition_collection = NULL;
+ gint definition_collection_length1 = 0;
+ gint _definition_collection_size_ = 0;
+ gint definition_it = 0;
+ definition_collection = VIRTUAL_FOLDERS_DEFAULT;
+ definition_collection_length1 = G_N_ELEMENTS (VIRTUAL_FOLDERS_DEFAULT);
+ for (definition_it = 0; definition_it < G_N_ELEMENTS (VIRTUAL_FOLDERS_DEFAULT); definition_it = definition_it + 1) {
+ RygelMediaExportFolderDefinition definition = {0};
+ definition = definition_collection[definition_it];
+ {
+ RygelNullContainer* _tmp10_;
+ const gchar* _tmp11_;
+ RygelMediaExportFolderDefinition _tmp12_;
+ _tmp10_ = container;
+ _tmp11_ = item_class;
+ _tmp12_ = definition;
+ rygel_media_export_root_container_add_folder_definition (self, (RygelMediaContainer*) _tmp10_, _tmp11_, &_tmp12_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (container);
+ return;
+ }
+ }
+ }
+ }
+ _tmp13_ = definitions;
+ _tmp13__length1 = definitions_length1;
+ if (_tmp13_ != NULL) {
+ RygelMediaExportFolderDefinition* _tmp14_;
+ gint _tmp14__length1;
+ _tmp14_ = definitions;
+ _tmp14__length1 = definitions_length1;
+ {
+ RygelMediaExportFolderDefinition* definition_collection = NULL;
+ gint definition_collection_length1 = 0;
+ gint _definition_collection_size_ = 0;
+ gint definition_it = 0;
+ definition_collection = _tmp14_;
+ definition_collection_length1 = _tmp14__length1;
+ for (definition_it = 0; definition_it < _tmp14__length1; definition_it = definition_it + 1) {
+ RygelMediaExportFolderDefinition _tmp15_ = {0};
+ RygelMediaExportFolderDefinition definition = {0};
+ rygel_media_export_folder_definition_copy (&definition_collection[definition_it], &_tmp15_);
+ definition = _tmp15_;
+ {
+ RygelNullContainer* _tmp16_;
+ const gchar* _tmp17_;
+ RygelMediaExportFolderDefinition _tmp18_;
+ _tmp16_ = container;
+ _tmp17_ = item_class;
+ _tmp18_ = definition;
+ rygel_media_export_root_container_add_folder_definition (self, (RygelMediaContainer*) _tmp16_, _tmp17_, &_tmp18_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ rygel_media_export_folder_definition_destroy (&definition);
+ _g_object_unref0 (container);
+ return;
+ }
+ rygel_media_export_folder_definition_destroy (&definition);
+ }
+ }
+ }
+ }
+ _tmp19_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp20_ = container;
+ _tmp21_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp20_);
+ _tmp22_ = _tmp21_;
+ _tmp23_ = rygel_media_export_media_cache_get_child_count (_tmp19_, _tmp22_, &_inner_error_);
+ _tmp24_ = _tmp23_;
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (container);
+ return;
+ }
+ if (_tmp24_ == 0) {
+ RygelMediaExportMediaCache* _tmp25_;
+ RygelNullContainer* _tmp26_;
+ const gchar* _tmp27_;
+ const gchar* _tmp28_;
+ _tmp25_ = ((RygelMediaExportDBContainer*) self)->media_db;
+ _tmp26_ = container;
+ _tmp27_ = rygel_media_object_get_id ((RygelMediaObject*) _tmp26_);
+ _tmp28_ = _tmp27_;
+ rygel_media_export_media_cache_remove_by_id (_tmp25_, _tmp28_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (container);
+ return;
+ }
+ } else {
+ RygelNullContainer* _tmp29_;
+ _tmp29_ = container;
+ rygel_media_container_updated ((RygelMediaContainer*) _tmp29_, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
+ }
+ _g_object_unref0 (container);
+}
+
+
+static void rygel_media_export_root_container_class_init (RygelMediaExportRootContainerClass * klass) {
+ rygel_media_export_root_container_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportRootContainerPrivate));
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->find_object = rygel_media_export_root_container_real_find_object;
+ RYGEL_MEDIA_CONTAINER_CLASS (klass)->find_object_finish = rygel_media_export_root_container_real_find_object_finish;
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (klass)->search = rygel_media_export_root_container_real_search;
+ RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS (klass)->search_finish = rygel_media_export_root_container_real_search_finish;
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_root_container_finalize;
+}
+
+
+static void rygel_media_export_root_container_init (RygelMediaExportRootContainer * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_root_container_finalize (GObject* obj) {
+ RygelMediaExportRootContainer * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, RygelMediaExportRootContainer);
+ _g_object_unref0 (self->priv->service);
+ _g_object_unref0 (self->priv->harvester);
+ _g_object_unref0 (self->priv->cancellable);
+ _g_object_unref0 (self->priv->filesystem_container);
+ G_OBJECT_CLASS (rygel_media_export_root_container_parent_class)->finalize (obj);
+}
+
+
+
+
diff --git a/src/media-export/rygel-media-export-root-container.h b/src/media-export/rygel-media-export-root-container.h
new file mode 100644
index 0000000..7a97190
--- /dev/null
+++ b/src/media-export/rygel-media-export-root-container.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_ROOT_CONTAINER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_ROOT_CONTAINER_H__
+
+#include "rygel-media-export-db-container.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER (rygel_media_export_root_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, RygelMediaExportRootContainer))
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, RygelMediaExportRootContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_ROOT_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_ROOT_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_ROOT_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_ROOT_CONTAINER, RygelMediaExportRootContainerClass))
+
+typedef struct _RygelMediaExportRootContainer RygelMediaExportRootContainer;
+typedef struct _RygelMediaExportRootContainerClass RygelMediaExportRootContainerClass;
+typedef struct _RygelMediaExportRootContainerPrivate RygelMediaExportRootContainerPrivate;
+
+struct _RygelMediaExportRootContainer {
+ RygelMediaExportDBContainer parent_instance;
+ RygelMediaExportRootContainerPrivate *priv;
+};
+
+struct _RygelMediaExportRootContainerClass {
+ RygelMediaExportDBContainerClass parent_class;
+};
+
+GType rygel_media_export_root_container_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportRootContainer* rygel_media_export_root_container_new (GError** error);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_ROOT_CONTAINER_H__ */
diff --git a/src/media-export/rygel-media-export-sql-factory.c b/src/media-export/rygel-media-export-sql-factory.c
new file mode 100644
index 0000000..998c837
--- /dev/null
+++ b/src/media-export/rygel-media-export-sql-factory.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright (C) 2010,2011 Jens Georg <mail jensge org>.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-sql-factory.h"
+
+
+G_DEFINE_TYPE (RygelMediaExportSQLFactory, rygel_media_export_sql_factory, G_TYPE_OBJECT)
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DETAIL_COLUMN (rygel_media_export_detail_column_get_type ())
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_STRING (rygel_media_export_sql_string_get_type ())
+
+
+typedef enum {
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TYPE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TITLE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SIZE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_MIME_TYPE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_WIDTH,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_HEIGHT,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CLASS,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ALBUM,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DATE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITRATE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SAMPLE_FREQ,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITS_PER_SAMPLE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CHANNELS,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TRACK,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_COLOR_DEPTH,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DURATION,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_PARENT,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TIMESTAMP,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_URI,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DLNA_PROFILE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_GENRE,
+ RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DISC
+} RygelMediaExportDetailColumn;
+
+typedef enum {
+ RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE,
+ RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS
+} RygelMediaExportSQLString;
+
+
+
+GType rygel_media_export_detail_column_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_sql_string_get_type (void) G_GNUC_CONST;
+
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_SAVE_META_DATA_STRING "INSERT OR REPLACE INTO meta_data " "(size, mime_type, width, height, class, " "author, album, date, bitrate, " "sample_freq, bits_per_sample, channels, " "track, color_depth, duration, object_fk, dlna_profile, genre, disc) VA" \
+"LUES " "(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_INSERT_OBJECT_STRING "INSERT OR REPLACE INTO Object (upnp_id, title, type_fk, parent, timest" \
+"amp, uri) " "VALUES (?,?,?,?,?,?)"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_DELETE_BY_ID_STRING "DELETE FROM Object WHERE upnp_id IN " "(SELECT descendant FROM closure WHERE ancestor = ?)"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_ALL_DETAILS_STRING "o.type_fk, o.title, m.size, m.mime_type, m.width, " "m.height, m.class, m.author, m.album, m.date, m.bitrate, " "m.sample_freq, m.bits_per_sample, m.channels, m.track, " "m.color_depth, m.duration, o.upnp_id, o.parent, o.timestamp, " "o.uri, m.dlna_profile, m.genre, m.disc "
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECT_WITH_PATH "SELECT DISTINCT " RYGEL_MEDIA_EXPORT_SQL_FACTORY_ALL_DETAILS_STRING "FROM Object o " "JOIN Closure c ON (o.upnp_id = c.ancestor) " "LEFT OUTER JOIN meta_data m ON (o.upnp_id = m.object_fk) " "WHERE c.descendant = ? ORDER BY c.depth DESC"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_CHILDREN_STRING "SELECT " RYGEL_MEDIA_EXPORT_SQL_FACTORY_ALL_DETAILS_STRING "FROM Object o " "JOIN Closure c ON (o.upnp_id = c.descendant) " "LEFT OUTER JOIN meta_data m " "ON c.descendant = m.object_fk " "WHERE c.ancestor = ? AND c.depth = 1 %s" "LIMIT ?,?"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECTS_BY_FILTER_STRING_WITH_ANCESTOR "SELECT DISTINCT " RYGEL_MEDIA_EXPORT_SQL_FACTORY_ALL_DETAILS_STRING "FROM Object o " "JOIN Closure c ON o.upnp_id = c.descendant AND c.ancestor = ? " "LEFT OUTER JOIN meta_data m " "ON o.upnp_id = m.object_fk %s %s " "LIMIT ?,?"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECTS_BY_FILTER_STRING "SELECT DISTINCT " RYGEL_MEDIA_EXPORT_SQL_FACTORY_ALL_DETAILS_STRING "FROM Object o " "LEFT OUTER JOIN meta_data m " "ON o.upnp_id = m.object_fk %s %s " "LIMIT ?,?"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECT_COUNT_BY_FILTER_STRING_WITH_ANCESTOR "SELECT COUNT(o.type_fk) FROM Object o " "JOIN Closure c ON o.upnp_id = c.descendant AND c.ancestor = ? " "LEFT OUTER JOIN meta_data m " "ON o.upnp_id = m.object_fk %s"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECT_COUNT_BY_FILTER_STRING "SELECT COUNT(1) FROM meta_data m %s"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CHILDREN_COUNT_STRING "SELECT COUNT(upnp_id) FROM Object WHERE Object.parent = ?"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_OBJECT_EXISTS_STRING "SELECT COUNT(1), timestamp, m.size FROM Object " "JOIN meta_data m ON m.object_fk = upnp_id " "WHERE Object.uri = ?"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_CHILD_ID_STRING "SELECT upnp_id FROM OBJECT WHERE parent = ?"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_META_DATA_COLUMN_STRING "SELECT DISTINCT %s AS _column FROM meta_data AS m " "WHERE _column IS NOT NULL %s ORDER BY _column COLLATE CASEFOLD " "LIMIT ?,?"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION "11"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_META_DATA_TABLE_STRING "CREATE TABLE meta_data (size INTEGER NOT NULL, " "mime_type TEXT NOT NULL, " "dlna_profile TEXT, " "duration INTEGER, " "width INTEGER, " "height INTEGER, " "class TEXT NOT NULL, " "author TEXT, " "album TEXT, " "genre TEXT, " "date TEXT, " "bitrate INTEGER, " "sample_freq INTEGER, " "bits_per_sample INTEGER, " "channels INTEGER, " "track INTEGER, " "disc INTEGER, " "color_depth INTEGER, " "object_fk TEXT UNIQUE CONSTRAINT " "object_fk_id REFERENCES Object(upnp_id) " "ON DELETE CASCADE);"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_STRING "CREATE TABLE schema_info (version TEXT NOT NULL); " RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_META_DATA_TABLE_STRING "CREATE TABLE object (parent TEXT CONSTRAINT parent_fk_id " "REFERENCES Object(upnp_id), " "upnp_id TEXT PRIMARY KEY, " "type_fk INTEGER, " "title TEXT NOT NULL, " "timestamp INTEGER NOT NULL, " "uri TEXT, " "flags TEXT);" "INSERT INTO schema_info (version) VALUES ('" RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_VERSION "'); "
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_CLOSURE_TABLE "CREATE TABLE closure (ancestor TEXT, descendant TEXT, depth INTEGER)"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_CLOSURE_TRIGGER_STRING "CREATE TRIGGER trgr_update_closure " "AFTER INSERT ON Object " "FOR EACH ROW BEGIN " "SELECT RAISE(IGNORE) WHERE (SELECT COUNT(*) FROM Closure " "WHERE ancestor = NEW.upnp_id " "AND descendant = NEW.upnp_id " "AND depth = 0) != 0;" "INSERT INTO Closure (ancestor, descendant, depth) " "VALUES (NEW.upnp_id, NEW.upnp_id, 0); " "INSERT INTO Closure (ancestor, descendant, depth) " "SELECT ancestor, NEW.upnp_id, depth + 1 FROM Closure " "WHERE descendant = NEW.parent;" "END;" "CREATE TRIGGER trgr_delete_closure " "AFTER DELETE ON Object " "FOR EACH ROW BEGIN " "DELETE FROM Closure WHERE descendant = OLD.upnp_id;" "END;"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_TRIGGER_STRING "CREATE TRIGGER trgr_delete_metadata " "BEFORE DELETE ON Object " "FOR EACH ROW BEGIN " "DELETE FROM meta_data WHERE meta_data.object_fk = OLD.upnp_id; " "END;"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_INDICES_STRING "CREATE INDEX IF NOT EXISTS idx_parent on Object(parent);" "CREATE INDEX IF NOT EXISTS idx_object_upnp_id on Object(upnp_id);" "CREATE INDEX IF NOT EXISTS idx_meta_data_fk on meta_data(object_fk);" "CREATE INDEX IF NOT EXISTS idx_closure on Closure(descendant,depth);" "CREATE INDEX IF NOT EXISTS idx_closure_descendant on Closure(descendan" \
+"t);" "CREATE INDEX IF NOT EXISTS idx_closure_ancestor on Closure(ancestor);" "CREATE INDEX IF NOT EXISTS idx_uri on Object(uri);" "CREATE INDEX IF NOT EXISTS idx_meta_data_date on meta_data(date);" "CREATE INDEX IF NOT EXISTS idx_meta_data_genre on meta_data(genre);" "CREATE INDEX IF NOT EXISTS idx_meta_data_album on meta_data(album);" "CREATE INDEX IF NOT EXISTS idx_meta_data_artist_album on " "meta_data(author, album);"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_EXISTS_CACHE_STRING "SELECT m.size, o.timestamp, o.uri FROM Object o " "JOIN meta_data m ON o.upnp_id = m.object_fk"
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_STATISTICS_STRING "SELECT class, count(1) FROM meta_data GROUP BY class"
+const gchar* rygel_media_export_sql_factory_make (RygelMediaExportSQLFactory* self, RygelMediaExportSQLString query);
+
+RygelMediaExportSQLFactory* rygel_media_export_sql_factory_construct (GType object_type);
+
+
+GType rygel_media_export_detail_column_get_type (void) {
+ static volatile gsize rygel_media_export_detail_column_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_detail_column_type_id__volatile)) {
+ static const GEnumValue values[] = {{RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TYPE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TYPE", "type"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TITLE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TITLE", "title"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SIZE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SIZE", "size"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_MIME_TYPE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_MIME_TYPE", "mime-type"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_WIDTH, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_WIDTH", "width"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_HEIGHT, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_HEIGHT", "height"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CLASS, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CLASS", "class"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR", "author"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ALBUM, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ALBUM", "album"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DATE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DATE", "date"}, {RYGEL_MEDIA
_EXPORT_DETAIL_COLUMN_BITRATE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITRATE", "bitrate"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SAMPLE_FREQ, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SAMPLE_FREQ", "sample-freq"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITS_PER_SAMPLE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITS_PER_SAMPLE", "bits-per-sample"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CHANNELS, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CHANNELS", "channels"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TRACK, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TRACK", "track"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_COLOR_DEPTH, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_COLOR_DEPTH", "color-depth"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DURATION, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DURATION", "duration"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID", "id"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_PARENT, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_PARENT", "parent"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TIMESTAMP, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_T
IMESTAMP", "timestamp"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_URI, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_URI", "uri"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DLNA_PROFILE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DLNA_PROFILE", "dlna-profile"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_GENRE, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_GENRE", "genre"}, {RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DISC, "RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DISC", "disc"}, {0, NULL, NULL}};
+ GType rygel_media_export_detail_column_type_id;
+ rygel_media_export_detail_column_type_id = g_enum_register_static ("RygelMediaExportDetailColumn", values);
+ g_once_init_leave (&rygel_media_export_detail_column_type_id__volatile, rygel_media_export_detail_column_type_id);
+ }
+ return rygel_media_export_detail_column_type_id__volatile;
+}
+
+
+GType rygel_media_export_sql_string_get_type (void) {
+ static volatile gsize rygel_media_export_sql_string_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_sql_string_type_id__volatile)) {
+ static const GEnumValue values[] = {{RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA, "RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA", "save-metadata"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT, "RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT", "insert"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE, "RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE", "delete"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT, "RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT", "get-object"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN, "RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN", "get-children"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER, "RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER", "get-objects-by-filter"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR, "RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR", "get-objects-by-filter-with-ancestor"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER, "RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER", "get-object-count-b
y-filter"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR, "RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR", "get-object-count-by-filter-with-ancestor"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN, "RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN", "get-meta-data-column"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT, "RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT", "child-count"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS, "RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS", "exists"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS, "RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS", "child-ids"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA, "RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA", "table-metadata"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE, "RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE", "table-closure"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE, "RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE", "trigger-closure"}, {RYGEL_MEDIA_EXPO
RT_SQL_STRING_TRIGGER_COMMON, "RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON", "trigger-common"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON, "RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON", "index-common"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA, "RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA", "schema"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE, "RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE", "exists-cache"}, {RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS, "RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS", "statistics"}, {0, NULL, NULL}};
+ GType rygel_media_export_sql_string_type_id;
+ rygel_media_export_sql_string_type_id = g_enum_register_static ("RygelMediaExportSQLString", values);
+ g_once_init_leave (&rygel_media_export_sql_string_type_id__volatile, rygel_media_export_sql_string_type_id);
+ }
+ return rygel_media_export_sql_string_type_id__volatile;
+}
+
+
+const gchar* rygel_media_export_sql_factory_make (RygelMediaExportSQLFactory* self, RygelMediaExportSQLString query) {
+ const gchar* result = NULL;
+ RygelMediaExportSQLString _tmp0_;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = query;
+ switch (_tmp0_) {
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_SAVE_META_DATA_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_INSERT_OBJECT_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_DELETE_BY_ID_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECT_WITH_PATH;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_CHILDREN_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECTS_BY_FILTER_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECTS_BY_FILTER_STRING_WITH_ANCESTOR;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECT_COUNT_BY_FILTER_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_OBJECT_COUNT_BY_FILTER_STRING_WITH_ANCESTOR;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_META_DATA_COLUMN_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_CHILDREN_COUNT_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_OBJECT_EXISTS_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_CHILD_ID_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_META_DATA_TABLE_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_TRIGGER_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_CLOSURE_TRIGGER_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_INDICES_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_SCHEMA_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_EXISTS_CACHE_STRING;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_CREATE_CLOSURE_TABLE;
+ return result;
+ }
+ case RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS:
+ {
+ result = RYGEL_MEDIA_EXPORT_SQL_FACTORY_STATISTICS_STRING;
+ return result;
+ }
+ default:
+ {
+ g_assert_not_reached ();
+ }
+ }
+}
+
+
+RygelMediaExportSQLFactory* rygel_media_export_sql_factory_construct (GType object_type) {
+ RygelMediaExportSQLFactory * self = NULL;
+ self = (RygelMediaExportSQLFactory*) g_object_new (object_type, NULL);
+ return self;
+}
+
+
+RygelMediaExportSQLFactory* rygel_media_export_sql_factory_new (void) {
+ return rygel_media_export_sql_factory_construct (RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY);
+}
+
+
+static void rygel_media_export_sql_factory_class_init (RygelMediaExportSQLFactoryClass * klass) {
+ rygel_media_export_sql_factory_parent_class = g_type_class_peek_parent (klass);
+}
+
+
+static void rygel_media_export_sql_factory_init (RygelMediaExportSQLFactory * self) {
+}
+
+
+
+
+
diff --git a/src/media-export/rygel-media-export-sql-factory.h b/src/media-export/rygel-media-export-sql-factory.h
new file mode 100644
index 0000000..9e3551a
--- /dev/null
+++ b/src/media-export/rygel-media-export-sql-factory.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010,2011 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_FACTORY_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_FACTORY_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY (rygel_media_export_sql_factory_get_type ())
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactory))
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactoryClass))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY))
+#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactoryClass))
+
+typedef struct _RygelMediaExportSQLFactory RygelMediaExportSQLFactory;
+typedef struct _RygelMediaExportSQLFactoryClass RygelMediaExportSQLFactoryClass;
+typedef struct _RygelMediaExportSQLFactoryPrivate RygelMediaExportSQLFactoryPrivate;
+
+struct _RygelMediaExportSQLFactory {
+ GObject parent_instance;
+ RygelMediaExportSQLFactoryPrivate *priv;
+};
+
+struct _RygelMediaExportSQLFactoryClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_sql_factory_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportSQLFactory* rygel_media_export_sql_factory_new ();
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_FACTORY_H__ */
diff --git a/src/media-export/rygel-media-export-sql-function.c b/src/media-export/rygel-media-export-sql-function.c
new file mode 100644
index 0000000..6508a8f
--- /dev/null
+++ b/src/media-export/rygel-media-export-sql-function.c
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#include "rygel-media-export-sql-function.h"
+
+G_DEFINE_TYPE (RygelMediaExportSqlFunction, rygel_media_export_sql_function, RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR)
+
+RygelMediaExportSqlFunction* rygel_media_export_sql_function_construct (GType object_type, const gchar* name, const gchar* arg);
+RygelMediaExportSqlOperator* rygel_media_export_sql_operator_new (const gchar* name, const gchar* arg, const gchar* collate);
+RygelMediaExportSqlOperator* rygel_media_export_sql_operator_construct (GType object_type, const gchar* name, const gchar* arg, const gchar* collate);
+static gchar* rygel_media_export_sql_function_real_to_string (RygelMediaExportSqlOperator* base);
+
+
+RygelMediaExportSqlFunction* rygel_media_export_sql_function_construct (GType object_type, const gchar* name, const gchar* arg) {
+ RygelMediaExportSqlFunction * self = NULL;
+ const gchar* _tmp0_;
+ const gchar* _tmp1_;
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (arg != NULL, NULL);
+ _tmp0_ = name;
+ _tmp1_ = arg;
+ self = (RygelMediaExportSqlFunction*) rygel_media_export_sql_operator_construct (object_type, _tmp0_, _tmp1_, "");
+ return self;
+}
+
+
+RygelMediaExportSqlFunction* rygel_media_export_sql_function_new (const gchar* name, const gchar* arg) {
+ return rygel_media_export_sql_function_construct (RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, name, arg);
+}
+
+
+static gchar* rygel_media_export_sql_function_real_to_string (RygelMediaExportSqlOperator* base) {
+ RygelMediaExportSqlFunction * self;
+ gchar* result = NULL;
+ const gchar* _tmp0_;
+ const gchar* _tmp1_;
+ gchar* _tmp2_ = NULL;
+ self = (RygelMediaExportSqlFunction*) base;
+ _tmp0_ = ((RygelMediaExportSqlOperator*) self)->name;
+ _tmp1_ = ((RygelMediaExportSqlOperator*) self)->arg;
+ _tmp2_ = g_strdup_printf ("%s(%s,?)", _tmp0_, _tmp1_);
+ result = _tmp2_;
+ return result;
+}
+
+
+static void rygel_media_export_sql_function_class_init (RygelMediaExportSqlFunctionClass * klass) {
+ rygel_media_export_sql_function_parent_class = g_type_class_peek_parent (klass);
+ RYGEL_MEDIA_EXPORT_SQL_OPERATOR_CLASS (klass)->to_string = rygel_media_export_sql_function_real_to_string;
+}
+
+
+static void rygel_media_export_sql_function_init (RygelMediaExportSqlFunction * self) {
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-sql-function.h b/src/media-export/rygel-media-export-sql-function.h
new file mode 100644
index 0000000..dc92142
--- /dev/null
+++ b/src/media-export/rygel-media-export-sql-function.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_FUNCTION_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_FUNCTION_H__
+
+#include "rygel-media-export-sql-operator.h"
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION (rygel_media_export_sql_function_get_type ())
+#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunction))
+#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunctionClass))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION))
+#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunctionClass))
+
+typedef struct _RygelMediaExportSqlFunction RygelMediaExportSqlFunction;
+typedef struct _RygelMediaExportSqlFunctionClass RygelMediaExportSqlFunctionClass;
+typedef struct _RygelMediaExportSqlFunctionPrivate RygelMediaExportSqlFunctionPrivate;
+
+struct _RygelMediaExportSqlFunction {
+ RygelMediaExportSqlOperator parent_instance;
+ RygelMediaExportSqlFunctionPrivate * priv;
+};
+
+struct _RygelMediaExportSqlFunctionClass {
+ RygelMediaExportSqlOperatorClass parent_class;
+};
+
+GType rygel_media_export_sql_function_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportSqlFunction* rygel_media_export_sql_function_new (const gchar* name, const gchar* arg);
+
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_FUNCTION_H__ */
diff --git a/src/media-export/rygel-media-export-sql-operator.c b/src/media-export/rygel-media-export-sql-operator.c
new file mode 100644
index 0000000..bd7b157
--- /dev/null
+++ b/src/media-export/rygel-media-export-sql-operator.c
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-sql-operator.h"
+
+G_DEFINE_TYPE (RygelMediaExportSqlOperator, rygel_media_export_sql_operator, G_TYPE_OBJECT)
+
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+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_free0 (self->name);
+ self->name = _tmp1_;
+ _tmp2_ = arg;
+ _tmp3_ = g_strdup (_tmp2_);
+ _g_free0 (self->arg);
+ self->arg = _tmp3_;
+ _tmp4_ = collate;
+ _tmp5_ = g_strdup (_tmp4_);
+ _g_free0 (self->collate);
+ self->collate = _tmp5_;
+ return self;
+}
+
+
+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);
+}
+
+
+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_free0 (sql);
+ sql = _tmp1_;
+ break;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_NEQ:
+ {
+ gchar* _tmp2_;
+ _tmp2_ = g_strdup ("!=");
+ _g_free0 (sql);
+ sql = _tmp2_;
+ break;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_LESS:
+ {
+ gchar* _tmp3_;
+ _tmp3_ = g_strdup ("<");
+ _g_free0 (sql);
+ sql = _tmp3_;
+ break;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_LEQ:
+ {
+ gchar* _tmp4_;
+ _tmp4_ = g_strdup ("<=");
+ _g_free0 (sql);
+ sql = _tmp4_;
+ break;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_GREATER:
+ {
+ gchar* _tmp5_;
+ _tmp5_ = g_strdup (">");
+ _g_free0 (sql);
+ sql = _tmp5_;
+ break;
+ }
+ case GUPNP_SEARCH_CRITERIA_OP_GEQ:
+ {
+ gchar* _tmp6_;
+ _tmp6_ = g_strdup (">=");
+ _g_free0 (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_free0 (sql);
+ return self;
+}
+
+
+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);
+}
+
+
+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;
+}
+
+
+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);
+}
+
+
+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_init (RygelMediaExportSqlOperator * self) {
+}
+
+
+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_free0 (self->name);
+ _g_free0 (self->arg);
+ _g_free0 (self->collate);
+ G_OBJECT_CLASS (rygel_media_export_sql_operator_parent_class)->finalize (obj);
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-sql-operator.h b/src/media-export/rygel-media-export-sql-operator.h
new file mode 100644
index 0000000..6896e70
--- /dev/null
+++ b/src/media-export/rygel-media-export-sql-operator.h
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_OPERATOR_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_OPERATOR_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR (rygel_media_export_sql_operator_get_type ())
+#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperator))
+#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperatorClass))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_OPERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR))
+#define RYGEL_MEDIA_EXPORT_IS_SQL_OPERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR))
+#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperatorClass))
+
+typedef struct _RygelMediaExportSqlOperator RygelMediaExportSqlOperator;
+typedef struct _RygelMediaExportSqlOperatorClass RygelMediaExportSqlOperatorClass;
+typedef struct _RygelMediaExportSqlOperatorPrivate RygelMediaExportSqlOperatorPrivate;
+
+struct _RygelMediaExportSqlOperator {
+ GObject parent_instance;
+ RygelMediaExportSqlOperatorPrivate * priv;
+ gchar* name;
+ gchar* arg;
+ gchar* collate;
+};
+
+struct _RygelMediaExportSqlOperatorClass {
+ GObjectClass parent_class;
+ gchar* (*to_string) (RygelMediaExportSqlOperator* self);
+};
+
+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_from_search_criteria_op (GUPnPSearchCriteriaOp op, const gchar* arg, const gchar* collate);
+
+gchar* rygel_media_export_sql_operator_to_string (RygelMediaExportSqlOperator* self);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQL_OPERATOR_H__ */
diff --git a/src/media-export/rygel-media-export-sqlite-wrapper.c b/src/media-export/rygel-media-export-sqlite-wrapper.c
new file mode 100644
index 0000000..aafd865
--- /dev/null
+++ b/src/media-export/rygel-media-export-sqlite-wrapper.c
@@ -0,0 +1,235 @@
+/*
+ * Copyright (C) 2011 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+
+#include "rygel-media-export-sqlite-wrapper.h"
+#include "rygel-media-export-database.h"
+#include <sqlite3.h>
+
+
+
+G_DEFINE_TYPE (RygelMediaExportSqliteWrapper, rygel_media_export_sqlite_wrapper, G_TYPE_OBJECT)
+
+
+#define _sqlite3_close0(var) ((var == NULL) ? NULL : (var = (sqlite3_close (var), NULL)))
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+
+struct _RygelMediaExportSqliteWrapperPrivate {
+ sqlite3* database;
+ sqlite3* reference;
+};
+
+
+#define RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapperPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_DUMMY_PROPERTY,
+ RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_DB
+};
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_new_wrap (sqlite3* db);
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_construct_wrap (GType object_type, sqlite3* db);
+GQuark rygel_media_export_database_error_quark (void);
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_new (const gchar* path, GError** error);
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_construct (GType object_type, const gchar* path, GError** error);
+void rygel_media_export_sqlite_wrapper_throw_if_db_has_error (RygelMediaExportSqliteWrapper* self, GError** error);
+void rygel_media_export_sqlite_wrapper_throw_if_code_is_error (RygelMediaExportSqliteWrapper* self, gint sqlite_error, GError** error);
+sqlite3* rygel_media_export_sqlite_wrapper_get_db (RygelMediaExportSqliteWrapper* self);
+static void rygel_media_export_sqlite_wrapper_finalize (GObject* obj);
+static void _vala_rygel_media_export_sqlite_wrapper_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
+
+
+/**
+ * Wrap an existing SQLite Database object.
+ *
+ * The SqliteWrapper doesn't take ownership of the passed db
+ */
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_construct_wrap (GType object_type, sqlite3* db) {
+ RygelMediaExportSqliteWrapper * self = NULL;
+ sqlite3* _tmp0_;
+ g_return_val_if_fail (db != NULL, NULL);
+ self = (RygelMediaExportSqliteWrapper*) g_object_new (object_type, NULL);
+ _tmp0_ = db;
+ self->priv->reference = _tmp0_;
+ return self;
+}
+
+
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_new_wrap (sqlite3* db) {
+ return rygel_media_export_sqlite_wrapper_construct_wrap (RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, db);
+}
+
+
+/**
+ * Create or open a new SQLite database in path.
+ *
+ * @note: Path may also be ":memory:" for temporary databases
+ */
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_construct (GType object_type, const gchar* path, GError** error) {
+ RygelMediaExportSqliteWrapper * self = NULL;
+ const gchar* _tmp0_;
+ sqlite3* _tmp1_ = NULL;
+ sqlite3* _tmp2_;
+ GError * _inner_error_ = NULL;
+ g_return_val_if_fail (path != NULL, NULL);
+ self = (RygelMediaExportSqliteWrapper*) g_object_new (object_type, NULL);
+ _tmp0_ = path;
+ sqlite3_open (_tmp0_, &_tmp1_);
+ _sqlite3_close0 (self->priv->database);
+ self->priv->database = _tmp1_;
+ _tmp2_ = self->priv->database;
+ self->priv->reference = _tmp2_;
+ rygel_media_export_sqlite_wrapper_throw_if_db_has_error (self, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ _g_object_unref0 (self);
+ return NULL;
+ } else {
+ 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;
+ }
+ }
+ return self;
+}
+
+
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_new (const gchar* path, GError** error) {
+ return rygel_media_export_sqlite_wrapper_construct (RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, path, error);
+}
+
+
+/**
+ * Convert a SQLite return code to a DatabaseError
+ */
+void rygel_media_export_sqlite_wrapper_throw_if_code_is_error (RygelMediaExportSqliteWrapper* self, gint sqlite_error, GError** error) {
+ gint _tmp0_;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = sqlite_error;
+ switch (_tmp0_) {
+ case SQLITE_OK:
+ case SQLITE_DONE:
+ case SQLITE_ROW:
+ {
+ return;
+ }
+ default:
+ {
+ gint _tmp1_;
+ sqlite3* _tmp2_;
+ const gchar* _tmp3_ = NULL;
+ GError* _tmp4_;
+ _tmp1_ = sqlite_error;
+ _tmp2_ = self->priv->reference;
+ _tmp3_ = sqlite3_errmsg (_tmp2_);
+ _tmp4_ = g_error_new (RYGEL_MEDIA_EXPORT_DATABASE_ERROR, RYGEL_MEDIA_EXPORT_DATABASE_ERROR_SQLITE_ERROR, "SQLite error %d: %s", _tmp1_, _tmp3_);
+ _inner_error_ = _tmp4_;
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+ }
+}
+
+
+/**
+ * Check if the last operation on the database was an error
+ */
+void rygel_media_export_sqlite_wrapper_throw_if_db_has_error (RygelMediaExportSqliteWrapper* self, GError** error) {
+ sqlite3* _tmp0_;
+ gint _tmp1_ = 0;
+ GError * _inner_error_ = NULL;
+ g_return_if_fail (self != NULL);
+ _tmp0_ = self->priv->reference;
+ _tmp1_ = sqlite3_errcode (_tmp0_);
+ rygel_media_export_sqlite_wrapper_throw_if_code_is_error (self, _tmp1_, &_inner_error_);
+ if (_inner_error_ != NULL) {
+ if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
+ g_propagate_error (error, _inner_error_);
+ return;
+ } else {
+ 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;
+ }
+ }
+}
+
+
+sqlite3* rygel_media_export_sqlite_wrapper_get_db (RygelMediaExportSqliteWrapper* self) {
+ sqlite3* result;
+ sqlite3* _tmp0_;
+ g_return_val_if_fail (self != NULL, NULL);
+ _tmp0_ = self->priv->reference;
+ result = _tmp0_;
+ return result;
+}
+
+
+static void rygel_media_export_sqlite_wrapper_class_init (RygelMediaExportSqliteWrapperClass * klass) {
+ rygel_media_export_sqlite_wrapper_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportSqliteWrapperPrivate));
+ G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_sqlite_wrapper_get_property;
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_sqlite_wrapper_finalize;
+ /**
+ * Property to access the wrapped database
+ */
+ g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_DB, g_param_spec_pointer ("db", "db", "db", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
+}
+
+
+static void rygel_media_export_sqlite_wrapper_init (RygelMediaExportSqliteWrapper * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_GET_PRIVATE (self);
+ self->priv->database = NULL;
+ self->priv->reference = NULL;
+}
+
+
+static void rygel_media_export_sqlite_wrapper_finalize (GObject* obj) {
+ RygelMediaExportSqliteWrapper * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapper);
+ _sqlite3_close0 (self->priv->database);
+ G_OBJECT_CLASS (rygel_media_export_sqlite_wrapper_parent_class)->finalize (obj);
+}
+
+static void _vala_rygel_media_export_sqlite_wrapper_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
+ RygelMediaExportSqliteWrapper * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapper);
+ switch (property_id) {
+ case RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_DB:
+ g_value_set_pointer (value, rygel_media_export_sqlite_wrapper_get_db (self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-sqlite-wrapper.h b/src/media-export/rygel-media-export-sqlite-wrapper.h
new file mode 100644
index 0000000..fba6aa0
--- /dev/null
+++ b/src/media-export/rygel-media-export-sqlite-wrapper.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQLITE_WRAPPER_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQLITE_WRAPPER_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER (rygel_media_export_sqlite_wrapper_get_type ())
+#define RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapper))
+#define RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapperClass))
+#define RYGEL_MEDIA_EXPORT_IS_SQLITE_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER))
+#define RYGEL_MEDIA_EXPORT_IS_SQLITE_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER))
+#define RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapperClass))
+
+typedef struct _RygelMediaExportSqliteWrapper RygelMediaExportSqliteWrapper;
+typedef struct _RygelMediaExportSqliteWrapperClass RygelMediaExportSqliteWrapperClass;
+typedef struct _RygelMediaExportSqliteWrapperPrivate RygelMediaExportSqliteWrapperPrivate;
+
+struct _RygelMediaExportSqliteWrapper {
+ GObject parent_instance;
+ RygelMediaExportSqliteWrapperPrivate *priv;
+};
+
+struct _RygelMediaExportSqliteWrapperClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_sqlite_wrapper_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportSqliteWrapper* rygel_media_export_sqlite_wrapper_new (const gchar* path, GError** error);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_SQLITE_WRAPPER_H__ */
diff --git a/src/media-export/rygel-media-export-video-item.c b/src/media-export/rygel-media-export-video-item.c
new file mode 100644
index 0000000..ca2c246
--- /dev/null
+++ b/src/media-export/rygel-media-export-video-item.c
@@ -0,0 +1,187 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus com>
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "rygel-media-export-video-item.h"
+#include "rygel-media-export-media-cache.h"
+
+static void rygel_media_export_video_item_rygel_trackable_item_interface_init (RygelTrackableItemIface * iface);
+static void rygel_media_export_video_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface);
+
+G_DEFINE_TYPE_WITH_CODE (RygelMediaExportVideoItem, rygel_media_export_video_item, RYGEL_TYPE_VIDEO_ITEM,
+ G_IMPLEMENT_INTERFACE (RYGEL_TYPE_TRACKABLE_ITEM, rygel_media_export_video_item_rygel_trackable_item_interface_init)
+ G_IMPLEMENT_INTERFACE (RYGEL_TYPE_UPDATABLE_OBJECT, rygel_media_export_video_item_rygel_updatable_object_interface_init))
+
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+typedef struct _RygelMediaExportVideoItemCommitData RygelMediaExportVideoItemCommitData;
+
+struct _RygelMediaExportVideoItemCommitData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportVideoItem* self;
+ RygelMediaExportMediaCache* _tmp0_;
+ RygelMediaExportMediaCache* cache;
+ RygelMediaExportMediaCache* _tmp1_;
+ GError * _inner_error_;
+};
+
+static RygelUpdatableObjectIface* rygel_media_export_video_item_rygel_updatable_object_parent_iface = NULL;
+
+
+RygelMediaExportVideoItem* rygel_media_export_video_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+static void rygel_media_export_video_item_real_commit_data_free (gpointer _data);
+static void rygel_media_export_video_item_real_commit (RygelUpdatableObject* base, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_video_item_real_commit_co (RygelMediaExportVideoItemCommitData* _data_);
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
+void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
+
+
+RygelMediaExportVideoItem* rygel_media_export_video_item_construct (GType object_type, const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class) {
+ RygelMediaExportVideoItem * 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 = (RygelMediaExportVideoItem*) rygel_video_item_construct (object_type, _tmp0_, _tmp1_, _tmp2_, _tmp3_);
+ return self;
+}
+
+
+RygelMediaExportVideoItem* rygel_media_export_video_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class) {
+ return rygel_media_export_video_item_construct (RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, id, parent, title, upnp_class);
+}
+
+
+static void rygel_media_export_video_item_real_commit_data_free (gpointer _data) {
+ RygelMediaExportVideoItemCommitData* _data_;
+ _data_ = _data;
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportVideoItemCommitData, _data_);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void rygel_media_export_video_item_real_commit (RygelUpdatableObject* base, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportVideoItem * self;
+ RygelMediaExportVideoItemCommitData* _data_;
+ RygelMediaExportVideoItem* _tmp0_;
+ self = (RygelMediaExportVideoItem*) base;
+ _data_ = g_slice_new0 (RygelMediaExportVideoItemCommitData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_video_item_real_commit);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_video_item_real_commit_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ rygel_media_export_video_item_real_commit_co (_data_);
+}
+
+
+static void rygel_media_export_video_item_real_commit_finish (RygelUpdatableObject* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaExportVideoItemCommitData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static gboolean rygel_media_export_video_item_real_commit_co (RygelMediaExportVideoItemCommitData* _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_unref0 (_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_unref0 (_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_video_item_class_init (RygelMediaExportVideoItemClass * klass) {
+ rygel_media_export_video_item_parent_class = g_type_class_peek_parent (klass);
+}
+
+static void rygel_media_export_video_item_rygel_trackable_item_interface_init (RygelTrackableItemIface * iface) {
+}
+
+static void rygel_media_export_video_item_rygel_updatable_object_interface_init (RygelUpdatableObjectIface * iface) {
+ rygel_media_export_video_item_rygel_updatable_object_parent_iface = g_type_interface_peek_parent (iface);
+ iface->commit = (void (*)(RygelUpdatableObject*, GError**)) rygel_media_export_video_item_real_commit;
+ iface->commit_finish = rygel_media_export_video_item_real_commit_finish;
+}
+
+
+static void rygel_media_export_video_item_init (RygelMediaExportVideoItem * self) {
+}
+
+
+
diff --git a/src/media-export/rygel-media-export-video-item.h b/src/media-export/rygel-media-export-video-item.h
new file mode 100644
index 0000000..6d59153
--- /dev/null
+++ b/src/media-export/rygel-media-export-video-item.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2009,2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_VIDEO_ITEM_H__
+#define __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_VIDEO_ITEM_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <stdlib.h>
+#include <string.h>
+#include <rygel-core.h>
+#include <rygel-server.h>
+#include <gee.h>
+
+G_BEGIN_DECLS
+
+#define RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM (rygel_media_export_video_item_get_type ())
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItem))
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItemClass))
+#define RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM))
+#define RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM))
+#define RYGEL_MEDIA_EXPORT_VIDEO_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_VIDEO_ITEM, RygelMediaExportVideoItemClass))
+
+typedef struct _RygelMediaExportVideoItem RygelMediaExportVideoItem;
+typedef struct _RygelMediaExportVideoItemClass RygelMediaExportVideoItemClass;
+typedef struct _RygelMediaExportVideoItemPrivate RygelMediaExportVideoItemPrivate;
+
+struct _RygelMediaExportVideoItem {
+ RygelVideoItem parent_instance;
+ RygelMediaExportVideoItemPrivate *priv;
+};
+
+struct _RygelMediaExportVideoItemClass {
+ GObjectClass parent_class;
+};
+
+GType rygel_media_export_video_item_get_type (void) G_GNUC_CONST;
+
+RygelMediaExportVideoItem* rygel_media_export_video_item_new (const gchar* id, RygelMediaContainer* parent, const gchar* title, const gchar* upnp_class);
+
+G_END_DECLS
+
+#endif /* __RYGEL_0_10_PLUGINS_MEDIA_EXPORT_VIDEO_ITEM_H__ */
diff --git a/src/media-export/rygel-media-export-writable-db-container.c b/src/media-export/rygel-media-export-writable-db-container.c
new file mode 100644
index 0000000..33a871f
--- /dev/null
+++ b/src/media-export/rygel-media-export-writable-db-container.c
@@ -0,0 +1,509 @@
+/* rygel-media-export-writable-db-container.c generated by valac 0.18.1, the Vala compiler
+ * generated from rygel-media-export-writable-db-container.vala, do not modify */
+
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <rygel-server.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <gee.h>
+
+
+#define RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER (rygel_media_export_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
+
+typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
+typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
+typedef struct _RygelMediaExportDBContainerPrivate RygelMediaExportDBContainerPrivate;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE (rygel_media_export_media_cache_get_type ())
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
+#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
+
+typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
+typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;
+
+#define RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER (rygel_media_export_writable_db_container_get_type ())
+#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer))
+#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainerClass))
+#define RYGEL_MEDIA_EXPORT_IS_WRITABLE_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_IS_WRITABLE_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER))
+#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainerClass))
+
+typedef struct _RygelMediaExportWritableDbContainer RygelMediaExportWritableDbContainer;
+typedef struct _RygelMediaExportWritableDbContainerClass RygelMediaExportWritableDbContainerClass;
+typedef struct _RygelMediaExportWritableDbContainerPrivate RygelMediaExportWritableDbContainerPrivate;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+typedef struct _RygelMediaExportWritableDbContainerAddItemData RygelMediaExportWritableDbContainerAddItemData;
+typedef struct _RygelMediaExportWritableDbContainerRemoveItemData RygelMediaExportWritableDbContainerRemoveItemData;
+
+struct _RygelMediaExportDBContainer {
+ RygelMediaContainer parent_instance;
+ RygelMediaExportDBContainerPrivate * priv;
+ RygelMediaExportMediaCache* media_db;
+};
+
+struct _RygelMediaExportDBContainerClass {
+ RygelMediaContainerClass parent_class;
+ void (*search) (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+ RygelMediaObjects* (*search_finish) (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error);
+};
+
+struct _RygelMediaExportWritableDbContainer {
+ RygelMediaExportDBContainer parent_instance;
+ RygelMediaExportWritableDbContainerPrivate * priv;
+};
+
+struct _RygelMediaExportWritableDbContainerClass {
+ RygelMediaExportDBContainerClass parent_class;
+};
+
+struct _RygelMediaExportWritableDbContainerPrivate {
+ GeeArrayList* _create_classes;
+};
+
+struct _RygelMediaExportWritableDbContainerAddItemData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportWritableDbContainer* self;
+ RygelMediaItem* item;
+ GCancellable* cancellable;
+ RygelMediaItem* _tmp0_;
+ RygelMediaItem* _tmp1_;
+ GeeArrayList* _tmp2_;
+ gpointer _tmp3_;
+ gchar* _tmp4_;
+ GFile* _tmp5_;
+ GFile* _tmp6_;
+ GFile* file;
+ GFile* _tmp7_;
+ gboolean _tmp8_;
+ RygelMediaItem* _tmp9_;
+ gint64 _tmp10_;
+ RygelMediaItem* _tmp11_;
+ GFile* _tmp12_;
+ gchar* _tmp13_;
+ gchar* _tmp14_;
+ RygelMediaExportMediaCache* _tmp15_;
+ RygelMediaItem* _tmp16_;
+ GError * _inner_error_;
+};
+
+struct _RygelMediaExportWritableDbContainerRemoveItemData {
+ int _state_;
+ GObject* _source_object_;
+ GAsyncResult* _res_;
+ GSimpleAsyncResult* _async_result;
+ RygelMediaExportWritableDbContainer* self;
+ gchar* id;
+ GCancellable* cancellable;
+ RygelMediaExportMediaCache* _tmp0_;
+ const gchar* _tmp1_;
+ GError * _inner_error_;
+};
+
+
+static gpointer rygel_media_export_writable_db_container_parent_class = NULL;
+static RygelWritableContainerIface* rygel_media_export_writable_db_container_rygel_writable_container_parent_iface = NULL;
+
+GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
+GType rygel_media_export_writable_db_container_get_type (void) G_GNUC_CONST;
+#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainerPrivate))
+enum {
+ RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_DUMMY_PROPERTY,
+ RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES
+};
+RygelMediaExportWritableDbContainer* rygel_media_export_writable_db_container_new (RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title);
+RygelMediaExportWritableDbContainer* rygel_media_export_writable_db_container_construct (GType object_type, 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);
+RygelMediaExportDBContainer* rygel_media_export_db_container_construct (GType object_type, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title);
+static void rygel_media_export_writable_db_container_real_add_item_data_free (gpointer _data);
+static void rygel_media_export_writable_db_container_real_add_item (RygelWritableContainer* base, RygelMediaItem* item, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_writable_db_container_real_add_item_co (RygelMediaExportWritableDbContainerAddItemData* _data_);
+gchar* rygel_media_export_media_cache_get_id (GFile* file);
+void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
+static void rygel_media_export_writable_db_container_real_remove_item_data_free (gpointer _data);
+static void rygel_media_export_writable_db_container_real_remove_item (RygelWritableContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
+static gboolean rygel_media_export_writable_db_container_real_remove_item_co (RygelMediaExportWritableDbContainerRemoveItemData* _data_);
+GQuark rygel_media_export_database_error_quark (void);
+void rygel_media_export_media_cache_remove_by_id (RygelMediaExportMediaCache* self, const gchar* id, GError** error);
+static void rygel_media_export_writable_db_container_finalize (GObject* obj);
+static void _vala_rygel_media_export_writable_db_container_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
+static void _vala_rygel_media_export_writable_db_container_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
+
+
+RygelMediaExportWritableDbContainer* rygel_media_export_writable_db_container_construct (GType object_type, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title) {
+ RygelMediaExportWritableDbContainer * self = NULL;
+ RygelMediaExportMediaCache* _tmp0_;
+ const gchar* _tmp1_;
+ const gchar* _tmp2_;
+ GeeArrayList* _tmp3_;
+ GeeArrayList* _tmp4_;
+ GeeArrayList* _tmp5_;
+ GeeArrayList* _tmp6_;
+ GeeArrayList* _tmp7_;
+ GeeArrayList* _tmp8_;
+ GeeArrayList* _tmp9_;
+ GeeArrayList* _tmp10_;
+ GeeArrayList* _tmp11_;
+ GeeArrayList* _tmp12_;
+ GeeArrayList* _tmp13_;
+ GeeArrayList* _tmp14_;
+ g_return_val_if_fail (media_db != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
+ g_return_val_if_fail (title != NULL, NULL);
+ _tmp0_ = media_db;
+ _tmp1_ = id;
+ _tmp2_ = title;
+ self = (RygelMediaExportWritableDbContainer*) rygel_media_export_db_container_construct (object_type, _tmp0_, _tmp1_, _tmp2_);
+ _tmp3_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
+ _tmp4_ = _tmp3_;
+ rygel_writable_container_set_create_classes ((RygelWritableContainer*) self, _tmp4_);
+ _g_object_unref0 (_tmp4_);
+ _tmp5_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
+ _tmp6_ = _tmp5_;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp6_, RYGEL_IMAGE_ITEM_UPNP_CLASS);
+ _tmp7_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
+ _tmp8_ = _tmp7_;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, RYGEL_PHOTO_ITEM_UPNP_CLASS);
+ _tmp9_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
+ _tmp10_ = _tmp9_;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, RYGEL_VIDEO_ITEM_UPNP_CLASS);
+ _tmp11_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
+ _tmp12_ = _tmp11_;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, RYGEL_AUDIO_ITEM_UPNP_CLASS);
+ _tmp13_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
+ _tmp14_ = _tmp13_;
+ gee_abstract_collection_add ((GeeAbstractCollection*) _tmp14_, RYGEL_MUSIC_ITEM_UPNP_CLASS);
+ return self;
+}
+
+
+RygelMediaExportWritableDbContainer* rygel_media_export_writable_db_container_new (RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title) {
+ return rygel_media_export_writable_db_container_construct (RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, media_db, id, title);
+}
+
+
+static void rygel_media_export_writable_db_container_real_add_item_data_free (gpointer _data) {
+ RygelMediaExportWritableDbContainerAddItemData* _data_;
+ _data_ = _data;
+ _g_object_unref0 (_data_->item);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportWritableDbContainerAddItemData, _data_);
+}
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+ return self ? g_object_ref (self) : NULL;
+}
+
+
+static void rygel_media_export_writable_db_container_real_add_item (RygelWritableContainer* base, RygelMediaItem* item, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportWritableDbContainer * self;
+ RygelMediaExportWritableDbContainerAddItemData* _data_;
+ RygelMediaExportWritableDbContainer* _tmp0_;
+ RygelMediaItem* _tmp1_;
+ RygelMediaItem* _tmp2_;
+ GCancellable* _tmp3_;
+ GCancellable* _tmp4_;
+ self = (RygelMediaExportWritableDbContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportWritableDbContainerAddItemData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_writable_db_container_real_add_item);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_writable_db_container_real_add_item_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = item;
+ _tmp2_ = _g_object_ref0 (_tmp1_);
+ _g_object_unref0 (_data_->item);
+ _data_->item = _tmp2_;
+ _tmp3_ = cancellable;
+ _tmp4_ = _g_object_ref0 (_tmp3_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp4_;
+ rygel_media_export_writable_db_container_real_add_item_co (_data_);
+}
+
+
+static void rygel_media_export_writable_db_container_real_add_item_finish (RygelWritableContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaExportWritableDbContainerAddItemData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static gboolean rygel_media_export_writable_db_container_real_add_item_co (RygelMediaExportWritableDbContainerAddItemData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = _data_->item;
+ ((RygelMediaObject*) _data_->_tmp0_)->parent = (RygelMediaContainer*) _data_->self;
+ _data_->_tmp1_ = _data_->item;
+ _data_->_tmp2_ = ((RygelMediaObject*) _data_->_tmp1_)->uris;
+ _data_->_tmp3_ = NULL;
+ _data_->_tmp3_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp2_, 0);
+ _data_->_tmp4_ = (gchar*) _data_->_tmp3_;
+ _data_->_tmp5_ = NULL;
+ _data_->_tmp5_ = g_file_new_for_uri (_data_->_tmp4_);
+ _data_->_tmp6_ = _data_->_tmp5_;
+ _g_free0 (_data_->_tmp4_);
+ _data_->file = _data_->_tmp6_;
+ _data_->_tmp7_ = _data_->file;
+ _data_->_tmp8_ = FALSE;
+ _data_->_tmp8_ = g_file_is_native (_data_->_tmp7_);
+ if (_data_->_tmp8_) {
+ _data_->_tmp9_ = _data_->item;
+ _data_->_tmp10_ = G_MAXINT64;
+ rygel_media_object_set_modified ((RygelMediaObject*) _data_->_tmp9_, (guint64) _data_->_tmp10_);
+ }
+ _data_->_tmp11_ = _data_->item;
+ _data_->_tmp12_ = _data_->file;
+ _data_->_tmp13_ = NULL;
+ _data_->_tmp13_ = rygel_media_export_media_cache_get_id (_data_->_tmp12_);
+ _data_->_tmp14_ = _data_->_tmp13_;
+ rygel_media_object_set_id ((RygelMediaObject*) _data_->_tmp11_, _data_->_tmp14_);
+ _g_free0 (_data_->_tmp14_);
+ _data_->_tmp15_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp16_ = _data_->item;
+ rygel_media_export_media_cache_save_item (_data_->_tmp15_, _data_->_tmp16_, &_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_unref0 (_data_->file);
+ 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_unref0 (_data_->file);
+ 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_writable_db_container_real_remove_item_data_free (gpointer _data) {
+ RygelMediaExportWritableDbContainerRemoveItemData* _data_;
+ _data_ = _data;
+ _g_free0 (_data_->id);
+ _g_object_unref0 (_data_->cancellable);
+ _g_object_unref0 (_data_->self);
+ g_slice_free (RygelMediaExportWritableDbContainerRemoveItemData, _data_);
+}
+
+
+static void rygel_media_export_writable_db_container_real_remove_item (RygelWritableContainer* base, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
+ RygelMediaExportWritableDbContainer * self;
+ RygelMediaExportWritableDbContainerRemoveItemData* _data_;
+ RygelMediaExportWritableDbContainer* _tmp0_;
+ const gchar* _tmp1_;
+ gchar* _tmp2_;
+ GCancellable* _tmp3_;
+ GCancellable* _tmp4_;
+ self = (RygelMediaExportWritableDbContainer*) base;
+ _data_ = g_slice_new0 (RygelMediaExportWritableDbContainerRemoveItemData);
+ _data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_writable_db_container_real_remove_item);
+ g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_writable_db_container_real_remove_item_data_free);
+ _tmp0_ = _g_object_ref0 (self);
+ _data_->self = _tmp0_;
+ _tmp1_ = id;
+ _tmp2_ = g_strdup (_tmp1_);
+ _g_free0 (_data_->id);
+ _data_->id = _tmp2_;
+ _tmp3_ = cancellable;
+ _tmp4_ = _g_object_ref0 (_tmp3_);
+ _g_object_unref0 (_data_->cancellable);
+ _data_->cancellable = _tmp4_;
+ rygel_media_export_writable_db_container_real_remove_item_co (_data_);
+}
+
+
+static void rygel_media_export_writable_db_container_real_remove_item_finish (RygelWritableContainer* base, GAsyncResult* _res_, GError** error) {
+ RygelMediaExportWritableDbContainerRemoveItemData* _data_;
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
+ return;
+ }
+ _data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
+}
+
+
+static gboolean rygel_media_export_writable_db_container_real_remove_item_co (RygelMediaExportWritableDbContainerRemoveItemData* _data_) {
+ switch (_data_->_state_) {
+ case 0:
+ goto _state_0;
+ default:
+ g_assert_not_reached ();
+ }
+ _state_0:
+ _data_->_tmp0_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
+ _data_->_tmp1_ = _data_->id;
+ rygel_media_export_media_cache_remove_by_id (_data_->_tmp0_, _data_->_tmp1_, &_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_);
+ 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;
+ }
+ 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 GeeArrayList* rygel_media_export_writable_db_container_real_get_create_classes (RygelWritableContainer* base) {
+ GeeArrayList* result;
+ RygelMediaExportWritableDbContainer* self;
+ GeeArrayList* _tmp0_;
+ self = (RygelMediaExportWritableDbContainer*) base;
+ _tmp0_ = self->priv->_create_classes;
+ result = _tmp0_;
+ return result;
+}
+
+
+static void rygel_media_export_writable_db_container_real_set_create_classes (RygelWritableContainer* base, GeeArrayList* value) {
+ RygelMediaExportWritableDbContainer* self;
+ GeeArrayList* _tmp0_;
+ GeeArrayList* _tmp1_;
+ self = (RygelMediaExportWritableDbContainer*) base;
+ _tmp0_ = value;
+ _tmp1_ = _g_object_ref0 (_tmp0_);
+ _g_object_unref0 (self->priv->_create_classes);
+ self->priv->_create_classes = _tmp1_;
+ g_object_notify ((GObject *) self, "create-classes");
+}
+
+
+static void rygel_media_export_writable_db_container_class_init (RygelMediaExportWritableDbContainerClass * klass) {
+ rygel_media_export_writable_db_container_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (RygelMediaExportWritableDbContainerPrivate));
+ G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_writable_db_container_get_property;
+ G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_writable_db_container_set_property;
+ G_OBJECT_CLASS (klass)->finalize = rygel_media_export_writable_db_container_finalize;
+ g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES, g_param_spec_object ("create-classes", "create-classes", "create-classes", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
+}
+
+
+static void rygel_media_export_writable_db_container_rygel_writable_container_interface_init (RygelWritableContainerIface * iface) {
+ rygel_media_export_writable_db_container_rygel_writable_container_parent_iface = g_type_interface_peek_parent (iface);
+ iface->add_item = (void (*)(RygelWritableContainer*, RygelMediaItem*, GCancellable*, GError**)) rygel_media_export_writable_db_container_real_add_item;
+ iface->add_item_finish = rygel_media_export_writable_db_container_real_add_item_finish;
+ iface->remove_item = (void (*)(RygelWritableContainer*, const gchar*, GCancellable*, GError**)) rygel_media_export_writable_db_container_real_remove_item;
+ iface->remove_item_finish = rygel_media_export_writable_db_container_real_remove_item_finish;
+ iface->get_create_classes = rygel_media_export_writable_db_container_real_get_create_classes;
+ iface->set_create_classes = rygel_media_export_writable_db_container_real_set_create_classes;
+}
+
+
+static void rygel_media_export_writable_db_container_init (RygelMediaExportWritableDbContainer * self) {
+ self->priv = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_PRIVATE (self);
+}
+
+
+static void rygel_media_export_writable_db_container_finalize (GObject* obj) {
+ RygelMediaExportWritableDbContainer * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer);
+ _g_object_unref0 (self->priv->_create_classes);
+ G_OBJECT_CLASS (rygel_media_export_writable_db_container_parent_class)->finalize (obj);
+}
+
+
+GType rygel_media_export_writable_db_container_get_type (void) {
+ static volatile gsize rygel_media_export_writable_db_container_type_id__volatile = 0;
+ if (g_once_init_enter (&rygel_media_export_writable_db_container_type_id__volatile)) {
+ static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportWritableDbContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_writable_db_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportWritableDbContainer), 0, (GInstanceInitFunc) rygel_media_export_writable_db_container_init, NULL };
+ static const GInterfaceInfo rygel_writable_container_info = { (GInterfaceInitFunc) rygel_media_export_writable_db_container_rygel_writable_container_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
+ GType rygel_media_export_writable_db_container_type_id;
+ rygel_media_export_writable_db_container_type_id = g_type_register_static (RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, "RygelMediaExportWritableDbContainer", &g_define_type_info, 0);
+ g_type_add_interface_static (rygel_media_export_writable_db_container_type_id, RYGEL_TYPE_WRITABLE_CONTAINER, &rygel_writable_container_info);
+ g_once_init_leave (&rygel_media_export_writable_db_container_type_id__volatile, rygel_media_export_writable_db_container_type_id);
+ }
+ return rygel_media_export_writable_db_container_type_id__volatile;
+}
+
+
+static void _vala_rygel_media_export_writable_db_container_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
+ RygelMediaExportWritableDbContainer * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer);
+ switch (property_id) {
+ case RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES:
+ g_value_set_object (value, rygel_writable_container_get_create_classes ((RygelWritableContainer*) self));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+static void _vala_rygel_media_export_writable_db_container_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
+ RygelMediaExportWritableDbContainer * self;
+ self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer);
+ switch (property_id) {
+ case RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES:
+ rygel_writable_container_set_create_classes ((RygelWritableContainer*) self, g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+
+
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 87545cc..1054593 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,10 +2,10 @@ noinst_PROGRAMS = test_simple
test_simple_SOURCES = test_simple.c
test_simple_CFLAGS = \
$(DEPS_CFLAGS) \
- -I$(top_builddir)/src -I$(top_srcdir)/src
+ -I$(top_builddir)/src/media-export -I$(top_srcdir)/src/media-export
test_simple_LDADD = \
$(DEPS_LIBS) \
- $(top_builddir)/src/librygel-media-engine-gst-0-10.la
+ $(top_builddir)/src/media-export/librygel-media-export-gst-0-10.la
check_PROGRAMS = test_simple
diff --git a/tests/test_simple.c b/tests/test_simple.c
index 52a0ad1..2b9a082 100644
--- a/tests/test_simple.c
+++ b/tests/test_simple.c
@@ -18,7 +18,8 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#include "rygel-gst-media-export-plugin.h"
+#include "rygel-media-export-plugin.h"
+#include "rygel-media-export-root-container.h"
int main(int argc, char *argv[])
{
@@ -30,16 +31,34 @@ int main(int argc, char *argv[])
/* Some very simple checks that the plugin can be instantiated
* and used in very simple ways.
*/
- RygelMediaServerPlugin *plugin = module_init ();
+
+ /* Call the plugin's module_init() to make it load itself: */
+ RygelPluginLoader* loader = rygel_plugin_loader_new ();
+ g_assert (loader);
+
+ module_init (loader);
+
+ /* Get the loaded plugin: */
+ GeeCollection* list_plugins = rygel_plugin_loader_list_plugins (loader);
+ g_assert (list_plugins);
+ g_assert (!gee_collection_get_is_empty (list_plugins));
+ g_assert (gee_collection_get_size (list_plugins) == 1);
+
+ /* Check the plugin: */
+ GeeIterator* iter = gee_iterable_iterator (GEE_ITERABLE (list_plugins));
+ RygelMediaServerPlugin *plugin = gee_iterator_get (iter);
g_assert (plugin);
g_assert (RYGEL_MEDIA_EXPORT_PLUGIN (plugin));
+ /* Check the plugin's root container: */
RygelMediaContainer *root_container = rygel_media_server_plugin_get_root_container (plugin);
g_assert (root_container);
g_assert (RYGEL_MEDIA_EXPORT_ROOT_CONTAINER (root_container));
+ /* unref: */
g_object_unref (root_container);
g_object_unref (plugin);
+ g_object_unref (loader);
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]