GDBus: Use Skeleton instead of Stub

After some brainstorming with Simon, see

 https://bugzilla.gnome.org/show_bug.cgi?id=647577#c8

Signed-off-by: David Zeuthen <davidz@redhat.com>
This commit is contained in:
David Zeuthen 2011-04-13 16:33:51 -04:00
parent 683943b40e
commit 6ccca55752
23 changed files with 775 additions and 775 deletions

View File

@ -57,11 +57,11 @@
#GTypeInterface<!-- -->-derived type is generated for each D-Bus #GTypeInterface<!-- -->-derived type is generated for each D-Bus
interface. Additionally, for every generated type, interface. Additionally, for every generated type,
<type>FooBar</type>, two concrete instantiable types, <type>FooBar</type>, two concrete instantiable types,
<type>FooBarProxy</type> and <type>FooBarStub</type>, implementing <type>FooBarProxy</type> and <type>FooBarSkeleton</type>, implementing
said interface are also generated. The former is derived from said interface are also generated. The former is derived from
#GDBusProxy and intended for use on the client side #GDBusProxy and intended for use on the client side
while the latter is derived from the while the latter is derived from the
#GDBusInterfaceStub type making it easy to export on a #GDBusInterfaceSkeleton type making it easy to export on a
#GDBusConnection either directly or via a #GDBusConnection either directly or via a
#GDBusObjectManagerServer instance. #GDBusObjectManagerServer instance.
</para> </para>
@ -375,13 +375,13 @@ gdbus-codegen --generate-c-code myapp-generated \
#GTypeInterface<!-- -->-derived type called #GTypeInterface<!-- -->-derived type called
<type>MyAppFrobber</type> as well as two instantiable types with <type>MyAppFrobber</type> as well as two instantiable types with
the same name but suffixed with <type>Proxy</type> and the same name but suffixed with <type>Proxy</type> and
<type>Stub</type>. The generated file, roughly, contains the <type>Skeleton</type>. The generated file, roughly, contains the
following facilities: following facilities:
</para> </para>
<informalexample><programlisting><![CDATA[ <informalexample><programlisting><![CDATA[
/* GType macros for the three generated types */ /* GType macros for the three generated types */
#define MY_APP_TYPE_FROBBER (my_app_frobber_get_type ()) #define MY_APP_TYPE_FROBBER (my_app_frobber_get_type ())
#define MY_APP_TYPE_FROBBER_STUB (my_app_frobber_stub_get_type ()) #define MY_APP_TYPE_FROBBER_SKELETON (my_app_frobber_skeleton_get_type ())
#define MY_APP_TYPE_FROBBER_PROXY (my_app_frobber_proxy_get_type ()) #define MY_APP_TYPE_FROBBER_PROXY (my_app_frobber_proxy_get_type ())
typedef struct _MyAppFrobber MyAppFrobber; /* Dummy typedef */ typedef struct _MyAppFrobber MyAppFrobber; /* Dummy typedef */
@ -450,8 +450,8 @@ void my_app_frobber_set_verbose (MyAppFrobber *object,
/* Gets the interface info */ /* Gets the interface info */
GDBusInterfaceInfo *my_app_frobber_interface_info (void); GDBusInterfaceInfo *my_app_frobber_interface_info (void);
/* Creates a new stub object, ready to be exported */ /* Creates a new skeleton object, ready to be exported */
MyAppFrobber *my_app_frobber_stub_new (void); MyAppFrobber *my_app_frobber_skeleton_new (void);
/* Client-side proxy constructors. /* Client-side proxy constructors.
* *
@ -591,7 +591,7 @@ my_app_frobber_proxy_new_sync (GDBusConnection *connection,
</para> </para>
<para> <para>
Instead of subclassing, it is often easier to use the generated Instead of subclassing, it is often easier to use the generated
<type>MyAppFrobberStub</type> subclass. To handle incoming <type>MyAppFrobberSkeleton</type> subclass. To handle incoming
method calls, use <function>g_signal_connect()</function> with method calls, use <function>g_signal_connect()</function> with
the <function>::handle-*</function> signals and instead of the <function>::handle-*</function> signals and instead of
overriding #GObject<!-- -->'s overriding #GObject<!-- -->'s
@ -628,7 +628,7 @@ on_handle_hello_world (MyAppFrobber *object,
[...] [...]
object = my_app_frobber_stub_new (); object = my_app_frobber_skeleton_new ();
my_app_frobber_set_verbose (object, TRUE); my_app_frobber_set_verbose (object, TRUE);
g_signal_connect (object, g_signal_connect (object,
@ -651,7 +651,7 @@ on_handle_hello_world (MyAppFrobber *object,
emissions of the <ulink emissions of the <ulink
url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties">org.freedesktop.DBus.Properties::PropertiesChanged</ulink> url="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties">org.freedesktop.DBus.Properties::PropertiesChanged</ulink>
signal with all the properties that has changed. Use signal with all the properties that has changed. Use
g_dbus_interface_stub_flush() or g_dbus_object_stub_flush() to g_dbus_interface_skeleton_flush() or g_dbus_object_skeleton_flush() to
empty the queue immediately. empty the queue immediately.
</para> </para>
</refsect2> </refsect2>

View File

@ -165,10 +165,10 @@
<xi:include href="xml/gdbusnameowning.xml"/> <xi:include href="xml/gdbusnameowning.xml"/>
<xi:include href="xml/gdbusnamewatching.xml"/> <xi:include href="xml/gdbusnamewatching.xml"/>
<xi:include href="xml/gdbusinterface.xml"/> <xi:include href="xml/gdbusinterface.xml"/>
<xi:include href="xml/gdbusinterfacestub.xml"/> <xi:include href="xml/gdbusinterfaceskeleton.xml"/>
<xi:include href="xml/gdbusproxy.xml"/> <xi:include href="xml/gdbusproxy.xml"/>
<xi:include href="xml/gdbusobject.xml"/> <xi:include href="xml/gdbusobject.xml"/>
<xi:include href="xml/gdbusobjectstub.xml"/> <xi:include href="xml/gdbusobjectskeleton.xml"/>
<xi:include href="xml/gdbusobjectproxy.xml"/> <xi:include href="xml/gdbusobjectproxy.xml"/>
<xi:include href="xml/gdbusobjectmanager.xml"/> <xi:include href="xml/gdbusobjectmanager.xml"/>
<xi:include href="xml/gdbusobjectmanagerserver.xml"/> <xi:include href="xml/gdbusobjectmanagerserver.xml"/>

View File

@ -3145,33 +3145,33 @@ g_dbus_object_peek_with_typecheck
<SECTION> <SECTION>
<FILE>gdbusinterfacestub</FILE> <FILE>gdbusinterfaceskeleton</FILE>
<TITLE>GDBusInterfaceStub</TITLE> <TITLE>GDBusInterfaceSkeleton</TITLE>
GDBusInterfaceStub GDBusInterfaceSkeleton
GDBusInterfaceStubClass GDBusInterfaceSkeletonClass
g_dbus_interface_stub_flush g_dbus_interface_skeleton_flush
g_dbus_interface_stub_get_info g_dbus_interface_skeleton_get_info
g_dbus_interface_stub_get_vtable g_dbus_interface_skeleton_get_vtable
g_dbus_interface_stub_get_properties g_dbus_interface_skeleton_get_properties
g_dbus_interface_stub_export g_dbus_interface_skeleton_export
g_dbus_interface_stub_unexport g_dbus_interface_skeleton_unexport
g_dbus_interface_stub_get_connection g_dbus_interface_skeleton_get_connection
g_dbus_interface_stub_get_object_path g_dbus_interface_skeleton_get_object_path
GDBusInterfaceStubFlags GDBusInterfaceSkeletonFlags
g_dbus_interface_stub_get_flags g_dbus_interface_skeleton_get_flags
g_dbus_interface_stub_set_flags g_dbus_interface_skeleton_set_flags
<SUBSECTION Standard> <SUBSECTION Standard>
G_DBUS_INTERFACE_STUB G_DBUS_INTERFACE_SKELETON
G_IS_DBUS_INTERFACE_STUB G_IS_DBUS_INTERFACE_SKELETON
G_TYPE_DBUS_INTERFACE_STUB G_TYPE_DBUS_INTERFACE_SKELETON
g_dbus_interface_stub_get_type g_dbus_interface_skeleton_get_type
G_DBUS_INTERFACE_STUB_CLASS G_DBUS_INTERFACE_SKELETON_CLASS
G_IS_DBUS_INTERFACE_STUB_CLASS G_IS_DBUS_INTERFACE_SKELETON_CLASS
G_DBUS_INTERFACE_STUB_GET_CLASS G_DBUS_INTERFACE_SKELETON_GET_CLASS
<SUBSECTION Private> <SUBSECTION Private>
GDBusInterfaceStubPrivate GDBusInterfaceSkeletonPrivate
G_TYPE_DBUS_INTERFACE_STUB_FLAGS G_TYPE_DBUS_INTERFACE_SKELETON_FLAGS
g_dbus_interface_stub_flags_get_type g_dbus_interface_skeleton_flags_get_type
</SECTION> </SECTION>
<SECTION> <SECTION>
@ -3209,26 +3209,26 @@ GDBusObjectProxyPrivate
</SECTION> </SECTION>
<SECTION> <SECTION>
<FILE>gdbusobjectstub</FILE> <FILE>gdbusobjectskeleton</FILE>
<TITLE>GDBusObjectStub</TITLE> <TITLE>GDBusObjectSkeleton</TITLE>
GDBusObjectStub GDBusObjectSkeleton
GDBusObjectStubClass GDBusObjectSkeletonClass
g_dbus_object_stub_new g_dbus_object_skeleton_new
g_dbus_object_stub_flush g_dbus_object_skeleton_flush
g_dbus_object_stub_add_interface g_dbus_object_skeleton_add_interface
g_dbus_object_stub_remove_interface g_dbus_object_skeleton_remove_interface
g_dbus_object_stub_remove_interface_by_name g_dbus_object_skeleton_remove_interface_by_name
g_dbus_object_stub_set_object_path g_dbus_object_skeleton_set_object_path
<SUBSECTION Standard> <SUBSECTION Standard>
G_DBUS_OBJECT_STUB G_DBUS_OBJECT_SKELETON
G_IS_DBUS_OBJECT_STUB G_IS_DBUS_OBJECT_SKELETON
G_TYPE_DBUS_OBJECT_STUB G_TYPE_DBUS_OBJECT_SKELETON
g_dbus_object_stub_get_type g_dbus_object_skeleton_get_type
G_DBUS_OBJECT_STUB_CLASS G_DBUS_OBJECT_SKELETON_CLASS
G_IS_DBUS_OBJECT_STUB_CLASS G_IS_DBUS_OBJECT_SKELETON_CLASS
G_DBUS_OBJECT_STUB_GET_CLASS G_DBUS_OBJECT_SKELETON_GET_CLASS
<SUBSECTION Private> <SUBSECTION Private>
GDBusObjectStubPrivate GDBusObjectSkeletonPrivate
</SECTION> </SECTION>
<SECTION> <SECTION>

View File

@ -138,9 +138,9 @@ g_credentials_get_type
g_unix_credentials_message_get_type g_unix_credentials_message_get_type
g_time_zone_monitor_get_type g_time_zone_monitor_get_type
g_dbus_interface_get_type g_dbus_interface_get_type
g_dbus_interface_stub_get_type g_dbus_interface_skeleton_get_type
g_dbus_object_get_type g_dbus_object_get_type
g_dbus_object_stub_get_type g_dbus_object_skeleton_get_type
g_dbus_object_proxy_get_type g_dbus_object_proxy_get_type
g_dbus_object_manager_get_type g_dbus_object_manager_get_type
g_dbus_object_manager_client_get_type g_dbus_object_manager_client_get_type

View File

@ -83,9 +83,9 @@ gdbus_headers = \
gdbusmethodinvocation.h \ gdbusmethodinvocation.h \
gdbusserver.h \ gdbusserver.h \
gdbusinterface.h \ gdbusinterface.h \
gdbusinterfacestub.h \ gdbusinterfaceskeleton.h \
gdbusobject.h \ gdbusobject.h \
gdbusobjectstub.h \ gdbusobjectskeleton.h \
gdbusobjectproxy.h \ gdbusobjectproxy.h \
gdbusobjectmanager.h \ gdbusobjectmanager.h \
gdbusobjectmanagerclient.h \ gdbusobjectmanagerclient.h \
@ -112,9 +112,9 @@ gdbus_sources = \
gdbusmethodinvocation.h gdbusmethodinvocation.c \ gdbusmethodinvocation.h gdbusmethodinvocation.c \
gdbusserver.h gdbusserver.c \ gdbusserver.h gdbusserver.c \
gdbusinterface.h gdbusinterface.c \ gdbusinterface.h gdbusinterface.c \
gdbusinterfacestub.h gdbusinterfacestub.c \ gdbusinterfaceskeleton.h gdbusinterfaceskeleton.c \
gdbusobject.h gdbusobject.c \ gdbusobject.h gdbusobject.c \
gdbusobjectstub.h gdbusobjectstub.c \ gdbusobjectskeleton.h gdbusobjectskeleton.c \
gdbusobjectproxy.h gdbusobjectproxy.c \ gdbusobjectproxy.h gdbusobjectproxy.c \
gdbusobjectmanager.h gdbusobjectmanager.c \ gdbusobjectmanager.h gdbusobjectmanager.c \
gdbusobjectmanagerclient.h gdbusobjectmanagerclient.c \ gdbusobjectmanagerclient.h gdbusobjectmanagerclient.c \

View File

@ -419,35 +419,35 @@ class CodeGenerator:
self.h.write('#define %sPEEK_%s(object) (g_dbus_object_peek_with_typecheck (G_DBUS_OBJECT (object), "%s", %sTYPE_%s))\n'%(i.ns_upper, i.name_upper, i.name, i.ns_upper, i.name_upper)) self.h.write('#define %sPEEK_%s(object) (g_dbus_object_peek_with_typecheck (G_DBUS_OBJECT (object), "%s", %sTYPE_%s))\n'%(i.ns_upper, i.name_upper, i.name, i.ns_upper, i.name_upper))
self.h.write('\n') self.h.write('\n')
# Then the stub # Then the skeleton
self.h.write('\n') self.h.write('\n')
self.h.write('/* ---- */\n') self.h.write('/* ---- */\n')
self.h.write('\n') self.h.write('\n')
self.h.write('#define %sTYPE_%s_STUB (%s_stub_get_gtype ())\n'%(i.ns_upper, i.name_upper, i.name_lower)) self.h.write('#define %sTYPE_%s_SKELETON (%s_skeleton_get_gtype ())\n'%(i.ns_upper, i.name_upper, i.name_lower))
self.h.write('#define %s%s_STUB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), %sTYPE_%s_STUB, %sStub))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper, i.camel_name)) self.h.write('#define %s%s_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), %sTYPE_%s_SKELETON, %sSkeleton))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper, i.camel_name))
self.h.write('#define %s%s_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), %sTYPE_%s_STUB, %sStubClass))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper, i.camel_name)) self.h.write('#define %s%s_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), %sTYPE_%s_SKELETON, %sSkeletonClass))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper, i.camel_name))
self.h.write('#define %s%s_STUB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), %sTYPE_%s_STUB, %sStubClass))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper, i.camel_name)) self.h.write('#define %s%s_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), %sTYPE_%s_SKELETON, %sSkeletonClass))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper, i.camel_name))
self.h.write('#define %sIS_%s_STUB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), %sTYPE_%s_STUB))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper)) self.h.write('#define %sIS_%s_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), %sTYPE_%s_SKELETON))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper))
self.h.write('#define %sIS_%s_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), %sTYPE_%s_STUB))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper)) self.h.write('#define %sIS_%s_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), %sTYPE_%s_SKELETON))\n'%(i.ns_upper, i.name_upper, i.ns_upper, i.name_upper))
self.h.write('\n') self.h.write('\n')
self.h.write('typedef struct _%sStub %sStub;\n'%(i.camel_name, i.camel_name)) self.h.write('typedef struct _%sSkeleton %sSkeleton;\n'%(i.camel_name, i.camel_name))
self.h.write('typedef struct _%sStubClass %sStubClass;\n'%(i.camel_name, i.camel_name)) self.h.write('typedef struct _%sSkeletonClass %sSkeletonClass;\n'%(i.camel_name, i.camel_name))
self.h.write('typedef struct _%sStubPrivate %sStubPrivate;\n'%(i.camel_name, i.camel_name)) self.h.write('typedef struct _%sSkeletonPrivate %sSkeletonPrivate;\n'%(i.camel_name, i.camel_name))
self.h.write('\n') self.h.write('\n')
self.h.write('struct _%sStub\n'%(i.camel_name)) self.h.write('struct _%sSkeleton\n'%(i.camel_name))
self.h.write('{\n') self.h.write('{\n')
self.h.write(' GDBusInterfaceStub parent_instance;\n') self.h.write(' GDBusInterfaceSkeleton parent_instance;\n')
self.h.write(' %sStubPrivate *priv;\n'%(i.camel_name)) self.h.write(' %sSkeletonPrivate *priv;\n'%(i.camel_name))
self.h.write('};\n') self.h.write('};\n')
self.h.write('\n') self.h.write('\n')
self.h.write('struct _%sStubClass\n'%(i.camel_name)) self.h.write('struct _%sSkeletonClass\n'%(i.camel_name))
self.h.write('{\n') self.h.write('{\n')
self.h.write(' GDBusInterfaceStubClass parent_class;\n') self.h.write(' GDBusInterfaceSkeletonClass parent_class;\n')
self.h.write('};\n') self.h.write('};\n')
self.h.write('\n') self.h.write('\n')
self.h.write('GType %s_stub_get_gtype (void) G_GNUC_CONST;\n'%(i.name_lower)) self.h.write('GType %s_skeleton_get_gtype (void) G_GNUC_CONST;\n'%(i.name_lower))
self.h.write('\n') self.h.write('\n')
self.h.write('%s *%s_stub_new (void);\n'%(i.camel_name, i.name_lower)) self.h.write('%s *%s_skeleton_new (void);\n'%(i.camel_name, i.name_lower))
self.h.write('\n') self.h.write('\n')
@ -1327,12 +1327,12 @@ class CodeGenerator:
# --------------------------------------------------------------------------------------------------- # ---------------------------------------------------------------------------------------------------
def generate_stub(self, i): def generate_skeleton(self, i):
# class boilerplate # class boilerplate
self.c.write('/* ------------------------------------------------------------------------ */\n' self.c.write('/* ------------------------------------------------------------------------ */\n'
'\n') '\n')
self.c.write('struct _%sStubPrivate\n' self.c.write('struct _%sSkeletonPrivate\n'
'{\n' '{\n'
' GValueArray *properties;\n' ' GValueArray *properties;\n'
' GList *changed_properties;\n' ' GList *changed_properties;\n'
@ -1342,7 +1342,7 @@ class CodeGenerator:
'\n'%i.camel_name) '\n'%i.camel_name)
self.c.write('static void\n' self.c.write('static void\n'
'_%s_stub_handle_method_call (\n' '_%s_skeleton_handle_method_call (\n'
' GDBusConnection *connection,\n' ' GDBusConnection *connection,\n'
' const gchar *sender,\n' ' const gchar *sender,\n'
' const gchar *object_path,\n' ' const gchar *object_path,\n'
@ -1352,7 +1352,7 @@ class CodeGenerator:
' GDBusMethodInvocation *invocation,\n' ' GDBusMethodInvocation *invocation,\n'
' gpointer user_data)\n' ' gpointer user_data)\n'
'{\n' '{\n'
' %sStub *stub = %s%s_STUB (user_data);\n' ' %sSkeleton *skeleton = %s%s_SKELETON (user_data);\n'
' _ExtendedGDBusMethodInfo *info;\n' ' _ExtendedGDBusMethodInfo *info;\n'
' GVariantIter iter;\n' ' GVariantIter iter;\n'
' GVariant *child;\n' ' GVariant *child;\n'
@ -1368,7 +1368,7 @@ class CodeGenerator:
self.c.write (' num_params = g_variant_n_children (parameters);\n' self.c.write (' num_params = g_variant_n_children (parameters);\n'
' paramv = g_new0 (GValue, num_params + 2);\n' ' paramv = g_new0 (GValue, num_params + 2);\n'
' g_value_init (&paramv[0], %sTYPE_%s);\n' ' g_value_init (&paramv[0], %sTYPE_%s);\n'
' g_value_set_object (&paramv[0], stub);\n' ' g_value_set_object (&paramv[0], skeleton);\n'
' g_value_init (&paramv[1], G_TYPE_DBUS_METHOD_INVOCATION);\n' ' g_value_init (&paramv[1], G_TYPE_DBUS_METHOD_INVOCATION);\n'
' g_value_set_object (&paramv[1], invocation);\n' ' g_value_set_object (&paramv[1], invocation);\n'
%(i.ns_upper, i.name_upper)) %(i.ns_upper, i.name_upper))
@ -1403,7 +1403,7 @@ class CodeGenerator:
'\n') '\n')
self.c.write('static GVariant *\n' self.c.write('static GVariant *\n'
'_%s_stub_handle_get_property (\n' '_%s_skeleton_handle_get_property (\n'
' GDBusConnection *connection,\n' ' GDBusConnection *connection,\n'
' const gchar *sender,\n' ' const gchar *sender,\n'
' const gchar *object_path,\n' ' const gchar *object_path,\n'
@ -1412,7 +1412,7 @@ class CodeGenerator:
' GError **error,\n' ' GError **error,\n'
' gpointer user_data)\n' ' gpointer user_data)\n'
'{\n' '{\n'
' %sStub *stub = %s%s_STUB (user_data);\n' ' %sSkeleton *skeleton = %s%s_SKELETON (user_data);\n'
' GValue value = {0};\n' ' GValue value = {0};\n'
' GParamSpec *pspec;\n' ' GParamSpec *pspec;\n'
' _ExtendedGDBusPropertyInfo *info;\n' ' _ExtendedGDBusPropertyInfo *info;\n'
@ -1421,7 +1421,7 @@ class CodeGenerator:
self.c.write(' ret = NULL;\n' self.c.write(' ret = NULL;\n'
' info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_%s_interface_info, property_name);\n' ' info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_%s_interface_info, property_name);\n'
' g_assert (info != NULL);\n' ' g_assert (info != NULL);\n'
' pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (stub), info->hyphen_name);\n' ' pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);\n'
' if (pspec == NULL)\n' ' if (pspec == NULL)\n'
' {\n' ' {\n'
' g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %%s", property_name);\n' ' g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %%s", property_name);\n'
@ -1429,7 +1429,7 @@ class CodeGenerator:
' else\n' ' else\n'
' {\n' ' {\n'
' g_value_init (&value, pspec->value_type);\n' ' g_value_init (&value, pspec->value_type);\n'
' g_object_get_property (G_OBJECT (stub), info->hyphen_name, &value);\n' ' g_object_get_property (G_OBJECT (skeleton), info->hyphen_name, &value);\n'
' ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));\n' ' ret = g_dbus_gvalue_to_gvariant (&value, G_VARIANT_TYPE (info->parent_struct.signature));\n'
' g_value_unset (&value);\n' ' g_value_unset (&value);\n'
' }\n' ' }\n'
@ -1439,7 +1439,7 @@ class CodeGenerator:
%(i.name_lower)) %(i.name_lower))
self.c.write('static gboolean\n' self.c.write('static gboolean\n'
'_%s_stub_handle_set_property (\n' '_%s_skeleton_handle_set_property (\n'
' GDBusConnection *connection,\n' ' GDBusConnection *connection,\n'
' const gchar *sender,\n' ' const gchar *sender,\n'
' const gchar *object_path,\n' ' const gchar *object_path,\n'
@ -1449,7 +1449,7 @@ class CodeGenerator:
' GError **error,\n' ' GError **error,\n'
' gpointer user_data)\n' ' gpointer user_data)\n'
'{\n' '{\n'
' %sStub *stub = %s%s_STUB (user_data);\n' ' %sSkeleton *skeleton = %s%s_SKELETON (user_data);\n'
' GValue value = {0};\n' ' GValue value = {0};\n'
' GParamSpec *pspec;\n' ' GParamSpec *pspec;\n'
' _ExtendedGDBusPropertyInfo *info;\n' ' _ExtendedGDBusPropertyInfo *info;\n'
@ -1458,7 +1458,7 @@ class CodeGenerator:
self.c.write(' ret = FALSE;\n' self.c.write(' ret = FALSE;\n'
' info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_%s_interface_info, property_name);\n' ' info = (_ExtendedGDBusPropertyInfo *) g_dbus_interface_info_lookup_property ((GDBusInterfaceInfo *) &_%s_interface_info, property_name);\n'
' g_assert (info != NULL);\n' ' g_assert (info != NULL);\n'
' pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (stub), info->hyphen_name);\n' ' pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (skeleton), info->hyphen_name);\n'
' if (pspec == NULL)\n' ' if (pspec == NULL)\n'
' {\n' ' {\n'
' g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %%s", property_name);\n' ' g_set_error (error, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "No property with name %%s", property_name);\n'
@ -1469,7 +1469,7 @@ class CodeGenerator:
' g_value_set_variant (&value, variant);\n' ' g_value_set_variant (&value, variant);\n'
' else\n' ' else\n'
' g_dbus_gvariant_to_gvalue (variant, &value);\n' ' g_dbus_gvariant_to_gvalue (variant, &value);\n'
' g_object_set_property (G_OBJECT (stub), info->hyphen_name, &value);\n' ' g_object_set_property (G_OBJECT (skeleton), info->hyphen_name, &value);\n'
' g_value_unset (&value);\n' ' g_value_unset (&value);\n'
' ret = TRUE;\n' ' ret = TRUE;\n'
' }\n' ' }\n'
@ -1479,16 +1479,16 @@ class CodeGenerator:
%(i.name_lower)) %(i.name_lower))
self.c.write('static const GDBusInterfaceVTable _%s_stub_vtable =\n' self.c.write('static const GDBusInterfaceVTable _%s_skeleton_vtable =\n'
'{\n' '{\n'
' _%s_stub_handle_method_call,\n' ' _%s_skeleton_handle_method_call,\n'
' _%s_stub_handle_get_property,\n' ' _%s_skeleton_handle_get_property,\n'
' _%s_stub_handle_set_property\n' ' _%s_skeleton_handle_set_property\n'
'};\n' '};\n'
'\n'%(i.name_lower, i.name_lower, i.name_lower, i.name_lower)) '\n'%(i.name_lower, i.name_lower, i.name_lower, i.name_lower))
self.c.write('static GDBusInterfaceInfo *\n' self.c.write('static GDBusInterfaceInfo *\n'
'%s_stub_dbus_interface_get_info (GDBusInterfaceStub *stub)\n' '%s_skeleton_dbus_interface_get_info (GDBusInterfaceSkeleton *skeleton)\n'
'{\n' '{\n'
' return %s_interface_info ();\n' ' return %s_interface_info ();\n'
%(i.name_lower, i.name_lower)) %(i.name_lower, i.name_lower))
@ -1496,17 +1496,17 @@ class CodeGenerator:
'\n') '\n')
self.c.write('static GDBusInterfaceVTable *\n' self.c.write('static GDBusInterfaceVTable *\n'
'%s_stub_dbus_interface_get_vtable (GDBusInterfaceStub *stub)\n' '%s_skeleton_dbus_interface_get_vtable (GDBusInterfaceSkeleton *skeleton)\n'
'{\n' '{\n'
' return (GDBusInterfaceVTable *) &_%s_stub_vtable;\n' ' return (GDBusInterfaceVTable *) &_%s_skeleton_vtable;\n'
%(i.name_lower, i.name_lower)) %(i.name_lower, i.name_lower))
self.c.write('}\n' self.c.write('}\n'
'\n') '\n')
self.c.write('static GVariant *\n' self.c.write('static GVariant *\n'
'%s_stub_dbus_interface_get_properties (GDBusInterfaceStub *_stub)\n' '%s_skeleton_dbus_interface_get_properties (GDBusInterfaceSkeleton *_skeleton)\n'
'{\n' '{\n'
' %sStub *stub = %s%s_STUB (_stub);\n' ' %sSkeleton *skeleton = %s%s_SKELETON (_skeleton);\n'
%(i.name_lower, i.camel_name, i.ns_upper, i.name_upper)) %(i.name_lower, i.camel_name, i.ns_upper, i.name_upper))
self.c.write('\n' self.c.write('\n'
' GVariantBuilder builder;\n' ' GVariantBuilder builder;\n'
@ -1520,7 +1520,7 @@ class CodeGenerator:
' if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)\n' ' if (info->flags & G_DBUS_PROPERTY_INFO_FLAGS_READABLE)\n'
' {\n' ' {\n'
' GVariant *value;\n' ' GVariant *value;\n'
' value = _%s_stub_handle_get_property (g_dbus_interface_stub_get_connection (G_DBUS_INTERFACE_STUB (stub)), NULL, g_dbus_interface_stub_get_object_path (G_DBUS_INTERFACE_STUB (stub)), "%s", info->name, NULL, stub);\n' ' value = _%s_skeleton_handle_get_property (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)), NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "%s", info->name, NULL, skeleton);\n'
' if (value != NULL)\n' ' if (value != NULL)\n'
' {\n' ' {\n'
' if (g_variant_is_floating (value))\n' ' if (g_variant_is_floating (value))\n'
@ -1542,16 +1542,16 @@ class CodeGenerator:
%(i.name_lower)) %(i.name_lower))
self.c.write('static void\n' self.c.write('static void\n'
'%s_stub_dbus_interface_flush (GDBusInterfaceStub *_stub)\n' '%s_skeleton_dbus_interface_flush (GDBusInterfaceSkeleton *_skeleton)\n'
'{\n' '{\n'
%(i.name_lower)) %(i.name_lower))
if len(i.properties) > 0: if len(i.properties) > 0:
self.c.write(' %sStub *stub = %s%s_STUB (_stub);\n' self.c.write(' %sSkeleton *skeleton = %s%s_SKELETON (_skeleton);\n'
' if (stub->priv->changed_properties_idle_source != NULL)\n' ' if (skeleton->priv->changed_properties_idle_source != NULL)\n'
' {\n' ' {\n'
' g_source_destroy (stub->priv->changed_properties_idle_source);\n' ' g_source_destroy (skeleton->priv->changed_properties_idle_source);\n'
' stub->priv->changed_properties_idle_source = NULL;\n' ' skeleton->priv->changed_properties_idle_source = NULL;\n'
' _%s_emit_changed (stub);\n' ' _%s_emit_changed (skeleton);\n'
' }\n' ' }\n'
%(i.camel_name, i.ns_upper, i.name_upper, i.name_lower)) %(i.camel_name, i.ns_upper, i.name_upper, i.name_lower))
self.c.write('}\n' self.c.write('}\n'
@ -1565,13 +1565,13 @@ class CodeGenerator:
self.c.write(',\n %s%s'%(a.ctype_in, a.name)) self.c.write(',\n %s%s'%(a.ctype_in, a.name))
self.c.write(')\n' self.c.write(')\n'
'{\n' '{\n'
' %sStub *stub = %s%s_STUB (object);\n' ' %sSkeleton *skeleton = %s%s_SKELETON (object);\n'
' GDBusConnection *connection = g_dbus_interface_stub_get_connection (G_DBUS_INTERFACE_STUB (stub));\n' ' GDBusConnection *connection = g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton));\n'
%(i.camel_name, i.ns_upper, i.name_upper)) %(i.camel_name, i.ns_upper, i.name_upper))
self.c.write(' if (connection == NULL)\n' self.c.write(' if (connection == NULL)\n'
' return;\n' ' return;\n'
' g_dbus_connection_emit_signal (connection,\n' ' g_dbus_connection_emit_signal (connection,\n'
' NULL, g_dbus_interface_stub_get_object_path (G_DBUS_INTERFACE_STUB (stub)), "%s", "%s",\n' ' NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)), "%s", "%s",\n'
' g_variant_new ("(' ' g_variant_new ("('
%(i.name, s.name)) %(i.name, s.name))
for a in s.args: for a in s.args:
@ -1584,7 +1584,7 @@ class CodeGenerator:
'\n') '\n')
self.c.write('static void\n' self.c.write('static void\n'
'%s_stub_iface_init (%sIface *iface)\n' '%s_skeleton_iface_init (%sIface *iface)\n'
'{\n' '{\n'
%(i.name_lower, i.camel_name)) %(i.name_lower, i.camel_name))
for s in i.signals: for s in i.signals:
@ -1592,39 +1592,39 @@ class CodeGenerator:
%(s.name_lower, i.name_lower, s.name_lower)) %(s.name_lower, i.name_lower, s.name_lower))
self.c.write('}\n' self.c.write('}\n'
'\n') '\n')
self.c.write('#define %s_stub_get_type %s_stub_get_gtype\n'%(i.name_lower, i.name_lower)) self.c.write('#define %s_skeleton_get_type %s_skeleton_get_gtype\n'%(i.name_lower, i.name_lower))
self.c.write('G_DEFINE_TYPE_WITH_CODE (%sStub, %s_stub, G_TYPE_DBUS_INTERFACE_STUB,\n'%(i.camel_name, i.name_lower)) self.c.write('G_DEFINE_TYPE_WITH_CODE (%sSkeleton, %s_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,\n'%(i.camel_name, i.name_lower))
self.c.write(' G_IMPLEMENT_INTERFACE (%sTYPE_%s, %s_stub_iface_init));\n'%(i.ns_upper, i.name_upper, i.name_lower)) self.c.write(' G_IMPLEMENT_INTERFACE (%sTYPE_%s, %s_skeleton_iface_init));\n'%(i.ns_upper, i.name_upper, i.name_lower))
self.c.write('#undef %s_stub_get_type\n' self.c.write('#undef %s_skeleton_get_type\n'
'\n'%(i.name_lower)) '\n'%(i.name_lower))
# finalize # finalize
self.c.write('static void\n' self.c.write('static void\n'
'%s_stub_finalize (GObject *object)\n' '%s_skeleton_finalize (GObject *object)\n'
'{\n'%(i.name_lower)) '{\n'%(i.name_lower))
self.c.write(' %sStub *stub = %s%s_STUB (object);\n'%(i.camel_name, i.ns_upper, i.name_upper)) self.c.write(' %sSkeleton *skeleton = %s%s_SKELETON (object);\n'%(i.camel_name, i.ns_upper, i.name_upper))
if len(i.properties) > 0: if len(i.properties) > 0:
self.c.write(' g_value_array_free (stub->priv->properties);\n') self.c.write(' g_value_array_free (skeleton->priv->properties);\n')
self.c.write(' g_list_foreach (stub->priv->changed_properties, (GFunc) _changed_property_free, NULL);\n') self.c.write(' g_list_foreach (skeleton->priv->changed_properties, (GFunc) _changed_property_free, NULL);\n')
self.c.write(' g_list_free (stub->priv->changed_properties);\n') self.c.write(' g_list_free (skeleton->priv->changed_properties);\n')
self.c.write(' if (stub->priv->changed_properties_idle_source != NULL)\n') self.c.write(' if (skeleton->priv->changed_properties_idle_source != NULL)\n')
self.c.write(' g_source_destroy (stub->priv->changed_properties_idle_source);\n') self.c.write(' g_source_destroy (skeleton->priv->changed_properties_idle_source);\n')
self.c.write(' if (stub->priv->context != NULL)\n') self.c.write(' if (skeleton->priv->context != NULL)\n')
self.c.write(' g_main_context_unref (stub->priv->context);\n') self.c.write(' g_main_context_unref (skeleton->priv->context);\n')
self.c.write(' G_OBJECT_CLASS (%s_stub_parent_class)->finalize (object);\n' self.c.write(' G_OBJECT_CLASS (%s_skeleton_parent_class)->finalize (object);\n'
'}\n' '}\n'
'\n'%(i.name_lower)) '\n'%(i.name_lower))
# property accessors (TODO: generate PropertiesChanged signals in setter) # property accessors (TODO: generate PropertiesChanged signals in setter)
self.c.write('static void\n' self.c.write('static void\n'
'%s_stub_get_property (GObject *object,\n' '%s_skeleton_get_property (GObject *object,\n'
' guint prop_id,\n' ' guint prop_id,\n'
' GValue *value,\n' ' GValue *value,\n'
' GParamSpec *pspec)\n' ' GParamSpec *pspec)\n'
'{\n'%(i.name_lower)) '{\n'%(i.name_lower))
self.c.write(' %sStub *stub = %s%s_STUB (object);\n' self.c.write(' %sSkeleton *skeleton = %s%s_SKELETON (object);\n'
' g_assert (prop_id - 1 >= 0 && prop_id - 1 < %d);\n' ' g_assert (prop_id - 1 >= 0 && prop_id - 1 < %d);\n'
' g_value_copy (&stub->priv->properties->values[prop_id - 1], value);\n' ' g_value_copy (&skeleton->priv->properties->values[prop_id - 1], value);\n'
%(i.camel_name, i.ns_upper, i.name_upper, len(i.properties))) %(i.camel_name, i.ns_upper, i.name_upper, len(i.properties)))
self.c.write('}\n' self.c.write('}\n'
'\n') '\n')
@ -1632,14 +1632,14 @@ class CodeGenerator:
self.c.write('static gboolean\n' self.c.write('static gboolean\n'
'_%s_emit_changed (gpointer user_data)\n' '_%s_emit_changed (gpointer user_data)\n'
'{\n' '{\n'
' %sStub *stub = %s%s_STUB (user_data);\n' ' %sSkeleton *skeleton = %s%s_SKELETON (user_data);\n'
%(i.name_lower, i.camel_name, i.ns_upper, i.name_upper)) %(i.name_lower, i.camel_name, i.ns_upper, i.name_upper))
self.c.write(' GList *l;\n' self.c.write(' GList *l;\n'
' GVariantBuilder builder;\n' ' GVariantBuilder builder;\n'
' GVariantBuilder invalidated_builder;\n' ' GVariantBuilder invalidated_builder;\n'
' g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));\n' ' g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));\n'
' g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));\n' ' g_variant_builder_init (&invalidated_builder, G_VARIANT_TYPE ("as"));\n'
' for (l = stub->priv->changed_properties; l != NULL; l = l->next)\n' ' for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)\n'
' {\n' ' {\n'
' ChangedProperty *cp = l->data;\n' ' ChangedProperty *cp = l->data;\n'
' GVariant *variant;\n' ' GVariant *variant;\n'
@ -1647,8 +1647,8 @@ class CodeGenerator:
' g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);\n' ' g_variant_builder_add (&builder, "{sv}", cp->info->parent_struct.name, variant);\n'
' g_variant_unref (variant);\n' ' g_variant_unref (variant);\n'
' }\n' ' }\n'
' g_dbus_connection_emit_signal (g_dbus_interface_stub_get_connection (G_DBUS_INTERFACE_STUB (stub)),\n' ' g_dbus_connection_emit_signal (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)),\n'
' NULL, g_dbus_interface_stub_get_object_path (G_DBUS_INTERFACE_STUB (stub)),\n' ' NULL, g_dbus_interface_skeleton_get_object_path (G_DBUS_INTERFACE_SKELETON (skeleton)),\n'
' "org.freedesktop.DBus.Properties",\n' ' "org.freedesktop.DBus.Properties",\n'
' "PropertiesChanged",\n' ' "PropertiesChanged",\n'
' g_variant_new ("(sa{sv}as)",\n' ' g_variant_new ("(sa{sv}as)",\n'
@ -1656,21 +1656,21 @@ class CodeGenerator:
' &builder, &invalidated_builder),\n' ' &builder, &invalidated_builder),\n'
' NULL);\n' ' NULL);\n'
%(i.name)) %(i.name))
self.c.write(' g_list_foreach (stub->priv->changed_properties, (GFunc) _changed_property_free, NULL);\n') self.c.write(' g_list_foreach (skeleton->priv->changed_properties, (GFunc) _changed_property_free, NULL);\n')
self.c.write(' g_list_free (stub->priv->changed_properties);\n') self.c.write(' g_list_free (skeleton->priv->changed_properties);\n')
self.c.write(' stub->priv->changed_properties = NULL;\n') self.c.write(' skeleton->priv->changed_properties = NULL;\n')
self.c.write(' stub->priv->changed_properties_idle_source = NULL;\n') self.c.write(' skeleton->priv->changed_properties_idle_source = NULL;\n')
self.c.write(' return FALSE;\n' self.c.write(' return FALSE;\n'
'}\n' '}\n'
'\n') '\n')
# if property is already scheduled then re-use entry # if property is already scheduled then re-use entry
self.c.write('static void\n' self.c.write('static void\n'
'_%s_schedule_emit_changed (%sStub *stub, const _ExtendedGDBusPropertyInfo *info, GParamSpec *pspec, const GValue *value)\n' '_%s_schedule_emit_changed (%sSkeleton *skeleton, const _ExtendedGDBusPropertyInfo *info, GParamSpec *pspec, const GValue *value)\n'
'{\n' '{\n'
' ChangedProperty *cp;\n' ' ChangedProperty *cp;\n'
' GList *l;\n' ' GList *l;\n'
' cp = NULL;\n' ' cp = NULL;\n'
' for (l = stub->priv->changed_properties; l != NULL; l = l->next)\n' ' for (l = skeleton->priv->changed_properties; l != NULL; l = l->next)\n'
' {\n' ' {\n'
' ChangedProperty *i_cp = l->data;\n' ' ChangedProperty *i_cp = l->data;\n'
' if (i_cp->info == info)\n' ' if (i_cp->info == info)\n'
@ -1685,88 +1685,88 @@ class CodeGenerator:
' cp = g_new0 (ChangedProperty, 1);\n' ' cp = g_new0 (ChangedProperty, 1);\n'
' cp->pspec = pspec;\n' ' cp->pspec = pspec;\n'
' cp->info = info;\n' ' cp->info = info;\n'
' stub->priv->changed_properties = g_list_prepend (stub->priv->changed_properties, cp);\n' ' skeleton->priv->changed_properties = g_list_prepend (skeleton->priv->changed_properties, cp);\n'
' }\n' ' }\n'
' g_value_init (&cp->value, G_VALUE_TYPE (value));\n' ' g_value_init (&cp->value, G_VALUE_TYPE (value));\n'
' g_value_copy (value, &cp->value);\n' ' g_value_copy (value, &cp->value);\n'
' if (stub->priv->changed_properties_idle_source == NULL)\n' ' if (skeleton->priv->changed_properties_idle_source == NULL)\n'
' {\n' ' {\n'
' stub->priv->changed_properties_idle_source = g_idle_source_new ();\n' ' skeleton->priv->changed_properties_idle_source = g_idle_source_new ();\n'
' g_source_set_priority (stub->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);\n' ' g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);\n'
' g_source_set_callback (stub->priv->changed_properties_idle_source, _%s_emit_changed, g_object_ref (stub), (GDestroyNotify) g_object_unref);\n' ' g_source_set_callback (skeleton->priv->changed_properties_idle_source, _%s_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);\n'
' g_source_attach (stub->priv->changed_properties_idle_source, stub->priv->context);\n' ' g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);\n'
' g_source_unref (stub->priv->changed_properties_idle_source);\n' ' g_source_unref (skeleton->priv->changed_properties_idle_source);\n'
' }\n' ' }\n'
'}\n' '}\n'
'\n' '\n'
%(i.name_lower, i.camel_name, i.name_lower)) %(i.name_lower, i.camel_name, i.name_lower))
self.c.write('static void\n' self.c.write('static void\n'
'%s_stub_set_property (GObject *object,\n' '%s_skeleton_set_property (GObject *object,\n'
' guint prop_id,\n' ' guint prop_id,\n'
' const GValue *value,\n' ' const GValue *value,\n'
' GParamSpec *pspec)\n' ' GParamSpec *pspec)\n'
'{\n'%(i.name_lower)) '{\n'%(i.name_lower))
if len(i.properties) > 0: if len(i.properties) > 0:
self.c.write(' %sStub *stub = %s%s_STUB (object);\n' self.c.write(' %sSkeleton *skeleton = %s%s_SKELETON (object);\n'
' g_assert (prop_id - 1 >= 0 && prop_id - 1 < %d);\n' ' g_assert (prop_id - 1 >= 0 && prop_id - 1 < %d);\n'
' if (!_g_value_equal (value, &stub->priv->properties->values[prop_id - 1]))\n' ' if (!_g_value_equal (value, &skeleton->priv->properties->values[prop_id - 1]))\n'
' {\n' ' {\n'
' g_value_copy (value, &stub->priv->properties->values[prop_id - 1]);\n' ' g_value_copy (value, &skeleton->priv->properties->values[prop_id - 1]);\n'
' g_object_notify_by_pspec (object, pspec);\n' ' g_object_notify_by_pspec (object, pspec);\n'
' if (g_dbus_interface_stub_get_connection (G_DBUS_INTERFACE_STUB (stub)) != NULL)\n' ' if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)\n'
' _%s_schedule_emit_changed (stub, _%s_property_info_pointers[prop_id - 1], pspec, value);\n' ' _%s_schedule_emit_changed (skeleton, _%s_property_info_pointers[prop_id - 1], pspec, value);\n'
' }\n' ' }\n'
%(i.camel_name, i.ns_upper, i.name_upper, len(i.properties), i.name_lower, i.name_lower)) %(i.camel_name, i.ns_upper, i.name_upper, len(i.properties), i.name_lower, i.name_lower))
self.c.write('}\n' self.c.write('}\n'
'\n') '\n')
self.c.write('static void\n' self.c.write('static void\n'
'%s_stub_init (%sStub *stub)\n' '%s_skeleton_init (%sSkeleton *skeleton)\n'
'{\n' '{\n'
' stub->priv = G_TYPE_INSTANCE_GET_PRIVATE (stub, %sTYPE_%s_STUB, %sStubPrivate);\n' ' skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, %sTYPE_%s_SKELETON, %sSkeletonPrivate);\n'
%(i.name_lower, i.camel_name, i.ns_upper, i.name_upper, i.camel_name)) %(i.name_lower, i.camel_name, i.ns_upper, i.name_upper, i.camel_name))
self.c.write(' stub->priv->context = g_main_context_get_thread_default ();\n') self.c.write(' skeleton->priv->context = g_main_context_get_thread_default ();\n')
self.c.write(' if (stub->priv->context != NULL)\n') self.c.write(' if (skeleton->priv->context != NULL)\n')
self.c.write(' g_main_context_ref (stub->priv->context);\n') self.c.write(' g_main_context_ref (skeleton->priv->context);\n')
if len(i.properties) > 0: if len(i.properties) > 0:
self.c.write(' stub->priv->properties = g_value_array_new (%d);\n'%(len(i.properties))) self.c.write(' skeleton->priv->properties = g_value_array_new (%d);\n'%(len(i.properties)))
n = 0 n = 0
for p in i.properties: for p in i.properties:
self.c.write(' g_value_array_append (stub->priv->properties, NULL);\n') self.c.write(' g_value_array_append (skeleton->priv->properties, NULL);\n')
self.c.write(' g_value_init (&stub->priv->properties->values[%d], %s);\n'%(n, p.arg.gtype)) self.c.write(' g_value_init (&skeleton->priv->properties->values[%d], %s);\n'%(n, p.arg.gtype))
n += 1 n += 1
self.c.write('}\n' self.c.write('}\n'
'\n') '\n')
self.c.write('static void\n' self.c.write('static void\n'
'%s_stub_class_init (%sStubClass *klass)\n' '%s_skeleton_class_init (%sSkeletonClass *klass)\n'
'{\n' '{\n'
' GObjectClass *gobject_class;\n' ' GObjectClass *gobject_class;\n'
' GDBusInterfaceStubClass *stub_class;\n' ' GDBusInterfaceSkeletonClass *skeleton_class;\n'
'\n' '\n'
' g_type_class_add_private (klass, sizeof (%sStubPrivate));\n' ' g_type_class_add_private (klass, sizeof (%sSkeletonPrivate));\n'
'\n' '\n'
' gobject_class = G_OBJECT_CLASS (klass);\n' ' gobject_class = G_OBJECT_CLASS (klass);\n'
' gobject_class->finalize = %s_stub_finalize;\n' ' gobject_class->finalize = %s_skeleton_finalize;\n'
' gobject_class->get_property = %s_stub_get_property;\n' ' gobject_class->get_property = %s_skeleton_get_property;\n'
' gobject_class->set_property = %s_stub_set_property;\n' ' gobject_class->set_property = %s_skeleton_set_property;\n'
'\n'%(i.name_lower, i.camel_name, i.camel_name, i.name_lower, i.name_lower, i.name_lower)) '\n'%(i.name_lower, i.camel_name, i.camel_name, i.name_lower, i.name_lower, i.name_lower))
if len(i.properties) > 0: if len(i.properties) > 0:
self.c.write('\n' self.c.write('\n'
' %s_override_properties (gobject_class, 1);\n'%(i.name_lower)) ' %s_override_properties (gobject_class, 1);\n'%(i.name_lower))
self.c.write('\n' self.c.write('\n'
' stub_class = G_DBUS_INTERFACE_STUB_CLASS (klass);\n'); ' skeleton_class = G_DBUS_INTERFACE_SKELETON_CLASS (klass);\n');
self.c.write(' stub_class->get_info = %s_stub_dbus_interface_get_info;\n'%(i.name_lower)) self.c.write(' skeleton_class->get_info = %s_skeleton_dbus_interface_get_info;\n'%(i.name_lower))
self.c.write(' stub_class->get_properties = %s_stub_dbus_interface_get_properties;\n'%(i.name_lower)) self.c.write(' skeleton_class->get_properties = %s_skeleton_dbus_interface_get_properties;\n'%(i.name_lower))
self.c.write(' stub_class->flush = %s_stub_dbus_interface_flush;\n'%(i.name_lower)) self.c.write(' skeleton_class->flush = %s_skeleton_dbus_interface_flush;\n'%(i.name_lower))
self.c.write(' stub_class->get_vtable = %s_stub_dbus_interface_get_vtable;\n'%(i.name_lower)) self.c.write(' skeleton_class->get_vtable = %s_skeleton_dbus_interface_get_vtable;\n'%(i.name_lower))
self.c.write('}\n' self.c.write('}\n'
'\n') '\n')
# constructors # constructors
self.c.write('%s *\n' self.c.write('%s *\n'
'%s_stub_new (void)\n' '%s_skeleton_new (void)\n'
'{\n' '{\n'
' return %s%s (g_object_new (%sTYPE_%s_STUB, NULL));\n' ' return %s%s (g_object_new (%sTYPE_%s_SKELETON, NULL));\n'
'}\n' '}\n'
'\n'%(i.camel_name, i.name_lower, i.ns_upper, i.name_upper, i.ns_upper, i.name_upper)) '\n'%(i.camel_name, i.name_lower, i.ns_upper, i.name_upper, i.ns_upper, i.name_upper))
@ -1950,7 +1950,7 @@ class CodeGenerator:
self.generate_method_calls(i) self.generate_method_calls(i)
self.generate_method_completers(i) self.generate_method_completers(i)
self.generate_proxy(i) self.generate_proxy(i)
self.generate_stub(i) self.generate_skeleton(i)
if self.generate_objmanager: if self.generate_objmanager:
self.generate_object_manager_client() self.generate_object_manager_client()
self.generate_outro() self.generate_outro()

View File

@ -34,8 +34,8 @@
* @include: gio/gio.h * @include: gio/gio.h
* *
* The #GDBusInterface type is the base type for D-Bus interfaces both * The #GDBusInterface type is the base type for D-Bus interfaces both
* on the service side (see #GDBusInterfaceStub) and client side (see * on the service side (see #GDBusInterfaceSkeleton) and client side
* #GDBusProxy). * (see #GDBusProxy).
*/ */
typedef GDBusInterfaceIface GDBusInterfaceInterface; typedef GDBusInterfaceIface GDBusInterfaceInterface;

View File

@ -23,8 +23,8 @@
#include "config.h" #include "config.h"
#include "gdbusinterface.h" #include "gdbusinterface.h"
#include "gdbusinterfacestub.h" #include "gdbusinterfaceskeleton.h"
#include "gdbusobjectstub.h" #include "gdbusobjectskeleton.h"
#include "gio-marshal.h" #include "gio-marshal.h"
#include "gioenumtypes.h" #include "gioenumtypes.h"
#include "gdbusprivate.h" #include "gdbusprivate.h"
@ -36,17 +36,17 @@
#include "glibintl.h" #include "glibintl.h"
/** /**
* SECTION:gdbusinterfacestub * SECTION:gdbusinterfaceskeleton
* @short_description: Service-side D-Bus interface * @short_description: Service-side D-Bus interface
* @include: gio/gio.h * @include: gio/gio.h
* *
* Abstract base class for D-Bus interfaces on the service side. * Abstract base class for D-Bus interfaces on the service side.
*/ */
struct _GDBusInterfaceStubPrivate struct _GDBusInterfaceSkeletonPrivate
{ {
GDBusObject *object; GDBusObject *object;
GDBusInterfaceStubFlags flags; GDBusInterfaceSkeletonFlags flags;
guint registration_id; guint registration_id;
GDBusConnection *connection; GDBusConnection *connection;
@ -70,16 +70,16 @@ static guint signals[LAST_SIGNAL] = {0};
static void dbus_interface_interface_init (GDBusInterfaceIface *iface); static void dbus_interface_interface_init (GDBusInterfaceIface *iface);
G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GDBusInterfaceStub, g_dbus_interface_stub, G_TYPE_OBJECT, G_DEFINE_ABSTRACT_TYPE_WITH_CODE (GDBusInterfaceSkeleton, g_dbus_interface_skeleton, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_INTERFACE, dbus_interface_interface_init)); G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_INTERFACE, dbus_interface_interface_init));
static void static void
g_dbus_interface_stub_finalize (GObject *object) g_dbus_interface_skeleton_finalize (GObject *object)
{ {
GDBusInterfaceStub *interface = G_DBUS_INTERFACE_STUB (object); GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (object);
/* unexport if already exported */ /* unexport if already exported */
if (interface->priv->registration_id > 0) if (interface->priv->registration_id > 0)
g_dbus_interface_stub_unexport (interface); g_dbus_interface_skeleton_unexport (interface);
g_assert (interface->priv->connection == NULL); g_assert (interface->priv->connection == NULL);
g_assert (interface->priv->object_path == NULL); g_assert (interface->priv->object_path == NULL);
@ -87,21 +87,21 @@ g_dbus_interface_stub_finalize (GObject *object)
if (interface->priv->object != NULL) if (interface->priv->object != NULL)
g_object_remove_weak_pointer (G_OBJECT (interface->priv->object), (gpointer *) &interface->priv->object); g_object_remove_weak_pointer (G_OBJECT (interface->priv->object), (gpointer *) &interface->priv->object);
G_OBJECT_CLASS (g_dbus_interface_stub_parent_class)->finalize (object); G_OBJECT_CLASS (g_dbus_interface_skeleton_parent_class)->finalize (object);
} }
static void static void
g_dbus_interface_stub_get_property (GObject *object, g_dbus_interface_skeleton_get_property (GObject *object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GDBusInterfaceStub *interface = G_DBUS_INTERFACE_STUB (object); GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (object);
switch (prop_id) switch (prop_id)
{ {
case PROP_G_FLAGS: case PROP_G_FLAGS:
g_value_set_flags (value, g_dbus_interface_stub_get_flags (interface)); g_value_set_flags (value, g_dbus_interface_skeleton_get_flags (interface));
break; break;
default: default:
@ -111,17 +111,17 @@ g_dbus_interface_stub_get_property (GObject *object,
} }
static void static void
g_dbus_interface_stub_set_property (GObject *object, g_dbus_interface_skeleton_set_property (GObject *object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GDBusInterfaceStub *interface = G_DBUS_INTERFACE_STUB (object); GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (object);
switch (prop_id) switch (prop_id)
{ {
case PROP_G_FLAGS: case PROP_G_FLAGS:
g_dbus_interface_stub_set_flags (interface, g_value_get_flags (value)); g_dbus_interface_skeleton_set_flags (interface, g_value_get_flags (value));
break; break;
default: default:
@ -131,28 +131,28 @@ g_dbus_interface_stub_set_property (GObject *object,
} }
static gboolean static gboolean
g_dbus_interface_stub_g_authorize_method_default (GDBusInterfaceStub *interface, g_dbus_interface_skeleton_g_authorize_method_default (GDBusInterfaceSkeleton *interface,
GDBusMethodInvocation *invocation) GDBusMethodInvocation *invocation)
{ {
return TRUE; return TRUE;
} }
static void static void
g_dbus_interface_stub_class_init (GDBusInterfaceStubClass *klass) g_dbus_interface_skeleton_class_init (GDBusInterfaceSkeletonClass *klass)
{ {
GObjectClass *gobject_class; GObjectClass *gobject_class;
gobject_class = G_OBJECT_CLASS (klass); gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = g_dbus_interface_stub_finalize; gobject_class->finalize = g_dbus_interface_skeleton_finalize;
gobject_class->set_property = g_dbus_interface_stub_set_property; gobject_class->set_property = g_dbus_interface_skeleton_set_property;
gobject_class->get_property = g_dbus_interface_stub_get_property; gobject_class->get_property = g_dbus_interface_skeleton_get_property;
klass->g_authorize_method = g_dbus_interface_stub_g_authorize_method_default; klass->g_authorize_method = g_dbus_interface_skeleton_g_authorize_method_default;
/** /**
* GDBusInterfaceStub:g-flags: * GDBusInterfaceSkeleton:g-flags:
* *
* Flags from the #GDBusInterfaceStubFlags enumeration. * Flags from the #GDBusInterfaceSkeletonFlags enumeration.
* *
* Since: 2.30 * Since: 2.30
*/ */
@ -160,16 +160,16 @@ g_dbus_interface_stub_class_init (GDBusInterfaceStubClass *klass)
PROP_G_FLAGS, PROP_G_FLAGS,
g_param_spec_flags ("g-flags", g_param_spec_flags ("g-flags",
"g-flags", "g-flags",
"Flags for the interface stub", "Flags for the interface skeleton",
G_TYPE_DBUS_INTERFACE_STUB_FLAGS, G_TYPE_DBUS_INTERFACE_SKELETON_FLAGS,
G_DBUS_INTERFACE_STUB_FLAGS_NONE, G_DBUS_INTERFACE_SKELETON_FLAGS_NONE,
G_PARAM_READABLE | G_PARAM_READABLE |
G_PARAM_WRITABLE | G_PARAM_WRITABLE |
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
/** /**
* GDBusInterfaceStub::g-authorize-method: * GDBusInterfaceSkeleton::g-authorize-method:
* @interface: The #GDBusInterfaceStub emitting the signal. * @interface: The #GDBusInterfaceSkeleton emitting the signal.
* @invocation: A #GDBusMethodInvocation. * @invocation: A #GDBusMethodInvocation.
* *
* Emitted when a method is invoked by a remote caller and used to * Emitted when a method is invoked by a remote caller and used to
@ -190,18 +190,18 @@ g_dbus_interface_stub_class_init (GDBusInterfaceStubClass *klass)
* *
* Otherwise, if %TRUE is returned, signal emission continues. If no * Otherwise, if %TRUE is returned, signal emission continues. If no
* handlers return %FALSE, then the method is dispatched. If * handlers return %FALSE, then the method is dispatched. If
* @interface has an enclosing #GDBusObjectStub, then the * @interface has an enclosing #GDBusObjectSkeleton, then the
* #GDBusObjectStub::authorize-method signal handlers run before the * #GDBusObjectSkeleton::authorize-method signal handlers run before
* handlers for this signal. * the handlers for this signal.
* *
* The default class handler just returns %TRUE. * The default class handler just returns %TRUE.
* *
* Please note that the common case is optimized: if no signals * Please note that the common case is optimized: if no signals
* handlers are connected and the default class handler isn't * handlers are connected and the default class handler isn't
* overridden (for both @interface and the enclosing * overridden (for both @interface and the enclosing
* #GDBusObjectStub, if any) and #GDBusInterfaceStub:g-flags does * #GDBusObjectSkeleton, if any) and #GDBusInterfaceSkeleton:g-flags does
* not have the * not have the
* %G_DBUS_INTERFACE_STUB_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD * %G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD
* flags set, no dedicated thread is ever used and the call will be * flags set, no dedicated thread is ever used and the call will be
* handled in the same thread as the object that @interface belongs * handled in the same thread as the object that @interface belongs
* to was exported in. * to was exported in.
@ -212,9 +212,9 @@ g_dbus_interface_stub_class_init (GDBusInterfaceStubClass *klass)
*/ */
signals[G_AUTHORIZE_METHOD_SIGNAL] = signals[G_AUTHORIZE_METHOD_SIGNAL] =
g_signal_new ("g-authorize-method", g_signal_new ("g-authorize-method",
G_TYPE_DBUS_INTERFACE_STUB, G_TYPE_DBUS_INTERFACE_SKELETON,
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GDBusInterfaceStubClass, g_authorize_method), G_STRUCT_OFFSET (GDBusInterfaceSkeletonClass, g_authorize_method),
_g_signal_accumulator_false_handled, _g_signal_accumulator_false_handled,
NULL, NULL,
_gio_marshal_BOOLEAN__OBJECT, _gio_marshal_BOOLEAN__OBJECT,
@ -222,49 +222,49 @@ g_dbus_interface_stub_class_init (GDBusInterfaceStubClass *klass)
1, 1,
G_TYPE_DBUS_METHOD_INVOCATION); G_TYPE_DBUS_METHOD_INVOCATION);
g_type_class_add_private (klass, sizeof (GDBusInterfaceStubPrivate)); g_type_class_add_private (klass, sizeof (GDBusInterfaceSkeletonPrivate));
} }
static void static void
g_dbus_interface_stub_init (GDBusInterfaceStub *interface) g_dbus_interface_skeleton_init (GDBusInterfaceSkeleton *interface)
{ {
interface->priv = G_TYPE_INSTANCE_GET_PRIVATE (interface, G_TYPE_DBUS_INTERFACE_STUB, GDBusInterfaceStubPrivate); interface->priv = G_TYPE_INSTANCE_GET_PRIVATE (interface, G_TYPE_DBUS_INTERFACE_SKELETON, GDBusInterfaceSkeletonPrivate);
} }
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
/** /**
* g_dbus_interface_stub_get_flags: * g_dbus_interface_skeleton_get_flags:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Gets the #GDBusInterfaceStubFlags that describes what the behavior * Gets the #GDBusInterfaceSkeletonFlags that describes what the behavior
* of @interface_ * of @interface_
* *
* Returns: One or more flags from the #GDBusInterfaceStubFlags enumeration. * Returns: One or more flags from the #GDBusInterfaceSkeletonFlags enumeration.
* *
* Since: 2.30 * Since: 2.30
*/ */
GDBusInterfaceStubFlags GDBusInterfaceSkeletonFlags
g_dbus_interface_stub_get_flags (GDBusInterfaceStub *interface_) g_dbus_interface_skeleton_get_flags (GDBusInterfaceSkeleton *interface_)
{ {
g_return_val_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_), G_DBUS_INTERFACE_STUB_FLAGS_NONE); g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), G_DBUS_INTERFACE_SKELETON_FLAGS_NONE);
return interface_->priv->flags; return interface_->priv->flags;
} }
/** /**
* g_dbus_interface_stub_set_flags: * g_dbus_interface_skeleton_set_flags:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* @flags: Flags from the #GDBusInterfaceStubFlags enumeration. * @flags: Flags from the #GDBusInterfaceSkeletonFlags enumeration.
* *
* Sets flags describing what the behavior of @stub should be. * Sets flags describing what the behavior of @skeleton should be.
* *
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_interface_stub_set_flags (GDBusInterfaceStub *interface_, g_dbus_interface_skeleton_set_flags (GDBusInterfaceSkeleton *interface_,
GDBusInterfaceStubFlags flags) GDBusInterfaceSkeletonFlags flags)
{ {
g_return_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_)); g_return_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_));
if (interface_->priv->flags != flags) if (interface_->priv->flags != flags)
{ {
interface_->priv->flags = flags; interface_->priv->flags = flags;
@ -273,8 +273,8 @@ g_dbus_interface_stub_set_flags (GDBusInterfaceStub *interface_,
} }
/** /**
* g_dbus_interface_stub_get_info: * g_dbus_interface_skeleton_get_info:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Gets D-Bus introspection information for the D-Bus interface * Gets D-Bus introspection information for the D-Bus interface
* implemented by @interface_. * implemented by @interface_.
@ -284,18 +284,18 @@ g_dbus_interface_stub_set_flags (GDBusInterfaceStub *interface_,
* Since: 2.30 * Since: 2.30
*/ */
GDBusInterfaceInfo * GDBusInterfaceInfo *
g_dbus_interface_stub_get_info (GDBusInterfaceStub *interface_) g_dbus_interface_skeleton_get_info (GDBusInterfaceSkeleton *interface_)
{ {
GDBusInterfaceInfo *ret; GDBusInterfaceInfo *ret;
g_return_val_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_), NULL); g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), NULL);
ret = G_DBUS_INTERFACE_STUB_GET_CLASS (interface_)->get_info (interface_); ret = G_DBUS_INTERFACE_SKELETON_GET_CLASS (interface_)->get_info (interface_);
g_warn_if_fail (ret != NULL); g_warn_if_fail (ret != NULL);
return ret; return ret;
} }
/** /**
* g_dbus_interface_stub_get_vtable: * g_dbus_interface_skeleton_get_vtable:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Gets the interface vtable for the D-Bus interface implemented by * Gets the interface vtable for the D-Bus interface implemented by
* @interface_. The returned function pointers should expect @interface_ * @interface_. The returned function pointers should expect @interface_
@ -306,18 +306,18 @@ g_dbus_interface_stub_get_info (GDBusInterfaceStub *interface_)
* Since: 2.30 * Since: 2.30
*/ */
GDBusInterfaceVTable * GDBusInterfaceVTable *
g_dbus_interface_stub_get_vtable (GDBusInterfaceStub *interface_) g_dbus_interface_skeleton_get_vtable (GDBusInterfaceSkeleton *interface_)
{ {
GDBusInterfaceVTable *ret; GDBusInterfaceVTable *ret;
g_return_val_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_), NULL); g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), NULL);
ret = G_DBUS_INTERFACE_STUB_GET_CLASS (interface_)->get_vtable (interface_); ret = G_DBUS_INTERFACE_SKELETON_GET_CLASS (interface_)->get_vtable (interface_);
g_warn_if_fail (ret != NULL); g_warn_if_fail (ret != NULL);
return ret; return ret;
} }
/** /**
* g_dbus_interface_stub_get_properties: * g_dbus_interface_skeleton_get_properties:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Gets all D-Bus properties for @interface_. * Gets all D-Bus properties for @interface_.
* *
@ -326,18 +326,18 @@ g_dbus_interface_stub_get_vtable (GDBusInterfaceStub *interface_)
* Since: 2.30 * Since: 2.30
*/ */
GVariant * GVariant *
g_dbus_interface_stub_get_properties (GDBusInterfaceStub *interface_) g_dbus_interface_skeleton_get_properties (GDBusInterfaceSkeleton *interface_)
{ {
GVariant *ret; GVariant *ret;
g_return_val_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_), NULL); g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), NULL);
ret = G_DBUS_INTERFACE_STUB_GET_CLASS (interface_)->get_properties (interface_); ret = G_DBUS_INTERFACE_SKELETON_GET_CLASS (interface_)->get_properties (interface_);
g_warn_if_fail (g_variant_is_floating (ret)); g_warn_if_fail (g_variant_is_floating (ret));
return ret; return ret;
} }
/** /**
* g_dbus_interface_stub_flush: * g_dbus_interface_skeleton_flush:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* If @interface_ has outstanding changes, request for these changes to be * If @interface_ has outstanding changes, request for these changes to be
* emitted immediately. * emitted immediately.
@ -351,33 +351,33 @@ g_dbus_interface_stub_get_properties (GDBusInterfaceStub *interface_)
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_interface_stub_flush (GDBusInterfaceStub *interface_) g_dbus_interface_skeleton_flush (GDBusInterfaceSkeleton *interface_)
{ {
g_return_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_)); g_return_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_));
G_DBUS_INTERFACE_STUB_GET_CLASS (interface_)->flush (interface_); G_DBUS_INTERFACE_SKELETON_GET_CLASS (interface_)->flush (interface_);
} }
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
static GDBusInterfaceInfo * static GDBusInterfaceInfo *
_g_dbus_interface_stub_get_info (GDBusInterface *interface_) _g_dbus_interface_skeleton_get_info (GDBusInterface *interface_)
{ {
GDBusInterfaceStub *interface = G_DBUS_INTERFACE_STUB (interface_); GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (interface_);
return g_dbus_interface_stub_get_info (interface); return g_dbus_interface_skeleton_get_info (interface);
} }
static GDBusObject * static GDBusObject *
g_dbus_interface_stub_get_object (GDBusInterface *interface_) g_dbus_interface_skeleton_get_object (GDBusInterface *interface_)
{ {
GDBusInterfaceStub *interface = G_DBUS_INTERFACE_STUB (interface_); GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (interface_);
return interface->priv->object; return interface->priv->object;
} }
static void static void
g_dbus_interface_stub_set_object (GDBusInterface *interface_, g_dbus_interface_skeleton_set_object (GDBusInterface *interface_,
GDBusObject *object) GDBusObject *object)
{ {
GDBusInterfaceStub *interface = G_DBUS_INTERFACE_STUB (interface_); GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (interface_);
if (interface->priv->object != NULL) if (interface->priv->object != NULL)
g_object_remove_weak_pointer (G_OBJECT (interface->priv->object), (gpointer *) &interface->priv->object); g_object_remove_weak_pointer (G_OBJECT (interface->priv->object), (gpointer *) &interface->priv->object);
interface->priv->object = object; interface->priv->object = object;
@ -388,9 +388,9 @@ g_dbus_interface_stub_set_object (GDBusInterface *interface_,
static void static void
dbus_interface_interface_init (GDBusInterfaceIface *iface) dbus_interface_interface_init (GDBusInterfaceIface *iface)
{ {
iface->get_info = _g_dbus_interface_stub_get_info; iface->get_info = _g_dbus_interface_skeleton_get_info;
iface->get_object = g_dbus_interface_stub_get_object; iface->get_object = g_dbus_interface_skeleton_get_object;
iface->set_object = g_dbus_interface_stub_set_object; iface->set_object = g_dbus_interface_skeleton_set_object;
} }
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
@ -398,7 +398,7 @@ dbus_interface_interface_init (GDBusInterfaceIface *iface)
typedef struct typedef struct
{ {
volatile gint ref_count; volatile gint ref_count;
GDBusInterfaceStub *interface; GDBusInterfaceSkeleton *interface;
GDBusInterfaceMethodCallFunc method_call_func; GDBusInterfaceMethodCallFunc method_call_func;
GDBusMethodInvocation *invocation; GDBusMethodInvocation *invocation;
GMainContext *context; GMainContext *context;
@ -467,7 +467,7 @@ dispatch_in_thread_func (GIOSchedulerJob *job,
if (authorized) if (authorized)
{ {
gboolean run_in_thread; gboolean run_in_thread;
run_in_thread = (data->interface->priv->flags & G_DBUS_INTERFACE_STUB_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD); run_in_thread = (data->interface->priv->flags & G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
if (run_in_thread) if (run_in_thread)
{ {
/* might as well just re-use the existing thread */ /* might as well just re-use the existing thread */
@ -499,7 +499,7 @@ dispatch_in_thread_func (GIOSchedulerJob *job,
} }
static void static void
g_dbus_interface_method_dispatch_helper (GDBusInterfaceStub *interface, g_dbus_interface_method_dispatch_helper (GDBusInterfaceSkeleton *interface,
GDBusInterfaceMethodCallFunc method_call_func, GDBusInterfaceMethodCallFunc method_call_func,
GDBusMethodInvocation *invocation) GDBusMethodInvocation *invocation)
{ {
@ -508,7 +508,7 @@ g_dbus_interface_method_dispatch_helper (GDBusInterfaceStub *interface
gboolean emit_authorized_signal; gboolean emit_authorized_signal;
gboolean run_in_thread; gboolean run_in_thread;
g_return_if_fail (G_IS_DBUS_INTERFACE_STUB (interface)); g_return_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface));
g_return_if_fail (method_call_func != NULL); g_return_if_fail (method_call_func != NULL);
g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation)); g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));
@ -521,17 +521,17 @@ g_dbus_interface_method_dispatch_helper (GDBusInterfaceStub *interface
signals[G_AUTHORIZE_METHOD_SIGNAL], signals[G_AUTHORIZE_METHOD_SIGNAL],
0, 0,
TRUE); TRUE);
has_default_class_handler = (G_DBUS_INTERFACE_STUB_GET_CLASS (interface)->g_authorize_method == has_default_class_handler = (G_DBUS_INTERFACE_SKELETON_GET_CLASS (interface)->g_authorize_method ==
g_dbus_interface_stub_g_authorize_method_default); g_dbus_interface_skeleton_g_authorize_method_default);
emit_authorized_signal = (has_handlers || !has_default_class_handler); emit_authorized_signal = (has_handlers || !has_default_class_handler);
if (!emit_authorized_signal) if (!emit_authorized_signal)
{ {
if (interface->priv->object != NULL) if (interface->priv->object != NULL)
emit_authorized_signal = _g_dbus_object_stub_has_authorize_method_handlers (G_DBUS_OBJECT_STUB (interface->priv->object)); emit_authorized_signal = _g_dbus_object_skeleton_has_authorize_method_handlers (G_DBUS_OBJECT_SKELETON (interface->priv->object));
} }
run_in_thread = (interface->priv->flags & G_DBUS_INTERFACE_STUB_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD); run_in_thread = (interface->priv->flags & G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
if (!emit_authorized_signal && !run_in_thread) if (!emit_authorized_signal && !run_in_thread)
{ {
method_call_func (g_dbus_method_invocation_get_connection (invocation), method_call_func (g_dbus_method_invocation_get_connection (invocation),
@ -563,26 +563,26 @@ g_dbus_interface_method_dispatch_helper (GDBusInterfaceStub *interface
} }
static void static void
stub_intercept_handle_method_call(GDBusConnection *connection, skeleton_intercept_handle_method_call (GDBusConnection *connection,
const gchar *sender, const gchar *sender,
const gchar *object_path, const gchar *object_path,
const gchar *interface_name, const gchar *interface_name,
const gchar *method_name, const gchar *method_name,
GVariant *parameters, GVariant *parameters,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
gpointer user_data) gpointer user_data)
{ {
GDBusInterfaceStub *interface = G_DBUS_INTERFACE_STUB (user_data); GDBusInterfaceSkeleton *interface = G_DBUS_INTERFACE_SKELETON (user_data);
g_dbus_interface_method_dispatch_helper (interface, g_dbus_interface_method_dispatch_helper (interface,
g_dbus_interface_stub_get_vtable (interface)->method_call, g_dbus_interface_skeleton_get_vtable (interface)->method_call,
invocation); invocation);
} }
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
/** /**
* g_dbus_interface_stub_get_connection: * g_dbus_interface_skeleton_get_connection:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Gets the connection that @interface_ is exported on, if any. * Gets the connection that @interface_ is exported on, if any.
* *
@ -592,15 +592,15 @@ stub_intercept_handle_method_call(GDBusConnection *connection,
* Since: 2.30 * Since: 2.30
*/ */
GDBusConnection * GDBusConnection *
g_dbus_interface_stub_get_connection (GDBusInterfaceStub *interface_) g_dbus_interface_skeleton_get_connection (GDBusInterfaceSkeleton *interface_)
{ {
g_return_val_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_), NULL); g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), NULL);
return interface_->priv->connection; return interface_->priv->connection;
} }
/** /**
* g_dbus_interface_stub_get_object_path: * g_dbus_interface_skeleton_get_object_path:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Gets the object path that @interface_ is exported on, if any. * Gets the object path that @interface_ is exported on, if any.
* *
@ -610,14 +610,14 @@ g_dbus_interface_stub_get_connection (GDBusInterfaceStub *interface_)
* Since: 2.30 * Since: 2.30
*/ */
const gchar * const gchar *
g_dbus_interface_stub_get_object_path (GDBusInterfaceStub *interface_) g_dbus_interface_skeleton_get_object_path (GDBusInterfaceSkeleton *interface_)
{ {
g_return_val_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_), NULL); g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), NULL);
return interface_->priv->object_path; return interface_->priv->object_path;
} }
/** /**
* g_dbus_interface_stub_export: * g_dbus_interface_skeleton_export:
* @interface_: The D-Bus interface to export. * @interface_: The D-Bus interface to export.
* @connection: A #GDBusConnection to export @interface_ on. * @connection: A #GDBusConnection to export @interface_ on.
* @object_path: The path to export the interface at. * @object_path: The path to export the interface at.
@ -625,7 +625,7 @@ g_dbus_interface_stub_get_object_path (GDBusInterfaceStub *interface_)
* *
* Exports @interface_ at @object_path on @connection. * Exports @interface_ at @object_path on @connection.
* *
* Use g_dbus_interface_stub_unexport() to unexport the object. * Use g_dbus_interface_skeleton_unexport() to unexport the object.
* *
* Returns: %TRUE if the interface was exported, other %FALSE with * Returns: %TRUE if the interface was exported, other %FALSE with
* @error set. * @error set.
@ -633,14 +633,14 @@ g_dbus_interface_stub_get_object_path (GDBusInterfaceStub *interface_)
* Since: 2.30 * Since: 2.30
*/ */
gboolean gboolean
g_dbus_interface_stub_export (GDBusInterfaceStub *interface_, g_dbus_interface_skeleton_export (GDBusInterfaceSkeleton *interface_,
GDBusConnection *connection, GDBusConnection *connection,
const gchar *object_path, const gchar *object_path,
GError **error) GError **error)
{ {
gboolean ret; gboolean ret;
g_return_val_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_), 0); g_return_val_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_), 0);
g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), 0); g_return_val_if_fail (G_IS_DBUS_CONNECTION (connection), 0);
g_return_val_if_fail (g_variant_is_object_path (object_path), 0); g_return_val_if_fail (g_variant_is_object_path (object_path), 0);
g_return_val_if_fail (error == NULL || *error == NULL, 0); g_return_val_if_fail (error == NULL || *error == NULL, 0);
@ -663,14 +663,14 @@ g_dbus_interface_stub_export (GDBusInterfaceStub *interface_,
* ::g-authorize-method and for dispatching in thread vs * ::g-authorize-method and for dispatching in thread vs
* context * context
*/ */
interface_->priv->hooked_vtable = g_memdup (g_dbus_interface_stub_get_vtable (interface_), sizeof (GDBusInterfaceVTable)); interface_->priv->hooked_vtable = g_memdup (g_dbus_interface_skeleton_get_vtable (interface_), sizeof (GDBusInterfaceVTable));
interface_->priv->hooked_vtable->method_call = stub_intercept_handle_method_call; interface_->priv->hooked_vtable->method_call = skeleton_intercept_handle_method_call;
interface_->priv->connection = g_object_ref (connection); interface_->priv->connection = g_object_ref (connection);
interface_->priv->object_path = g_strdup (object_path); interface_->priv->object_path = g_strdup (object_path);
interface_->priv->registration_id = g_dbus_connection_register_object (connection, interface_->priv->registration_id = g_dbus_connection_register_object (connection,
object_path, object_path,
g_dbus_interface_stub_get_info (interface_), g_dbus_interface_skeleton_get_info (interface_),
interface_->priv->hooked_vtable, interface_->priv->hooked_vtable,
interface_, interface_,
NULL, /* user_data_free_func */ NULL, /* user_data_free_func */
@ -685,18 +685,18 @@ g_dbus_interface_stub_export (GDBusInterfaceStub *interface_,
} }
/** /**
* g_dbus_interface_stub_unexport: * g_dbus_interface_skeleton_unexport:
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Stops exporting an interface previously exported with * Stops exporting an interface previously exported with
* g_dbus_interface_stub_export(). * g_dbus_interface_skeleton_export().
* *
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_interface_stub_unexport (GDBusInterfaceStub *interface_) g_dbus_interface_skeleton_unexport (GDBusInterfaceSkeleton *interface_)
{ {
g_return_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_)); g_return_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_));
g_return_if_fail (interface_->priv->registration_id > 0); g_return_if_fail (interface_->priv->registration_id > 0);
g_assert (interface_->priv->connection != NULL); g_assert (interface_->priv->connection != NULL);

View File

@ -0,0 +1,109 @@
/* GDBus - GLib D-Bus Library
*
* Copyright (C) 2008-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#ifndef __G_DBUS_INTERFACE_SKELETON_H__
#define __G_DBUS_INTERFACE_SKELETON_H__
#include <gio/giotypes.h>
G_BEGIN_DECLS
#define G_TYPE_DBUS_INTERFACE_SKELETON (g_dbus_interface_skeleton_get_type ())
#define G_DBUS_INTERFACE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_INTERFACE_SKELETON, GDBusInterfaceSkeleton))
#define G_DBUS_INTERFACE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_INTERFACE_SKELETON, GDBusInterfaceSkeletonClass))
#define G_DBUS_INTERFACE_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_INTERFACE_SKELETON, GDBusInterfaceSkeletonClass))
#define G_IS_DBUS_INTERFACE_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_INTERFACE_SKELETON))
#define G_IS_DBUS_INTERFACE_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_INTERFACE_SKELETON))
typedef struct _GDBusInterfaceSkeletonClass GDBusInterfaceSkeletonClass;
typedef struct _GDBusInterfaceSkeletonPrivate GDBusInterfaceSkeletonPrivate;
/**
* GDBusInterfaceSkeleton:
*
* The #GDBusInterfaceSkeleton structure contains private data and should
* only be accessed using the provided API.
*
* Since: 2.30
*/
struct _GDBusInterfaceSkeleton
{
/*< private >*/
GObject parent_instance;
GDBusInterfaceSkeletonPrivate *priv;
};
/**
* GDBusInterfaceSkeletonClass:
* @parent_class: The parent class.
* @get_info: Returns a #GDBusInterfaceInfo. See g_dbus_interface_skeleton_get_info() for details.
* @get_vtable: Returns a #GDBusInterfaceVTable. See g_dbus_interface_skeleton_get_vtable() for details.
* @get_properties: Returns a new, floating, #GVariant with all properties. See g_dbus_interface_skeleton_get_properties().
* @flush: Emits outstanding changes, if any. See g_dbus_interface_skeleton_flush().
* @g_authorize_method: Signal class handler for the #GDBusInterfaceSkeleton::g-authorize-method signal.
*
* Class structure for #GDBusInterfaceSkeleton.
*
* Since: 2.30
*/
struct _GDBusInterfaceSkeletonClass
{
GObjectClass parent_class;
/* Virtual Functions */
GDBusInterfaceInfo *(*get_info) (GDBusInterfaceSkeleton *interface_);
GDBusInterfaceVTable *(*get_vtable) (GDBusInterfaceSkeleton *interface_);
GVariant *(*get_properties) (GDBusInterfaceSkeleton *interface_);
void (*flush) (GDBusInterfaceSkeleton *interface_);
/*< private >*/
gpointer vfunc_padding[8];
/*< public >*/
/* Signals */
gboolean (*g_authorize_method) (GDBusInterfaceSkeleton *interface_,
GDBusMethodInvocation *invocation);
/*< private >*/
gpointer signal_padding[8];
};
GType g_dbus_interface_skeleton_get_type (void) G_GNUC_CONST;
GDBusInterfaceSkeletonFlags g_dbus_interface_skeleton_get_flags (GDBusInterfaceSkeleton *interface_);
void g_dbus_interface_skeleton_set_flags (GDBusInterfaceSkeleton *interface_,
GDBusInterfaceSkeletonFlags flags);
GDBusInterfaceInfo *g_dbus_interface_skeleton_get_info (GDBusInterfaceSkeleton *interface_);
GDBusInterfaceVTable *g_dbus_interface_skeleton_get_vtable (GDBusInterfaceSkeleton *interface_);
GVariant *g_dbus_interface_skeleton_get_properties (GDBusInterfaceSkeleton *interface_);
void g_dbus_interface_skeleton_flush (GDBusInterfaceSkeleton *interface_);
gboolean g_dbus_interface_skeleton_export (GDBusInterfaceSkeleton *interface_,
GDBusConnection *connection,
const gchar *object_path,
GError **error);
void g_dbus_interface_skeleton_unexport (GDBusInterfaceSkeleton *interface_);
GDBusConnection *g_dbus_interface_skeleton_get_connection (GDBusInterfaceSkeleton *interface_);
const gchar *g_dbus_interface_skeleton_get_object_path (GDBusInterfaceSkeleton *interface_);
G_END_DECLS
#endif /* __G_DBUS_INTERFACE_SKELETON_H */

View File

@ -1,109 +0,0 @@
/* GDBus - GLib D-Bus Library
*
* Copyright (C) 2008-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#ifndef __G_DBUS_INTERFACE_STUB_H__
#define __G_DBUS_INTERFACE_STUB_H__
#include <gio/giotypes.h>
G_BEGIN_DECLS
#define G_TYPE_DBUS_INTERFACE_STUB (g_dbus_interface_stub_get_type ())
#define G_DBUS_INTERFACE_STUB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_INTERFACE_STUB, GDBusInterfaceStub))
#define G_DBUS_INTERFACE_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_INTERFACE_STUB, GDBusInterfaceStubClass))
#define G_DBUS_INTERFACE_STUB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_INTERFACE_STUB, GDBusInterfaceStubClass))
#define G_IS_DBUS_INTERFACE_STUB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_INTERFACE_STUB))
#define G_IS_DBUS_INTERFACE_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_INTERFACE_STUB))
typedef struct _GDBusInterfaceStubClass GDBusInterfaceStubClass;
typedef struct _GDBusInterfaceStubPrivate GDBusInterfaceStubPrivate;
/**
* GDBusInterfaceStub:
*
* The #GDBusInterfaceStub structure contains private data and should
* only be accessed using the provided API.
*
* Since: 2.30
*/
struct _GDBusInterfaceStub
{
/*< private >*/
GObject parent_instance;
GDBusInterfaceStubPrivate *priv;
};
/**
* GDBusInterfaceStubClass:
* @parent_class: The parent class.
* @get_info: Returns a #GDBusInterfaceInfo. See g_dbus_interface_stub_get_info() for details.
* @get_vtable: Returns a #GDBusInterfaceVTable. See g_dbus_interface_stub_get_vtable() for details.
* @get_properties: Returns a new, floating, #GVariant with all properties. See g_dbus_interface_stub_get_properties().
* @flush: Emits outstanding changes, if any. See g_dbus_interface_stub_flush().
* @g_authorize_method: Signal class handler for the #GDBusInterfaceStub::g-authorize-method signal.
*
* Class structure for #GDBusInterfaceStub.
*
* Since: 2.30
*/
struct _GDBusInterfaceStubClass
{
GObjectClass parent_class;
/* Virtual Functions */
GDBusInterfaceInfo *(*get_info) (GDBusInterfaceStub *interface_);
GDBusInterfaceVTable *(*get_vtable) (GDBusInterfaceStub *interface_);
GVariant *(*get_properties) (GDBusInterfaceStub *interface_);
void (*flush) (GDBusInterfaceStub *interface_);
/*< private >*/
gpointer vfunc_padding[8];
/*< public >*/
/* Signals */
gboolean (*g_authorize_method) (GDBusInterfaceStub *interface_,
GDBusMethodInvocation *invocation);
/*< private >*/
gpointer signal_padding[8];
};
GType g_dbus_interface_stub_get_type (void) G_GNUC_CONST;
GDBusInterfaceStubFlags g_dbus_interface_stub_get_flags (GDBusInterfaceStub *interface_);
void g_dbus_interface_stub_set_flags (GDBusInterfaceStub *interface_,
GDBusInterfaceStubFlags flags);
GDBusInterfaceInfo *g_dbus_interface_stub_get_info (GDBusInterfaceStub *interface_);
GDBusInterfaceVTable *g_dbus_interface_stub_get_vtable (GDBusInterfaceStub *interface_);
GVariant *g_dbus_interface_stub_get_properties (GDBusInterfaceStub *interface_);
void g_dbus_interface_stub_flush (GDBusInterfaceStub *interface_);
gboolean g_dbus_interface_stub_export (GDBusInterfaceStub *interface_,
GDBusConnection *connection,
const gchar *object_path,
GError **error);
void g_dbus_interface_stub_unexport (GDBusInterfaceStub *interface_);
GDBusConnection *g_dbus_interface_stub_get_connection (GDBusInterfaceStub *interface_);
const gchar *g_dbus_interface_stub_get_object_path (GDBusInterfaceStub *interface_);
G_END_DECLS
#endif /* __G_DBUS_INTERFACE_STUB_H */

View File

@ -35,8 +35,8 @@
* @include: gio/gio.h * @include: gio/gio.h
* *
* The #GDBusObject type is the base type for D-Bus objects on both * The #GDBusObject type is the base type for D-Bus objects on both
* the service side (see #GDBusObjectStub) and the client side (see * the service side (see #GDBusObjectSkeleton) and the client side
* #GDBusObjectProxy). It is essentially just a container of * (see #GDBusObjectProxy). It is essentially just a container of
* interfaces. * interfaces.
*/ */

View File

@ -25,8 +25,8 @@
#include "gdbusobjectmanager.h" #include "gdbusobjectmanager.h"
#include "gdbusobjectmanagerserver.h" #include "gdbusobjectmanagerserver.h"
#include "gdbusobject.h" #include "gdbusobject.h"
#include "gdbusobjectstub.h" #include "gdbusobjectskeleton.h"
#include "gdbusinterfacestub.h" #include "gdbusinterfaceskeleton.h"
#include "gdbusconnection.h" #include "gdbusconnection.h"
#include "gdbusintrospection.h" #include "gdbusintrospection.h"
#include "gdbusmethodinvocation.h" #include "gdbusmethodinvocation.h"
@ -54,7 +54,7 @@
typedef struct typedef struct
{ {
GDBusObjectStub *object; GDBusObjectSkeleton *object;
GDBusObjectManagerServer *manager; GDBusObjectManagerServer *manager;
GHashTable *map_iface_name_to_iface; GHashTable *map_iface_name_to_iface;
gboolean exported; gboolean exported;
@ -270,8 +270,8 @@ g_dbus_object_manager_server_get_connection (GDBusObjectManagerServer *manager)
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
static void static void
registration_data_export_interface (RegistrationData *data, registration_data_export_interface (RegistrationData *data,
GDBusInterfaceStub *interface_stub) GDBusInterfaceSkeleton *interface_skeleton)
{ {
GDBusInterfaceInfo *info; GDBusInterfaceInfo *info;
GError *error; GError *error;
@ -279,12 +279,12 @@ registration_data_export_interface (RegistrationData *data,
object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object)); object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object));
info = g_dbus_interface_stub_get_info (interface_stub); info = g_dbus_interface_skeleton_get_info (interface_skeleton);
error = NULL; error = NULL;
if (!g_dbus_interface_stub_export (interface_stub, if (!g_dbus_interface_skeleton_export (interface_skeleton,
data->manager->priv->connection, data->manager->priv->connection,
object_path, object_path,
&error)) &error))
{ {
/* TODO: probably wrong to complain on stderr */ /* TODO: probably wrong to complain on stderr */
g_warning ("%s: Error registering object at %s with interface %s: %s", g_warning ("%s: Error registering object at %s with interface %s: %s",
@ -299,7 +299,7 @@ registration_data_export_interface (RegistrationData *data,
g_assert (g_hash_table_lookup (data->map_iface_name_to_iface, info->name) == NULL); g_assert (g_hash_table_lookup (data->map_iface_name_to_iface, info->name) == NULL);
g_hash_table_insert (data->map_iface_name_to_iface, g_hash_table_insert (data->map_iface_name_to_iface,
info->name, info->name,
g_object_ref (interface_stub)); g_object_ref (interface_skeleton));
/* if we are already exported, then... */ /* if we are already exported, then... */
if (data->exported) if (data->exported)
@ -316,17 +316,17 @@ registration_data_export_interface (RegistrationData *data,
} }
static void static void
registration_data_unexport_interface (RegistrationData *data, registration_data_unexport_interface (RegistrationData *data,
GDBusInterfaceStub *interface_stub) GDBusInterfaceSkeleton *interface_skeleton)
{ {
GDBusInterfaceInfo *info; GDBusInterfaceInfo *info;
GDBusInterfaceStub *iface; GDBusInterfaceSkeleton *iface;
info = g_dbus_interface_stub_get_info (interface_stub); info = g_dbus_interface_skeleton_get_info (interface_skeleton);
iface = g_hash_table_lookup (data->map_iface_name_to_iface, info->name); iface = g_hash_table_lookup (data->map_iface_name_to_iface, info->name);
g_assert (iface != NULL); g_assert (iface != NULL);
g_dbus_interface_stub_unexport (iface); g_dbus_interface_skeleton_unexport (iface);
g_warn_if_fail (g_hash_table_remove (data->map_iface_name_to_iface, info->name)); g_warn_if_fail (g_hash_table_remove (data->map_iface_name_to_iface, info->name));
@ -349,7 +349,7 @@ on_interface_added (GDBusObject *object,
gpointer user_data) gpointer user_data)
{ {
RegistrationData *data = user_data; RegistrationData *data = user_data;
registration_data_export_interface (data, G_DBUS_INTERFACE_STUB (interface)); registration_data_export_interface (data, G_DBUS_INTERFACE_SKELETON (interface));
} }
static void static void
@ -358,7 +358,7 @@ on_interface_removed (GDBusObject *object,
gpointer user_data) gpointer user_data)
{ {
RegistrationData *data = user_data; RegistrationData *data = user_data;
registration_data_unexport_interface (data, G_DBUS_INTERFACE_STUB (interface)); registration_data_unexport_interface (data, G_DBUS_INTERFACE_SKELETON (interface));
} }
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
@ -368,13 +368,13 @@ static void
registration_data_free (RegistrationData *data) registration_data_free (RegistrationData *data)
{ {
GHashTableIter iter; GHashTableIter iter;
GDBusInterfaceStub *iface; GDBusInterfaceSkeleton *iface;
data->exported = FALSE; data->exported = FALSE;
g_hash_table_iter_init (&iter, data->map_iface_name_to_iface); g_hash_table_iter_init (&iter, data->map_iface_name_to_iface);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &iface)) while (g_hash_table_iter_next (&iter, NULL, (gpointer) &iface))
g_dbus_interface_stub_unexport (iface); g_dbus_interface_skeleton_unexport (iface);
g_signal_handlers_disconnect_by_func (data->object, G_CALLBACK (on_interface_added), data); g_signal_handlers_disconnect_by_func (data->object, G_CALLBACK (on_interface_added), data);
g_signal_handlers_disconnect_by_func (data->object, G_CALLBACK (on_interface_removed), data); g_signal_handlers_disconnect_by_func (data->object, G_CALLBACK (on_interface_removed), data);
@ -388,7 +388,7 @@ registration_data_free (RegistrationData *data)
/** /**
* g_dbus_object_manager_server_export: * g_dbus_object_manager_server_export:
* @manager: A #GDBusObjectManagerServer. * @manager: A #GDBusObjectManagerServer.
* @object: A #GDBusObjectStub. * @object: A #GDBusObjectSkeleton.
* *
* Exports @object on @manager. * Exports @object on @manager.
* *
@ -405,7 +405,7 @@ registration_data_free (RegistrationData *data)
*/ */
void void
g_dbus_object_manager_server_export (GDBusObjectManagerServer *manager, g_dbus_object_manager_server_export (GDBusObjectManagerServer *manager,
GDBusObjectStub *object) GDBusObjectSkeleton *object)
{ {
RegistrationData *data; RegistrationData *data;
GList *existing_interfaces; GList *existing_interfaces;
@ -448,9 +448,9 @@ g_dbus_object_manager_server_export (GDBusObjectManagerServer *manager,
existing_interfaces = g_dbus_object_get_interfaces (G_DBUS_OBJECT (object)); existing_interfaces = g_dbus_object_get_interfaces (G_DBUS_OBJECT (object));
for (l = existing_interfaces; l != NULL; l = l->next) for (l = existing_interfaces; l != NULL; l = l->next)
{ {
GDBusInterfaceStub *interface_stub = G_DBUS_INTERFACE_STUB (l->data); GDBusInterfaceSkeleton *interface_skeleton = G_DBUS_INTERFACE_SKELETON (l->data);
registration_data_export_interface (data, interface_stub); registration_data_export_interface (data, interface_skeleton);
g_ptr_array_add (interface_names, g_dbus_interface_stub_get_info (interface_stub)->name); g_ptr_array_add (interface_names, g_dbus_interface_skeleton_get_info (interface_skeleton)->name);
} }
g_list_foreach (existing_interfaces, (GFunc) g_object_unref, NULL); g_list_foreach (existing_interfaces, (GFunc) g_object_unref, NULL);
g_list_free (existing_interfaces); g_list_free (existing_interfaces);
@ -481,8 +481,8 @@ g_dbus_object_manager_server_export (GDBusObjectManagerServer *manager,
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager, g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager,
GDBusObjectStub *object) GDBusObjectSkeleton *object)
{ {
gchar *orig_object_path; gchar *orig_object_path;
gchar *object_path; gchar *object_path;
@ -512,7 +512,7 @@ g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager
} }
if (modified) if (modified)
g_dbus_object_stub_set_object_path (G_DBUS_OBJECT_STUB (object), object_path); g_dbus_object_skeleton_set_object_path (G_DBUS_OBJECT_SKELETON (object), object_path);
g_dbus_object_manager_server_export (manager, object); g_dbus_object_manager_server_export (manager, object);
@ -705,7 +705,7 @@ manager_method_call (GDBusConnection *connection,
{ {
GVariantBuilder interfaces_builder; GVariantBuilder interfaces_builder;
GHashTableIter interface_iter; GHashTableIter interface_iter;
GDBusInterfaceStub *iface; GDBusInterfaceSkeleton *iface;
const gchar *iter_object_path; const gchar *iter_object_path;
g_variant_builder_init (&interfaces_builder, G_VARIANT_TYPE ("a{sa{sv}}")); g_variant_builder_init (&interfaces_builder, G_VARIANT_TYPE ("a{sa{sv}}"));
@ -714,8 +714,8 @@ manager_method_call (GDBusConnection *connection,
{ {
g_variant_builder_add_value (&interfaces_builder, g_variant_builder_add_value (&interfaces_builder,
g_variant_new ("{s@a{sv}}", g_variant_new ("{s@a{sv}}",
g_dbus_interface_stub_get_info (iface)->name, g_dbus_interface_skeleton_get_info (iface)->name,
g_dbus_interface_stub_get_properties (iface))); g_dbus_interface_skeleton_get_properties (iface)));
} }
iter_object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object)); iter_object_path = g_dbus_object_get_object_path (G_DBUS_OBJECT (data->object));
g_variant_builder_add (&array_builder, g_variant_builder_add (&array_builder,
@ -788,13 +788,13 @@ g_dbus_object_manager_server_emit_interfaces_added (GDBusObjectManagerServer *ma
g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("a{sa{sv}}")); g_variant_builder_init (&array_builder, G_VARIANT_TYPE ("a{sa{sv}}"));
for (n = 0; interfaces[n] != NULL; n++) for (n = 0; interfaces[n] != NULL; n++)
{ {
GDBusInterfaceStub *iface; GDBusInterfaceSkeleton *iface;
iface = g_hash_table_lookup (data->map_iface_name_to_iface, interfaces[n]); iface = g_hash_table_lookup (data->map_iface_name_to_iface, interfaces[n]);
g_assert (iface != NULL); g_assert (iface != NULL);
g_variant_builder_add_value (&array_builder, g_variant_builder_add_value (&array_builder,
g_variant_new ("{s@a{sv}}", g_variant_new ("{s@a{sv}}",
interfaces[n], interfaces[n],
g_dbus_interface_stub_get_properties (iface))); g_dbus_interface_skeleton_get_properties (iface)));
} }
error = NULL; error = NULL;

View File

@ -73,9 +73,9 @@ GDBusObjectManagerServer *g_dbus_object_manager_server_new (GDBu
const gchar *object_path); const gchar *object_path);
GDBusConnection *g_dbus_object_manager_server_get_connection (GDBusObjectManagerServer *manager); GDBusConnection *g_dbus_object_manager_server_get_connection (GDBusObjectManagerServer *manager);
void g_dbus_object_manager_server_export (GDBusObjectManagerServer *manager, void g_dbus_object_manager_server_export (GDBusObjectManagerServer *manager,
GDBusObjectStub *object); GDBusObjectSkeleton *object);
void g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager, void g_dbus_object_manager_server_export_uniquely (GDBusObjectManagerServer *manager,
GDBusObjectStub *object); GDBusObjectSkeleton *object);
void g_dbus_object_manager_server_unexport (GDBusObjectManagerServer *manager, void g_dbus_object_manager_server_unexport (GDBusObjectManagerServer *manager,
const gchar *object_path); const gchar *object_path);

View File

@ -23,8 +23,8 @@
#include "config.h" #include "config.h"
#include "gdbusobject.h" #include "gdbusobject.h"
#include "gdbusobjectstub.h" #include "gdbusobjectskeleton.h"
#include "gdbusinterfacestub.h" #include "gdbusinterfaceskeleton.h"
#include "gio-marshal.h" #include "gio-marshal.h"
#include "gdbusprivate.h" #include "gdbusprivate.h"
#include "gdbusmethodinvocation.h" #include "gdbusmethodinvocation.h"
@ -35,18 +35,18 @@
#include "glibintl.h" #include "glibintl.h"
/** /**
* SECTION:gdbusobjectstub * SECTION:gdbusobjectskeleton
* @short_description: Service-side D-Bus object * @short_description: Service-side D-Bus object
* @include: gio/gio.h * @include: gio/gio.h
* *
* A #GDBusObjectStub instance is essentially a group of D-Bus * A #GDBusObjectSkeleton instance is essentially a group of D-Bus
* interfaces. The set of exported interfaces on the object may be * interfaces. The set of exported interfaces on the object may be
* dynamic and change at runtime. * dynamic and change at runtime.
* *
* This type is intended to be used with #GDBusObjectManager. * This type is intended to be used with #GDBusObjectManager.
*/ */
struct _GDBusObjectStubPrivate struct _GDBusObjectSkeletonPrivate
{ {
gchar *object_path; gchar *object_path;
GHashTable *map_name_to_iface; GHashTable *map_name_to_iface;
@ -68,29 +68,29 @@ static guint signals[LAST_SIGNAL] = {0};
static void dbus_object_interface_init (GDBusObjectIface *iface); static void dbus_object_interface_init (GDBusObjectIface *iface);
G_DEFINE_TYPE_WITH_CODE (GDBusObjectStub, g_dbus_object_stub, G_TYPE_OBJECT, G_DEFINE_TYPE_WITH_CODE (GDBusObjectSkeleton, g_dbus_object_skeleton, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, dbus_object_interface_init)); G_IMPLEMENT_INTERFACE (G_TYPE_DBUS_OBJECT, dbus_object_interface_init));
static void static void
g_dbus_object_stub_finalize (GObject *_object) g_dbus_object_skeleton_finalize (GObject *_object)
{ {
GDBusObjectStub *object = G_DBUS_OBJECT_STUB (_object); GDBusObjectSkeleton *object = G_DBUS_OBJECT_SKELETON (_object);
g_free (object->priv->object_path); g_free (object->priv->object_path);
g_hash_table_unref (object->priv->map_name_to_iface); g_hash_table_unref (object->priv->map_name_to_iface);
if (G_OBJECT_CLASS (g_dbus_object_stub_parent_class)->finalize != NULL) if (G_OBJECT_CLASS (g_dbus_object_skeleton_parent_class)->finalize != NULL)
G_OBJECT_CLASS (g_dbus_object_stub_parent_class)->finalize (_object); G_OBJECT_CLASS (g_dbus_object_skeleton_parent_class)->finalize (_object);
} }
static void static void
g_dbus_object_stub_get_property (GObject *_object, g_dbus_object_skeleton_get_property (GObject *_object,
guint prop_id, guint prop_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GDBusObjectStub *object = G_DBUS_OBJECT_STUB (_object); GDBusObjectSkeleton *object = G_DBUS_OBJECT_SKELETON (_object);
switch (prop_id) switch (prop_id)
{ {
@ -105,17 +105,17 @@ g_dbus_object_stub_get_property (GObject *_object,
} }
static void static void
g_dbus_object_stub_set_property (GObject *_object, g_dbus_object_skeleton_set_property (GObject *_object,
guint prop_id, guint prop_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
GDBusObjectStub *object = G_DBUS_OBJECT_STUB (_object); GDBusObjectSkeleton *object = G_DBUS_OBJECT_SKELETON (_object);
switch (prop_id) switch (prop_id)
{ {
case PROP_OBJECT_PATH: case PROP_OBJECT_PATH:
g_dbus_object_stub_set_object_path (object, g_value_get_string (value)); g_dbus_object_skeleton_set_object_path (object, g_value_get_string (value));
break; break;
default: default:
@ -125,26 +125,26 @@ g_dbus_object_stub_set_property (GObject *_object,
} }
static gboolean static gboolean
g_dbus_object_stub_authorize_method_default (GDBusObjectStub *object, g_dbus_object_skeleton_authorize_method_default (GDBusObjectSkeleton *object,
GDBusInterfaceStub *interface, GDBusInterfaceSkeleton *interface,
GDBusMethodInvocation *invocation) GDBusMethodInvocation *invocation)
{ {
return TRUE; return TRUE;
} }
static void static void
g_dbus_object_stub_class_init (GDBusObjectStubClass *klass) g_dbus_object_skeleton_class_init (GDBusObjectSkeletonClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = g_dbus_object_stub_finalize; gobject_class->finalize = g_dbus_object_skeleton_finalize;
gobject_class->set_property = g_dbus_object_stub_set_property; gobject_class->set_property = g_dbus_object_skeleton_set_property;
gobject_class->get_property = g_dbus_object_stub_get_property; gobject_class->get_property = g_dbus_object_skeleton_get_property;
klass->authorize_method = g_dbus_object_stub_authorize_method_default; klass->authorize_method = g_dbus_object_skeleton_authorize_method_default;
/** /**
* GDBusObjectStub:object-path: * GDBusObjectSkeleton:object-path:
* *
* The object path where the object is exported. * The object path where the object is exported.
* *
@ -162,16 +162,16 @@ g_dbus_object_stub_class_init (GDBusObjectStubClass *klass)
G_PARAM_STATIC_STRINGS)); G_PARAM_STATIC_STRINGS));
/** /**
* GDBusObjectStub::authorize-method: * GDBusObjectSkeleton::authorize-method:
* @object: The #GDBusObjectStub emitting the signal. * @object: The #GDBusObjectSkeleton emitting the signal.
* @interface: The #GDBusInterfaceStub that @invocation is on. * @interface: The #GDBusInterfaceSkeleton that @invocation is on.
* @invocation: A #GDBusMethodInvocation. * @invocation: A #GDBusMethodInvocation.
* *
* Emitted when a method is invoked by a remote caller and used to * Emitted when a method is invoked by a remote caller and used to
* determine if the method call is authorized. * determine if the method call is authorized.
* *
* This signal is like #GDBusInterfaceStub<!-- -->'s * This signal is like #GDBusInterfaceSkeleton<!-- -->'s
* #GDBusInterfaceStub::g-authorize-method signal, except that it is * #GDBusInterfaceSkeleton::g-authorize-method signal, except that it is
* for the enclosing object. * for the enclosing object.
* *
* The default class handler just returns %TRUE. * The default class handler just returns %TRUE.
@ -182,24 +182,24 @@ g_dbus_object_stub_class_init (GDBusObjectStubClass *klass)
*/ */
signals[AUTHORIZE_METHOD_SIGNAL] = signals[AUTHORIZE_METHOD_SIGNAL] =
g_signal_new ("authorize-method", g_signal_new ("authorize-method",
G_TYPE_DBUS_OBJECT_STUB, G_TYPE_DBUS_OBJECT_SKELETON,
G_SIGNAL_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GDBusObjectStubClass, authorize_method), G_STRUCT_OFFSET (GDBusObjectSkeletonClass, authorize_method),
_g_signal_accumulator_false_handled, _g_signal_accumulator_false_handled,
NULL, NULL,
_gio_marshal_BOOLEAN__OBJECT_OBJECT, _gio_marshal_BOOLEAN__OBJECT_OBJECT,
G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
2, 2,
G_TYPE_DBUS_INTERFACE_STUB, G_TYPE_DBUS_INTERFACE_SKELETON,
G_TYPE_DBUS_METHOD_INVOCATION); G_TYPE_DBUS_METHOD_INVOCATION);
g_type_class_add_private (klass, sizeof (GDBusObjectStubPrivate)); g_type_class_add_private (klass, sizeof (GDBusObjectSkeletonPrivate));
} }
static void static void
g_dbus_object_stub_init (GDBusObjectStub *object) g_dbus_object_skeleton_init (GDBusObjectSkeleton *object)
{ {
object->priv = G_TYPE_INSTANCE_GET_PRIVATE (object, G_TYPE_DBUS_OBJECT_STUB, GDBusObjectStubPrivate); object->priv = G_TYPE_INSTANCE_GET_PRIVATE (object, G_TYPE_DBUS_OBJECT_SKELETON, GDBusObjectSkeletonPrivate);
object->priv->map_name_to_iface = g_hash_table_new_full (g_str_hash, object->priv->map_name_to_iface = g_hash_table_new_full (g_str_hash,
g_str_equal, g_str_equal,
g_free, g_free,
@ -207,27 +207,27 @@ g_dbus_object_stub_init (GDBusObjectStub *object)
} }
/** /**
* g_dbus_object_stub_new: * g_dbus_object_skeleton_new:
* @object_path: An object path. * @object_path: An object path.
* *
* Creates a new #GDBusObjectStub. * Creates a new #GDBusObjectSkeleton.
* *
* Returns: A #GDBusObjectStub. Free with g_object_unref(). * Returns: A #GDBusObjectSkeleton. Free with g_object_unref().
* *
* Since: 2.30 * Since: 2.30
*/ */
GDBusObjectStub * GDBusObjectSkeleton *
g_dbus_object_stub_new (const gchar *object_path) g_dbus_object_skeleton_new (const gchar *object_path)
{ {
g_return_val_if_fail (g_variant_is_object_path (object_path), NULL); g_return_val_if_fail (g_variant_is_object_path (object_path), NULL);
return G_DBUS_OBJECT_STUB (g_object_new (G_TYPE_DBUS_OBJECT_STUB, return G_DBUS_OBJECT_SKELETON (g_object_new (G_TYPE_DBUS_OBJECT_SKELETON,
"object-path", object_path, "object-path", object_path,
NULL)); NULL));
} }
/** /**
* g_dbus_object_stub_set_object_path: * g_dbus_object_skeleton_set_object_path:
* @object: A #GDBusObjectStub. * @object: A #GDBusObjectSkeleton.
* @object_path: A valid D-Bus object path. * @object_path: A valid D-Bus object path.
* *
* Sets the object path for @object. * Sets the object path for @object.
@ -235,10 +235,10 @@ g_dbus_object_stub_new (const gchar *object_path)
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_object_stub_set_object_path (GDBusObjectStub *object, g_dbus_object_skeleton_set_object_path (GDBusObjectSkeleton *object,
const gchar *object_path) const gchar *object_path)
{ {
g_return_if_fail (G_IS_DBUS_OBJECT_STUB (object)); g_return_if_fail (G_IS_DBUS_OBJECT_SKELETON (object));
g_return_if_fail (object_path == NULL || g_variant_is_object_path (object_path)); g_return_if_fail (object_path == NULL || g_variant_is_object_path (object_path));
/* TODO: fail if object is currently exported */ /* TODO: fail if object is currently exported */
if (g_strcmp0 (object->priv->object_path, object_path) != 0) if (g_strcmp0 (object->priv->object_path, object_path) != 0)
@ -250,20 +250,20 @@ g_dbus_object_stub_set_object_path (GDBusObjectStub *object,
} }
static const gchar * static const gchar *
g_dbus_object_stub_get_object_path (GDBusObject *_object) g_dbus_object_skeleton_get_object_path (GDBusObject *_object)
{ {
GDBusObjectStub *object = G_DBUS_OBJECT_STUB (_object); GDBusObjectSkeleton *object = G_DBUS_OBJECT_SKELETON (_object);
return object->priv->object_path; return object->priv->object_path;
} }
/** /**
* g_dbus_object_stub_add_interface: * g_dbus_object_skeleton_add_interface:
* @object: A #GDBusObjectStub. * @object: A #GDBusObjectSkeleton.
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Adds @interface_ to @object. * Adds @interface_ to @object.
* *
* If @object already contains a #GDBusInterfaceStub with the same * If @object already contains a #GDBusInterfaceSkeleton with the same
* interface name, it is removed before @interface_ is added. * interface name, it is removed before @interface_ is added.
* *
* Note that @object takes its own reference on @interface_ and holds * Note that @object takes its own reference on @interface_ and holds
@ -272,17 +272,17 @@ g_dbus_object_stub_get_object_path (GDBusObject *_object)
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_object_stub_add_interface (GDBusObjectStub *object, g_dbus_object_skeleton_add_interface (GDBusObjectSkeleton *object,
GDBusInterfaceStub *interface_) GDBusInterfaceSkeleton *interface_)
{ {
GDBusInterfaceInfo *info; GDBusInterfaceInfo *info;
g_return_if_fail (G_IS_DBUS_OBJECT_STUB (object)); g_return_if_fail (G_IS_DBUS_OBJECT_SKELETON (object));
g_return_if_fail (G_IS_DBUS_INTERFACE_STUB (interface_)); g_return_if_fail (G_IS_DBUS_INTERFACE_SKELETON (interface_));
info = g_dbus_interface_stub_get_info (interface_); info = g_dbus_interface_skeleton_get_info (interface_);
g_object_ref (interface_); g_object_ref (interface_);
g_dbus_object_stub_remove_interface_by_name (object, info->name); g_dbus_object_skeleton_remove_interface_by_name (object, info->name);
g_hash_table_insert (object->priv->map_name_to_iface, g_hash_table_insert (object->priv->map_name_to_iface,
g_strdup (info->name), g_strdup (info->name),
interface_); interface_);
@ -293,25 +293,25 @@ g_dbus_object_stub_add_interface (GDBusObjectStub *object,
} }
/** /**
* g_dbus_object_stub_remove_interface: * g_dbus_object_skeleton_remove_interface:
* @object: A #GDBusObjectStub. * @object: A #GDBusObjectSkeleton.
* @interface_: A #GDBusInterfaceStub. * @interface_: A #GDBusInterfaceSkeleton.
* *
* Removes @interface_ from @object. * Removes @interface_ from @object.
* *
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_object_stub_remove_interface (GDBusObjectStub *object, g_dbus_object_skeleton_remove_interface (GDBusObjectSkeleton *object,
GDBusInterfaceStub *interface_) GDBusInterfaceSkeleton *interface_)
{ {
GDBusInterfaceStub *other_interface; GDBusInterfaceSkeleton *other_interface;
GDBusInterfaceInfo *info; GDBusInterfaceInfo *info;
g_return_if_fail (G_IS_DBUS_OBJECT_STUB (object)); g_return_if_fail (G_IS_DBUS_OBJECT_SKELETON (object));
g_return_if_fail (G_IS_DBUS_INTERFACE (interface_)); g_return_if_fail (G_IS_DBUS_INTERFACE (interface_));
info = g_dbus_interface_stub_get_info (interface_); info = g_dbus_interface_skeleton_get_info (interface_);
other_interface = g_hash_table_lookup (object->priv->map_name_to_iface, info->name); other_interface = g_hash_table_lookup (object->priv->map_name_to_iface, info->name);
if (other_interface == NULL) if (other_interface == NULL)
@ -344,8 +344,8 @@ g_dbus_object_stub_remove_interface (GDBusObjectStub *object,
/** /**
* g_dbus_object_stub_remove_interface_by_name: * g_dbus_object_skeleton_remove_interface_by_name:
* @object: A #GDBusObjectStub. * @object: A #GDBusObjectSkeleton.
* @interface_name: A D-Bus interface name. * @interface_name: A D-Bus interface name.
* *
* Removes the #GDBusInterface with @interface_name from @object. * Removes the #GDBusInterface with @interface_name from @object.
@ -356,12 +356,12 @@ g_dbus_object_stub_remove_interface (GDBusObjectStub *object,
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_object_stub_remove_interface_by_name (GDBusObjectStub *object, g_dbus_object_skeleton_remove_interface_by_name (GDBusObjectSkeleton *object,
const gchar *interface_name) const gchar *interface_name)
{ {
GDBusInterface *interface; GDBusInterface *interface;
g_return_if_fail (G_IS_DBUS_OBJECT_STUB (object)); g_return_if_fail (G_IS_DBUS_OBJECT_SKELETON (object));
g_return_if_fail (g_dbus_is_interface_name (interface_name)); g_return_if_fail (g_dbus_is_interface_name (interface_name));
interface = g_hash_table_lookup (object->priv->map_name_to_iface, interface_name); interface = g_hash_table_lookup (object->priv->map_name_to_iface, interface_name);
@ -378,13 +378,13 @@ g_dbus_object_stub_remove_interface_by_name (GDBusObjectStub *object,
} }
static GDBusInterface * static GDBusInterface *
g_dbus_object_stub_get_interface (GDBusObject *_object, g_dbus_object_skeleton_get_interface (GDBusObject *_object,
const gchar *interface_name) const gchar *interface_name)
{ {
GDBusObjectStub *object = G_DBUS_OBJECT_STUB (_object); GDBusObjectSkeleton *object = G_DBUS_OBJECT_SKELETON (_object);
GDBusInterface *ret; GDBusInterface *ret;
g_return_val_if_fail (G_IS_DBUS_OBJECT_STUB (object), NULL); g_return_val_if_fail (G_IS_DBUS_OBJECT_SKELETON (object), NULL);
g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL); g_return_val_if_fail (g_dbus_is_interface_name (interface_name), NULL);
ret = g_hash_table_lookup (object->priv->map_name_to_iface, interface_name); ret = g_hash_table_lookup (object->priv->map_name_to_iface, interface_name);
@ -394,14 +394,14 @@ g_dbus_object_stub_get_interface (GDBusObject *_object,
} }
static GList * static GList *
g_dbus_object_stub_get_interfaces (GDBusObject *_object) g_dbus_object_skeleton_get_interfaces (GDBusObject *_object)
{ {
GDBusObjectStub *object = G_DBUS_OBJECT_STUB (_object); GDBusObjectSkeleton *object = G_DBUS_OBJECT_SKELETON (_object);
GList *ret; GList *ret;
GHashTableIter iter; GHashTableIter iter;
GDBusInterface *interface; GDBusInterface *interface;
g_return_val_if_fail (G_IS_DBUS_OBJECT_STUB (object), NULL); g_return_val_if_fail (G_IS_DBUS_OBJECT_SKELETON (object), NULL);
ret = NULL; ret = NULL;
@ -413,37 +413,37 @@ g_dbus_object_stub_get_interfaces (GDBusObject *_object)
} }
/** /**
* g_dbus_object_stub_flush: * g_dbus_object_skeleton_flush:
* @object: A #GDBusObjectStub. * @object: A #GDBusObjectSkeleton.
* *
* This method simply calls g_dbus_interface_stub_flush() on all * This method simply calls g_dbus_interface_skeleton_flush() on all
* interfaces stubs belonging to @object. See that method for when * interfaces belonging to @object. See that method for when flushing
* flushing is useful. * is useful.
* *
* Since: 2.30 * Since: 2.30
*/ */
void void
g_dbus_object_stub_flush (GDBusObjectStub *object) g_dbus_object_skeleton_flush (GDBusObjectSkeleton *object)
{ {
GHashTableIter iter; GHashTableIter iter;
GDBusInterfaceStub *interface_stub; GDBusInterfaceSkeleton *interface_skeleton;
g_hash_table_iter_init (&iter, object->priv->map_name_to_iface); g_hash_table_iter_init (&iter, object->priv->map_name_to_iface);
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &interface_stub)) while (g_hash_table_iter_next (&iter, NULL, (gpointer) &interface_skeleton))
{ {
g_dbus_interface_stub_flush (interface_stub); g_dbus_interface_skeleton_flush (interface_skeleton);
} }
} }
static gpointer static gpointer
g_dbus_object_stub_lookup_with_typecheck (GDBusObject *object, g_dbus_object_skeleton_lookup_with_typecheck (GDBusObject *object,
const gchar *interface_name, const gchar *interface_name,
GType type) GType type)
{ {
GDBusObjectStub *stub = G_DBUS_OBJECT_STUB (object); GDBusObjectSkeleton *skeleton = G_DBUS_OBJECT_SKELETON (object);
GDBusProxy *ret; GDBusProxy *ret;
ret = g_hash_table_lookup (stub->priv->map_name_to_iface, interface_name); ret = g_hash_table_lookup (skeleton->priv->map_name_to_iface, interface_name);
if (ret != NULL) if (ret != NULL)
{ {
g_warn_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ret, type)); g_warn_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ret, type));
@ -453,12 +453,12 @@ g_dbus_object_stub_lookup_with_typecheck (GDBusObject *object,
} }
static gpointer static gpointer
g_dbus_object_stub_peek_with_typecheck (GDBusObject *object, g_dbus_object_skeleton_peek_with_typecheck (GDBusObject *object,
const gchar *interface_name, const gchar *interface_name,
GType type) GType type)
{ {
GDBusInterfaceStub *ret; GDBusInterfaceSkeleton *ret;
ret = g_dbus_object_stub_lookup_with_typecheck (object, interface_name, type); ret = g_dbus_object_skeleton_lookup_with_typecheck (object, interface_name, type);
if (ret != NULL) if (ret != NULL)
g_object_unref (ret); g_object_unref (ret);
return ret; return ret;
@ -467,25 +467,25 @@ g_dbus_object_stub_peek_with_typecheck (GDBusObject *object,
static void static void
dbus_object_interface_init (GDBusObjectIface *iface) dbus_object_interface_init (GDBusObjectIface *iface)
{ {
iface->get_object_path = g_dbus_object_stub_get_object_path; iface->get_object_path = g_dbus_object_skeleton_get_object_path;
iface->get_interfaces = g_dbus_object_stub_get_interfaces; iface->get_interfaces = g_dbus_object_skeleton_get_interfaces;
iface->get_interface = g_dbus_object_stub_get_interface; iface->get_interface = g_dbus_object_skeleton_get_interface;
iface->lookup_with_typecheck = g_dbus_object_stub_lookup_with_typecheck; iface->lookup_with_typecheck = g_dbus_object_skeleton_lookup_with_typecheck;
iface->peek_with_typecheck = g_dbus_object_stub_peek_with_typecheck; iface->peek_with_typecheck = g_dbus_object_skeleton_peek_with_typecheck;
} }
gboolean gboolean
_g_dbus_object_stub_has_authorize_method_handlers (GDBusObjectStub *stub) _g_dbus_object_skeleton_has_authorize_method_handlers (GDBusObjectSkeleton *object)
{ {
gboolean has_handlers; gboolean has_handlers;
gboolean has_default_class_handler; gboolean has_default_class_handler;
has_handlers = g_signal_has_handler_pending (stub, has_handlers = g_signal_has_handler_pending (object,
signals[AUTHORIZE_METHOD_SIGNAL], signals[AUTHORIZE_METHOD_SIGNAL],
0, 0,
TRUE); TRUE);
has_default_class_handler = (G_DBUS_OBJECT_STUB_GET_CLASS (stub)->authorize_method == has_default_class_handler = (G_DBUS_OBJECT_SKELETON_GET_CLASS (object)->authorize_method ==
g_dbus_object_stub_authorize_method_default); g_dbus_object_skeleton_authorize_method_default);
return has_handlers || !has_default_class_handler; return has_handlers || !has_default_class_handler;
} }

91
gio/gdbusobjectskeleton.h Normal file
View File

@ -0,0 +1,91 @@
/* GDBus - GLib D-Bus Library
*
* Copyright (C) 2008-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#ifndef __G_DBUS_OBJECT_SKELETON_H__
#define __G_DBUS_OBJECT_SKELETON_H__
#include <gio/giotypes.h>
G_BEGIN_DECLS
#define G_TYPE_DBUS_OBJECT_SKELETON (g_dbus_object_skeleton_get_type ())
#define G_DBUS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_OBJECT_SKELETON, GDBusObjectSkeleton))
#define G_DBUS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_OBJECT_SKELETON, GDBusObjectSkeletonClass))
#define G_DBUS_OBJECT_SKELETON_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_OBJECT_SKELETON, GDBusObjectSkeletonClass))
#define G_IS_DBUS_OBJECT_SKELETON(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_OBJECT_SKELETON))
#define G_IS_DBUS_OBJECT_SKELETON_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_OBJECT_SKELETON))
typedef struct _GDBusObjectSkeletonClass GDBusObjectSkeletonClass;
typedef struct _GDBusObjectSkeletonPrivate GDBusObjectSkeletonPrivate;
/**
* GDBusObjectSkeleton:
*
* The #GDBusObjectSkeleton structure contains private data and should only be
* accessed using the provided API.
*
* Since: 2.30
*/
struct _GDBusObjectSkeleton
{
/*< private >*/
GObject parent_instance;
GDBusObjectSkeletonPrivate *priv;
};
/**
* GDBusObjectSkeletonClass:
* @parent_class: The parent class.
* @authorize_method: Signal class handler for the #GDBusObjectSkeleton::authorize-method signal.
*
* Class structure for #GDBusObjectSkeleton.
*
* Since: 2.30
*/
struct _GDBusObjectSkeletonClass
{
GObjectClass parent_class;
/* Signals */
gboolean (*authorize_method) (GDBusObjectSkeleton *object,
GDBusInterfaceSkeleton *interface_,
GDBusMethodInvocation *invocation);
/*< private >*/
gpointer padding[8];
};
GType g_dbus_object_skeleton_get_type (void) G_GNUC_CONST;
GDBusObjectSkeleton *g_dbus_object_skeleton_new (const gchar *object_path);
void g_dbus_object_skeleton_flush (GDBusObjectSkeleton *object);
void g_dbus_object_skeleton_add_interface (GDBusObjectSkeleton *object,
GDBusInterfaceSkeleton *interface_);
void g_dbus_object_skeleton_remove_interface (GDBusObjectSkeleton *object,
GDBusInterfaceSkeleton *interface_);
void g_dbus_object_skeleton_remove_interface_by_name (GDBusObjectSkeleton *object,
const gchar *interface_name);
void g_dbus_object_skeleton_set_object_path (GDBusObjectSkeleton *object,
const gchar *object_path);
G_END_DECLS
#endif /* __G_DBUS_OBJECT_SKELETON_H */

View File

@ -1,91 +0,0 @@
/* GDBus - GLib D-Bus Library
*
* Copyright (C) 2008-2010 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* Author: David Zeuthen <davidz@redhat.com>
*/
#ifndef __G_DBUS_OBJECT_STUB_H__
#define __G_DBUS_OBJECT_STUB_H__
#include <gio/giotypes.h>
G_BEGIN_DECLS
#define G_TYPE_DBUS_OBJECT_STUB (g_dbus_object_stub_get_type ())
#define G_DBUS_OBJECT_STUB(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), G_TYPE_DBUS_OBJECT_STUB, GDBusObjectStub))
#define G_DBUS_OBJECT_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), G_TYPE_DBUS_OBJECT_STUB, GDBusObjectStubClass))
#define G_DBUS_OBJECT_STUB_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), G_TYPE_DBUS_OBJECT_STUB, GDBusObjectStubClass))
#define G_IS_DBUS_OBJECT_STUB(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), G_TYPE_DBUS_OBJECT_STUB))
#define G_IS_DBUS_OBJECT_STUB_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), G_TYPE_DBUS_OBJECT_STUB))
typedef struct _GDBusObjectStubClass GDBusObjectStubClass;
typedef struct _GDBusObjectStubPrivate GDBusObjectStubPrivate;
/**
* GDBusObjectStub:
*
* The #GDBusObjectStub structure contains private data and should only be
* accessed using the provided API.
*
* Since: 2.30
*/
struct _GDBusObjectStub
{
/*< private >*/
GObject parent_instance;
GDBusObjectStubPrivate *priv;
};
/**
* GDBusObjectStubClass:
* @parent_class: The parent class.
* @authorize_method: Signal class handler for the #GDBusObjectStub::authorize-method signal.
*
* Class structure for #GDBusObjectStub.
*
* Since: 2.30
*/
struct _GDBusObjectStubClass
{
GObjectClass parent_class;
/* Signals */
gboolean (*authorize_method) (GDBusObjectStub *stub,
GDBusInterfaceStub *interface_stub,
GDBusMethodInvocation *invocation);
/*< private >*/
gpointer padding[8];
};
GType g_dbus_object_stub_get_type (void) G_GNUC_CONST;
GDBusObjectStub *g_dbus_object_stub_new (const gchar *object_path);
void g_dbus_object_stub_flush (GDBusObjectStub *object);
void g_dbus_object_stub_add_interface (GDBusObjectStub *object,
GDBusInterfaceStub *interface_);
void g_dbus_object_stub_remove_interface (GDBusObjectStub *object,
GDBusInterfaceStub *interface_);
void g_dbus_object_stub_remove_interface_by_name (GDBusObjectStub *object,
const gchar *interface_name);
void g_dbus_object_stub_set_object_path (GDBusObjectStub *object,
const gchar *object_path);
G_END_DECLS
#endif /* __G_DBUS_OBJECT_STUB_H */

View File

@ -131,7 +131,7 @@ gboolean _g_signal_accumulator_false_handled (GSignalInvocationHint *ihint,
const GValue *handler_return, const GValue *handler_return,
gpointer dummy); gpointer dummy);
gboolean _g_dbus_object_stub_has_authorize_method_handlers (GDBusObjectStub *stub); gboolean _g_dbus_object_skeleton_has_authorize_method_handlers (GDBusObjectSkeleton *object);
GDBusObjectProxy *_g_dbus_object_proxy_new (GDBusConnection *connection, GDBusObjectProxy *_g_dbus_object_proxy_new (GDBusConnection *connection,
const gchar *object_path); const gchar *object_path);

View File

@ -131,9 +131,9 @@
#include <gio/gzlibcompressor.h> #include <gio/gzlibcompressor.h>
#include <gio/gzlibdecompressor.h> #include <gio/gzlibdecompressor.h>
#include <gio/gdbusinterface.h> #include <gio/gdbusinterface.h>
#include <gio/gdbusinterfacestub.h> #include <gio/gdbusinterfaceskeleton.h>
#include <gio/gdbusobject.h> #include <gio/gdbusobject.h>
#include <gio/gdbusobjectstub.h> #include <gio/gdbusobjectskeleton.h>
#include <gio/gdbusobjectproxy.h> #include <gio/gdbusobjectproxy.h>
#include <gio/gdbusobjectmanager.h> #include <gio/gdbusobjectmanager.h>
#include <gio/gdbusobjectmanagerclient.h> #include <gio/gdbusobjectmanagerclient.h>

View File

@ -2098,20 +2098,20 @@ g_dbus_interface_set_object
#endif #endif
#endif #endif
#if IN_HEADER(__G_DBUS_INTERFACE_STUB_H__) #if IN_HEADER(__G_DBUS_INTERFACE_SKELETON_H__)
#if IN_FILE(__G_DBUS_INTERFACE_STUB_C__) #if IN_FILE(__G_DBUS_INTERFACE_SKELETON_C__)
g_dbus_interface_stub_export g_dbus_interface_skeleton_export
g_dbus_interface_stub_flags_get_type g_dbus_interface_skeleton_flags_get_type
g_dbus_interface_stub_flush g_dbus_interface_skeleton_flush
g_dbus_interface_stub_get_connection g_dbus_interface_skeleton_get_connection
g_dbus_interface_stub_get_flags g_dbus_interface_skeleton_get_flags
g_dbus_interface_stub_get_info g_dbus_interface_skeleton_get_info
g_dbus_interface_stub_get_object_path g_dbus_interface_skeleton_get_object_path
g_dbus_interface_stub_get_properties g_dbus_interface_skeleton_get_properties
g_dbus_interface_stub_get_type g_dbus_interface_skeleton_get_type
g_dbus_interface_stub_get_vtable g_dbus_interface_skeleton_get_vtable
g_dbus_interface_stub_set_flags g_dbus_interface_skeleton_set_flags
g_dbus_interface_stub_unexport g_dbus_interface_skeleton_unexport
#endif #endif
#endif #endif
@ -2133,15 +2133,15 @@ g_dbus_object_proxy_get_type
#endif #endif
#endif #endif
#if IN_HEADER(__G_DBUS_OBJECT_STUB_H__) #if IN_HEADER(__G_DBUS_OBJECT_SKELETON_H__)
#if IN_FILE(__G_DBUS_OBJECT_STUB_C__) #if IN_FILE(__G_DBUS_OBJECT_SKELETON_C__)
g_dbus_object_stub_add_interface g_dbus_object_skeleton_add_interface
g_dbus_object_stub_flush g_dbus_object_skeleton_flush
g_dbus_object_stub_get_type g_dbus_object_skeleton_get_type
g_dbus_object_stub_new g_dbus_object_skeleton_new
g_dbus_object_stub_remove_interface g_dbus_object_skeleton_remove_interface
g_dbus_object_stub_remove_interface_by_name g_dbus_object_skeleton_remove_interface_by_name
g_dbus_object_stub_set_object_path g_dbus_object_skeleton_set_object_path
#endif #endif
#endif #endif

View File

@ -1384,22 +1384,22 @@ typedef enum {
} GTlsRehandshakeMode; } GTlsRehandshakeMode;
/** /**
* GDBusInterfaceStubFlags: * GDBusInterfaceSkeletonFlags:
* @G_DBUS_INTERFACE_STUB_FLAGS_NONE: No flags set. * @G_DBUS_INTERFACE_SKELETON_FLAGS_NONE: No flags set.
* @G_DBUS_INTERFACE_STUB_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD: Each method invocation is handled in * @G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD: Each method invocation is handled in
* a thread dedicated to the invocation. This means that the method implementation can use blocking IO * a thread dedicated to the invocation. This means that the method implementation can use blocking IO
* without blocking any other part of the process. It also means that the method implementation must * without blocking any other part of the process. It also means that the method implementation must
* use locking to access data structures used by other threads. * use locking to access data structures used by other threads.
* *
* Flags describing the behavior of a #GDBusInterfaceStub class. * Flags describing the behavior of a #GDBusInterfaceSkeleton instance.
* *
* Since: 2.30 * Since: 2.30
*/ */
typedef enum typedef enum
{ {
G_DBUS_INTERFACE_STUB_FLAGS_NONE = 0, G_DBUS_INTERFACE_SKELETON_FLAGS_NONE = 0,
G_DBUS_INTERFACE_STUB_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD = (1<<0) G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD = (1<<0)
} GDBusInterfaceStubFlags; } GDBusInterfaceSkeletonFlags;
/** /**
* GDBusObjectManagerClientFlags: * GDBusObjectManagerClientFlags:

View File

@ -419,9 +419,9 @@ typedef gboolean (*GPollableSourceFunc) (GObject *pollable_stream,
gpointer user_data); gpointer user_data);
typedef struct _GDBusInterface GDBusInterface; /* Dummy typedef */ typedef struct _GDBusInterface GDBusInterface; /* Dummy typedef */
typedef struct _GDBusInterfaceStub GDBusInterfaceStub; typedef struct _GDBusInterfaceSkeleton GDBusInterfaceSkeleton;
typedef struct _GDBusObject GDBusObject; /* Dummy typedef */ typedef struct _GDBusObject GDBusObject; /* Dummy typedef */
typedef struct _GDBusObjectStub GDBusObjectStub; typedef struct _GDBusObjectSkeleton GDBusObjectSkeleton;
typedef struct _GDBusObjectProxy GDBusObjectProxy; typedef struct _GDBusObjectProxy GDBusObjectProxy;
typedef struct _GDBusObjectManager GDBusObjectManager; /* Dummy typedef */ typedef struct _GDBusObjectManager GDBusObjectManager; /* Dummy typedef */
typedef struct _GDBusObjectManagerClient GDBusObjectManagerClient; typedef struct _GDBusObjectManagerClient GDBusObjectManagerClient;

View File

@ -62,7 +62,7 @@ on_bus_acquired (GDBusConnection *connection,
const gchar *name, const gchar *name,
gpointer user_data) gpointer user_data)
{ {
GDBusObjectStub *object; GDBusObjectSkeleton *object;
guint n; guint n;
g_print ("Acquired a message bus connection\n"); g_print ("Acquired a message bus connection\n");
@ -77,16 +77,16 @@ on_bus_acquired (GDBusConnection *connection,
/* Create a new D-Bus object at the path /example/Animals/N where N is 000..009 */ /* Create a new D-Bus object at the path /example/Animals/N where N is 000..009 */
s = g_strdup_printf ("/example/Animals/%03d", n); s = g_strdup_printf ("/example/Animals/%03d", n);
object = g_dbus_object_stub_new (s); object = g_dbus_object_skeleton_new (s);
g_free (s); g_free (s);
/* Make the newly created object export the interface /* Make the newly created object export the interface
* org.gtk.GDBus.Example.ObjectManager.Animal (note * org.gtk.GDBus.Example.ObjectManager.Animal (note
* that @object takes its own reference to @animal). * that @object takes its own reference to @animal).
*/ */
animal = example_animal_stub_new (); animal = example_animal_skeleton_new ();
example_animal_set_mood (animal, "Happy"); example_animal_set_mood (animal, "Happy");
g_dbus_object_stub_add_interface (object, G_DBUS_INTERFACE_STUB (animal)); g_dbus_object_skeleton_add_interface (object, G_DBUS_INTERFACE_SKELETON (animal));
g_object_unref (animal); g_object_unref (animal);
/* Cats are odd animals - so some of our objects implement the /* Cats are odd animals - so some of our objects implement the
@ -96,8 +96,8 @@ on_bus_acquired (GDBusConnection *connection,
if (n % 2 == 1) if (n % 2 == 1)
{ {
ExampleCat *cat; ExampleCat *cat;
cat = example_cat_stub_new (); cat = example_cat_skeleton_new ();
g_dbus_object_stub_add_interface (object, G_DBUS_INTERFACE_STUB (cat)); g_dbus_object_skeleton_add_interface (object, G_DBUS_INTERFACE_SKELETON (cat));
g_object_unref (cat); g_object_unref (cat);
} }

View File

@ -93,7 +93,7 @@ on_handle_hello_world (FooBar *object,
gpointer user_data) gpointer user_data)
{ {
gchar *response; gchar *response;
response = g_strdup_printf ("Word! You said `%s'. I'm Stub, btw!", greeting); response = g_strdup_printf ("Word! You said `%s'. I'm Skeleton, btw!", greeting);
foo_bar_complete_hello_world (object, invocation, response); foo_bar_complete_hello_world (object, invocation, response);
g_free (response); g_free (response);
return TRUE; return TRUE;
@ -205,7 +205,7 @@ on_handle_request_multi_property_mods (FooBar *object,
foo_bar_set_i (object, foo_bar_get_i (object) + 1); foo_bar_set_i (object, foo_bar_get_i (object) + 1);
foo_bar_set_y (object, foo_bar_get_y (object) + 1); foo_bar_set_y (object, foo_bar_get_y (object) + 1);
foo_bar_set_i (object, foo_bar_get_i (object) + 1); foo_bar_set_i (object, foo_bar_get_i (object) + 1);
g_dbus_interface_stub_flush (G_DBUS_INTERFACE_STUB (object)); g_dbus_interface_skeleton_flush (G_DBUS_INTERFACE_SKELETON (object));
foo_bar_set_y (object, foo_bar_get_y (object) + 1); foo_bar_set_y (object, foo_bar_get_y (object) + 1);
foo_bar_set_i (object, foo_bar_get_i (object) + 1); foo_bar_set_i (object, foo_bar_get_i (object) + 1);
foo_bar_complete_request_multi_property_mods (object, invocation); foo_bar_complete_request_multi_property_mods (object, invocation);
@ -271,9 +271,9 @@ on_handle_force_method (FooBat *object,
/* ---------------------------------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------------------------------- */
static gboolean static gboolean
my_g_authorize_method_handler (GDBusInterfaceStub *interface, my_g_authorize_method_handler (GDBusInterfaceSkeleton *interface,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
gpointer user_data) gpointer user_data)
{ {
const gchar *method_name; const gchar *method_name;
gboolean authorized; gboolean authorized;
@ -309,10 +309,10 @@ my_g_authorize_method_handler (GDBusInterfaceStub *interface,
} }
static gboolean static gboolean
my_object_authorize_method_handler (GDBusObjectStub *object, my_object_authorize_method_handler (GDBusObjectSkeleton *object,
GDBusInterfaceStub *interface, GDBusInterfaceSkeleton *interface,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
gpointer user_data) gpointer user_data)
{ {
const gchar *method_name; const gchar *method_name;
gboolean authorized; gboolean authorized;
@ -395,7 +395,7 @@ static GThread *method_handler_thread = NULL;
static FooBar *exported_bar_object = NULL; static FooBar *exported_bar_object = NULL;
static FooBat *exported_bat_object = NULL; static FooBat *exported_bat_object = NULL;
static FooAuthorize *exported_authorize_object = NULL; static FooAuthorize *exported_authorize_object = NULL;
static GDBusObjectStub *authorize_enclosing_object = NULL; static GDBusObjectSkeleton *authorize_enclosing_object = NULL;
static FooMethodThreads *exported_thread_object_1 = NULL; static FooMethodThreads *exported_thread_object_1 = NULL;
static FooMethodThreads *exported_thread_object_2 = NULL; static FooMethodThreads *exported_thread_object_2 = NULL;
@ -407,7 +407,7 @@ on_bus_acquired (GDBusConnection *connection,
GError *error; GError *error;
/* Test that we can export an object using the generated /* Test that we can export an object using the generated
* FooBarStub subclass. Notes: * FooBarSkeleton subclass. Notes:
* *
* 1. We handle methods by simply connecting to the appropriate * 1. We handle methods by simply connecting to the appropriate
* GObject signal. * GObject signal.
@ -417,23 +417,23 @@ on_bus_acquired (GDBusConnection *connection,
* C bindings at will) * C bindings at will)
*/ */
error = NULL; error = NULL;
exported_bar_object = foo_bar_stub_new (); exported_bar_object = foo_bar_skeleton_new ();
foo_bar_set_ay (exported_bar_object, "ABCabc"); foo_bar_set_ay (exported_bar_object, "ABCabc");
foo_bar_set_y (exported_bar_object, 42); foo_bar_set_y (exported_bar_object, 42);
foo_bar_set_d (exported_bar_object, 43.0); foo_bar_set_d (exported_bar_object, 43.0);
foo_bar_set_finally_normal_name (exported_bar_object, "There aint no place like home"); foo_bar_set_finally_normal_name (exported_bar_object, "There aint no place like home");
foo_bar_set_writeonly_property (exported_bar_object, "Mr. Burns"); foo_bar_set_writeonly_property (exported_bar_object, "Mr. Burns");
/* The following works because it's on the Stub object - it will /* The following works because it's on the Skeleton object - it will
* fail (at run-time) on a Proxy (see on_proxy_appeared() below) * fail (at run-time) on a Proxy (see on_proxy_appeared() below)
*/ */
foo_bar_set_readonly_property (exported_bar_object, "blah"); foo_bar_set_readonly_property (exported_bar_object, "blah");
g_assert_cmpstr (foo_bar_get_writeonly_property (exported_bar_object), ==, "Mr. Burns"); g_assert_cmpstr (foo_bar_get_writeonly_property (exported_bar_object), ==, "Mr. Burns");
g_dbus_interface_stub_export (G_DBUS_INTERFACE_STUB (exported_bar_object), g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (exported_bar_object),
connection, connection,
"/bar", "/bar",
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);
g_signal_connect (exported_bar_object, g_signal_connect (exported_bar_object,
"handle-hello-world", "handle-hello-world",
@ -456,11 +456,11 @@ on_bus_acquired (GDBusConnection *connection,
G_CALLBACK (on_handle_request_multi_property_mods), G_CALLBACK (on_handle_request_multi_property_mods),
NULL); NULL);
exported_bat_object = foo_bat_stub_new (); exported_bat_object = foo_bat_skeleton_new ();
g_dbus_interface_stub_export (G_DBUS_INTERFACE_STUB (exported_bat_object), g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (exported_bat_object),
connection, connection,
"/bat", "/bat",
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);
g_signal_connect (exported_bat_object, g_signal_connect (exported_bat_object,
"handle-force-method", "handle-force-method",
@ -473,18 +473,18 @@ on_bus_acquired (GDBusConnection *connection,
"force-struct", g_variant_new ("(i)", 4300), "force-struct", g_variant_new ("(i)", 4300),
NULL); NULL);
authorize_enclosing_object = g_dbus_object_stub_new ("/authorize"); authorize_enclosing_object = g_dbus_object_skeleton_new ("/authorize");
g_signal_connect (authorize_enclosing_object, g_signal_connect (authorize_enclosing_object,
"authorize-method", "authorize-method",
G_CALLBACK (my_object_authorize_method_handler), G_CALLBACK (my_object_authorize_method_handler),
NULL); NULL);
exported_authorize_object = foo_authorize_stub_new (); exported_authorize_object = foo_authorize_skeleton_new ();
g_dbus_object_stub_add_interface (authorize_enclosing_object, g_dbus_object_skeleton_add_interface (authorize_enclosing_object,
G_DBUS_INTERFACE_STUB (exported_authorize_object)); G_DBUS_INTERFACE_SKELETON (exported_authorize_object));
g_dbus_interface_stub_export (G_DBUS_INTERFACE_STUB (exported_authorize_object), g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (exported_authorize_object),
connection, connection,
"/authorize", "/authorize",
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);
g_signal_connect (exported_authorize_object, g_signal_connect (exported_authorize_object,
"g-authorize-method", "g-authorize-method",
@ -504,25 +504,25 @@ on_bus_acquired (GDBusConnection *connection,
NULL); NULL);
/* only object 1 has the G_DBUS_INTERFACE_STUB_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD flag set */ /* only object 1 has the G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD flag set */
exported_thread_object_1 = foo_method_threads_stub_new (); exported_thread_object_1 = foo_method_threads_skeleton_new ();
g_dbus_interface_stub_set_flags (G_DBUS_INTERFACE_STUB (exported_thread_object_1), g_dbus_interface_skeleton_set_flags (G_DBUS_INTERFACE_SKELETON (exported_thread_object_1),
G_DBUS_INTERFACE_STUB_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD); G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD);
g_dbus_interface_stub_export (G_DBUS_INTERFACE_STUB (exported_thread_object_1), g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (exported_thread_object_1),
connection, connection,
"/method_threads_1", "/method_threads_1",
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);
g_signal_connect (exported_thread_object_1, g_signal_connect (exported_thread_object_1,
"handle-get-self", "handle-get-self",
G_CALLBACK (on_handle_get_self), G_CALLBACK (on_handle_get_self),
NULL); NULL);
exported_thread_object_2 = foo_method_threads_stub_new (); exported_thread_object_2 = foo_method_threads_skeleton_new ();
g_dbus_interface_stub_export (G_DBUS_INTERFACE_STUB (exported_thread_object_2), g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (exported_thread_object_2),
connection, connection,
"/method_threads_2", "/method_threads_2",
&error); &error);
g_assert_no_error (error); g_assert_no_error (error);
g_signal_connect (exported_thread_object_2, g_signal_connect (exported_thread_object_2,
"handle-get-self", "handle-get-self",
@ -1648,29 +1648,29 @@ on_object_proxy_removed (GDBusObjectManagerClient *manager,
static void static void
om_check_property_and_signal_emission (GMainLoop *loop, om_check_property_and_signal_emission (GMainLoop *loop,
FooBar *stub, FooBar *skeleton,
FooBar *proxy) FooBar *proxy)
{ {
/* First PropertiesChanged */ /* First PropertiesChanged */
g_assert_cmpint (foo_bar_get_i (stub), ==, 0); g_assert_cmpint (foo_bar_get_i (skeleton), ==, 0);
g_assert_cmpint (foo_bar_get_i (proxy), ==, 0); g_assert_cmpint (foo_bar_get_i (proxy), ==, 0);
foo_bar_set_i (stub, 1); foo_bar_set_i (skeleton, 1);
_g_assert_property_notify (proxy, "i"); _g_assert_property_notify (proxy, "i");
g_assert_cmpint (foo_bar_get_i (stub), ==, 1); g_assert_cmpint (foo_bar_get_i (skeleton), ==, 1);
g_assert_cmpint (foo_bar_get_i (proxy), ==, 1); g_assert_cmpint (foo_bar_get_i (proxy), ==, 1);
/* Then just a regular signal */ /* Then just a regular signal */
foo_bar_emit_another_signal (stub, "word"); foo_bar_emit_another_signal (skeleton, "word");
_g_assert_signal_received (proxy, "another-signal"); _g_assert_signal_received (proxy, "another-signal");
} }
static void static void
check_object_manager (void) check_object_manager (void)
{ {
GDBusObjectStub *o; GDBusObjectSkeleton *o;
GDBusObjectStub *o2; GDBusObjectSkeleton *o2;
GDBusInterfaceStub *i; GDBusInterfaceSkeleton *i;
GDBusInterfaceStub *i2; GDBusInterfaceSkeleton *i2;
GDBusConnection *c; GDBusConnection *c;
GDBusObjectManagerServer *manager; GDBusObjectManagerServer *manager;
GDBusNodeInfo *info; GDBusNodeInfo *info;
@ -1683,7 +1683,7 @@ check_object_manager (void)
GList *proxies; GList *proxies;
GDBusObject *op; GDBusObject *op;
GDBusProxy *p; GDBusProxy *p;
FooBar *bar_stub; FooBar *bar_skeleton;
FooBar *bar_p; FooBar *bar_p;
FooBar *bar_p2; FooBar *bar_p2;
FooComAcmeCoyote *coyote_p; FooComAcmeCoyote *coyote_p;
@ -1777,19 +1777,19 @@ check_object_manager (void)
/* First, export an object with a single interface (also check that /* First, export an object with a single interface (also check that
* g_dbus_interface_get_object() works and that the object isn't reffed) * g_dbus_interface_get_object() works and that the object isn't reffed)
*/ */
o = g_dbus_object_stub_new ("/managed/first"); o = g_dbus_object_skeleton_new ("/managed/first");
i = G_DBUS_INTERFACE_STUB (foo_bar_stub_new ()); i = G_DBUS_INTERFACE_SKELETON (foo_bar_skeleton_new ());
g_assert (g_dbus_interface_get_object (G_DBUS_INTERFACE (i)) == NULL); g_assert (g_dbus_interface_get_object (G_DBUS_INTERFACE (i)) == NULL);
g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1); g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1);
g_dbus_object_stub_add_interface (o, i); g_dbus_object_skeleton_add_interface (o, i);
g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1); g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1);
g_assert (g_dbus_interface_get_object (G_DBUS_INTERFACE (i)) == G_DBUS_OBJECT (o)); g_assert (g_dbus_interface_get_object (G_DBUS_INTERFACE (i)) == G_DBUS_OBJECT (o));
g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1); g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1);
g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1); g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1);
g_dbus_object_stub_remove_interface (o, i); g_dbus_object_skeleton_remove_interface (o, i);
g_assert (g_dbus_interface_get_object (G_DBUS_INTERFACE (i)) == NULL); g_assert (g_dbus_interface_get_object (G_DBUS_INTERFACE (i)) == NULL);
g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1); g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1);
g_dbus_object_stub_add_interface (o, i); g_dbus_object_skeleton_add_interface (o, i);
g_assert (g_dbus_interface_get_object (G_DBUS_INTERFACE (i)) == G_DBUS_OBJECT (o)); g_assert (g_dbus_interface_get_object (G_DBUS_INTERFACE (i)) == G_DBUS_OBJECT (o));
g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1); g_assert_cmpint (G_OBJECT (o)->ref_count, ==, 1);
g_dbus_object_manager_server_export (manager, o); g_dbus_object_manager_server_export (manager, o);
@ -1809,7 +1809,7 @@ check_object_manager (void)
g_dbus_node_info_unref (info); g_dbus_node_info_unref (info);
/* Now, check adding the same interface replaces the existing one */ /* Now, check adding the same interface replaces the existing one */
g_dbus_object_stub_add_interface (o, i); g_dbus_object_skeleton_add_interface (o, i);
/* ... check we get the InterfacesRemoved */ /* ... check we get the InterfacesRemoved */
om_data->state = 3; om_data->state = 3;
g_main_loop_run (om_data->loop); g_main_loop_run (om_data->loop);
@ -1827,8 +1827,8 @@ check_object_manager (void)
g_object_unref (i); g_object_unref (i);
/* check adding an interface of same type (but not same object) replaces the existing one */ /* check adding an interface of same type (but not same object) replaces the existing one */
i = G_DBUS_INTERFACE_STUB (foo_bar_stub_new ()); i = G_DBUS_INTERFACE_SKELETON (foo_bar_skeleton_new ());
g_dbus_object_stub_add_interface (o, i); g_dbus_object_skeleton_add_interface (o, i);
/* ... check we get the InterfacesRemoved and then InterfacesAdded */ /* ... check we get the InterfacesRemoved and then InterfacesAdded */
om_data->state = 7; om_data->state = 7;
g_main_loop_run (om_data->loop); g_main_loop_run (om_data->loop);
@ -1845,8 +1845,8 @@ check_object_manager (void)
g_object_unref (i); g_object_unref (i);
/* check adding an interface of another type doesn't replace the existing one */ /* check adding an interface of another type doesn't replace the existing one */
i = G_DBUS_INTERFACE_STUB (foo_bat_stub_new ()); i = G_DBUS_INTERFACE_SKELETON (foo_bat_skeleton_new ());
g_dbus_object_stub_add_interface (o, i); g_dbus_object_skeleton_add_interface (o, i);
g_object_unref (i); g_object_unref (i);
/* ... check we get the InterfacesAdded */ /* ... check we get the InterfacesAdded */
om_data->state = 11; om_data->state = 11;
@ -1864,7 +1864,7 @@ check_object_manager (void)
g_dbus_node_info_unref (info); g_dbus_node_info_unref (info);
/* check we can remove an interface */ /* check we can remove an interface */
g_dbus_object_stub_remove_interface_by_name (o, "org.project.Bar"); g_dbus_object_skeleton_remove_interface_by_name (o, "org.project.Bar");
/* ... check we get the InterfacesRemoved */ /* ... check we get the InterfacesRemoved */
om_data->state = 13; om_data->state = 13;
g_main_loop_run (om_data->loop); g_main_loop_run (om_data->loop);
@ -1883,7 +1883,7 @@ check_object_manager (void)
* (Note: if a signal was emitted we'd assert in the signal handler * (Note: if a signal was emitted we'd assert in the signal handler
* because we're in state 14) * because we're in state 14)
*/ */
g_dbus_object_stub_remove_interface_by_name (o, "org.project.Bar"); g_dbus_object_skeleton_remove_interface_by_name (o, "org.project.Bar");
/* ... check introspection data */ /* ... check introspection data */
info = introspect (c, g_dbus_connection_get_unique_name (c), "/managed/first", loop); info = introspect (c, g_dbus_connection_get_unique_name (c), "/managed/first", loop);
g_assert_cmpint (count_interfaces (info), ==, 4); /* Bat + Properties,Introspectable,Peer */ g_assert_cmpint (count_interfaces (info), ==, 4); /* Bat + Properties,Introspectable,Peer */
@ -1891,7 +1891,7 @@ check_object_manager (void)
g_dbus_node_info_unref (info); g_dbus_node_info_unref (info);
/* remove the last interface */ /* remove the last interface */
g_dbus_object_stub_remove_interface_by_name (o, "org.project.Bat"); g_dbus_object_skeleton_remove_interface_by_name (o, "org.project.Bat");
/* ... check we get the InterfacesRemoved */ /* ... check we get the InterfacesRemoved */
om_data->state = 15; om_data->state = 15;
g_main_loop_run (om_data->loop); g_main_loop_run (om_data->loop);
@ -1906,8 +1906,8 @@ check_object_manager (void)
g_dbus_node_info_unref (info); g_dbus_node_info_unref (info);
/* and add an interface again */ /* and add an interface again */
i = G_DBUS_INTERFACE_STUB (foo_com_acme_coyote_stub_new ()); i = G_DBUS_INTERFACE_SKELETON (foo_com_acme_coyote_skeleton_new ());
g_dbus_object_stub_add_interface (o, i); g_dbus_object_skeleton_add_interface (o, i);
g_object_unref (i); g_object_unref (i);
/* ... check we get the InterfacesAdded */ /* ... check we get the InterfacesAdded */
om_data->state = 17; om_data->state = 17;
@ -1930,13 +1930,13 @@ check_object_manager (void)
/* -------------------------------------------------- */ /* -------------------------------------------------- */
/* create a new object with two interfaces */ /* create a new object with two interfaces */
o2 = g_dbus_object_stub_new ("/managed/second"); o2 = g_dbus_object_skeleton_new ("/managed/second");
i = G_DBUS_INTERFACE_STUB (foo_bar_stub_new ()); i = G_DBUS_INTERFACE_SKELETON (foo_bar_skeleton_new ());
bar_stub = FOO_BAR (i); /* save for later test */ bar_skeleton = FOO_BAR (i); /* save for later test */
g_dbus_object_stub_add_interface (o2, i); g_dbus_object_skeleton_add_interface (o2, i);
g_object_unref (i); g_object_unref (i);
i = G_DBUS_INTERFACE_STUB (foo_bat_stub_new ()); i = G_DBUS_INTERFACE_SKELETON (foo_bat_skeleton_new ());
g_dbus_object_stub_add_interface (o2, i); g_dbus_object_skeleton_add_interface (o2, i);
g_object_unref (i); g_object_unref (i);
/* ... add it */ /* ... add it */
g_dbus_object_manager_server_export (manager, o2); g_dbus_object_manager_server_export (manager, o2);
@ -1962,9 +1962,9 @@ check_object_manager (void)
g_assert (i == NULL); g_assert (i == NULL);
i = FOO_PEEK_COM_ACME_COYOTE (o); i = FOO_PEEK_COM_ACME_COYOTE (o);
g_assert (i != NULL); g_assert (i != NULL);
g_assert (g_type_is_a (G_TYPE_FROM_INSTANCE (i), G_TYPE_DBUS_INTERFACE_STUB)); g_assert (g_type_is_a (G_TYPE_FROM_INSTANCE (i), G_TYPE_DBUS_INTERFACE_SKELETON));
g_assert (g_type_is_a (G_TYPE_FROM_INSTANCE (i), FOO_TYPE_COM_ACME_COYOTE)); g_assert (g_type_is_a (G_TYPE_FROM_INSTANCE (i), FOO_TYPE_COM_ACME_COYOTE));
g_assert (g_type_is_a (G_TYPE_FROM_INSTANCE (i), FOO_TYPE_COM_ACME_COYOTE_STUB)); g_assert (g_type_is_a (G_TYPE_FROM_INSTANCE (i), FOO_TYPE_COM_ACME_COYOTE_SKELETON));
/* ... and that PEEK doesn't increase the ref_count but GET does */ /* ... and that PEEK doesn't increase the ref_count but GET does */
g_assert_cmpint (G_OBJECT (i)->ref_count, ==, 2); g_assert_cmpint (G_OBJECT (i)->ref_count, ==, 2);
i2 = FOO_PEEK_COM_ACME_COYOTE (o); i2 = FOO_PEEK_COM_ACME_COYOTE (o);
@ -2018,7 +2018,7 @@ check_object_manager (void)
/* ... now that we have a Bar instance around, also check that we get signals /* ... now that we have a Bar instance around, also check that we get signals
* and property changes... * and property changes...
*/ */
om_check_property_and_signal_emission (loop, bar_stub, FOO_BAR (p)); om_check_property_and_signal_emission (loop, bar_skeleton, FOO_BAR (p));
g_object_unref (p); g_object_unref (p);
p = (GDBusProxy *) g_dbus_object_get_interface (op, "org.project.NonExisting"); p = (GDBusProxy *) g_dbus_object_get_interface (op, "org.project.NonExisting");
g_assert (p == NULL); g_assert (p == NULL);