summaryrefslogtreecommitdiffstats
path: root/src/monitor
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/monitor
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/monitor')
-rw-r--r--src/monitor/monitor_iface.xml30
-rw-r--r--src/monitor/monitor_iface_generated.c10
-rw-r--r--src/monitor/monitor_iface_generated.h10
3 files changed, 38 insertions, 12 deletions
diff --git a/src/monitor/monitor_iface.xml b/src/monitor/monitor_iface.xml
index 506b749c8..1f61de5b7 100644
--- a/src/monitor/monitor_iface.xml
+++ b/src/monitor/monitor_iface.xml
@@ -4,38 +4,48 @@
<interface name="org.freedesktop.sssd.monitor">
<annotation value="mon_srv_iface" name="org.freedesktop.DBus.GLib.CSymbol"/>
<method name="getVersion">
- <!-- manual argument parsing -->
+ <!-- manual argument parsing, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
<method name="RegisterService">
- <!-- manual argument parsing -->
+ <!-- manual argument parsing, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
</interface>
<interface name="org.freedesktop.sssd.service">
<annotation value="mon_cli_iface" name="org.freedesktop.DBus.GLib.CSymbol"/>
<method name="ping">
- <!-- no arguments -->
+ <!-- no arguments, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
<method name="resInit">
- <!-- no arguments -->
+ <!-- no arguments, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
<method name="shutDown">
- <!-- no arguments -->
+ <!-- no arguments, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
<method name="goOffline">
- <!-- no arguments -->
+ <!-- no arguments, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
<method name="resetOffline">
- <!-- no arguments -->
+ <!-- no arguments, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
<method name="rotateLogs">
- <!-- no arguments -->
+ <!-- no arguments, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
<method name="clearMemcache">
- <!-- no arguments -->
+ <!-- no arguments, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
<method name="clearEnumCache">
- <!-- no arguments -->
+ <!-- no arguments, raw handler -->
+ <annotation name="org.freedesktop.sssd.RawHandler" value="true"/>
</method>
</interface>
</node>
diff --git a/src/monitor/monitor_iface_generated.c b/src/monitor/monitor_iface_generated.c
index 81a7c247a..e9c3c1d52 100644
--- a/src/monitor/monitor_iface_generated.c
+++ b/src/monitor/monitor_iface_generated.c
@@ -12,12 +12,14 @@ const struct sbus_method_meta mon_srv_iface__methods[] = {
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_srv_iface, getVersion),
+ NULL, /* no invoker */
},
{
"RegisterService", /* name */
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_srv_iface, RegisterService),
+ NULL, /* no invoker */
},
{ NULL, }
};
@@ -37,48 +39,56 @@ const struct sbus_method_meta mon_cli_iface__methods[] = {
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_cli_iface, ping),
+ NULL, /* no invoker */
},
{
"resInit", /* name */
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_cli_iface, resInit),
+ NULL, /* no invoker */
},
{
"shutDown", /* name */
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_cli_iface, shutDown),
+ NULL, /* no invoker */
},
{
"goOffline", /* name */
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_cli_iface, goOffline),
+ NULL, /* no invoker */
},
{
"resetOffline", /* name */
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_cli_iface, resetOffline),
+ NULL, /* no invoker */
},
{
"rotateLogs", /* name */
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_cli_iface, rotateLogs),
+ NULL, /* no invoker */
},
{
"clearMemcache", /* name */
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_cli_iface, clearMemcache),
+ NULL, /* no invoker */
},
{
"clearEnumCache", /* name */
NULL, /* no in_args */
NULL, /* no out_args */
offsetof(struct mon_cli_iface, clearEnumCache),
+ NULL, /* no invoker */
},
{ NULL, }
};
diff --git a/src/monitor/monitor_iface_generated.h b/src/monitor/monitor_iface_generated.h
index bd556616c..37e4d480b 100644
--- a/src/monitor/monitor_iface_generated.h
+++ b/src/monitor/monitor_iface_generated.h
@@ -28,15 +28,21 @@
#define MON_CLI_IFACE_CLEARENUMCACHE "clearEnumCache"
/* ------------------------------------------------------------------------
- * 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.monitor */