4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
28 static int check_temporary_constraints(const struct wgt_desc *desc)
31 syslog(LOG_ERR, "widget has not icon defined (temporary constraints)");
35 if (desc->icons->next) {
36 syslog(LOG_ERR, "widget has more than one icon defined (temporary constraints)");
40 if (!desc->content_src) {
41 syslog(LOG_ERR, "widget has not content defined (temporary constraints)");
45 if (!desc->content_type) {
46 syslog(LOG_ERR, "widget has not type for its content (temporary constraints)");
53 static int check_permissions(const char *name, int required)
55 if (permission_exists(name)) {
56 if (request_permission(name)) {
57 debug("granted permission: %s", name);
58 } else if (required) {
59 syslog(LOG_ERR, "ungranted permission required: %s", name);
63 notice("ungranted permission optional: %s", name);
69 static int check_widget(const struct wgt_desc *desc)
72 const struct wgt_desc_feature *feature;
75 result = check_temporary_constraints(desc);
76 feature = desc->features;
79 if (0 == strcmp(name, AGLWIDGET)) {
82 if (!check_permissions(feature->name, feature->required))
85 feature = feature->next;
90 static int place(const char *root, const char *appid, const char *version, int force)
92 char newdir[PATH_MAX];
95 rc = snprintf(newdir, sizeof newdir, "%s/%s/%s", root, appid, version);
96 if (rc >= sizeof newdir) {
97 syslog(LOG_ERR, "path to long: %s/%s/%s", root, appid, version);
102 rc = move_workdir(newdir, 1, force);
106 /* install the widget of the file */
107 void install_widget(const char *wgtfile, const char *root, int force)
109 struct wgt_info *ifo;
110 const struct wgt_desc *desc;
112 notice("-- INSTALLING widget %s --", wgtfile);
115 if (make_workdir_base(root, "UNPACK", 0)) {
116 syslog(LOG_ERR, "failed to create a working directory");
120 if (zread(wgtfile, 0))
123 if (check_all_signatures())
126 ifo = wgt_info_createat(workdirfd, NULL, 1, 1, 1);
130 desc = wgt_info_desc(ifo);
131 if (check_widget(desc))
135 if (check_and_place())