dbus/mono BusDriver.cs, NONE, 1.1 Connection.cs, 1.8, 1.9 Handler.cs, 1.6, 1.7 Makefile.am, 1.10, 1.11 Message.cs, 1.9, 1.10 Service.cs, 1.6, 1.7

Jon Trowbridge trow at freedesktop.org
Mon Aug 30 20:59:16 PDT 2004


Update of /cvs/dbus/dbus/mono
In directory gabe:/tmp/cvs-serv18315/mono

Modified Files:
	Connection.cs Handler.cs Makefile.am Message.cs Service.cs 
Added Files:
	BusDriver.cs 
Log Message:
2004-08-30  Jon Trowbridge  <trow at 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.



--- NEW FILE: BusDriver.cs ---
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;
    }
  }
}

Index: Connection.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Connection.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Connection.cs	29 Aug 2004 18:14:30 -0000	1.8
+++ Connection.cs	31 Aug 2004 03:59:14 -0000	1.9
@@ -76,6 +76,14 @@
       return new Connection(rawConnection);
     }
 
+    public string BaseService
+    {
+      get
+	{
+	  return Marshal.PtrToStringAnsi (dbus_bus_get_base_service (RawConnection));
+	}
+    }
+
     public int Timeout
     {
       get
@@ -182,5 +190,8 @@
     
     [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);
   }
 }

Index: Handler.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Handler.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Handler.cs	7 Jun 2004 11:40:20 -0000	1.6
+++ Handler.cs	31 Aug 2004 03:59:14 -0000	1.7
@@ -177,11 +177,15 @@
       }
       
       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);

Index: Makefile.am
===================================================================
RCS file: /cvs/dbus/dbus/mono/Makefile.am,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- Makefile.am	17 Aug 2004 17:08:32 -0000	1.10
+++ Makefile.am	31 Aug 2004 03:59:14 -0000	1.11
@@ -9,6 +9,7 @@
 DBUS_SHARP_FILES= 		\
 	Arguments.cs		\
 	Bus.cs			\
+	BusDriver.cs		\
 	Connection.cs		\
 	Custom.cs		\
 	DBusException.cs	\

Index: Message.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Message.cs,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- Message.cs	29 Aug 2004 18:14:30 -0000	1.9
+++ Message.cs	31 Aug 2004 03:59:14 -0000	1.10
@@ -8,6 +8,25 @@
   
   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
@@ -294,6 +313,22 @@
 	}
     }
 
+    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 
@@ -373,5 +408,8 @@
 
     [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);
   }
 }

Index: Service.cs
===================================================================
RCS file: /cvs/dbus/dbus/mono/Service.cs,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Service.cs	23 May 2004 21:33:14 -0000	1.6
+++ Service.cs	31 Aug 2004 03:59:14 -0000	1.7
@@ -128,7 +128,9 @@
 	// We're only interested in signals
 	Signal signal = (Signal) message;
 	if (SignalCalled != null) {
+	  Message.Push (message);
 	  SignalCalled(signal);
+	  Message.Pop ();
 	}
       }
       



More information about the dbus-commit mailing list