All pastes #268900 Raw Edit

Stuff

public text v1 · immutable
·published 2006-12-06 02:56 UTC
rendered paste body
using System;
using System.Collections;
using System.Collections.Generic;

using NDesk.DBus;

namespace NDesk.Hal
{
	public delegate void DeviceAddedHandler (Device udi);
	public delegate void DeviceRemovedHandler (Device udi);
	public delegate void NewCapabilityHandler (Device udi, string capability);

	[Interface ("org.freedesktop.Hal.Manager")]
	public interface Manager
	{
		event DeviceAddedHandler DeviceAdded;
		event DeviceRemovedHandler DeviceRemoved;
		event NewCapabilityHandler NewCapability;

		Device[] AllDevices { get; }
		bool DeviceExists (Device udi);
		bool DeviceExists (ObjectPath udi);
		Device[] FindDeviceStringMatch (string key, string value);
		Device[] FindDeviceByCapability (string capability);
		void Remove  (Device udi);
		void CommitToGdl (string temporary_udi, string global_udi);
	}

	public struct PropertyModification
	{
		public string Key;
		public bool Added;
		public bool Removed;
	}

	public delegate void PropertyModifiedHandler (int modificationsLength, PropertyModification[] modifications);
	public delegate void ConditionHandler (string conditionName, string conditionDetail);

	[Interface ("org.freedesktop.Hal.Device")]
	public interface Device
	{
		event PropertyModifiedHandler PropertyModified;
		event ConditionHandler Condition;

		void SetPropertyString (string key, string value);
		void SetPropertyInteger (string key, int value);
		void SetPropertyBoolean (string key, bool value);
		void SetPropertyDouble (string key, double value);
		void SetPropertyStringList (string key, string[] value);

		void SetProperty (string key, ulong value);
		// Hack to make up for lack of GetPropertyUInt64
		ulong GetProperty (string key);

		string GetPropertyString (string key);
		int GetPropertyInteger (string key);
		bool GetPropertyBoolean (string key);
		double GetPropertyDouble (string key);
		string[] GetPropertyStringList (string key);

		IDictionary<string, object> GetAllProperties ();
		void RemoveProperty (string key);
		PropertyType GetPropertyType (string key);
		bool PropertyExists (string key);

		void AddCapability (string capability);
		bool QueryCapability (string capability);
		void Lock (string reason);
		void Unlock ();
	}

	public enum PropertyType
	{
		Invalid = DType.Invalid,
		Int32 = DType.Int32,
		UInt64 = DType.UInt64,
		Double = DType.Double,
		Boolean = DType.Boolean,
		String = DType.String,
		StrList =  ( (int) (DType.String << 8) +  ('l')) 
	}

	public static class Driver
	{
		public static Manager GetManager  ()
		{
			if (!Bus.System.NameHasOwner ("org.freedesktop.Hal"))
				throw new ApplicationException ("Could not find org.freedesktop.Hal");

			return Bus.System.GetObject<Manager> ("org.freedesktop.Hal", new ObjectPath ("/org/freedesktop/Hal/Manager"));
		}
	}
}