+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):
NeedMemory = 2
}
- internal class Handler
+ internal class Handler : IDisposable
{
private string[] path = null;
private string pathName = null;
private DBusObjectPathVTable vTable;
private Connection connection;
private Service service;
+ private bool disposed = false;
internal delegate void DBusObjectPathUnregisterFunction(IntPtr rawConnection,
IntPtr userData);
}
}
+ 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,
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,
}
}
+ public void UnregisterObject(object handledObject)
+ {
+ Handler handler = (Handler) registeredHandlers[handledObject];
+ registeredHandlers.Remove(handledObject);
+ handler.Dispose();
+ }
+
public void RegisterObject(object handledObject,
string pathName)
{