656
656
<span class="gtkdoc kwb">const</span> gchar<span class="gtkdoc opt">*</span> <span class="gtkdoc kwb">const</span> <span class="gtkdoc opt">*</span>messages<span class="gtkdoc opt">);</span>
658
658
<span class="comment">/* Signal handler for the ::handle-hello-world signal */</span>
659
<span class="function"><a href="../glib/glib-Basic-Types.html#gboolean">gboolean</a></span> <span class="gtkdoc opt">(*</span>handle_hello_world<span class="gtkdoc opt">) (</span>MyAppFrobber <span class="gtkdoc opt">*</span>proxy<span class="gtkdoc opt">,</span>
659
<span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean">gboolean</a></span> <span class="gtkdoc opt">(*</span>handle_hello_world<span class="gtkdoc opt">) (</span>MyAppFrobber <span class="gtkdoc opt">*</span>proxy<span class="gtkdoc opt">,</span>
660
660
GDBusMethodInvocation <span class="gtkdoc opt">*</span>invocation<span class="gtkdoc opt">,</span>
661
661
<span class="gtkdoc kwb">const</span> gchar <span class="gtkdoc opt">*</span>greeting<span class="gtkdoc opt">);</span>
662
662
<span class="gtkdoc opt">}</span> MyAppFrobberIface<span class="gtkdoc opt">;</span>
744
744
Thus, for every D-Bus method, there will be three C functions for
745
calling the method, one <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> signal for handling an incoming
745
calling the method, one <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> signal for handling an incoming
746
746
call and one C function for completing an incoming call. For every
747
D-Bus signal, there's one <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> signal and one C function for
747
D-Bus signal, there's one <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> signal and one C function for
748
748
emitting it. For every D-Bus property, two C functions are
749
generated (one setter, one getter) and one <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> property. The
749
generated (one setter, one getter) and one <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a> property. The
750
750
following table summarizes the generated facilities and where they
783
783
<td>Properties (Reading)</td>
784
784
<td>Use <code class="function"><code class="function">m_a_f_get_verbose()</code></code> or <em class="parameter"><code>:verbose</code></em>.</td>
785
<td>Implement <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>'s <code class="function"><code class="function">get_property()</code></code> vfunc.</td>
785
<td>Implement <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>'s <code class="function"><code class="function">get_property()</code></code> vfunc.</td>
788
788
<td>Properties (writing)</td>
789
789
<td>Use <code class="function"><code class="function">m_a_f_set_verbose()</code></code> or <em class="parameter"><code>:verbose</code></em>.</td>
790
<td>Implement <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>'s <code class="function"><code class="function">set_property()</code></code> vfunc.</td>
790
<td>Implement <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>'s <code class="function"><code class="function">set_property()</code></code> vfunc.</td>
863
863
<a name="id-1.4.24.7.10.11"></a><h3>Server-side usage</h3>
865
865
The generated <span class="type">MyAppFrobber</span> interface is designed so
866
it is easy to implement it in a <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>
866
it is easy to implement it in a <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>
867
867
subclass. For example, to handle
868
868
<code class="function"><code class="function">HelloWorld()</code></code> method invocations, set the
869
869
vfunc for <code class="function"><code class="function">handle_hello_hello_world()</code></code> in the
870
870
<span class="type">MyAppFrobberIface</span> structure. Similary, to handle
871
871
the <em class="parameter"><code>net.Corp.MyApp.Frobber:Verbose</code></em>
872
property override the <em class="parameter"><code>:verbose</code></em> <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>
872
property override the <em class="parameter"><code>:verbose</code></em> <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>
873
873
property from the subclass. To emit a signal, use
874
874
e.g. <code class="function"><code class="function">my_app_emit_signal()</code></code> or
875
<a href="../gobject/gobject-Signals.html#g-signal-emit-by-name"><code class="function">g_signal_emit_by_name()</code></a>.
875
<a href="http://library.gnome.org/devel/gobject/unstable/gobject-Signals.html#g-signal-emit-by-name"><code class="function">g_signal_emit_by_name()</code></a>.
878
878
Instead of subclassing, it is often easier to use the generated
879
879
<span class="type">MyAppFrobberSkeleton</span> subclass. To handle incoming
880
method calls, use <code class="function"><a href="../gobject/gobject-Signals.html#g-signal-connect"><code class="function">g_signal_connect()</code></a></code> with
880
method calls, use <code class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Signals.html#g-signal-connect"><code class="function">g_signal_connect()</code></a></code> with
881
881
the <code class="function">::handle-*</code> signals and instead of
882
overriding <a href="../gobject/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>'s
882
overriding <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject"><span class="type">GObject</span></a>'s
883
883
<code class="function"><code class="function">get_property()</code></code> and
884
884
<code class="function"><code class="function">set_property()</code></code> vfuncs, use
885
<a href="../gobject/gobject-The-Base-Object-Type.html#g-object-get"><code class="function">g_object_get()</code></a> and
886
<a href="../gobject/gobject-The-Base-Object-Type.html#g-object-set"><code class="function">g_object_set()</code></a> or the generated property
885
<a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-get"><code class="function">g_object_get()</code></a> and
886
<a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-set"><code class="function">g_object_set()</code></a> or the generated property
887
887
getters and setters (the generated class has an internal
888
888
property bag implementation).
941
941
<span class="gtkdoc kwb">const</span> gchar <span class="gtkdoc opt">*</span>greeting<span class="gtkdoc opt">,</span>
942
942
gpointer user_data<span class="gtkdoc opt">)</span>
943
943
<span class="gtkdoc opt">{</span>
944
<span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function"><a href="../glib/glib-String-Utility-Functions.html#g-strcmp0">g_strcmp0</a></span> <span class="gtkdoc opt">(</span>greeting<span class="gtkdoc opt">,</span> <span class="string">"Boo"</span><span class="gtkdoc opt">) !=</span> <span class="number">0</span><span class="gtkdoc opt">)</span>
944
<span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-String-Utility-Functions.html#g-strcmp0">g_strcmp0</a></span> <span class="gtkdoc opt">(</span>greeting<span class="gtkdoc opt">,</span> <span class="string">"Boo"</span><span class="gtkdoc opt">) !=</span> <span class="number">0</span><span class="gtkdoc opt">)</span>
945
945
<span class="gtkdoc opt">{</span>
946
946
gchar <span class="gtkdoc opt">*</span>response<span class="gtkdoc opt">;</span>
947
response <span class="gtkdoc opt">=</span> <span class="function"><a href="../glib/glib-String-Utility-Functions.html#g-strdup-printf">g_strdup_printf</a></span> <span class="gtkdoc opt">(</span><span class="string">"Word! You said `%s'."</span><span class="gtkdoc opt">,</span> greeting<span class="gtkdoc opt">);</span>
947
response <span class="gtkdoc opt">=</span> <span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-String-Utility-Functions.html#g-strdup-printf">g_strdup_printf</a></span> <span class="gtkdoc opt">(</span><span class="string">"Word! You said `%s'."</span><span class="gtkdoc opt">,</span> greeting<span class="gtkdoc opt">);</span>
948
948
<span class="function">my_app_complete_hello_world</span> <span class="gtkdoc opt">(</span>interface<span class="gtkdoc opt">,</span> invocation<span class="gtkdoc opt">,</span> response<span class="gtkdoc opt">);</span>
949
<span class="function"><a href="../glib/glib-Memory-Allocation.html#g-free">g_free</a></span> <span class="gtkdoc opt">(</span>response<span class="gtkdoc opt">);</span>
949
<span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-Memory-Allocation.html#g-free">g_free</a></span> <span class="gtkdoc opt">(</span>response<span class="gtkdoc opt">);</span>
950
950
<span class="gtkdoc opt">}</span>
951
951
<span class="keyword">else</span>
952
952
<span class="gtkdoc opt">{</span>
964
964
interface <span class="gtkdoc opt">=</span> <span class="function">my_app_frobber_skeleton_new</span> <span class="gtkdoc opt">();</span>
965
965
<span class="function">my_app_frobber_set_verbose</span> <span class="gtkdoc opt">(</span>interface<span class="gtkdoc opt">,</span> TRUE<span class="gtkdoc opt">);</span>
967
<span class="function"><a href="../gobject/gobject-Signals.html#g-signal-connect">g_signal_connect</a></span> <span class="gtkdoc opt">(</span>interface<span class="gtkdoc opt">,</span>
967
<span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Signals.html#g-signal-connect">g_signal_connect</a></span> <span class="gtkdoc opt">(</span>interface<span class="gtkdoc opt">,</span>
968
968
<span class="string">"handle-hello-world"</span><span class="gtkdoc opt">,</span>
969
<span class="function"><a href="../gobject/gobject-Closures.html#G-CALLBACK:CAPS">G_CALLBACK</a></span> <span class="gtkdoc opt">(</span>on_handle_hello_world<span class="gtkdoc opt">),</span>
969
<span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Closures.html#G-CALLBACK:CAPS">G_CALLBACK</a></span> <span class="gtkdoc opt">(</span>on_handle_hello_world<span class="gtkdoc opt">),</span>
970
970
some_user_data<span class="gtkdoc opt">);</span>
972
972
<span class="gtkdoc opt">[...]</span>
988
988
To facilitate atomic changesets (multiple properties changing at
989
the same time), <a href="../gobject/gobject-The-Base-Object-Type.html#GObject-notify"><span class="type">“notify”</span></a> signals are queued up when
989
the same time), <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject-notify"><span class="type">“notify”</span></a> signals are queued up when
990
990
received. The queue is drained in an idle handler (which is called from the
991
<a href="../glib/glib-The-Main-Event-Loop.html#g-main-context-push-thread-default">thread-default main loop</a>
991
<a href="http://library.gnome.org/devel/glib/unstable/glib-The-Main-Event-Loop.html#g-main-context-push-thread-default">thread-default main loop</a>
992
992
of the thread where the skeleton object was
993
993
contructed) and will cause emissions of the <a class="ulink" href="http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-properties" target="_top">org.freedesktop.DBus.Properties::PropertiesChanged</a>
994
994
signal with all the properties that have changed. Use
995
995
<a class="link" href="GDBusInterfaceSkeleton.html#g-dbus-interface-skeleton-flush" title="g_dbus_interface_skeleton_flush ()"><code class="function">g_dbus_interface_skeleton_flush()</code></a> or
996
996
<a class="link" href="GDBusObjectSkeleton.html#g-dbus-object-skeleton-flush" title="g_dbus_object_skeleton_flush ()"><code class="function">g_dbus_object_skeleton_flush()</code></a> to empty the queue
997
immediately. Use <a href="../gobject/gobject-The-Base-Object-Type.html#g-object-freeze-notify"><code class="function">g_object_freeze_notify()</code></a> and
998
<a href="../gobject/gobject-The-Base-Object-Type.html#g-object-thaw-notify"><code class="function">g_object_thaw_notify()</code></a> for atomic changesets if on a different
997
immediately. Use <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-freeze-notify"><code class="function">g_object_freeze_notify()</code></a> and
998
<a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-thaw-notify"><code class="function">g_object_thaw_notify()</code></a> for atomic changesets if on a different
1008
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-BOOLEAN:CAPS">'b'</a>,
1009
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-BYTE:CAPS">'y'</a>,
1010
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-INT16:CAPS">'n'</a>,
1011
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-UINT16:CAPS">'q'</a>,
1012
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-INT32:CAPS">'i'</a>,
1013
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-UINT32:CAPS">'u'</a>,
1014
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-INT64:CAPS">'x'</a>,
1015
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-UINT64:CAPS">'t'</a> and
1016
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-DOUBLE:CAPS">'d'</a>)
1008
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-BOOLEAN:CAPS">'b'</a>,
1009
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-BYTE:CAPS">'y'</a>,
1010
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-INT16:CAPS">'n'</a>,
1011
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-UINT16:CAPS">'q'</a>,
1012
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-INT32:CAPS">'i'</a>,
1013
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-UINT32:CAPS">'u'</a>,
1014
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-INT64:CAPS">'x'</a>,
1015
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-UINT64:CAPS">'t'</a> and
1016
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-DOUBLE:CAPS">'d'</a>)
1018
1018
strings (type-strings
1019
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-STRING:CAPS">'s'</a>,
1020
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-BYTESTRING:CAPS">'ay'</a>,
1021
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-OBJECT-PATH:CAPS">'o'</a> and
1022
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-SIGNATURE:CAPS">'g'</a>) and
1019
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-STRING:CAPS">'s'</a>,
1020
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-BYTESTRING:CAPS">'ay'</a>,
1021
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-OBJECT-PATH:CAPS">'o'</a> and
1022
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-SIGNATURE:CAPS">'g'</a>) and
1023
1023
arrays of string (type-strings
1024
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-STRING-ARRAY:CAPS">'as'</a>,
1025
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-OBJECT-PATH-ARRAY:CAPS">'ao'</a> and
1026
<a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-BYTESTRING-ARRAY:CAPS">'aay'</a>)
1024
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-STRING-ARRAY:CAPS">'as'</a>,
1025
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-OBJECT-PATH-ARRAY:CAPS">'ao'</a> and
1026
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-BYTESTRING-ARRAY:CAPS">'aay'</a>)
1027
1027
are mapped to the natural types,
1028
e.g. <a href="../glib/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>, <a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a>, <a href="../glib/glib-Basic-Types.html#gint"><span class="type">gint</span></a>, <a href="../gobject/gobject-Standard-Parameter-and-Value-Types.html#gchararray">gchar*</a>,
1029
<a href="../gobject/gobject-Boxed-Types.html#GStrv">gchar**</a> and
1030
so on. Everything else is mapped to the <a href="../glib/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a>
1028
e.g. <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>, <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a>, <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gint"><span class="type">gint</span></a>, <a href="http://library.gnome.org/devel/gobject/unstable/gobject-Standard-Parameter-and-Value-Types.html#gchararray">gchar*</a>,
1029
<a href="http://library.gnome.org/devel/gobject/unstable/gobject-Boxed-Types.html#GStrv">gchar**</a> and
1030
so on. Everything else is mapped to the <a href="http://library.gnome.org/devel/glib/unstable/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a>
1034
1034
This automatic mapping can be turned off by using the annotation
1035
1035
<code class="literal">org.gtk.GDBus.C.ForceGVariant</code> - if used then a
1036
<a href="../glib/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> is always exchanged instead of the
1036
<a href="http://library.gnome.org/devel/glib/unstable/glib-GVariant.html#GVariant"><span class="type">GVariant</span></a> is always exchanged instead of the
1037
1037
corresponding native C type. This annotation may be convenient to
1039
bytestrings (type-string <a href="../glib/glib-GVariantType.html#G-VARIANT-TYPE-BYTESTRING:CAPS">'ay'</a>)
1039
bytestrings (type-string <a href="http://library.gnome.org/devel/glib/unstable/glib-GVariantType.html#G-VARIANT-TYPE-BYTESTRING:CAPS">'ay'</a>)
1040
1040
for data that could have embedded NUL bytes.
1050
1050
class structures will be preserved as well.
1053
The ABI of the generated <a href="../gobject/gobject-Type-Information.html#GType"><span class="type">GType</span></a>s will be preserved only if
1053
The ABI of the generated <a href="http://library.gnome.org/devel/gobject/unstable/gobject-Type-Information.html#GType"><span class="type">GType</span></a>s will be preserved only if
1054
1054
the <code class="literal">org.gtk.GDBus.Since</code> annotation is used
1055
judiciously — this is because the VTable for the <a href="/home/desrt/.cache/jhbuild/install/share/gtk-doc/html/gobject/GTypeModule.html"><span class="type">GInterface</span></a>
1055
judiciously — this is because the VTable for the <a href="http://library.gnome.org/devel/gobject/unstable/GTypeModule.html"><span class="type">GInterface</span></a>
1056
1056
relies on functions pointers for signal handlers. Specifically, if
1057
1057
a D-Bus method, property or signal or is added to a D-Bus
1058
interface, then ABI of the generated <a href="/home/desrt/.cache/jhbuild/install/share/gtk-doc/html/gobject/GTypeModule.html"><span class="type">GInterface</span></a> type is preserved
1058
interface, then ABI of the generated <a href="http://library.gnome.org/devel/gobject/unstable/GTypeModule.html"><span class="type">GInterface</span></a> type is preserved
1059
1059
if, and only if, each added method, property signal is annotated
1060
1060
with they <code class="literal">org.gtk.GDBus.Since</code> annotation using
1061
1061
a greater version number than previous versions.