doc: more documentation
[src/app-framework-main.git] / doc / afm-system-daemon.html
1 <html>
2 <head>
3   <link rel="stylesheet" type="text/css" href="doc.css">
4   <meta charset="UTF-8">
5 </head>
6 <body>
7 <a name="The.afm-system-daemon"></a>
8 <h1>The afm-system-daemon</h1>
9
10 <pre><code>version: 1
11 Date:    15 March 2016
12 Author:  José Bollo
13 </code></pre>
14
15 <a name="Foreword"></a>
16 <h2>Foreword</h2>
17
18 <p>This document describes what we intend to do. It may happen that our
19 current implementation and the content of this document differ.</p>
20
21 <p>In case of differences, it is assumed that this document is right
22 and the implementation is wrong.</p>
23
24 <a name="Introduction"></a>
25 <h2>Introduction</h2>
26
27 <p>The daemon <strong>afm-system-daemon</strong> is in charge of installing
28 applications on the system. Its main tasks are:</p>
29
30 <ul>
31 <li><p>installs the applications and setup the security framework
32 to include it</p></li>
33 <li><p>uninstall the applications</p></li>
34 </ul>
35
36
37 <p>The <strong>afm-system-daemon</strong> takes its orders from the system
38 instance of D-Bus.</p>
39
40 <p>The figure below summarizes the situation of the
41 <strong>afm-system-daemon</strong> in the system.</p>
42
43 <pre><code>+------------------------------------------------------------+
44 |                          User                              |
45 |                                                            |
46 |     +-------------------------------------------------+    |
47 |     |                                                 |    |
48 |     |                  afm-user-daemon                |    |
49 |     |                                                 |    |
50 |     +----------+----------------------+----------+----+    |
51 |                |                      |          :         |
52 |                |                      |          :         |
53 :================|======================|==========:=========:
54 |                |                      |          :         |
55 |     +----------+----------+     +-----+-----+    :         |
56 |     |   D-Bus   system    +-----+  CYNARA   |    :         |
57 |     +----------+----------+     +-----+-----+    :         |
58 |                |                      |          :         |
59 |     +----------+---------+    +-------+----------+----+    |
60 |     | afm-system-daemon  +----+   SECURITY-MANAGER    |    |
61 |     +--------------------+    +-----------------------+    |
62 |                                                            |
63 |                          System                            |
64 +------------------------------------------------------------+
65 </code></pre>
66
67 <a name="Starting..strong.afm-system-daemon..strong."></a>
68 <h2>Starting <strong>afm-system-daemon</strong></h2>
69
70 <p><strong>afm-system-daemon</strong> is launched as a <strong>systemd</strong> service
71 attached to system. Normally, the service file is
72 located at /lib/systemd/system/afm-system-daemon.service.</p>
73
74 <p>The options for launching <strong>afm-system-daemon</strong> are:</p>
75
76 <pre><code>-r
77 --root directory
78
79      Set the root application directory.
80
81      Note that the default root directory is defined
82      to be /usr/share/afm/applications (may change).
83
84 -d
85 --daemon
86
87      Daemonizes the process. It is not needed by sytemd.
88
89 -q
90 --quiet
91
92      Reduces the verbosity (can be repeated).
93
94 -v
95 --verbose
96
97      Increases the verbosity (can be repeated).
98
99 -h
100 --help
101
102      Prints a short help.
103 </code></pre>
104
105 <a name="The.D-Bus.interface"></a>
106 <h2>The D-Bus interface</h2>
107
108 <a name="Overview.of.the.dbus.interface"></a>
109 <h3>Overview of the dbus interface</h3>
110
111 <p><strong><em>afm-system-daemon</em></strong> takes its orders from the session instance
112 of D-Bus. The use of D-Bus is great because it allows to implement
113 discovery and signaling.</p>
114
115 <p>The <strong>afm-system-daemon</strong> is listening with the destination name
116 <strong><em>org.AGL.afm.system</em></strong> at the object of path <strong><em>/org/AGL/afm/system</em></strong>
117 on the interface <strong><em>org.AGL.afm.system</em></strong> for the below detailed
118 members <strong><em>install</em></strong> and <strong><em>uninstall</em></strong>.</p>
119
120 <p>D-Bus is mainly used for signaling and discovery. Its optimized
121 typed protocol is not used except for transmitting only one string
122 in both directions.</p>
123
124 <p>The client and the service are using JSON serialisation to
125 exchange data.</p>
126
127 <p>The D-Bus interface is defined by:</p>
128
129 <ul>
130 <li><p>DESTINATION: <strong>org.AGL.afm.system</strong></p></li>
131 <li><p>PATH: <strong>/org/AGL/afm/system</strong></p></li>
132 <li><p>INTERFACE: <strong>org.AGL.afm.system</strong></p></li>
133 </ul>
134
135
136 <p>The signature of any member of the interface is <strong><em>string -> string</em></strong>
137 for <strong><em>JSON -> JSON</em></strong>.</p>
138
139 <p>This is the normal case. In case of error, the current implmentation
140 returns a dbus error that is a string.</p>
141
142 <p>Here is an example that use <em>dbus-send</em> to query data on
143 installed applications.</p>
144
145 <pre><code>dbus-send --session --print-reply \
146     --dest=org.AGL.afm.system \
147     /org/AGL/afm/system \
148     org.AGL.afm.system.install 'string:"/tmp/appli.wgt"'
149 </code></pre>
150
151 <a name="The.protocol.over.D-Bus"></a>
152 <h3>The protocol over D-Bus</h3>
153
154 <hr />
155
156 <a name="Method.org.AGL.afm.system.install"></a>
157 <h4>Method org.AGL.afm.system.install</h4>
158
159 <p><strong>Description</strong>: Install an application from its widget file.</p>
160
161 <p>If an application of the same <em>id</em> and <em>version</em> exists, it is not
162 reinstalled except if <em>force=true</em>.</p>
163
164 <p>Applications are installed in the subdirectories of the common directory
165 of applications.
166 If <em>root</em> is specified, the application is installed under the
167 sub-directories of the <em>root</em> defined.</p>
168
169 <p>Note that this methods is a simple accessor to the method
170 <strong><em>org.AGL.afm.system.install</em></strong> of <strong><em>afm-system-daemon</em></strong>.</p>
171
172 <p>After the installation and before returning to the sender,
173 <strong><em>afm-system-daemon</em></strong> sends the signal <strong><em>org.AGL.afm.system.changed</em></strong>.</p>
174
175 <p><strong>Input</strong>: The <em>path</em> of the widget file to install and, optionaly,
176 a flag to <em>force</em> reinstallation, and, optionaly, a <em>root</em> directory.</p>
177
178 <p>Either just a string being the absolute path of the widget file:</p>
179
180 <pre><code>"/a/path/driving/to/the/widget"
181 </code></pre>
182
183 <p>Or an object:</p>
184
185 <pre><code>{
186   "wgt": "/a/path/to/the/widget",
187   "force": false,
188   "root": "/a/path/to/the/root"
189 }
190 </code></pre>
191
192 <p>&ldquo;wgt&rdquo; and &ldquo;root&rdquo; must be absolute paths.</p>
193
194 <p><strong>output</strong>: An object with the field &ldquo;added&rdquo; being the string for
195 the id of the added application.</p>
196
197 <pre><code>{"added":"appli@x.y"}
198 </code></pre>
199
200 <hr />
201
202 <a name="Method.org.AGL.afm.system.uninstall"></a>
203 <h4>Method org.AGL.afm.system.uninstall</h4>
204
205 <p><strong>Description</strong>: Uninstall an application from its id.</p>
206
207 <p>Note that this methods is a simple accessor to the method
208 <strong><em>org.AGL.afm.system.uninstall</em></strong> of <strong><em>afm-system-daemon</em></strong>.</p>
209
210 <p>After the uninstallation and before returning to the sender,
211 <strong><em>afm-system-daemon</em></strong> sends the signal <strong><em>org.AGL.afm.system.changed</em></strong>.</p>
212
213 <p><strong>Input</strong>: the <em>id</em> of the application and, otpionaly, the path to
214 <em>root</em> of the application.</p>
215
216 <p>Either a string:</p>
217
218 <pre><code>"appli@x.y"
219 </code></pre>
220
221 <p>Or an object:</p>
222
223 <pre><code>{
224   "id": "appli@x.y",
225   "root": "/a/path/to/the/root"
226 }
227 </code></pre>
228
229 <p><strong>output</strong>: the value &lsquo;true&rsquo;.</p>
230 </body>
231 </html>