summaryrefslogtreecommitdiffstats
path: root/src/responder
diff options
context:
space:
mode:
authorStef Walter <stefw@redhat.com>2014-02-25 10:29:23 +0100
committerJakub Hrozek <jhrozek@redhat.com>2014-04-19 10:32:50 +0200
commitdff909d473f43a6bd0f0286fa2d279c0ebe945c6 (patch)
tree61b2f3e2c33e28b51a8ffed64a73de364093557a /src/responder
parent7a9a6ee1b5f5479c3a6958401f9b34c571c3b6bf (diff)
downloadsssd-dff909d473f43a6bd0f0286fa2d279c0ebe945c6.tar.gz
sssd-dff909d473f43a6bd0f0286fa2d279c0ebe945c6.tar.xz
sssd-dff909d473f43a6bd0f0286fa2d279c0ebe945c6.zip
sbus: Add type-safe DBus method handlers and finish functions
Type safe method handlers allow methods not to have to do tedious unwrapping and wrapping of DBus method call messages or replies. Arguments of the following DBus types are supported in type-safe method handlers. In addition arrays of these are supported. y: uint8_t b: bool (but no arrays, yet) n: int16_t q: uint16_t i: int32_t u: uint32_t x: int64_t t: uint64_t d: double s: char * (utf8 string) o: char * (object path) As an exception, arrays of booleans are not supported, but could be added later. Other more complex types could be added later if desired. If a method has other argument types, then it must be marked as having a raw handler (see below). Internally each method can have a type specific invoker function which unpacks the incoming arguments and invokes the method handler with the correct arguments. Each method also has a finish which accepts the type-safe out arguments (ie: return values) and builds the reply message. Like other request 'finish' functions, these free the request talloc context, and are to be used in place of sbus_request_finish() or friends. Raw method handlers parse their own method arguments, and prepare their own reply (ideally using sbus_request_finish() helpers). They can also do strange things like have variable arguments. To mark a DBus method as having a raw method handler use the following annotation: <annotation name="org.freedesktop.sssd.RawHandler" value="true"/> Raw methods do not have invokers or finish functions. I've left all of the internal peer to peer communication using raw method handlers. No code changes here.
Diffstat (limited to 'src/responder')
-rw-r--r--src/responder/ifp/ifp_iface.xml3
-rw-r--r--src/responder/ifp/ifp_iface_generated.c1
-rw-r--r--src/responder/ifp/ifp_iface_generated.h10
3 files changed, 11 insertions, 3 deletions
diff --git a/src/responder/ifp/ifp_iface.xml b/src/responder/ifp/ifp_iface.xml
index e3221b577..078d29e2d 100644
--- a/src/responder/ifp/ifp_iface.xml
+++ b/src/responder/ifp/ifp_iface.xml
@@ -4,7 +4,8 @@
<interface name="org.freedesktop.sssd.infopipe">
<annotation value="infopipe_iface" name="org.freedesktop.DBus.GLib.CSymbol"/>
<method name="Ping">
- <!-- arguments parsed manually -->
+ <!-- manual argument parsing, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
</interface>
</node>
diff --git a/src/responder/ifp/ifp_iface_generated.c b/src/responder/ifp/ifp_iface_generated.c
index db5e0e545..57c67f8bc 100644
--- a/src/responder/ifp/ifp_iface_generated.c
+++ b/src/responder/ifp/ifp_iface_generated.c
@@ -12,6 +12,7 @@ const struct sbus_method_meta infopipe_iface__methods[] = {
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct infopipe_iface, Ping),
+ NULL, /* no invoker */
},
{ NULL, }
};
diff --git a/src/responder/ifp/ifp_iface_generated.h b/src/responder/ifp/ifp_iface_generated.h
index 8db83fc11..f69fb162d 100644
--- a/src/responder/ifp/ifp_iface_generated.h
+++ b/src/responder/ifp/ifp_iface_generated.h
@@ -16,15 +16,21 @@
#define INFOPIPE_IFACE_PING "Ping"
/* ------------------------------------------------------------------------
- * DBus Vtable handler structures
+ * DBus handlers
*
* These structures are filled in by implementors of the different
* dbus interfaces to handle method calls.
*
* Handler functions of type sbus_msg_handler_fn accept raw messages,
- * other handlers will be typed appropriately. If a handler that is
+ * other handlers are typed appropriately. If a handler that is
* set to NULL is invoked it will result in a
* org.freedesktop.DBus.Error.NotSupported error for the caller.
+ *
+ * Handlers have a matching xxx_finish() function (unless the method has
+ * accepts raw messages). These finish functions the
+ * sbus_request_return_and_finish() with the appropriate arguments to
+ * construct a valid reply. Once a finish function has been called, the
+ * @dbus_req it was called with is freed and no longer valid.
*/
/* vtable for org.freedesktop.sssd.infopipe */