aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/wgt-config.c67
-rw-r--r--src/wgt-config.h27
-rw-r--r--src/wgt-info.c47
-rw-r--r--src/wgt-strings.c50
-rw-r--r--src/wgt-strings.h50
-rw-r--r--src/wgtpkg-install.c10
7 files changed, 150 insertions, 102 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 991b5b8..6b2b280 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -101,6 +101,7 @@ add_library(utils STATIC
add_library(wgt STATIC
wgt-config.c
wgt-info.c
+ wgt-strings.c
wgt.c
)
diff --git a/src/wgt-config.c b/src/wgt-config.c
index 453f295..e8bc2b9 100644
--- a/src/wgt-config.c
+++ b/src/wgt-config.c
@@ -28,33 +28,8 @@
#include "verbose.h"
#include "wgt.h"
#include "wgt-config.h"
+#include "wgt-strings.h"
-const char wgt_config_string_author[] = "author";
-const char wgt_config_string_content[] = "content";
-const char wgt_config_string_defaultlocale[] = "defaultlocale";
-const char wgt_config_string_description[] = "description";
-const char wgt_config_string_email[] = "email";
-const char wgt_config_string_encoding[] = "encoding";
-const char wgt_config_string_feature[] = "feature";
-const char wgt_config_string_height[] = "height";
-const char wgt_config_string_href[] = "href";
-const char wgt_config_string_icon[] = "icon";
-const char wgt_config_string_id[] = "id";
-const char wgt_config_string_license[] = "license";
-const char wgt_config_string_name[] = "name";
-const char wgt_config_string_param[] = "param";
-const char wgt_config_string_preference[] = "preference";
-const char wgt_config_string_readonly[] = "readonly";
-const char wgt_config_string_required[] = "required";
-const char wgt_config_string_short[] = "short";
-const char wgt_config_string_src[] = "src";
-const char wgt_config_string_type[] = "type";
-const char wgt_config_string_value[] = "value";
-const char wgt_config_string_version[] = "version";
-const char wgt_config_string_viewmodes[] = "viewmodes";
-const char wgt_config_string_widget[] = "widget";
-const char wgt_config_string_width[] = "width";
-const char wgt_config_string_xml_file[] = "config.xml";
static struct wgt *configwgt = NULL;
static xmlDocPtr configxml = NULL;
@@ -115,15 +90,15 @@ int wgt_config_open(struct wgt *wgt)
{
int fd;
assert(!configxml);
- fd = wgt_open_read(wgt, wgt_config_string_xml_file);
+ fd = wgt_open_read(wgt, string_config_dot_xml);
if (fd < 0) {
- ERROR("can't open config file %s", wgt_config_string_xml_file);
+ ERROR("can't open config file %s", string_config_dot_xml);
return fd;
}
- configxml = xmlReadFd(fd, wgt_config_string_xml_file, NULL, 0);
+ configxml = xmlReadFd(fd, string_config_dot_xml, NULL, 0);
close(fd);
if (configxml == NULL) {
- ERROR("xml parse of config file %s failed", wgt_config_string_xml_file);
+ ERROR("xml parse of config file %s failed", string_config_dot_xml);
return -1;
}
assert(xmlDocGetRootElement(configxml));
@@ -136,39 +111,39 @@ xmlNodePtr wgt_config_widget()
xmlNodePtr root;
assert(configxml);
root = xmlDocGetRootElement(configxml);
- return strcmp(wgt_config_string_widget, root->name) ? NULL : root;
+ return strcmp(string_widget, root->name) ? NULL : root;
}
/* elements based on localisation */
xmlNodePtr wgt_config_name()
{
assert(configxml);
- return element_based_localisation(wgt_config_string_name);
+ return element_based_localisation(string_name);
}
xmlNodePtr wgt_config_description()
{
assert(configxml);
- return element_based_localisation(wgt_config_string_description);
+ return element_based_localisation(string_description);
}
xmlNodePtr wgt_config_license()
{
assert(configxml);
- return element_based_localisation(wgt_config_string_license);
+ return element_based_localisation(string_license);
}
/* elements based on path localisation */
xmlNodePtr wgt_config_author()
{
assert(configxml);
- return first(wgt_config_string_author);
+ return first(string_author);
}
xmlNodePtr wgt_config_content()
{
assert(configxml);
- return first(wgt_config_string_content);
+ return first(string_content);
}
/* element multiple */
@@ -176,54 +151,54 @@ xmlNodePtr wgt_config_content()
xmlNodePtr wgt_config_first_feature()
{
assert(configxml);
- return first(wgt_config_string_feature);
+ return first(string_feature);
}
xmlNodePtr wgt_config_next_feature(xmlNodePtr node)
{
assert(configxml);
assert(node);
- return next(node->next, wgt_config_string_feature);
+ return next(node->next, string_feature);
}
xmlNodePtr wgt_config_first_preference()
{
assert(configxml);
- return first(wgt_config_string_preference);
+ return first(string_preference);
}
xmlNodePtr wgt_config_next_preference(xmlNodePtr node)
{
assert(configxml);
assert(node);
- return next(node->next, wgt_config_string_preference);
+ return next(node->next, string_preference);
}
xmlNodePtr wgt_config_first_icon()
{
assert(configxml);
- return first(wgt_config_string_icon);
+ return first(string_icon);
}
xmlNodePtr wgt_config_next_icon(xmlNodePtr node)
{
assert(configxml);
assert(node);
- return next(node->next, wgt_config_string_icon);
+ return next(node->next, string_icon);
}
xmlNodePtr wgt_config_first_param(xmlNodePtr node)
{
assert(configxml);
assert(node);
- return next(node->children, wgt_config_string_param);
+ return next(node->children, string_param);
}
xmlNodePtr wgt_config_next_param(xmlNodePtr node)
{
assert(configxml);
assert(node);
- return next(node->next, wgt_config_string_param);
+ return next(node->next, string_param);
}
/* best sized icon */
@@ -280,8 +255,8 @@ static int score_dim(xmlNodePtr ref, xmlNodePtr x, const char *dim, int request)
static int is_better_icon(xmlNodePtr ref, xmlNodePtr x, int width, int height)
{
- int sw = score_dim(ref, x, wgt_config_string_width, width);
- int sh = score_dim(ref, x, wgt_config_string_height, height);
+ int sw = score_dim(ref, x, string_width, width);
+ int sh = score_dim(ref, x, string_height, height);
return sw+sh < 0;
}
diff --git a/src/wgt-config.h b/src/wgt-config.h
index 3209a58..bac90b7 100644
--- a/src/wgt-config.h
+++ b/src/wgt-config.h
@@ -17,33 +17,6 @@
*/
-extern const char wgt_config_string_author[];
-extern const char wgt_config_string_content[];
-extern const char wgt_config_string_defaultlocale[];
-extern const char wgt_config_string_description[];
-extern const char wgt_config_string_email[];
-extern const char wgt_config_string_encoding[];
-extern const char wgt_config_string_feature[];
-extern const char wgt_config_string_height[];
-extern const char wgt_config_string_href[];
-extern const char wgt_config_string_icon[];
-extern const char wgt_config_string_id[];
-extern const char wgt_config_string_license[];
-extern const char wgt_config_string_name[];
-extern const char wgt_config_string_param[];
-extern const char wgt_config_string_preference[];
-extern const char wgt_config_string_readonly[];
-extern const char wgt_config_string_required[];
-extern const char wgt_config_string_short[];
-extern const char wgt_config_string_src[];
-extern const char wgt_config_string_type[];
-extern const char wgt_config_string_value[];
-extern const char wgt_config_string_version[];
-extern const char wgt_config_string_viewmodes[];
-extern const char wgt_config_string_widget[];
-extern const char wgt_config_string_width[];
-extern const char wgt_config_string_xml_file[];
-
struct wgt;
extern int wgt_config_open(struct wgt *wgt);
extern void wgt_config_close();
diff --git a/src/wgt-info.c b/src/wgt-info.c
index 9ff7766..12b3966 100644
--- a/src/wgt-info.c
+++ b/src/wgt-info.c
@@ -27,6 +27,7 @@
#include "verbose.h"
#include "wgt.h"
#include "wgt-config.h"
+#include "wgt-strings.h"
#include "wgt-info.h"
struct wgt_info {
@@ -142,42 +143,42 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i
errno = EINVAL;
return -1;
}
- desc->id = xmlGetProp(node, wgt_config_string_id);
+ desc->id = xmlGetProp(node, string_id);
make_lowercase(desc->id);
- desc->version = xmlGetProp(node, wgt_config_string_version);
+ desc->version = xmlGetProp(node, string_version);
desc->ver = mkver(desc->version);
make_lowercase(desc->ver);
desc->idaver = mkidaver(desc->id, desc->ver);
- desc->width = getpropnum(node, wgt_config_string_width, 0);
- desc->height = getpropnum(node, wgt_config_string_height, 0);
- desc->viewmodes = xmlGetProp(node, wgt_config_string_viewmodes);
- desc->defaultlocale = xmlGetProp(node, wgt_config_string_defaultlocale);
+ desc->width = getpropnum(node, string_width, 0);
+ desc->height = getpropnum(node, string_height, 0);
+ desc->viewmodes = xmlGetProp(node, string_viewmodes);
+ desc->defaultlocale = xmlGetProp(node, string_defaultlocale);
node = wgt_config_name();
desc->name = optcontent(node);
- desc->name_short = optprop(node, wgt_config_string_short);
+ desc->name_short = optprop(node, string_short);
node = wgt_config_description();
desc->description = optcontent(node);
node = wgt_config_author();
desc->author = optcontent(node);
- desc->author_href = optprop(node, wgt_config_string_href);
- desc->author_email = optprop(node, wgt_config_string_email);
+ desc->author_href = optprop(node, string_href);
+ desc->author_email = optprop(node, string_email);
node = wgt_config_license();
desc->license = optcontent(node);
- desc->license_href = optprop(node, wgt_config_string_href);
+ desc->license_href = optprop(node, string_href);
node = wgt_config_content();
- desc->content_src = optprop(node, wgt_config_string_src);
+ desc->content_src = optprop(node, string_src);
if (node && desc->content_src == NULL) {
WARNING("content without src");
errno = EINVAL;
return -1;
}
- desc->content_type = optprop(node, wgt_config_string_type);
- desc->content_encoding = optprop(node, wgt_config_string_encoding);
+ desc->content_type = optprop(node, string_type);
+ desc->content_encoding = optprop(node, string_encoding);
if (want_icons) {
icontail = &desc->icons;
@@ -188,9 +189,9 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i
errno = ENOMEM;
return -1;
}
- icon->src = xmlGetProp(node, wgt_config_string_src);
- icon->width = getpropnum(node, wgt_config_string_width, 0);
- icon->height = getpropnum(node, wgt_config_string_height, 0);
+ icon->src = xmlGetProp(node, string_src);
+ icon->width = getpropnum(node, string_width, 0);
+ icon->height = getpropnum(node, string_height, 0);
icon->next = NULL;
*icontail = icon;
@@ -214,8 +215,8 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i
errno = ENOMEM;
return -1;
}
- feature->name = xmlGetProp(node, wgt_config_string_name);
- feature->required = getpropbool(node, wgt_config_string_required, 1);
+ feature->name = xmlGetProp(node, string_name);
+ feature->required = getpropbool(node, string_required, 1);
feature->params = NULL;
feature->next = NULL;
@@ -235,8 +236,8 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i
errno = ENOMEM;
return -1;
}
- param->name = xmlGetProp(pnode, wgt_config_string_name);
- param->value = xmlGetProp(pnode, wgt_config_string_value);
+ param->name = xmlGetProp(pnode, string_name);
+ param->value = xmlGetProp(pnode, string_value);
param->next = NULL;
*paramtail = param;
@@ -265,9 +266,9 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i
errno = ENOMEM;
return -1;
}
- preference->name = xmlGetProp(node, wgt_config_string_name);
- preference->value = xmlGetProp(node, wgt_config_string_value);
- preference->readonly = getpropbool(node, wgt_config_string_readonly, 0);
+ preference->name = xmlGetProp(node, string_name);
+ preference->value = xmlGetProp(node, string_value);
+ preference->readonly = getpropbool(node, string_readonly, 0);
*preferencetail = preference;
preference->next = NULL;
diff --git a/src/wgt-strings.c b/src/wgt-strings.c
new file mode 100644
index 0000000..e3d45a0
--- /dev/null
+++ b/src/wgt-strings.c
@@ -0,0 +1,50 @@
+/*
+ Copyright 2016 IoT.bzh
+
+ author: José Bollo <jose.bollo@iot.bzh>
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+const char string_author[] = "author";
+const char string_content[] = "content";
+const char string_defaultlocale[] = "defaultlocale";
+const char string_description[] = "description";
+const char string_email[] = "email";
+const char string_encoding[] = "encoding";
+const char string_feature[] = "feature";
+const char string_height[] = "height";
+const char string_href[] = "href";
+const char string_icon[] = "icon";
+const char string_id[] = "id";
+const char string_license[] = "license";
+const char string_name[] = "name";
+const char string_optional[] = "optional";
+const char string_param[] = "param";
+const char string_preference[] = "preference";
+const char string_readonly[] = "readonly";
+const char string_required[] = "required";
+const char string_short[] = "short";
+const char string_src[] = "src";
+const char string_type[] = "type";
+const char string_value[] = "value";
+const char string_version[] = "version";
+const char string_viewmodes[] = "viewmodes";
+const char string_widget[] = "widget";
+const char string_width[] = "width";
+const char string_config_dot_xml[] = "config.xml";
+
+const char feature_required_binding[] = FWK_PREFIX "required-binding";
+const char feature_required_permission[] = FWK_PREFIX "required-permission";
+
+
diff --git a/src/wgt-strings.h b/src/wgt-strings.h
new file mode 100644
index 0000000..b2befcc
--- /dev/null
+++ b/src/wgt-strings.h
@@ -0,0 +1,50 @@
+/*
+ Copyright 2016 IoT.bzh
+
+ author: José Bollo <jose.bollo@iot.bzh>
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+extern const char string_author[];
+extern const char string_content[];
+extern const char string_defaultlocale[];
+extern const char string_description[];
+extern const char string_email[];
+extern const char string_encoding[];
+extern const char string_feature[];
+extern const char string_height[];
+extern const char string_href[];
+extern const char string_icon[];
+extern const char string_id[];
+extern const char string_license[];
+extern const char string_name[];
+extern const char string_optional[];
+extern const char string_param[];
+extern const char string_preference[];
+extern const char string_readonly[];
+extern const char string_required[];
+extern const char string_short[];
+extern const char string_src[];
+extern const char string_type[];
+extern const char string_value[];
+extern const char string_version[];
+extern const char string_viewmodes[];
+extern const char string_widget[];
+extern const char string_width[];
+extern const char string_config_dot_xml[];
+
+
+extern const char feature_required_binding[];
+extern const char feature_required_permission[];
+
diff --git a/src/wgtpkg-install.c b/src/wgtpkg-install.c
index 3dbd6ac..550135c 100644
--- a/src/wgtpkg-install.c
+++ b/src/wgtpkg-install.c
@@ -30,6 +30,7 @@
#include "verbose.h"
#include "wgt.h"
#include "wgt-info.h"
+#include "wgt-strings.h"
#include "wgtpkg-files.h"
#include "wgtpkg-workdir.h"
#include "wgtpkg-zip.h"
@@ -39,9 +40,6 @@
#include "secmgr-wrap.h"
#include "utils-dir.h"
-static const char permission_required[] = "required";
-static const char permission_optional[] = "optional";
-static const char feature_required_permissions[] = FWK_PREFIX "required-permission";
static const char* exec_type_strings[] = {
"application/x-executable",
"application/vnd.agl.native"
@@ -104,9 +102,9 @@ static int set_required_permissions(struct wgt_desc_param *params, int required)
while (params) {
/* check the value */
- if (!strcmp(params->value, permission_required))
+ if (!strcmp(params->value, string_required))
optional = !required;
- else if (!strcmp(params->value, permission_optional))
+ else if (!strcmp(params->value, string_optional))
optional = 1;
else {
ERROR("unexpected parameter value: %s found for %s", params->value, params->name);
@@ -136,7 +134,7 @@ static int check_widget(const struct wgt_desc *desc)
result = check_temporary_constraints(desc);
feature = desc->features;
while(result >= 0 && feature) {
- if (!strcmp(feature->name, feature_required_permissions))
+ if (!strcmp(feature->name, feature_required_permission))
result = set_required_permissions(feature->params, feature->required);
feature = feature->next;
}