[gnome-software] Infer the plugin name from the filename
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Infer the plugin name from the filename
- Date: Thu, 21 Apr 2016 18:00:30 +0000 (UTC)
commit a7d9bdd863479e74103e998ba5dbd368cdbfcaba
Author: Richard Hughes <richard hughsie com>
Date: Thu Apr 21 18:34:54 2016 +0100
Infer the plugin name from the filename
There was only one plugin not matching and that was a typo. This allows us to
reuse the gs_plugin_get_name() symbol in our sealing effort.
src/gs-plugin.c | 29 +++++++++++++----------
src/gs-plugin.h | 1 -
src/plugins/Makefile.am | 2 +-
src/plugins/gs-plugin-appstream.c | 9 -------
src/plugins/gs-plugin-dpkg.c | 9 -------
src/plugins/gs-plugin-dummy.c | 9 -------
src/plugins/gs-plugin-epiphany.c | 9 -------
src/plugins/gs-plugin-fedora-distro-upgrades.c | 9 -------
src/plugins/gs-plugin-fedora-tagger-usage.c | 9 -------
src/plugins/gs-plugin-fwupd.c | 9 -------
src/plugins/gs-plugin-hardcoded-blacklist.c | 9 -------
src/plugins/gs-plugin-icons.c | 9 -------
src/plugins/gs-plugin-limba.c | 9 -------
src/plugins/gs-plugin-menu-spec-categories.c | 9 -------
src/plugins/gs-plugin-menu-spec-refine.c | 9 -------
src/plugins/gs-plugin-odrs.c | 9 -------
src/plugins/gs-plugin-ostree.c | 9 -------
src/plugins/gs-plugin-packagekit-history.c | 9 -------
src/plugins/gs-plugin-packagekit-offline.c | 9 -------
src/plugins/gs-plugin-packagekit-origin.c | 9 -------
src/plugins/gs-plugin-packagekit-proxy.c | 9 -------
src/plugins/gs-plugin-packagekit-refine.c | 9 -------
src/plugins/gs-plugin-packagekit-refresh.c | 9 -------
src/plugins/gs-plugin-packagekit.c | 9 -------
src/plugins/gs-plugin-provenance.c | 9 -------
src/plugins/gs-plugin-rpm.c | 9 -------
src/plugins/gs-plugin-shell-extensions.c | 9 -------
src/plugins/gs-plugin-steam.c | 9 -------
src/plugins/gs-plugin-systemd-updates.c | 9 -------
src/plugins/gs-plugin-ubuntu-reviews.c | 6 -----
src/plugins/gs-plugin-xdg-app.c | 9 -------
31 files changed, 17 insertions(+), 264 deletions(-)
---
diff --git a/src/gs-plugin.c b/src/gs-plugin.c
index 3754026..4dcfb37 100644
--- a/src/gs-plugin.c
+++ b/src/gs-plugin.c
@@ -63,7 +63,6 @@ struct GsPluginPrivate {
guint timer_id;
};
-typedef const gchar *(*GsPluginGetNameFunc) (void);
typedef const gchar **(*GsPluginGetDepsFunc) (GsPlugin *plugin);
#define gs_plugin_get_instance_private(p) (p->priv);
@@ -118,29 +117,33 @@ GsPlugin *
gs_plugin_create (const gchar *filename, GError **error)
{
GModule *module;
- GsPluginGetNameFunc plugin_name = NULL;
GsPluginGetDepsFunc order_after = NULL;
GsPluginGetDepsFunc order_before = NULL;
GsPluginGetDepsFunc plugin_conflicts = NULL;
GsPlugin *plugin = NULL;
- gboolean ret;
+ g_autofree gchar *basename = NULL;
module = g_module_open (filename, 0);
if (module == NULL) {
- g_warning ("failed to open plugin %s: %s",
- filename, g_module_error ());
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
+ "failed to open plugin %s: %s",
+ filename, g_module_error ());
return NULL;
}
- /* get description */
- ret = g_module_symbol (module,
- "gs_plugin_get_name",
- (gpointer *) &plugin_name);
- if (!ret) {
- g_warning ("Plugin %s requires name", filename);
- g_module_close (module);
+ /* get the plugin name from the basename */
+ basename = g_path_get_basename (filename);
+ if (!g_str_has_prefix (basename, "libgs_plugin_")) {
+ g_set_error (error,
+ GS_PLUGIN_ERROR,
+ GS_PLUGIN_ERROR_FAILED,
+ "plugin filename has wrong prefix: %s",
+ filename);
return NULL;
}
+ g_strdelimit (basename, ".", '\0');
/* get plugins this plugin depends on */
g_module_symbol (module,
@@ -159,7 +162,7 @@ gs_plugin_create (const gchar *filename, GError **error)
plugin->priv->order_after = order_after != NULL ? order_after (plugin) : NULL;
plugin->priv->order_before = order_before != NULL ? order_before (plugin) : NULL;
plugin->priv->conflicts = plugin_conflicts != NULL ? plugin_conflicts (plugin) : NULL;
- plugin->name = g_strdup (plugin_name ());
+ plugin->name = g_strdup (basename + 13);
return plugin;
}
diff --git a/src/gs-plugin.h b/src/gs-plugin.h
index 076a09c..c43d236 100644
--- a/src/gs-plugin.h
+++ b/src/gs-plugin.h
@@ -182,7 +182,6 @@ void gs_plugin_updates_changed (GsPlugin *plugin);
const gchar *gs_plugin_status_to_string (GsPluginStatus status);
/* vfuncs */
-const gchar *gs_plugin_get_name (void);
void gs_plugin_initialize (GsPlugin *plugin);
void gs_plugin_destroy (GsPlugin *plugin);
void gs_plugin_adopt_app (GsPlugin *plugin,
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index e4bb552..73922d7 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -64,7 +64,7 @@ plugin_LTLIBRARIES += libgs_plugin_fwupd.la
endif
if HAVE_XDG_APP
-plugin_LTLIBRARIES += libgs_plugin_xdg_app.la
+plugin_LTLIBRARIES += libgs_plugin_xdg-app.la
endif
if HAVE_OSTREE
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index 5cfdfaf..df1643d 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -45,15 +45,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "appstream";
-}
-
-/**
* gs_plugin_appstream_store_changed_cb:
*/
static void
diff --git a/src/plugins/gs-plugin-dpkg.c b/src/plugins/gs-plugin-dpkg.c
index 1708de9..f2108a3 100644
--- a/src/plugins/gs-plugin-dpkg.c
+++ b/src/plugins/gs-plugin-dpkg.c
@@ -29,15 +29,6 @@
#define DPKG_DEB_BINARY "/usr/bin/dpkg-deb"
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "dpkg";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-dummy.c b/src/plugins/gs-plugin-dummy.c
index 35ad51a..3115100 100644
--- a/src/plugins/gs-plugin-dummy.c
+++ b/src/plugins/gs-plugin-dummy.c
@@ -33,15 +33,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "dummy";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-epiphany.c b/src/plugins/gs-plugin-epiphany.c
index 145addb..fca73e2 100644
--- a/src/plugins/gs-plugin-epiphany.c
+++ b/src/plugins/gs-plugin-epiphany.c
@@ -38,15 +38,6 @@
*/
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "epiphany";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-fedora-distro-upgrades.c b/src/plugins/gs-plugin-fedora-distro-upgrades.c
index 5738cb1..aacb099 100644
--- a/src/plugins/gs-plugin-fedora-distro-upgrades.c
+++ b/src/plugins/gs-plugin-fedora-distro-upgrades.c
@@ -37,15 +37,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "fedora-distro-upgrades";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-fedora-tagger-usage.c b/src/plugins/gs-plugin-fedora-tagger-usage.c
index 2e7e21e..64c1db5 100644
--- a/src/plugins/gs-plugin-fedora-tagger-usage.c
+++ b/src/plugins/gs-plugin-fedora-tagger-usage.c
@@ -35,15 +35,6 @@
* It will self-disable if not run on a Fedora system.
*/
-/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "fedora-tagger-usage";
-}
-
#define GS_PLUGIN_FEDORA_TAGGER_SERVER "https://apps.fedoraproject.org/tagger"
/**
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 6d3cf50..3baca15 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -51,15 +51,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "fwupd";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-hardcoded-blacklist.c b/src/plugins/gs-plugin-hardcoded-blacklist.c
index e9de91b..85103b0 100644
--- a/src/plugins/gs-plugin-hardcoded-blacklist.c
+++ b/src/plugins/gs-plugin-hardcoded-blacklist.c
@@ -29,15 +29,6 @@
*/
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "hardcoded-blacklist";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-icons.c b/src/plugins/gs-plugin-icons.c
index 54531c3..e7fd022 100644
--- a/src/plugins/gs-plugin-icons.c
+++ b/src/plugins/gs-plugin-icons.c
@@ -38,15 +38,6 @@
*/
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "icons";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-limba.c b/src/plugins/gs-plugin-limba.c
index 3ba41bd..56a572f 100644
--- a/src/plugins/gs-plugin-limba.c
+++ b/src/plugins/gs-plugin-limba.c
@@ -36,15 +36,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "limba";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-menu-spec-categories.c b/src/plugins/gs-plugin-menu-spec-categories.c
index 5d56f6c..f3b38bb 100644
--- a/src/plugins/gs-plugin-menu-spec-categories.c
+++ b/src/plugins/gs-plugin-menu-spec-categories.c
@@ -33,15 +33,6 @@
*/
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "menu-spec-categories";
-}
-
-/**
* gs_plugin_add_categories:
*/
gboolean
diff --git a/src/plugins/gs-plugin-menu-spec-refine.c b/src/plugins/gs-plugin-menu-spec-refine.c
index c6fb49c..affa9f7 100644
--- a/src/plugins/gs-plugin-menu-spec-refine.c
+++ b/src/plugins/gs-plugin-menu-spec-refine.c
@@ -33,15 +33,6 @@
*/
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "menu-spec-refine";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-odrs.c b/src/plugins/gs-plugin-odrs.c
index 53629b4..7260467 100644
--- a/src/plugins/gs-plugin-odrs.c
+++ b/src/plugins/gs-plugin-odrs.c
@@ -47,15 +47,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "odrs";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-ostree.c b/src/plugins/gs-plugin-ostree.c
index 57cad40..2270165 100644
--- a/src/plugins/gs-plugin-ostree.c
+++ b/src/plugins/gs-plugin-ostree.c
@@ -34,15 +34,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "ostree";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-packagekit-history.c b/src/plugins/gs-plugin-packagekit-history.c
index 435cca5..8686879 100644
--- a/src/plugins/gs-plugin-packagekit-history.c
+++ b/src/plugins/gs-plugin-packagekit-history.c
@@ -38,15 +38,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "packagekit-history";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-packagekit-offline.c b/src/plugins/gs-plugin-packagekit-offline.c
index 554920f..d756c2c 100644
--- a/src/plugins/gs-plugin-packagekit-offline.c
+++ b/src/plugins/gs-plugin-packagekit-offline.c
@@ -34,15 +34,6 @@
* other users.
*/
-/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "packagekit-offline";
-}
-
#define PK_OFFLINE_UPDATE_RESULTS_GROUP "PackageKit Offline Update Results"
#define PK_OFFLINE_UPDATE_RESULTS_FILENAME "/var/lib/PackageKit/offline-update-competed"
diff --git a/src/plugins/gs-plugin-packagekit-origin.c b/src/plugins/gs-plugin-packagekit-origin.c
index 7ef0b51..ccd8bba 100644
--- a/src/plugins/gs-plugin-packagekit-origin.c
+++ b/src/plugins/gs-plugin-packagekit-origin.c
@@ -44,15 +44,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "packagekit-origin";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-packagekit-proxy.c b/src/plugins/gs-plugin-packagekit-proxy.c
index f840cdc..375f1bc 100644
--- a/src/plugins/gs-plugin-packagekit-proxy.c
+++ b/src/plugins/gs-plugin-packagekit-proxy.c
@@ -42,15 +42,6 @@ struct GsPluginData {
GSettings *settings_ftp;
};
-/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "packagekit-proxy";
-}
-
static gchar *
get_proxy_http (GsPlugin *plugin)
{
diff --git a/src/plugins/gs-plugin-packagekit-refine.c b/src/plugins/gs-plugin-packagekit-refine.c
index 2d3accc..e211d43 100644
--- a/src/plugins/gs-plugin-packagekit-refine.c
+++ b/src/plugins/gs-plugin-packagekit-refine.c
@@ -48,15 +48,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "packagekit-refine";
-}
-
-/**
* gs_plugin_get_conflicts:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-packagekit-refresh.c b/src/plugins/gs-plugin-packagekit-refresh.c
index e6598b0..feadaea 100644
--- a/src/plugins/gs-plugin-packagekit-refresh.c
+++ b/src/plugins/gs-plugin-packagekit-refresh.c
@@ -41,15 +41,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "packagekit-refresh";
-}
-
-/**
* gs_plugin_get_conflicts:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-packagekit.c b/src/plugins/gs-plugin-packagekit.c
index f991c89..e2b4ac4 100644
--- a/src/plugins/gs-plugin-packagekit.c
+++ b/src/plugins/gs-plugin-packagekit.c
@@ -43,15 +43,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "packagekit";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-provenance.c b/src/plugins/gs-plugin-provenance.c
index 4b3afae..e1013b3 100644
--- a/src/plugins/gs-plugin-provenance.c
+++ b/src/plugins/gs-plugin-provenance.c
@@ -37,15 +37,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "provenance";
-}
-
-/**
* gs_plugin_provenance_get_sources:
*/
static gchar **
diff --git a/src/plugins/gs-plugin-rpm.c b/src/plugins/gs-plugin-rpm.c
index f5cfe6b..2e5c5f7 100644
--- a/src/plugins/gs-plugin-rpm.c
+++ b/src/plugins/gs-plugin-rpm.c
@@ -29,15 +29,6 @@
#include <gs-plugin.h>
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "rpm";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-shell-extensions.c b/src/plugins/gs-plugin-shell-extensions.c
index 0b71140..e6edd00 100644
--- a/src/plugins/gs-plugin-shell-extensions.c
+++ b/src/plugins/gs-plugin-shell-extensions.c
@@ -65,15 +65,6 @@ typedef enum {
} GsPluginShellExtensionKind;
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "shell-extensions";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-steam.c b/src/plugins/gs-plugin-steam.c
index 7ac3e37..984a91c 100644
--- a/src/plugins/gs-plugin-steam.c
+++ b/src/plugins/gs-plugin-steam.c
@@ -29,15 +29,6 @@
#define GS_PLUGIN_STEAM_SCREENSHOT_URI "http://cdn.akamai.steamstatic.com/steam/apps"
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "steam";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
diff --git a/src/plugins/gs-plugin-systemd-updates.c b/src/plugins/gs-plugin-systemd-updates.c
index ad46ef0..1e819a5 100644
--- a/src/plugins/gs-plugin-systemd-updates.c
+++ b/src/plugins/gs-plugin-systemd-updates.c
@@ -38,15 +38,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "systemd-updates";
-}
-
-/**
* gs_plugin_initialize:
*/
void
diff --git a/src/plugins/gs-plugin-ubuntu-reviews.c b/src/plugins/gs-plugin-ubuntu-reviews.c
index 6c5a0f9..8133dd2 100644
--- a/src/plugins/gs-plugin-ubuntu-reviews.c
+++ b/src/plugins/gs-plugin-ubuntu-reviews.c
@@ -46,12 +46,6 @@ typedef struct {
gint64 five_star_count;
} Histogram;
-const gchar *
-gs_plugin_get_name (void)
-{
- return "ubuntu-reviews";
-}
-
#define UBUNTU_REVIEWS_SERVER "https://reviews.ubuntu.com/reviews"
/* Download new stats every three months */
diff --git a/src/plugins/gs-plugin-xdg-app.c b/src/plugins/gs-plugin-xdg-app.c
index e4f8307..8188bec 100644
--- a/src/plugins/gs-plugin-xdg-app.c
+++ b/src/plugins/gs-plugin-xdg-app.c
@@ -50,15 +50,6 @@ struct GsPluginData {
};
/**
- * gs_plugin_get_name:
- */
-const gchar *
-gs_plugin_get_name (void)
-{
- return "xdg-app";
-}
-
-/**
* gs_plugin_order_after:
*/
const gchar **
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]