tracker r2511 - in trunk: . data/dbus src/libtracker-common src/tracker-indexer src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r2511 - in trunk: . data/dbus src/libtracker-common src/tracker-indexer src/trackerd
- Date: Mon, 17 Nov 2008 17:02:12 +0000 (UTC)
Author: mr
Date: Mon Nov 17 17:02:11 2008
New Revision: 2511
URL: http://svn.gnome.org/viewvc/tracker?rev=2511&view=rev
Log:
* src/libtracker-common/tracker-hal.c: Added the UDI to the
mount-pointer-added and mount-point-removed signals.
* src/trackerd/tracker-processor.c:
* src/libtracker-common/Makefile.am:
* src/libtracker-common/tracker-marshal-main.c:
* src/libtracker-common/tracker-marshal.list: Added marshalling
for VOID__STRING_STRING function signature.
* data/dbus/tracker-indexer.xml:
* src/tracker-indexer/tracker-indexer.[ch]: Added function to
allow the daemon to tell us when a volume has changed state so we
can update the Volume table in the database.
* src/trackerd/tracker-main.c: Added volume monitoring here so we
can notify the Indexer that it should update the Volumes table in
teh database.
Added:
trunk/src/libtracker-common/tracker-marshal-main.c
trunk/src/libtracker-common/tracker-marshal.list
Modified:
trunk/ChangeLog
trunk/data/dbus/tracker-indexer.xml
trunk/src/libtracker-common/Makefile.am
trunk/src/libtracker-common/tracker-hal.c
trunk/src/tracker-indexer/tracker-indexer.c
trunk/src/tracker-indexer/tracker-indexer.h
trunk/src/trackerd/tracker-main.c
trunk/src/trackerd/tracker-processor.c
Modified: trunk/data/dbus/tracker-indexer.xml
==============================================================================
--- trunk/data/dbus/tracker-indexer.xml (original)
+++ trunk/data/dbus/tracker-indexer.xml Mon Nov 17 17:02:11 2008
@@ -33,6 +33,13 @@
<arg type="s" name="file_to" direction="in" />
</method>
+ <method name="VolumeUpdateState">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
+ <arg type="s" name="volume_id" direction="in" />
+ <arg type="s" name="path" direction="in" />
+ <arg type="b" name="enabled" direction="in" />
+ </method>
+
<method name="PropertySet">
<annotation name="org.freedesktop.DBus.GLib.Async" value="true"/>
<arg type="s" name="service_type" direction="in" />
Modified: trunk/src/libtracker-common/Makefile.am
==============================================================================
--- trunk/src/libtracker-common/Makefile.am (original)
+++ trunk/src/libtracker-common/Makefile.am Mon Nov 17 17:02:11 2008
@@ -40,6 +40,7 @@
tracker-ioprio.c \
tracker-language.c \
tracker-log.c \
+ tracker-marshal-main.c \
tracker-module-config.c \
tracker-nfs-lock.c \
tracker-ontology.c \
@@ -80,3 +81,24 @@
$(GIO_LIBS) \
$(GLIB2_LIBS)
+
+tracker-marshal.h: tracker-marshal.list
+ $(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --header > $@
+
+tracker-marshal.c: tracker-marshal.list
+ $(GLIB_GENMARSHAL) $< --prefix=tracker_marshal --body > $@
+
+tracker-marshal-main.c: tracker-marshal.c tracker-marshal.h
+
+marshal_sources = \
+ tracker-marshal.h \
+ tracker-marshal.c
+
+BUILT_SOURCES = \
+ $(marshal_sources)
+
+CLEANFILES = $(BUILT_SOURCES)
+
+EXTRA_DIST = \
+ $(BUILT_SOURCES) \
+ tracker-marshal.list
Modified: trunk/src/libtracker-common/tracker-hal.c
==============================================================================
--- trunk/src/libtracker-common/tracker-hal.c (original)
+++ trunk/src/libtracker-common/tracker-hal.c Mon Nov 17 17:02:11 2008
@@ -33,14 +33,15 @@
#include "tracker-log.h"
#include "tracker-hal.h"
#include "tracker-utils.h"
+#include "tracker-marshal.h"
#define CAPABILITY_AC_ADAPTER "ac_adapter"
#define CAPABILITY_BATTERY "battery"
#define CAPABILITY_VOLUME "volume"
-#define PROP_AC_ADAPTER_ON "ac_adapter.present"
-#define PROP_BATT_PERCENTAGE "battery.charge_level.percentage"
-#define PROP_IS_MOUNTED "volume.is_mounted"
+#define PROP_AC_ADAPTER_ON "ac_adapter.present"
+#define PROP_BATT_PERCENTAGE "battery.charge_level.percentage"
+#define PROP_IS_MOUNTED "volume.is_mounted"
#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_HAL, TrackerHalPriv))
@@ -98,8 +99,8 @@
};
enum {
- SIG_MOUNT_POINT_ADDED,
- SIG_MOUNT_POINT_REMOVED,
+ MOUNT_POINT_ADDED,
+ MOUNT_POINT_REMOVED,
LAST_SIGNAL
};
@@ -117,25 +118,29 @@
object_class->finalize = tracker_hal_finalize;
object_class->get_property = hal_get_property;
- signals[SIG_MOUNT_POINT_ADDED] =
+ signals[MOUNT_POINT_ADDED] =
g_signal_new ("mount-point-added",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
+ tracker_marshal_VOID__STRING_STRING,
G_TYPE_NONE,
- 1, G_TYPE_STRING);
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
- signals[SIG_MOUNT_POINT_REMOVED] =
+ signals[MOUNT_POINT_REMOVED] =
g_signal_new ("mount-point-removed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
+ tracker_marshal_VOID__STRING_STRING,
G_TYPE_NONE,
- 1, G_TYPE_STRING);
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_STRING);
g_object_class_install_property (object_class,
PROP_BATTERY_IN_USE,
@@ -349,13 +354,13 @@
}
g_message ("HAL device found:\n"
- " - udi : %s\n"
+ " - udi : %s\n"
" - mount point: %s\n"
" - device file: %s\n"
- " - uuid : %s\n"
- " - mounted : %s\n"
+ " - uuid : %s\n"
+ " - mounted : %s\n"
" - file system: %s\n"
- " - label : %s",
+ " - label : %s",
libhal_volume_get_udi (volume),
libhal_volume_get_mount_point (volume),
libhal_volume_get_device_file (volume),
@@ -511,9 +516,9 @@
priv = GET_PRIV (hal);
g_message ("HAL device with mount point:'%s', removable:%s now being tracked",
- mount_point,
- removable_device ? "yes" : "no");
-
+ mount_point,
+ removable_device ? "yes" : "no");
+
g_hash_table_insert (priv->mounted_devices,
g_strdup (udi),
g_strdup (mount_point));
@@ -524,7 +529,7 @@
g_strdup (mount_point));
}
- g_signal_emit (hal, signals[SIG_MOUNT_POINT_ADDED], 0, mount_point, NULL);
+ g_signal_emit (hal, signals[MOUNT_POINT_ADDED], 0, udi, mount_point, NULL);
}
static void
@@ -532,20 +537,24 @@
const gchar *udi)
{
TrackerHalPriv *priv;
+ LibHalVolume *volume;
const gchar *mount_point;
+ const gchar *volume_uuid;
priv = GET_PRIV (hal);
mount_point = g_hash_table_lookup (priv->mounted_devices, udi);
+
if (!mount_point) {
return;
}
- g_message ("HAL device with mount point:'%s', removable:%s NO LONGER being tracked",
- mount_point,
- g_hash_table_remove (priv->removable_devices, udi) ? "yes" : "no");
-
- g_signal_emit (hal, signals[SIG_MOUNT_POINT_REMOVED], 0, mount_point, NULL);
+ g_message ("HAL device with mount point:'%s' (uuid:'%s'), removable:%s NO LONGER being tracked",
+ mount_point,
+ udi,
+ g_hash_table_remove (priv->removable_devices, udi) ? "yes" : "no");
+
+ g_signal_emit (hal, signals[MOUNT_POINT_REMOVED], 0, udi, mount_point, NULL);
g_hash_table_remove (priv->mounted_devices, udi);
g_hash_table_remove (priv->removable_devices, udi);
@@ -810,13 +819,13 @@
}
g_message ("HAL device added:\n"
- " - udi : %s\n"
+ " - udi : %s\n"
" - mount point: %s\n"
" - device file: %s\n"
- " - uuid : %s\n"
+ " - uuid : %s\n"
" - mounted : %s\n"
" - file system: %s\n"
- " - label : %s",
+ " - label : %s",
udi,
libhal_volume_get_mount_point (volume),
libhal_volume_get_device_file (volume),
@@ -855,7 +864,7 @@
mount_point = g_hash_table_lookup (priv->mounted_devices, udi);
g_message ("HAL device removed:\n"
- " - udi : %s\n"
+ " - udi : %s\n"
" - mount point: %s\n"
" - device_file: %s",
udi,
Added: trunk/src/libtracker-common/tracker-marshal-main.c
==============================================================================
--- (empty file)
+++ trunk/src/libtracker-common/tracker-marshal-main.c Mon Nov 17 17:02:11 2008
@@ -0,0 +1,2 @@
+#include "tracker-marshal.h"
+#include "tracker-marshal.c"
Added: trunk/src/libtracker-common/tracker-marshal.list
==============================================================================
--- (empty file)
+++ trunk/src/libtracker-common/tracker-marshal.list Mon Nov 17 17:02:11 2008
@@ -0,0 +1 @@
+VOID:STRING,STRING
Modified: trunk/src/tracker-indexer/tracker-indexer.c
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.c (original)
+++ trunk/src/tracker-indexer/tracker-indexer.c Mon Nov 17 17:02:11 2008
@@ -2592,6 +2592,33 @@
}
void
+tracker_indexer_volume_update_state (TrackerIndexer *indexer,
+ const gchar *volume_uuid,
+ const gchar *path,
+ gboolean enabled,
+ DBusGMethodInvocation *context,
+ GError **error)
+{
+ guint request_id;
+
+ tracker_dbus_async_return_if_fail (TRACKER_IS_INDEXER (indexer), context);
+ tracker_dbus_async_return_if_fail (volume_uuid != NULL, context);
+ tracker_dbus_async_return_if_fail (path != NULL, context);
+
+ request_id = tracker_dbus_get_next_request_id ();
+
+ tracker_dbus_request_new (request_id,
+ "DBus request to update volume "
+ "UUID:'%s', path:'%s', enabled:%s",
+ volume_uuid,
+ path,
+ enabled ? "yes" : "no");
+
+ dbus_g_method_return (context);
+ tracker_dbus_request_success (request_id);
+}
+
+void
tracker_indexer_property_set (TrackerIndexer *indexer,
const gchar *service_type,
const gchar *uri,
Modified: trunk/src/tracker-indexer/tracker-indexer.h
==============================================================================
--- trunk/src/tracker-indexer/tracker-indexer.h (original)
+++ trunk/src/tracker-indexer/tracker-indexer.h Mon Nov 17 17:02:11 2008
@@ -70,66 +70,72 @@
const gchar *module_name);
};
-GType tracker_indexer_get_type (void) G_GNUC_CONST;
+GType tracker_indexer_get_type (void) G_GNUC_CONST;
-TrackerIndexer *tracker_indexer_new (void);
-gboolean tracker_indexer_get_running (TrackerIndexer *indexer);
-void tracker_indexer_set_running (TrackerIndexer *indexer,
- gboolean running);
-void tracker_indexer_stop (TrackerIndexer *indexer);
-void tracker_indexer_process_all (TrackerIndexer *indexer);
-void tracker_indexer_process_modules (TrackerIndexer *indexer,
- gchar **modules);
+TrackerIndexer *tracker_indexer_new (void);
+gboolean tracker_indexer_get_running (TrackerIndexer *indexer);
+void tracker_indexer_set_running (TrackerIndexer *indexer,
+ gboolean running);
+void tracker_indexer_stop (TrackerIndexer *indexer);
+void tracker_indexer_process_all (TrackerIndexer *indexer);
+void tracker_indexer_process_modules (TrackerIndexer *indexer,
+ gchar **modules);
/* DBus methods */
-void tracker_indexer_pause (TrackerIndexer *indexer,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_pause_for_duration (TrackerIndexer *indexer,
- guint seconds,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_continue (TrackerIndexer *indexer,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_files_check (TrackerIndexer *indexer,
- const gchar *module,
- GStrv files,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_files_update (TrackerIndexer *indexer,
- const gchar *module,
- GStrv files,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_files_delete (TrackerIndexer *indexer,
- const gchar *module,
- GStrv files,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_file_move (TrackerIndexer *indexer,
- const gchar *module_name,
- gchar *from,
- gchar *to,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_property_set (TrackerIndexer *indexer,
- const gchar *service_type,
- const gchar *uri,
- const gchar *property,
- GStrv values,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_property_remove (TrackerIndexer *indexer,
- const gchar *service_type,
- const gchar *uri,
- const gchar *property,
- GStrv values,
- DBusGMethodInvocation *context,
- GError **error);
-void tracker_indexer_shutdown (TrackerIndexer *indexer,
- DBusGMethodInvocation *context,
- GError **error);
+void tracker_indexer_pause (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_pause_for_duration (TrackerIndexer *indexer,
+ guint seconds,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_continue (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_files_check (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_files_update (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_files_delete (TrackerIndexer *indexer,
+ const gchar *module,
+ GStrv files,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_file_move (TrackerIndexer *indexer,
+ const gchar *module_name,
+ gchar *from,
+ gchar *to,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_volume_update_state (TrackerIndexer *indexer,
+ const gchar *volume_uuid,
+ const gchar *path,
+ gboolean enabled,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_property_set (TrackerIndexer *indexer,
+ const gchar *service_type,
+ const gchar *uri,
+ const gchar *property,
+ GStrv values,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_property_remove (TrackerIndexer *indexer,
+ const gchar *service_type,
+ const gchar *uri,
+ const gchar *property,
+ GStrv values,
+ DBusGMethodInvocation *context,
+ GError **error);
+void tracker_indexer_shutdown (TrackerIndexer *indexer,
+ DBusGMethodInvocation *context,
+ GError **error);
G_END_DECLS
Modified: trunk/src/trackerd/tracker-main.c
==============================================================================
--- trunk/src/trackerd/tracker-main.c (original)
+++ trunk/src/trackerd/tracker-main.c Mon Nov 17 17:02:11 2008
@@ -288,6 +288,69 @@
return runlevel;
}
+#ifdef HAVE_HAL
+
+static void
+mount_point_set_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
+{
+ switch (GPOINTER_TO_INT (user_data)) {
+ case 1:
+ g_message ("Indexer now knows about mount point addition");
+ break;
+ case 2:
+ g_message ("Indexer now knows about mount point removal");
+ break;
+ }
+}
+
+static void
+mount_point_added_cb (TrackerHal *hal,
+ const gchar *udi,
+ const gchar *mount_point,
+ gpointer user_data)
+{
+ TrackerMainPrivate *private;
+ GError *error = NULL;
+
+ private = g_static_private_get (&private_key);
+
+ g_message ("Indexer is being notified about added mount point:'%s'",
+ mount_point);
+
+ org_freedesktop_Tracker_Indexer_volume_update_state_async (tracker_dbus_indexer_get_proxy (),
+ udi,
+ mount_point,
+ TRUE,
+ mount_point_set_cb,
+ GINT_TO_POINTER (1));
+}
+
+static void
+mount_point_removed_cb (TrackerHal *hal,
+ const gchar *udi,
+ const gchar *mount_point,
+ gpointer user_data)
+{
+ TrackerMainPrivate *private;
+ GError *error = NULL;
+
+ private = g_static_private_get (&private_key);
+
+ g_message ("Indexer is being notified about removed mount point:'%s'",
+ mount_point);
+
+ org_freedesktop_Tracker_Indexer_volume_update_state_async (tracker_dbus_indexer_get_proxy (),
+ udi,
+ mount_point,
+ FALSE,
+ mount_point_set_cb,
+ GINT_TO_POINTER (2));
+}
+
+#endif /* HAVE_HAL */
+
static void
log_option_list (GSList *list,
const gchar *str)
@@ -648,14 +711,15 @@
g_type_init ();
+ if (!g_thread_supported ()) {
+ g_thread_init (NULL);
+ }
+
private = g_new0 (TrackerMainPrivate, 1);
g_static_private_set (&private_key,
private,
private_free);
- if (!g_thread_supported ())
- g_thread_init (NULL);
-
dbus_g_thread_init ();
setlocale (LC_ALL, "");
@@ -745,6 +809,12 @@
g_signal_connect (hal, "notify::battery-in-use",
G_CALLBACK (notify_battery_in_use_cb),
config);
+ g_signal_connect (hal, "mount-point-added",
+ G_CALLBACK (mount_point_added_cb),
+ NULL);
+ g_signal_connect (hal, "mount-point-removed",
+ G_CALLBACK (mount_point_removed_cb),
+ NULL);
set_up_throttle (hal, config);
#endif /* HAVE_HAL */
@@ -905,15 +975,6 @@
g_main_loop_run (private->main_loop);
}
-#if 0
- /* We can block on this since we are likely to block on
- * shutting down otherwise anyway.
- */
- org_freedesktop_Tracker_Indexer_pause_for_duration (tracker_dbus_indexer_get_proxy (),
- 2,
- NULL);
-#endif
-
/*
* Shutdown the daemon
*/
@@ -961,6 +1022,12 @@
g_signal_handlers_disconnect_by_func (hal,
notify_battery_in_use_cb,
config);
+ g_signal_handlers_disconnect_by_func (hal,
+ mount_point_added_cb,
+ NULL);
+ g_signal_handlers_disconnect_by_func (hal,
+ mount_point_removed_cb,
+ NULL);
g_object_unref (hal);
#endif /* HAVE_HAL */
Modified: trunk/src/trackerd/tracker-processor.c
==============================================================================
--- trunk/src/trackerd/tracker-processor.c (original)
+++ trunk/src/trackerd/tracker-processor.c Mon Nov 17 17:02:11 2008
@@ -160,9 +160,11 @@
#ifdef HAVE_HAL
static void mount_point_added_cb (TrackerHal *hal,
+ const gchar *volume_uuid,
const gchar *mount_point,
gpointer user_data);
static void mount_point_removed_cb (TrackerHal *hal,
+ const gchar *volume_uuid,
const gchar *mount_point,
gpointer user_data);
#endif /* HAVE_HAL */
@@ -1411,6 +1413,7 @@
static void
mount_point_added_cb (TrackerHal *hal,
+ const gchar *udi,
const gchar *mount_point,
gpointer user_data)
{
@@ -1419,8 +1422,6 @@
processor = user_data;
- g_message ("** TRAWLING THROUGH NEW MOUNT POINT:'%s'", mount_point);
-
status = tracker_status_get ();
processor->private->iterated_removable_media = FALSE;
@@ -1438,6 +1439,7 @@
static void
mount_point_removed_cb (TrackerHal *hal,
+ const gchar *udi,
const gchar *mount_point,
gpointer user_data)
{
@@ -1447,8 +1449,6 @@
processor = user_data;
- g_message ("** CLEANING UP OLD MOUNT POINT:'%s'", mount_point);
-
/* Remove the monitor and item from the database */
file = g_file_new_for_path (mount_point);
tracker_monitor_remove (processor->private->monitor, module_name, file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]