index.html
Main Page
|
modules.html
Modules
|
namespaces.html
Namespace List
|
hierarchy.html
Class Hierarchy
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
namespacemembers.html
Namespace Members
|
functions.html
Data Fields
|
pages.html
Related Pages
dir_000000.html
mono
Handler.cs
00001
namespace
DBus
00002 {
00003
using
System;
00004
using
System.Runtime.InteropServices;
00005
using
System.Diagnostics;
00006
using
System.Reflection;
00007
using
System.Collections;
00008
namespaceDBus.html#a7
00009
internal
enum
namespaceDBus.html#a7
Result
00010   {
00011     Handled = 0,
00012     NotYetHandled = 1,
00013     NeedMemory = 2
00014   }
00015
classDBus_1_1Handler.html
00016
internal
class
classDBus_1_1Handler.html
Handler
00017   {
00018
private
string path = null;
00019
private
classDBus_1_1Introspector.html
Introspector
introspector = null;
00020
private
object handledObject = null;
00021
private
structDBus_1_1DBusObjectPathVTable.html
DBusObjectPathVTable
vTable;
00022
private
classDBus_1_1Connection.html
Connection
connection;
00023
private
classDBus_1_1Service.html
Service
service;
00024
00025
// We need to hold extra references to these callbacks so that they don't
00026
// get garbage collected before they are called back into from unmanaged
00027
// code.
00028
private
DBusObjectPathUnregisterFunction unregister_func;
00029
private
DBusObjectPathMessageFunction message_func;
00030
classDBus_1_1Handler.html#a0
00031
public
classDBus_1_1Handler.html#a0
Handler
(object handledObject,
00032                    string path,
00033
classDBus_1_1Service.html
Service
service)
00034     {
00035
classDBus_1_1Service.html
Service
= service;
00036
classDBus_1_1Connection.html
Connection
= service.
classDBus_1_1Service.html#01
Connection
;
00037
classDBus_1_1Handler.html#00
HandledObject
= handledObject;
00038
this
.path = path;
00039
00040
// Create the vTable and register the path
00041
this
.unregister_func =
new
DBusObjectPathUnregisterFunction (
classDBus_1_1Handler.html#a1
Unregister_Called
);
00042
this
.message_func =
new
DBusObjectPathMessageFunction (Message_Called);
00043
00044       vTable =
new
structDBus_1_1DBusObjectPathVTable.html
DBusObjectPathVTable
(
this
.unregister_func,
this
.message_func);
00045
classDBus_1_1Connection.html
Connection
.RegisterObjectPath (Path, vTable);
00046       RegisterSignalHandlers();
00047     }
00048
00049
private
void
RegisterSignalHandlers()
00050     {
00051
classDBus_1_1ProxyBuilder.html
ProxyBuilder
proxyBuilder =
new
classDBus_1_1ProxyBuilder.html
ProxyBuilder
(
classDBus_1_1Service.html
Service
,
classDBus_1_1Handler.html#00
HandledObject
.GetType(), Path);
00052
00053       foreach (DictionaryEntry interfaceEntry in
this
.introspector.
classDBus_1_1Introspector.html#00
InterfaceProxies
) {
00054
classDBus_1_1InterfaceProxy.html
InterfaceProxy
interfaceProxy = (
classDBus_1_1InterfaceProxy.html
InterfaceProxy
) interfaceEntry.Value;
00055         foreach (DictionaryEntry signalEntry in interfaceProxy.
classDBus_1_1InterfaceProxy.html#01
Signals
) {
00056           EventInfo eventE = (EventInfo) signalEntry.Value;
00057           Delegate del = Delegate.CreateDelegate(eventE.EventHandlerType, proxyBuilder.
classDBus_1_1ProxyBuilder.html#a4
GetSignalProxy
(),
"Proxy_"
+ eventE.Name);
00058           eventE.AddEventHandler(
classDBus_1_1Handler.html#00
HandledObject
, del);
00059         }
00060       }
00061     }
00062
00063
public
object
classDBus_1_1Handler.html#00
HandledObject
classDBus_1_1Handler.html#00
00064
{
00065       get {
00066
return
this
.handledObject;
00067       }
00068
00069       set {
00070
this
.handledObject = value;
00071
00072
// Register the methods
00073
this
.introspector =
classDBus_1_1Introspector.html
Introspector
.GetIntrospector(value.GetType());
00074       }
00075     }
00076
classDBus_1_1Handler.html#a1
00077
public
void
classDBus_1_1Handler.html#a1
Unregister_Called
(IntPtr rawConnection,
00078                                   IntPtr userData)
00079     {
00080
if
(service != null) {
00081         service.
classDBus_1_1Service.html#a2
UnregisterObject
(
classDBus_1_1Handler.html#00
HandledObject
);
00082       }
00083
00084       path = null;
00085     }
00086
00087
private
int
Message_Called(IntPtr rawConnection,
00088                                IntPtr rawMessage,
00089                                IntPtr userData)
00090     {
00091
classDBus_1_1Message.html
Message
message =
classDBus_1_1Message.html
Message
.Wrap(rawMessage,
classDBus_1_1Service.html
Service
);
00092
namespaceDBus.html#a7
Result
res =
namespaceDBus.html#a7
Result
.NotYetHandled;
00093
00094
switch
(message.
classDBus_1_1Message.html#010
Type
) {
00095
case
classDBus_1_1Message.html
Message
.MessageType.MethodCall:
00096         res = HandleMethod ((
classDBus_1_1MethodCall.html
MethodCall
) message);
00097
break
;
00098
00099
case
classDBus_1_1Message.html
Message
.MessageType.Signal:
00100
// We're not interested in signals here because we're the ones
00101
// that generate them!
00102
break
;
00103       }
00104
00105       message.
classDBus_1_1Message.html#a0
Dispose
();
00106
00107
return
(
int
) res;
00108     }
00109
00110
private
namespaceDBus.html#a7
Result
HandleMethod(MethodCall methodCall)
00111     {
00112       methodCall.Service = service;
00113
00114       InterfaceProxy interfaceProxy =
this
.introspector.
classDBus_1_1InterfaceProxy.html#e0
GetInterface
(methodCall.InterfaceName);
00115
if
(interfaceProxy == null || !interfaceProxy.HasMethod(methodCall.Key)) {
00116
// No such interface here.
00117
return
namespaceDBus.html#a7
Result
.NotYetHandled;
00118       }
00119
00120       MethodInfo method = interfaceProxy.GetMethod(methodCall.Key);
00121
00122       Message.Push (methodCall);
00123
00124
// Now call the method. FIXME: Error handling
00125       object [] args = methodCall.Arguments.GetParameters(method);
00126       object retVal = method.Invoke(
this
.handledObject, args);
00127
00128       Message.Pop ();
00129
00130
// Create the reply and send it
00131       MethodReturn methodReturn =
new
MethodReturn(methodCall);
00132       methodReturn.Arguments.AppendResults(method, retVal, args);
00133       methodReturn.Send();
00134
00135
return
namespaceDBus.html#a7
Result
.Handled;
00136     }
00137
00138     internal string Path
00139     {
00140       get
00141         {
00142
return
path;
00143         }
00144     }
00145
00146     internal Connection Connection
00147     {
00148       get
00149         {
00150
return
connection;
00151         }
00152
00153       set
00154         {
00155
this
.connection = value;
00156         }
00157     }
00158
00159
public
classDBus_1_1Handler.html#03
Service
classDBus_1_1Handler.html#03
Service
classDBus_1_1Handler.html#03
00160
{
00161       get
00162         {
00163
return
service;
00164         }
00165
00166       set
00167         {
00168
this
.service = value;
00169         }
00170     }
00171   }
00172 }
Generated on Tue Sep 13 01:28:08 2005 for D-BUS by
http://www.doxygen.org/index.html
doxygen
1.4.4
