tracker r2896 - trunk/src/tracker-extract
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2896 - trunk/src/tracker-extract
- Date: Fri, 6 Feb 2009 20:48:57 +0000 (UTC)
Author: mr
Date: Fri Feb 6 20:48:57 2009
New Revision: 2896
URL: http://svn.gnome.org/viewvc/tracker?rev=2896&view=rev
Log:
Missing files
Added:
trunk/src/tracker-extract/tracker-dbus.c
trunk/src/tracker-extract/tracker-dbus.h
Modified:
trunk/src/tracker-extract/tracker-extract-mplayer.c
Added: trunk/src/tracker-extract/tracker-dbus.c
==============================================================================
--- (empty file)
+++ trunk/src/tracker-extract/tracker-dbus.c Fri Feb 6 20:48:57 2009
@@ -0,0 +1,201 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <libtracker-common/tracker-dbus.h>
+
+#include "tracker-dbus.h"
+#include "tracker-extract.h"
+#include "tracker-extract-glue.h"
+
+static DBusGConnection *connection;
+static DBusGProxy *gproxy;
+static GSList *objects;
+
+static gboolean
+dbus_register_service (DBusGProxy *proxy,
+ const gchar *name)
+{
+ GError *error = NULL;
+ guint result;
+
+ g_message ("Registering DBus service...\n"
+ " Name:'%s'",
+ name);
+
+ if (!org_freedesktop_DBus_request_name (proxy,
+ name,
+ DBUS_NAME_FLAG_DO_NOT_QUEUE,
+ &result, &error)) {
+ g_critical ("Could not aquire name:'%s', %s",
+ name,
+ error ? error->message : "no error given");
+ g_error_free (error);
+
+ return FALSE;
+ }
+
+ if (result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ g_critical ("DBus service name:'%s' is already taken, "
+ "perhaps the daemon is already running?",
+ name);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static void
+dbus_register_object (DBusGConnection *lconnection,
+ DBusGProxy *proxy,
+ GObject *object,
+ const DBusGObjectInfo *info,
+ const gchar *path)
+{
+ g_message ("Registering DBus object...");
+ g_message (" Path:'%s'", path);
+ g_message (" Type:'%s'", G_OBJECT_TYPE_NAME (object));
+
+ dbus_g_object_type_install_info (G_OBJECT_TYPE (object), info);
+ dbus_g_connection_register_g_object (lconnection, path, object);
+}
+
+static void
+dbus_name_owner_changed (gpointer data,
+ GClosure *closure)
+{
+ g_object_unref (data);
+}
+
+static gboolean
+dbus_register_names (void)
+{
+ GError *error = NULL;
+
+ if (connection) {
+ g_critical ("The DBusGConnection is already set, have we already initialized?");
+ return FALSE;
+ }
+
+ if (gproxy) {
+ g_critical ("The DBusGProxy is already set, have we already initialized?");
+ return FALSE;
+ }
+
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+
+ if (!connection) {
+ g_critical ("Could not connect to the DBus session bus, %s",
+ error ? error->message : "no error given.");
+ g_clear_error (&error);
+ return FALSE;
+ }
+
+ /* The definitions below (DBUS_SERVICE_DBUS, etc) are
+ * predefined for us to just use (dbus_g_proxy_...)
+ */
+ gproxy = dbus_g_proxy_new_for_name (connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ /* Register the service name for org.freedesktop.Tracker.Extract */
+ if (!dbus_register_service (gproxy, TRACKER_EXTRACT_SERVICE)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+gboolean
+tracker_dbus_init (void)
+{
+ /* Don't reinitialize */
+ if (objects) {
+ return TRUE;
+ }
+
+ /* Register names and get proxy/connection details */
+ if (!dbus_register_names ()) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+void
+tracker_dbus_shutdown (void)
+{
+ if (objects) {
+ g_slist_foreach (objects, (GFunc) g_object_unref, NULL);
+ g_slist_free (objects);
+ objects = NULL;
+ }
+
+ if (gproxy) {
+ g_object_unref (gproxy);
+ gproxy = NULL;
+ }
+
+ connection = NULL;
+}
+
+gboolean
+tracker_dbus_register_objects (void)
+{
+ gpointer object;
+
+ if (!connection || !gproxy) {
+ g_critical ("DBus support must be initialized before registering objects!");
+ return FALSE;
+ }
+
+ /* Add org.freedesktop.Tracker.Extract */
+ object = tracker_extract_new ();
+ if (!object) {
+ g_critical ("Could not create TrackerExtract object to register");
+ return FALSE;
+ }
+
+ dbus_register_object (connection,
+ gproxy,
+ G_OBJECT (object),
+ &dbus_glib_tracker_extract_object_info,
+ TRACKER_EXTRACT_PATH);
+ objects = g_slist_prepend (objects, object);
+
+ return TRUE;
+}
+
+GObject *
+tracker_dbus_get_object (GType type)
+{
+ GSList *l;
+
+ for (l = objects; l; l = l->next) {
+ if (G_OBJECT_TYPE (l->data) == type) {
+ return l->data;
+ }
+ }
+
+ return NULL;
+}
Added: trunk/src/tracker-extract/tracker-dbus.h
==============================================================================
--- (empty file)
+++ trunk/src/tracker-extract/tracker-dbus.h Fri Feb 6 20:48:57 2009
@@ -0,0 +1,37 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2006, Mr Jamie McCracken (jamiemcc gnome org)
+ * Copyright (C) 2008, Nokia
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __TRACKER_DBUS_H__
+#define __TRACKER_DBUS_H__
+
+#include <glib.h>
+
+#include <dbus/dbus-glib-bindings.h>
+
+G_BEGIN_DECLS
+
+gboolean tracker_dbus_init (void);
+void tracker_dbus_shutdown (void);
+gboolean tracker_dbus_register_object (void);
+
+G_END_DECLS
+
+#endif /* __TRACKER_DBUS_H__ */
Modified: trunk/src/tracker-extract/tracker-extract-mplayer.c
==============================================================================
--- trunk/src/tracker-extract/tracker-extract-mplayer.c (original)
+++ trunk/src/tracker-extract/tracker-extract-mplayer.c Fri Feb 6 20:48:57 2009
@@ -229,21 +229,28 @@
g_pattern_spec_free (pattern_ID_LENGTH);
if (has_video) {
- g_hash_table_foreach (tmp_metadata_video, copy_hash_table_entry, metadata);
+ if (tmp_metadata_video) {
+ g_hash_table_foreach (tmp_metadata_video,
+ copy_hash_table_entry,
+ metadata);
+ g_hash_table_destroy (tmp_metadata_video);
+ }
if (duration) {
g_hash_table_insert (metadata, g_strdup ("Video:Duration"), duration);
}
} else if (has_audio) {
- g_hash_table_foreach (tmp_metadata_audio, copy_hash_table_entry, metadata);
+ if (tmp_metadata_video) {
+ g_hash_table_foreach (tmp_metadata_audio,
+ copy_hash_table_entry,
+ metadata);
+ g_hash_table_destroy (tmp_metadata_audio);
+ }
if (duration) {
g_hash_table_insert (metadata, g_strdup ("Audio:Duration"), duration);
}
}
-
- g_hash_table_destroy (tmp_metadata_audio);
- g_hash_table_destroy (tmp_metadata_video);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]