summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Dionisio <michele.dionisio@gmail.com>2016-09-17 10:02:15 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2016-09-17 10:02:15 +0200
commit0431459492f94a9840f29abb143f7e29834e2d54 (patch)
tree63a075e17004b590c9ef6ac66058d6753c5f78c4
parentde38563e742fcf4041779ea19ec9458f57fa3879 (diff)
downloadvala-0431459492f94a9840f29abb143f7e29834e2d54.tar.gz
D-Bus: Support DBus.timeout attribute for client methods
https://bugzilla.gnome.org/show_bug.cgi?id=737913
-rw-r--r--codegen/valagdbusclientmodule.vala19
-rw-r--r--codegen/valagdbusmodule.vala4
-rw-r--r--vala/valausedattr.vala2
3 files changed, 17 insertions, 8 deletions
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index 59aa20ee3..7ec23876e 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -55,7 +55,7 @@ public class Vala.GDBusClientModule : GDBusModule {
push_function (func);
if (dynamic_method.dynamic_type.data_type == dbus_proxy_type) {
- generate_marshalling (method, CallType.SYNC, null, method.name);
+ generate_marshalling (method, CallType.SYNC, null, method.name, -1);
} else {
Report.error (method.source_reference, "dynamic methods are not supported for `%s'".printf (dynamic_method.dynamic_type.to_string ()));
}
@@ -554,7 +554,7 @@ public class Vala.GDBusClientModule : GDBusModule {
cfile.add_function (cfunc);
}
- void generate_marshalling (Method m, CallType call_type, string? iface_name, string? method_name) {
+ void generate_marshalling (Method m, CallType call_type, string? iface_name, string? method_name, int method_timeout) {
var gdbusproxy = new CCodeCastExpression (new CCodeIdentifier ("self"), "GDBusProxy *");
var connection = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_proxy_get_connection"));
@@ -575,8 +575,13 @@ public class Vala.GDBusClientModule : GDBusModule {
var object_path = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_proxy_get_object_path"));
object_path.add_argument (gdbusproxy);
- var timeout = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_proxy_get_default_timeout"));
- timeout.add_argument (gdbusproxy);
+ CCodeExpression timeout;
+ if (method_timeout <= 0) {
+ timeout = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_proxy_get_default_timeout"));
+ ((CCodeFunctionCall) timeout).add_argument (gdbusproxy);
+ } else {
+ timeout = new CCodeConstant ("%d".printf (method_timeout));
+ }
// register errors
foreach (var error_type in m.get_error_types ()) {
@@ -862,7 +867,7 @@ public class Vala.GDBusClientModule : GDBusModule {
push_function (function);
- generate_marshalling (m, no_reply ? CallType.NO_REPLY : CallType.SYNC, dbus_iface_name, get_dbus_name_for_member (m));
+ generate_marshalling (m, no_reply ? CallType.NO_REPLY : CallType.SYNC, dbus_iface_name, get_dbus_name_for_member (m), get_dbus_timeout_for_member (m));
pop_function ();
@@ -889,7 +894,7 @@ public class Vala.GDBusClientModule : GDBusModule {
push_function (function);
- generate_marshalling (m, CallType.ASYNC, dbus_iface_name, get_dbus_name_for_member (m));
+ generate_marshalling (m, CallType.ASYNC, dbus_iface_name, get_dbus_name_for_member (m), get_dbus_timeout_for_member (m));
pop_function ();
@@ -913,7 +918,7 @@ public class Vala.GDBusClientModule : GDBusModule {
push_function (function);
- generate_marshalling (m, CallType.FINISH, null, null);
+ generate_marshalling (m, CallType.FINISH, null, null, -1);
pop_function ();
diff --git a/codegen/valagdbusmodule.vala b/codegen/valagdbusmodule.vala
index edfc82731..8f10daa02 100644
--- a/codegen/valagdbusmodule.vala
+++ b/codegen/valagdbusmodule.vala
@@ -34,6 +34,10 @@ public class Vala.GDBusModule : GVariantModule {
return Symbol.lower_case_to_camel_case (symbol.name);
}
+ public static int get_dbus_timeout_for_member (Symbol symbol) {
+ return symbol.get_attribute_integer ("DBus", "timeout", -1);
+ }
+
public static bool is_dbus_visible (CodeNode node) {
var dbus_attribute = node.get_attribute ("DBus");
if (dbus_attribute != null
diff --git a/vala/valausedattr.vala b/vala/valausedattr.vala
index 588aaf7f8..6516e5e15 100644
--- a/vala/valausedattr.vala
+++ b/vala/valausedattr.vala
@@ -72,7 +72,7 @@ public class Vala.UsedAttr : CodeVisitor {
"GtkTemplate", "ui", "",
"GtkCallback", "name", "",
- "DBus", "name", "no_reply", "result", "use_string_marshalling", "value", "signature", "visible", "",
+ "DBus", "name", "no_reply", "result", "use_string_marshalling", "value", "signature", "visible", "timeout", "",
"GIR", "name", ""