+2004-08-30 Jon Trowbridge <trow@ximian.com>
+
+ * mono/BusDriver.cs: Added. This is a class for interacting with
+ the org.freedesktop.DBus service.
+
+ * mono/Message.cs: Added a mechanism to expose the message that is
+ currently being dispatched via the static Message.Current
+ property. Added Message.Sender and Message.Destination
+ properties.
+
+ * mono/Handler.cs: Expose the dispatched message via
+ Message.Current when handling method calls.
+
+ * mono/Service.cs: Expose the dispatched message via
+ Message.Current when handling signal emissions.
+
+ * mono/Connection.cs: Bind dbus_bus_get_base_service via the
+ Connection.BaseService property.
+
2004-08-28 Havoc Pennington <hp@redhat.com>
* dbus/dbus-userdb.c (_dbus_is_console_user): remove unused variable
--- /dev/null
+namespace DBus
+{
+
+ using System;
+
+ public delegate void ServiceEventHandler (string serviceName);
+
+ [Interface ("org.freedesktop.DBus")]
+ public abstract class BusDriver
+ {
+ [Method]
+ public abstract string[] ListServices ();
+
+ [Method]
+ public abstract string GetServiceOwner (string serviceName);
+
+ [Method]
+ public abstract UInt32 GetConnectionUnixUser (string connectionName);
+
+
+ [Signal]
+ public virtual event ServiceEventHandler ServiceCreated;
+
+ [Signal]
+ public virtual event ServiceEventHandler ServiceDeleted;
+
+
+ static public BusDriver New (Connection connection)
+ {
+ Service service;
+ service = Service.Get (connection, "org.freedesktop.DBus");
+
+ BusDriver driver;
+ driver = (BusDriver) service.GetObject (typeof (BusDriver), "/org/freedesktop/DBus");
+
+ return driver;
+ }
+ }
+}
return new Connection(rawConnection);
}
+ public string BaseService
+ {
+ get
+ {
+ return Marshal.PtrToStringAnsi (dbus_bus_get_base_service (RawConnection));
+ }
+ }
+
public int Timeout
{
get
[DllImport ("dbus-1")]
private extern static void dbus_connection_disconnect (IntPtr ptr);
+
+ [DllImport ("dbus-1")]
+ private extern static IntPtr dbus_bus_get_base_service (IntPtr ptr);
}
}
}
MethodInfo method = interfaceProxy.GetMethod(methodCall.Key);
+
+ Message.Push (methodCall);
// Now call the method. FIXME: Error handling
object [] args = methodCall.Arguments.GetParameters(method);
object retVal = method.Invoke(this.handledObject, args);
+ Message.Pop ();
+
// Create the reply and send it
MethodReturn methodReturn = new MethodReturn(methodCall);
methodReturn.Arguments.AppendResults(method, retVal, args);
DBUS_SHARP_FILES= \
Arguments.cs \
Bus.cs \
+ BusDriver.cs \
Connection.cs \
Custom.cs \
DBusException.cs \
public class Message
{
+ private static Stack stack = new Stack ();
+
+ static public Message Current {
+ get
+ {
+ return stack.Count > 0 ? (Message) stack.Peek () : null;
+ }
+ }
+
+ static internal void Push (Message message)
+ {
+ stack.Push (message);
+ }
+
+ static internal void Pop ()
+ {
+ stack.Pop ();
+ }
+
/// <summary>
/// A pointer to the underlying Message structure
}
}
+ public string Sender
+ {
+ get
+ {
+ return Marshal.PtrToStringAnsi(dbus_message_get_sender(RawMessage));
+ }
+ }
+
+ public string Destination
+ {
+ get
+ {
+ return Marshal.PtrToStringAnsi(dbus_message_get_destination(RawMessage));
+ }
+ }
+
protected int Slot
{
get
[DllImport("dbus-1")]
private extern static IntPtr dbus_message_get_destination(IntPtr rawMessage);
+
+ [DllImport("dbus-1")]
+ private extern static IntPtr dbus_message_get_sender(IntPtr rawMessage);
}
}
// We're only interested in signals
Signal signal = (Signal) message;
if (SignalCalled != null) {
+ Message.Push (message);
SignalCalled(signal);
+ Message.Pop ();
}
}