summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Trowbridge <trow@ximian.com>2004-09-29 01:46:45 +0000
committerJohn Palmieri <johnp@remedyz.boston.redhat.com>2006-06-28 08:15:39 -0400
commiteaf328cf1638ca600c5359170fd749bee2516a44 (patch)
treef51d6d61ca537f164af36ad814b86011d6685a17
parente9d56b9ad065a996ebbfee1ad2ef66aab7bd494d (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.
-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 8b1fc68..426dd37 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 9a63921..fb4e561 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 0000000..8af83d8
--- /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 d5a2912..da202de 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