summaryrefslogtreecommitdiffstats
path: root/mono
diff options
context:
space:
mode:
authorOwen Fraser-Green <owen@discobabe.net>2004-05-23 21:33:14 +0000
committerOwen Fraser-Green <owen@discobabe.net>2004-05-23 21:33:14 +0000
commite55e38d8dfc4255282b59a8fa1830f7b0b458685 (patch)
tree71a3b6232b580cd60ecd8f5e13613fab7e8f6856 /mono
parent14d9ef5be9667e3c1ed8447146d38d40b7ddaa62 (diff)
Added UnregisterObject method.
Diffstat (limited to 'mono')
-rw-r--r--mono/Handler.cs43
-rw-r--r--mono/Service.cs7
2 files changed, 44 insertions, 6 deletions
diff --git a/mono/Handler.cs b/mono/Handler.cs
index 000a7886..ce3974b6 100644
--- a/mono/Handler.cs
+++ b/mono/Handler.cs
@@ -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,
diff --git a/mono/Service.cs b/mono/Service.cs
index 5dea3113..167cfc4c 100644
--- a/mono/Service.cs
+++ b/mono/Service.cs
@@ -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)
{