Ejemplo 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");
			}
		}
Ejemplo n.º 2
0
		public ICollection<Device> FindDeviceStringMatch (string key, string value)
		{
			List<Device> devices = new List<Device> ();

			foreach (ObjectPath opath in manager.FindDeviceStringMatch (key, value)) {
				Device device = new Device (context, opath);
				devices.Add (device);
			}

			return devices;
		}
Ejemplo n.º 3
0
		public ICollection<Device> FindDeviceByCapability (string capability)
		{
			List<Device> devices = new List<Device> ();

			foreach (ObjectPath opath in manager.FindDeviceByCapability (capability)) {
				Device device = new Device (context, opath);
				devices.Add (device);
			}

			return devices;
		}
Ejemplo n.º 4
0
		public ICollection<Device> GetAllDevices ()
		{
			List<Device> devices = new List<Device> ();

			foreach (ObjectPath opath in manager.GetAllDevices ()) {
				Device device = new Device (context, opath);
				devices.Add (device);
			}

			return devices;
		}
Ejemplo n.º 5
0
        private bool IsMounted(Hal.Device device)
        {
            try {
                if (!device.PropertyExists("volume.mount_point"))
                {
                    return(false);
                }
            } catch {
                return(false);
            }

            string mountPoint = device.GetPropertyString("volume.mount_point");

            return(mountPoint != null && mountPoint != String.Empty);
        }
Ejemplo n.º 6
0
	public void ImportUdi (string udi)
	{
		/* probably a camera we need to contruct on of our gphoto2 uris */
		Hal.Device dev = new Hal.Device (Core.HalContext, udi);
		string mount_point = dev.GetPropertyString ("volume.mount_point");
		int bus = dev.GetPropertyInt ("usb.bus_number");
		int device = dev.GetPropertyInt ("usb.linux.device_number");
		System.Console.WriteLine ("dev = {1} exists = {2} mount_point = {0} {3},{4}", mount_point, dev, dev.Exists, bus, device);

		if (! dev.Exists || mount_point != null) {
			ImportFile (mount_point);
		} else {
			string gphoto_uri = String.Format ("gphoto2:usb:{0},{1}", bus.ToString ("d3") , device.ToString ("d3"));
			System.Console.WriteLine ("gphoto_uri = {0}", gphoto_uri);
			ImportCamera (gphoto_uri);
		} 
			
	}
Ejemplo n.º 7
0
		public AccessControl (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Ejemplo n.º 8
0
        public static Device[] UdisToDevices(Context ctx, string [] udis)
        {
            if(ctx == null) {
                return new Device[0];
            }

            Device [] devices = new Device[udis.Length];

            for(int i = 0; i < udis.Length; i++) {
                devices[i] = new Device(ctx, udis[i]);
            }

            return devices;
        }
Ejemplo n.º 9
0
		public Storage (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Ejemplo n.º 10
0
		public LaptopPanel (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Ejemplo n.º 11
0
		public SystemPowerManagement (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Ejemplo n.º 12
0
		public Device NewDevice ()
		{
			ObjectPath opath = manager.NewDevice ();
			Device device = new Device (context, opath);

			return device;
		}
Ejemplo n.º 13
0
		public bool DeviceExists (Device device)
		{
			return manager.DeviceExists (device.ObjectPath);
		}
Ejemplo n.º 14
0
		public KillSwitch (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Ejemplo n.º 15
0
 private bool IsIPod(Hal.Device device)
 {
     return(device.PropertyExists("org.podsleuth.version"));
 }
Ejemplo n.º 16
0
		public void Remove (Device udi)
		{
			manager.Remove (udi.ObjectPath);
		}
Ejemplo n.º 17
0
		public void CommitToGdl (Device tmp_udi, Device udi)
		{
			manager.CommitToGdl (tmp_udi.ObjectPath, udi.ObjectPath);
		}
Ejemplo n.º 18
0
		public Volume (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Ejemplo n.º 19
0
		public LightSensor (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}