diff options
author | Havoc Pennington <hp@redhat.com> | 2003-07-03 01:48:31 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-07-03 01:48:31 +0000 |
commit | a7560f456754bcebda988b0bf2cecc319bb61c3d (patch) | |
tree | 3ae799317c519805c9394cd0998b56dcd76b2dc9 /mono | |
parent | 23c9bbf77f49aec7d61590d399d0423fe44dd3b3 (diff) | |
download | dbus-a7560f456754bcebda988b0bf2cecc319bb61c3d.tar.gz |
2003-06-29 Havoc Pennington <hp@pobox.com>
* mono/Test.cs (class Test): fire up a main loop and run it
* mono/DBus.cs (DBus): don't g_thread_init since it can only be
done once, the app has to do it
2003-06-26 Havoc Pennington <hp@pobox.com>
* mono/Connection.cs: set up connection with the glib main loop
Diffstat (limited to 'mono')
-rw-r--r-- | mono/Connection.cs | 1 | ||||
-rw-r--r-- | mono/DBus.cs | 9 | ||||
-rw-r--r-- | mono/Test.cs | 48 |
3 files changed, 42 insertions, 16 deletions
diff --git a/mono/Connection.cs b/mono/Connection.cs index e22133f7..56dcb7a2 100644 --- a/mono/Connection.cs +++ b/mono/Connection.cs @@ -18,6 +18,7 @@ namespace DBus { error.Free (); throw e; } + dbus_connection_setup_with_g_main (raw, IntPtr.Zero); } // Keep in sync with C diff --git a/mono/DBus.cs b/mono/DBus.cs index f6f8b003..377af742 100644 --- a/mono/DBus.cs +++ b/mono/DBus.cs @@ -15,19 +15,10 @@ namespace DBus { internal const string GThreadname = "libgthread-2.0.so.0"; internal static void Init () { - if (!initialized) { - initialized = true; - g_thread_init (IntPtr.Zero); dbus_gthread_init (); - } } - - private static bool initialized = false; [DllImport (DBus.Internals.DBusGLibname, EntryPoint="dbus_gthread_init")] private extern static void dbus_gthread_init (); - - [DllImport (DBus.Internals.GThreadname, EntryPoint="g_thread_init")] - private extern static void g_thread_init (IntPtr vtable); } } diff --git a/mono/Test.cs b/mono/Test.cs index b64ed9c3..e92176f2 100644 --- a/mono/Test.cs +++ b/mono/Test.cs @@ -1,19 +1,53 @@ using System; +using System.Runtime.InteropServices; class Test { - static void Main() { - DBus.Message m; + static void Main() { + g_thread_init (IntPtr.Zero); + DBus.Connection c; // c = new DBus.Connection ("unix:path=/tmp/foobar"); - c = DBus.Connection.GetBus (DBus.Connection.BusType.Session); - - m = new DBus.Message ("org.freedesktop.Foo", - "org.freedesktop.DBus.Broadcast"); + try { + c = DBus.Connection.GetBus (DBus.Connection.BusType.Session); + } + catch (DBus.Exception e) { + Console.Error.WriteLine ("Failed to open connection: {0}", + e.Message); + return; + } + + DBus.Message m = new DBus.Message ("org.freedesktop.Foo", + "org.freedesktop.DBus.Broadcast"); c.Send (m); - c.Flush (); + c.Flush (); + + IntPtr loop = g_main_loop_new (IntPtr.Zero, false); + + g_main_loop_run (loop); + + g_main_loop_unref (loop); } + + internal const string GLibname = "libglib-2.0.so.0"; + internal const string GThreadname = "libgthread-2.0.so.0"; + + [DllImport (GLibname, EntryPoint="g_main_loop_new")] + private extern static IntPtr g_main_loop_new (IntPtr context, + bool is_running); + + [DllImport (GLibname, EntryPoint="g_main_loop_unref")] + private extern static void g_main_loop_unref (IntPtr loop); + + [DllImport (GLibname, EntryPoint="g_main_loop_run")] + private extern static void g_main_loop_run (IntPtr loop); + + [DllImport (GLibname, EntryPoint="g_main_loop_quit")] + private extern static void g_main_loop_quit (IntPtr loop); + + [DllImport (GThreadname, EntryPoint="g_thread_init")] + private extern static void g_thread_init (IntPtr vtable); } |