7 This document describes application framework daemons
8 FCS (Fully Conform to Specification) implementation is still under development.
9 It may happen that current implementation somehow diverges with specifications.
13 Daemons ***afm-user-daemon*** and ***afm-system-daemon*** handle applications
15 Understand that they will manage operations like:
18 - ***uninstallation***
24 In addition, they ensure that operations use the security framework as needed
25 and that applications are executed in the correct context.
27 ***D-Bus*** is in charge of transmitting orders to the appropriate daemon
28 depending upon ***D-Bus*** destination.
30 The figure below summarizes the situation of both **afm-system-daemon** and
31 **afm-user-daemon** in the system.
33 ![afm-daemons][afm-daemons]
35 ## The D-Bus interface
37 ### Overview of the dbus interface
39 The ***afm daemons*** takes theirs orders from the session instance
41 The use of D-Bus is great because it allows to implement
42 discovery and signaling.
44 The dbus session is by default addressed by environment
45 variable *DBUS_SESSION_BUS_ADDRESS*. Using **systemd**
46 variable *DBUS_SESSION_BUS_ADDRESS* is automatically set for
49 They are listening with the destination name ***org.AGL.afm.[user|system]***
50 at the object of path ***/org/AGL/afm/[user|system]*** on the interface
51 ***org.AGL.afm.[user|system]*** for the below detailed members for the
52 ***afm-system-daemon***:
57 And for ***afm-user-daemon***:
71 D-Bus is mainly used for signaling and discovery.
72 Its optimized typed protocol is not used except for transmitting
73 only one string in both directions.
75 The client and the service are using JSON serialization to
77 Signature of any member of the D-Bus interface is
78 ***string -> string*** for ***JSON -> JSON***.
79 This is the normal case, if there is an error, current implementation
80 returns a dbus error that is a string.
82 Here are examples using *dbus-send*, here to install an application from a
86 dbus-send --session --print-reply \
87 --dest=org.AGL.afm.system \
89 org.AGL.afm.system.install 'string:"/tmp/appli.wgt"
92 And here, to query data on installed applications that can be run:
95 dbus-send --session --print-reply \
96 --dest=org.AGL.afm.user \
98 org.AGL.afm.user.runnables string:true
101 ### The protocol over D-Bus
103 On all following sub-chapters we assume that we talk about either
104 ***afm-system-daemon*** or ***afm-user-daemon***. Method and D-Bus parameters
105 are considered as self-explanatory.
107 The D-Bus interface is defined by:
109 - **DESTINATION**: org.AGL.afm.[user|system]
110 - **PATH**: /org/AGL/afm/[user|system]
111 - **INTERFACE**: org.AGL.afm.[user|system]
113 #### Method org.AGL.afm.system.install
115 **Description**: Install an application from a widget file.
117 When an application with the same *id* and *version* already exists. Outside of
118 using *force=true* the application is not reinstalled.
120 Applications are installed the subdirectories of applications common directory.
121 If *root* is specified, the application is installed under the
122 sub-directories of the *root* defined.
124 Note that this methods is a simple accessor method of
125 ***org.AGL.afm.system.install*** from ***afm-system-daemon***.
127 After the installation and before returning to the sender,
128 ***afm-system-daemon*** sends a signal ***org.AGL.afm.system.changed***.
130 **Input**: The *path* of the widget file to install and, optionally,
131 a flag to *force* reinstallation, and, optionally, a *root* directory.
133 Either just a string being the absolute path of the widget file:
136 "/a/path/driving/to/the/widget"
143 "wgt": "/a/path/to/the/widget",
145 "root": "/a/path/to/the/root"
149 "wgt" and "root" must be absolute paths.
151 **output**: An object with the field "added" being the string for
152 the id of the added application.
155 {"added":"appli@x.y"}
160 #### Method org.AGL.afm.system.uninstall
162 **Description**: Uninstall an application from its id.
164 Note that this methods is a simple method accessor of
165 ***org.AGL.afm.system.uninstall*** from ***afm-system-daemon***.
167 After the uninstallation and before returning to the sender,
168 ***afm-system-daemon*** sends a signal ***org.AGL.afm.system.changed***.
170 **Input**: the *id* of the application and optionally the application *root* path.
183 "root": "/a/path/to/the/root"
187 **output**: the value 'true'.
191 #### Method org.AGL.afm.user.detail
193 **Description**: Get details about an application from its id.
195 **Input**: the id of the application as below.
197 Either just a string:
203 Or an object having the field "id" of type string:
209 **Output**: A JSON object describing the application containing
210 the fields described below.
214 "id": string, the application id (id@version)
215 "version": string, the version of the application
216 "width": integer, requested width of the application
217 "height": integer, requested height of the application
218 "name": string, the name of the application
219 "description": string, the description of the application
220 "shortname": string, the short name of the application
221 "author": string, the author of the application
227 #### Method org.AGL.afm.user.runnables
229 **Description**: Get the list of applications that can be run.
231 **Input**: any valid json entry, can be anything except null.
233 **output**: An array of description of the runnable applications.
234 Each item of the array contains an object containing the detail of
235 an application as described above for the method
236 *org.AGL.afm.user.detail*.
240 #### Method org.AGL.afm.user.install
242 **Description**: Install an application from its widget file.
244 If an application of the same *id* and *version* exists, it is not
245 reinstalled except when *force=true*.
247 Applications are installed in the subdirectories of the common directory
248 reserved for applications.
249 If *root* is specified, the application is installed under
250 sub-directories of defined *root*.
252 Note that this methods is a simple accessor to the method
253 ***org.AGL.afm.system.install*** of ***afm-system-daemon***.
255 After the installation and before returning to the sender,
256 ***afm-user-daemon*** sends the signal ***org.AGL.afm.user.changed***.
258 **Input**: The *path* of widget file to be installed. Optionally,
259 a flag to *force* reinstallation and/or a *root* directory.
261 Simple form a simple string containing the absolute widget path:
264 "/a/path/driving/to/the/widget"
271 "wgt": "/a/path/to/the/widget",
273 "root": "/a/path/to/the/root"
277 ***wgt*** and ***root*** MUST be absolute paths.
279 **output**: An object containing field "added" to use as application ID.
282 {"added":"appli@x.y"}
287 #### Method org.AGL.afm.user.uninstall
289 **Description**: Uninstall an application from its id.
291 Note that this methods is a simple accessor to
292 ***org.AGL.afm.system.uninstall*** method from ***afm-system-daemon***.
294 After the uninstallation and before returning to the sender,
295 ***afm-user-daemon*** sends the signal ***org.AGL.afm.user.changed***.
297 **Input**: the *id* of the application and, optionally, the path to
311 "root": "/a/path/to/the/root"
315 **output**: the value 'true'.
319 #### Method org.AGL.afm.user.start
323 **Input**: the *id* of the application and, optionally, the
324 start *mode* as below.
326 Either just a string:
332 Or an object containing field "id" of type string and
333 optionally a field mode:
336 {"id":"appli@x.y","mode":"local"}
339 The field "mode" is a string equal to either "local" or "remote".
341 [Currently the mode is not available in the systemd version]
343 **output**: The *runid* of the application launched. *runid* is an integer.
347 #### Method org.AGL.afm.user.once
351 **Input**: the *id* of the application
353 Either just a string:
359 Or an object containing field "id" of type string.
365 **output**: The *state* of the application retrieved or launched.
366 See *org.AGL.afm.user.state* to get a description of the returned
371 #### Method org.AGL.afm.user.terminate
373 **Description**: Terminates the application attached to *runid*.
375 **Input**: The *runid* (an integer) of running instance to terminate.
377 **output**: the value 'true'.
381 #### Method org.AGL.afm.user.stop
383 Obsolete since 8th November 2016 (2016/11/08).
384 Kept for compatibility.
386 Use **org.AGL.afm.user.pause** instead.
390 #### Method org.AGL.afm.user.continue
392 Obsolete since 8th November 2016 (2016/11/08).
393 Kept for compatibility.
395 Use **org.AGL.afm.user.resume** instead.
399 #### Method org.AGL.afm.user.pause
401 [Currently not available in the systemd version]
403 **Description**: Pauses the application attached to *runid* until terminate or resume.
405 **Input**: The *runid* (integer) of the running instance to pause.
407 **output**: the value 'true'.
411 #### Method org.AGL.afm.user.resume
413 [Currently not available in the systemd version]
415 **Description**: Resumes the application attached to *runid* previously paused.
417 **Input**: The *runid* (integer) of the running instance to resume.
419 **output**: the value 'true'.
423 #### Method org.AGL.afm.user.state
425 **Description**: Get information about a running instance of *runid*.
427 **Input**: The *runid* (integer) of the running instance inspected.
429 **output**: An object describing instance state.
432 - the runid (integer)
433 - the pids of the processes as an array starting
434 - with the group leader
435 - the id of the running application (string)
436 - the state of the application (string either: "starting", "running", "paused").
438 Example of returned state:
443 "pids": [ 435, 436 ],
451 #### Method org.AGL.afm.user.runners
453 **Description**: Get the list of currently running instances.
457 **output**: An array of states, one per running instance, as returned by
458 the method ***org.AGL.afm.user.state***.
460 ## Starting **afm daemons**
462 ***afm-system-daemon*** and ***afm-user-daemon*** are launched as systemd
463 services attached to system and user respectively.
464 Normally, service files are locatedat */lib/systemd/system/afm-system-daemon.service* and
465 */usr/lib/systemd/user/afm-user-daemon.service*.
467 ### ***afm-system-daemon*** options
469 The options for launching **afm-system-daemon** are:
475 Set the root application directory.
477 Note that the default root directory is defined
478 to be /usr/share/afm/applications (may change).
483 Daemonizes the process. It is not needed by systemd.
488 Reduces the verbosity (can be repeated).
493 Increases the verbosity (can be repeated).
501 ### ***afm-user-daemon*** options
503 The options for launching **afm-user-daemon** are:
507 --application directory
509 [Currently not available in the systemd version]
511 Includes the given application directory to
512 the database base of applications.
519 [Currently not available in the systemd version]
521 Includes root application directory or directories when
522 passing multiple rootdir to
523 applications database.
525 Note that default root directory for
526 applications is always added. In current version
527 /usr/share/afm/applications is used as default.
530 --mode (local|remote)
532 [Currently not available in the systemd version]
534 Set the default launch mode.
535 The default value is 'local'
540 Daemonizes the process. It is not needed by systemd.
545 Reduces the verbosity (can be repeated).
550 Increases the verbosity (can be repeated).
558 ## Tasks of **afm-user-daemon**
560 ### Maintaining list of applications
562 At start **afm-user-daemon** scans the directories containing
563 applications and load in memory a list of available applications
564 accessible by current user.
566 When **afm-system-daemon** installs or removes an application.
567 On success it sends the signal *org.AGL.afm.system.changed*.
568 When receiving such a signal, **afm-user-daemon** rebuilds its
571 **afm-user-daemon** provides the data it collects about
572 applications to its clients.
573 Clients may either request the full list
574 of available applications or a more specific information about a
577 ### Launching application
579 **afm-user-daemon** launches application by using systemd.
580 Systemd builds a secure environment for the application
583 Once launched, running instances of application receive
584 a runid that identify them.
585 To make interface with systemd evident, the pid is the runid.
587 ### Managing instances of running applications
589 **afm-user-daemon** manages the list of applications
592 When owning the right permissions, a client can get the list
593 of running instances and details about a specific
595 It can also terminate a given application.
597 ### Installing and uninstalling applications
599 If the client own the right permissions,
600 **afm-user-daemon** delegates that task
601 to **afm-system-daemon**.
603 ## Using ***afm-util***
605 The command line tool ***afm-util*** uses dbus-send to send
606 orders to **afm-user-daemon**.
607 This small scripts allows to send command to ***afm-user-daemon*** either
608 interactively at shell prompt or scriptically.
610 The syntax is simple:
612 - it accept a command and when requires attached arguments.
614 Here is the summary of ***afm-util***:
616 - **afm-util runnables **:
617 list the runnable widgets installed
619 - **afm-util install wgt **:
622 - **afm-util uninstall id **:
623 remove the installed widget of id
625 - **afm-util detail id **:
626 print detail about the installed widget of id
628 - **afm-util runners **:
629 list the running instance
631 - **afm-util start id **:
632 start an instance of the widget of id
634 - **afm-util once id **:
635 run once an instance of the widget of id
637 - **afm-util terminate rid **:
638 terminate the running instance rid
640 - **afm-util state rid **:
641 get status of the running instance rid
643 Here is how to list applications using ***afm-util***:
649 [afm-daemons]: images/afm-daemons.svg