2004-09-28 Jon Trowbridge <trow@ximian.com>
authorJon Trowbridge <trow@ximian.com>
Wed, 29 Sep 2004 01:46:45 +0000 (01:46 +0000)
committerJon Trowbridge <trow@ximian.com>
Wed, 29 Sep 2004 01:46:45 +0000 (01:46 +0000)
    * mono/BusDriver.cs: Changed BusDriver struct to remove
    the ServiceCreated and ServiceDeleted events and replace them
    with the new ServiceOwnerChanged event.

    * mono/example/BusListener.cs: Added a new example program,
    which listens for and reports any ServiceOwnerChanged events
    on the bus driver.

    * mono/example/Makefile.am (DESTDIR): Build changes for the
    new BusListener.cs example.

ChangeLog
mono/BusDriver.cs
mono/example/.cvsignore
mono/example/BusListener.cs [new file with mode: 0644]
mono/example/Makefile.am

index 6ce8518..75b4dfc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2004-09-28  Jon Trowbridge  <trow@ximian.com>
+
+       * mono/BusDriver.cs: Changed BusDriver struct to remove
+       the ServiceCreated and ServiceDeleted events and replace them
+       with the new ServiceOwnerChanged event.
+
+       * mono/example/BusListener.cs: Added a new example program,
+       which listens for and reports any ServiceOwnerChanged events
+       on the bus driver.
+
+       * mono/example/Makefile.am (DESTDIR): Build changes for the
+       new BusListener.cs example.
+
 2004-09-27  Olivier Andrieu  <oliv__a@users.sourceforge.net>
 
        * bus/signals.c (bus_match_rule_parse): validate the components of
index 8b1fc68..426dd37 100644 (file)
@@ -3,7 +3,9 @@ namespace DBus
 
   using System;
 
-  public delegate void ServiceEventHandler (string serviceName);
+  public delegate void ServiceEventHandler (string serviceName,
+                                           string oldOwner,
+                                           string newOwner);
 
   [Interface ("org.freedesktop.DBus")]
   public abstract class BusDriver
@@ -19,11 +21,7 @@ namespace DBus
 
 
     [Signal]
-    public virtual event ServiceEventHandler ServiceCreated;
-
-    [Signal]
-    public virtual event ServiceEventHandler ServiceDeleted;
-
+    public virtual event ServiceEventHandler ServiceOwnerChanged;
 
     static public BusDriver New (Connection connection)
     {
index 9a63921..fb4e561 100644 (file)
@@ -1,3 +1,4 @@
 .deps
 Makefile.in
 Makefile
+*.exe
diff --git a/mono/example/BusListener.cs b/mono/example/BusListener.cs
new file mode 100644 (file)
index 0000000..8af83d8
--- /dev/null
@@ -0,0 +1,44 @@
+namespace Foo
+{
+       using System;
+       using DBus;
+       using Gtk;
+
+       public class BusListener
+       {
+
+               static void OnServiceOwnerChanged (string serviceName,
+                                                  string oldOwner,
+                                                  string newOwner)
+               {
+                       if (oldOwner == "")
+                               Console.WriteLine ("{0} created by {1}",
+                                                  serviceName, newOwner);
+                       else if (newOwner == "")
+                               Console.WriteLine ("{0} released by {1}", 
+                                                  serviceName, oldOwner);
+                       else
+                               Console.WriteLine ("{0} transfered from {1} to {2}",
+                                                  serviceName, oldOwner, newOwner);
+               }
+
+               public static int Main (string [] args)
+               {
+                       Application.Init ();
+
+                       Connection connection;
+                       connection = Bus.GetSessionBus ();
+
+                       BusDriver driver = BusDriver.New (connection);
+                       driver.ServiceOwnerChanged += new ServiceEventHandler (OnServiceOwnerChanged);
+
+                       Console.WriteLine ("Listening for service changes...");
+
+                       Application.Run ();
+
+                       return 0;
+               }
+       }
+
+       
+}
index d5a2912..da202de 100644 (file)
@@ -1,6 +1,6 @@
 DESTDIR=
 
-NOINST_EXES=echo-server.exe echo-client.exe
+NOINST_EXES=echo-server.exe echo-client.exe bus-listener.exe
 DISTCLEANFILES=$(NOINST_EXES)
 
 all: $(NOINST_EXES)
@@ -11,10 +11,14 @@ echo-server.exe: EchoServer.cs Echoer.cs
 echo-client.exe: EchoClient.cs Echoer.cs
        $(CSC) --target exe -L .. -r:../dbus-sharp.dll -o echo-client.exe $(srcdir)/EchoClient.cs $(srcdir)/Echoer.cs
 
+bus-listener.exe: BusListener.cs
+       $(CSC) --target exe -L .. -r:../dbus-sharp.dll -pkg:gtk-sharp -o bus-listener.exe $(srcdir)/BusListener.cs
+
+
 clean:
        rm -f $(NOINST_EXES)
 
 install: all
 
-EXTRA_DIST=EchoServer.cs EchoClient.cs Echoer.cs
+EXTRA_DIST=EchoServer.cs EchoClient.cs Echoer.cs BusListener.cs