[tracker] TrackerMinerFiles: Hook up throttling to config and batt status.



commit 08c110228208da001e265454f151a3ddc17bcd67
Author: Carlos Garnacho <carlos lanedo com>
Date:   Fri Sep 18 13:45:24 2009 +0200

    TrackerMinerFiles: Hook up throttling to config and batt status.

 src/tracker-miner-fs/tracker-miner-files.c |   33 +++++++++++++++++++++++----
 1 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/src/tracker-miner-fs/tracker-miner-files.c b/src/tracker-miner-fs/tracker-miner-files.c
index 16bc8a1..60fdcf0 100644
--- a/src/tracker-miner-fs/tracker-miner-files.c
+++ b/src/tracker-miner-fs/tracker-miner-files.c
@@ -305,6 +305,7 @@ miner_files_constructed (GObject *object)
         TrackerMinerFiles *mf;
         TrackerMinerFS *fs;
         GSList *dirs;
+	gint throttle;
 
 	G_OBJECT_CLASS (tracker_miner_files_parent_class)->constructed (object);
 
@@ -365,6 +366,11 @@ miner_files_constructed (GObject *object)
                 dirs = dirs->next;
         }
 
+	throttle = tracker_config_get_throttle (mf->private->config);
+
+	/* Throttle in config goes from 0 to 20, translate to 0.0 -> 1.0 */
+	tracker_miner_fs_set_throttle (TRACKER_MINER_FS (mf), (1.0 / 20) * throttle);
+
 #ifdef HAVE_HAL
         initialize_removable_devices (mf);
 #endif /* HAVE_HAL */
@@ -655,6 +661,26 @@ initialize_removable_devices (TrackerMinerFiles *mf)
 }
 
 static void
+set_up_throttle (TrackerMinerFiles *mf,
+		 gboolean           enable)
+{
+	gdouble throttle;
+	gint config_throttle;
+
+	config_throttle = tracker_config_get_throttle (mf->private->config);
+	throttle = (1.0 / 20) * config_throttle;
+
+	if (enable) {
+		throttle += 0.25;
+	}
+
+	throttle = CLAMP (throttle, 0, 1);
+
+	g_debug ("Setting new throttle to %0.3f", throttle);
+	tracker_miner_fs_set_throttle (TRACKER_MINER_FS (mf), throttle);
+}
+
+static void
 on_battery_cb (GObject    *gobject,
 	       GParamSpec *arg1,
 	       gpointer    user_data)
@@ -662,9 +688,7 @@ on_battery_cb (GObject    *gobject,
 	TrackerMinerFiles *mf = user_data;
 	gboolean on_battery;
 
-	/* FIXME: Get this working again */
-	/* set_up_throttle (TRUE); */
-
+	set_up_throttle (mf, TRUE);
 	on_battery = tracker_power_get_on_battery (mf->private->power);
 
 	if (on_battery) {
@@ -723,8 +747,7 @@ on_low_battery_cb (GObject    *object,
 		}
 	}
 
-	/* FIXME: Get this working again */
-	/* set_up_throttle (FALSE); */
+	set_up_throttle (mf, FALSE);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]