[vala] D-Bus: Support instantiating GDBus proxy with specific DBusConnection
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] D-Bus: Support instantiating GDBus proxy with specific DBusConnection
- Date: Thu, 9 Sep 2010 16:46:28 +0000 (UTC)
commit 8b30b56d76dc1f8d0e02b0e3c0b21ddc7994f57b
Author: Ole André Vadla Ravnås <oleavr gmail com>
Date: Sat Aug 7 02:04:49 2010 +0200
D-Bus: Support instantiating GDBus proxy with specific DBusConnection
codegen/valagdbusclientmodule.vala | 30 +++++++++++++++++++++---------
vapi/gio-2.0.vapi | 1 +
2 files changed, 22 insertions(+), 9 deletions(-)
---
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index fbc7955..168acbd 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -234,8 +234,9 @@ public class Vala.GDBusClientModule : GDBusModule {
public override void visit_method_call (MethodCall expr) {
var mtype = expr.call.value_type as MethodType;
- bool get_proxy_sync = (mtype != null && mtype.method_symbol.get_cname () == "g_bus_get_proxy_sync");
- if (!get_proxy_sync) {
+ bool bus_get_proxy_sync = (mtype != null && mtype.method_symbol.get_cname () == "g_bus_get_proxy_sync");
+ bool conn_get_proxy_sync = (mtype != null && mtype.method_symbol.get_cname () == "g_dbus_connection_get_proxy_sync");
+ if (!bus_get_proxy_sync && !conn_get_proxy_sync) {
base.visit_method_call (expr);
return;
}
@@ -250,11 +251,14 @@ public class Vala.GDBusClientModule : GDBusModule {
return;
}
+ var base_arg_index = 0;
+ if (bus_get_proxy_sync)
+ base_arg_index = 1;
+
var args = expr.get_argument_list ();
- Expression bus_type = args.get (0);
- Expression name = args.get (1);
- Expression object_path = args.get (2);
- Expression cancellable = args.get (3);
+ Expression name = args.get (base_arg_index + 0);
+ Expression object_path = args.get (base_arg_index + 1);
+ Expression cancellable = args.get (base_arg_index + 2);
// method can fail
current_method_inner_error = true;
@@ -269,9 +273,17 @@ public class Vala.GDBusClientModule : GDBusModule {
ccall.add_argument (new CCodeConstant ("\"g-name\""));
name.emit (this);
ccall.add_argument ((CCodeExpression) name.ccodenode);
- ccall.add_argument (new CCodeConstant ("\"g-bus-type\""));
- bus_type.emit (this);
- ccall.add_argument ((CCodeExpression) bus_type.ccodenode);
+ if (bus_get_proxy_sync) {
+ Expression bus_type = args.get (0);
+ ccall.add_argument (new CCodeConstant ("\"g-bus-type\""));
+ bus_type.emit (this);
+ ccall.add_argument ((CCodeExpression) bus_type.ccodenode);
+ } else {
+ Expression connection = ((MemberAccess) expr.call).inner;
+ ccall.add_argument (new CCodeConstant ("\"g-connection\""));
+ connection.emit (this);
+ ccall.add_argument ((CCodeExpression) connection.ccodenode);
+ }
ccall.add_argument (new CCodeConstant ("\"g-object-path\""));
object_path.emit (this);
ccall.add_argument ((CCodeExpression) object_path.ccodenode);
diff --git a/vapi/gio-2.0.vapi b/vapi/gio-2.0.vapi
index 6476dc5..475b2ae 100644
--- a/vapi/gio-2.0.vapi
+++ b/vapi/gio-2.0.vapi
@@ -194,6 +194,7 @@ namespace GLib {
public bool get_exit_on_close ();
public unowned string get_guid ();
public unowned GLib.Credentials get_peer_credentials ();
+ public T get_proxy_sync<T> (string? name, string object_path, GLib.Cancellable? cancellable = null) throws GLib.IOError;
public unowned GLib.IOStream get_stream ();
public unowned string get_unique_name ();
public bool is_closed ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]