[gnome-software/wip/hughsie/fwupd] Use libfwupd
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/fwupd] Use libfwupd
- Date: Thu, 19 Mar 2015 17:53:15 +0000 (UTC)
commit 83cf8481974e269c41b5d607bdf867572838a067
Author: Richard Hughes <richard hughsie com>
Date: Thu Mar 19 10:44:52 2015 +0000
Use libfwupd
configure.ac | 1 +
contrib/gnome-software.spec.in | 1 +
src/plugins/Makefile.am | 3 +-
src/plugins/gs-plugin-fwupd.c | 92 ++++------------------------------------
4 files changed, 13 insertions(+), 84 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 19407d6..411aa20 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,7 @@ PKG_CHECK_MODULES(SQLITE, sqlite3)
PKG_CHECK_MODULES(SOUP, libsoup-2.4)
PKG_CHECK_MODULES(GSETTINGS_DESKTOP_SCHEMAS, gsettings-desktop-schemas >= 3.11.5)
PKG_CHECK_MODULES(GNOME_DESKTOP, gnome-desktop-3.0)
+PKG_CHECK_MODULES(FWUPD, fwupd)
AC_PATH_PROG(APPSTREAM_UTIL, [appstream-util], [unfound])
AC_ARG_ENABLE(man,
[AS_HELP_STRING([--enable-man],
diff --git a/contrib/gnome-software.spec.in b/contrib/gnome-software.spec.in
index 7cf5132..4f28d67 100644
--- a/contrib/gnome-software.spec.in
+++ b/contrib/gnome-software.spec.in
@@ -28,6 +28,7 @@ BuildRequires: libsoup-devel
BuildRequires: gnome-desktop3-devel
BuildRequires: gsettings-desktop-schemas-devel
BuildRequires: libappstream-glib-devel
+BuildRequires: fwupd-devel
# this is not a library version
%define gs_plugin_version 7
diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am
index 7608898..3a6a5bf 100644
--- a/src/plugins/Makefile.am
+++ b/src/plugins/Makefile.am
@@ -9,6 +9,7 @@ AM_CPPFLAGS = \
$(PACKAGEKIT_CFLAGS) \
$(SOUP_CFLAGS) \
$(SQLITE_CFLAGS) \
+ $(FWUPD_CFLAGS) \
-DBINDIR=\"$(bindir)\" \
-DDATADIR=\"$(datadir)\" \
-DGS_MODULESETDIR=\"$(datadir)/gnome-software/modulesets.d\" \
@@ -150,7 +151,7 @@ libgs_plugin_systemd_updates_la_LDFLAGS = -module -avoid-version
libgs_plugin_systemd_updates_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
libgs_plugin_fwupd_la_SOURCES = gs-plugin-fwupd.c
-libgs_plugin_fwupd_la_LIBADD = $(GS_PLUGIN_LIBS) $(PACKAGEKIT_LIBS)
+libgs_plugin_fwupd_la_LIBADD = $(GS_PLUGIN_LIBS) $(FWUPD_LIBS)
libgs_plugin_fwupd_la_LDFLAGS = -module -avoid-version
libgs_plugin_fwupd_la_CFLAGS = $(GS_PLUGIN_CFLAGS) $(WARN_CFLAGS)
diff --git a/src/plugins/gs-plugin-fwupd.c b/src/plugins/gs-plugin-fwupd.c
index 02e83f4..698adfc 100644
--- a/src/plugins/gs-plugin-fwupd.c
+++ b/src/plugins/gs-plugin-fwupd.c
@@ -21,6 +21,7 @@
#include <config.h>
+#include <fwupd.h>
#include <appstream-glib.h>
#include <fcntl.h>
#include <gio/gio.h>
@@ -32,82 +33,6 @@
#include "gs-cleanup.h"
-#define FWUPD_DBUS_PATH "/"
-#define FWUPD_DBUS_SERVICE "org.freedesktop.fwupd"
-#define FWUPD_DBUS_INTERFACE "org.freedesktop.fwupd"
-
-typedef enum {
- FU_ERROR_INTERNAL,
- FU_ERROR_ALREADY_NEWER_VERSION,
- FU_ERROR_ALREADY_SAME_VERSION,
- FU_ERROR_ALREADY_SCHEDULED,
- FU_ERROR_FAILED_TO_AUTHENTICATE,
- FU_ERROR_FAILED_TO_READ,
- FU_ERROR_FAILED_TO_WRITE,
- FU_ERROR_INVALID_FILE,
- FU_ERROR_NO_SUCH_DEVICE,
- FU_ERROR_NO_SUCH_METHOD,
- FU_ERROR_NO_SUCH_PROPERTY,
- FU_ERROR_NOTHING_TO_DO,
- FU_ERROR_NOT_POSSIBLE,
- /* private */
- FU_ERROR_LAST
-} FuError;
-
-/**
- * fu_error_quark:
- **/
-static GQuark
-fu_error_quark (void)
-{
- static GQuark quark = 0;
- if (!quark) {
- quark = g_quark_from_static_string ("FuError");
- g_dbus_error_register_error (quark,
- FU_ERROR_INTERNAL,
- "org.freedesktop.fwupd.InternalError");
- g_dbus_error_register_error (quark,
- FU_ERROR_ALREADY_NEWER_VERSION,
- "org.freedesktop.fwupd.AlreadyNewerVersion");
- g_dbus_error_register_error (quark,
- FU_ERROR_ALREADY_SAME_VERSION,
- "org.freedesktop.fwupd.AlreadySameVersion");
- g_dbus_error_register_error (quark,
- FU_ERROR_ALREADY_SCHEDULED,
- "org.freedesktop.fwupd.AlreadyScheduled");
- g_dbus_error_register_error (quark,
- FU_ERROR_FAILED_TO_AUTHENTICATE,
- "org.freedesktop.fwupd.FailedToAuthenticate");
- g_dbus_error_register_error (quark,
- FU_ERROR_FAILED_TO_READ,
- "org.freedesktop.fwupd.FailedToRead");
- g_dbus_error_register_error (quark,
- FU_ERROR_FAILED_TO_WRITE,
- "org.freedesktop.fwupd.FailedToWrite");
- g_dbus_error_register_error (quark,
- FU_ERROR_INVALID_FILE,
- "org.freedesktop.fwupd.InvalidFile");
- g_dbus_error_register_error (quark,
- FU_ERROR_NO_SUCH_DEVICE,
- "org.freedesktop.fwupd.NoSuchDevice");
- g_dbus_error_register_error (quark,
- FU_ERROR_NO_SUCH_METHOD,
- "org.freedesktop.fwupd.NoSuchMethod");
- g_dbus_error_register_error (quark,
- FU_ERROR_NO_SUCH_PROPERTY,
- "org.freedesktop.fwupd.NoSuchProperty");
- g_dbus_error_register_error (quark,
- FU_ERROR_NOTHING_TO_DO,
- "org.freedesktop.fwupd.NothingToDo");
- g_dbus_error_register_error (quark,
- FU_ERROR_NOT_POSSIBLE,
- "org.freedesktop.fwupd.NotPossible");
- }
- return quark;
-}
-
-#define FU_ERROR fu_error_quark()
-
struct GsPluginPrivate {
gsize done_init;
GDBusProxy *proxy;
@@ -207,7 +132,7 @@ gs_plugin_startup (GsPlugin *plugin, GCancellable *cancellable, GError **error)
_cleanup_object_unref_ GDBusConnection *conn = NULL;
/* register D-Bus errors */
- fu_error_quark ();
+ fwupd_error_quark ();
conn = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);
if (conn == NULL)
@@ -474,15 +399,15 @@ gs_plugin_add_updates_historical (GsPlugin *plugin,
val = g_dbus_proxy_call_sync (plugin->priv->proxy,
"GetResults",
- g_variant_new ("(s)", "*"),
+ g_variant_new ("(s)", FWUPD_DEVICE_ID_ANY),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error_local);
if (val == NULL) {
if (g_error_matches (error_local,
- FU_ERROR,
- FU_ERROR_NOTHING_TO_DO))
+ FWUPD_ERROR,
+ FWUPD_ERROR_NOTHING_TO_DO))
return TRUE;
g_set_error_literal (error,
GS_PLUGIN_ERROR,
@@ -551,8 +476,8 @@ gs_plugin_add_updates (GsPlugin *plugin,
&error_local);
if (val == NULL) {
if (g_error_matches (error_local,
- FU_ERROR,
- FU_ERROR_NOTHING_TO_DO))
+ FWUPD_ERROR,
+ FWUPD_ERROR_NOTHING_TO_DO))
return TRUE;
g_set_error_literal (error,
GS_PLUGIN_ERROR,
@@ -790,7 +715,8 @@ gs_plugin_app_install (GsPlugin *plugin,
return FALSE;
}
gs_app_set_state (app, AS_APP_STATE_INSTALLING);
- if (!gs_plugin_fwupd_upgrade (plugin, filename, "*", cancellable, error))
+ if (!gs_plugin_fwupd_upgrade (plugin, filename, FWUPD_DEVICE_ID_ANY,
+ cancellable, error))
return FALSE;
gs_app_set_state (app, AS_APP_STATE_INSTALLED);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]