X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafm-db.c;h=8cf3b3799e46a7d06e31c70912828215c4274888;hb=dfd49d8fe0bcbc4d794b5a8d56447dd7129aa853;hp=a903be083a59fb577924edb570b25a2a447d4fc9;hpb=2c6fcae14552ab6e7addc82516617a135f86b5ca;p=src%2Fapp-framework-main.git diff --git a/src/afm-db.c b/src/afm-db.c index a903be0..8cf3b37 100644 --- a/src/afm-db.c +++ b/src/afm-db.c @@ -1,5 +1,5 @@ /* - Copyright 2015 IoT.bzh + Copyright 2015, 2016 IoT.bzh author: José Bollo @@ -25,7 +25,7 @@ #include #include -#include +#include #include "utils-json.h" #include "wgt-info.h" @@ -39,9 +39,9 @@ * path: STRING, the path of the root directory for the application * content: STRING, the relative path to the entryu point of the application * type: STRING, the mime type describing the type 'content' - * plugins: ARRAY, array of plugins + * bindings: ARRAY, array of bindings * [ - * STRING, path to the plugin + * STRING, path to the binding * ] * public: OBJECT, public content describing the application widget * { @@ -139,7 +139,7 @@ static int addwgt(struct afm_apps *apps, const char *path, if (!pub) goto error; - plugs = j_add_new_array(priv, "plugins"); + plugs = j_add_new_array(priv, "bindings"); if (!plugs) goto error; @@ -157,10 +157,10 @@ static int addwgt(struct afm_apps *apps, const char *path, || !j_add_string(pub, "author", desc->author)) goto error; - /* extract plugins from features */ + /* extract bindings from features */ feat = desc->features; while (feat) { - static const char prefix[] = FWK_PREFIX_PLUGIN; + static const char prefix[] = FWK_PREFIX_BINDING; if (!memcmp(feat->name, prefix, sizeof prefix - 1)) { str = json_object_new_string ( feat->name + sizeof prefix - 1); @@ -482,10 +482,31 @@ struct json_object *afm_db_application_list(struct afm_db *afdb) */ struct json_object *afm_db_get_application(struct afm_db *afdb, const char *id) { + int i; struct json_object *result; - if (!afm_db_ensure_applications(afdb) && json_object_object_get_ex( - afdb->applications.direct, id, &result)) + + if (afm_db_ensure_applications(afdb)) + return NULL; + + /* search case sensitively */ + if (json_object_object_get_ex( afdb->applications.direct, id, &result)) return json_object_get(result); + + /* fallback to a case insensitive search */ + i = json_object_array_length(afdb->applications.pubarr); + while (i) { + result = json_object_array_get_idx(afdb->applications.pubarr, --i); + if (result + && json_object_object_get_ex(result, "id", &result) + && !strcasecmp(id, json_object_get_string(result))) { + if (json_object_object_get_ex( afdb->applications.direct, + json_object_get_string(result), + &result)) + return json_object_get(result); + else + return NULL; + } + } return NULL; }