Esempio n. 1
0
		public static void Init ()
		{
			try {
				// Init System DBus
				NDesk.DBus.BusG.Init (NDesk.DBus.Bus.System);
			} catch (Exception e) {
				// Lack of specific exception
				Log.Error (e, "Failed to access dbus session bus. Battery monitoring will be disabled.");
				return;
			}

			try {
				Manager manager = new Manager (new Context ());

				foreach (Device device in manager.FindDeviceByCapability ("ac_adapter")) {
					Log.Debug ("Found HAL device AC adapter for battery monitoring.");
					
					device.PropertyModified += OnPropertyModified;
					adapter = device;
					
					prev_on_battery = ! device.GetPropertyBoolean ("ac_adapter.present");
					
					break;
				}
			} catch (Exception e) {
				Log.Error (e, "Failed to acquire a HAL device for battery monitoring");
			}
		}
Esempio n. 2
0
        public HalDeviceManager()
        {
            Manager manager = new Manager ();

            foreach (Hal.Device device in manager.FindDeviceByCapabilityAsDevice ("volume")) {
                if (IsIPod (device)) {
                    MaybeAddVolume (new Volume (device.Udi));
                }
            }

            manager.DeviceAdded += OnDeviceAdded;
            manager.DeviceRemoved += OnDeviceRemoved;
        }