4 using System.Runtime.InteropServices;
5 using System.Diagnostics;
6 using System.Collections;
7 using System.Reflection;
8 using System.Reflection.Emit;
12 private Connection connection;
14 private bool local = false;
15 private Hashtable registeredHandlers = new Hashtable();
16 internal ModuleBuilder module = null;
18 internal Service(string name, Connection connection)
21 this.connection = connection;
24 public Service(Connection connection, string name)
26 Error error = new Error();
29 // This isn't used for now
32 if (dbus_bus_acquire_service(connection.RawConnection, name, flags, ref error) == -1) {
33 throw new DBusException(error);
36 this.connection = connection;
41 public static bool Exists(Connection connection, string name)
43 Error error = new Error();
46 if (dbus_bus_service_exists(connection.RawConnection,
52 throw new DBusException(error);
58 public static Service Get(Connection connection, string name)
60 if (Exists(connection, name)) {
61 return new Service(name, connection);
63 throw new ApplicationException("Service '" + name + "' does not exist.");
67 public void RegisterObject(object handledObject,
70 Handler handler = new Handler(handledObject,
73 registeredHandlers.Add(handledObject, handler);
76 internal Handler GetHandler(object handledObject)
78 return (Handler) registeredHandlers[handledObject];
81 public object GetObject(Type type, string pathName)
83 ProxyBuilder builder = new ProxyBuilder(this, type, pathName);
84 object proxy = builder.GetProxy();
96 public Connection Connection
105 this.connection = value;
109 [DllImport ("dbus-1")]
110 private extern static int dbus_bus_acquire_service (IntPtr rawConnection, string serviceName, uint flags, ref Error error);
112 [DllImport ("dbus-1")]
113 private extern static bool dbus_bus_service_exists (IntPtr rawConnection, string serviceName, ref Error error);