add documentation & ideas about config.xml
[src/app-framework-main.git] / doc / widgets.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta charset="utf-8">
5   <meta name="generator" content="pandoc">
6   <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
7   <meta name="author" content="José Bollo">
8   <meta name="author" content="Fulup Ar Foll">
9   <title>The widgets</title>
10   <style type="text/css">code{white-space: pre;}</style>
11   <style type="text/css">
12 div.sourceCode { overflow-x: auto; }
13 table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
14   margin: 0; padding: 0; vertical-align: baseline; border: none; }
15 table.sourceCode { width: 100%; line-height: 100%; }
16 td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
17 td.sourceCode { padding-left: 5px; }
18 code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
19 code > span.dt { color: #902000; } /* DataType */
20 code > span.dv { color: #40a070; } /* DecVal */
21 code > span.bn { color: #40a070; } /* BaseN */
22 code > span.fl { color: #40a070; } /* Float */
23 code > span.ch { color: #4070a0; } /* Char */
24 code > span.st { color: #4070a0; } /* String */
25 code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
26 code > span.ot { color: #007020; } /* Other */
27 code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
28 code > span.fu { color: #06287e; } /* Function */
29 code > span.er { color: #ff0000; font-weight: bold; } /* Error */
30 code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
31 code > span.cn { color: #880000; } /* Constant */
32 code > span.sc { color: #4070a0; } /* SpecialChar */
33 code > span.vs { color: #4070a0; } /* VerbatimString */
34 code > span.ss { color: #bb6688; } /* SpecialString */
35 code > span.im { } /* Import */
36 code > span.va { color: #19177c; } /* Variable */
37 code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
38 code > span.op { color: #666666; } /* Operator */
39 code > span.bu { } /* BuiltIn */
40 code > span.ex { } /* Extension */
41 code > span.pp { color: #bc7a00; } /* Preprocessor */
42 code > span.at { color: #7d9029; } /* Attribute */
43 code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
44 code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
45 code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
46 code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
47   </style>
48   <link rel="stylesheet" href="doc.css">
49   <!--[if lt IE 9]>
50     <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
51   <![endif]-->
52 </head>
53 <body>
54 <header>
55 <h1 class="title">The widgets</h1>
56 <h2 class="author">José Bollo</h2>
57 <h2 class="author">Fulup Ar Foll</h2>
58 <h3 class="date">24 juin 2016</h3>
59 </header>
60 <nav id="TOC">
61 <ul>
62 <li><a href="#the-widgets">The widgets</a><ul>
63 <li><a href="#the-widgets-1">The widgets</a><ul>
64 <li><a href="#the-configuration-file-config.xml">The configuration file config.xml</a></li>
65 <li><a href="#tools-for-managing-widgets">Tools for managing widgets</a></li>
66 <li><a href="#signing-a-widget">Signing a widget</a></li>
67 <li><a href="#packing-a-widget">Packing a widget</a></li>
68 <li><a href="#getting-data-about-a-widget-file">Getting data about a widget file</a></li>
69 </ul></li>
70 <li><a href="#writing-a-widget">Writing a widget</a><ul>
71 <li><a href="#what-kind-of-application">What kind of application?</a></li>
72 <li><a href="#the-steps-for-writing-a-widget">The steps for writing a widget</a></li>
73 </ul></li>
74 <li><a href="#organization-of-directory-of-applications">Organization of directory of applications</a><ul>
75 <li><a href="#directory-where-are-stored-applications">directory where are stored applications</a></li>
76 <li><a href="#identity-of-installed-files">Identity of installed files</a></li>
77 <li><a href="#labeling-the-directories-of-applications">labeling the directories of applications</a></li>
78 </ul></li>
79 </ul></li>
80 </ul>
81 </nav>
82 <h1 id="the-widgets">The widgets</h1>
83 <h2 id="the-widgets-1">The widgets</h2>
84 <p>The widgets are described by the technical recommendations <a href="http://www.w3.org/TR/widgets" title="Packaged Web Apps">widgets</a> and <a href="http://www.w3.org/TR/widgets-digsig" title="XML Digital Signatures for Widgets">widgets-digsig</a>.</p>
85 <p>In summary, <strong>widgets are ZIP files that can be signed and whose content is described by the file <config.xml></strong>.</p>
86 <h3 id="the-configuration-file-config.xml">The configuration file config.xml</h3>
87 <p>This is one of the important file of the widget. It fully describes the widget.</p>
88 <p>Here is the example of the config file for the QML application SmartHome.</p>
89 <div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml"><span class="kw">&lt;?xml</span> version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;<span class="kw">?&gt;</span>
90 <span class="kw">&lt;widget</span><span class="ot"> xmlns=</span><span class="st">&quot;http://www.w3.org/ns/widgets&quot;</span><span class="ot"> id=</span><span class="st">&quot;smarthome&quot;</span><span class="ot"> version=</span><span class="st">&quot;0.1&quot;</span><span class="kw">&gt;</span>
91   <span class="kw">&lt;name&gt;</span>SmartHome<span class="kw">&lt;/name&gt;</span>
92   <span class="kw">&lt;icon</span><span class="ot"> src=</span><span class="st">&quot;smarthome.png&quot;</span><span class="kw">/&gt;</span>
93   <span class="kw">&lt;content</span><span class="ot"> src=</span><span class="st">&quot;qml/smarthome/smarthome.qml&quot;</span><span class="ot"> type=</span><span class="st">&quot;text/vnd.qt.qml&quot;</span><span class="kw">/&gt;</span>
94   <span class="kw">&lt;description&gt;</span>This is the Smarthome QML demo application. It shows some user interfaces for controlling an 
95 automated house. The user interface is completely done with QML.<span class="kw">&lt;/description&gt;</span>
96   <span class="kw">&lt;author&gt;</span>Qt team<span class="kw">&lt;/author&gt;</span>
97   <span class="kw">&lt;license&gt;</span>GPL<span class="kw">&lt;/license&gt;</span>
98 <span class="kw">&lt;/widget&gt;</span></code></pre></div>
99 <p>The most important items are:</p>
100 <ul>
101 <li><p><strong>&lt;widget id=&quot;......&quot;&gt;</strong>: gives the id of the widget. It must be unique.</p></li>
102 <li><p><strong>&lt;widget version=&quot;......&quot;&gt;</strong>: gives the version of the widget</p></li>
103 <li><p><strong>&lt;icon src=&quot;...&quot;&gt;</strong>: gives a path to the icon of the application (can be repeated with different sizes)</p></li>
104 <li><p><strong>&lt;content src=&quot;...&quot; type=&quot;...&quot;&gt;</strong>: this indicates the entry point and its type. The types handled are set through the file /etc/afm/afm-launch.conf</p></li>
105 </ul>
106 <p>Further development will add handling of <feature> for requiring and providing permissions and services.</p>
107 <h3 id="tools-for-managing-widgets">Tools for managing widgets</h3>
108 <p>This project includes tools for managing widgets. These tools are:</p>
109 <ul>
110 <li><p><strong><em>wgtpkg-info</em></strong>: command line tool to display informations about a widget file.</p></li>
111 <li><p><strong><em>wgtpkg-installer</em></strong>: command line tool to install a widget file.</p></li>
112 <li><p><strong><em>wgtpkg-pack</em></strong>: command line tool to create a widget file from a widget directory.</p></li>
113 <li><p><strong><em>wgtpkg-sign</em></strong>: command line tool to add a signature to a widget directory.</p></li>
114 </ul>
115 <p>For all these commands, a tiny help is available with options <strong>-h</strong> or <strong>--help</strong>.</p>
116 <p>There is no tool for unpacking a widget. For doing such operation, you can use the command <strong>unzip</strong>.</p>
117 <p>To list the files of a widget:</p>
118 <div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">unzip</span> -l WIDGET</code></pre></div>
119 <p>To extract a widget in some directory:</p>
120 <div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">unzip</span> WIDGET -d DIRECTORY</code></pre></div>
121 <p><em>Note that DIRECTORY will be created if needed</em>.</p>
122 <h3 id="signing-a-widget">Signing a widget</h3>
123 <p>To sign a widget, you need a private key and its certificate.</p>
124 <p>The tool <strong>wgtpkg-sign</strong> creates or replace a signature file in the directory of the widget BEFORE its packaging.</p>
125 <p>There are two types of signature files: author and distributor.</p>
126 <p>Example 1: add an author signature</p>
127 <div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">wgtpkg-sign</span> -a -k me.key.pem -c me.cert.pem DIRECTORY</code></pre></div>
128 <p>Example 2: add a distributor signature</p>
129 <div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">wgtpkg-sign</span> -k authority.key.pem -c authority.cert.pem DIRECTORY</code></pre></div>
130 <h3 id="packing-a-widget">Packing a widget</h3>
131 <p>This operation can be done using the command <strong>zip</strong> but we provide the tool <strong>wgtpkg-pack</strong> that may add checking.</p>
132 <p>Example:</p>
133 <div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash">$ <span class="kw">wgtpkg-pack</span> DIRECTORY -o file.wgt</code></pre></div>
134 <h3 id="getting-data-about-a-widget-file">Getting data about a widget file</h3>
135 <p>The command <strong>wgtpkg-info</strong> opens a widget file, reads its <strong>config.xml</strong> file and displays its content in a human readable way.</p>
136 <h2 id="writing-a-widget">Writing a widget</h2>
137 <h3 id="what-kind-of-application">What kind of application?</h3>
138 <p>The file <strong>/etc/afm/afm-launch.conf</strong> explain how to launch applications. (It is the current state that use afm-user-daemon. In a future, it may be replace by systemd features.)</p>
139 <p>Currently the applications that can be run are:</p>
140 <ul>
141 <li><p>binary applications: their type is <strong><em>application/x-executable</em></strong></p></li>
142 <li><p>HTML5 applications: their type is <strong><em>text/html</em></strong></p></li>
143 <li><p>QML applications: their type is <strong><em>text/vnd.qt.qml</em></strong></p></li>
144 </ul>
145 <h3 id="the-steps-for-writing-a-widget">The steps for writing a widget</h3>
146 <ol type="1">
147 <li><p>make your application</p></li>
148 <li><p>create its configuration file <strong>config.xml</strong></p></li>
149 <li><p>sign it</p></li>
150 <li><p>pack it</p></li>
151 </ol>
152 <p>Fairly easy, no?</p>
153 <h2 id="organization-of-directory-of-applications">Organization of directory of applications</h2>
154 <h3 id="directory-where-are-stored-applications">directory where are stored applications</h3>
155 <p>Applications can be installed in different places: the system itself, extension device. On a phone application are typically installed on the sd card.</p>
156 <p>This translates to:</p>
157 <ul>
158 <li>/usr/applications: system wide applications</li>
159 <li>/opt/applications: removable applications</li>
160 </ul>
161 <p>From here those paths are referenced as: &quot;APPDIR&quot;.</p>
162 <p>The main path for applications is: APPDIR/PKGID/VER.</p>
163 <p>Where:</p>
164 <ul>
165 <li>APPDIR is as defined above</li>
166 <li>PKGID is a directory whose name is the package identifier</li>
167 <li>VER is the version of the package MAJOR.MINOR</li>
168 </ul>
169 <p>This organization has the advantage to allow several versions to leave together. This is needed for some good reasons (rolling back) and also for less good reasons (user habits).</p>
170 <h3 id="identity-of-installed-files">Identity of installed files</h3>
171 <p>All files are installed as user &quot;afm&quot; and group &quot;afm&quot;. All files have rw(x) for user and r-(x) for group and others.</p>
172 <p>This allows every user to read every file.</p>
173 <h3 id="labeling-the-directories-of-applications">labeling the directories of applications</h3>
174 <p>The data of a user are in its directory and are labelled by the security-manager using the labels of the application.</p>
175 </body>
176 </html>