summaryrefslogtreecommitdiffstats
path: root/mono
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2004-09-29 01:46:45 +0000
committerJon Trowbridge <trow@ximian.com>2004-09-29 01:46:45 +0000
commit0c168e3e1506c9cf5d4cb13189fa284ec0706904 (patch)
tree35ded9f61f7c0c4213451f11488b3ef443d46738 /mono
parent73a69d496bb26356d684774cd1e98646a443c723 (diff)
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.
Diffstat (limited to 'mono')
-rw-r--r--mono/BusDriver.cs10
-rw-r--r--mono/example/.cvsignore1
-rw-r--r--mono/example/BusListener.cs44
-rw-r--r--mono/example/Makefile.am8
4 files changed, 55 insertions, 8 deletions
diff --git a/mono/BusDriver.cs b/mono/BusDriver.cs
index 8b1fc680..426dd370 100644
--- a/mono/BusDriver.cs
+++ b/mono/BusDriver.cs
@@ -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)
{
diff --git a/mono/example/.cvsignore b/mono/example/.cvsignore
index 9a639215..fb4e561d 100644
--- a/mono/example/.cvsignore
+++ b/mono/example/.cvsignore
@@ -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
index 00000000..8af83d84
--- /dev/null
+++ b/mono/example/BusListener.cs
@@ -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;
+ }
+ }
+
+
+}
diff --git a/mono/example/Makefile.am b/mono/example/Makefile.am
index d5a29127..da202ded 100644
--- a/mono/example/Makefile.am
+++ b/mono/example/Makefile.am
@@ -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