summaryrefslogtreecommitdiff
path: root/libappstream-builder/plugins
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2016-01-31 19:55:13 +0000
committerRichard Hughes <richard@hughsie.com>2016-01-31 20:31:14 +0000
commitbfc6783eccc7e4d67d43011fdfaf88cf5972bc83 (patch)
treecc8cb773f7eb70818dec8d47643612d9bdfe35a7 /libappstream-builder/plugins
parentd85558dbf74025bddfae6a369d77bc95654e1d91 (diff)
downloadappstream-glib-bfc6783eccc7e4d67d43011fdfaf88cf5972bc83.tar.gz
Move the kudo and provides autodetection to libappstream-glib
Diffstat (limited to 'libappstream-builder/plugins')
-rw-r--r--libappstream-builder/plugins/Makefile.am6
-rw-r--r--libappstream-builder/plugins/asb-plugin-dbus.c128
-rw-r--r--libappstream-builder/plugins/asb-plugin-hardcoded.c34
3 files changed, 15 insertions, 153 deletions
diff --git a/libappstream-builder/plugins/Makefile.am b/libappstream-builder/plugins/Makefile.am
index 3709321..b933ed2 100644
--- a/libappstream-builder/plugins/Makefile.am
+++ b/libappstream-builder/plugins/Makefile.am
@@ -16,7 +16,6 @@ plugindir = $(libdir)/asb-plugins-$(AS_PLUGIN_VERSION)
plugin_LTLIBRARIES = \
libasb_plugin_absorb.la \
libasb_plugin_appdata.la \
- libasb_plugin_dbus.la \
libasb_plugin_desktop.la \
libasb_plugin_gettext.la \
libasb_plugin_hardcoded.la
@@ -26,11 +25,6 @@ plugin_LTLIBRARIES += \
libasb_plugin_font.la
endif
-libasb_plugin_dbus_la_SOURCES = asb-plugin-dbus.c
-libasb_plugin_dbus_la_LIBADD = $(GLIB_LIBS)
-libasb_plugin_dbus_la_LDFLAGS = -module -avoid-version
-libasb_plugin_dbus_la_CFLAGS = $(GLIB_CFLAGS) $(WARNINGFLAGS_C)
-
libasb_plugin_absorb_la_SOURCES = asb-plugin-absorb.c
libasb_plugin_absorb_la_LIBADD = $(GLIB_LIBS)
libasb_plugin_absorb_la_LDFLAGS = -module -avoid-version
diff --git a/libappstream-builder/plugins/asb-plugin-dbus.c b/libappstream-builder/plugins/asb-plugin-dbus.c
deleted file mode 100644
index c0a861f..0000000
--- a/libappstream-builder/plugins/asb-plugin-dbus.c
+++ /dev/null
@@ -1,128 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2014 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 "dbus";
-}
-
-/**
- * asb_plugin_add_globs:
- */
-void
-asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
-{
- asb_plugin_add_glob (globs, "/usr/share/dbus-1/system-services/*.service");
- asb_plugin_add_glob (globs, "/usr/share/dbus-1/services/*.service");
-}
-
-/**
- * _asb_plugin_check_filename_system:
- */
-static gboolean
-_asb_plugin_check_filename_system (const gchar *filename)
-{
- if (asb_plugin_match_glob ("/usr/share/dbus-1/system-services/*.service", filename))
- return TRUE;
- return FALSE;
-}
-
-/**
- * _asb_plugin_check_filename_session:
- */
-static gboolean
-_asb_plugin_check_filename_session (const gchar *filename)
-{
- if (asb_plugin_match_glob ("/usr/share/dbus-1/services/*.service", filename))
- return TRUE;
- return FALSE;
-}
-
-/**
- * asb_plugin_process_dbus:
- */
-static gboolean
-asb_plugin_process_dbus (AsbApp *app,
- const gchar *tmpdir,
- const gchar *filename,
- gboolean is_system,
- GError **error)
-{
- g_autofree gchar *filename_full = NULL;
- g_autofree gchar *name = NULL;
- g_autoptr(GKeyFile) kf = NULL;
- g_autoptr(AsProvide) provide = NULL;
-
- /* load file */
- filename_full = g_build_filename (tmpdir, filename, NULL);
- kf = g_key_file_new ();
- if (!g_key_file_load_from_file (kf, filename_full, G_KEY_FILE_NONE, error))
- return FALSE;
- name = g_key_file_get_string (kf, "D-BUS Service", "Name", error);
- if (name == NULL)
- return FALSE;
-
- /* add provide */
- provide = as_provide_new ();
- as_provide_set_kind (provide, is_system ? AS_PROVIDE_KIND_DBUS_SYSTEM :
- AS_PROVIDE_KIND_DBUS_SESSION);
- as_provide_set_value (provide, name);
- as_app_add_provide (AS_APP (app), provide);
- return TRUE;
-}
-
-/**
- * asb_plugin_process_app:
- */
-gboolean
-asb_plugin_process_app (AsbPlugin *plugin,
- AsbPackage *pkg,
- AsbApp *app,
- const gchar *tmpdir,
- GError **error)
-{
- gchar **filelist;
- guint i;
-
- /* look for any GIR files */
- filelist = asb_package_get_filelist (pkg);
- for (i = 0; filelist[i] != NULL; i++) {
- if (_asb_plugin_check_filename_system (filelist[i])) {
- if (!asb_plugin_process_dbus (app, tmpdir, filelist[i],
- TRUE, error))
- return FALSE;
- } else if (_asb_plugin_check_filename_session (filelist[i])) {
- if (!asb_plugin_process_dbus (app, tmpdir, filelist[i],
- FALSE, error))
- return FALSE;
- }
- }
- return TRUE;
-}
diff --git a/libappstream-builder/plugins/asb-plugin-hardcoded.c b/libappstream-builder/plugins/asb-plugin-hardcoded.c
index f15e15c..25334f1 100644
--- a/libappstream-builder/plugins/asb-plugin-hardcoded.c
+++ b/libappstream-builder/plugins/asb-plugin-hardcoded.c
@@ -40,6 +40,8 @@ asb_plugin_add_globs (AsbPlugin *plugin, GPtrArray *globs)
{
asb_plugin_add_glob (globs, "/usr/share/help/*");
asb_plugin_add_glob (globs, "/usr/share/gnome-shell/search-providers/*");
+ asb_plugin_add_glob (globs, "/usr/share/dbus-1/system-services/*.service");
+ asb_plugin_add_glob (globs, "/usr/share/dbus-1/services/*.service");
}
/**
@@ -56,6 +58,7 @@ asb_plugin_process_app (AsbPlugin *plugin,
GPtrArray *deps;
gchar **filelist;
guint i;
+ g_autofree gchar *prefix = NULL;
/* look for any installed docs */
filelist = asb_package_get_filelist (pkg);
@@ -71,19 +74,18 @@ asb_plugin_process_app (AsbPlugin *plugin,
}
}
- /* look for a shell search provider */
- for (i = 0; filelist[i] != NULL; i++) {
- if (asb_plugin_match_glob ("/usr/share/gnome-shell/search-providers/*",
- filelist[i])) {
- asb_package_log (pkg,
- ASB_PACKAGE_LOG_LEVEL_DEBUG,
- "Auto-adding kudo SearchProvider for %s",
- as_app_get_id (AS_APP (app)));
- as_app_add_kudo_kind (AS_APP (app),
- AS_KUDO_KIND_SEARCH_PROVIDER);
- break;
- }
- }
+ /* look for kudos and provides */
+ prefix = g_build_filename (tmpdir, "usr", NULL);
+ if (!as_app_builder_search_kudos (AS_APP (app),
+ prefix,
+ AS_APP_BUILDER_FLAG_USE_FALLBACKS,
+ error))
+ return FALSE;
+ if (!as_app_builder_search_provides (AS_APP (app),
+ prefix,
+ AS_APP_BUILDER_FLAG_USE_FALLBACKS,
+ error))
+ return FALSE;
/* look for a high contrast icon */
for (i = 0; filelist[i] != NULL; i++) {
@@ -93,12 +95,6 @@ asb_plugin_process_app (AsbPlugin *plugin,
AS_KUDO_KIND_HIGH_CONTRAST);
break;
}
- if (asb_plugin_match_glob ("/usr/share/icons/hicolor/symbolic/apps/*.svg",
- filelist[i])) {
- as_app_add_kudo_kind (AS_APP (app),
- AS_KUDO_KIND_HIGH_CONTRAST);
- break;
- }
}
/* look for a modern toolkit */