From 632d54e0dbf5e405258be7afffbaa48942c06cbc Mon Sep 17 00:00:00 2001 From: Owen Fraser-Green Date: Tue, 23 Mar 2004 18:07:48 +0000 Subject: Added InterfaceProxy to Mono bindings to avoid having to generate a proxy for every registered object. Also added object_path functions to dbus-message. --- mono/Handler.cs | 56 +++++++++++++++++--------------------------------------- 1 file changed, 17 insertions(+), 39 deletions(-) (limited to 'mono/Handler.cs') diff --git a/mono/Handler.cs b/mono/Handler.cs index d565b7ec..a854c9ce 100644 --- a/mono/Handler.cs +++ b/mono/Handler.cs @@ -12,7 +12,6 @@ namespace DBus private string pathName = null; private Introspector introspector = null; private object handledObject = null; - private Hashtable handledMethods = null; private DBusObjectPathVTable vTable; private Connection connection; private Service service; @@ -99,33 +98,20 @@ namespace DBus throw new OutOfMemoryException(); } - private void RegisterMethod(MethodInfo method) - { - string key = method.Name + " " + Arguments.ParseParameters(method); - handledMethods.Add(key, method); - } - public object HandledObject { - get - { - return this.handledObject; - } + get { + return this.handledObject; + } - set - { - this.handledObject = value; - - object[] attributes; - - // Register the methods - this.handledMethods = new Hashtable(); - this.introspector = new Introspector(value.GetType()); - - foreach (MethodInfo method in this.introspector.Methods) { - RegisterMethod(method); - } - } + set { + this.handledObject = value; + + object[] attributes; + + // Register the methods + this.introspector = Introspector.GetIntrospector(value.GetType()); + } } public int Filter_Called(IntPtr rawConnection, @@ -169,22 +155,14 @@ namespace DBus private Result HandleMethod(MethodCall methodCall) { methodCall.Service = service; - - // Check the interface name matches - if (methodCall.InterfaceName != this.introspector.InterfaceName) { - return Result.NotYetHandled; - } - - // Iterate through getting the type codes - string key = methodCall.Name + " " + methodCall.Arguments; - - // Check it's one of our methods - if (!handledMethods.Contains(key)) { + + InterfaceProxy interfaceProxy = this.introspector.GetInterface(methodCall.InterfaceName); + if (interfaceProxy == null || !interfaceProxy.HasMethod(methodCall.Key)) { + // No such interface here. return Result.NotYetHandled; } - - // Got it! - MethodInfo method = (MethodInfo) handledMethods[key]; + + MethodInfo method = interfaceProxy.GetMethod(methodCall.Key); // Now call the method. FIXME: Error handling object [] args = methodCall.Arguments.GetParameters(method); -- cgit