summaryrefslogtreecommitdiffstats
path: root/mono
diff options
context:
space:
mode:
Diffstat (limited to 'mono')
-rw-r--r--mono/Arguments.cs12
-rw-r--r--mono/Connection.cs13
-rw-r--r--mono/DBusType/ObjectPath.cs20
-rw-r--r--mono/DBusType/String.cs21
-rw-r--r--mono/Service.cs27
5 files changed, 45 insertions, 48 deletions
diff --git a/mono/Arguments.cs b/mono/Arguments.cs
index 61ae443f..f8e3ccea 100644
--- a/mono/Arguments.cs
+++ b/mono/Arguments.cs
@@ -191,12 +191,6 @@ namespace DBus
return (char) dbusType.InvokeMember("Code", BindingFlags.Static | BindingFlags.GetField, null, null, null);
}
- // Get the type code for a given D-BUS type as a string
- public static string GetCodeAsString (Type dbusType)
- {
- return GetCode (dbusType).ToString ();
- }
-
// Get a complete method signature
public override string ToString()
{
@@ -215,7 +209,7 @@ namespace DBus
key += code;
} while (dbus_message_iter_next(iter));
}
-
+
Marshal.FreeCoTaskMem(iter);
return key;
@@ -231,7 +225,7 @@ namespace DBus
// Begin appending
public void InitAppending()
{
- dbus_message_iter_init_append(message.RawMessage, appenderIter);
+ dbus_message_append_iter_init(message.RawMessage, appenderIter);
}
// Get the enumerator
@@ -291,7 +285,7 @@ namespace DBus
}
[DllImport("dbus-1")]
- private extern static void dbus_message_iter_init_append(IntPtr rawMessage, IntPtr iter);
+ private extern static void dbus_message_append_iter_init(IntPtr rawMessage, IntPtr iter);
[DllImport("dbus-1")]
private extern static bool dbus_message_iter_has_next(IntPtr iter);
diff --git a/mono/Connection.cs b/mono/Connection.cs
index af0764db..50b2dd99 100644
--- a/mono/Connection.cs
+++ b/mono/Connection.cs
@@ -161,23 +161,22 @@ namespace DBus
{
if (!dbus_connection_register_object_path (RawConnection, path, ref vtable, IntPtr.Zero))
throw new OutOfMemoryException ();
-
+
this.object_paths[path] = vtable;
}
-
+
internal void UnregisterObjectPath (string path)
{
dbus_connection_unregister_object_path (RawConnection, path);
-
+
this.object_paths.Remove (path);
}
-
- public string UniqueName
+ public string BaseService
{
get
{
- return Marshal.PtrToStringAnsi (dbus_bus_get_unique_name (RawConnection));
+ return Marshal.PtrToStringAnsi (dbus_bus_get_base_service (RawConnection));
}
}
@@ -317,7 +316,7 @@ namespace DBus
private extern static void dbus_connection_disconnect (IntPtr ptr);
[DllImport ("dbus-1")]
- private extern static IntPtr dbus_bus_get_unique_name (IntPtr ptr);
+ private extern static IntPtr dbus_bus_get_base_service (IntPtr ptr);
[DllImport("dbus-1")]
private extern static bool dbus_connection_add_filter(IntPtr rawConnection,
diff --git a/mono/DBusType/ObjectPath.cs b/mono/DBusType/ObjectPath.cs
index 4f064d59..38952f4e 100644
--- a/mono/DBusType/ObjectPath.cs
+++ b/mono/DBusType/ObjectPath.cs
@@ -28,11 +28,10 @@ namespace DBus.DBusType
public ObjectPath(IntPtr iter, Service service)
{
- IntPtr raw;
+ IntPtr raw_str = dbus_message_iter_get_object_path (iter);
+ this.path = Marshal.PtrToStringAnsi (raw_str);
+ dbus_free (raw_str);
- dbus_message_iter_get_basic (iter, out raw);
-
- this.path = Marshal.PtrToStringAnsi (raw);
this.service = service;
}
@@ -50,10 +49,10 @@ namespace DBus.DBusType
public void Append(IntPtr iter)
{
- IntPtr marshalVal = Marshal.StringToHGlobalAnsi (Path);
+ IntPtr raw_str = Marshal.StringToHGlobalAnsi (Path);
- bool success = dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal);
- Marshal.FreeHGlobal (marshalVal);
+ bool success = dbus_message_iter_append_object_path (iter, raw_str);
+ Marshal.FreeHGlobal (raw_str);
if (!success)
throw new ApplicationException("Failed to append OBJECT_PATH argument:" + val);
@@ -99,9 +98,12 @@ namespace DBus.DBusType
}
[DllImport("dbus-1")]
- private extern static void dbus_message_iter_get_basic (IntPtr iter, out IntPtr path);
+ private extern static IntPtr dbus_message_iter_get_object_path(IntPtr iter);
[DllImport("dbus-1")]
- private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref IntPtr path);
+ private extern static bool dbus_message_iter_append_object_path(IntPtr iter, IntPtr path);
+
+ [DllImport("dbus-1")]
+ private extern static void dbus_free (IntPtr raw);
}
}
diff --git a/mono/DBusType/String.cs b/mono/DBusType/String.cs
index 3b619cfb..9d7502fa 100644
--- a/mono/DBusType/String.cs
+++ b/mono/DBusType/String.cs
@@ -25,19 +25,17 @@ namespace DBus.DBusType
public String(IntPtr iter, Service service)
{
- IntPtr raw;
-
- dbus_message_iter_get_basic (iter, out raw);
-
- this.val = Marshal.PtrToStringAnsi (raw);
+ IntPtr raw_str = dbus_message_iter_get_string (iter);
+ this.val = Marshal.PtrToStringAnsi (raw_str);
+ dbus_free (raw_str);
}
public void Append(IntPtr iter)
{
- IntPtr marshalVal = Marshal.StringToHGlobalAnsi (val);
+ IntPtr raw_str = Marshal.StringToHGlobalAnsi (val);
- bool success = dbus_message_iter_append_basic (iter, (int) Code, ref marshalVal);
- Marshal.FreeHGlobal (marshalVal);
+ bool success = dbus_message_iter_append_string (iter, raw_str);
+ Marshal.FreeHGlobal (raw_str);
if (!success)
throw new ApplicationException("Failed to append STRING argument:" + val);
@@ -87,9 +85,12 @@ namespace DBus.DBusType
}
[DllImport("dbus-1")]
- private extern static void dbus_message_iter_get_basic (IntPtr iter, out IntPtr value);
+ private extern static IntPtr dbus_message_iter_get_string(IntPtr iter);
[DllImport("dbus-1")]
- private extern static bool dbus_message_iter_append_basic (IntPtr iter, int type, ref IntPtr value);
+ private extern static bool dbus_message_iter_append_string(IntPtr iter, IntPtr value);
+
+ [DllImport("dbus-1")]
+ private extern static void dbus_free (IntPtr raw);
}
}
diff --git a/mono/Service.cs b/mono/Service.cs
index 40703a53..ea21233f 100644
--- a/mono/Service.cs
+++ b/mono/Service.cs
@@ -20,9 +20,6 @@ namespace DBus
private static AssemblyBuilder proxyAssembly;
private ModuleBuilder module = null;
- // Add a match for signals. FIXME: Can we filter the service?
- private const string MatchRule = "type='signal'";
-
internal Service(string name, Connection connection)
{
this.name = name;
@@ -38,7 +35,7 @@ namespace DBus
// This isn't used for now
uint flags = 0;
- if (dbus_bus_request_name (connection.RawConnection, name, flags, ref error) == -1) {
+ if (dbus_bus_acquire_service(connection.RawConnection, name, flags, ref error) == -1) {
throw new DBusException(error);
}
@@ -47,12 +44,12 @@ namespace DBus
this.local = true;
}
- public static bool HasOwner(Connection connection, string name)
+ public static bool Exists(Connection connection, string name)
{
Error error = new Error();
error.Init();
- if (dbus_bus_name_has_owner(connection.RawConnection,
+ if (dbus_bus_service_exists(connection.RawConnection,
name,
ref error)) {
return true;
@@ -66,10 +63,10 @@ namespace DBus
public static Service Get(Connection connection, string name)
{
- if (HasOwner(connection, name)) {
+ if (Exists(connection, name)) {
return new Service(name, connection);
} else {
- throw new ApplicationException("Name '" + name + "' does not exist.");
+ throw new ApplicationException("Service '" + name + "' does not exist.");
}
}
@@ -170,7 +167,10 @@ namespace DBus
{
get {
if (this.module == null) {
- this.module = ProxyAssembly.DefineDynamicModule(Name, Name + ".proxy.dll", true);
+ this.module = ProxyAssembly.GetDynamicModule (Name);
+
+ if (this.module == null)
+ this.module = ProxyAssembly.DefineDynamicModule (Name, true);
}
return this.module;
@@ -178,14 +178,15 @@ namespace DBus
}
[DllImport("dbus-1")]
- private extern static int dbus_bus_request_name(IntPtr rawConnection,
- string serviceName,
- uint flags, ref Error error);
+ private extern static int dbus_bus_acquire_service(IntPtr rawConnection,
+ string serviceName,
+ uint flags, ref Error error);
[DllImport("dbus-1")]
- private extern static bool dbus_bus_name_has_owner(IntPtr rawConnection,
+ private extern static bool dbus_bus_service_exists(IntPtr rawConnection,
string serviceName,
ref Error error);
+
}
}