diff options
author | Jon Trowbridge <trow@ximian.com> | 2004-09-29 01:46:45 +0000 |
---|---|---|
committer | Jon Trowbridge <trow@ximian.com> | 2004-09-29 01:46:45 +0000 |
commit | 0c168e3e1506c9cf5d4cb13189fa284ec0706904 (patch) | |
tree | 35ded9f61f7c0c4213451f11488b3ef443d46738 /mono/example/BusListener.cs | |
parent | 73a69d496bb26356d684774cd1e98646a443c723 (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/example/BusListener.cs')
-rw-r--r-- | mono/example/BusListener.cs | 44 |
1 files changed, 44 insertions, 0 deletions
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; + } + } + + +} |