c69efddfb22d642968a7b4aa3a2ecd6ac110bc1f
[AGL/documentation.git] / docs / 4_APIs_and_Services / 4.2_Application_Framework / 3_widgets.md
1 ---
2 edit_link: ''
3 title: Overview of widgets
4 origin_url: >-
5   https://git.automotivelinux.org/src/app-framework-main/plain/docs/2.1-widgets.md?h=master
6 ---
7
8 <!-- WARNING: This file is generated by fetch_docs.js using /home/boron/Documents/AGL/docs-webtemplate/site/_data/tocs/apis_services/master/app-framework-main-developer-guides-api-services-book.yml -->
9
10 # Tools for managing widgets
11
12 This project includes tools for managing widgets.  
13 These tools are:
14
15 - ***wgtpkg-info***: command line tool to display
16   informations about a widget file.
17
18 - ***wgtpkg-install***: command line tool to
19   install a widget file.
20
21 - ***wgtpkg-pack***: command line tool to create
22   a widget file from a widget directory.
23
24 - ***wgtpkg-sign***: command line tool to add a signature
25   to a widget directory.
26
27 For all these commands, a tiny help is available with
28 options **-h** or **--help**.
29
30 There is no tool for unpacking a widget.  
31 For doing such operation, you can use the command **unzip**.
32
33 To list the files of a widget:
34
35 ```bash
36 unzip -l WIDGET
37 ```
38
39 To extract a widget in some directory:
40
41 ```bash
42 unzip WIDGET -d DIRECTORY
43 ```
44
45 *Note: that DIRECTORY will be created if needed*.
46
47 ## Getting data about a widget file
48
49 The command **wgtpkg-info** opens a widget file, reads its **config.xml**
50 file and displays its content in a human readable way.
51
52 ## Signing and packing widget
53
54 ### Signing
55
56 To sign a widget, you need a private key and its certificate.
57
58 The tool **wgtpkg-sign** creates or replace a signature file in
59 the directory of the widget BEFORE its packaging.
60
61 There are two types of signature files: author and distributor.
62
63 Example 1: add an author signature
64
65 ```bash
66 wgtpkg-sign -a -k me.key.pem -c me.cert.pem DIRECTORY
67 ```
68
69 Example 2: add a distributor signature
70
71 ```bash
72 wgtpkg-sign -k authority.key.pem -c authority.cert.pem DIRECTORY
73 ```
74
75 ### Packing
76
77 This operation can be done using the command **zip** but
78 we provide the tool **wgtpkg-pack** that may add checking.
79
80 Example:
81
82 ```bash
83 wgtpkg-pack DIRECTORY -o file.wgt
84 ```
85
86 ## Writing a widget
87
88 ### App directory organization
89
90 There are few directories that are by default used in the binder. At the root
91 directory of the widget folder, here are the directories that could be used:
92
93 - *lib* : default directory where lies external libraries needed for
94  the binding. Binding could be stored here too or in another directory of your
95  choice.
96 - *htdocs* : root HTTP directory if binding has web UI.
97
98 ### The steps for writing a widget
99
100 1. make your application
101 1. create its configuration file **config.xml**
102 1. sign it
103 1. pack it
104
105 Fairly easy, no?
106
107 ## Organization of directory of applications
108
109 ### directory where are stored applications
110
111 Applications can be installed in different places:
112
113 - the system itself, extension device.
114
115 On a phone application are typically installed on the sd card.
116
117 This translates to:
118
119 - /var/local/lib/afm/applications
120
121 From here this path is referenced as: "APPDIR".
122
123 The main path for applications is: APPDIR/PKGID/VER.
124
125 Where:
126
127 - APPDIR is as defined above
128 - PKGID is a directory whose name is the package identifier
129 - VER is the version of the package MAJOR.MINOR
130
131 This organization has the advantage to allow several versions
132 to leave together.  
133 This is needed for some good reasons (rolling back) and also for less good reasons (user habits).
134
135 ### Identity of installed files
136
137 All files are installed as user "afm" and group "afm".  
138 All files have rw(x) for user and r-(x) for group and others.
139
140 This allows every user to read every file.
141
142 ### labeling the directories of applications
143
144 The data of a user are in its directory and are labelled by the security-manager using the application labels.
145
146 [widgets]:          http://www.w3.org/TR/widgets                                    "Packaged Web Apps"
147 [widgets-digsig]:   http://www.w3.org/TR/widgets-digsig                             "XML Digital Signatures for Widgets"
148 [app-manifest]:     http://www.w3.org/TR/appmanifest                                "Web App Manifest"
149 [meta-intel]:       https://github.com/01org/meta-intel-iot-security                "A collection of layers providing security technologies"
150 [widgets]:          http://www.w3.org/TR/widgets                                    "Packaged Web Apps"
151 [widgets-digsig]:   http://www.w3.org/TR/widgets-digsig                             "XML Digital Signatures for Widgets"
152 [libxml2]:          http://xmlsoft.org/html/index.html                              "libxml2"
153 [openssl]:          https://www.openssl.org                                         "OpenSSL"
154 [xmlsec]:           https://www.aleksey.com/xmlsec                                  "XMLSec"
155 [json-c]:           https://github.com/json-c/json-c                                "JSON-c"
156 [d-bus]:            http://www.freedesktop.org/wiki/Software/dbus                   "D-Bus"
157 [libzip]:           http://www.nih.at/libzip                                        "libzip"
158 [cmake]:            https://cmake.org                                               "CMake"
159 [security-manager]: https://wiki.tizen.org/wiki/Security/Tizen_3.X_Security_Manager "Security-Manager"
160 [app-manifest]:     http://www.w3.org/TR/appmanifest                                "Web App Manifest"
161 [tizen-security]:   https://wiki.tizen.org/wiki/Security                            "Tizen security home page"
162 [tizen-secu-3]:     https://wiki.tizen.org/wiki/Security/Tizen_3.X_Overview         "Tizen 3 security overview"