Пример #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");
			}
		}
Пример #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;
		}
Пример #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;
		}
Пример #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;
		}
Пример #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);
        }
	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);
		} 
			
	}
Пример #7
0
		public AccessControl (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Пример #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;
        }
Пример #9
0
		public Storage (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Пример #10
0
		public LaptopPanel (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
		public SystemPowerManagement (Context context, Device device)
			: this (context, device.ObjectPath)
		{
		}
Пример #12
0
		public Device NewDevice ()
		{
			ObjectPath opath = manager.NewDevice ();
			Device device = new Device (context, opath);

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