[vala] D-Bus: Support BusName sender parameter in GDBus servers



commit 24ac6614bcca9552bb64677e81cdae9d32baed02
Author: Jürg Billeter <j bitron ch>
Date:   Mon Dec 20 22:57:13 2010 +0100

    D-Bus: Support BusName sender parameter in GDBus servers

 codegen/valagdbusclientmodule.vala |    5 +++++
 codegen/valagdbusservermodule.vala |   21 +++++++++++++++++++++
 vapi/glib-2.0.vapi                 |    6 ++++++
 3 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valagdbusclientmodule.vala b/codegen/valagdbusclientmodule.vala
index c69f212..4b945f3 100644
--- a/codegen/valagdbusclientmodule.vala
+++ b/codegen/valagdbusclientmodule.vala
@@ -496,6 +496,11 @@ public class Vala.GDBusClientModule : GDBusModule {
 						continue;
 					}
 
+					if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+						// ignore BusName sender parameters
+						continue;
+					}
+
 					send_dbus_value (param.variable_type, new CCodeIdentifier ("_arguments_builder"), expr, param);
 				}
 			}
diff --git a/codegen/valagdbusservermodule.vala b/codegen/valagdbusservermodule.vala
index f1a5284..688b2d7 100644
--- a/codegen/valagdbusservermodule.vala
+++ b/codegen/valagdbusservermodule.vala
@@ -124,6 +124,11 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 					continue;
 				}
 
+				if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+					// ignore BusName sender parameters
+					continue;
+				}
+
 				var owned_type = param.variable_type.copy ();
 				owned_type.value_owned = true;
 
@@ -152,6 +157,14 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 					continue;
 				}
 
+				if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+					// ignore BusName sender parameters
+					var sender = new CCodeFunctionCall (new CCodeIdentifier ("g_dbus_method_invocation_get_sender"));
+					sender.add_argument (new CCodeIdentifier ("invocation"));
+					ccall.add_argument (sender);
+					continue;
+				}
+
 				var st = param.variable_type.data_type as Struct;
 				if (st != null && !st.is_simple_type ()) {
 					ccall.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (param.name)));
@@ -351,6 +364,11 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 					continue;
 				}
 
+				if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+					// ignore BusName sender parameters
+					continue;
+				}
+
 				var owned_type = param.variable_type.copy ();
 				owned_type.value_owned = true;
 
@@ -816,6 +834,9 @@ public class Vala.GDBusServerModule : GDBusClientModule {
 				if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.Cancellable") {
 					continue;
 				}
+				if (param.variable_type is ObjectType && param.variable_type.data_type.get_full_name () == "GLib.BusName") {
+					continue;
+				}
 
 				var info = new CCodeInitializerList ();
 				info.append (new CCodeConstant ("-1"));
diff --git a/vapi/glib-2.0.vapi b/vapi/glib-2.0.vapi
index 9066509..ec8a51c 100644
--- a/vapi/glib-2.0.vapi
+++ b/vapi/glib-2.0.vapi
@@ -4321,6 +4321,12 @@ namespace GLib {
 		[CCode (cname = "g_strdup")]
 		public ObjectPath (string path);
 	}
+
+	[CCode (cname = "char", const_cname = "const char", copy_function = "g_strdup", free_function = "g_free", cheader_filename = "stdlib.h,string.h,glib.h", type_id = "G_TYPE_STRING", marshaller_type_name = "STRING", param_spec_function = "g_param_spec_string", get_value_function = "g_value_get_string", set_value_function = "g_value_set_string", take_value_function = "g_value_take_string")]
+	public class BusName : string {
+		[CCode (cname = "g_strdup")]
+		public BusName (string bus_name);
+	}
 #endif
 
 	[CCode (cname = "G_LIKELY", cheader_filename = "glib.h")]



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]