tracker r1923 - in branches/indexer-split: . data/dbus src/tracker-applet src/trackerd
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1923 - in branches/indexer-split: . data/dbus src/tracker-applet src/trackerd
- Date: Thu, 24 Jul 2008 10:36:45 +0000 (UTC)
Author: mr
Date: Thu Jul 24 10:36:44 2008
New Revision: 1923
URL: http://svn.gnome.org/viewvc/tracker?rev=1923&view=rev
Log:
* data/dbus/tracker-daemon.xml:
* src/tracker-applet/tracker-applet.c: Signal how many items are
done/remaining/total instead of files/folders. This is much more
generic for whatever is being indexed.
* src/trackerd/tracker-daemon.c: Don't set the daemon/indexer as
"manually paused" if we get paused/continued state from the
indexer, only set that when the user sets it using DBus.
* src/trackerd/tracker-dbus.c: Don't synchronously continue the
indexer, do it asynchronously.
* src/trackerd/tracker-processor.c: When we get state from the
indexer, signal it up the stack so the applet knows how many items
have been indexed as we are doing it. This was completely
forgotten about until now!
* src/trackerd/tracker-main.c:
* src/trackerd/tracker-status.[ch]: Initialize and shutdown the
status module. The only reason for adding this is because we need
TrackerConfig for some of the information we emit when we signal
status. We now correctly signal if we are on battery or not and if
we are paused for IO (i.e. if we are indexing or not). This is now
correctly reflected in the tooltip in the applet.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/data/dbus/tracker-daemon.xml
branches/indexer-split/src/tracker-applet/tracker-applet.c
branches/indexer-split/src/trackerd/tracker-daemon.c
branches/indexer-split/src/trackerd/tracker-dbus.c
branches/indexer-split/src/trackerd/tracker-main.c
branches/indexer-split/src/trackerd/tracker-processor.c
branches/indexer-split/src/trackerd/tracker-status.c
branches/indexer-split/src/trackerd/tracker-status.h
Modified: branches/indexer-split/data/dbus/tracker-daemon.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-daemon.xml (original)
+++ branches/indexer-split/data/dbus/tracker-daemon.xml Thu Jul 24 10:36:44 2008
@@ -174,9 +174,9 @@
<signal name="IndexProgress">
<arg type="s" name="service"/>
<arg type="s" name="current_uri" />
- <arg type="i" name="index_count"/>
- <arg type="i" name="folders_processed"/>
- <arg type="i" name="folders_total"/>
+ <arg type="i" name="items_done"/>
+ <arg type="i" name="items_remaining"/>
+ <arg type="i" name="items_total"/>
</signal>
</interface>
</node>
Modified: branches/indexer-split/src/tracker-applet/tracker-applet.c
==============================================================================
--- branches/indexer-split/src/tracker-applet/tracker-applet.c (original)
+++ branches/indexer-split/src/tracker-applet/tracker-applet.c Thu Jul 24 10:36:44 2008
@@ -137,8 +137,9 @@
gboolean indexer_stopped;
/* status hints */
- int folders_indexed;
- int folders_total;
+ gint items_done;
+ gint items_remaining;
+ gint items_total;
/* main window */
GtkMenu *menu;
@@ -288,22 +289,23 @@
if (priv->index_state == INDEX_BUSY) {
if (!priv->email_indexing) {
- status = _("folders");
+ status = _("files");
} else {
status = _("mailboxes");
}
g_string_append_printf (hint, " %d/%d %s",
- priv->folders_indexed,
- priv->folders_total, status);
+ priv->items_done,
+ priv->items_total,
+ status);
}
if (priv->index_state == INDEX_MERGING) {
g_string_append_printf (hint, " %d/%d indexes being merged",
- priv->folders_indexed,
- priv->folders_total);
+ priv->items_done,
+ priv->items_total);
}
tray_icon_set_tooltip (icon, hint->str);
@@ -1576,19 +1578,19 @@
}
static void
-index_progress_changed (DBusGProxy * proxy, const gchar * service,
- const char *uri, int index_count,
- int folders_processed, int folders_total,
- TrayIcon * icon)
+index_progress_changed (DBusGProxy *proxy,
+ const gchar *service,
+ const gchar *uri,
+ gint items_done,
+ gint items_remaining,
+ gint items_total,
+ TrayIcon *icon)
{
TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
- if (folders_processed > folders_total)
- folders_processed = folders_total;
-
- priv->folders_indexed = folders_processed;
- priv->folders_total = folders_total;
+ priv->items_done = items_done;
+ priv->items_total = items_total;
priv->email_indexing = (strcmp (service, "Emails") == 0);
Modified: branches/indexer-split/src/trackerd/tracker-daemon.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-daemon.c (original)
+++ branches/indexer-split/src/trackerd/tracker-daemon.c Thu Jul 24 10:36:44 2008
@@ -216,7 +216,6 @@
gpointer user_data)
{
g_message ("The indexer has paused");
- tracker_set_is_paused_manually (TRUE);
}
static void
@@ -225,7 +224,6 @@
gpointer user_data)
{
g_message ("The indexer has continued");
- tracker_set_is_paused_manually (FALSE);
}
/*
@@ -395,6 +393,12 @@
value ? "true" : "false");
if (strcasecmp (option, "Pause") == 0) {
+ /* We do it here and not in the callback because we
+ * don't know if something else paused us or if it
+ * was the signal from our request.
+ */
+ tracker_set_is_paused_manually (value);
+
if (value) {
org_freedesktop_Tracker_Indexer_pause_async (priv->indexer_proxy,
indexer_pause_cb,
Modified: branches/indexer-split/src/trackerd/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-dbus.c (original)
+++ branches/indexer-split/src/trackerd/tracker-dbus.c Thu Jul 24 10:36:44 2008
@@ -156,20 +156,29 @@
return TRUE;
}
+static void
+indexer_continue_async_cb (DBusGProxy *proxy,
+ GError *error,
+ gpointer user_data)
+{
+ if (error) {
+ g_message ("Couldn't resume the indexer, eeek");
+ g_error_free (error);
+ }
+
+ g_object_unref (proxy);
+}
+
static gboolean
indexer_resume_cb (gpointer user_data)
{
DBusGProxy *proxy;
- GError *error = NULL;
proxy = user_data;
- org_freedesktop_Tracker_Indexer_continue (proxy, &error);
-
- if (error) {
- g_message ("Couldn't resume the indexer, eeek");
- g_error_free (error);
- }
+ org_freedesktop_Tracker_Indexer_continue_async (g_object_ref (proxy),
+ indexer_continue_async_cb,
+ NULL);
return FALSE;
}
Modified: branches/indexer-split/src/trackerd/tracker-main.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-main.c (original)
+++ branches/indexer-split/src/trackerd/tracker-main.c Thu Jul 24 10:36:44 2008
@@ -655,6 +655,8 @@
initialize_directories ();
/* Initialize other subsystems */
+ tracker_status_init (config);
+
tracker_log_init (log_filename, tracker_config_get_verbosity (config));
g_print ("Starting log:\n File:'%s'\n", log_filename);
@@ -797,6 +799,7 @@
tracker_db_shutdown ();
tracker_module_config_shutdown ();
tracker_nfs_lock_shutdown ();
+ tracker_status_shutdown ();
tracker_log_shutdown ();
/* Clean up object references */
Modified: branches/indexer-split/src/trackerd/tracker-processor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-processor.c (original)
+++ branches/indexer-split/src/trackerd/tracker-processor.c Thu Jul 24 10:36:44 2008
@@ -33,6 +33,7 @@
#include "tracker-processor.h"
#include "tracker-crawler.h"
+#include "tracker-daemon.h"
#include "tracker-dbus.h"
#include "tracker-indexer-client.h"
#include "tracker-monitor.h"
@@ -43,6 +44,8 @@
#define ITEMS_QUEUE_PROCESS_INTERVAL 2000
#define ITEMS_QUEUE_PROCESS_MAX 5000
+#define ITEMS_SIGNAL_TO_DAEMON_RATIO 500
+
typedef enum {
SENT_TYPE_NONE,
SENT_TYPE_CREATED,
@@ -84,6 +87,9 @@
guint directories_ignored;
guint files_found;
guint files_ignored;
+
+ guint items_done;
+ guint items_remaining;
};
enum {
@@ -639,8 +645,36 @@
guint items_remaining,
gpointer user_data)
{
- gchar *str1;
- gchar *str2;
+ TrackerProcessorPrivate *priv;
+ GObject *daemon;
+ GQueue *queue;
+ GFile *file;
+ gchar *path = NULL;
+ gchar *str1;
+ gchar *str2;
+
+ priv = TRACKER_PROCESSOR_GET_PRIVATE (user_data);
+
+ priv->items_done = items_done;
+ priv->items_remaining = items_remaining;
+
+ queue = g_hash_table_lookup (priv->items_created_queues, current_module_name);
+ if (queue) {
+ file = g_queue_peek_tail (queue);
+ if (file) {
+ path = g_file_get_path (file);
+ }
+ }
+
+ daemon = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
+ g_signal_emit_by_name (daemon,
+ "index-progress",
+ tracker_module_config_get_index_service (current_module_name),
+ path ? path : "",
+ priv->items_done, /* files */
+ priv->items_remaining, /* files */
+ priv->items_done + priv->items_remaining); /* files */
+ g_free (path);
if (items_remaining < 1) {
return;
@@ -658,7 +692,7 @@
current_module_name,
str1,
str2);
-
+
g_free (str2);
g_free (str1);
}
Modified: branches/indexer-split/src/trackerd/tracker-status.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-status.c (original)
+++ branches/indexer-split/src/trackerd/tracker-status.c Thu Jul 24 10:36:44 2008
@@ -26,14 +26,54 @@
#include "tracker-daemon.h"
#include "tracker-main.h"
-static TrackerStatus status = TRACKER_STATUS_INITIALIZING;
+static TrackerStatus status = TRACKER_STATUS_INITIALIZING;
+static TrackerConfig *status_config;
+static gpointer status_type_class;
+
+gboolean
+tracker_status_init (TrackerConfig *config)
+{
+ GType type;
+
+ g_return_val_if_fail (TRACKER_IS_CONFIG (config), FALSE);
+
+ status = TRACKER_STATUS_INITIALIZING;
+
+ /* Since we don't reference this enum anywhere, we do
+ * it here to make sure it exists when we call
+ * g_type_class_peek(). This wouldn't be necessary if
+ * it was a param in a GObject for example.
+ *
+ * This does mean that we are leaking by 1 reference
+ * here and should clean it up, but it doesn't grow so
+ * this is acceptable.
+ */
+ type = tracker_status_get_type ();
+ status_type_class = g_type_class_ref (type);
+
+ status_config = g_object_ref (config);
+
+ return TRUE;
+}
+
+void
+tracker_status_shutdown (void)
+{
+ g_object_unref (status_config);
+ status_config = NULL;
+
+ g_type_class_unref (status_type_class);
+ status_type_class = NULL;
+
+ status = TRACKER_STATUS_INITIALIZING;
+}
GType
tracker_status_get_type (void)
{
- static GType etype = 0;
+ static GType type = 0;
- if (etype == 0) {
+ if (type == 0) {
static const GEnumValue values[] = {
{ TRACKER_STATUS_INITIALIZING,
"TRACKER_STATUS_INITIALIZING",
@@ -59,22 +99,10 @@
{ 0, NULL, NULL }
};
- etype = g_enum_register_static ("TrackerStatus", values);
-
- /* Since we don't reference this enum anywhere, we do
- * it here to make sure it exists when we call
- * g_type_class_peek(). This wouldn't be necessary if
- * it was a param in a GObject for example.
- *
- * This does mean that we are leaking by 1 reference
- * here and should clean it up, but it doesn't grow so
- * this is acceptable.
- */
-
- g_type_class_ref (etype);
+ type = g_enum_register_static ("TrackerStatus", values);
}
- return etype;
+ return type;
}
const gchar *
@@ -116,7 +144,9 @@
void
tracker_status_signal (void)
{
- GObject *object;
+ GObject *object;
+ gboolean pause_io;
+ gboolean pause_on_battery;
object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
@@ -126,6 +156,7 @@
* created. This is redundant now since we don't do both in
* the daemon. Should this be added back?
*/
+ pause_io = status == TRACKER_STATUS_PENDING ? TRUE : FALSE;
/* Pause on battery is a config option, not sure how to get
* that from here or the point of passing it in the state
@@ -133,15 +164,33 @@
* shouldn't send all this crap just for a simple state
* change. This is passed as FALSE for now.
*/
-
+ pause_on_battery = FALSE;
+
+#if 0
+ /* According to the old code, we always used:
+ *
+ * if (!tracker->pause_battery)
+ * pause_on_battery = FALSE;
+ *
+ * Which means this code was never used and FALSE was ALWAYS
+ * passed because tracker->pause_battery wasn't ever set to
+ * anything other than FALSE.
+ */
+ if (tracker->first_time_index) {
+ pause_on_battery = tracker_config_get_disable_indexing_on_battery_init (status_config);
+ } else {
+ pause_on_battery = tracker_config_get_disable_indexing_on_battery (status_config);
+ }
+#endif
+
g_signal_emit_by_name (object,
"index-state-change",
tracker_status_to_string (status),
tracker_get_is_first_time_index (),
tracker_get_in_merge (),
tracker_get_is_paused_manually (),
- FALSE, /* Pause on battery */
- FALSE, /* Pause IO */
+ pause_on_battery, /* Pause on battery */
+ pause_io, /* Pause IO */
!tracker_get_is_readonly ());
}
Modified: branches/indexer-split/src/trackerd/tracker-status.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-status.h (original)
+++ branches/indexer-split/src/trackerd/tracker-status.h Thu Jul 24 10:36:44 2008
@@ -24,6 +24,8 @@
#include <glib-object.h>
+#include <libtracker-common/tracker-config.h>
+
G_BEGIN_DECLS
#define TRACKER_TYPE_STATUS (tracker_status_get_type ())
@@ -38,13 +40,17 @@
TRACKER_STATUS_SHUTDOWN
} TrackerStatus;
-GType tracker_status_get_type (void) G_GNUC_CONST;
-const gchar * tracker_status_to_string (TrackerStatus status);
+gboolean tracker_status_init (TrackerConfig *config);
+void tracker_status_shutdown (void);
+
+GType tracker_status_get_type (void) G_GNUC_CONST;
+
+const gchar * tracker_status_to_string (TrackerStatus status);
TrackerStatus tracker_status_get (void);
const gchar * tracker_status_get_as_string (void);
-void tracker_status_set (TrackerStatus new_status);
-void tracker_status_set_and_signal (TrackerStatus new_status);
+void tracker_status_set (TrackerStatus new_status);
+void tracker_status_set_and_signal (TrackerStatus new_status);
void tracker_status_signal (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]