2005-01-25 Joe Shaw <joeshaw@novell.com>
authorJoe Shaw <joeshaw@novell.com>
Tue, 25 Jan 2005 19:47:13 +0000 (19:47 +0000)
committerJoe Shaw <joeshaw@novell.com>
Tue, 25 Jan 2005 19:47:13 +0000 (19:47 +0000)
* Land the mono binding changes to conform to the new APIs.

* mono/Makefile.am: Remove Custom.cs, DBusType/Custom.cs,
DBusType/Dict.cs, and DBusType/Nil.cs from the build.

* mono/Arguments.cs (GetCodeAsString): Added.  Returns the dbus
type code as a string.
(InitAppending): Rename dbus_message_append_iter_init() to
dbus_message_iter_init_append().

* mono/BusDriver.cs: Rename ServiceEventHandler to
NameOwnerChangedHandler.  Rename GetServiceOwner to GetOwner.
Rename ServiceOwnerChanged to NameOwnerChanged.

* mono/Connection.cs: Rename BaseService to UniqueName, and the
underlying C call.

* mono/Custom.cs: Removed.  The CUSTOM type has been removed.

* mono/Service.cs: Rename Exists to HasOwner, internally rename
dbus_bus_acquire_service() to dbus_bus_request_name().

* mono/DBusType/Array.cs (ctor): Use Type.GetElementType() instead
of Type.UnderlyingSystemType to get the correct element type for
the array.
(ctor): Update code for new APIs: use dbus_message_iter_recurse(),
dbus_message_get_{element|arg}_type() instead of
dbus_message_iter_init_array_iterator().
(Append): Replace dbus_message_iter_append_array() with
dbus_message_iter_open_container() and
dbus_message_iter_close_container().

* mono/DBusType/Custom.cs, mono/DBusType/Nil.cs: Removed.  These
types have been removed.

* mono/DBusType/*.cs: Replace calls of
dbus_message_iter_get_[type]() to dbus_message_iter_get_basic(),
but specify the type in the DllImport extern declaration.  Ditto
for dbus_message_iter_append_[type]() ->
dbus_message_iter_append_basic().

* mono/example/BusListener.cs: Update for ServiceEventHandler ->
NameOwnerChangedHandler.

20 files changed:
ChangeLog
mono/Arguments.cs
mono/BusDriver.cs
mono/Connection.cs
mono/Custom.cs [deleted file]
mono/DBusType/Array.cs
mono/DBusType/Boolean.cs
mono/DBusType/Byte.cs
mono/DBusType/Custom.cs [deleted file]
mono/DBusType/Double.cs
mono/DBusType/Int32.cs
mono/DBusType/Int64.cs
mono/DBusType/Nil.cs [deleted file]
mono/DBusType/ObjectPath.cs
mono/DBusType/String.cs
mono/DBusType/UInt32.cs
mono/DBusType/UInt64.cs
mono/Makefile.am
mono/Service.cs
mono/example/BusListener.cs

index 558bf74..7eb2699 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,49 @@
+2005-01-25  Joe Shaw  <joeshaw@novell.com>
+
+       * Land the mono binding changes to conform to the new APIs.
+
+       * mono/Makefile.am: Remove Custom.cs, DBusType/Custom.cs,
+       DBusType/Dict.cs, and DBusType/Nil.cs from the build.
+
+       * mono/Arguments.cs (GetCodeAsString): Added.  Returns the dbus
+       type code as a string.
+       (InitAppending): Rename dbus_message_append_iter_init() to
+       dbus_message_iter_init_append().
+
+       * mono/BusDriver.cs: Rename ServiceEventHandler to
+       NameOwnerChangedHandler.  Rename GetServiceOwner to GetOwner.
+       Rename ServiceOwnerChanged to NameOwnerChanged.
+
+       * mono/Connection.cs: Rename BaseService to UniqueName, and the
+       underlying C call.
+
+       * mono/Custom.cs: Removed.  The CUSTOM type has been removed.
+
+       * mono/Service.cs: Rename Exists to HasOwner, internally rename
+       dbus_bus_acquire_service() to dbus_bus_request_name().
+
+       * mono/DBusType/Array.cs (ctor): Use Type.GetElementType() instead
+       of Type.UnderlyingSystemType to get the correct element type for
+       the array.
+       (ctor): Update code for new APIs: use dbus_message_iter_recurse(),
+       dbus_message_get_{element|arg}_type() instead of
+       dbus_message_iter_init_array_iterator().
+       (Append): Replace dbus_message_iter_append_array() with
+       dbus_message_iter_open_container() and
+       dbus_message_iter_close_container().
+
+       * mono/DBusType/Custom.cs, mono/DBusType/Nil.cs: Removed.  These
+       types have been removed.
+       
+       * mono/DBusType/*.cs: Replace calls of
+       dbus_message_iter_get_[type]() to dbus_message_iter_get_basic(),
+       but specify the type in the DllImport extern declaration.  Ditto
+       for dbus_message_iter_append_[type]() ->
+       dbus_message_iter_append_basic().
+
+       * mono/example/BusListener.cs: Update for ServiceEventHandler ->
+       NameOwnerChangedHandler.
+
 2005-01-25  John (J5) Palmieri  <johnp@redhat.com>
 
        * python/dbus_bindings.pyx.in: Rename of methods and bindings
index b68ed5a..41e6d15 100644 (file)
@@ -183,6 +183,12 @@ namespace DBus
       return (char) dbusType.InvokeMember("Code", BindingFlags.Static | BindingFlags.GetField, null, null, null);
     }
 
+    // Get the type code for a given D-BUS type as a string
+    public static string GetCodeAsString (Type dbusType)
+    {
+      return GetCode (dbusType).ToString ();
+    }
+
     // Get a complete method signature
     public override string ToString() 
     {
@@ -201,7 +207,7 @@ namespace DBus
          key += code;
        } while (dbus_message_iter_next(iter));
       }
-      
+
       Marshal.FreeCoTaskMem(iter);
 
       return key;
@@ -217,7 +223,7 @@ namespace DBus
     // Begin appending
     public void InitAppending() 
     {
-      dbus_message_append_iter_init(message.RawMessage, appenderIter);
+      dbus_message_iter_init_append(message.RawMessage, appenderIter);
     }
 
     // Get the enumerator
@@ -277,7 +283,7 @@ namespace DBus
     }
 
     [DllImport("dbus-1")]
-    private extern static void dbus_message_append_iter_init(IntPtr rawMessage, IntPtr iter);
+    private extern static void dbus_message_iter_init_append(IntPtr rawMessage, IntPtr iter);
 
     [DllImport("dbus-1")]
     private extern static bool dbus_message_iter_has_next(IntPtr iter);
index 426dd37..b5885a3 100644 (file)
@@ -3,9 +3,9 @@ namespace DBus
 
   using System;
 
-  public delegate void ServiceEventHandler (string serviceName,
-                                           string oldOwner,
-                                           string newOwner);
+  public delegate void NameOwnerChangedHandler (string name,
+                                               string oldOwner,
+                                               string newOwner);
 
   [Interface ("org.freedesktop.DBus")]
   public abstract class BusDriver
@@ -14,14 +14,14 @@ namespace DBus
     public abstract string[] ListServices ();
 
     [Method]
-    public abstract string GetServiceOwner (string serviceName);
+    public abstract string GetOwner (string name);
 
     [Method]
     public abstract UInt32 GetConnectionUnixUser (string connectionName);
 
 
     [Signal]
-    public virtual event ServiceEventHandler ServiceOwnerChanged;
+    public virtual event NameOwnerChangedHandler NameOwnerChanged;
 
     static public BusDriver New (Connection connection)
     {
index acc6ef6..2d98f64 100644 (file)
@@ -76,11 +76,11 @@ namespace DBus
       return new Connection(rawConnection);
     }
 
-    public string BaseService
+    public string UniqueName
     {
       get
        {
-         return Marshal.PtrToStringAnsi (dbus_bus_get_base_service (RawConnection));
+         return Marshal.PtrToStringAnsi (dbus_bus_get_unique_name (RawConnection));
        }
     }
 
@@ -192,6 +192,6 @@ namespace DBus
     private extern static void dbus_connection_disconnect (IntPtr ptr);
 
     [DllImport ("dbus-1")]
-    private extern static IntPtr dbus_bus_get_base_service (IntPtr ptr);
+    private extern static IntPtr dbus_bus_get_unique_name (IntPtr ptr);
   }
 }
diff --git a/mono/Custom.cs b/mono/Custom.cs
deleted file mode 100644 (file)
index f96562b..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-
-using DBus;
-
-namespace DBus
-{
-  public struct Custom
-  {
-    public string Name;
-    public byte[] Data;
-    
-    public Custom(string name, byte[] data) 
-    {
-      Name = name;
-      Data = data;
-    }
-  }
-}
index dd93a5c..7e46f73 100644 (file)
@@ -25,7 +25,7 @@ namespace DBus.DBusType
     public Array(System.Array val, Service service) 
     {
       this.val = val;
-      this.elementType = Arguments.MatchType(val.GetType().UnderlyingSystemType);
+      this.elementType = Arguments.MatchType(val.GetType().GetElementType());
       this.service = service;
     }
 
@@ -34,36 +34,37 @@ namespace DBus.DBusType
       this.service = service;
 
       IntPtr arrayIter = Marshal.AllocCoTaskMem(Arguments.DBusMessageIterSize);
-      
-      int elementTypeCode;
-      bool notEmpty = dbus_message_iter_init_array_iterator(iter, arrayIter, out elementTypeCode);
-      this.elementType = (Type) Arguments.DBusTypes[(char) elementTypeCode];
 
-      elements = new ArrayList();
+      int elementTypeCode = dbus_message_iter_get_element_type (iter);
+      dbus_message_iter_recurse (iter, arrayIter);
+      this.elementType = (Type) Arguments.DBusTypes [(char) elementTypeCode];
+
+      elements = new ArrayList ();
 
-      if (notEmpty) {
-       do {
-         object [] pars = new Object[2];
+      if (dbus_message_iter_get_arg_type (arrayIter) != 0) {
+        do {
+          object [] pars = new Object[2];
          pars[0] = arrayIter;
-         pars[1] = service;
+         pars[1] = service;
          DBusType.IDBusType dbusType = (DBusType.IDBusType) Activator.CreateInstance(elementType, pars);
          elements.Add(dbusType);
-       } while (dbus_message_iter_next(arrayIter));
-      }
-      
+        } while (dbus_message_iter_next(arrayIter));
+      }      
+
       Marshal.FreeCoTaskMem(arrayIter);
     }
     
     public void Append(IntPtr iter)
     {
-      IntPtr arrayIter = Marshal.AllocCoTaskMem(Arguments.DBusMessageIterSize);
+      IntPtr arrayIter = Marshal.AllocCoTaskMem (Arguments.DBusMessageIterSize);
 
-      if (!dbus_message_iter_append_array(iter,
-                                         arrayIter,
-                                         (int) Arguments.GetCode(this.elementType))) {
-       throw new ApplicationException("Failed to append INT32 argument:" + val);
+      if (!dbus_message_iter_open_container (iter,
+                                            (int) this.Code,
+                                            Arguments.GetCodeAsString (elementType),
+                                            arrayIter)) {
+       throw new ApplicationException("Failed to append array argument: " + val);
       }
-
+      
       foreach (object element in this.val) {
        object [] pars = new Object[2];
        pars[0] = element;
@@ -72,7 +73,11 @@ namespace DBus.DBusType
        dbusType.Append(arrayIter);
       }
 
-      Marshal.FreeCoTaskMem(arrayIter);
+      if (!dbus_message_iter_close_container (iter, arrayIter)) {
+       throw new ApplicationException ("Failed to append array argument: " + val);
+      }
+
+      Marshal.FreeCoTaskMem (arrayIter);
     }    
 
     public static bool Suits(System.Type type) 
@@ -107,7 +112,7 @@ namespace DBus.DBusType
     public object Get(System.Type type)
     {
       if (type.IsArray)
-        type = type.GetElementType ();
+       type = type.GetElementType ();
 
       if (Arguments.Suits(elementType, type.UnderlyingSystemType)) {
        this.val = System.Array.CreateInstance(type.UnderlyingSystemType, elements.Count);
@@ -123,19 +128,28 @@ namespace DBus.DBusType
     }    
 
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_init_array_iterator(IntPtr iter,
-                                                                    IntPtr arrayIter,
-                                                                    out int elementType);
+    private extern static bool dbus_message_iter_open_container (IntPtr iter,
+                                                                int containerType,
+                                                                string elementType,
+                                                                IntPtr subIter);
+
+    [DllImport("dbus-1")]
+    private extern static bool dbus_message_iter_close_container (IntPtr iter,
+                                                                 IntPtr subIter);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_array(IntPtr iter, 
-                                                             IntPtr arrayIter,
-                                                             int elementType);
+    private extern static int dbus_message_iter_get_element_type(IntPtr iter);
 
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_has_next(IntPtr iter);
+    private extern static int dbus_message_iter_get_arg_type(IntPtr iter);
+
+    [DllImport("dbus-1")]
+    private extern static void dbus_message_iter_recurse(IntPtr iter, IntPtr subIter);
 
     [DllImport("dbus-1")]
     private extern static bool dbus_message_iter_next(IntPtr iter);
+
+    [DllImport("dbus-1")]
+    private extern static bool dbus_message_iter_has_next (IntPtr iter);
   }
 }
index fa5e1bc..c561f0c 100644 (file)
@@ -25,12 +25,12 @@ namespace DBus.DBusType
 
     public Boolean(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_boolean(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_boolean(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
        throw new ApplicationException("Failed to append BOOLEAN argument:" + val);
     }
 
@@ -78,9 +78,9 @@ namespace DBus.DBusType
     }
 
     [DllImport("dbus-1")]
-    private extern static System.Boolean dbus_message_iter_get_boolean(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out bool value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_boolean(IntPtr iter, System.Boolean value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref bool value);
   }
 }
index 2fb19ae..958f683 100644 (file)
@@ -30,12 +30,12 @@ namespace DBus.DBusType
 
     public Byte(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_byte(iter);
-    }
+      dbus_message_iter_get_basic (iter, out this.val);
+      }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_byte(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
        throw new ApplicationException("Failed to append BYTE argument:" + val);
     }
 
@@ -97,9 +97,9 @@ namespace DBus.DBusType
     }
 
     [DllImport("dbus-1")]
-    private extern static System.Byte dbus_message_iter_get_byte(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out byte value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_byte(IntPtr iter, System.Byte value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref byte value);
   }
 }
diff --git a/mono/DBusType/Custom.cs b/mono/DBusType/Custom.cs
deleted file mode 100644 (file)
index 9256064..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using System.Reflection.Emit;
-
-using DBus;
-
-namespace DBus.DBusType
-{
-  /// <summary>
-  /// A named byte array, used for custom types.
-  /// </summary>
-  public class Custom : IDBusType
-  {
-    public const char Code = 'c';
-    private DBus.Custom val;
-    
-    private Custom()
-    {
-    }
-    
-    public Custom(DBus.Custom val, Service service) 
-    {
-      this.val = val;
-    }
-
-    public Custom(IntPtr iter, Service service)
-    {
-      string name;
-      IntPtr value;
-      int len;
-
-      if (!dbus_message_iter_get_custom(iter, out name, out value, out len)) {
-       throw new ApplicationException("Failed to get CUSTOM argument.");
-      }
-
-      this.val.Name = name;
-      this.val.Data = new byte[len];
-      Marshal.Copy(value, this.val.Data, 0, len);
-    }
-    
-    public void Append(IntPtr iter)
-    {
-      IntPtr data = Marshal.AllocCoTaskMem(this.val.Data.Length);
-      try {
-       Marshal.Copy(this.val.Data, 0, data, this.val.Data.Length);
-       if (!dbus_message_iter_append_custom(iter, this.val.Name, data, this.val.Data.Length)) {
-         throw new ApplicationException("Failed to append CUSTOM argument:" + val);
-       }
-      } finally {
-       Marshal.FreeCoTaskMem(data);
-      }
-    }
-
-    public static bool Suits(System.Type type) 
-    {
-      switch (type.ToString()) {
-      case "DBus.Custom":
-      case "DBus.Custom&":
-       return true;
-      }
-      
-      return false;
-    }
-
-    public static void EmitMarshalIn(ILGenerator generator, Type type)
-    {
-      if (type.IsByRef) {
-       generator.Emit(OpCodes.Ldobj, type);
-      }
-    }
-
-    public static void EmitMarshalOut(ILGenerator generator, Type type, bool isReturn) 
-    {
-      generator.Emit(OpCodes.Unbox, type);
-      generator.Emit(OpCodes.Ldobj, type);
-      if (!isReturn) {
-       generator.Emit(OpCodes.Stobj, type);
-      }
-    }
-    
-    public object Get() 
-    {
-      return this.val;
-    }
-
-    public object Get(System.Type type)
-    {
-      switch (type.ToString()) {
-      case "DBus.Custom":
-      case "DBus.Custom&":
-       return this.val;
-      default:
-       throw new ArgumentException("Cannot cast DBus.Type.Custom to type '" + type.ToString() + "'");
-      }
-    }
-
-    [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_get_custom(IntPtr iter,
-                                                           out string name,
-                                                           out IntPtr value,
-                                                           out int len);
-    [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_custom(IntPtr iter, 
-                                                              string name,
-                                                              IntPtr data,
-                                                              int len);
-  }
-}
index 008f682..c8975cd 100644 (file)
@@ -25,12 +25,12 @@ namespace DBus.DBusType
 
     public Double(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_double(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_double(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
        throw new ApplicationException("Failed to append DOUBLE argument:" + val);
     }
 
@@ -78,9 +78,9 @@ namespace DBus.DBusType
     }
 
     [DllImport("dbus-1")]
-    private extern static System.Double dbus_message_iter_get_double(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out double value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_double(IntPtr iter, System.Double value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref double value);
   }
 }
index a759b79..868d433 100644 (file)
@@ -25,12 +25,12 @@ namespace DBus.DBusType
 
     public Int32(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_int32(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_int32(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
        throw new ApplicationException("Failed to append INT32 argument:" + val);
     }
 
@@ -85,9 +85,9 @@ namespace DBus.DBusType
     }    
 
     [DllImport("dbus-1")]
-    private extern static System.Int32 dbus_message_iter_get_int32(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.Int32 value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_int32(IntPtr iter, System.Int32 value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.Int32 value);
   }
 }
index 6aea7ee..47c066b 100644 (file)
@@ -25,12 +25,12 @@ namespace DBus.DBusType
 
     public Int64(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_int64(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_int64(iter, val))
+           if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
        throw new ApplicationException("Failed to append INT64 argument:" + val);
     }
 
@@ -86,9 +86,9 @@ namespace DBus.DBusType
     }    
 
     [DllImport("dbus-1")]
-    private extern static System.Int64 dbus_message_iter_get_int64(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.Int64 value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_int64(IntPtr iter, System.Int64 value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.Int64 value);
   }
 }
diff --git a/mono/DBusType/Nil.cs b/mono/DBusType/Nil.cs
deleted file mode 100644 (file)
index a271db3..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using System.Reflection.Emit;
-
-using DBus;
-
-namespace DBus.DBusType
-{
-  /// <summary>
-  /// Marks a "void"/"unset"/"nonexistent"/"null" argument.
-  /// </summary>
-  public class Nil : IDBusType
-  {
-    public const char Code = 'v';
-    
-    private Nil()
-    {
-    }
-    
-    public Nil(object nil, Service service) 
-    {
-    }
-
-    public Nil(IntPtr iter, Service service)
-    {
-    }
-    
-    public void Append(IntPtr iter)
-    {
-      if (!dbus_message_iter_append_nil(iter))
-       throw new ApplicationException("Failed to append NIL argument");
-    }
-
-    public static bool Suits(System.Type type) 
-    {
-      return false;
-    }
-
-    public static void EmitMarshalIn(ILGenerator generator, Type type)
-    {
-      if (type.IsByRef) {
-       generator.Emit(OpCodes.Ldind_I1);
-      }
-    }
-
-    public static void EmitMarshalOut(ILGenerator generator, Type type, bool isReturn) 
-    {
-      generator.Emit(OpCodes.Unbox, type);
-      generator.Emit(OpCodes.Ldind_I1);
-      if (!isReturn) {
-       generator.Emit(OpCodes.Stind_I1);
-      }
-    }
-    
-    public object Get() 
-    {
-      return null;
-    }
-
-    public object Get(System.Type type)
-    {
-      throw new ArgumentException("Cannot cast DBus.Type.Nil to type '" + type.ToString() + "'");
-    }
-
-    [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_nil(IntPtr iter);
-  }
-}
index f82c680..01a21ca 100644 (file)
@@ -28,8 +28,11 @@ namespace DBus.DBusType
     
     public ObjectPath(IntPtr iter, Service service)
     {
-      
-      this.path = Marshal.PtrToStringAnsi(dbus_message_iter_get_object_path(iter));
+      IntPtr raw;
+
+      dbus_message_iter_get_basic (iter, out raw);
+
+      this.path = Marshal.PtrToStringAnsi (raw);
       this.service = service;
     }
 
@@ -47,7 +50,9 @@ namespace DBus.DBusType
 
     public void Append(IntPtr iter) 
     {
-      if (!dbus_message_iter_append_object_path(iter, Marshal.StringToHGlobalAnsi(Path)))
+      IntPtr marshalVal = Marshal.StringToHGlobalAnsi (Path);
+
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal))
        throw new ApplicationException("Failed to append OBJECT_PATH argument:" + val);
     }
 
@@ -91,9 +96,9 @@ namespace DBus.DBusType
     }
 
     [DllImport("dbus-1")]
-    private extern static IntPtr dbus_message_iter_get_object_path(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out IntPtr path);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_object_path(IntPtr iter, IntPtr path);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref IntPtr path);
   }
 }
index bced310..bf354ea 100644 (file)
@@ -25,12 +25,18 @@ namespace DBus.DBusType
     
     public String(IntPtr iter, Service service)
     {
-      this.val = Marshal.PtrToStringAnsi(dbus_message_iter_get_string(iter));
+      IntPtr raw;
+
+      dbus_message_iter_get_basic (iter, out raw);
+
+      this.val = Marshal.PtrToStringAnsi (raw);
     }
 
     public void Append(IntPtr iter) 
     {
-      if (!dbus_message_iter_append_string(iter, Marshal.StringToHGlobalAnsi(val)))
+      IntPtr marshalVal = Marshal.StringToHGlobalAnsi (val);
+
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal))
        throw new ApplicationException("Failed to append STRING argument:" + val);
     }
 
@@ -78,9 +84,9 @@ namespace DBus.DBusType
     }    
 
     [DllImport("dbus-1")]
-    private extern static IntPtr dbus_message_iter_get_string(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out IntPtr value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_string(IntPtr iter, IntPtr value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref IntPtr value);
   }
 }
index b55893d..5bb3121 100644 (file)
@@ -25,12 +25,12 @@ namespace DBus.DBusType
 
     public UInt32(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_uint32(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_uint32(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
        throw new ApplicationException("Failed to append UINT32 argument:" + val);
     }
 
@@ -87,9 +87,9 @@ namespace DBus.DBusType
     }    
 
     [DllImport("dbus-1")]
-    private extern static System.UInt32 dbus_message_iter_get_uint32(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.UInt32 value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_uint32(IntPtr iter, System.UInt32 value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.UInt32 value);
   }
 }
index c987a91..ef689f2 100644 (file)
@@ -25,12 +25,12 @@ namespace DBus.DBusType
 
     public UInt64(IntPtr iter, Service service)
     {
-      this.val = dbus_message_iter_get_uint64(iter);
+      dbus_message_iter_get_basic (iter, out this.val);
     }
     
     public void Append(IntPtr iter)
     {
-      if (!dbus_message_iter_append_uint64(iter, val))
+      if (!dbus_message_iter_append_basic (iter, (int) Code, ref val))
        throw new ApplicationException("Failed to append UINT64 argument:" + val);
     }
 
@@ -87,9 +87,9 @@ namespace DBus.DBusType
     }    
 
     [DllImport("dbus-1")]
-    private extern static System.UInt64 dbus_message_iter_get_uint64(IntPtr iter);
+    private extern static void dbus_message_iter_get_basic (IntPtr iter, out System.UInt64 value);
  
     [DllImport("dbus-1")]
-    private extern static bool dbus_message_iter_append_uint64(IntPtr iter, System.UInt64 value);
+    private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref System.UInt64 value);
   }
 }
index 0a53f74..02223f1 100644 (file)
@@ -10,7 +10,6 @@ DBUS_SHARP_FILES=                             \
        $(srcdir)/Bus.cs                        \
        $(srcdir)/BusDriver.cs                  \
        $(srcdir)/Connection.cs                 \
-       $(srcdir)/Custom.cs                     \
        $(srcdir)/DBusException.cs              \
        $(srcdir)/Error.cs                      \
        $(srcdir)/ErrorMessage.cs               \
@@ -31,12 +30,9 @@ DBUS_SHARP_FILES=                            \
        $(srcdir)/DBusType/Array.cs             \
        $(srcdir)/DBusType/Boolean.cs           \
        $(srcdir)/DBusType/Byte.cs              \
-       $(srcdir)/DBusType/Custom.cs            \
-       $(srcdir)/DBusType/Dict.cs              \
        $(srcdir)/DBusType/Double.cs            \
        $(srcdir)/DBusType/Int32.cs             \
        $(srcdir)/DBusType/Int64.cs             \
-       $(srcdir)/DBusType/Nil.cs               \
        $(srcdir)/DBusType/ObjectPath.cs        \
        $(srcdir)/DBusType/String.cs            \
        $(srcdir)/DBusType/UInt32.cs            \
index 35a2584..5f6ff4c 100644 (file)
@@ -38,7 +38,7 @@ namespace DBus
       // This isn't used for now
       uint flags = 0;
 
-      if (dbus_bus_acquire_service(connection.RawConnection, name, flags, ref error) == -1) {
+      if (dbus_bus_request_name (connection.RawConnection, name, flags, ref error) == -1) {
        throw new DBusException(error);
       }
 
@@ -47,12 +47,12 @@ namespace DBus
       this.local = true;
     }
 
-    public static bool Exists(Connection connection, string name)
+    public static bool HasOwner(Connection connection, string name)
     {
       Error error = new Error();
       error.Init();
       
-      if (dbus_bus_service_exists(connection.RawConnection, 
+      if (dbus_bus_name_has_owner(connection.RawConnection, 
                                  name, 
                                  ref error)) {
        return true;
@@ -66,10 +66,10 @@ namespace DBus
 
     public static Service Get(Connection connection, string name)
     {
-      if (Exists(connection, name)) {
+      if (HasOwner(connection, name)) {
        return new Service(name, connection);
       } else {
-       throw new ApplicationException("Service '" + name + "' does not exist.");
+       throw new ApplicationException("Name '" + name + "' does not exist.");
       }
     }
 
@@ -184,12 +184,12 @@ namespace DBus
     }
 
     [DllImport("dbus-1")]
-    private extern static int dbus_bus_acquire_service(IntPtr rawConnection, 
-                                                       string serviceName, 
-                                                       uint flags, ref Error error);
+    private extern static int dbus_bus_request_name(IntPtr rawConnection, 
+                                                   string serviceName, 
+                                                   uint flags, ref Error error);
 
     [DllImport("dbus-1")]
-    private extern static bool dbus_bus_service_exists(IntPtr rawConnection, 
+    private extern static bool dbus_bus_name_has_owner(IntPtr rawConnection, 
                                                       string serviceName, 
                                                       ref Error error);    
 
index 8af83d8..d999360 100644 (file)
@@ -7,19 +7,19 @@ namespace Foo
        public class BusListener
        {
 
-               static void OnServiceOwnerChanged (string serviceName,
-                                                  string oldOwner,
-                                                  string newOwner)
+               static void OnNameOwnerChanged (string name,
+                                               string oldOwner,
+                                               string newOwner)
                {
                        if (oldOwner == "")
                                Console.WriteLine ("{0} created by {1}",
-                                                  serviceName, newOwner);
+                                                  name, newOwner);
                        else if (newOwner == "")
                                Console.WriteLine ("{0} released by {1}", 
-                                                  serviceName, oldOwner);
+                                                  name, oldOwner);
                        else
                                Console.WriteLine ("{0} transfered from {1} to {2}",
-                                                  serviceName, oldOwner, newOwner);
+                                                  name, oldOwner, newOwner);
                }
 
                public static int Main (string [] args)
@@ -30,9 +30,9 @@ namespace Foo
                        connection = Bus.GetSessionBus ();
 
                        BusDriver driver = BusDriver.New (connection);
-                       driver.ServiceOwnerChanged += new ServiceEventHandler (OnServiceOwnerChanged);
+                       driver.NameOwnerChanged += new NameOwnerChangedHandler (OnNameOwnerChanged);
 
-                       Console.WriteLine ("Listening for service changes...");
+                       Console.WriteLine ("Listening for name owner changes...");
 
                        Application.Run ();