dbus/mono Arguments.cs, 1.5, 1.6 Connection.cs, 1.7,
1.8 DBusException.cs, 1.1, 1.2 Error.cs, 1.3, 1.4 Message.cs,
1.8, 1.9 MethodCall.cs, 1.1, 1.2 Test.cs, 1.5, 1.6
Jon Trowbridge
trow at freedesktop.org
Sun Aug 29 11:14:33 PDT 2004
- Previous message: dbus/dbus dbus-spawn.c, 1.17, 1.18 dbus-sysdeps.c, 1.77,
1.78 dbus-userdb.c, 1.10, 1.11
- Next message: dbus/mono/DBusType Array.cs, 1.4, 1.5 Boolean.cs, 1.2, 1.3 Byte.cs,
1.4, 1.5 Custom.cs, 1.2, 1.3 Dict.cs, 1.4, 1.5 Double.cs, 1.2,
1.3 IDBusType.cs, 1.1, 1.2 Int32.cs, 1.3, 1.4 Int64.cs, 1.3,
1.4 Nil.cs, 1.2, 1.3 ObjectPath.cs, 1.4, 1.5 String.cs, 1.2,
1.3 UInt32.cs, 1.3, 1.4 UInt64.cs, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvs/dbus/dbus/mono
In directory gabe:/tmp/cvs-serv4743
Modified Files:
Arguments.cs Connection.cs DBusException.cs Error.cs
Message.cs MethodCall.cs Test.cs
Log Message:
Mapped CRLF -> LF for consistency.
Index: Arguments.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Arguments.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Arguments.cs 1 May 2004 19:59:58 -0000 1.5
+++ Arguments.cs 29 Aug 2004 18:14:30 -0000 1.6
@@ -1,285 +1,285 @@
-using System;
-using System.Collections;
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-namespace DBus
-{
- // Holds the arguments of a message. Provides methods for appending
- // arguments and to assist in matching .NET types with D-BUS types.
- public class Arguments : IEnumerable
- {
- // Must follow sizeof(DBusMessageIter)
- internal const int DBusMessageIterSize = 14*4;
- private static Hashtable dbusTypes = null;
- private Message message;
- private IntPtr appenderIter = Marshal.AllocCoTaskMem(DBusMessageIterSize);
- private IEnumerator enumerator = null;
-
- internal Arguments()
- {
- }
-
- ~Arguments()
- {
- Marshal.FreeCoTaskMem(appenderIter);
- }
-
- internal Arguments(Message message)
- {
- this.message = message;
- }
-
- // Checks the suitability of a D-BUS type for supporting a .NET
- // type.
- public static bool Suits(Type dbusType, Type type)
- {
- object [] pars = new object[1];
- pars[0] = type;
-
- return (bool) dbusType.InvokeMember("Suits", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, null, pars, null);
- }
-
- // Find a suitable match for the given .NET type or throw an
- // exception if one can't be found.
- public static Type MatchType(Type type)
- {
- foreach(Type dbusType in DBusTypes.Values) {
- if (Suits(dbusType, type)) {
- return dbusType;
- }
- }
-
- throw new ApplicationException("No suitable DBUS type found for type '" + type + "'");
- }
-
- // The D-BUS types.
- public static Hashtable DBusTypes {
- get
- {
- if (dbusTypes == null) {
- dbusTypes = new Hashtable();
-
- foreach (Type type in Assembly.GetAssembly(typeof(DBusType.IDBusType)).GetTypes()) {
- if (type != typeof(DBusType.IDBusType) && typeof(DBusType.IDBusType).IsAssignableFrom(type)) {
- dbusTypes.Add(GetCode(type), type);
- }
- }
- }
-
- return dbusTypes;
- }
- }
-
- // Append an argument
- public void Append(DBusType.IDBusType dbusType)
- {
- dbusType.Append(appenderIter);
- }
-
- // Append an argument of the specified type
- private void AppendType(Type type, object val)
- {
- object [] pars = new Object[2];
- pars[0] = val;
- pars[1] = message.Service;
- DBusType.IDBusType dbusType = (DBusType.IDBusType) Activator.CreateInstance(MatchType(type), pars);
- Append(dbusType);
- }
-
- // Append the results of a method call
- public void AppendResults(MethodInfo method, object retVal, object [] parameters)
- {
- InitAppending();
-
- if (method.ReturnType != typeof(void)) {
- AppendType(method.ReturnType, retVal);
- }
-
- for (int i = 0; i < method.GetParameters().Length; i++) {
- ParameterInfo par = method.GetParameters()[i];
- if (par.IsOut || par.ParameterType.ToString().EndsWith("&")) {
- // It's an OUT or INOUT parameter.
- AppendType(par.ParameterType.UnderlyingSystemType, parameters[i]);
- }
- }
- }
-
- // Get the parameters
- public object[] GetParameters(MethodInfo method)
- {
- ParameterInfo[] pars = method.GetParameters();
- ArrayList paramList = new ArrayList();
-
- enumerator = GetEnumerator();
- foreach (ParameterInfo par in pars) {
- if (!par.IsOut) {
- // It's an IN or INOUT paramter.
- enumerator.MoveNext();
- DBusType.IDBusType dbusType = (DBusType.IDBusType) enumerator.Current;
- paramList.Add(dbusType.Get(par.ParameterType));
- } else {
- // It's an OUT so just create a parameter for it
- object var = null;
- paramList.Add(var);
- }
- }
-
- return paramList.ToArray();
- }
-
- // Parse the IN & REF parameters to a method and return the types in a list.
- public static object[] ParseInParameters(MethodInfo method)
- {
- ArrayList types = new ArrayList();
-
- ParameterInfo[] pars = method.GetParameters();
- foreach (ParameterInfo par in pars) {
- if (!par.IsOut) {
- types.Add(MatchType(par.ParameterType));
- }
- }
-
- return types.ToArray();
- }
-
- // Parse the OUT & REF parameters to a method and return the types in a list.
- public static object[] ParseOutParameters(MethodInfo method)
- {
- ArrayList types = new ArrayList();
-
- ParameterInfo[] pars = method.GetParameters();
- foreach (ParameterInfo par in pars) {
- if (par.IsOut || par.ParameterType.ToString().EndsWith("&")) {
- types.Add(MatchType(par.ParameterType));
- }
- }
-
- return types.ToArray();
- }
-
- // Get the appropriate constructor for a D-BUS type
- public static ConstructorInfo GetDBusTypeConstructor(Type dbusType, Type type)
- {
- ConstructorInfo constructor = dbusType.GetConstructor(new Type[] {type.UnderlyingSystemType, typeof(Service)});
- if (constructor == null)
- throw new ArgumentException("There is no valid constructor for '" + dbusType + "' from type '" + type + "'");
-
- return constructor;
- }
-
- // Get the type code for a given D-BUS type
- public static char GetCode(Type dbusType)
- {
- return (char) dbusType.InvokeMember("Code", BindingFlags.Static | BindingFlags.GetField, null, null, null);
- }
-
- // Get a complete method signature
- public override string ToString()
- {
- IntPtr iter = Marshal.AllocCoTaskMem(DBusMessageIterSize);
- string key = "";
-
- // Iterate through the parameters getting the type codes to a string
- bool notEmpty = dbus_message_iter_init(message.RawMessage, iter);
-
- if (notEmpty) {
- do {
- char code = (char) dbus_message_iter_get_arg_type(iter);
- if (code == '\0')
- return key;
-
- key += code;
- } while (dbus_message_iter_next(iter));
- }
-
- Marshal.FreeCoTaskMem(iter);
-
- return key;
- }
-
- // Move to the next parameter
- public DBusType.IDBusType GetNext()
- {
- enumerator.MoveNext();
- return (DBusType.IDBusType) enumerator.Current;
- }
-
- // Begin appending
- public void InitAppending()
- {
- dbus_message_append_iter_init(message.RawMessage, appenderIter);
- }
-
- // Get the enumerator
- public IEnumerator GetEnumerator()
- {
- return new ArgumentsEnumerator(this);
- }
-
- private class ArgumentsEnumerator : IEnumerator
- {
- private Arguments arguments;
- private bool started = false;
- private bool notEmpty = false;
- private IntPtr iter = Marshal.AllocCoTaskMem(Arguments.DBusMessageIterSize);
-
- public ArgumentsEnumerator(Arguments arguments)
- {
- this.arguments = arguments;
- Reset();
- }
-
- ~ArgumentsEnumerator()
- {
- Marshal.FreeCoTaskMem(iter);
- }
-
- public bool MoveNext()
- {
- if (started) {
- return dbus_message_iter_next(iter);
- } else {
- started = true;
- return notEmpty;
- }
- }
-
- public void Reset()
- {
- notEmpty = dbus_message_iter_init(arguments.message.RawMessage, iter);
- started = false;
- }
-
- public object Current
- {
- get
- {
- object [] pars = new Object[2];
- pars[0] = iter;
- pars[1] = arguments.message.Service;
-
- Type type = (Type) DBusTypes[(char) dbus_message_iter_get_arg_type(iter)];
- DBusType.IDBusType dbusType = (DBusType.IDBusType) Activator.CreateInstance(type, pars);
-
- return dbusType;
- }
- }
- }
-
- [DllImport("dbus-1")]
- private extern static void dbus_message_append_iter_init(IntPtr rawMessage, IntPtr iter);
-
- [DllImport("dbus-1")]
- private extern static bool dbus_message_iter_has_next(IntPtr iter);
-
- [DllImport("dbus-1")]
- private extern static bool dbus_message_iter_next(IntPtr iter);
-
- [DllImport("dbus-1")]
- private extern static bool dbus_message_iter_init(IntPtr rawMessage, IntPtr iter);
-
- [DllImport("dbus-1")]
- private extern static int dbus_message_iter_get_arg_type(IntPtr iter);
- }
-}
+using System;
+using System.Collections;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+namespace DBus
+{
+ // Holds the arguments of a message. Provides methods for appending
+ // arguments and to assist in matching .NET types with D-BUS types.
+ public class Arguments : IEnumerable
+ {
+ // Must follow sizeof(DBusMessageIter)
+ internal const int DBusMessageIterSize = 14*4;
+ private static Hashtable dbusTypes = null;
+ private Message message;
+ private IntPtr appenderIter = Marshal.AllocCoTaskMem(DBusMessageIterSize);
+ private IEnumerator enumerator = null;
+
+ internal Arguments()
+ {
+ }
+
+ ~Arguments()
+ {
+ Marshal.FreeCoTaskMem(appenderIter);
+ }
+
+ internal Arguments(Message message)
+ {
+ this.message = message;
+ }
+
+ // Checks the suitability of a D-BUS type for supporting a .NET
+ // type.
+ public static bool Suits(Type dbusType, Type type)
+ {
+ object [] pars = new object[1];
+ pars[0] = type;
+
+ return (bool) dbusType.InvokeMember("Suits", BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, null, pars, null);
+ }
+
+ // Find a suitable match for the given .NET type or throw an
+ // exception if one can't be found.
+ public static Type MatchType(Type type)
+ {
+ foreach(Type dbusType in DBusTypes.Values) {
+ if (Suits(dbusType, type)) {
+ return dbusType;
+ }
+ }
+
+ throw new ApplicationException("No suitable DBUS type found for type '" + type + "'");
+ }
+
+ // The D-BUS types.
+ public static Hashtable DBusTypes {
+ get
+ {
+ if (dbusTypes == null) {
+ dbusTypes = new Hashtable();
+
+ foreach (Type type in Assembly.GetAssembly(typeof(DBusType.IDBusType)).GetTypes()) {
+ if (type != typeof(DBusType.IDBusType) && typeof(DBusType.IDBusType).IsAssignableFrom(type)) {
+ dbusTypes.Add(GetCode(type), type);
+ }
+ }
+ }
+
+ return dbusTypes;
+ }
+ }
+
+ // Append an argument
+ public void Append(DBusType.IDBusType dbusType)
+ {
+ dbusType.Append(appenderIter);
+ }
+
+ // Append an argument of the specified type
+ private void AppendType(Type type, object val)
+ {
+ object [] pars = new Object[2];
+ pars[0] = val;
+ pars[1] = message.Service;
+ DBusType.IDBusType dbusType = (DBusType.IDBusType) Activator.CreateInstance(MatchType(type), pars);
+ Append(dbusType);
+ }
+
+ // Append the results of a method call
+ public void AppendResults(MethodInfo method, object retVal, object [] parameters)
+ {
+ InitAppending();
+
+ if (method.ReturnType != typeof(void)) {
+ AppendType(method.ReturnType, retVal);
+ }
+
+ for (int i = 0; i < method.GetParameters().Length; i++) {
+ ParameterInfo par = method.GetParameters()[i];
+ if (par.IsOut || par.ParameterType.ToString().EndsWith("&")) {
+ // It's an OUT or INOUT parameter.
+ AppendType(par.ParameterType.UnderlyingSystemType, parameters[i]);
+ }
+ }
+ }
+
+ // Get the parameters
+ public object[] GetParameters(MethodInfo method)
+ {
+ ParameterInfo[] pars = method.GetParameters();
+ ArrayList paramList = new ArrayList();
+
+ enumerator = GetEnumerator();
+ foreach (ParameterInfo par in pars) {
+ if (!par.IsOut) {
+ // It's an IN or INOUT paramter.
+ enumerator.MoveNext();
+ DBusType.IDBusType dbusType = (DBusType.IDBusType) enumerator.Current;
+ paramList.Add(dbusType.Get(par.ParameterType));
+ } else {
+ // It's an OUT so just create a parameter for it
+ object var = null;
+ paramList.Add(var);
+ }
+ }
+
+ return paramList.ToArray();
+ }
+
+ // Parse the IN & REF parameters to a method and return the types in a list.
+ public static object[] ParseInParameters(MethodInfo method)
+ {
+ ArrayList types = new ArrayList();
+
+ ParameterInfo[] pars = method.GetParameters();
+ foreach (ParameterInfo par in pars) {
+ if (!par.IsOut) {
+ types.Add(MatchType(par.ParameterType));
+ }
+ }
+
+ return types.ToArray();
+ }
+
+ // Parse the OUT & REF parameters to a method and return the types in a list.
+ public static object[] ParseOutParameters(MethodInfo method)
+ {
+ ArrayList types = new ArrayList();
+
+ ParameterInfo[] pars = method.GetParameters();
+ foreach (ParameterInfo par in pars) {
+ if (par.IsOut || par.ParameterType.ToString().EndsWith("&")) {
+ types.Add(MatchType(par.ParameterType));
+ }
+ }
+
+ return types.ToArray();
+ }
+
+ // Get the appropriate constructor for a D-BUS type
+ public static ConstructorInfo GetDBusTypeConstructor(Type dbusType, Type type)
+ {
+ ConstructorInfo constructor = dbusType.GetConstructor(new Type[] {type.UnderlyingSystemType, typeof(Service)});
+ if (constructor == null)
+ throw new ArgumentException("There is no valid constructor for '" + dbusType + "' from type '" + type + "'");
+
+ return constructor;
+ }
+
+ // Get the type code for a given D-BUS type
+ public static char GetCode(Type dbusType)
+ {
+ return (char) dbusType.InvokeMember("Code", BindingFlags.Static | BindingFlags.GetField, null, null, null);
+ }
+
+ // Get a complete method signature
+ public override string ToString()
+ {
+ IntPtr iter = Marshal.AllocCoTaskMem(DBusMessageIterSize);
+ string key = "";
+
+ // Iterate through the parameters getting the type codes to a string
+ bool notEmpty = dbus_message_iter_init(message.RawMessage, iter);
+
+ if (notEmpty) {
+ do {
+ char code = (char) dbus_message_iter_get_arg_type(iter);
+ if (code == '\0')
+ return key;
+
+ key += code;
+ } while (dbus_message_iter_next(iter));
+ }
+
+ Marshal.FreeCoTaskMem(iter);
+
+ return key;
+ }
+
+ // Move to the next parameter
+ public DBusType.IDBusType GetNext()
+ {
+ enumerator.MoveNext();
+ return (DBusType.IDBusType) enumerator.Current;
+ }
+
+ // Begin appending
+ public void InitAppending()
+ {
+ dbus_message_append_iter_init(message.RawMessage, appenderIter);
+ }
+
+ // Get the enumerator
+ public IEnumerator GetEnumerator()
+ {
+ return new ArgumentsEnumerator(this);
+ }
+
+ private class ArgumentsEnumerator : IEnumerator
+ {
+ private Arguments arguments;
+ private bool started = false;
+ private bool notEmpty = false;
+ private IntPtr iter = Marshal.AllocCoTaskMem(Arguments.DBusMessageIterSize);
+
+ public ArgumentsEnumerator(Arguments arguments)
+ {
+ this.arguments = arguments;
+ Reset();
+ }
+
+ ~ArgumentsEnumerator()
+ {
+ Marshal.FreeCoTaskMem(iter);
+ }
+
+ public bool MoveNext()
+ {
+ if (started) {
+ return dbus_message_iter_next(iter);
+ } else {
+ started = true;
+ return notEmpty;
+ }
+ }
+
+ public void Reset()
+ {
+ notEmpty = dbus_message_iter_init(arguments.message.RawMessage, iter);
+ started = false;
+ }
+
+ public object Current
+ {
+ get
+ {
+ object [] pars = new Object[2];
+ pars[0] = iter;
+ pars[1] = arguments.message.Service;
+
+ Type type = (Type) DBusTypes[(char) dbus_message_iter_get_arg_type(iter)];
+ DBusType.IDBusType dbusType = (DBusType.IDBusType) Activator.CreateInstance(type, pars);
+
+ return dbusType;
+ }
+ }
+ }
+
+ [DllImport("dbus-1")]
+ private extern static void dbus_message_append_iter_init(IntPtr rawMessage, IntPtr iter);
+
+ [DllImport("dbus-1")]
+ private extern static bool dbus_message_iter_has_next(IntPtr iter);
+
+ [DllImport("dbus-1")]
+ private extern static bool dbus_message_iter_next(IntPtr iter);
+
+ [DllImport("dbus-1")]
+ private extern static bool dbus_message_iter_init(IntPtr rawMessage, IntPtr iter);
+
+ [DllImport("dbus-1")]
+ private extern static int dbus_message_iter_get_arg_type(IntPtr iter);
+ }
+}
Index: Connection.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Connection.cs,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- Connection.cs 3 Apr 2004 22:00:40 -0000 1.7
+++ Connection.cs 29 Aug 2004 18:14:30 -0000 1.8
@@ -1,186 +1,186 @@
-namespace DBus
-{
-
- using System;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using System.Reflection;
- using System.IO;
- using System.Collections;
-
- public class Connection
- {
- /// <summary>
- /// A pointer to the underlying Connection structure
- /// </summary>
- private IntPtr rawConnection;
-
- /// <summary>
- /// The current slot number
- /// </summary>
- private static int slot = -1;
-
- private int timeout = -1;
-
- internal Connection(IntPtr rawConnection)
- {
- RawConnection = rawConnection;
- }
-
- public Connection(string address)
- {
- // the assignment bumps the refcount
- Error error = new Error();
- error.Init();
- RawConnection = dbus_connection_open(address, ref error);
- if (RawConnection != IntPtr.Zero) {
- dbus_connection_unref(RawConnection);
- } else {
- throw new DBusException(error);
- }
-
- SetupWithMain();
- }
-
- public void Flush()
- {
- dbus_connection_flush(RawConnection);
- }
-
- public void SetupWithMain()
- {
- dbus_connection_setup_with_g_main(RawConnection, IntPtr.Zero);
- }
-
- ~Connection ()
- {
- if (RawConnection != IntPtr.Zero)
- {
- dbus_connection_disconnect(rawConnection);
- }
- RawConnection = IntPtr.Zero; // free the native object
- }
-
- internal static Connection Wrap(IntPtr rawConnection)
- {
- if (slot > -1) {
- // Maybe we already have a Connection object associated with
- // this rawConnection then return it
- IntPtr rawThis = dbus_connection_get_data (rawConnection, slot);
- if (rawThis != IntPtr.Zero) {
- return (DBus.Connection) ((GCHandle)rawThis).Target;
- }
- }
-
- // If it doesn't exist then create a new connection around it
- return new Connection(rawConnection);
- }
-
- public int Timeout
- {
- get
- {
- return this.timeout;
- }
- set
- {
- this.timeout = value;
- }
- }
-
- private int Slot
- {
- get
- {
- if (slot == -1)
- {
- // We need to initialize the slot
- if (!dbus_connection_allocate_data_slot (ref slot))
- throw new OutOfMemoryException ();
-
- Debug.Assert (slot >= 0);
- }
-
- return slot;
- }
- }
-
- internal IntPtr RawConnection
- {
- get
- {
- return rawConnection;
- }
- set
- {
- if (value == rawConnection)
- return;
-
- if (rawConnection != IntPtr.Zero)
- {
- // Get the reference to this
- IntPtr rawThis = dbus_connection_get_data (rawConnection, Slot);
- Debug.Assert (rawThis != IntPtr.Zero);
-
- // Blank over the reference
- dbus_connection_set_data (rawConnection, Slot, IntPtr.Zero, IntPtr.Zero);
-
- // Free the reference
- ((GCHandle) rawThis).Free();
-
- // Unref the connection
- dbus_connection_unref(rawConnection);
- }
-
- this.rawConnection = value;
-
- if (rawConnection != IntPtr.Zero)
- {
- GCHandle rawThis;
-
- dbus_connection_ref (rawConnection);
-
- // We store a weak reference to the C# object on the C object
- rawThis = GCHandle.Alloc (this, GCHandleType.WeakTrackResurrection);
-
- dbus_connection_set_data(rawConnection, Slot, (IntPtr) rawThis, IntPtr.Zero);
- }
- }
- }
-
- [DllImport("dbus-glib-1")]
- private extern static void dbus_connection_setup_with_g_main(IntPtr rawConnection,
- IntPtr rawContext);
-
- [DllImport ("dbus-1")]
- private extern static IntPtr dbus_connection_open (string address, ref Error error);
-
- [DllImport ("dbus-1")]
- private extern static void dbus_connection_unref (IntPtr ptr);
-
- [DllImport ("dbus-1")]
- private extern static void dbus_connection_ref (IntPtr ptr);
-
- [DllImport ("dbus-1")]
- private extern static bool dbus_connection_allocate_data_slot (ref int slot);
-
- [DllImport ("dbus-1")]
- private extern static void dbus_connection_free_data_slot (ref int slot);
-
- [DllImport ("dbus-1")]
- private extern static bool dbus_connection_set_data (IntPtr ptr,
- int slot,
- IntPtr data,
- IntPtr free_data_func);
-
- [DllImport ("dbus-1")]
- private extern static void dbus_connection_flush (IntPtr ptr);
-
- [DllImport ("dbus-1")]
- private extern static IntPtr dbus_connection_get_data (IntPtr ptr,
- int slot);
-
- [DllImport ("dbus-1")]
- private extern static void dbus_connection_disconnect (IntPtr ptr);
- }
-}
+namespace DBus
+{
+
+ using System;
+ using System.Runtime.InteropServices;
+ using System.Diagnostics;
+ using System.Reflection;
+ using System.IO;
+ using System.Collections;
+
+ public class Connection
+ {
+ /// <summary>
+ /// A pointer to the underlying Connection structure
+ /// </summary>
+ private IntPtr rawConnection;
+
+ /// <summary>
+ /// The current slot number
+ /// </summary>
+ private static int slot = -1;
+
+ private int timeout = -1;
+
+ internal Connection(IntPtr rawConnection)
+ {
+ RawConnection = rawConnection;
+ }
+
+ public Connection(string address)
+ {
+ // the assignment bumps the refcount
+ Error error = new Error();
+ error.Init();
+ RawConnection = dbus_connection_open(address, ref error);
+ if (RawConnection != IntPtr.Zero) {
+ dbus_connection_unref(RawConnection);
+ } else {
+ throw new DBusException(error);
+ }
+
+ SetupWithMain();
+ }
+
+ public void Flush()
+ {
+ dbus_connection_flush(RawConnection);
+ }
+
+ public void SetupWithMain()
+ {
+ dbus_connection_setup_with_g_main(RawConnection, IntPtr.Zero);
+ }
+
+ ~Connection ()
+ {
+ if (RawConnection != IntPtr.Zero)
+ {
+ dbus_connection_disconnect(rawConnection);
+ }
+ RawConnection = IntPtr.Zero; // free the native object
+ }
+
+ internal static Connection Wrap(IntPtr rawConnection)
+ {
+ if (slot > -1) {
+ // Maybe we already have a Connection object associated with
+ // this rawConnection then return it
+ IntPtr rawThis = dbus_connection_get_data (rawConnection, slot);
+ if (rawThis != IntPtr.Zero) {
+ return (DBus.Connection) ((GCHandle)rawThis).Target;
+ }
+ }
+
+ // If it doesn't exist then create a new connection around it
+ return new Connection(rawConnection);
+ }
+
+ public int Timeout
+ {
+ get
+ {
+ return this.timeout;
+ }
+ set
+ {
+ this.timeout = value;
+ }
+ }
+
+ private int Slot
+ {
+ get
+ {
+ if (slot == -1)
+ {
+ // We need to initialize the slot
+ if (!dbus_connection_allocate_data_slot (ref slot))
+ throw new OutOfMemoryException ();
+
+ Debug.Assert (slot >= 0);
+ }
+
+ return slot;
+ }
+ }
+
+ internal IntPtr RawConnection
+ {
+ get
+ {
+ return rawConnection;
+ }
+ set
+ {
+ if (value == rawConnection)
+ return;
+
+ if (rawConnection != IntPtr.Zero)
+ {
+ // Get the reference to this
+ IntPtr rawThis = dbus_connection_get_data (rawConnection, Slot);
+ Debug.Assert (rawThis != IntPtr.Zero);
+
+ // Blank over the reference
+ dbus_connection_set_data (rawConnection, Slot, IntPtr.Zero, IntPtr.Zero);
+
+ // Free the reference
+ ((GCHandle) rawThis).Free();
+
+ // Unref the connection
+ dbus_connection_unref(rawConnection);
+ }
+
+ this.rawConnection = value;
+
+ if (rawConnection != IntPtr.Zero)
+ {
+ GCHandle rawThis;
+
+ dbus_connection_ref (rawConnection);
+
+ // We store a weak reference to the C# object on the C object
+ rawThis = GCHandle.Alloc (this, GCHandleType.WeakTrackResurrection);
+
+ dbus_connection_set_data(rawConnection, Slot, (IntPtr) rawThis, IntPtr.Zero);
+ }
+ }
+ }
+
+ [DllImport("dbus-glib-1")]
+ private extern static void dbus_connection_setup_with_g_main(IntPtr rawConnection,
+ IntPtr rawContext);
+
+ [DllImport ("dbus-1")]
+ private extern static IntPtr dbus_connection_open (string address, ref Error error);
+
+ [DllImport ("dbus-1")]
+ private extern static void dbus_connection_unref (IntPtr ptr);
+
+ [DllImport ("dbus-1")]
+ private extern static void dbus_connection_ref (IntPtr ptr);
+
+ [DllImport ("dbus-1")]
+ private extern static bool dbus_connection_allocate_data_slot (ref int slot);
+
+ [DllImport ("dbus-1")]
+ private extern static void dbus_connection_free_data_slot (ref int slot);
+
+ [DllImport ("dbus-1")]
+ private extern static bool dbus_connection_set_data (IntPtr ptr,
+ int slot,
+ IntPtr data,
+ IntPtr free_data_func);
+
+ [DllImport ("dbus-1")]
+ private extern static void dbus_connection_flush (IntPtr ptr);
+
+ [DllImport ("dbus-1")]
+ private extern static IntPtr dbus_connection_get_data (IntPtr ptr,
+ int slot);
+
+ [DllImport ("dbus-1")]
+ private extern static void dbus_connection_disconnect (IntPtr ptr);
+ }
+}
Index: DBusException.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/DBusException.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- DBusException.cs 23 Mar 2004 12:10:32 -0000 1.1
+++ DBusException.cs 29 Aug 2004 18:14:30 -0000 1.2
@@ -1,12 +1,12 @@
-namespace DBus
-{
- using System;
- using System.Runtime.InteropServices;
-
- public class DBusException : ApplicationException
- {
- internal DBusException (Error error) : base (error.Message) {
- error.Free();
- }
- }
-}
+namespace DBus
+{
+ using System;
+ using System.Runtime.InteropServices;
+
+ public class DBusException : ApplicationException
+ {
+ internal DBusException (Error error) : base (error.Message) {
+ error.Free();
+ }
+ }
+}
Index: Error.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Error.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Error.cs 23 Mar 2004 12:10:32 -0000 1.3
+++ Error.cs 29 Aug 2004 18:14:30 -0000 1.4
@@ -1,60 +1,60 @@
-namespace DBus
-{
-
- using System;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
-
- // FIXME add code to verify that size of DBus.Error
- // matches the C code.
-
- [StructLayout (LayoutKind.Sequential)]
- internal struct Error
- {
- internal IntPtr name;
- internal IntPtr message;
- private int dummies;
- private IntPtr padding1;
-
- public void Init()
- {
- dbus_error_init(ref this);
- }
-
- public void Free()
- {
- dbus_error_free(ref this);
- }
-
- public string Message
- {
- get
- {
- return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(message);
- }
- }
-
- public string Name
- {
- get
- {
- return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(name);
- }
- }
-
- public bool IsSet
- {
- get
- {
- return (name != IntPtr.Zero);
- }
- }
-
-
- [DllImport ("dbus-1", EntryPoint="dbus_error_init")]
- private extern static void dbus_error_init (ref Error error);
-
- [DllImport ("dbus-1", EntryPoint="dbus_error_free")]
- private extern static void dbus_error_free (ref Error error);
- }
-}
+namespace DBus
+{
+
+ using System;
+ using System.Runtime.InteropServices;
+ using System.Diagnostics;
+
+ // FIXME add code to verify that size of DBus.Error
+ // matches the C code.
+
+ [StructLayout (LayoutKind.Sequential)]
+ internal struct Error
+ {
+ internal IntPtr name;
+ internal IntPtr message;
+ private int dummies;
+ private IntPtr padding1;
+
+ public void Init()
+ {
+ dbus_error_init(ref this);
+ }
+
+ public void Free()
+ {
+ dbus_error_free(ref this);
+ }
+
+ public string Message
+ {
+ get
+ {
+ return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(message);
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return System.Runtime.InteropServices.Marshal.PtrToStringAnsi(name);
+ }
+ }
+
+ public bool IsSet
+ {
+ get
+ {
+ return (name != IntPtr.Zero);
+ }
+ }
+
+
+ [DllImport ("dbus-1", EntryPoint="dbus_error_init")]
+ private extern static void dbus_error_init (ref Error error);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_error_free")]
+ private extern static void dbus_error_free (ref Error error);
+ }
+}
Index: Message.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Message.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Message.cs 26 Mar 2004 15:25:59 -0000 1.8
+++ Message.cs 29 Aug 2004 18:14:30 -0000 1.9
@@ -1,377 +1,377 @@
-namespace DBus
-{
-
- using System;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
- using System.Collections;
-
- public class Message
- {
-
- /// <summary>
- /// A pointer to the underlying Message structure
- /// </summary>
- private IntPtr rawMessage;
-
- /// <summary>
- /// The current slot number
- /// </summary>
- private static int slot = -1;
-
- // Keep in sync with C
- public enum MessageType
- {
- Invalid = 0,
- MethodCall = 1,
- MethodReturn = 2,
- Error = 3,
- Signal = 4
- }
-
- private Arguments arguments = null;
-
- protected Service service = null;
- protected string pathName = null;
- protected string interfaceName = null;
- protected string name = null;
- private string key= null;
-
- protected Message()
- {
- // An empty constructor for the sake of sub-classes which know how to construct theirselves.
- }
-
- protected Message(IntPtr rawMessage, Service service)
- {
- RawMessage = rawMessage;
- this.service = service;
- }
-
- protected Message(MessageType messageType)
- {
- // the assignment bumps the refcount
- RawMessage = dbus_message_new((int) messageType);
-
- if (RawMessage == IntPtr.Zero) {
- throw new OutOfMemoryException();
- }
-
- dbus_message_unref(RawMessage);
- }
-
- protected Message(MessageType messageType, Service service) : this(messageType)
- {
- this.service = service;
- }
-
- ~Message()
- {
- RawMessage = IntPtr.Zero; // free the native object
- }
-
- public static Message Wrap(IntPtr rawMessage, Service service)
- {
- if (slot > -1) {
- // If we already have a Message object associated with this rawMessage then return it
- IntPtr rawThis = dbus_message_get_data(rawMessage, slot);
- if (rawThis != IntPtr.Zero)
- return (DBus.Message) ((GCHandle)rawThis).Target;
- }
- // If it doesn't exist then create a new Message around it
- Message message = null;
- MessageType messageType = (MessageType) dbus_message_get_type(rawMessage);
-
- switch (messageType) {
- case MessageType.Signal:
- message = new Signal(rawMessage, service);
- break;
- case MessageType.MethodCall:
- message = new MethodCall(rawMessage, service);
- break;
- case MessageType.MethodReturn:
- message = new MethodReturn(rawMessage, service);
- break;
- case MessageType.Error:
- message = new ErrorMessage(rawMessage, service);
- break;
- default:
- throw new ApplicationException("Unknown message type to wrap: " + messageType);
- }
-
- return message;
- }
-
- internal IntPtr RawMessage
- {
- get
- {
- return rawMessage;
- }
- set
- {
- if (value == rawMessage)
- return;
-
- if (rawMessage != IntPtr.Zero)
- {
- // Get the reference to this
- IntPtr rawThis = dbus_message_get_data(rawMessage, Slot);
- Debug.Assert (rawThis != IntPtr.Zero);
-
- // Blank over the reference
- dbus_message_set_data(rawMessage, Slot, IntPtr.Zero, IntPtr.Zero);
-
- // Free the reference
- ((GCHandle) rawThis).Free();
-
- // Unref the connection
- dbus_message_unref(rawMessage);
- }
-
- this.rawMessage = value;
-
- if (rawMessage != IntPtr.Zero)
- {
- GCHandle rawThis;
-
- dbus_message_ref(rawMessage);
-
- // We store a weak reference to the C# object on the C object
- rawThis = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection);
-
- dbus_message_set_data(rawMessage, Slot, (IntPtr) rawThis, IntPtr.Zero);
- }
- }
- }
-
- public void Send(ref int serial)
- {
- if (!dbus_connection_send (Service.Connection.RawConnection, RawMessage, ref serial))
- throw new OutOfMemoryException ();
-
- Service.Connection.Flush();
- }
-
- public void Send()
- {
- int ignored = 0;
- Send(ref ignored);
- }
-
- public void SendWithReply()
- {
- IntPtr rawPendingCall = IntPtr.Zero;
-
- if (!dbus_connection_send_with_reply (Service.Connection.RawConnection, RawMessage, rawPendingCall, Service.Connection.Timeout))
- throw new OutOfMemoryException();
- }
-
- public MethodReturn SendWithReplyAndBlock()
- {
- Error error = new Error();
- error.Init();
-
- IntPtr rawMessage = dbus_connection_send_with_reply_and_block(Service.Connection.RawConnection,
- RawMessage,
- Service.Connection.Timeout,
- ref error);
-
- if (rawMessage != IntPtr.Zero) {
- MethodReturn methodReturn = new MethodReturn(rawMessage, Service);
- return methodReturn;
- } else {
- throw new DBusException(error);
- }
- }
-
- public MessageType Type
- {
- get
- {
- return (MessageType) dbus_message_get_type(RawMessage);
- }
- }
-
- public Service Service
- {
- set
- {
- if (this.service != null && (value.Name != this.service.Name)) {
- if (!dbus_message_set_destination(RawMessage, value.Name)) {
- throw new OutOfMemoryException();
- }
- }
-
- this.service = value;
- }
- get
- {
- return this.service;
- }
- }
-
- protected virtual string PathName
- {
- set
- {
- if (value != this.pathName)
- {
- if (!dbus_message_set_path(RawMessage, value)) {
- throw new OutOfMemoryException();
- }
-
- this.pathName = value;
- }
- }
- get
- {
- if (this.pathName == null) {
- this.pathName = Marshal.PtrToStringAnsi(dbus_message_get_path(RawMessage));
- }
-
- return this.pathName;
- }
- }
-
- protected virtual string InterfaceName
- {
- set
- {
- if (value != this.interfaceName)
- {
- dbus_message_set_interface (RawMessage, value);
- this.interfaceName = value;
- }
- }
- get
- {
- if (this.interfaceName == null) {
- this.interfaceName = Marshal.PtrToStringAnsi(dbus_message_get_interface(RawMessage));
- }
-
- return this.interfaceName;
- }
- }
-
- protected virtual string Name
- {
- set {
- if (value != this.name) {
- dbus_message_set_member(RawMessage, value);
- this.name = value;
- }
- }
- get {
- if (this.name == null) {
- this.name = Marshal.PtrToStringAnsi(dbus_message_get_member(RawMessage));
- }
-
- return this.name;
- }
- }
-
- public string Key
- {
- get {
- if (this.key == null) {
- this.key = Name + " " + Arguments;
- }
-
- return this.key;
- }
- }
-
- public Arguments Arguments
- {
- get
- {
- if (this.arguments == null) {
- this.arguments = new Arguments(this);
- }
-
- return this.arguments;
- }
- }
-
- protected int Slot
- {
- get
- {
- if (slot == -1)
- {
- // We need to initialize the slot
- if (!dbus_message_allocate_data_slot (ref slot))
- throw new OutOfMemoryException ();
-
- Debug.Assert (slot >= 0);
- }
-
- return slot;
- }
- }
-
- [DllImport ("dbus-1", EntryPoint="dbus_message_new")]
- protected extern static IntPtr dbus_message_new (int messageType);
-
- [DllImport ("dbus-1", EntryPoint="dbus_message_unref")]
- protected extern static void dbus_message_unref (IntPtr ptr);
-
- [DllImport ("dbus-1", EntryPoint="dbus_message_ref")]
- protected extern static void dbus_message_ref (IntPtr ptr);
-
- [DllImport ("dbus-1", EntryPoint="dbus_message_allocate_data_slot")]
- protected extern static bool dbus_message_allocate_data_slot (ref int slot);
-
- [DllImport ("dbus-1", EntryPoint="dbus_message_free_data_slot")]
- protected extern static void dbus_message_free_data_slot (ref int slot);
-
- [DllImport ("dbus-1", EntryPoint="dbus_message_set_data")]
- protected extern static bool dbus_message_set_data (IntPtr ptr,
- int slot,
- IntPtr data,
- IntPtr free_data_func);
-
- [DllImport ("dbus-1", EntryPoint="dbus_message_get_data")]
- protected extern static IntPtr dbus_message_get_data (IntPtr ptr,
- int slot);
-
- [DllImport ("dbus-1", EntryPoint="dbus_connection_send")]
- private extern static bool dbus_connection_send (IntPtr ptr,
- IntPtr message,
- ref int client_serial);
-
- [DllImport ("dbus-1", EntryPoint="dbus_connection_send_with_reply")]
- private extern static bool dbus_connection_send_with_reply (IntPtr rawConnection, IntPtr rawMessage, IntPtr rawPendingCall, int timeout);
-
- [DllImport ("dbus-1", EntryPoint="dbus_connection_send_with_reply_and_block")]
- private extern static IntPtr dbus_connection_send_with_reply_and_block (IntPtr rawConnection, IntPtr message, int timeout, ref Error error);
-
- [DllImport("dbus-1")]
- private extern static int dbus_message_get_type(IntPtr rawMessage);
-
- [DllImport("dbus-1")]
- private extern static bool dbus_message_set_path(IntPtr rawMessage, string pathName);
-
- [DllImport("dbus-1")]
- private extern static IntPtr dbus_message_get_path(IntPtr rawMessage);
-
- [DllImport("dbus-1")]
- private extern static bool dbus_message_set_interface (IntPtr rawMessage, string interfaceName);
-
- [DllImport("dbus-1")]
- private extern static IntPtr dbus_message_get_interface(IntPtr rawMessage);
-
- [DllImport("dbus-1")]
- private extern static bool dbus_message_set_member(IntPtr rawMessage, string name);
-
- [DllImport("dbus-1")]
- private extern static IntPtr dbus_message_get_member(IntPtr rawMessage);
-
- [DllImport("dbus-1")]
- private extern static bool dbus_message_set_destination(IntPtr rawMessage, string serviceName);
-
- [DllImport("dbus-1")]
- private extern static IntPtr dbus_message_get_destination(IntPtr rawMessage);
- }
-}
+namespace DBus
+{
+
+ using System;
+ using System.Runtime.InteropServices;
+ using System.Diagnostics;
+ using System.Collections;
+
+ public class Message
+ {
+
+ /// <summary>
+ /// A pointer to the underlying Message structure
+ /// </summary>
+ private IntPtr rawMessage;
+
+ /// <summary>
+ /// The current slot number
+ /// </summary>
+ private static int slot = -1;
+
+ // Keep in sync with C
+ public enum MessageType
+ {
+ Invalid = 0,
+ MethodCall = 1,
+ MethodReturn = 2,
+ Error = 3,
+ Signal = 4
+ }
+
+ private Arguments arguments = null;
+
+ protected Service service = null;
+ protected string pathName = null;
+ protected string interfaceName = null;
+ protected string name = null;
+ private string key= null;
+
+ protected Message()
+ {
+ // An empty constructor for the sake of sub-classes which know how to construct theirselves.
+ }
+
+ protected Message(IntPtr rawMessage, Service service)
+ {
+ RawMessage = rawMessage;
+ this.service = service;
+ }
+
+ protected Message(MessageType messageType)
+ {
+ // the assignment bumps the refcount
+ RawMessage = dbus_message_new((int) messageType);
+
+ if (RawMessage == IntPtr.Zero) {
+ throw new OutOfMemoryException();
+ }
+
+ dbus_message_unref(RawMessage);
+ }
+
+ protected Message(MessageType messageType, Service service) : this(messageType)
+ {
+ this.service = service;
+ }
+
+ ~Message()
+ {
+ RawMessage = IntPtr.Zero; // free the native object
+ }
+
+ public static Message Wrap(IntPtr rawMessage, Service service)
+ {
+ if (slot > -1) {
+ // If we already have a Message object associated with this rawMessage then return it
+ IntPtr rawThis = dbus_message_get_data(rawMessage, slot);
+ if (rawThis != IntPtr.Zero)
+ return (DBus.Message) ((GCHandle)rawThis).Target;
+ }
+ // If it doesn't exist then create a new Message around it
+ Message message = null;
+ MessageType messageType = (MessageType) dbus_message_get_type(rawMessage);
+
+ switch (messageType) {
+ case MessageType.Signal:
+ message = new Signal(rawMessage, service);
+ break;
+ case MessageType.MethodCall:
+ message = new MethodCall(rawMessage, service);
+ break;
+ case MessageType.MethodReturn:
+ message = new MethodReturn(rawMessage, service);
+ break;
+ case MessageType.Error:
+ message = new ErrorMessage(rawMessage, service);
+ break;
+ default:
+ throw new ApplicationException("Unknown message type to wrap: " + messageType);
+ }
+
+ return message;
+ }
+
+ internal IntPtr RawMessage
+ {
+ get
+ {
+ return rawMessage;
+ }
+ set
+ {
+ if (value == rawMessage)
+ return;
+
+ if (rawMessage != IntPtr.Zero)
+ {
+ // Get the reference to this
+ IntPtr rawThis = dbus_message_get_data(rawMessage, Slot);
+ Debug.Assert (rawThis != IntPtr.Zero);
+
+ // Blank over the reference
+ dbus_message_set_data(rawMessage, Slot, IntPtr.Zero, IntPtr.Zero);
+
+ // Free the reference
+ ((GCHandle) rawThis).Free();
+
+ // Unref the connection
+ dbus_message_unref(rawMessage);
+ }
+
+ this.rawMessage = value;
+
+ if (rawMessage != IntPtr.Zero)
+ {
+ GCHandle rawThis;
+
+ dbus_message_ref(rawMessage);
+
+ // We store a weak reference to the C# object on the C object
+ rawThis = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection);
+
+ dbus_message_set_data(rawMessage, Slot, (IntPtr) rawThis, IntPtr.Zero);
+ }
+ }
+ }
+
+ public void Send(ref int serial)
+ {
+ if (!dbus_connection_send (Service.Connection.RawConnection, RawMessage, ref serial))
+ throw new OutOfMemoryException ();
+
+ Service.Connection.Flush();
+ }
+
+ public void Send()
+ {
+ int ignored = 0;
+ Send(ref ignored);
+ }
+
+ public void SendWithReply()
+ {
+ IntPtr rawPendingCall = IntPtr.Zero;
+
+ if (!dbus_connection_send_with_reply (Service.Connection.RawConnection, RawMessage, rawPendingCall, Service.Connection.Timeout))
+ throw new OutOfMemoryException();
+ }
+
+ public MethodReturn SendWithReplyAndBlock()
+ {
+ Error error = new Error();
+ error.Init();
+
+ IntPtr rawMessage = dbus_connection_send_with_reply_and_block(Service.Connection.RawConnection,
+ RawMessage,
+ Service.Connection.Timeout,
+ ref error);
+
+ if (rawMessage != IntPtr.Zero) {
+ MethodReturn methodReturn = new MethodReturn(rawMessage, Service);
+ return methodReturn;
+ } else {
+ throw new DBusException(error);
+ }
+ }
+
+ public MessageType Type
+ {
+ get
+ {
+ return (MessageType) dbus_message_get_type(RawMessage);
+ }
+ }
+
+ public Service Service
+ {
+ set
+ {
+ if (this.service != null && (value.Name != this.service.Name)) {
+ if (!dbus_message_set_destination(RawMessage, value.Name)) {
+ throw new OutOfMemoryException();
+ }
+ }
+
+ this.service = value;
+ }
+ get
+ {
+ return this.service;
+ }
+ }
+
+ protected virtual string PathName
+ {
+ set
+ {
+ if (value != this.pathName)
+ {
+ if (!dbus_message_set_path(RawMessage, value)) {
+ throw new OutOfMemoryException();
+ }
+
+ this.pathName = value;
+ }
+ }
+ get
+ {
+ if (this.pathName == null) {
+ this.pathName = Marshal.PtrToStringAnsi(dbus_message_get_path(RawMessage));
+ }
+
+ return this.pathName;
+ }
+ }
+
+ protected virtual string InterfaceName
+ {
+ set
+ {
+ if (value != this.interfaceName)
+ {
+ dbus_message_set_interface (RawMessage, value);
+ this.interfaceName = value;
+ }
+ }
+ get
+ {
+ if (this.interfaceName == null) {
+ this.interfaceName = Marshal.PtrToStringAnsi(dbus_message_get_interface(RawMessage));
+ }
+
+ return this.interfaceName;
+ }
+ }
+
+ protected virtual string Name
+ {
+ set {
+ if (value != this.name) {
+ dbus_message_set_member(RawMessage, value);
+ this.name = value;
+ }
+ }
+ get {
+ if (this.name == null) {
+ this.name = Marshal.PtrToStringAnsi(dbus_message_get_member(RawMessage));
+ }
+
+ return this.name;
+ }
+ }
+
+ public string Key
+ {
+ get {
+ if (this.key == null) {
+ this.key = Name + " " + Arguments;
+ }
+
+ return this.key;
+ }
+ }
+
+ public Arguments Arguments
+ {
+ get
+ {
+ if (this.arguments == null) {
+ this.arguments = new Arguments(this);
+ }
+
+ return this.arguments;
+ }
+ }
+
+ protected int Slot
+ {
+ get
+ {
+ if (slot == -1)
+ {
+ // We need to initialize the slot
+ if (!dbus_message_allocate_data_slot (ref slot))
+ throw new OutOfMemoryException ();
+
+ Debug.Assert (slot >= 0);
+ }
+
+ return slot;
+ }
+ }
+
+ [DllImport ("dbus-1", EntryPoint="dbus_message_new")]
+ protected extern static IntPtr dbus_message_new (int messageType);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_message_unref")]
+ protected extern static void dbus_message_unref (IntPtr ptr);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_message_ref")]
+ protected extern static void dbus_message_ref (IntPtr ptr);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_message_allocate_data_slot")]
+ protected extern static bool dbus_message_allocate_data_slot (ref int slot);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_message_free_data_slot")]
+ protected extern static void dbus_message_free_data_slot (ref int slot);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_message_set_data")]
+ protected extern static bool dbus_message_set_data (IntPtr ptr,
+ int slot,
+ IntPtr data,
+ IntPtr free_data_func);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_message_get_data")]
+ protected extern static IntPtr dbus_message_get_data (IntPtr ptr,
+ int slot);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_connection_send")]
+ private extern static bool dbus_connection_send (IntPtr ptr,
+ IntPtr message,
+ ref int client_serial);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_connection_send_with_reply")]
+ private extern static bool dbus_connection_send_with_reply (IntPtr rawConnection, IntPtr rawMessage, IntPtr rawPendingCall, int timeout);
+
+ [DllImport ("dbus-1", EntryPoint="dbus_connection_send_with_reply_and_block")]
+ private extern static IntPtr dbus_connection_send_with_reply_and_block (IntPtr rawConnection, IntPtr message, int timeout, ref Error error);
+
+ [DllImport("dbus-1")]
+ private extern static int dbus_message_get_type(IntPtr rawMessage);
+
+ [DllImport("dbus-1")]
+ private extern static bool dbus_message_set_path(IntPtr rawMessage, string pathName);
+
+ [DllImport("dbus-1")]
+ private extern static IntPtr dbus_message_get_path(IntPtr rawMessage);
+
+ [DllImport("dbus-1")]
+ private extern static bool dbus_message_set_interface (IntPtr rawMessage, string interfaceName);
+
+ [DllImport("dbus-1")]
+ private extern static IntPtr dbus_message_get_interface(IntPtr rawMessage);
+
+ [DllImport("dbus-1")]
+ private extern static bool dbus_message_set_member(IntPtr rawMessage, string name);
+
+ [DllImport("dbus-1")]
+ private extern static IntPtr dbus_message_get_member(IntPtr rawMessage);
+
+ [DllImport("dbus-1")]
+ private extern static bool dbus_message_set_destination(IntPtr rawMessage, string serviceName);
+
+ [DllImport("dbus-1")]
+ private extern static IntPtr dbus_message_get_destination(IntPtr rawMessage);
+ }
+}
Index: MethodCall.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/MethodCall.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- MethodCall.cs 23 Mar 2004 12:10:32 -0000 1.1
+++ MethodCall.cs 29 Aug 2004 18:14:30 -0000 1.2
@@ -1,80 +1,80 @@
-namespace DBus
-{
- using System;
- using System.Runtime.InteropServices;
- using System.Diagnostics;
-
- public class MethodCall : Message
- {
- public MethodCall() : base(MessageType.MethodCall)
- {
- }
-
- internal MethodCall(IntPtr rawMessage, Service service) : base(rawMessage, service)
- {
- }
-
- public MethodCall(Service service) : base(MessageType.MethodCall, service)
- {
- }
-
- public MethodCall(Service service, string pathName, string interfaceName, string name)
- {
- this.service = service;
-
- RawMessage = dbus_message_new_method_call(service.Name, pathName, interfaceName, name);
-
- if (RawMessage == IntPtr.Zero) {
- throw new OutOfMemoryException();
- }
-
- this.pathName = pathName;
- this.interfaceName = interfaceName;
- this.name = name;
-
- dbus_message_unref(RawMessage);
- }
-
- public new string PathName
- {
- get
- {
- return base.PathName;
- }
-
- set
- {
- base.PathName = value;
- }
- }
-
- public new string InterfaceName
- {
- get
- {
- return base.InterfaceName;
- }
-
- set
- {
- base.InterfaceName = value;
- }
- }
-
- public new string Name
- {
- get
- {
- return base.Name;
- }
-
- set
- {
- base.Name = value;
- }
- }
-
- [DllImport("dbus-1")]
- private extern static IntPtr dbus_message_new_method_call(string serviceName, string pathName, string interfaceName, string name);
- }
-}
+namespace DBus
+{
+ using System;
+ using System.Runtime.InteropServices;
+ using System.Diagnostics;
+
+ public class MethodCall : Message
+ {
+ public MethodCall() : base(MessageType.MethodCall)
+ {
+ }
+
+ internal MethodCall(IntPtr rawMessage, Service service) : base(rawMessage, service)
+ {
+ }
+
+ public MethodCall(Service service) : base(MessageType.MethodCall, service)
+ {
+ }
+
+ public MethodCall(Service service, string pathName, string interfaceName, string name)
+ {
+ this.service = service;
+
+ RawMessage = dbus_message_new_method_call(service.Name, pathName, interfaceName, name);
+
+ if (RawMessage == IntPtr.Zero) {
+ throw new OutOfMemoryException();
+ }
+
+ this.pathName = pathName;
+ this.interfaceName = interfaceName;
+ this.name = name;
+
+ dbus_message_unref(RawMessage);
+ }
+
+ public new string PathName
+ {
+ get
+ {
+ return base.PathName;
+ }
+
+ set
+ {
+ base.PathName = value;
+ }
+ }
+
+ public new string InterfaceName
+ {
+ get
+ {
+ return base.InterfaceName;
+ }
+
+ set
+ {
+ base.InterfaceName = value;
+ }
+ }
+
+ public new string Name
+ {
+ get
+ {
+ return base.Name;
+ }
+
+ set
+ {
+ base.Name = value;
+ }
+ }
+
+ [DllImport("dbus-1")]
+ private extern static IntPtr dbus_message_new_method_call(string serviceName, string pathName, string interfaceName, string name);
+ }
+}
Index: Test.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Test.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Test.cs 23 Mar 2004 12:10:32 -0000 1.5
+++ Test.cs 29 Aug 2004 18:14:30 -0000 1.6
@@ -17,12 +17,17 @@
serverThread.Start();
connection = Bus.GetSessionBus();
- service = Service.Get(connection, "org.freedesktop.Test");
+ service = Service.Get(connection, "org.freedesktop.Test");
+ Thread.Sleep (1000);
TestObject testObject = (TestObject) service.GetObject(typeof(TestObject), "/org/freedesktop/Test/TestObject");
+
+ Console.WriteLine ("Got object [{0}]", testObject);
System.Console.WriteLine(testObject.Test1("Hello"));
+ Console.WriteLine ("Got object [{0}]", testObject);
+
//RunTests(testObject);
return 0;
@@ -49,6 +54,8 @@
service = new Service(connection, "org.freedesktop.Test");
TestObject testObject = new TestObject();
service.RegisterObject(testObject, "/org/freedesktop/Test/TestObject");
+
+ System.Console.WriteLine("Foo!");
}
public void StartServer()
- Previous message: dbus/dbus dbus-spawn.c, 1.17, 1.18 dbus-sysdeps.c, 1.77,
1.78 dbus-userdb.c, 1.10, 1.11
- Next message: dbus/mono/DBusType Array.cs, 1.4, 1.5 Boolean.cs, 1.2, 1.3 Byte.cs,
1.4, 1.5 Custom.cs, 1.2, 1.3 Dict.cs, 1.4, 1.5 Double.cs, 1.2,
1.3 IDBusType.cs, 1.1, 1.2 Int32.cs, 1.3, 1.4 Int64.cs, 1.3,
1.4 Nil.cs, 1.2, 1.3 ObjectPath.cs, 1.4, 1.5 String.cs, 1.2,
1.3 UInt32.cs, 1.3, 1.4 UInt64.cs, 1.3, 1.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dbus-commit
mailing list