+ if(json_add_str(pub, "id", appid)
+ || json_add_str(priv, "id", desc->id)
+ || json_add_str(pub, "version", desc->version)
+ || json_add_str(priv, "path", path)
+ || json_add_int(pub, "width", desc->width)
+ || json_add_int(pub, "height", desc->height)
+ || json_add_str(pub, "name", desc->name)
+ || json_add_str(pub, "description", desc->description)
+ || json_add_str(pub, "shortname", desc->name_short)
+ || json_add_str(pub, "author", desc->author))
+ goto error2;
+
+ feat = desc->features;
+ while (feat) {
+ static const char prefix[] = FWK_PREFIX_PLUGIN;
+ if (!memcmp(feat->name, prefix, sizeof prefix - 1)) {
+ str = json_object_new_string (feat->name + sizeof prefix - 1);
+ if (str == NULL)
+ goto error2;
+ if (json_object_array_add(plugs, str)) {
+ json_object_put(str);
+ goto error2;
+ }
+ }
+ feat = feat->next;
+ }
+
+ /* record the application structure */
+ if (!json_object_object_get_ex(apps->byapp, desc->id, &bya)) {
+ bya = json_object_new_object();
+ if (!bya)
+ goto error2;
+ if (json_add(apps->byapp, desc->id, bya)) {
+ json_object_put(bya);
+ goto error2;
+ }
+ }
+
+ if (json_add(apps->direct, appid, priv))
+ goto error2;
+ json_object_get(priv);
+
+ if (json_add(bya, desc->version, priv)) {
+ json_object_put(priv);
+ goto error2;
+ }
+
+ if (json_object_array_add(apps->pubarr, pub))
+ goto error2;
+
+ wgt_info_unref(info);
+ return 0;
+
+error2:
+ json_object_put(priv);
+ wgt_info_unref(info);
+error:
+ return -1;