X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fwgt-info.c;h=1560feb3391905ac326cb7fb220e12f0d9a63825;hb=c0fc18e47e49dd4e3cc2f09452a19297dad63f9c;hp=ddecb9a785e3795cbdf3bd9133d880baf6e19bd4;hpb=34fc3d39e4038b72513db2fc35077251f1f15d01;p=src%2Fapp-framework-main.git diff --git a/src/wgt-info.c b/src/wgt-info.c index ddecb9a..1560feb 100644 --- a/src/wgt-info.c +++ b/src/wgt-info.c @@ -1,6 +1,8 @@ /* Copyright 2015 IoT.bzh + author: José Bollo + 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 @@ -18,7 +20,7 @@ #include #include #include -#include + #include #include "verbose.h" @@ -83,7 +85,7 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i node = wgt_config_widget(); if (!node) { - warning("no widget"); + WARNING("no widget"); errno = EINVAL; return -1; } @@ -113,7 +115,7 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i node = wgt_config_content(); desc->content_src = optprop(node, wgt_config_string_src); if (node && desc->content_src == NULL) { - warning("content without src"); + WARNING("content without src"); errno = EINVAL; return -1; } @@ -137,7 +139,7 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i *icontail = icon; if (icon->src == NULL) { - warning("icon without src"); + WARNING("icon without src"); errno = EINVAL; return -1; } @@ -163,7 +165,7 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i *featuretail = feature; if (feature->name == NULL) { - warning("feature without name"); + WARNING("feature without name"); errno = EINVAL; return -1; } @@ -183,7 +185,7 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i *paramtail = param; if (param->name == NULL || param->value == NULL) { - warning("param without name or value"); + WARNING("param without name or value"); errno = EINVAL; return -1; } @@ -214,7 +216,7 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i preference->next = NULL; if (preference->name == NULL) { - warning("preference without name"); + WARNING("preference without name"); errno = EINVAL; return -1; } @@ -334,7 +336,7 @@ static void dump_desc(struct wgt_desc *desc, FILE *f, const char *prefix) } } -struct wgt_info *wgt_info_get(struct wgt *wgt, int icons, int features, int preferences) +struct wgt_info *wgt_info_create(struct wgt *wgt, int icons, int features, int preferences) { int rc; struct wgt_info *result; @@ -366,11 +368,30 @@ struct wgt_info *wgt_info_get(struct wgt *wgt, int icons, int features, int pref return result; } +struct wgt_info *wgt_info_createat(int dirfd, const char *pathname, int icons, int features, int preferences) +{ + struct wgt_info *result = NULL; + struct wgt *wgt = wgt_createat(dirfd, pathname); + if (wgt) { + result = wgt_info_create(wgt, icons, features, preferences); + wgt_unref(wgt); + } + return result; +} + const struct wgt_desc *wgt_info_desc(struct wgt_info *ifo) { + assert(ifo); return &ifo->desc; } +struct wgt *wgt_info_wgt(struct wgt_info *ifo) +{ + assert(ifo); + assert(ifo->wgt); + return ifo->wgt; +} + void wgt_info_addref(struct wgt_info *ifo) { assert(ifo); @@ -397,10 +418,28 @@ void wgt_info_dump(struct wgt_info *ifo, int fd, const char *prefix) assert(ifo); f = fdopen(fd, "w"); if (f == NULL) - warning("can't fdopen in wgt_info_dump"); + WARNING("can't fdopen in wgt_info_dump"); else { dump_desc(&ifo->desc, f, prefix); fclose(f); } } +const struct wgt_desc_feature *wgt_info_feature(struct wgt_info *ifo, const char *name) +{ + const struct wgt_desc_feature *result = ifo->desc.features; + while(result && strcmp(result->name, name)) + result = result->next; + return result; +} + +const char *wgt_info_param(const struct wgt_desc_feature *feature, const char *name) +{ + const struct wgt_desc_param *param = feature->params; + while(param) { + if (0 == strcmp(name, param->name)) + return param->value; + } + return NULL; +} +