]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
Added UnregisterObject method.
authorOwen Fraser-Green <owen@discobabe.net>
Sun, 23 May 2004 21:33:14 +0000 (21:33 +0000)
committerOwen Fraser-Green <owen@discobabe.net>
Sun, 23 May 2004 21:33:14 +0000 (21:33 +0000)
ChangeLog
mono/Handler.cs
mono/Service.cs

index 30c958ffccdc2cc6886d4e1dc13c1ba0019f318b..a5fa0b8aaff0e0f2be671cd84b6bf88e57c51a79 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2004-05-23  Owen Fraser-Green  <owen@discobabe.net>
+
+       * mono/Handler.cs, mono/Service.cs: Added UnregisterObject method
+       which unregisters the object path and disposes the handler.
+
 2004-05-23  Kristian Høgsberg  <krh@redhat.com>
  
         Patch from Timo Teräs <ext-timo.teras@nokia.com> (#614):
index 000a78864bd8e1ca385850c73c3eae3e71c7d6ec..ce3974b6c359b3deb278195f722824f99b7af220 100644 (file)
@@ -13,7 +13,7 @@ namespace DBus
     NeedMemory = 2
   }
 
-  internal class Handler
+  internal class Handler : IDisposable
   {
     private string[] path = null;
     private string pathName = null;
@@ -22,6 +22,7 @@ namespace DBus
     private DBusObjectPathVTable vTable;
     private Connection connection;
     private Service service;
+    private bool disposed = false;
     
     internal delegate void DBusObjectPathUnregisterFunction(IntPtr rawConnection,
                                                            IntPtr userData);
@@ -52,12 +53,38 @@ namespace DBus
       }
     }
 
+    public void Dispose() 
+    {
+      Dispose(true);
+      GC.SuppressFinalize(this);
+    }
+    
+    private void Dispose(bool disposing) 
+    {
+      if (!disposed) { 
+       if (disposing) {
+         // Clean up managed resources
+       }
+
+       service = null;
+
+       // Clean up unmanaged resources
+       if (Connection != null && Connection.RawConnection != IntPtr.Zero && path != null) {
+         dbus_connection_unregister_object_path(Connection.RawConnection,
+                                                Path);
+       }       
+
+       connection = null;
+       introspector = null;
+       handledObject = null;
+      }
+      
+      disposed = true;    
+    }
+
     ~Handler() 
     {
-      if (Connection != null && Connection.RawConnection != IntPtr.Zero && path != null) {
-       dbus_connection_unregister_object_path(Connection.RawConnection,
-                                              Path);
-      } 
+      Dispose(false);
     }
 
     public Handler(object handledObject, 
@@ -119,7 +146,11 @@ namespace DBus
     public void Unregister_Called(IntPtr rawConnection, 
                                  IntPtr userData)
     {
-      System.Console.WriteLine("FIXME: Unregister called.");
+      if (service != null) {
+       service.UnregisterObject(HandledObject);
+      }
+
+      path = null;
     }
 
     private int Message_Called(IntPtr rawConnection, 
index 5dea31135394ef96f2d76b25d8c399a716b4a7df..167cfc4c0a4f3b8f836cbadbabc04d942860c1ac 100644 (file)
@@ -73,6 +73,13 @@ namespace DBus
       }
     }
 
+    public void UnregisterObject(object handledObject) 
+    {
+      Handler handler = (Handler) registeredHandlers[handledObject];
+      registeredHandlers.Remove(handledObject);
+      handler.Dispose();
+    }
+
     public void RegisterObject(object handledObject, 
                               string pathName) 
     {