All pastes #268657 Raw Edit

Someone

public text v1 · immutable
·published 2006-12-05 22:10 UTC
rendered paste body
using System;
using System.Collections;
using System.Collections.Generic;

using NDesk.DBus;

namespace 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 [] GetAllDevices();
        bool DeviceExists(Device 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 DBusPropertyModifiedHandler(int modificationsLength, 
        PropertyModification [] modifications);
    
    [Interface("org.freedesktop.Hal.Device")]
    public interface Device
    {
        // TODO:
        // Need to support the Condition event, but it has a
        // variable number of arguments, not currently supported
        
        event DBusPropertyModifiedHandler PropertyModified;
    
        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);
        ulong GetProperty(string key); // nasty hack to get around the fact
                                       // that HAL doesn't actually send this
                                       // in a variant, nor does it have a 
                                       // GetPropertyUInt64
                                       // should be object 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')) 
    }
}