summaryrefslogtreecommitdiffstats
path: root/mono/Handler.cs
diff options
context:
space:
mode:
authorOwen Fraser-Green <owen@discobabe.net>2004-03-26 15:25:59 +0000
committerOwen Fraser-Green <owen@discobabe.net>2004-03-26 15:25:59 +0000
commit45277e93d8c8e18a04d1c28eb666337316726152 (patch)
tree46502f3644fad7cad6932e3d3267edf3a4a42eec /mono/Handler.cs
parent7dd57040236dc34a313948f75b403a49df693649 (diff)
Added signal support.
Diffstat (limited to 'mono/Handler.cs')
-rw-r--r--mono/Handler.cs74
1 files changed, 28 insertions, 46 deletions
diff --git a/mono/Handler.cs b/mono/Handler.cs
index a854c9ce..be03dc5e 100644
--- a/mono/Handler.cs
+++ b/mono/Handler.cs
@@ -6,6 +6,13 @@ namespace DBus
using System.Reflection;
using System.Collections;
+ internal enum Result
+ {
+ Handled = 0,
+ NotYetHandled = 1,
+ NeedMemory = 2
+ }
+
internal class Handler
{
private string[] path = null;
@@ -15,7 +22,6 @@ namespace DBus
private DBusObjectPathVTable vTable;
private Connection connection;
private Service service;
- private DBusHandleMessageFunction filterCalled;
internal delegate void DBusObjectPathUnregisterFunction(IntPtr rawConnection,
IntPtr userData);
@@ -24,18 +30,6 @@ namespace DBus
IntPtr rawMessage,
IntPtr userData);
- internal delegate int DBusHandleMessageFunction(IntPtr rawConnection,
- IntPtr rawMessage,
- IntPtr userData);
-
-
- private enum Result
- {
- Handled = 0,
- NotYetHandled = 1,
- NeedMemory = 2
- }
-
[StructLayout (LayoutKind.Sequential)]
private struct DBusObjectPathVTable
{
@@ -67,8 +61,8 @@ namespace DBus
}
public Handler(object handledObject,
- string pathName,
- Service service)
+ string pathName,
+ Service service)
{
Service = service;
Connection = service.Connection;
@@ -88,14 +82,22 @@ namespace DBus
ref vTable,
IntPtr.Zero))
throw new OutOfMemoryException();
-
- // Setup the filter function
- this.filterCalled = new DBusHandleMessageFunction(Filter_Called);
- if (!dbus_connection_add_filter(Connection.RawConnection,
- this.filterCalled,
- IntPtr.Zero,
- IntPtr.Zero))
- throw new OutOfMemoryException();
+
+ RegisterSignalHandlers();
+ }
+
+ private void RegisterSignalHandlers()
+ {
+ ProxyBuilder proxyBuilder = new ProxyBuilder(Service, HandledObject.GetType(), this.pathName);
+
+ foreach (DictionaryEntry interfaceEntry in this.introspector.InterfaceProxies) {
+ InterfaceProxy interfaceProxy = (InterfaceProxy) interfaceEntry.Value;
+ foreach (DictionaryEntry signalEntry in interfaceProxy.Signals) {
+ EventInfo eventE = (EventInfo) signalEntry.Value;
+ Delegate del = Delegate.CreateDelegate(eventE.EventHandlerType, proxyBuilder.GetSignalProxy(), "Proxy_" + eventE.Name);
+ eventE.AddEventHandler(HandledObject, del);
+ }
+ }
}
public object HandledObject
@@ -113,21 +115,6 @@ namespace DBus
this.introspector = Introspector.GetIntrospector(value.GetType());
}
}
-
- public int Filter_Called(IntPtr rawConnection,
- IntPtr rawMessage,
- IntPtr userData)
- {
- Message message = Message.Wrap(rawMessage, Service);
-
- if (message.Type == Message.MessageType.Signal) {
- Signal signal = (Signal) message;
- } else if (message.Type == Message.MessageType.MethodCall) {
- MethodCall methodCall = (MethodCall) message;
- }
-
- return (int) Result.NotYetHandled;
- }
public void Unregister_Called(IntPtr rawConnection,
IntPtr userData)
@@ -143,7 +130,8 @@ namespace DBus
switch (message.Type) {
case Message.MessageType.Signal:
- System.Console.WriteLine("FIXME: Signal called.");
+ // We're not interested in signals here because we're the ones
+ // that generate them!
break;
case Message.MessageType.MethodCall:
return (int) HandleMethod((MethodCall) message);
@@ -216,7 +204,7 @@ namespace DBus
{
this.service = value;
}
- }
+ }
[DllImport ("dbus-1")]
private extern static bool dbus_connection_register_object_path (IntPtr rawConnection, string[] path, ref DBusObjectPathVTable vTable, IntPtr userData);
@@ -224,11 +212,5 @@ namespace DBus
[DllImport ("dbus-1")]
private extern static void dbus_connection_unregister_object_path (IntPtr rawConnection, string[] path);
- [DllImport ("dbus-1")]
- private extern static bool dbus_connection_add_filter(IntPtr rawConnection,
- DBusHandleMessageFunction filter,
- IntPtr userData,
- IntPtr freeData);
-
}
}