]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
2003-06-29 Havoc Pennington <hp@pobox.com> dbus-object-names-branchpoint
authorHavoc Pennington <hp@redhat.com>
Thu, 3 Jul 2003 01:48:31 +0000 (01:48 +0000)
committerHavoc Pennington <hp@redhat.com>
Thu, 3 Jul 2003 01:48:31 +0000 (01:48 +0000)
* 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

ChangeLog
mono/Connection.cs
mono/DBus.cs
mono/Test.cs

index 12661ed8fff48d15c2a3ee56ea1f732a9abd5644..e68400830d09306cd97c3226cfe793051953084b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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
+
 2003-07-01  Havoc Pennington  <hp@redhat.com>
 
        * doc/dbus-specification.sgml: clarify the format of a type code, 
index e22133f74ac84bab4a8cba587cce2ea1482e4687..56dcb7a2b71a43ffd12754e8ef9be5c051fb01bf 100644 (file)
@@ -18,6 +18,7 @@ namespace DBus {
         error.Free ();
         throw e;
       }
+      dbus_connection_setup_with_g_main (raw, IntPtr.Zero);
     }
 
     // Keep in sync with C
index f6f8b003ad107acb70f6dc1d8b0426dc8f9eeab5..377af742ec8fd6ad9b387d7ef7898b1794887d35 100644 (file)
@@ -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); 
   }
 }
index b64ed9c3858d4b5d5b30b051cb9e4263c7c6b1fc..e92176f2aebf803e9acb7e48c3fa55e0a4f94bca 100644 (file)
@@ -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);
 }