summaryrefslogtreecommitdiff
path: root/libappstream-builder/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'libappstream-builder/plugins')
-rw-r--r--libappstream-builder/plugins/Makefile.am18
-rw-r--r--libappstream-builder/plugins/asb-plugin-appdata.c358
-rw-r--r--libappstream-builder/plugins/asb-plugin-blacklist.c2
-rw-r--r--libappstream-builder/plugins/asb-plugin-desktop.c124
-rw-r--r--libappstream-builder/plugins/asb-plugin-firmware.c139
-rw-r--r--libappstream-builder/plugins/asb-plugin-gstreamer.c101
-rw-r--r--libappstream-builder/plugins/asb-plugin-hardcoded.c28
-rw-r--r--libappstream-builder/plugins/asb-plugin-ibus-sql.c264
-rw-r--r--libappstream-builder/plugins/asb-plugin-ibus-xml.c224
-rw-r--r--libappstream-builder/plugins/asb-plugin-metainfo.c184
10 files changed, 259 insertions, 1183 deletions
diff --git a/libappstream-builder/plugins/Makefile.am b/libappstream-builder/plugins/Makefile.am
index f697631..96840ad 100644
--- a/libappstream-builder/plugins/Makefile.am
+++ b/libappstream-builder/plugins/Makefile.am
@@ -27,9 +27,6 @@ plugin_LTLIBRARIES = \
libasb_plugin_gettext.la \
libasb_plugin_gstreamer.la \
libasb_plugin_hardcoded.la \
- libasb_plugin_ibus_sql.la \
- libasb_plugin_ibus_xml.la \
- libasb_plugin_metainfo.la \
libasb_plugin_kde_services.la \
libasb_plugin_kde_notifyrc.la \
libasb_plugin_nm.la
@@ -69,11 +66,6 @@ libasb_plugin_gstreamer_la_LIBADD = $(GLIB_LIBS)
libasb_plugin_gstreamer_la_LDFLAGS = -module -avoid-version
libasb_plugin_gstreamer_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C)
-libasb_plugin_metainfo_la_SOURCES = asb-plugin-metainfo.c
-libasb_plugin_metainfo_la_LIBADD = $(GLIB_LIBS)
-libasb_plugin_metainfo_la_LDFLAGS = -module -avoid-version
-libasb_plugin_metainfo_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C)
-
libasb_plugin_gettext_la_SOURCES = asb-plugin-gettext.c
libasb_plugin_gettext_la_LIBADD = $(GLIB_LIBS)
libasb_plugin_gettext_la_LDFLAGS = -module -avoid-version
@@ -114,16 +106,6 @@ libasb_plugin_nm_la_LIBADD = $(GLIB_LIBS)
libasb_plugin_nm_la_LDFLAGS = -module -avoid-version
libasb_plugin_nm_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C)
-libasb_plugin_ibus_sql_la_SOURCES = asb-plugin-ibus-sql.c
-libasb_plugin_ibus_sql_la_LIBADD = $(GLIB_LIBS) $(SQLITE_LIBS)
-libasb_plugin_ibus_sql_la_LDFLAGS = -module -avoid-version
-libasb_plugin_ibus_sql_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C)
-
-libasb_plugin_ibus_xml_la_SOURCES = asb-plugin-ibus-xml.c
-libasb_plugin_ibus_xml_la_LIBADD = $(GLIB_LIBS) $(SQLITE_LIBS)
-libasb_plugin_ibus_xml_la_LDFLAGS = -module -avoid-version
-libasb_plugin_ibus_xml_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C)
-
libasb_plugin_font_la_SOURCES = asb-plugin-font.c
libasb_plugin_font_la_LIBADD = $(GLIB_LIBS) $(FREETYPE_LIBS) $(GDKPIXBUF_LIBS) $(GTK_LIBS)
libasb_plugin_font_la_LDFLAGS = -module -avoid-version
diff --git a/libappstream-builder/plugins/asb-plugin-appdata.c b/libappstream-builder/plugins/asb-plugin-appdata.c
index e0d3851..26e68c5 100644
--- a/libappstream-builder/plugins/asb-plugin-appdata.c
+++ b/libappstream-builder/plugins/asb-plugin-appdata.c
@@ -20,8 +20,7 @@
*/
#include <config.h>
-
-#include <appstream-glib.h>
+#include <fnmatch.h>
#include <asb-plugin.h>
@@ -40,46 +39,73 @@ asb_plugin_get_name (void)
void
asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
{
+ asb_plugin_add_glob (globs, "/usr/share/appdata/*.metainfo.xml");
asb_plugin_add_glob (globs, "/usr/share/appdata/*.appdata.xml");
asb_plugin_add_glob (globs, "*.metainfo.xml");
}
/**
+ * _asb_plugin_check_filename:
+ */
+static gboolean
+_asb_plugin_check_filename (const gchar *filename)
+{
+ if (asb_plugin_match_glob ("*.metainfo.xml", filename) ||
+ asb_plugin_match_glob ("/usr/share/appdata/*.metainfo.xml", filename) ||
+ asb_plugin_match_glob ("/usr/share/appdata/*.appdata.xml", filename))
+ return TRUE;
+ return FALSE;
+}
+
+/**
+ * asb_plugin_check_filename:
+ */
+gboolean
+asb_plugin_check_filename (AsbPlugin *plugin, const gchar *filename)
+{
+ return _asb_plugin_check_filename (filename);
+}
+
+/**
* asb_plugin_process_filename:
*/
static gboolean
asb_plugin_process_filename (AsbPlugin *plugin,
- AsbApp *app,
+ AsbPackage *pkg,
const gchar *filename,
+ GList **apps,
GError **error)
{
AsProblemKind problem_kind;
AsProblem *problem;
- const gchar *key;
- const gchar *old;
+ GPtrArray *icons;
const gchar *tmp;
- gboolean ret;
- GHashTable *hash;
- GPtrArray *array;
- GList *l;
- GList *list;
guint i;
- g_autoptr(AsApp) appdata = NULL;
+ g_autoptr(AsbApp) app = NULL;
g_autoptr(GPtrArray) problems = NULL;
- /* validate */
- appdata = as_app_new ();
- ret = as_app_parse_file (appdata, filename,
- AS_APP_PARSE_FLAG_NONE,
- error);
- if (!ret)
+ app = asb_app_new (NULL, NULL);
+ if (!as_app_parse_file (AS_APP (app), filename,
+ AS_APP_PARSE_FLAG_NONE,
+ error))
+ return FALSE;
+ if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_UNKNOWN) {
+ g_set_error (error,
+ ASB_PLUGIN_ERROR,
+ ASB_PLUGIN_ERROR_FAILED,
+ "%s has no recognised type",
+ as_app_get_id (AS_APP (app)));
return FALSE;
- problems = as_app_validate (appdata,
+ }
+
+ /* validate */
+ problems = as_app_validate (AS_APP (app),
AS_APP_VALIDATE_FLAG_NO_NETWORK |
AS_APP_VALIDATE_FLAG_RELAX,
error);
if (problems == NULL)
return FALSE;
+ asb_app_set_package (app, pkg);
for (i = 0; i < problems->len; i++) {
problem = g_ptr_array_index (problems, i);
problem_kind = as_problem_get_kind (problem);
@@ -90,34 +116,14 @@ asb_plugin_process_filename (AsbPlugin *plugin,
as_problem_get_message (problem));
}
- /* check <id> matches, but still accept if missing or incorrect */
- tmp = as_app_get_id (appdata);
- if (tmp == NULL) {
- asb_package_log (asb_app_get_package (app),
- ASB_PACKAGE_LOG_LEVEL_WARNING,
- "AppData %s has no ID", filename);
- } else if (g_strcmp0 (tmp, as_app_get_id (AS_APP (app))) != 0) {
- asb_package_log (asb_app_get_package (app),
- ASB_PACKAGE_LOG_LEVEL_WARNING,
- "AppData %s does not match '%s':'%s'",
- filename, tmp,
- as_app_get_id (AS_APP (app)));
- }
-
- /* overwrite the app ID with the metadata one for firmware */
- if (as_app_get_id_kind (appdata) == AS_ID_KIND_FIRMWARE) {
- old = as_app_get_id (AS_APP (app));
- if (old != NULL) {
- asb_package_log (asb_app_get_package (app),
- ASB_PACKAGE_LOG_LEVEL_DEBUG,
- "renaming ID %s -> %s",
- old, as_app_get_id (AS_APP (appdata)));
- }
- as_app_set_id (AS_APP (app), as_app_get_id (AS_APP (appdata)));
- }
+ /* nuke things that do not belong */
+ icons = as_app_get_icons (AS_APP (app));
+ if (icons->len > 0)
+ g_ptr_array_set_size (icons, 0);
/* add provide if missing */
- if (as_app_get_id_kind (appdata) == AS_ID_KIND_FIRMWARE &&
+ tmp = as_app_get_id (AS_APP (app));
+ if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_FIRMWARE &&
as_utils_guid_is_valid (tmp)) {
g_autoptr(AsProvide) provide = NULL;
provide = as_provide_new ();
@@ -127,7 +133,7 @@ asb_plugin_process_filename (AsbPlugin *plugin,
}
/* check license */
- tmp = as_app_get_metadata_license (appdata);
+ tmp = as_app_get_metadata_license (AS_APP (app));
if (tmp == NULL) {
g_set_error (error,
ASB_PLUGIN_ERROR,
@@ -145,189 +151,149 @@ asb_plugin_process_filename (AsbPlugin *plugin,
return FALSE;
}
- /* other optional data */
- tmp = as_app_get_url_item (appdata, AS_URL_KIND_HOMEPAGE);
- if (tmp != NULL)
- as_app_add_url (AS_APP (app), AS_URL_KIND_HOMEPAGE, tmp);
- tmp = as_app_get_project_group (appdata);
+ /* check project group */
+ tmp = as_app_get_project_group (AS_APP (app));
if (tmp != NULL) {
- /* check the category is valid */
if (!as_utils_is_environment_id (tmp)) {
asb_package_log (asb_app_get_package (app),
ASB_PACKAGE_LOG_LEVEL_WARNING,
"AppData project group invalid, "
"so ignoring: %s", tmp);
- } else {
- as_app_set_project_group (AS_APP (app), tmp);
- }
- }
- array = as_app_get_compulsory_for_desktops (appdata);
- if (array->len > 0) {
- tmp = g_ptr_array_index (array, 0);
- as_app_add_compulsory_for_desktop (AS_APP (app), tmp);
- }
-
- /* perhaps get name */
- hash = as_app_get_names (appdata);
- list = g_hash_table_get_keys (hash);
- for (l = list; l != NULL; l = l->next) {
- key = l->data;
- tmp = g_hash_table_lookup (hash, key);
- as_app_set_name (AS_APP (app), key, tmp);
- }
- g_list_free (list);
-
- /* perhaps get summary */
- hash = as_app_get_comments (appdata);
- list = g_hash_table_get_keys (hash);
- for (l = list; l != NULL; l = l->next) {
- key = l->data;
- tmp = g_hash_table_lookup (hash, key);
- as_app_set_comment (AS_APP (app), key, tmp);
- }
- g_list_free (list);
-
- /* get descriptions */
- hash = as_app_get_descriptions (appdata);
- list = g_hash_table_get_keys (hash);
- for (l = list; l != NULL; l = l->next) {
- key = l->data;
- tmp = g_hash_table_lookup (hash, key);
- as_app_set_description (AS_APP (app), key, tmp);
- }
- g_list_free (list);
-
- /* add screenshots if not already added */
- array = as_app_get_screenshots (AS_APP (app));
- if (array->len == 0) {
- /* just use the upstream locations */
- array = as_app_get_screenshots (appdata);
- for (i = 0; i < array->len; i++) {
- AsScreenshot *ss;
- ss = g_ptr_array_index (array, i);
- as_app_add_screenshot (AS_APP (app), ss);
- }
- } else {
- array = as_app_get_screenshots (appdata);
- if (array->len > 0) {
- asb_package_log (asb_app_get_package (app),
- ASB_PACKAGE_LOG_LEVEL_INFO,
- "AppData screenshots ignored");
+ as_app_set_project_group (AS_APP (app), NULL);
}
}
- /* add metadata */
- hash = as_app_get_metadata (appdata);
- list = g_hash_table_get_keys (hash);
- for (l = list; l != NULL; l = l->next) {
- key = l->data;
- tmp = g_hash_table_lookup (hash, key);
- as_app_add_metadata (AS_APP (app), key, tmp);
+ /* log updateinfo */
+ tmp = as_app_get_update_contact (AS_APP (app));
+ if (tmp != NULL) {
+ asb_package_log (asb_app_get_package (app),
+ ASB_PACKAGE_LOG_LEVEL_INFO,
+ "Upstream contact <%s>", tmp);
}
- /* add developer name */
- tmp = as_app_get_developer_name (AS_APP (appdata), NULL);
- if (tmp != NULL)
- as_app_set_developer_name (AS_APP (app), NULL, tmp);
-
- /* add releases */
- array = as_app_get_releases (appdata);
- for (i = 0; i < array->len; i++) {
- AsRelease *rel = g_ptr_array_index (array, i);
- as_app_add_release (AS_APP (app), rel);
+ /* add icon for firmware */
+ if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_FIRMWARE) {
+ g_autoptr(AsIcon) icon = NULL;
+ icon = as_icon_new ();
+ as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+ as_icon_set_name (icon, "application-x-executable");
+ as_app_add_icon (AS_APP (app), icon);
}
- /* add provides */
- array = as_app_get_provides (appdata);
- for (i = 0; i < array->len; i++) {
- AsProvide *pr = g_ptr_array_index (array, i);
- as_app_add_provide (AS_APP (app), pr);
+ /* fix up input methods */
+ if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_INPUT_METHOD) {
+ g_autoptr(AsIcon) icon = NULL;
+ icon = as_icon_new ();
+ as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+ as_icon_set_name (icon, "system-run-symbolic");
+ as_app_add_icon (AS_APP (app), icon);
+ as_app_add_category (AS_APP (app), "Addons");
+ as_app_add_category (AS_APP (app), "InputSources");
}
- /* log updateinfo */
- tmp = as_app_get_update_contact (AS_APP (appdata));
- if (tmp != NULL) {
- asb_package_log (asb_app_get_package (app),
- ASB_PACKAGE_LOG_LEVEL_INFO,
- "Upstream contact <%s>", tmp);
+ /* fix up codecs */
+ if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_CODEC) {
+ g_autoptr(AsIcon) icon = NULL;
+ icon = as_icon_new ();
+ as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
+ as_icon_set_name (icon, "application-x-executable");
+ as_app_add_icon (AS_APP (app), icon);
+ as_app_add_category (AS_APP (app), "Addons");
+ as_app_add_category (AS_APP (app), "Codecs");
}
/* success */
- asb_app_set_requires_appdata (app, FALSE);
+ asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx,
+ ASB_CONTEXT_FLAG_HIDPI_ICONS));
+ asb_plugin_add_app (apps, AS_APP (app));
return TRUE;
}
/**
- * asb_plugin_appdata_get_fn_for_app:
+ * asb_plugin_process:
*/
-static gchar *
-asb_plugin_appdata_get_fn_for_app (AsApp *app)
+GList *
+asb_plugin_process (AsbPlugin *plugin,
+ AsbPackage *pkg,
+ const gchar *tmpdir,
+ GError **error)
{
- gchar *fn = g_strdup (as_app_get_id (app));
- gchar *tmp;
+ gboolean ret;
+ GList *apps = NULL;
+ guint i;
+ gchar **filelist;
- /* just cut off the last section without munging the name */
- tmp = g_strrstr (fn, ".");
- if (tmp != NULL)
- *tmp = '\0';
- return fn;
+ filelist = asb_package_get_filelist (pkg);
+ for (i = 0; filelist[i] != NULL; i++) {
+ g_autofree gchar *filename_tmp = NULL;
+ if (!_asb_plugin_check_filename (filelist[i]))
+ continue;
+ filename_tmp = g_build_filename (tmpdir, filelist[i], NULL);
+ ret = asb_plugin_process_filename (plugin,
+ pkg,
+ filename_tmp,
+ &apps,
+ error);
+ if (!ret) {
+ g_list_free_full (apps, (GDestroyNotify) g_object_unref);
+ return NULL;
+ }
+ }
+
+ /* no desktop files we care about */
+ if (apps == NULL) {
+ g_set_error (error,
+ ASB_PLUGIN_ERROR,
+ ASB_PLUGIN_ERROR_FAILED,
+ "nothing interesting in %s",
+ asb_package_get_basename (pkg));
+ return NULL;
+ }
+ return apps;
}
/**
- * asb_plugin_process_app:
+ * asb_plugin_merge:
*/
-gboolean
-asb_plugin_process_app (AsbPlugin *plugin,
- AsbPackage *pkg,
- AsbApp *app,
- const gchar *tmpdir,
- GError **error)
+void
+asb_plugin_merge (AsbPlugin *plugin, GList *list)
{
- GError *error_local = NULL;
- g_autofree gchar *appdata_filename = NULL;
-
- /* get possible sources */
- if (asb_package_get_kind (pkg) == ASB_PACKAGE_KIND_FIRMWARE) {
- appdata_filename = g_build_filename (tmpdir,
- as_app_get_metadata_item (AS_APP (app), "MetainfoBasename"),
- NULL);
- } else {
- g_autofree gchar *appdata_basename = NULL;
- appdata_basename = asb_plugin_appdata_get_fn_for_app (AS_APP (app));
- appdata_filename = g_strdup_printf ("%s/files/share/appdata/%s.appdata.xml",
- tmpdir, appdata_basename);
- if (!g_file_test (appdata_filename, G_FILE_TEST_EXISTS)) {
- g_free (appdata_filename);
- appdata_filename = g_strdup_printf ("%s/usr/share/appdata/%s.appdata.xml",
- tmpdir, appdata_basename);
- }
- }
+ AsApp *app;
+ AsApp *found;
+ GList *l;
+ g_autoptr(GHashTable) hash = NULL;
- /* any installed appdata file */
- if (g_file_test (appdata_filename, G_FILE_TEST_EXISTS)) {
- /* be understanding if upstream gets the AppData file
- * wrong -- just fall back to the desktop file data */
- if (!asb_plugin_process_filename (plugin,
- app,
- appdata_filename,
- &error_local)) {
- error_local->code = ASB_PLUGIN_ERROR_IGNORE;
- g_propagate_error (error, error_local);
- g_prefix_error (error,
- "AppData file '%s' invalid: ",
- appdata_filename);
- return FALSE;
- }
- return TRUE;
+ /* make a hash table of ID->AsApp */
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free, (GDestroyNotify) g_object_unref);
+ for (l = list; l != NULL; l = l->next) {
+ app = AS_APP (l->data);
+ if (as_app_get_id_kind (app) != AS_ID_KIND_DESKTOP)
+ continue;
+ g_hash_table_insert (hash,
+ g_strdup (as_app_get_id (app)),
+ g_object_ref (app));
}
- /* we're going to require this soon */
- if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_DESKTOP &&
- as_app_get_metadata_item (AS_APP (app), "NoDisplay") == NULL) {
- asb_package_log (pkg,
- ASB_PACKAGE_LOG_LEVEL_WARNING,
- "desktop application %s has no AppData",
- as_app_get_id (AS_APP (app)));
+ /* add addons where the pkgname is different from the
+ * main package */
+ for (l = list; l != NULL; l = l->next) {
+ if (!ASB_IS_APP (l->data))
+ continue;
+ app = AS_APP (l->data);
+ if (as_app_get_id_kind (app) != AS_ID_KIND_ADDON)
+ continue;
+ found = g_hash_table_lookup (hash, as_app_get_id (app));
+ if (found == NULL)
+ continue;
+ if (g_strcmp0 (as_app_get_pkgname_default (app),
+ as_app_get_pkgname_default (found)) != 0)
+ continue;
+ as_app_add_veto (app,
+ "absorbing addon %s shipped in "
+ "main package %s",
+ as_app_get_id (app),
+ as_app_get_pkgname_default (app));
+ as_app_subsume_full (found, app, AS_APP_SUBSUME_FLAG_PARTIAL);
}
- return TRUE;
}
diff --git a/libappstream-builder/plugins/asb-plugin-blacklist.c b/libappstream-builder/plugins/asb-plugin-blacklist.c
index d441b5a..e4360ef 100644
--- a/libappstream-builder/plugins/asb-plugin-blacklist.c
+++ b/libappstream-builder/plugins/asb-plugin-blacklist.c
@@ -133,6 +133,6 @@ asb_plugin_process_app (AsbPlugin *plugin,
tmp = asb_glob_value_search (plugin->priv->vetos,
as_app_get_id (AS_APP (app)));
if (tmp != NULL)
- asb_app_add_requires_appdata (app, "%s", tmp);
+ as_app_add_veto (AS_APP (app), "%s", tmp);
return TRUE;
}
diff --git a/libappstream-builder/plugins/asb-plugin-desktop.c b/libappstream-builder/plugins/asb-plugin-desktop.c
index ec412c1..34cf795 100644
--- a/libappstream-builder/plugins/asb-plugin-desktop.c
+++ b/libappstream-builder/plugins/asb-plugin-desktop.c
@@ -53,28 +53,6 @@ asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
}
/**
- * _asb_plugin_check_filename:
- */
-static gboolean
-_asb_plugin_check_filename (const gchar *filename)
-{
- if (asb_plugin_match_glob ("/usr/share/applications/*.desktop", filename))
- return TRUE;
- if (asb_plugin_match_glob ("/usr/share/applications/kde4/*.desktop", filename))
- return TRUE;
- return FALSE;
-}
-
-/**
- * asb_plugin_check_filename:
- */
-gboolean
-asb_plugin_check_filename (AsbPlugin *plugin, const gchar *filename)
-{
- return _asb_plugin_check_filename (filename);
-}
-
-/**
* asb_app_load_icon:
*/
static GdkPixbuf *
@@ -301,22 +279,21 @@ asb_plugin_desktop_add_icons (AsbPlugin *plugin,
}
/**
- * asb_plugin_process_filename:
+ * asb_plugin_desktop_refine:
*/
static gboolean
-asb_plugin_process_filename (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *filename,
- GList **apps,
- const gchar *tmpdir,
- GError **error)
+asb_plugin_desktop_refine (AsbPlugin *plugin,
+ AsbPackage *pkg,
+ const gchar *filename,
+ AsbApp *app,
+ const gchar *tmpdir,
+ GError **error)
{
AsIcon *icon;
AsAppParseFlags parse_flags = AS_APP_PARSE_FLAG_USE_HEURISTICS;
gboolean ret;
g_autofree gchar *app_id = NULL;
- g_autofree gchar *full_filename = NULL;
- g_autoptr(AsbApp) app = NULL;
+ g_autoptr(AsApp) desktop_app = NULL;
g_autoptr(GdkPixbuf) pixbuf = NULL;
/* use GenericName fallback */
@@ -325,23 +302,16 @@ asb_plugin_process_filename (AsbPlugin *plugin,
/* create app */
app_id = g_path_get_basename (filename);
- app = asb_app_new (pkg, app_id);
- asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
- full_filename = g_build_filename (tmpdir, filename, NULL);
- if (!as_app_parse_file (AS_APP (app), full_filename, parse_flags, error))
+ desktop_app = as_app_new ();
+ if (!as_app_parse_file (desktop_app, filename, parse_flags, error))
return FALSE;
/* NoDisplay apps are never included */
- if (as_app_get_metadata_item (AS_APP (app), "NoDisplay") != NULL)
- asb_app_add_requires_appdata (app, "NoDisplay=true");
-
- /* Settings or DesktopSettings requires AppData */
- if (!asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_IGNORE_SETTINGS)) {
- if (as_app_has_category (AS_APP (app), "Settings"))
- asb_app_add_requires_appdata (app, "Category=Settings");
- if (as_app_has_category (AS_APP (app), "DesktopSettings"))
- asb_app_add_requires_appdata (app, "Category=DesktopSettings");
- }
+ if (as_app_get_metadata_item (desktop_app, "NoDisplay") != NULL)
+ as_app_add_veto (AS_APP (app), "NoDisplay=true");
+
+ /* copy all metadata */
+ as_app_subsume_full (AS_APP (app), desktop_app, AS_APP_SUBSUME_FLAG_NO_OVERWRITE);
/* is the icon a stock-icon-name? */
icon = as_app_get_icon_default (AS_APP (app));
@@ -367,54 +337,38 @@ asb_plugin_process_filename (AsbPlugin *plugin,
}
}
- /* add */
- asb_plugin_add_app (apps, AS_APP (app));
return TRUE;
}
/**
- * asb_plugin_process:
+ * asb_plugin_process_app:
*/
-GList *
-asb_plugin_process (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *tmpdir,
- GError **error)
+gboolean
+asb_plugin_process_app (AsbPlugin *plugin,
+ AsbPackage *pkg,
+ AsbApp *app,
+ const gchar *tmpdir,
+ GError **error)
{
- gboolean ret;
- GError *error_local = NULL;
- GList *apps = NULL;
guint i;
- gchar **filelist;
-
- filelist = asb_package_get_filelist (pkg);
- for (i = 0; filelist[i] != NULL; i++) {
- if (!_asb_plugin_check_filename (filelist[i]))
- continue;
- ret = asb_plugin_process_filename (plugin,
- pkg,
- filelist[i],
- &apps,
- tmpdir,
- &error_local);
- if (!ret) {
- asb_package_log (pkg,
- ASB_PACKAGE_LOG_LEVEL_INFO,
- "Failed to process %s: %s",
- filelist[i],
- error_local->message);
- g_clear_error (&error_local);
+ const gchar *app_dirs[] = {
+ "/usr/share/applications",
+ "/usr/share/applications/kde4",
+ NULL };
+
+ /* use the .desktop file to refine the application */
+ for (i = 0; app_dirs[i] != NULL; i++) {
+ g_autofree gchar *fn = NULL;
+ fn = g_build_filename (tmpdir,
+ app_dirs[i],
+ as_app_get_id (AS_APP (app)),
+ NULL);
+ if (g_file_test (fn, G_FILE_TEST_EXISTS)) {
+ if (!asb_plugin_desktop_refine (plugin, pkg, fn,
+ app, tmpdir, error))
+ return FALSE;
}
}
- /* no desktop files we care about */
- if (apps == NULL) {
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "nothing interesting in %s",
- asb_package_get_basename (pkg));
- return NULL;
- }
- return apps;
+ return TRUE;
}
diff --git a/libappstream-builder/plugins/asb-plugin-firmware.c b/libappstream-builder/plugins/asb-plugin-firmware.c
index bd98f07..2ef9b5c 100644
--- a/libappstream-builder/plugins/asb-plugin-firmware.c
+++ b/libappstream-builder/plugins/asb-plugin-firmware.c
@@ -46,39 +46,19 @@ asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
}
/**
- * _asb_plugin_check_filename:
- */
-static gboolean
-_asb_plugin_check_filename (const gchar *filename)
-{
- if (asb_plugin_match_glob ("*.inf", filename))
- return TRUE;
- return FALSE;
-}
-
-/**
- * asb_plugin_check_filename:
- */
-gboolean
-asb_plugin_check_filename (AsbPlugin *plugin, const gchar *filename)
-{
- return _asb_plugin_check_filename (filename);
-}
-
-/**
- * asb_plugin_firmware_get_metainfo_fn:
+ * asb_plugin_firmware_get_inf_fn:
*/
static gchar *
-asb_plugin_firmware_get_metainfo_fn (const gchar *filename)
+asb_plugin_firmware_get_inf_fn (const gchar *filename)
{
gchar *basename;
gchar *tmp;
basename = g_path_get_basename (filename);
- tmp = g_strrstr (basename, ".inf");
+ tmp = g_strrstr (basename, ".metainfo.xml");
if (tmp != NULL)
*tmp = '\0';
- return g_strdup_printf ("%s.metainfo.xml", basename);
+ return g_strdup_printf ("%s.inf", basename);
}
/**
@@ -98,30 +78,28 @@ asb_plugin_firmware_get_checksum (const gchar *filename,
}
/**
- * asb_plugin_process_filename:
+ * asb_plugin_firmware_refine:
*/
static gboolean
-asb_plugin_process_filename (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *filename,
- GList **apps,
- const gchar *tmpdir,
- GError **error)
+asb_plugin_firmware_refine (AsbPlugin *plugin,
+ AsbPackage *pkg,
+ const gchar *filename,
+ AsbApp *app,
+ const gchar *tmpdir,
+ GError **error)
{
AsRelease *release;
GError *error_local = NULL;
const gchar *fw_basename = NULL;
g_autofree gchar *checksum = NULL;
- g_autofree gchar *filename_full = NULL;
g_autofree gchar *location_checksum = NULL;
g_autofree gchar *metainfo_fn = NULL;
- g_autoptr(AsbApp) app = NULL;
+ g_autoptr(AsApp) inf = NULL;
g_autoptr(AsChecksum) csum = NULL;
/* parse */
- filename_full = g_build_filename (tmpdir, filename, NULL);
- app = asb_app_new (pkg, NULL);
- if (!as_app_parse_file (AS_APP (app), filename_full,
+ inf = as_app_new ();
+ if (!as_app_parse_file (inf, filename,
AS_APP_PARSE_FLAG_NONE, &error_local)) {
g_set_error_literal (error,
ASB_PLUGIN_ERROR,
@@ -130,7 +108,7 @@ asb_plugin_process_filename (AsbPlugin *plugin,
return FALSE;
}
- /* get the default release, creating if required */
+ /* get the correct release, creating if required */
release = as_app_get_release_default (AS_APP (app));
if (release == NULL) {
release = as_release_new ();
@@ -152,13 +130,8 @@ asb_plugin_process_filename (AsbPlugin *plugin,
as_checksum_set_filename (csum, asb_package_get_basename (pkg));
as_release_add_checksum (release, csum);
- /* for the adddata plugin; removed in asb_plugin_merge() */
- metainfo_fn = asb_plugin_firmware_get_metainfo_fn (filename);
- if (metainfo_fn != NULL)
- as_app_add_metadata (AS_APP (app), "MetainfoBasename", metainfo_fn);
-
/* set the internal checksum */
- fw_basename = as_app_get_metadata_item (AS_APP (app), "FirmwareBasename");
+ fw_basename = as_app_get_metadata_item (inf, "FirmwareBasename");
if (fw_basename != NULL) {
g_autofree gchar *checksum_bin = NULL;
g_autofree gchar *fn_bin = NULL;
@@ -181,72 +154,40 @@ asb_plugin_process_filename (AsbPlugin *plugin,
as_release_add_checksum (release, csum_bin);
}
- asb_plugin_add_app (apps, AS_APP (app));
return TRUE;
}
/**
- * asb_plugin_process:
+ * asb_plugin_process_app:
*/
-GList *
-asb_plugin_process (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *tmpdir,
- GError **error)
+gboolean
+asb_plugin_process_app (AsbPlugin *plugin,
+ AsbPackage *pkg,
+ AsbApp *app,
+ const gchar *tmpdir,
+ GError **error)
{
- gboolean ret;
- GError *error_local = NULL;
- GList *apps = NULL;
- guint i;
- gchar **filelist;
-
- filelist = asb_package_get_filelist (pkg);
- for (i = 0; filelist[i] != NULL; i++) {
- if (!_asb_plugin_check_filename (filelist[i]))
- continue;
- ret = asb_plugin_process_filename (plugin,
- pkg,
- filelist[i],
- &apps,
- tmpdir,
- &error_local);
- if (!ret) {
- asb_package_log (pkg,
- ASB_PACKAGE_LOG_LEVEL_INFO,
- "Failed to process %s: %s",
- filelist[i],
- error_local->message);
- g_clear_error (&error_local);
- }
- }
+ const gchar *tmp;
+ g_autofree gchar *fn = NULL;
+ g_autofree gchar *inf_fn = NULL;
- /* no desktop files we care about */
- if (apps == NULL) {
+ /* use metainfo basename */
+ tmp = as_app_get_source_file (AS_APP (app));
+ if (tmp == NULL) {
g_set_error (error,
ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "nothing interesting in %s",
- asb_package_get_basename (pkg));
- return NULL;
+ ASB_PLUGIN_ERROR_NOT_SUPPORTED,
+ "no source_file set for %s",
+ as_app_get_id (AS_APP (app)));
+ return FALSE;
}
- return apps;
-}
-/**
- * asb_plugin_merge:
- */
-void
-asb_plugin_merge (AsbPlugin *plugin, GList *list)
-{
- AsApp *app;
- GList *l;
-
- /* remove the MetainfoBasename metadata */
- for (l = list; l != NULL; l = l->next) {
- app = AS_APP (l->data);
- if (as_app_get_id_kind (app) != AS_ID_KIND_FIRMWARE)
- continue;
- as_app_remove_metadata (app, "MetainfoBasename");
- as_app_remove_metadata (app, "FirmwareBasename");
+ /* use the .inf file to refine the application */
+ inf_fn = asb_plugin_firmware_get_inf_fn (tmp);
+ fn = g_build_filename (tmpdir, inf_fn, NULL);
+ if (g_file_test (fn, G_FILE_TEST_EXISTS)) {
+ if (!asb_plugin_firmware_refine (plugin, pkg, fn, app, tmpdir, error))
+ return FALSE;
}
+ return TRUE;
}
diff --git a/libappstream-builder/plugins/asb-plugin-gstreamer.c b/libappstream-builder/plugins/asb-plugin-gstreamer.c
index 9f0c710..8c5a8a4 100644
--- a/libappstream-builder/plugins/asb-plugin-gstreamer.c
+++ b/libappstream-builder/plugins/asb-plugin-gstreamer.c
@@ -42,17 +42,6 @@ asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
asb_plugin_add_glob (globs, "/usr/lib64/gstreamer-1.0/libgst*.so");
}
-/**
- * asb_plugin_check_filename:
- */
-gboolean
-asb_plugin_check_filename (AsbPlugin *plugin, const gchar *filename)
-{
- if (asb_plugin_match_glob ("/usr/lib64/gstreamer-1.0/libgst*.so", filename))
- return TRUE;
- return FALSE;
-}
-
typedef struct {
const gchar *path;
const gchar *text;
@@ -117,98 +106,26 @@ asb_utils_is_file_in_tmpdir (const gchar *tmpdir, const gchar *filename)
}
/**
- * asb_utils_string_sort_cb:
- */
-static gint
-asb_utils_string_sort_cb (gconstpointer a, gconstpointer b)
-{
- return g_strcmp0 (*((const gchar **) a), *((const gchar **) b));
-}
-
-/**
- * asb_plugin_process:
+ * asb_plugin_process_app:
*/
-GList *
-asb_plugin_process (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *tmpdir,
- GError **error)
+gboolean
+asb_plugin_process_app (AsbPlugin *plugin,
+ AsbPackage *pkg,
+ AsbApp *app,
+ const gchar *tmpdir,
+ GError **error)
{
- const gchar *tmp;
- gchar **split;
- GList *apps = NULL;
- GPtrArray *keywords;
guint i;
guint j;
- g_autofree gchar *app_id = NULL;
- g_autoptr(AsbApp) app = NULL;
- g_autoptr(AsIcon) icon = NULL;
- g_autoptr(GString) str = NULL;
-
- /* use the pkgname suffix as the app-id */
- tmp = asb_package_get_name (pkg);
- if (g_str_has_prefix (tmp, "gstreamer1-"))
- tmp += 11;
- if (g_str_has_prefix (tmp, "gstreamer-"))
- tmp += 10;
- if (g_str_has_prefix (tmp, "plugins-"))
- tmp += 8;
- app_id = g_strdup_printf ("gstreamer-%s", tmp);
-
- /* create app */
- app = asb_app_new (pkg, app_id);
- as_app_set_id_kind (AS_APP (app), AS_ID_KIND_CODEC);
- as_app_set_name (AS_APP (app), "C", "GStreamer Multimedia Codecs");
- asb_app_set_requires_appdata (app, TRUE);
- asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
- as_app_add_category (AS_APP (app), "Addons");
- as_app_add_category (AS_APP (app), "Codecs");
-
- /* add icon */
- icon = as_icon_new ();
- as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
- as_icon_set_name (icon, "application-x-executable");
- as_app_add_icon (AS_APP (app), icon);
for (i = 0; data[i].path != NULL; i++) {
+ g_auto(GStrv) split = NULL;
if (!asb_utils_is_file_in_tmpdir (tmpdir, data[i].path))
continue;
split = g_strsplit (data[i].text, "|", -1);
for (j = 0; split[j] != NULL; j++)
as_app_add_keyword (AS_APP (app), NULL, split[j]);
- g_strfreev (split);
- }
-
- /* no codecs we care about */
- keywords = as_app_get_keywords (AS_APP (app), NULL);
- if (keywords == NULL) {
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "nothing interesting in %s",
- asb_package_get_basename (pkg));
- return NULL;
- }
-
- /* sort categories by name */
- g_ptr_array_sort (keywords, asb_utils_string_sort_cb);
-
- /* create a description */
- str = g_string_new ("Multimedia playback for ");
- if (keywords->len > 1) {
- for (i = 0; i < keywords->len - 1; i++) {
- tmp = g_ptr_array_index (keywords, i);
- g_string_append_printf (str, "%s, ", tmp);
- }
- g_string_truncate (str, str->len - 2);
- tmp = g_ptr_array_index (keywords, keywords->len - 1);
- g_string_append_printf (str, " and %s", tmp);
- } else {
- g_string_append (str, g_ptr_array_index (keywords, 0));
}
- as_app_set_comment (AS_APP (app), "C", str->str);
- /* add */
- asb_plugin_add_app (&apps, AS_APP (app));
- return apps;
+ return TRUE;
}
diff --git a/libappstream-builder/plugins/asb-plugin-hardcoded.c b/libappstream-builder/plugins/asb-plugin-hardcoded.c
index b2e7396..d17271b 100644
--- a/libappstream-builder/plugins/asb-plugin-hardcoded.c
+++ b/libappstream-builder/plugins/asb-plugin-hardcoded.c
@@ -222,18 +222,6 @@ asb_plugin_process_app (AsbPlugin *plugin,
as_app_add_veto (AS_APP (app), "Uses obsolete Elektra library");
break;
}
- if (g_strcmp0 (tmp, "libXt.so.6") == 0) {
- asb_app_add_requires_appdata (app, "Uses obsolete X11 toolkit");
- break;
- }
- if (g_strcmp0 (tmp, "Xvfb") == 0) {
- asb_app_add_requires_appdata (app, "Uses obsolete Xvfb");
- break;
- }
- if (g_strcmp0 (tmp, "wine-core") == 0) {
- asb_app_add_requires_appdata (app, "Uses wine");
- break;
- }
}
}
@@ -261,21 +249,21 @@ asb_plugin_process_app (AsbPlugin *plugin,
secs = (g_get_real_time () / G_USEC_PER_SEC) -
as_release_get_timestamp (release);
days = secs / (60 * 60 * 24);
- /* we need AppData if the app needs saving */
if (secs > 0 && days > 365 * 5) {
- asb_app_add_requires_appdata (app,
- "Dead upstream for > %i years", 5);
+ asb_package_log (asb_app_get_package (app),
+ ASB_PACKAGE_LOG_LEVEL_WARNING,
+ "Dead upstream for > %i years", 5);
}
}
/* a ConsoleOnly category means we require AppData */
if (as_app_has_category (AS_APP(app), "ConsoleOnly"))
- asb_app_add_requires_appdata (app, "ConsoleOnly");
+ as_app_add_veto (AS_APP (app), "ConsoleOnly");
- /* no categories means we require AppData */
- if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_DESKTOP &&
- as_app_get_categories(AS_APP(app))->len == 0)
- asb_app_add_requires_appdata (app, "no Categories");
+ /* no categories means veto */
+// if (as_app_get_id_kind (AS_APP (app)) == AS_ID_KIND_DESKTOP &&
+// as_app_get_categories(AS_APP(app))->len == 0)
+// as_app_add_veto (AS_APP (app), "no Categories");
return TRUE;
}
diff --git a/libappstream-builder/plugins/asb-plugin-ibus-sql.c b/libappstream-builder/plugins/asb-plugin-ibus-sql.c
deleted file mode 100644
index 6a6919c..0000000
--- a/libappstream-builder/plugins/asb-plugin-ibus-sql.c
+++ /dev/null
@@ -1,264 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
- *
- * Licensed under the GNU Lesser General Public License Version 2.1
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <config.h>
-#include <fnmatch.h>
-#include <sqlite3.h>
-
-#include <asb-plugin.h>
-
-/**
- * asb_plugin_get_name:
- */
-const gchar *
-asb_plugin_get_name (void)
-{
- return "ibus-sqlite";
-}
-
-/**
- * asb_plugin_add_globs:
- */
-void
-asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
-{
- asb_plugin_add_glob (globs, "/usr/share/ibus-table/tables/*.db");
-}
-
-/**
- * _asb_plugin_check_filename:
- */
-static gboolean
-_asb_plugin_check_filename (const gchar *filename)
-{
- if (asb_plugin_match_glob ("/usr/share/ibus-table/tables/*.db", filename))
- return TRUE;
- return FALSE;
-}
-
-/**
- * asb_plugin_check_filename:
- */
-gboolean
-asb_plugin_check_filename (AsbPlugin *plugin, const gchar *filename)
-{
- return _asb_plugin_check_filename (filename);
-}
-
-/**
- * asb_plugin_sqlite_callback_cb:
- */
-static int
-asb_plugin_sqlite_callback_cb (void *user_data, int argc, char **argv, char **data)
-{
- gchar **tmp = (gchar **) user_data;
- *tmp = g_strdup (argv[1]);
- return 0;
-}
-
-/**
- * asb_plugin_process_filename:
- */
-static gboolean
-asb_plugin_process_filename (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *filename,
- GList **apps,
- const gchar *tmpdir,
- GError **error)
-{
- gboolean ret = TRUE;
- gchar *error_msg = 0;
- gchar *filename_tmp;
- gint rc;
- guint i;
- sqlite3 *db = NULL;
- g_autofree gchar *basename = NULL;
- g_autofree gchar *description = NULL;
- g_autofree gchar *language_string = NULL;
- g_autofree gchar *name = NULL;
- g_autofree gchar *symbol = NULL;
- g_autoptr(AsbApp) app = NULL;
- g_autoptr(AsIcon) icon = NULL;
- g_auto(GStrv) languages = NULL;
-
- /* open IME database */
- filename_tmp = g_build_filename (tmpdir, filename, NULL);
- rc = sqlite3_open (filename_tmp, &db);
- if (rc) {
- ret = FALSE;
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "Can't open database: %s",
- sqlite3_errmsg (db));
- goto out;
- }
-
- /* get name */
- rc = sqlite3_exec(db, "SELECT * FROM ime WHERE attr = 'name' LIMIT 1;",
- asb_plugin_sqlite_callback_cb,
- &name, &error_msg);
- if (rc != SQLITE_OK) {
- ret = FALSE;
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "Can't get IME name from %s: %s",
- filename, error_msg);
- sqlite3_free(error_msg);
- goto out;
- }
-
- /* get symbol */
- rc = sqlite3_exec(db, "SELECT * FROM ime WHERE attr = 'symbol' LIMIT 1;",
- asb_plugin_sqlite_callback_cb,
- &symbol, &error_msg);
- if (rc != SQLITE_OK) {
- ret = FALSE;
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "Can't get IME symbol from %s: %s",
- filename, error_msg);
- sqlite3_free(error_msg);
- goto out;
- }
-
- /* get languages */
- rc = sqlite3_exec(db, "SELECT * FROM ime WHERE attr = 'languages' LIMIT 1;",
- asb_plugin_sqlite_callback_cb,
- &language_string, &error_msg);
- if (rc != SQLITE_OK) {
- ret = FALSE;
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "Can't get IME languages from %s: %s",
- filename, error_msg);
- sqlite3_free(error_msg);
- goto out;
- }
-
- /* get description */
- rc = sqlite3_exec(db, "SELECT * FROM ime WHERE attr = 'description' LIMIT 1;",
- asb_plugin_sqlite_callback_cb,
- &description, &error_msg);
- if (rc != SQLITE_OK) {
- ret = FALSE;
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "Can't get IME name from %s: %s",
- filename, error_msg);
- sqlite3_free(error_msg);
- goto out;
- }
-
- /* this is _required_ */
- if (name == NULL || description == NULL) {
- ret = FALSE;
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "No 'name' and 'description' in %s",
- filename);
- goto out;
- }
-
- /* create new app */
- basename = g_path_get_basename (filename);
- app = asb_app_new (pkg, basename);
- as_app_set_id_kind (AS_APP (app), AS_ID_KIND_INPUT_METHOD);
- as_app_add_category (AS_APP (app), "Addons");
- as_app_add_category (AS_APP (app), "InputSources");
- as_app_set_name (AS_APP (app), "C", name);
- as_app_set_comment (AS_APP (app), "C", description);
- if (symbol != NULL && symbol[0] != '\0')
- as_app_add_metadata (AS_APP (app), "X-IBus-Symbol", symbol);
- if (language_string != NULL) {
- languages = g_strsplit (language_string, ",", -1);
- for (i = 0; languages[i] != NULL; i++) {
- if (g_strcmp0 (languages[i], "other") == 0)
- continue;
- as_app_add_language (AS_APP (app),
- 100, languages[i]);
- }
- }
- asb_app_set_requires_appdata (app, TRUE);
- asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
-
- /* add icon */
- icon = as_icon_new ();
- as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
- as_icon_set_name (icon, "system-run-symbolic");
- as_app_add_icon (AS_APP (app), icon);
-
- asb_plugin_add_app (apps, AS_APP (app));
-out:
- if (db != NULL)
- sqlite3_close (db);
- return ret;
-}
-
-/**
- * asb_plugin_process:
- */
-GList *
-asb_plugin_process (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *tmpdir,
- GError **error)
-{
- gboolean ret;
- GList *apps = NULL;
- guint i;
- gchar **filelist;
-
- filelist = asb_package_get_filelist (pkg);
- for (i = 0; filelist[i] != NULL; i++) {
- if (!_asb_plugin_check_filename (filelist[i]))
- continue;
- ret = asb_plugin_process_filename (plugin,
- pkg,
- filelist[i],
- &apps,
- tmpdir,
- error);
- if (!ret) {
- g_list_free_full (apps, (GDestroyNotify) g_object_unref);
- apps = NULL;
- goto out;
- }
- }
-
- /* no desktop files we care about */
- if (apps == NULL) {
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "nothing interesting in %s",
- asb_package_get_basename (pkg));
- goto out;
- }
-out:
- return apps;
-}
diff --git a/libappstream-builder/plugins/asb-plugin-ibus-xml.c b/libappstream-builder/plugins/asb-plugin-ibus-xml.c
deleted file mode 100644
index f5180fb..0000000
--- a/libappstream-builder/plugins/asb-plugin-ibus-xml.c
+++ /dev/null
@@ -1,224 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
- *
- * Licensed under the GNU Lesser General Public License Version 2.1
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <config.h>
-#include <fnmatch.h>
-#include <sqlite3.h>
-#include <appstream-glib.h>
-
-#include <asb-plugin.h>
-
-/**
- * asb_plugin_get_name:
- */
-const gchar *
-asb_plugin_get_name (void)
-{
- return "ibus-xml";
-}
-
-/**
- * asb_plugin_add_globs:
- */
-void
-asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
-{
- asb_plugin_add_glob (globs, "/usr/share/ibus/component/*.xml");
-}
-
-/**
- * _asb_plugin_check_filename:
- */
-static gboolean
-_asb_plugin_check_filename (const gchar *filename)
-{
- if (asb_plugin_match_glob ("/usr/share/ibus/component/*.xml", filename))
- return TRUE;
- return FALSE;
-}
-
-/**
- * asb_plugin_check_filename:
- */
-gboolean
-asb_plugin_check_filename (AsbPlugin *plugin, const gchar *filename)
-{
- return _asb_plugin_check_filename (filename);
-}
-
-/**
- * asb_plugin_process_filename:
- */
-static gboolean
-asb_plugin_process_filename (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *filename,
- GList **apps,
- const gchar *tmpdir,
- GError **error)
-{
- GNode *root = NULL;
- GString *valid_xml;
- const gchar *tmp;
- const GNode *n;
- gboolean found_header = FALSE;
- gboolean ret;
- guint i;
- g_autofree gchar *basename = NULL;
- g_autofree gchar *data = NULL;
- g_autofree gchar *filename_tmp = NULL;
- g_autoptr(AsbApp) app = NULL;
- g_autoptr(AsIcon) icon = NULL;
- g_auto(GStrv) languages = NULL;
- g_auto(GStrv) lines = NULL;
-
- /* open file */
- filename_tmp = g_build_filename (tmpdir, filename, NULL);
- ret = g_file_get_contents (filename_tmp, &data, NULL, error);
- if (!ret)
- goto out;
-
- /* some components start with a comment (invalid XML) and some
- * don't even have '<?xml' -- try to fix up best we can */
- valid_xml = g_string_new ("");
- lines = g_strsplit (data, "\n", -1);
- for (i = 0; lines[i] != NULL; i++) {
- if (g_str_has_prefix (lines[i], "<?xml") ||
- g_str_has_prefix (lines[i], "<component>"))
- found_header = TRUE;
- if (found_header)
- g_string_append_printf (valid_xml, "%s\n", lines[i]);
- }
-
- /* parse contents */
- root = as_node_from_xml (valid_xml->str,
- AS_NODE_FROM_XML_FLAG_NONE,
- error);
- if (!ret)
- goto out;
-
- /* create new app */
- basename = g_path_get_basename (filename);
- app = asb_app_new (pkg, basename);
- as_app_set_id_kind (AS_APP (app), AS_ID_KIND_INPUT_METHOD);
- as_app_add_category (AS_APP (app), "Addons");
- as_app_add_category (AS_APP (app), "InputSources");
- asb_app_set_requires_appdata (app, TRUE);
- asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
-
- /* add icon */
- icon = as_icon_new ();
- as_icon_set_kind (icon, AS_ICON_KIND_STOCK);
- as_icon_set_name (icon, "system-run-symbolic");
- as_app_add_icon (AS_APP (app), icon);
-
- /* read the component header which all input methods have */
- n = as_node_find (root, "component/description");
- if (n != NULL) {
- as_app_set_name (AS_APP (app), "C", as_node_get_data (n));
- as_app_set_comment (AS_APP (app), "C", as_node_get_data (n));
- }
- n = as_node_find (root, "component/homepage");
- if (n != NULL) {
- as_app_add_url (AS_APP (app),
- AS_URL_KIND_HOMEPAGE,
- as_node_get_data (n));
- }
-
- /* do we have a engine section we can use? */
- n = as_node_find (root, "component/engines/engine/longname");
- if (n != NULL)
- as_app_set_name (AS_APP (app), "C", as_node_get_data (n));
- n = as_node_find (root, "component/engines/engine/description");
- if (n != NULL)
- as_app_set_comment (AS_APP (app), "C", as_node_get_data (n));
- n = as_node_find (root, "component/engines/engine/symbol");
- if (n != NULL) {
- tmp = as_node_get_data (n);
- if (tmp != NULL && tmp[0] != '\0') {
- as_app_add_metadata (AS_APP (app),
- "X-IBus-Symbol",
- tmp);
- }
- }
- n = as_node_find (root, "component/engines/engine/language");
- if (n != NULL) {
- tmp = as_node_get_data (n);
- if (tmp != NULL) {
- languages = g_strsplit (tmp, ",", -1);
- for (i = 0; languages[i] != NULL; i++) {
- if (g_strcmp0 (languages[i], "other") == 0)
- continue;
- as_app_add_language (AS_APP (app),
- 100, languages[i]);
- }
- }
- }
-
- /* add */
- asb_plugin_add_app (apps, AS_APP (app));
-out:
- if (root != NULL)
- as_node_unref (root);
- return ret;
-}
-
-/**
- * asb_plugin_process:
- */
-GList *
-asb_plugin_process (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *tmpdir,
- GError **error)
-{
- gboolean ret;
- GList *apps = NULL;
- guint i;
- gchar **filelist;
-
- filelist = asb_package_get_filelist (pkg);
- for (i = 0; filelist[i] != NULL; i++) {
- if (!_asb_plugin_check_filename (filelist[i]))
- continue;
- ret = asb_plugin_process_filename (plugin,
- pkg,
- filelist[i],
- &apps,
- tmpdir,
- error);
- if (!ret) {
- g_list_free_full (apps, (GDestroyNotify) g_object_unref);
- return NULL;
- }
- }
-
- /* no desktop files we care about */
- if (apps == NULL) {
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "nothing interesting in %s",
- asb_package_get_basename (pkg));
- return NULL;
- }
- return apps;
-}
diff --git a/libappstream-builder/plugins/asb-plugin-metainfo.c b/libappstream-builder/plugins/asb-plugin-metainfo.c
deleted file mode 100644
index 5f54d65..0000000
--- a/libappstream-builder/plugins/asb-plugin-metainfo.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2014-2015 Richard Hughes <richard@hughsie.com>
- *
- * Licensed under the GNU Lesser General Public License Version 2.1
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <config.h>
-#include <fnmatch.h>
-
-#include <asb-plugin.h>
-
-/**
- * asb_plugin_get_name:
- */
-const gchar *
-asb_plugin_get_name (void)
-{
- return "metainfo";
-}
-
-/**
- * asb_plugin_add_globs:
- */
-void
-asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
-{
- asb_plugin_add_glob (globs, "/usr/share/appdata/*.metainfo.xml");
-}
-
-/**
- * _asb_plugin_check_filename:
- */
-static gboolean
-_asb_plugin_check_filename (const gchar *filename)
-{
- if (asb_plugin_match_glob ("/usr/share/appdata/*.metainfo.xml", filename))
- return TRUE;
- return FALSE;
-}
-
-/**
- * asb_plugin_check_filename:
- */
-gboolean
-asb_plugin_check_filename (AsbPlugin *plugin, const gchar *filename)
-{
- return _asb_plugin_check_filename (filename);
-}
-
-/**
- * asb_plugin_process_filename:
- */
-static gboolean
-asb_plugin_process_filename (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *filename,
- GList **apps,
- GError **error)
-{
- g_autoptr(AsbApp) app = NULL;
-
- app = asb_app_new (pkg, NULL);
- if (!as_app_parse_file (AS_APP (app), filename,
- AS_APP_PARSE_FLAG_APPEND_DATA,
- error))
- return FALSE;
- if (as_app_get_id_kind (AS_APP (app)) != AS_ID_KIND_ADDON &&
- as_app_get_id_kind (AS_APP (app)) != AS_ID_KIND_FONT) {
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "%s is not an addon or font",
- as_app_get_id (AS_APP (app)));
- return FALSE;
- }
- asb_app_set_requires_appdata (app, FALSE);
- asb_app_set_hidpi_enabled (app, asb_context_get_flag (plugin->ctx, ASB_CONTEXT_FLAG_HIDPI_ICONS));
- asb_plugin_add_app (apps, AS_APP (app));
- return TRUE;
-}
-
-/**
- * asb_plugin_process:
- */
-GList *
-asb_plugin_process (AsbPlugin *plugin,
- AsbPackage *pkg,
- const gchar *tmpdir,
- GError **error)
-{
- gboolean ret;
- GList *apps = NULL;
- guint i;
- gchar **filelist;
-
- filelist = asb_package_get_filelist (pkg);
- for (i = 0; filelist[i] != NULL; i++) {
- g_autofree gchar *filename_tmp = NULL;
- if (!_asb_plugin_check_filename (filelist[i]))
- continue;
- filename_tmp = g_build_filename (tmpdir, filelist[i], NULL);
- ret = asb_plugin_process_filename (plugin,
- pkg,
- filename_tmp,
- &apps,
- error);
- if (!ret) {
- g_list_free_full (apps, (GDestroyNotify) g_object_unref);
- return NULL;
- }
- }
-
- /* no desktop files we care about */
- if (apps == NULL) {
- g_set_error (error,
- ASB_PLUGIN_ERROR,
- ASB_PLUGIN_ERROR_FAILED,
- "nothing interesting in %s",
- asb_package_get_basename (pkg));
- return NULL;
- }
- return apps;
-}
-
-/**
- * asb_plugin_merge:
- */
-void
-asb_plugin_merge (AsbPlugin *plugin, GList *list)
-{
- AsApp *app;
- AsApp *found;
- GList *l;
- g_autoptr(GHashTable) hash = NULL;
-
- /* make a hash table of ID->AsApp */
- hash = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free, (GDestroyNotify) g_object_unref);
- for (l = list; l != NULL; l = l->next) {
- app = AS_APP (l->data);
- if (as_app_get_id_kind (app) != AS_ID_KIND_DESKTOP)
- continue;
- g_hash_table_insert (hash,
- g_strdup (as_app_get_id (app)),
- g_object_ref (app));
- }
-
- /* add addons where the pkgname is different from the
- * main package */
- for (l = list; l != NULL; l = l->next) {
- if (!ASB_IS_APP (l->data))
- continue;
- app = AS_APP (l->data);
- if (as_app_get_id_kind (app) != AS_ID_KIND_ADDON)
- continue;
- found = g_hash_table_lookup (hash, as_app_get_id (app));
- if (found == NULL)
- continue;
- if (g_strcmp0 (as_app_get_pkgname_default (app),
- as_app_get_pkgname_default (found)) != 0)
- continue;
- as_app_add_veto (app,
- "absorbing addon %s shipped in "
- "main package %s",
- as_app_get_id (app),
- as_app_get_pkgname_default (app));
- as_app_subsume_full (found, app, AS_APP_SUBSUME_FLAG_PARTIAL);
- }
-}