Commit c7214e11 authored by Jürg Billeter's avatar Jürg Billeter

D-Bus: Support [DBus (timeout = ...)] attribute in static clients

The attribute can be applied to D-Bus methods, properties, and parent
declarations. The timeout is specified in milliseconds.
parent 28a4035f
......@@ -44,6 +44,19 @@ internal class Vala.DBusClientModule : DBusModule {
}
}
public CCodeConstant get_dbus_timeout (Symbol symbol) {
int timeout = -1;
var dbus = symbol.get_attribute ("DBus");
if (dbus != null && dbus.has_argument ("timeout")) {
timeout = dbus.get_integer ("timeout");
} else if (symbol.parent_symbol != null) {
return get_dbus_timeout (symbol.parent_symbol);
}
return new CCodeConstant (timeout.to_string ());
}
bool has_dbus_error (List<DataType> error_types) {
foreach (DataType error_type in error_types) {
if (((ErrorType) error_type).error_domain.get_full_name () == "DBus.Error") {
......@@ -1304,7 +1317,7 @@ internal class Vala.DBusClientModule : DBusModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("dbus_connection_send_with_reply_and_block"));
ccall.add_argument (connection);
ccall.add_argument (new CCodeIdentifier ("_message"));
ccall.add_argument (new CCodeConstant ("-1"));
ccall.add_argument (get_dbus_timeout (m));
ccall.add_argument (dbus_error);
block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_reply"), ccall)));
......@@ -1802,7 +1815,7 @@ internal class Vala.DBusClientModule : DBusModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("dbus_connection_send_with_reply_and_block"));
ccall.add_argument (connection);
ccall.add_argument (new CCodeIdentifier ("_message"));
ccall.add_argument (new CCodeConstant ("-1"));
ccall.add_argument (get_dbus_timeout (m));
ccall.add_argument (dbus_error);
block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_reply"), ccall)));
......@@ -1976,7 +1989,7 @@ internal class Vala.DBusClientModule : DBusModule {
ccall.add_argument (connection);
ccall.add_argument (new CCodeIdentifier ("_message"));
ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier ("_pending")));
ccall.add_argument (new CCodeConstant ("-1"));
ccall.add_argument (get_dbus_timeout (m));
block.add_statement (new CCodeExpressionStatement (ccall));
var conn_unref = new CCodeFunctionCall (new CCodeIdentifier ("dbus_g_connection_unref"));
......@@ -2450,7 +2463,7 @@ internal class Vala.DBusClientModule : DBusModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("dbus_connection_send_with_reply_and_block"));
ccall.add_argument (connection);
ccall.add_argument (new CCodeIdentifier ("_message"));
ccall.add_argument (new CCodeConstant ("-1"));
ccall.add_argument (get_dbus_timeout (prop));
ccall.add_argument (dbus_error);
block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_reply"), ccall)));
......@@ -2603,7 +2616,7 @@ internal class Vala.DBusClientModule : DBusModule {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("dbus_connection_send_with_reply_and_block"));
ccall.add_argument (connection);
ccall.add_argument (new CCodeIdentifier ("_message"));
ccall.add_argument (new CCodeConstant ("-1"));
ccall.add_argument (get_dbus_timeout (prop));
ccall.add_argument (dbus_error);
block.add_statement (new CCodeExpressionStatement (new CCodeAssignment (new CCodeIdentifier ("_reply"), ccall)));
......
......@@ -81,7 +81,7 @@ internal class Vala.DBusModule : GAsyncModule {
public string get_dbus_name_for_member (Symbol symbol) {
var dbus = symbol.get_attribute ("DBus");
if (dbus != null) {
if (dbus != null && dbus.has_argument ("name")) {
return dbus.get_string ("name");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment