beagle r4796 - in trunk/beagle: Util beagled



Author: dbera
Date: Mon Jun 30 02:03:01 2008
New Revision: 4796
URL: http://svn.gnome.org/viewvc/beagle?rev=4796&view=rev

Log:
* Remove duplicate code for checking Battery status (beagled/BatteryMonitor.cs) and use Util/BatteryMonitor.cs.
* Only initialize the system dbus for battery monitoring; we don't need session dbus for that. This will remove the unnecessary error beagled prints if session dbus is not enabled.

Added:
   trunk/beagle/Util/BatteryMonitor.cs
      - copied, changed from r4787, /trunk/beagle/beagled/BatteryMonitor.cs
Removed:
   trunk/beagle/beagled/BatteryMonitor.cs
Modified:
   trunk/beagle/Util/Makefile.am
   trunk/beagle/Util/Scheduler.cs
   trunk/beagle/beagled/BuildIndex.cs
   trunk/beagle/beagled/Makefile.am

Copied: trunk/beagle/Util/BatteryMonitor.cs (from r4787, /trunk/beagle/beagled/BatteryMonitor.cs)
==============================================================================
--- /trunk/beagle/beagled/BatteryMonitor.cs	(original)
+++ trunk/beagle/Util/BatteryMonitor.cs	Mon Jun 30 02:03:01 2008
@@ -3,6 +3,24 @@
 //
 //  Copyright (c) 2007 Lukas Lipka, <lukaslipka gmail com>
 //
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+//
 
 using System;
 using System.Collections;
@@ -10,11 +28,9 @@
 
 using Hal;
 
-using Beagle.Util;
-
-namespace Beagle.Daemon {
+namespace Beagle.Util {
 
-	public class BatteryMonitor {
+	public static class BatteryMonitor {
 
 		private static Device adapter = null;
 		private static bool prev_on_battery = false;
@@ -22,8 +38,8 @@
 		public static void Init ()
 		{
 			try {
-				// Init DBus
-				NDesk.DBus.BusG.Init ();
+				// Init System DBus
+				NDesk.DBus.BusG.Init (NDesk.DBus.Bus.Session);
 			} catch (Exception e) {
 				// Lack of specific exception
 				Log.Error (e, "Failed to access dbus session bus. Battery monitoring will be disabled.");

Modified: trunk/beagle/Util/Makefile.am
==============================================================================
--- trunk/beagle/Util/Makefile.am	(original)
+++ trunk/beagle/Util/Makefile.am	Mon Jun 30 02:03:01 2008
@@ -59,7 +59,7 @@
 UTIL_CSFILES = 			        	\
 	$(F_SPOT_FILES)				\
 	$(srcdir)/ArrayFu.cs              	\
-	$(srcdir)/Battery.cs			\
+	$(srcdir)/BatteryMonitor.cs		\
 	$(srcdir)/BetterBitArray.cs		\
 	$(srcdir)/camel.cs              	\
 	$(srcdir)/Config.cs			\

Modified: trunk/beagle/Util/Scheduler.cs
==============================================================================
--- trunk/beagle/Util/Scheduler.cs	(original)
+++ trunk/beagle/Util/Scheduler.cs	Mon Jun 30 02:03:01 2008
@@ -752,7 +752,7 @@
 			bool need_throttle = false;
 
 			// Never speed up if we are using the battery.
-			if (idle_time > idle_threshold && ! Battery.UsingBattery) {
+			if (idle_time > idle_threshold && BatteryMonitor.UsingAC) {
 				is_idle = true;
 				double t = (idle_time - idle_threshold) / idle_ramp_up_time;				     
 				idle_scale = (1 - Math.Min (t, 1.0));

Modified: trunk/beagle/beagled/BuildIndex.cs
==============================================================================
--- trunk/beagle/beagled/BuildIndex.cs	(original)
+++ trunk/beagle/beagled/BuildIndex.cs	Mon Jun 30 02:03:01 2008
@@ -376,7 +376,7 @@
 				arg_source = dir.Name;
 			}
 
-			if (Battery.UsingBattery && arg_disable_on_battery) {
+			if (! BatteryMonitor.UsingAC && arg_disable_on_battery) {
 				Log.Always ("Indexer is disabled when on battery power (--disable-on-battery)");
 				Environment.Exit (0);
 			}

Modified: trunk/beagle/beagled/Makefile.am
==============================================================================
--- trunk/beagle/beagled/Makefile.am	(original)
+++ trunk/beagle/beagled/Makefile.am	Mon Jun 30 02:03:01 2008
@@ -253,7 +253,6 @@
 	$(EMPATHY_QUERYABLE_CSFILES)				\
 	$(LOCATE_QUERYABLE_CSFILES)				\
 	$(srcdir)/AssemblyInfo.cs				\
-	$(srcdir)/BatteryMonitor.cs				\
 	$(srcdir)/ExternalMetadataQueryable.cs			\
 	$(srcdir)/FileAttributes.cs				\
 	$(srcdir)/FileAttributesStore.cs			\



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