<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<pre>I am beginning to use the sd-bus library. I have been able to get a couple of properties, MainPID and SubState.</pre>
<pre>I would like to use the Stop method. I am using cups as an example. This commands shows that in thee Unit interface there is a Start and Stop method:
</pre>
<pre>$ busctl introspect org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/cups_2eservice</pre>
<pre>NAME TYPE SIGNATURE RESULT/VALUE FLAGS
</pre>
<pre>org.freedesktop.systemd1.Unit interface - - -
</pre>
<pre>.Start method s o -
.Stop method s o -
</pre>
<pre>Each has a signature of "s" I assume it takes one parameter of type string.</pre>
<pre>I have tried the sample on this page. Pasting it into a file and compiling and running it works
great.
</pre>
<pre><a class="moz-txt-link-freetext" href="https://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html">https://0pointer.net/blog/the-new-sd-bus-api-of-systemd.html</a></pre>
<pre>This sample starts the cups service by acccessing the systemd Manager and calling StartUnit.</pre>
<pre><code><span class="w"></span><span class="cm"> /* Issue the method call and store the respons message in m */</span>
<span class="w"> </span><span class="n">r</span><span class="w"> </span><span
class="o">=</span><span class="w"> </span><span class="n">sd_bus_call_method</span><span
class="p">(</span><span class="n">bus</span><span class="p">,</span>
<span class="w"> </span><span class="s">"org.freedesktop.systemd1"</span><span
class="p">,</span><span class="w"> </span><span class="cm">/* service to contact */</span>
<span class="w"> </span><span class="s">"/org/freedesktop/systemd1"</span><span
class="p">,</span><span class="w"> </span><span class="cm">/* object path */</span>
<span class="w"> </span><span class="s">"org.freedesktop.systemd1.Manager"</span><span
class="p">,</span><span class="w"> </span><span class="cm">/* interface name */</span>
<span class="w"> </span><span class="s">"StartUnit"</span><span
class="p">,</span><span class="w"> </span><span
class="cm">/* method name */</span>
<span class="w"> </span><span class="o">&</span><span
class="n">error</span><span class="p">,</span><span class="w"> </span><span
class="cm">/* object to return error in */</span>
<span class="w"> </span><span class="o">&</span><span
class="n">m</span><span class="p">,</span><span class="w"> </span><span
class="cm">/* return message on success */</span>
<span class="w"> </span><span class="s">"ss"</span><span
class="p">,</span><span class="w"> </span><span
class="cm">/* input signature */</span>
<span class="w"> </span><span class="s">"cups.service"</span><span
class="p">,</span><span class="w"> </span><span
class="cm">/* first argument */</span>
<span class="w"> </span><span class="s">"replace"</span><span
class="p">);</span><span class="w"> </span><span
class="cm">/* second argument */
It has a signature of "ss" which I assume means the method takes 2 arguments each of a type string.
My question is for any given method how do I get what the arguments for it are ?
Like if I use Start what are valid values to pass for the one argument?
In StartUnit the first argument seems obvious with an example to be the unit you want to start. I
am not sure what the "replace" means or what other strings would be valid.
Again I am interested in the Stop method specifically, but in general would like to know where I can
get a list of the arguments and possible values for any method.
Thanks
Chris
</span></code></pre>
<p></p>
</body>
</html>