Release fwupd 1.3.5

-----BEGIN PGP SIGNATURE-----
 
 iQFIBAABCAAyFiEEFj61ARkiXbPfj0nqF6y6jfqXDhcFAl3hSGIUHHJpY2hhcmRA
 aHVnaHNpZS5jb20ACgkQF6y6jfqXDheP8wgAlkOof9ji4wMT9MKgFUnDPQjoRv7G
 1KolR+NMej/oDfhe+M4F2iEfzSW1Bfd9fd3vpnzFusROKvUTHuiKoziqzYRY8Ahk
 hgzqT4RLGSTDQh2xsVPGo44A8SQ4bfTiNAPtKnwoF6P9/JLmJbxxdGDZSBZmWlNE
 dPRPu2YVzljr+dGg3hwBm5W4iHP/t7a4zi+LO+NnB+uW+HQXkFGh09a3KJyqIfmV
 Hi1nsTS/YVvDTph/85vlyucoq1JHAI27EhSsFgBIFjv+kGg8HidwHCosmdqYVYCd
 OOCs01/OW6AmT8qtGJzlCMvkxMYC6AhKBLGPtKgmf2SSwLvD+/6SAFbM4g==
 =DCx2
 -----END PGP SIGNATURE-----

Merge tag '1.3.5' into debian

Release fwupd 1.3.5
This commit is contained in:
Mario Limonciello 2019-11-30 16:51:54 -06:00
commit d5083e7432
247 changed files with 6124 additions and 3076 deletions

View File

@ -1,5 +1,19 @@
FROM %%%ARCH_PREFIX%%%debian:testing FROM %%%ARCH_PREFIX%%%debian:testing
%%%OS%%% %%%OS%%%
RUN echo "deb http://ftp.us.debian.org/debian unstable main contrib non-free" >> /etc/apt/sources.list
RUN echo 'Package: *\n\
Pin: release a=testing\n\
Pin-Priority: 900\n\
\n\
Package: *\n\
Pin: release a=unstable\n\
Pin-Priority: 800\n\
\n\
Package: lintian\n\
Pin: release a=unstable\n\
Pin-Priority: 901\n'\
> /etc/apt/preferences
RUN cat /etc/apt/preferences
RUN echo fubar > /etc/machine-id RUN echo fubar > /etc/machine-id
%%%ARCH_SPECIFIC_COMMAND%%% %%%ARCH_SPECIFIC_COMMAND%%%
%%%INSTALL_DEPENDENCIES_COMMAND%%% %%%INSTALL_DEPENDENCIES_COMMAND%%%

View File

@ -15,7 +15,7 @@ ninja -C build test -v
#make docs available outside of docker #make docs available outside of docker
ninja -C build install -v ninja -C build install -v
mkdir -p dist/docs mkdir -p dist/docs
cp build/docs/libfwupd/* dist/docs -R cp build/docs/* dist/docs -R
#run static analysis (these mostly won't be critical) #run static analysis (these mostly won't be critical)
ninja -C build scan-build -v ninja -C build scan-build -v

View File

@ -69,6 +69,7 @@ BuildRequires: help2man
BuildRequires: json-glib-devel >= %{json_glib_version} BuildRequires: json-glib-devel >= %{json_glib_version}
BuildRequires: vala BuildRequires: vala
BuildRequires: bash-completion BuildRequires: bash-completion
BuildRequires: git-core
%if 0%{?have_modem_manager} %if 0%{?have_modem_manager}
BuildRequires: ModemManager-glib-devel >= 1.10.0 BuildRequires: ModemManager-glib-devel >= 1.10.0
@ -299,6 +300,7 @@ rm ${RPM_BUILD_ROOT}%{_sbindir}/flashrom
%{_localstatedir}/lib/fwupd/builder/README.md %{_localstatedir}/lib/fwupd/builder/README.md
%{_libdir}/libfwupd*.so.* %{_libdir}/libfwupd*.so.*
%{_libdir}/girepository-1.0/Fwupd-2.0.typelib %{_libdir}/girepository-1.0/Fwupd-2.0.typelib
%{_libdir}/girepository-1.0/FwupdPlugin-1.0.typelib
/usr/lib/udev/rules.d/*.rules /usr/lib/udev/rules.d/*.rules
/usr/lib/systemd/system-shutdown/fwupd.shutdown /usr/lib/systemd/system-shutdown/fwupd.shutdown
%dir %{_libdir}/fwupd-plugins-3 %dir %{_libdir}/fwupd-plugins-3
@ -370,11 +372,13 @@ rm ${RPM_BUILD_ROOT}%{_sbindir}/flashrom
%files devel %files devel
%{_datadir}/gir-1.0/Fwupd-2.0.gir %{_datadir}/gir-1.0/Fwupd-2.0.gir
%{_datadir}/gtk-doc/html/libfwupd %{_datadir}/gir-1.0/FwupdPlugin-1.0.gir
%{_datadir}/gtk-doc/html/fwupd
%{_datadir}/vala/vapi %{_datadir}/vala/vapi
%{_includedir}/fwupd-1 %{_includedir}/fwupd-1
%{_libdir}/libfwupd*.so %{_libdir}/libfwupd*.so
%{_libdir}/pkgconfig/fwupd.pc %{_libdir}/pkgconfig/fwupd.pc
%{_libdir}/pkgconfig/fwupdplugin.pc
%files tests %files tests
%dir %{_datadir}/installed-tests/fwupd %dir %{_datadir}/installed-tests/fwupd

View File

@ -38,6 +38,7 @@ class LdVersionScript:
if version not in self.releases: if version not in self.releases:
self.releases[version] = [] self.releases[version] = []
release = self.releases[version] release = self.releases[version]
if identifier not in release:
release.append(identifier) release.append(identifier)
return version return version
@ -47,10 +48,6 @@ class LdVersionScript:
for node in cls.findall(XMLNS + 'function'): for node in cls.findall(XMLNS + 'function'):
self._add_node(node) self._add_node(node)
# add the constructor
for node in cls.findall(XMLNS + 'constructor'):
self._add_node(node)
# choose the lowest version method for the _get_type symbol # choose the lowest version method for the _get_type symbol
version_lowest = None version_lowest = None
if '{http://www.gtk.org/introspection/glib/1.0}get-type' not in cls.attrib: if '{http://www.gtk.org/introspection/glib/1.0}get-type' not in cls.attrib:
@ -64,6 +61,13 @@ class LdVersionScript:
if not version_lowest or version_tmp < version_lowest: if not version_lowest or version_tmp < version_lowest:
version_lowest = version_tmp version_lowest = version_tmp
# add the constructor
for node in cls.findall(XMLNS + 'constructor'):
version_tmp = self._add_node(node)
if version_tmp:
if not version_lowest or version_tmp < version_lowest:
version_lowest = version_tmp
# finally add the get_type symbol # finally add the get_type symbol
if version_lowest: if version_lowest:
self.releases[version_lowest].append(type_name) self.releases[version_lowest].append(type_name)

View File

@ -32,6 +32,23 @@
<binary>fwupdmgr</binary> <binary>fwupdmgr</binary>
</provides> </provides>
<releases> <releases>
<release version="1.3.5" date="2019-11-29">
<description>
<p>This release adds the following features:</p>
<ul>
<li>Convert libfwupdprivate to a shared library libfwupdplugin</li>
<li>Create a REV_00 instance ID as this may be what the vendor needs to target</li>
</ul>
<p>This release fixes the following bugs:</p>
<ul>
<li>Improve coreboot version detection</li>
<li>Invert default behavior to be safer for reboot and shutdown prompts</li>
<li>Reload the Synaptics prometheus device version after update</li>
<li>Use the correct unlocker when using GRWLock</li>
<li>Whitelist VIA USB hub PD and I²C devices</li>
</ul>
</description>
</release>
<release version="1.3.4" date="2019-11-22"> <release version="1.3.4" date="2019-11-22">
<description> <description>
<p>This release adds the following features:</p> <p>This release adds the following features:</p>

View File

@ -1,2 +1,2 @@
#/bin/sh #!/bin/sh
cat source.bin | rev > firmware.bin cat source.bin | rev > firmware.bin

View File

@ -1,4 +1,4 @@
#/bin/sh #!/bin/sh
echo "this is a test" echo "this is a test"
sleep 1 sleep 1
echo "this is another line1" echo "this is another line1"

43
debian/control.in vendored
View File

@ -12,6 +12,21 @@ Homepage: https://github.com/fwupd/fwupd
Vcs-Git: https://salsa.debian.org/efi-team/fwupd.git Vcs-Git: https://salsa.debian.org/efi-team/fwupd.git
Vcs-Browser: https://salsa.debian.org/efi-team/fwupd Vcs-Browser: https://salsa.debian.org/efi-team/fwupd
Package: libfwupdplugin1
Section: libs
Architecture: linux-any
Depends: ${misc:Depends},
${shlibs:Depends}
Multi-Arch: same
Description: Firmware update daemon plugin library
fwupd is a daemon to allow session software to update device firmware.
You can either use a GUI software manager like GNOME Software to view and
apply updates, the command-line tool or the system D-Bus interface directly.
Firmware updates are supported for a variety of technologies.
See <https://github.com/fwupd/fwupd> for details
.
This package provides the library for the interface between daemon and plugins.
Package: libfwupd2 Package: libfwupd2
Section: libs Section: libs
Architecture: linux-any Architecture: linux-any
@ -125,6 +140,34 @@ Description: GObject introspection data for libfwupd
It can be used by packages using the GIRepository format to generate It can be used by packages using the GIRepository format to generate
dynamic bindings. dynamic bindings.
Package: libfwupdplugin-dev
Architecture: linux-any
Multi-Arch: same
Depends: libfwupd2 (= ${binary:Version}),
gir1.2-fwupdplugin-1.0 (= ${binary:Version}),
${misc:Depends}
Section: libdevel
Description: development files for libfwupdplugin
fwupd is a daemon to allow session software to update device firmware.
You can either use a GUI software manager like GNOME Software to view and
apply updates, the command-line tool or the system D-Bus interface directly.
Firmware updates are supported for a variety of technologies.
See <https://github.com/fwupd/fwupd> for details
.
This package provides the development files for libfwupdplugin
Package: gir1.2-fwupdplugin-1.0
Architecture: linux-any
Multi-Arch: same
Depends: ${misc:Depends},
${gir:Depends}
Section: introspection
Description: GObject introspection data for libfwupdplugin
This package provides the introspection data for libfwupdplugin.
.
It can be used by packages using the GIRepository format to generate
dynamic bindings.
Package: fwupd-amd64-signed-template Package: fwupd-amd64-signed-template
Architecture: amd64 Architecture: amd64
Depends: ${shlibs:Depends}, ${misc:Depends}, make | build-essential | dpkg-dev Depends: ${shlibs:Depends}, ${misc:Depends}, make | build-essential | dpkg-dev

View File

@ -1 +1 @@
usr/lib/*/girepository-1.0/*.typelib usr/lib/*/girepository-1.0/Fwupd-*.typelib

1
debian/gir1.2-fwupdplugin-1.0.install vendored Normal file
View File

@ -0,0 +1 @@
usr/lib/*/girepository-1.0/FwupdPlugin-*.typelib

View File

@ -1,5 +1,7 @@
usr/include/* usr/include/fwupd-1/fwupd.h
usr/lib/*/*.so usr/include/fwupd-1/libfwupd
usr/lib/*/pkgconfig/*.pc usr/lib/*/libfwupd.so
usr/share/gir-1.0/*.gir usr/lib/*/pkgconfig/fwupd.pc
usr/share/vala/vapi usr/share/gir-1.0/Fwupd-*.gir
usr/share/vala/vapi/fwupd.deps
usr/share/vala/vapi/fwupd.vapi

View File

@ -1 +1 @@
usr/lib/*/*.so.* usr/lib/*/libfwupd.so.*

7
debian/libfwupdplugin-dev.install vendored Normal file
View File

@ -0,0 +1,7 @@
usr/include/fwupd-1/fwupdplugin.h
usr/include/fwupd-1/libfwupdplugin
usr/lib/*/libfwupdplugin.so
usr/lib/*/pkgconfig/fwupdplugin.pc
usr/share/gir-1.0/FwupdPlugin-*.gir
usr/share/vala/vapi/fwupdplugin.deps
usr/share/vala/vapi/fwupdplugin.vapi

1
debian/libfwupdplugin1.install vendored Normal file
View File

@ -0,0 +1 @@
usr/lib/*/libfwupdplugin.so.*

View File

@ -4,6 +4,7 @@ fwupd binary: systemd-service-file-missing-install-key lib/systemd/system/fwupd.
fwupd binary: systemd-service-file-missing-install-key lib/systemd/system/system-update.target.wants/fwupd-offline-update.service fwupd binary: systemd-service-file-missing-install-key lib/systemd/system/system-update.target.wants/fwupd-offline-update.service
#see debian bug 896012 #see debian bug 896012
fwupd: library-not-linked-against-libc usr/lib/*/fwupd-plugins-3/libfu_plugin_upower.so fwupd: library-not-linked-against-libc usr/lib/*/fwupd-plugins-3/libfu_plugin_upower.so
fwupd: library-not-linked-against-libc usr/lib/*/fwupd-plugins-3/libfu_plugin_uefi_recovery.so
#EFI applications are PE executables #EFI applications are PE executables
fwupd: executable-not-elf-or-script usr/lib/fwupd/efi/*.efi fwupd: executable-not-elf-or-script usr/lib/fwupd/efi/*.efi
fwupd: portable-executable-missing-security-features usr/lib/fwupd/efi/*.efi SafeSEH fwupd: portable-executable-missing-security-features usr/lib/fwupd/efi/*.efi SafeSEH

4
debian/rules vendored
View File

@ -69,6 +69,10 @@ override_dh_install:
fi fi
if [ ! -z "$$CI" ] && [ -f debian/tmp/usr/sbin/flashrom ]; then \ if [ ! -z "$$CI" ] && [ -f debian/tmp/usr/sbin/flashrom ]; then \
dh_install -pfwupd usr/sbin/flashrom ;\ dh_install -pfwupd usr/sbin/flashrom ;\
dh_install -plibfwupd2 usr/lib/*/libflashrom.so.*; \
dh_install -plibfwupd-dev usr/include/libflashrom.h; \
dh_install -plibfwupd-dev usr/lib/*/libflashrom.so; \
dh_install -plibfwupd-dev usr/lib/*/pkgconfig/flashrom.pc; \
fi fi
dh_missing -a --fail-missing dh_missing -a --fail-missing

View File

@ -41,13 +41,28 @@
Functionality available to plugins. Functionality available to plugins.
</para> </para>
</partintro> </partintro>
<xi:include href="xml/fu-archive.xml"/>
<xi:include href="xml/fu-chunk.xml"/> <xi:include href="xml/fu-chunk.xml"/>
<xi:include href="xml/fu-common-cab.xml"/>
<xi:include href="xml/fu-common-guid.xml"/>
<xi:include href="xml/fu-common-version.xml"/>
<xi:include href="xml/fu-common.xml"/> <xi:include href="xml/fu-common.xml"/>
<xi:include href="xml/fu-device-locker.xml"/> <xi:include href="xml/fu-device-locker.xml"/>
<xi:include href="xml/fu-device-metadata.xml"/> <xi:include href="xml/fu-device-metadata.xml"/>
<xi:include href="xml/fu-device.xml"/> <xi:include href="xml/fu-device.xml"/>
<xi:include href="xml/fu-dfu-firmware.xml"/>
<xi:include href="xml/fu-firmware-common.xml"/>
<xi:include href="xml/fu-firmware-image.xml"/>
<xi:include href="xml/fu-firmware.xml"/>
<xi:include href="xml/fu-hwids.xml"/>
<xi:include href="xml/fu-ihex-firmware.xml"/>
<xi:include href="xml/fu-srec-firmware.xml"/>
<xi:include href="xml/fu-io-channel.xml"/>
<xi:include href="xml/fu-mutex.xml"/>
<xi:include href="xml/fu-plugin-vfuncs.xml"/>
<xi:include href="xml/fu-plugin.xml"/> <xi:include href="xml/fu-plugin.xml"/>
<xi:include href="xml/fu-quirks.xml"/> <xi:include href="xml/fu-quirks.xml"/>
<xi:include href="xml/fu-smbios.xml"/>
<xi:include href="xml/fu-udev-device.xml"/> <xi:include href="xml/fu-udev-device.xml"/>
<xi:include href="xml/fu-usb-device.xml"/> <xi:include href="xml/fu-usb-device.xml"/>
</reference> </reference>

View File

@ -1,5 +0,0 @@
rm -f *.txt
rm -rf html/
rm -rf xml/
rm -rf tmpl/
rm -f *.stamp

View File

@ -1,6 +0,0 @@
fwupd_client_get_type
fwupd_device_get_type
fwupd_quirks_get_type
fwupd_release_get_type
fwupd_remote_get_type
fwupd_result_get_type

View File

@ -1,11 +0,0 @@
gnome.gtkdoc(
'libfwupd',
src_dir : [
join_paths(meson.source_root(), 'libfwupd'),
join_paths(meson.source_root(), 'src'),
join_paths(meson.build_root(), 'libfwupd'),
join_paths(meson.build_root(), 'src'),
],
main_xml : 'libfwupd-docs.xml',
install : true
)

View File

@ -1 +1,11 @@
subdir('libfwupd') gnome.gtkdoc(
'fwupd',
src_dir : [
join_paths(meson.source_root(), 'libfwupd'),
join_paths(meson.source_root(), 'libfwupdplugin'),
join_paths(meson.build_root(), 'libfwupd'),
join_paths(meson.build_root(), 'libfwupdplugin'),
],
main_xml : 'fwupd-docs.xml',
install : true
)

View File

@ -1,58 +0,0 @@
Version Formats
===============
In some circumstances fwupd has to convert from a unsigned integer version
number into something that has either been used in documentation or has been
defined in some specification.
A good example here is the UEFI ESRT table, which specifies a `uint32_t` for
the version but does not specify how this should be formatted for the user.
As is typical in underspecified specifications, vendors have converted the
integer in different ways. For instance, Dell uses version strings like 1.2.3
and Microsoft use versions like 1.2.3.4.
The fwudp daemon can match specific devices and apply the correct version style
using quirk files. The version format can also be specified in the firmware
`metainfo.xml` file so that the new version is correctly shown, and so that it
matches on the LVFS website.
The current version formats supported by fwupd and the LVFS are:
* `plain`: Use plain integer version numbers with no dots, e.g. `AABBCCDD`
* `quad`: Use Dell-style `AA.BB.CC.DD` version numbers
* `triplet`: Use Microsoft-style `AA.BB.CCDD` version numbers
* `pair`: Use two `AABB.CCDD` version numbers
* `bcd`: Use binary coded decimal notation
* `intel-me`: Use Intel ME-style notation (`aaa+11.bbbbb.CC.DDDD`)
* `intel-me2`: Use alternate Intel ME-style-style `A.B.CC.DDDD` notation
These can be specified in quirk files like this:
# Vendor Modelname
[Guid=5b92717b-2cad-4a96-a13b-9d65781df8bf]
VersionFormat = intel-me2
...or in metainfo.xml files like this:
<custom>
<value key="LVFS::VersionFormat">intel-me2</value>
</custom>
Runtime requirements
--------------------
Versions of fwupd `< 1.2.0` can only support firmware updates with key values
`LVFS::VersionFormat` of `quad` and `triplet`. Additionally, on older versions
no quirk `VersionFormat` device fixups are supported.
If want to use one of the additional version formats you should depend on a
specific version of fwupd in the firmware file:
<requires>
<id compare="ge" version="1.2.0">org.freedesktop.fwupd</id>
</requires>
This is not *strictly* required, as the integer value can be used for update
calculations if the version is specified in hex (e.g. `0x12345678`) in the
`<release>` tag, although the user might get a bit confused if the update
version does not match the update description.

View File

@ -8,7 +8,9 @@
#include <glib-object.h> #include <glib-object.h>
#include <gio/gio.h> #include <gio/gio.h>
#ifdef HAVE_GIO_UNIX
#include <gio/gunixfdlist.h> #include <gio/gunixfdlist.h>
#endif
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
@ -953,6 +955,7 @@ fwupd_client_get_results (FwupdClient *client, const gchar *device_id,
return fwupd_device_from_variant (helper->val); return fwupd_device_from_variant (helper->val);
} }
#ifdef HAVE_GIO_UNIX
static void static void
fwupd_client_send_message_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) fwupd_client_send_message_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{ {
@ -971,6 +974,7 @@ fwupd_client_send_message_cb (GObject *source_object, GAsyncResult *res, gpointe
fwupd_client_fixup_dbus_error (helper->error); fwupd_client_fixup_dbus_error (helper->error);
g_main_loop_quit (helper->loop); g_main_loop_quit (helper->loop);
} }
#endif
/** /**
* fwupd_client_install: * fwupd_client_install:
@ -995,6 +999,7 @@ fwupd_client_install (FwupdClient *client,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
#ifdef HAVE_GIO_UNIX
FwupdClientPrivate *priv = GET_PRIVATE (client); FwupdClientPrivate *priv = GET_PRIVATE (client);
GVariant *body; GVariant *body;
GVariantBuilder builder; GVariantBuilder builder;
@ -1084,6 +1089,13 @@ fwupd_client_install (FwupdClient *client,
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <glib-unix.h> is unavailable");
return FALSE;
#endif
} }
/** /**
@ -1103,6 +1115,7 @@ GPtrArray *
fwupd_client_get_details (FwupdClient *client, const gchar *filename, fwupd_client_get_details (FwupdClient *client, const gchar *filename,
GCancellable *cancellable, GError **error) GCancellable *cancellable, GError **error)
{ {
#ifdef HAVE_GIO_UNIX
FwupdClientPrivate *priv = GET_PRIVATE (client); FwupdClientPrivate *priv = GET_PRIVATE (client);
GVariant *body; GVariant *body;
gint fd; gint fd;
@ -1166,6 +1179,13 @@ fwupd_client_get_details (FwupdClient *client, const gchar *filename,
/* return results */ /* return results */
return fwupd_device_array_from_variant (helper->val); return fwupd_device_array_from_variant (helper->val);
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <glib-unix.h> is unavailable");
return NULL;
#endif
} }
/** /**
@ -1323,6 +1343,7 @@ fwupd_client_update_metadata (FwupdClient *client,
GCancellable *cancellable, GCancellable *cancellable,
GError **error) GError **error)
{ {
#ifdef HAVE_GIO_UNIX
FwupdClientPrivate *priv = GET_PRIVATE (client); FwupdClientPrivate *priv = GET_PRIVATE (client);
GVariant *body; GVariant *body;
gint fd; gint fd;
@ -1396,6 +1417,13 @@ fwupd_client_update_metadata (FwupdClient *client,
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <glib-unix.h> is unavailable");
return FALSE;
#endif
} }
/** /**

View File

@ -13,7 +13,9 @@
#include <locale.h> #include <locale.h>
#include <string.h> #include <string.h>
#ifdef HAVE_UTSNAME_H
#include <sys/utsname.h> #include <sys/utsname.h>
#endif
#include <json-glib/json-glib.h> #include <json-glib/json-glib.h>
#if !GLIB_CHECK_VERSION(2,54,0) #if !GLIB_CHECK_VERSION(2,54,0)
@ -222,12 +224,15 @@ fwupd_build_user_agent_os_release (void)
static gchar * static gchar *
fwupd_build_user_agent_system (void) fwupd_build_user_agent_system (void)
{ {
#ifdef HAVE_UTSNAME_H
struct utsname name_tmp; struct utsname name_tmp;
#endif
g_autofree gchar *locale = NULL; g_autofree gchar *locale = NULL;
g_autofree gchar *os_release = NULL; g_autofree gchar *os_release = NULL;
g_autoptr(GPtrArray) ids = g_ptr_array_new_with_free_func (g_free); g_autoptr(GPtrArray) ids = g_ptr_array_new_with_free_func (g_free);
/* system, architecture and kernel, e.g. "Linux i686 4.14.5" */ /* system, architecture and kernel, e.g. "Linux i686 4.14.5" */
#ifdef HAVE_UTSNAME_H
memset (&name_tmp, 0, sizeof(struct utsname)); memset (&name_tmp, 0, sizeof(struct utsname));
if (uname (&name_tmp) >= 0) { if (uname (&name_tmp) >= 0) {
g_ptr_array_add (ids, g_strdup_printf ("%s %s %s", g_ptr_array_add (ids, g_strdup_printf ("%s %s %s",
@ -235,9 +240,12 @@ fwupd_build_user_agent_system (void)
name_tmp.machine, name_tmp.machine,
name_tmp.release)); name_tmp.release));
} }
#endif
/* current locale, e.g. "en-gb" */ /* current locale, e.g. "en-gb" */
#ifdef HAVE_LC_MESSAGES
locale = g_strdup (setlocale (LC_MESSAGES, NULL)); locale = g_strdup (setlocale (LC_MESSAGES, NULL));
#endif
if (locale != NULL) { if (locale != NULL) {
g_strdelimit (locale, ".", '\0'); g_strdelimit (locale, ".", '\0');
g_strdelimit (locale, "_", '-'); g_strdelimit (locale, "_", '-');
@ -320,8 +328,8 @@ fwupd_build_machine_id (const gchar *salt, GError **error)
gsize sz = 0; gsize sz = 0;
/* one of these has to exist */ /* one of these has to exist */
fns[0] = g_build_filename (SYSCONFDIR, "machine-id", NULL); fns[0] = g_build_filename (FWUPD_SYSCONFDIR, "machine-id", NULL);
fns[1] = g_build_filename (LOCALSTATEDIR, "lib", "dbus", "machine-id", NULL); fns[1] = g_build_filename (FWUPD_LOCALSTATEDIR, "lib", "dbus", "machine-id", NULL);
fns[2] = g_strdup ("/etc/machine-id"); fns[2] = g_strdup ("/etc/machine-id");
fns[3] = g_strdup ("/var/lib/dbus/machine-id"); fns[3] = g_strdup ("/var/lib/dbus/machine-id");
for (guint i = 0; fns[i] != NULL; i++) { for (guint i = 0; fns[i] != NULL; i++) {

View File

@ -61,6 +61,7 @@ typedef struct {
enum { enum {
PROP_0, PROP_0,
PROP_VERSION_FORMAT, PROP_VERSION_FORMAT,
PROP_FLAGS,
PROP_LAST PROP_LAST
}; };
@ -875,7 +876,10 @@ fwupd_device_set_flags (FwupdDevice *device, guint64 flags)
{ {
FwupdDevicePrivate *priv = GET_PRIVATE (device); FwupdDevicePrivate *priv = GET_PRIVATE (device);
g_return_if_fail (FWUPD_IS_DEVICE (device)); g_return_if_fail (FWUPD_IS_DEVICE (device));
if (priv->flags == flags)
return;
priv->flags = flags; priv->flags = flags;
g_object_notify (G_OBJECT (device), "flags");
} }
/** /**
@ -892,7 +896,12 @@ fwupd_device_add_flag (FwupdDevice *device, FwupdDeviceFlags flag)
{ {
FwupdDevicePrivate *priv = GET_PRIVATE (device); FwupdDevicePrivate *priv = GET_PRIVATE (device);
g_return_if_fail (FWUPD_IS_DEVICE (device)); g_return_if_fail (FWUPD_IS_DEVICE (device));
if (flag == 0)
return;
if ((priv->flags & flag) > 0)
return;
priv->flags |= flag; priv->flags |= flag;
g_object_notify (G_OBJECT (device), "flags");
} }
/** /**
@ -909,7 +918,12 @@ fwupd_device_remove_flag (FwupdDevice *device, FwupdDeviceFlags flag)
{ {
FwupdDevicePrivate *priv = GET_PRIVATE (device); FwupdDevicePrivate *priv = GET_PRIVATE (device);
g_return_if_fail (FWUPD_IS_DEVICE (device)); g_return_if_fail (FWUPD_IS_DEVICE (device));
if (flag == 0)
return;
if ((priv->flags & flag) == 0)
return;
priv->flags &= ~flag; priv->flags &= ~flag;
g_object_notify (G_OBJECT (device), "flags");
} }
/** /**
@ -1880,6 +1894,9 @@ fwupd_device_get_property (GObject *object, guint prop_id,
case PROP_VERSION_FORMAT: case PROP_VERSION_FORMAT:
g_value_set_uint (value, priv->version_format); g_value_set_uint (value, priv->version_format);
break; break;
case PROP_FLAGS:
g_value_set_uint64 (value, priv->flags);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -1895,6 +1912,9 @@ fwupd_device_set_property (GObject *object, guint prop_id,
case PROP_VERSION_FORMAT: case PROP_VERSION_FORMAT:
fwupd_device_set_version_format (self, g_value_get_uint (value)); fwupd_device_set_version_format (self, g_value_get_uint (value));
break; break;
case PROP_FLAGS:
fwupd_device_set_flags (self, g_value_get_uint64 (value));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -1918,6 +1938,14 @@ fwupd_device_class_init (FwupdDeviceClass *klass)
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_NAME); G_PARAM_STATIC_NAME);
g_object_class_install_property (object_class, PROP_VERSION_FORMAT, pspec); g_object_class_install_property (object_class, PROP_VERSION_FORMAT, pspec);
pspec = g_param_spec_uint64 ("flags", NULL, NULL,
FWUPD_DEVICE_FLAG_NONE,
FWUPD_DEVICE_FLAG_UNKNOWN,
FWUPD_DEVICE_FLAG_NONE,
G_PARAM_READWRITE |
G_PARAM_STATIC_NAME);
g_object_class_install_property (object_class, PROP_FLAGS, pspec);
} }
static void static void

View File

@ -7,7 +7,9 @@
#include "config.h" #include "config.h"
#include <glib-object.h> #include <glib-object.h>
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h> #include <fnmatch.h>
#endif
#include "fwupd-client.h" #include "fwupd-client.h"
#include "fwupd-common.h" #include "fwupd-common.h"
@ -27,8 +29,13 @@ fu_test_compare_lines (const gchar *txt1, const gchar *txt2, GError **error)
return TRUE; return TRUE;
/* matches a pattern */ /* matches a pattern */
#ifdef HAVE_FNMATCH_H
if (fnmatch (txt2, txt1, FNM_NOESCAPE) == 0) if (fnmatch (txt2, txt1, FNM_NOESCAPE) == 0)
return TRUE; return TRUE;
#else
if (g_strcmp0 (txt1, txt2) == 0)
return TRUE;
#endif
/* save temp files and diff them */ /* save temp files and diff them */
if (!g_file_set_contents ("/tmp/a", txt1, -1, error)) if (!g_file_set_contents ("/tmp/a", txt1, -1, error))
@ -147,7 +154,7 @@ fwupd_remote_download_func (void)
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
remote = fwupd_remote_new (); remote = fwupd_remote_new ();
directory = g_build_filename (LOCALSTATEDIR, directory = g_build_filename (FWUPD_LOCALSTATEDIR,
"lib", "lib",
"fwupd", "fwupd",
"remotes.d", "remotes.d",
@ -166,9 +173,9 @@ fwupd_remote_download_func (void)
g_assert_cmpstr (fwupd_remote_get_title (remote), ==, "Linux Vendor Firmware Service"); g_assert_cmpstr (fwupd_remote_get_title (remote), ==, "Linux Vendor Firmware Service");
g_assert_cmpstr (fwupd_remote_get_report_uri (remote), ==, "https://fwupd.org/lvfs/firmware/report"); g_assert_cmpstr (fwupd_remote_get_report_uri (remote), ==, "https://fwupd.org/lvfs/firmware/report");
g_assert_cmpstr (fwupd_remote_get_filename_cache (remote), ==, g_assert_cmpstr (fwupd_remote_get_filename_cache (remote), ==,
LOCALSTATEDIR "/lib/fwupd/remotes.d/lvfs/metadata.xml.gz"); FWUPD_LOCALSTATEDIR "/lib/fwupd/remotes.d/lvfs/metadata.xml.gz");
g_assert_cmpstr (fwupd_remote_get_filename_cache_sig (remote), ==, g_assert_cmpstr (fwupd_remote_get_filename_cache_sig (remote), ==,
LOCALSTATEDIR "/lib/fwupd/remotes.d/lvfs/metadata.xml.gz.asc"); FWUPD_LOCALSTATEDIR "/lib/fwupd/remotes.d/lvfs/metadata.xml.gz.asc");
} }
/* verify we used the FirmwareBaseURI just for firmware */ /* verify we used the FirmwareBaseURI just for firmware */
@ -183,7 +190,7 @@ fwupd_remote_baseuri_func (void)
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
remote = fwupd_remote_new (); remote = fwupd_remote_new ();
directory = g_build_filename (LOCALSTATEDIR, directory = g_build_filename (FWUPD_LOCALSTATEDIR,
"lib", "lib",
"fwupd", "fwupd",
"remotes.d", "remotes.d",
@ -219,7 +226,7 @@ fwupd_remote_nopath_func (void)
g_autofree gchar *directory = NULL; g_autofree gchar *directory = NULL;
remote = fwupd_remote_new (); remote = fwupd_remote_new ();
directory = g_build_filename (LOCALSTATEDIR, directory = g_build_filename (FWUPD_LOCALSTATEDIR,
"lib", "lib",
"fwupd", "fwupd",
"remotes.d", "remotes.d",

View File

@ -27,8 +27,8 @@ install_headers([
subdir : 'fwupd-1/libfwupd', subdir : 'fwupd-1/libfwupd',
) )
mapfile = 'fwupd.map' fwupd_mapfile = 'fwupd.map'
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), fwupd_mapfile)
fwupd = shared_library( fwupd = shared_library(
'fwupd', 'fwupd',
sources : [ sources : [
@ -40,8 +40,8 @@ fwupd = shared_library(
'fwupd-release.c', 'fwupd-release.c',
'fwupd-remote.c', 'fwupd-remote.c',
], ],
soversion : lt_current, soversion : libfwupd_lt_current,
version : lt_version, version : libfwupd_lt_version,
dependencies : [ dependencies : [
giounix, giounix,
soup, soup,
@ -51,9 +51,9 @@ fwupd = shared_library(
cargs, cargs,
'-DLOCALSTATEDIR="' + localstatedir + '"', '-DLOCALSTATEDIR="' + localstatedir + '"',
], ],
include_directories : include_directories('..'), include_directories : root_incdir,
link_args : vflag, link_args : vflag,
link_depends : mapfile, link_depends : fwupd_mapfile,
install : true install : true
) )
@ -69,7 +69,7 @@ pkgg.generate(
) )
if get_option('introspection') if get_option('introspection')
gir = gnome.generate_gir(fwupd, fwupd_gir = gnome.generate_gir(fwupd,
sources : [ sources : [
'fwupd-client.c', 'fwupd-client.c',
'fwupd-client.h', 'fwupd-client.h',
@ -110,7 +110,7 @@ if get_option('introspection')
) )
gnome.generate_vapi('fwupd', gnome.generate_vapi('fwupd',
sources : gir[0], sources : fwupd_gir[0],
packages : ['gio-2.0', 'libsoup-2.4'], packages : ['gio-2.0', 'libsoup-2.4'],
install : true, install : true,
) )
@ -123,17 +123,16 @@ if get_option('introspection')
# #
# To avoid the circular dep, and to ensure we don't change exported API # To avoid the circular dep, and to ensure we don't change exported API
# accidentally actually check in a version of the version script to git. # accidentally actually check in a version of the version script to git.
mapfile_target = custom_target('mapfile', mapfile_target = custom_target('fwupd_mapfile',
input: gir[0], input: fwupd_gir[0],
output: 'fwupd.map', output: 'fwupd.map',
command: [ command: [
join_paths(meson.current_source_dir(), 'generate-version-script.py'), join_paths(meson.source_root(), 'contrib', 'generate-version-script.py'),
'LIBFWUPD', 'LIBFWUPD',
'@INPUT@', '@INPUT@',
'@OUTPUT@', '@OUTPUT@',
], ],
) )
diffcmd = find_program('diff')
test('fwupd-exported-api', diffcmd, test('fwupd-exported-api', diffcmd,
args : [ args : [
'-urNp', '-urNp',
@ -152,7 +151,7 @@ if get_option('tests')
'fwupd-self-test.c' 'fwupd-self-test.c'
], ],
include_directories : [ include_directories : [
include_directories('..'), root_incdir,
], ],
dependencies : [ dependencies : [
gio, gio,
@ -170,3 +169,5 @@ if get_option('tests')
) )
test('fwupd-self-test', e) test('fwupd-self-test', e)
endif endif
fwupd_incdir = include_directories('.')

View File

@ -59,6 +59,8 @@ fu_archive_init (FuArchive *self)
* Finds the blob referenced by filename * Finds the blob referenced by filename
* *
* Returns: (transfer none): a #GBytes, or %NULL if the filename was not found * Returns: (transfer none): a #GBytes, or %NULL if the filename was not found
*
* Since: 1.2.2
**/ **/
GBytes * GBytes *
fu_archive_lookup_by_fn (FuArchive *self, const gchar *fn, GError **error) fu_archive_lookup_by_fn (FuArchive *self, const gchar *fn, GError **error)
@ -82,7 +84,7 @@ fu_archive_lookup_by_fn (FuArchive *self, const gchar *fn, GError **error)
/** /**
* fu_archive_iterate: * fu_archive_iterate:
* @self: A #FuArchive * @self: A #FuArchive
* @callback: A #FuArchiveIterateFunc. * @callback: (scope call): A #FuArchiveIterateFunc.
* @user_data: User data. * @user_data: User data.
* @error: A #GError, or %NULL * @error: A #GError, or %NULL
* *
@ -90,6 +92,8 @@ fu_archive_lookup_by_fn (FuArchive *self, const gchar *fn, GError **error)
* of the files found. If any @callback returns %FALSE scanning is aborted. * of the files found. If any @callback returns %FALSE scanning is aborted.
* *
* Returns: True if no @callback returned FALSE * Returns: True if no @callback returned FALSE
*
* Since: 1.3.4
*/ */
gboolean gboolean
fu_archive_iterate (FuArchive *self, fu_archive_iterate (FuArchive *self,
@ -225,6 +229,8 @@ fu_archive_load (FuArchive *self, GBytes *blob, FuArchiveFlags flags, GError **e
* Parses @data as an archive and decompresses all files to memory blobs. * Parses @data as an archive and decompresses all files to memory blobs.
* *
* Returns: a #FuArchive, or %NULL if the archive was invalid in any way. * Returns: a #FuArchive, or %NULL if the archive was invalid in any way.
*
* Since: 1.2.2
**/ **/
FuArchive * FuArchive *
fu_archive_new (GBytes *data, FuArchiveFlags flags, GError **error) fu_archive_new (GBytes *data, FuArchiveFlags flags, GError **error)

View File

@ -13,7 +13,15 @@
#include "fu-chunk.h" #include "fu-chunk.h"
/** /**
* fu_chunk_new: * SECTION:fu-chunk
* @short_description: A packet of chunked data
*
* An object that represents a packet of data.
*
*/
/**
* fu_chunk_new: (skip):
* @idx: the packet number * @idx: the packet number
* @page: the hardware memory page * @page: the hardware memory page
* @address: the address *within* the page * @address: the address *within* the page
@ -23,6 +31,8 @@
* Creates a new packet of chunked data. * Creates a new packet of chunked data.
* *
* Return value: (transfer full): a #FuChunk * Return value: (transfer full): a #FuChunk
*
* Since: 1.1.2
**/ **/
FuChunk * FuChunk *
fu_chunk_new (guint32 idx, fu_chunk_new (guint32 idx,
@ -47,6 +57,8 @@ fu_chunk_new (guint32 idx,
* Converts the chunked packet to a string representation. * Converts the chunked packet to a string representation.
* *
* Return value: (transfer full): A string * Return value: (transfer full): A string
*
* Since: 1.1.2
**/ **/
gchar * gchar *
fu_chunk_to_string (FuChunk *item) fu_chunk_to_string (FuChunk *item)
@ -76,6 +88,8 @@ fu_chunk_to_string (FuChunk *item)
* Converts all the chunked packets in an array to a string representation. * Converts all the chunked packets in an array to a string representation.
* *
* Return value: (transfer full): A string * Return value: (transfer full): A string
*
* Since: 1.0.1
**/ **/
gchar * gchar *
fu_chunk_array_to_string (GPtrArray *chunks) fu_chunk_array_to_string (GPtrArray *chunks)
@ -90,7 +104,7 @@ fu_chunk_array_to_string (GPtrArray *chunks)
} }
/** /**
* fu_chunk_array_new: * fu_chunk_array_new: (skip):
* @data: a linear blob of memory, or %NULL * @data: a linear blob of memory, or %NULL
* @data_sz: size of @data_sz * @data_sz: size of @data_sz
* @addr_start: the hardware address offset, or 0 * @addr_start: the hardware address offset, or 0
@ -100,7 +114,9 @@ fu_chunk_array_to_string (GPtrArray *chunks)
* Chunks a linear blob of memory into packets, ensuring each packet does not * Chunks a linear blob of memory into packets, ensuring each packet does not
* cross a package boundary and is less that a specific transfer size. * cross a package boundary and is less that a specific transfer size.
* *
* Return value: (element-type FuChunk): array of packets * Return value: (transfer container) (element-type FuChunk): array of packets
*
* Since: 1.1.2
**/ **/
GPtrArray * GPtrArray *
fu_chunk_array_new (const guint8 *data, fu_chunk_array_new (const guint8 *data,
@ -172,7 +188,7 @@ fu_chunk_array_new (const guint8 *data,
} }
/** /**
* fu_chunk_array_new_from_bytes: * fu_chunk_array_new_from_bytes: (skip):
* @blob: a #GBytes * @blob: a #GBytes
* @addr_start: the hardware address offset, or 0 * @addr_start: the hardware address offset, or 0
* @page_sz: the hardware page size, or 0 * @page_sz: the hardware page size, or 0
@ -181,7 +197,9 @@ fu_chunk_array_new (const guint8 *data,
* Chunks a linear blob of memory into packets, ensuring each packet does not * Chunks a linear blob of memory into packets, ensuring each packet does not
* cross a package boundary and is less that a specific transfer size. * cross a package boundary and is less that a specific transfer size.
* *
* Return value: (element-type FuChunk): array of packets * Return value: (transfer container) (element-type FuChunk): array of packets
*
* Since: 1.1.2
**/ **/
GPtrArray * GPtrArray *
fu_chunk_array_new_from_bytes (GBytes *blob, fu_chunk_array_new_from_bytes (GBytes *blob,

View File

@ -375,7 +375,7 @@ fu_common_cab_set_container_checksum_cb (XbBuilderFixup *self,
} }
/** /**
* fu_common_cab_build_silo: * fu_common_cab_build_silo: (skip):
* @blob: A readable blob * @blob: A readable blob
* @size_max: The maximum size of the archive * @size_max: The maximum size of the archive
* @error: A #FuEndianType, e.g. %G_LITTLE_ENDIAN * @error: A #FuEndianType, e.g. %G_LITTLE_ENDIAN
@ -383,6 +383,8 @@ fu_common_cab_set_container_checksum_cb (XbBuilderFixup *self,
* Create an AppStream silo from a cabinet archive. * Create an AppStream silo from a cabinet archive.
* *
* Returns: a #XbSilo, or %NULL on error * Returns: a #XbSilo, or %NULL on error
*
* Since: 1.2.0
**/ **/
XbSilo * XbSilo *
fu_common_cab_build_silo (GBytes *blob, guint64 size_max, GError **error) fu_common_cab_build_silo (GBytes *blob, guint64 size_max, GError **error)

View File

@ -355,6 +355,18 @@ fu_common_version_convert_base (FwupdVersionFormat fmt)
return fmt; return fmt;
} }
/**
* fu_common_version_verify_format:
* @version: A string, e.g. "0x1234"
* @fmt: a #FwupdVersionFormat
* @error: A #GError or %NULL
*
* Verifies if a version matches the input format.
*
* Returns: TRUE or FALSE
*
* Since: 1.2.9
**/
gboolean gboolean
fu_common_version_verify_format (const gchar *version, fu_common_version_verify_format (const gchar *version,
FwupdVersionFormat fmt, FwupdVersionFormat fmt,

View File

@ -8,9 +8,15 @@
#include <config.h> #include <config.h>
#ifdef HAVE_GIO_UNIX
#include <gio/gunixinputstream.h> #include <gio/gunixinputstream.h>
#endif
#include <glib/gstdio.h> #include <glib/gstdio.h>
#ifdef HAVE_FNMATCH_H
#include <fnmatch.h>
#endif
#include <archive_entry.h> #include <archive_entry.h>
#include <archive.h> #include <archive.h>
#include <errno.h> #include <errno.h>
@ -39,6 +45,8 @@
* Recursively removes a directory. * Recursively removes a directory.
* *
* Returns: %TRUE for success, %FALSE otherwise * Returns: %TRUE for success, %FALSE otherwise
*
* Since: 0.9.7
**/ **/
gboolean gboolean
fu_common_rmtree (const gchar *directory, GError **error) fu_common_rmtree (const gchar *directory, GError **error)
@ -113,7 +121,9 @@ fu_common_get_file_list_internal (GPtrArray *files, const gchar *directory, GErr
* If any path under @directory cannot be accessed due to permissions an error * If any path under @directory cannot be accessed due to permissions an error
* will be returned. * will be returned.
* *
* Returns: (element-type: utf8) (transfer container): array of files, or %NULL for error * Returns: (transfer container) (element-type utf8): array of files, or %NULL for error
*
* Since: 1.0.6
**/ **/
GPtrArray * GPtrArray *
fu_common_get_files_recursive (const gchar *path, GError **error) fu_common_get_files_recursive (const gchar *path, GError **error)
@ -131,6 +141,8 @@ fu_common_get_files_recursive (const gchar *path, GError **error)
* Creates any required directories, including any parent directories. * Creates any required directories, including any parent directories.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
*
* Since: 0.9.7
**/ **/
gboolean gboolean
fu_common_mkdir_parent (const gchar *filename, GError **error) fu_common_mkdir_parent (const gchar *filename, GError **error)
@ -160,6 +172,8 @@ fu_common_mkdir_parent (const gchar *filename, GError **error)
* required. * required.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
*
* Since: 0.9.5
**/ **/
gboolean gboolean
fu_common_set_contents_bytes (const gchar *filename, GBytes *bytes, GError **error) fu_common_set_contents_bytes (const gchar *filename, GBytes *bytes, GError **error)
@ -188,6 +202,8 @@ fu_common_set_contents_bytes (const gchar *filename, GBytes *bytes, GError **err
* Reads a blob of data from a file. * Reads a blob of data from a file.
* *
* Returns: a #GBytes, or %NULL for failure * Returns: a #GBytes, or %NULL for failure
*
* Since: 0.9.7
**/ **/
GBytes * GBytes *
fu_common_get_contents_bytes (const gchar *filename, GError **error) fu_common_get_contents_bytes (const gchar *filename, GError **error)
@ -211,10 +227,13 @@ fu_common_get_contents_bytes (const gchar *filename, GError **error)
* Note: this will close the fd when done * Note: this will close the fd when done
* *
* Returns: (transfer full): a #GBytes, or %NULL * Returns: (transfer full): a #GBytes, or %NULL
*
* Since: 0.9.5
**/ **/
GBytes * GBytes *
fu_common_get_contents_fd (gint fd, gsize count, GError **error) fu_common_get_contents_fd (gint fd, gsize count, GError **error)
{ {
#ifdef HAVE_GIO_UNIX
g_autoptr(GBytes) blob = NULL; g_autoptr(GBytes) blob = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
g_autoptr(GInputStream) stream = NULL; g_autoptr(GInputStream) stream = NULL;
@ -242,6 +261,13 @@ fu_common_get_contents_fd (gint fd, gsize count, GError **error)
return NULL; return NULL;
} }
return g_steal_pointer (&blob); return g_steal_pointer (&blob);
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <glib-unix.h> is unavailable");
return NULL;
#endif
} }
static gboolean static gboolean
@ -270,6 +296,8 @@ fu_common_extract_archive_entry (struct archive_entry *entry, const gchar *dir)
* Extracts an achive to a directory. * Extracts an achive to a directory.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
*
* Since: 0.9.7
**/ **/
gboolean gboolean
fu_common_extract_archive (GBytes *blob, const gchar *dir, GError **error) fu_common_extract_archive (GBytes *blob, const gchar *dir, GError **error)
@ -353,6 +381,17 @@ fu_common_add_argv (GPtrArray *argv, const gchar *fmt, ...)
g_ptr_array_add (argv, g_strdup (split[i])); g_ptr_array_add (argv, g_strdup (split[i]));
} }
/**
* fu_common_find_program_in_path:
* @basename: The program to search
* @error: A #GError, or %NULL
*
* Looks for a program in the PATH variable
*
* Returns: a new #gchar, or %NULL for error
*
* Since: 1.1.2
**/
gchar * gchar *
fu_common_find_program_in_path (const gchar *basename, GError **error) fu_common_find_program_in_path (const gchar *basename, GError **error)
{ {
@ -411,6 +450,8 @@ fu_common_test_namespace_support (GError **error)
* 5. The temporary location is deleted * 5. The temporary location is deleted
* *
* Returns: a new #GBytes, or %NULL for error * Returns: a new #GBytes, or %NULL for error
*
* Since: 0.9.7
**/ **/
GBytes * GBytes *
fu_common_firmware_builder (GBytes *bytes, fu_common_firmware_builder (GBytes *bytes,
@ -631,6 +672,8 @@ fu_common_spawn_cancelled_cb (GCancellable *cancellable, FuCommonSpawnHelper *he
* standard error will be forwarded to @handler_cb as whole lines. * standard error will be forwarded to @handler_cb as whole lines.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
*
* Since: 0.9.7
**/ **/
gboolean gboolean
fu_common_spawn_sync (const gchar * const * argv, fu_common_spawn_sync (const gchar * const * argv,
@ -688,6 +731,8 @@ fu_common_spawn_sync (const gchar * const * argv,
* @endian: A #FuEndianType, e.g. %G_LITTLE_ENDIAN * @endian: A #FuEndianType, e.g. %G_LITTLE_ENDIAN
* *
* Writes a value to a buffer using a specified endian. * Writes a value to a buffer using a specified endian.
*
* Since: 1.0.3
**/ **/
void void
fu_common_write_uint16 (guint8 *buf, guint16 val_native, FuEndianType endian) fu_common_write_uint16 (guint8 *buf, guint16 val_native, FuEndianType endian)
@ -713,6 +758,8 @@ fu_common_write_uint16 (guint8 *buf, guint16 val_native, FuEndianType endian)
* @endian: A #FuEndianType, e.g. %G_LITTLE_ENDIAN * @endian: A #FuEndianType, e.g. %G_LITTLE_ENDIAN
* *
* Writes a value to a buffer using a specified endian. * Writes a value to a buffer using a specified endian.
*
* Since: 1.0.3
**/ **/
void void
fu_common_write_uint32 (guint8 *buf, guint32 val_native, FuEndianType endian) fu_common_write_uint32 (guint8 *buf, guint32 val_native, FuEndianType endian)
@ -739,6 +786,8 @@ fu_common_write_uint32 (guint8 *buf, guint32 val_native, FuEndianType endian)
* Read a value from a buffer using a specified endian. * Read a value from a buffer using a specified endian.
* *
* Returns: a value in host byte-order * Returns: a value in host byte-order
*
* Since: 1.0.3
**/ **/
guint16 guint16
fu_common_read_uint16 (const guint8 *buf, FuEndianType endian) fu_common_read_uint16 (const guint8 *buf, FuEndianType endian)
@ -766,6 +815,8 @@ fu_common_read_uint16 (const guint8 *buf, FuEndianType endian)
* Read a value from a buffer using a specified endian. * Read a value from a buffer using a specified endian.
* *
* Returns: a value in host byte-order * Returns: a value in host byte-order
*
* Since: 1.0.3
**/ **/
guint32 guint32
fu_common_read_uint32 (const guint8 *buf, FuEndianType endian) fu_common_read_uint32 (const guint8 *buf, FuEndianType endian)
@ -793,6 +844,8 @@ fu_common_read_uint32 (const guint8 *buf, FuEndianType endian)
* prefixed with "0x" where they are parsed as base 16. * prefixed with "0x" where they are parsed as base 16.
* *
* Returns: integer value, or 0x0 for error * Returns: integer value, or 0x0 for error
*
* Since: 1.1.2
**/ **/
guint64 guint64
fu_common_strtoull (const gchar *str) fu_common_strtoull (const gchar *str)
@ -814,6 +867,8 @@ fu_common_strtoull (const gchar *str)
* Removes leading and trailing whitespace from a constant string. * Removes leading and trailing whitespace from a constant string.
* *
* Returns: newly allocated string * Returns: newly allocated string
*
* Since: 1.1.2
**/ **/
gchar * gchar *
fu_common_strstrip (const gchar *str) fu_common_strstrip (const gchar *str)
@ -890,6 +945,8 @@ fu_common_error_array_matches_any (GPtrArray *errors, FwupdError *error_codes)
* completely bespoke error where required. * completely bespoke error where required.
* *
* Returns: (transfer full): a #GError, never %NULL * Returns: (transfer full): a #GError, never %NULL
*
* Since: 1.0.8
**/ **/
GError * GError *
fu_common_error_array_get_best (GPtrArray *errors) fu_common_error_array_get_best (GPtrArray *errors)
@ -948,6 +1005,8 @@ fu_common_error_array_get_best (GPtrArray *errors)
* environment variables, for instance %FWUPD_DATADIR. * environment variables, for instance %FWUPD_DATADIR.
* *
* Returns: a system path, or %NULL if invalid * Returns: a system path, or %NULL if invalid
*
* Since: 1.0.8
**/ **/
gchar * gchar *
fu_common_get_path (FuPathKind path_kind) fu_common_get_path (FuPathKind path_kind)
@ -963,8 +1022,8 @@ fu_common_get_path (FuPathKind path_kind)
return g_strdup (tmp); return g_strdup (tmp);
tmp = g_getenv ("SNAP_USER_DATA"); tmp = g_getenv ("SNAP_USER_DATA");
if (tmp != NULL) if (tmp != NULL)
return g_build_filename (tmp, LOCALSTATEDIR, NULL); return g_build_filename (tmp, FWUPD_LOCALSTATEDIR, NULL);
return g_build_filename (LOCALSTATEDIR, NULL); return g_build_filename (FWUPD_LOCALSTATEDIR, NULL);
/* /sys/firmware */ /* /sys/firmware */
case FU_PATH_KIND_SYSFSDIR_FW: case FU_PATH_KIND_SYSFSDIR_FW:
tmp = g_getenv ("FWUPD_SYSFSFWDIR"); tmp = g_getenv ("FWUPD_SYSFSFWDIR");
@ -990,8 +1049,8 @@ fu_common_get_path (FuPathKind path_kind)
return g_strdup (tmp); return g_strdup (tmp);
tmp = g_getenv ("SNAP_USER_DATA"); tmp = g_getenv ("SNAP_USER_DATA");
if (tmp != NULL) if (tmp != NULL)
return g_build_filename (tmp, SYSCONFDIR, NULL); return g_build_filename (tmp, FWUPD_SYSCONFDIR, NULL);
return g_strdup (SYSCONFDIR); return g_strdup (FWUPD_SYSCONFDIR);
/* /usr/lib/<triplet>/fwupd-plugins-3 */ /* /usr/lib/<triplet>/fwupd-plugins-3 */
case FU_PATH_KIND_PLUGINDIR_PKG: case FU_PATH_KIND_PLUGINDIR_PKG:
tmp = g_getenv ("FWUPD_PLUGINDIR"); tmp = g_getenv ("FWUPD_PLUGINDIR");
@ -999,8 +1058,8 @@ fu_common_get_path (FuPathKind path_kind)
return g_strdup (tmp); return g_strdup (tmp);
tmp = g_getenv ("SNAP"); tmp = g_getenv ("SNAP");
if (tmp != NULL) if (tmp != NULL)
return g_build_filename (tmp, PLUGINDIR, NULL); return g_build_filename (tmp, FWUPD_PLUGINDIR, NULL);
return g_build_filename (PLUGINDIR, NULL); return g_build_filename (FWUPD_PLUGINDIR, NULL);
/* /usr/share/fwupd */ /* /usr/share/fwupd */
case FU_PATH_KIND_DATADIR_PKG: case FU_PATH_KIND_DATADIR_PKG:
tmp = g_getenv ("FWUPD_DATADIR"); tmp = g_getenv ("FWUPD_DATADIR");
@ -1008,8 +1067,8 @@ fu_common_get_path (FuPathKind path_kind)
return g_strdup (tmp); return g_strdup (tmp);
tmp = g_getenv ("SNAP"); tmp = g_getenv ("SNAP");
if (tmp != NULL) if (tmp != NULL)
return g_build_filename (tmp, DATADIR, PACKAGE_NAME, NULL); return g_build_filename (tmp, FWUPD_DATADIR, PACKAGE_NAME, NULL);
return g_build_filename (DATADIR, PACKAGE_NAME, NULL); return g_build_filename (FWUPD_DATADIR, PACKAGE_NAME, NULL);
/* /usr/libexec/fwupd/efi */ /* /usr/libexec/fwupd/efi */
case FU_PATH_KIND_EFIAPPDIR: case FU_PATH_KIND_EFIAPPDIR:
tmp = g_getenv ("FWUPD_EFIAPPDIR"); tmp = g_getenv ("FWUPD_EFIAPPDIR");
@ -1044,6 +1103,11 @@ fu_common_get_path (FuPathKind path_kind)
return g_build_filename (tmp, NULL); return g_build_filename (tmp, NULL);
basedir = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR); basedir = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR);
return g_build_filename (basedir, "cache", PACKAGE_NAME, NULL); return g_build_filename (basedir, "cache", PACKAGE_NAME, NULL);
case FU_PATH_KIND_OFFLINE_TRIGGER:
tmp = g_getenv ("FWUPD_OFFLINE_TRIGGER");
if (tmp != NULL)
return g_strdup (tmp);
return g_strdup ("/system-update");
case FU_PATH_KIND_POLKIT_ACTIONS: case FU_PATH_KIND_POLKIT_ACTIONS:
#ifdef POLKIT_ACTIONDIR #ifdef POLKIT_ACTIONDIR
return g_strdup (POLKIT_ACTIONDIR); return g_strdup (POLKIT_ACTIONDIR);
@ -1149,6 +1213,17 @@ fu_common_strwidth (const gchar *text)
return width; return width;
} }
/**
* fu_common_string_append_kv:
* @str: A #GString
* @idt: The indent
* @key: A string to append
* @value: a string to append
*
* Appends a key and string value to a string
*
* Since: 1.2.4
*/
void void
fu_common_string_append_kv (GString *str, guint idt, const gchar *key, const gchar *value) fu_common_string_append_kv (GString *str, guint idt, const gchar *key, const gchar *value)
{ {
@ -1187,6 +1262,17 @@ fu_common_string_append_kv (GString *str, guint idt, const gchar *key, const gch
} }
} }
/**
* fu_common_string_append_ku:
* @str: A #GString
* @idt: The indent
* @key: A string to append
* @value: guint64
*
* Appends a key and unsigned integer to a string
*
* Since: 1.2.4
*/
void void
fu_common_string_append_ku (GString *str, guint idt, const gchar *key, guint64 value) fu_common_string_append_ku (GString *str, guint idt, const gchar *key, guint64 value)
{ {
@ -1194,6 +1280,17 @@ fu_common_string_append_ku (GString *str, guint idt, const gchar *key, guint64 v
fu_common_string_append_kv (str, idt, key, tmp); fu_common_string_append_kv (str, idt, key, tmp);
} }
/**
* fu_common_string_append_kx:
* @str: A #GString
* @idt: The indent
* @key: A string to append
* @value: guint64
*
* Appends a key and hex integer to a string
*
* Since: 1.2.4
*/
void void
fu_common_string_append_kx (GString *str, guint idt, const gchar *key, guint64 value) fu_common_string_append_kx (GString *str, guint idt, const gchar *key, guint64 value)
{ {
@ -1201,6 +1298,17 @@ fu_common_string_append_kx (GString *str, guint idt, const gchar *key, guint64 v
fu_common_string_append_kv (str, idt, key, tmp); fu_common_string_append_kv (str, idt, key, tmp);
} }
/**
* fu_common_string_append_kb:
* @str: A #GString
* @idt: The indent
* @key: A string to append
* @value: Boolean
*
* Appends a key and boolean value to a string
*
* Since: 1.2.4
*/
void void
fu_common_string_append_kb (GString *str, guint idt, const gchar *key, gboolean value) fu_common_string_append_kb (GString *str, guint idt, const gchar *key, gboolean value)
{ {
@ -1363,6 +1471,8 @@ fu_common_bytes_align (GBytes *bytes, gsize blksz, gchar padval)
* Checks if a byte array are just empty (0xff) bytes. * Checks if a byte array are just empty (0xff) bytes.
* *
* Return value: %TRUE if @bytes is empty * Return value: %TRUE if @bytes is empty
*
* Since: 1.2.6
**/ **/
gboolean gboolean
fu_common_bytes_is_empty (GBytes *bytes) fu_common_bytes_is_empty (GBytes *bytes)
@ -1387,6 +1497,8 @@ fu_common_bytes_is_empty (GBytes *bytes)
* Compares the buffers for equality. * Compares the buffers for equality.
* *
* Return value: %TRUE if @buf1 and @buf2 are identical * Return value: %TRUE if @buf1 and @buf2 are identical
*
* Since: 1.3.2
**/ **/
gboolean gboolean
fu_common_bytes_compare_raw (const guint8 *buf1, gsize bufsz1, fu_common_bytes_compare_raw (const guint8 *buf1, gsize bufsz1,
@ -1432,6 +1544,8 @@ fu_common_bytes_compare_raw (const guint8 *buf1, gsize bufsz1,
* Compares the buffers for equality. * Compares the buffers for equality.
* *
* Return value: %TRUE if @bytes1 and @bytes2 are identical * Return value: %TRUE if @bytes1 and @bytes2 are identical
*
* Since: 1.2.6
**/ **/
gboolean gboolean
fu_common_bytes_compare (GBytes *bytes1, GBytes *bytes2, GError **error) fu_common_bytes_compare (GBytes *bytes1, GBytes *bytes2, GError **error)
@ -1458,6 +1572,8 @@ fu_common_bytes_compare (GBytes *bytes1, GBytes *bytes2, GError **error)
* Pads a GBytes to a given @sz with `0xff`. * Pads a GBytes to a given @sz with `0xff`.
* *
* Return value: (transfer full): a #GBytes * Return value: (transfer full): a #GBytes
*
* Since: 1.3.1
**/ **/
GBytes * GBytes *
fu_common_bytes_pad (GBytes *bytes, gsize sz) fu_common_bytes_pad (GBytes *bytes, gsize sz)
@ -1488,6 +1604,8 @@ fu_common_bytes_pad (GBytes *bytes, gsize sz)
* Finds the canonicalized absolute filename for a path. * Finds the canonicalized absolute filename for a path.
* *
* Return value: A filename, or %NULL if invalid or not found * Return value: A filename, or %NULL if invalid or not found
*
* Since: 1.2.6
**/ **/
gchar * gchar *
fu_common_realpath (const gchar *filename, GError **error) fu_common_realpath (const gchar *filename, GError **error)
@ -1496,7 +1614,11 @@ fu_common_realpath (const gchar *filename, GError **error)
g_return_val_if_fail (filename != NULL, NULL); g_return_val_if_fail (filename != NULL, NULL);
#ifdef HAVE_REALPATH
if (realpath (filename, full_tmp) == NULL) { if (realpath (filename, full_tmp) == NULL) {
#else
if (_fullpath (full_tmp, filename, sizeof(full_tmp)) == NULL) {
#endif
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
G_IO_ERROR_INVALID_DATA, G_IO_ERROR_INVALID_DATA,
@ -1504,9 +1626,40 @@ fu_common_realpath (const gchar *filename, GError **error)
strerror (errno)); strerror (errno));
return NULL; return NULL;
} }
if (!g_file_test (full_tmp, G_FILE_TEST_EXISTS)) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_INVALID_DATA,
"cannot find path: %s",
full_tmp);
return NULL;
}
return g_strdup (full_tmp); return g_strdup (full_tmp);
} }
/**
* fu_common_fnmatch:
* @pattern: a glob pattern, e.g. `*foo*`
* @str: a string to match against the pattern, e.g. `bazfoobar`
*
* Matches a string against a glob pattern.
*
* Return value: %TRUE if the string matched
*
* Since: 1.3.5
**/
gboolean
fu_common_fnmatch (const gchar *pattern, const gchar *str)
{
g_return_val_if_fail (pattern != NULL, FALSE);
g_return_val_if_fail (str != NULL, FALSE);
#ifdef HAVE_FNMATCH_H
return fnmatch (pattern, str, FNM_NOESCAPE) == 0;
#else
return g_strcmp0 (pattern, str) == 0;
#endif
}
/** /**
* fu_common_strnsplit: * fu_common_strnsplit:
* @str: a string to split * @str: a string to split
@ -1518,7 +1671,9 @@ fu_common_realpath (const gchar *filename, GError **error)
* delimiter. If @max_tokens is reached, the remainder of string is appended * delimiter. If @max_tokens is reached, the remainder of string is appended
* to the last token. * to the last token.
* *
* Return value: a newly-allocated NULL-terminated array of strings * Return value: (transfer full): a newly-allocated NULL-terminated array of strings
*
* Since: 1.3.1
**/ **/
gchar ** gchar **
fu_common_strnsplit (const gchar *str, gsize sz, fu_common_strnsplit (const gchar *str, gsize sz,
@ -1554,6 +1709,8 @@ fu_common_strnsplit (const gchar *str, gsize sz,
* malicious data from a device or firmware could cause memory corruption. * malicious data from a device or firmware could cause memory corruption.
* *
* Return value: %TRUE if the bytes were copied, %FALSE otherwise * Return value: %TRUE if the bytes were copied, %FALSE otherwise
*
* Since: 1.3.1
**/ **/
gboolean gboolean
fu_memcpy_safe (guint8 *dst, gsize dst_sz, gsize dst_offset, fu_memcpy_safe (guint8 *dst, gsize dst_sz, gsize dst_offset,
@ -1616,6 +1773,8 @@ fu_memcpy_safe (guint8 *dst, gsize dst_sz, gsize dst_offset,
* malicious data from a device or firmware could cause memory corruption. * malicious data from a device or firmware could cause memory corruption.
* *
* Return value: %TRUE if @value was set, %FALSE otherwise * Return value: %TRUE if @value was set, %FALSE otherwise
*
* Since: 1.3.3
**/ **/
gboolean gboolean
fu_common_read_uint8_safe (const guint8 *buf, fu_common_read_uint8_safe (const guint8 *buf,
@ -1650,6 +1809,8 @@ fu_common_read_uint8_safe (const guint8 *buf,
* malicious data from a device or firmware could cause memory corruption. * malicious data from a device or firmware could cause memory corruption.
* *
* Return value: %TRUE if @value was set, %FALSE otherwise * Return value: %TRUE if @value was set, %FALSE otherwise
*
* Since: 1.3.3
**/ **/
gboolean gboolean
fu_common_read_uint16_safe (const guint8 *buf, fu_common_read_uint16_safe (const guint8 *buf,
@ -1685,6 +1846,8 @@ fu_common_read_uint16_safe (const guint8 *buf,
* malicious data from a device or firmware could cause memory corruption. * malicious data from a device or firmware could cause memory corruption.
* *
* Return value: %TRUE if @value was set, %FALSE otherwise * Return value: %TRUE if @value was set, %FALSE otherwise
*
* Since: 1.3.3
**/ **/
gboolean gboolean
fu_common_read_uint32_safe (const guint8 *buf, fu_common_read_uint32_safe (const guint8 *buf,
@ -1704,12 +1867,31 @@ fu_common_read_uint32_safe (const guint8 *buf,
return TRUE; return TRUE;
} }
/**
* fu_byte_array_append_uint8:
* @array: A #GByteArray
* @data: #guint8
*
* Adds a 8 bit integer to a byte array
*
* Since: 1.3.1
**/
void void
fu_byte_array_append_uint8 (GByteArray *array, guint8 data) fu_byte_array_append_uint8 (GByteArray *array, guint8 data)
{ {
g_byte_array_append (array, &data, sizeof(data)); g_byte_array_append (array, &data, sizeof(data));
} }
/**
* fu_byte_array_append_uint16:
* @array: A #GByteArray
* @data: #guint16
* @endian: #FuEndianType
*
* Adds a 16 bit integer to a byte array
*
* Since: 1.3.1
**/
void void
fu_byte_array_append_uint16 (GByteArray *array, guint16 data, FuEndianType endian) fu_byte_array_append_uint16 (GByteArray *array, guint16 data, FuEndianType endian)
{ {
@ -1718,6 +1900,16 @@ fu_byte_array_append_uint16 (GByteArray *array, guint16 data, FuEndianType endia
g_byte_array_append (array, buf, sizeof(buf)); g_byte_array_append (array, buf, sizeof(buf));
} }
/**
* fu_byte_array_append_uint32:
* @array: A #GByteArray
* @data: #guint32
* @endian: #FuEndianType
*
* Adds a 32 bit integer to a byte array
*
* Since: 1.3.1
**/
void void
fu_byte_array_append_uint32 (GByteArray *array, guint32 data, FuEndianType endian) fu_byte_array_append_uint32 (GByteArray *array, guint32 data, FuEndianType endian)
{ {

View File

@ -54,6 +54,7 @@ typedef guint FuEndianType;
* @FU_PATH_KIND_SYSFSDIR_DRIVERS: The platform sysfs directory (IE /sys/bus/platform/drivers) * @FU_PATH_KIND_SYSFSDIR_DRIVERS: The platform sysfs directory (IE /sys/bus/platform/drivers)
* @FU_PATH_KIND_SYSFSDIR_TPM: The TPM sysfs directory (IE /sys/class/tpm) * @FU_PATH_KIND_SYSFSDIR_TPM: The TPM sysfs directory (IE /sys/class/tpm)
* @FU_PATH_KIND_POLKIT_ACTIONS: The directory for policy kit actions (IE /usr/share/polkit-1/actions/) * @FU_PATH_KIND_POLKIT_ACTIONS: The directory for policy kit actions (IE /usr/share/polkit-1/actions/)
* @FU_PATH_KIND_OFFLINE_TRIGGER: The file for the offline trigger (IE /system-update)
* *
* Path types to use when dynamically determining a path at runtime * Path types to use when dynamically determining a path at runtime
**/ **/
@ -70,6 +71,7 @@ typedef enum {
FU_PATH_KIND_SYSFSDIR_DRIVERS, FU_PATH_KIND_SYSFSDIR_DRIVERS,
FU_PATH_KIND_SYSFSDIR_TPM, FU_PATH_KIND_SYSFSDIR_TPM,
FU_PATH_KIND_POLKIT_ACTIONS, FU_PATH_KIND_POLKIT_ACTIONS,
FU_PATH_KIND_OFFLINE_TRIGGER,
/*< private >*/ /*< private >*/
FU_PATH_KIND_LAST FU_PATH_KIND_LAST
} FuPathKind; } FuPathKind;
@ -87,6 +89,8 @@ gboolean fu_common_spawn_sync (const gchar * const *argv,
gchar *fu_common_get_path (FuPathKind path_kind); gchar *fu_common_get_path (FuPathKind path_kind);
gchar *fu_common_realpath (const gchar *filename, gchar *fu_common_realpath (const gchar *filename,
GError **error); GError **error);
gboolean fu_common_fnmatch (const gchar *pattern,
const gchar *str);
gboolean fu_common_rmtree (const gchar *directory, gboolean fu_common_rmtree (const gchar *directory,
GError **error); GError **error);
GPtrArray *fu_common_get_files_recursive (const gchar *path, GPtrArray *fu_common_get_files_recursive (const gchar *path,

View File

@ -0,0 +1,13 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
G_BEGIN_DECLS
/* indeed, nothing */
G_END_DECLS

View File

@ -84,6 +84,8 @@ fu_device_locker_init (FuDeviceLocker *self)
* Think of this object as the device ownership. * Think of this object as the device ownership.
* *
* Returns: a #FuDeviceLocker, or %NULL if the @open_func failed. * Returns: a #FuDeviceLocker, or %NULL if the @open_func failed.
*
* Since: 1.0.0
**/ **/
FuDeviceLocker * FuDeviceLocker *
fu_device_locker_new (gpointer device, GError **error) fu_device_locker_new (gpointer device, GError **error)
@ -130,6 +132,8 @@ fu_device_locker_new (gpointer device, GError **error)
* Think of this object as the device ownership. * Think of this object as the device ownership.
* *
* Returns: a #FuDeviceLocker, or %NULL if the @open_func failed. * Returns: a #FuDeviceLocker, or %NULL if the @open_func failed.
*
* Since: 1.0.0
**/ **/
FuDeviceLocker * FuDeviceLocker *
fu_device_locker_new_full (gpointer device, fu_device_locker_new_full (gpointer device,

View File

@ -36,6 +36,7 @@ typedef struct {
gchar *equivalent_id; gchar *equivalent_id;
gchar *physical_id; gchar *physical_id;
gchar *logical_id; gchar *logical_id;
gchar *protocol;
FuDevice *alternate; FuDevice *alternate;
FuDevice *parent; /* noref */ FuDevice *parent; /* noref */
FuQuirks *quirks; FuQuirks *quirks;
@ -65,7 +66,9 @@ enum {
PROP_PROGRESS, PROP_PROGRESS,
PROP_PHYSICAL_ID, PROP_PHYSICAL_ID,
PROP_LOGICAL_ID, PROP_LOGICAL_ID,
PROP_PROTOCOL,
PROP_QUIRKS, PROP_QUIRKS,
PROP_PARENT,
PROP_LAST PROP_LAST
}; };
@ -91,9 +94,15 @@ fu_device_get_property (GObject *object, guint prop_id,
case PROP_LOGICAL_ID: case PROP_LOGICAL_ID:
g_value_set_string (value, priv->logical_id); g_value_set_string (value, priv->logical_id);
break; break;
case PROP_PROTOCOL:
g_value_set_string (value, priv->protocol);
break;
case PROP_QUIRKS: case PROP_QUIRKS:
g_value_set_object (value, priv->quirks); g_value_set_object (value, priv->quirks);
break; break;
case PROP_PARENT:
g_value_set_object (value, priv->parent);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -105,6 +114,7 @@ fu_device_set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec) const GValue *value, GParamSpec *pspec)
{ {
FuDevice *self = FU_DEVICE (object); FuDevice *self = FU_DEVICE (object);
FuDevicePrivate *priv = GET_PRIVATE (self);
switch (prop_id) { switch (prop_id) {
case PROP_STATUS: case PROP_STATUS:
fu_device_set_status (self, g_value_get_uint (value)); fu_device_set_status (self, g_value_get_uint (value));
@ -118,9 +128,16 @@ fu_device_set_property (GObject *object, guint prop_id,
case PROP_LOGICAL_ID: case PROP_LOGICAL_ID:
fu_device_set_logical_id (self, g_value_get_string (value)); fu_device_set_logical_id (self, g_value_get_string (value));
break; break;
case PROP_PROTOCOL:
fu_device_set_protocol (self, g_value_get_string (value));
break;
case PROP_QUIRKS: case PROP_QUIRKS:
fu_device_set_quirks (self, g_value_get_object (value)); fu_device_set_quirks (self, g_value_get_object (value));
break; break;
case PROP_PARENT:
/* noref */
priv->parent = g_value_get_object (value);
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break; break;
@ -133,7 +150,7 @@ fu_device_set_property (GObject *object, guint prop_id,
* *
* Gets the list of possible plugin names, typically added from quirk files. * Gets the list of possible plugin names, typically added from quirk files.
* *
* Returns: (element-type utf-8) (transfer container): plugin names * Returns: (element-type utf8) (transfer container): plugin names
* *
* Since: 1.3.3 * Since: 1.3.3
**/ **/
@ -307,6 +324,16 @@ fu_device_set_priority (FuDevice *self, guint priority)
priv->priority = priority; priv->priority = priority;
} }
/**
* fu_device_get_equivalent_id:
* @self: A #FuDevice
*
* Gets any equivalent ID for a device
*
* Returns: (transfer none): a #gchar or NULL
*
* Since: 0.6.1
**/
const gchar * const gchar *
fu_device_get_equivalent_id (FuDevice *self) fu_device_get_equivalent_id (FuDevice *self)
{ {
@ -315,6 +342,15 @@ fu_device_get_equivalent_id (FuDevice *self)
return priv->equivalent_id; return priv->equivalent_id;
} }
/**
* fu_device_set_equivalent_id:
* @self: A #FuDevice
* @equivalent_id: A string
*
* Sets any equivalent ID for a device
*
* Since: 0.6.1
**/
void void
fu_device_set_equivalent_id (FuDevice *self, const gchar *equivalent_id) fu_device_set_equivalent_id (FuDevice *self, const gchar *equivalent_id)
{ {
@ -325,7 +361,7 @@ fu_device_set_equivalent_id (FuDevice *self, const gchar *equivalent_id)
} }
/** /**
* fu_device_get_alternate: * fu_device_get_alternate_id:
* @self: A #FuDevice * @self: A #FuDevice
* *
* Gets any alternate device ID. An alternate device may be linked to the primary * Gets any alternate device ID. An alternate device may be linked to the primary
@ -344,9 +380,9 @@ fu_device_get_alternate_id (FuDevice *self)
} }
/** /**
* fu_device_set_alternate: * fu_device_set_alternate_id:
* @self: A #FuDevice * @self: A #FuDevice
* @alternate: Another #FuDevice * @alternate_id: Another #FuDevice
* *
* Sets any alternate device ID. An alternate device may be linked to the primary * Sets any alternate device ID. An alternate device may be linked to the primary
* device in some way. * device in some way.
@ -430,6 +466,19 @@ fu_device_get_parent (FuDevice *self)
return priv->parent; return priv->parent;
} }
/**
* fu_device_set_parent:
* @self: A #FuDevice
* @parent: A #FuDevice
*
* Sets any parent device. An parent device is logically "above" the current
* device and this may be reflected in client tools.
*
* This information also allows the plugin to optionally verify the parent
* device, for instance checking the parent device firmware version.
*
* Since: 1.0.8
**/
void void
fu_device_set_parent (FuDevice *self, FuDevice *parent) fu_device_set_parent (FuDevice *self, FuDevice *parent)
{ {
@ -585,7 +634,7 @@ void
fu_device_add_parent_guid (FuDevice *self, const gchar *guid) fu_device_add_parent_guid (FuDevice *self, const gchar *guid)
{ {
FuDevicePrivate *priv = GET_PRIVATE (self); FuDevicePrivate *priv = GET_PRIVATE (self);
g_autoptr(GRWLockReaderLocker) locker = NULL; g_autoptr(GRWLockWriterLocker) locker = NULL;
g_return_if_fail (FU_IS_DEVICE (self)); g_return_if_fail (FU_IS_DEVICE (self));
g_return_if_fail (guid != NULL); g_return_if_fail (guid != NULL);
@ -778,6 +827,16 @@ fu_device_set_quirk_kv (FuDevice *self,
return FALSE; return FALSE;
} }
/**
* fu_device_get_specialized_gtype:
* @self: A #FuDevice
*
* Gets the specialized type of the device
*
* Returns:#GType
*
* Since: 1.3.3
**/
GType GType
fu_device_get_specialized_gtype (FuDevice *self) fu_device_get_specialized_gtype (FuDevice *self)
{ {
@ -931,7 +990,17 @@ fu_device_has_guid (FuDevice *self, const gchar *guid)
return fwupd_device_has_guid (FWUPD_DEVICE (self), guid); return fwupd_device_has_guid (FWUPD_DEVICE (self), guid);
} }
/* private */ /**
* fu_device_add_instance_id_full:
* @self: A #FuDevice
* @instance_id: A Instance ID, e.g. `WacomAES`
* @flags: A #FuDeviceInstanceFlags
*
* Adds an instance ID with all paramters set
*
*
* Since: 1.2.9
**/
void void
fu_device_add_instance_id_full (FuDevice *self, fu_device_add_instance_id_full (FuDevice *self,
const gchar *instance_id, const gchar *instance_id,
@ -1149,7 +1218,7 @@ void
fu_device_remove_metadata (FuDevice *self, const gchar *key) fu_device_remove_metadata (FuDevice *self, const gchar *key)
{ {
FuDevicePrivate *priv = GET_PRIVATE (self); FuDevicePrivate *priv = GET_PRIVATE (self);
g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&priv->metadata_mutex); g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&priv->metadata_mutex);
g_return_if_fail (FU_IS_DEVICE (self)); g_return_if_fail (FU_IS_DEVICE (self));
g_return_if_fail (key != NULL); g_return_if_fail (key != NULL);
g_return_if_fail (locker != NULL); g_return_if_fail (locker != NULL);
@ -1170,7 +1239,7 @@ void
fu_device_set_metadata (FuDevice *self, const gchar *key, const gchar *value) fu_device_set_metadata (FuDevice *self, const gchar *key, const gchar *value)
{ {
FuDevicePrivate *priv = GET_PRIVATE (self); FuDevicePrivate *priv = GET_PRIVATE (self);
g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&priv->metadata_mutex); g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&priv->metadata_mutex);
g_return_if_fail (FU_IS_DEVICE (self)); g_return_if_fail (FU_IS_DEVICE (self));
g_return_if_fail (key != NULL); g_return_if_fail (key != NULL);
g_return_if_fail (value != NULL); g_return_if_fail (value != NULL);
@ -1411,6 +1480,42 @@ fu_device_set_logical_id (FuDevice *self, const gchar *logical_id)
priv->logical_id = g_strdup (logical_id); priv->logical_id = g_strdup (logical_id);
} }
/**
* fu_device_get_protocol:
* @self: A #FuDevice
*
* Gets the protocol ID on the device.
*
* Returns: a string value e.g. `org.hughski.colorhug`, or %NULL
*
* Since: 1.3.5
**/
const gchar *
fu_device_get_protocol (FuDevice *self)
{
FuDevicePrivate *priv = GET_PRIVATE (self);
g_return_val_if_fail (FU_IS_DEVICE (self), NULL);
return priv->protocol;
}
/**
* fu_device_set_protocol:
* @self: A #FuDevice
* @protocol: a defined protocol ID, e.g. `org.hughski.colorhug`
*
* Sets the protocol ID on the device.
*
* Since: 1.3.5
**/
void
fu_device_set_protocol (FuDevice *self, const gchar *protocol)
{
FuDevicePrivate *priv = GET_PRIVATE (self);
g_return_if_fail (FU_IS_DEVICE (self));
g_free (priv->protocol);
priv->protocol = g_strdup (protocol);
}
/** /**
* fu_device_set_physical_id: * fu_device_set_physical_id:
* @self: A #FuDevice * @self: A #FuDevice
@ -1458,6 +1563,16 @@ fu_device_get_physical_id (FuDevice *self)
return priv->physical_id; return priv->physical_id;
} }
/**
* fu_device_add_flag:
* @self: A #FuDevice
* @flag: A #FwupdDeviceFlags
*
* Adds a device flag to the device
*
* Since: 0.1.0
**/
void void
fu_device_add_flag (FuDevice *self, FwupdDeviceFlags flag) fu_device_add_flag (FuDevice *self, FwupdDeviceFlags flag)
{ {
@ -1729,6 +1844,8 @@ fu_device_add_string (FuDevice *self, guint idt, GString *str)
fu_common_string_append_kv (str, idt + 1, "PhysicalId", priv->physical_id); fu_common_string_append_kv (str, idt + 1, "PhysicalId", priv->physical_id);
if (priv->logical_id != NULL) if (priv->logical_id != NULL)
fu_common_string_append_kv (str, idt + 1, "LogicalId", priv->logical_id); fu_common_string_append_kv (str, idt + 1, "LogicalId", priv->logical_id);
if (priv->protocol != NULL)
fu_common_string_append_kv (str, idt + 1, "Protocol", priv->protocol);
if (priv->size_min > 0) { if (priv->size_min > 0) {
g_autofree gchar *sz = g_strdup_printf ("%" G_GUINT64_FORMAT, priv->size_min); g_autofree gchar *sz = g_strdup_printf ("%" G_GUINT64_FORMAT, priv->size_min);
fu_common_string_append_kv (str, idt + 1, "FirmwareSizeMin", sz); fu_common_string_append_kv (str, idt + 1, "FirmwareSizeMin", sz);
@ -2071,6 +2188,7 @@ fu_device_reload (FuDevice *self, GError **error)
/** /**
* fu_device_prepare: * fu_device_prepare:
* @self: A #FuDevice * @self: A #FuDevice
* @flags: A #FwupdInstallFlags
* @error: A #GError * @error: A #GError
* *
* Prepares a device for update. A different plugin can handle each of * Prepares a device for update. A different plugin can handle each of
@ -2099,6 +2217,7 @@ fu_device_prepare (FuDevice *self, FwupdInstallFlags flags, GError **error)
/** /**
* fu_device_cleanup: * fu_device_cleanup:
* @self: A #FuDevice * @self: A #FuDevice
* @flags: A #FwupdInstallFlags
* @error: A #GError * @error: A #GError
* *
* Cleans up a device after an update. A different plugin can handle each of * Cleans up a device after an update. A different plugin can handle each of
@ -2412,8 +2531,6 @@ fu_device_activate (FuDevice *self, GError **error)
* This should be done in case the backing device has changed, for instance if * This should be done in case the backing device has changed, for instance if
* a USB device has been replugged. * a USB device has been replugged.
* *
* Returns: %TRUE for success
*
* Since: 1.1.2 * Since: 1.1.2
**/ **/
void void
@ -2456,6 +2573,8 @@ fu_device_incorporate (FuDevice *self, FuDevice *donor)
fu_device_set_physical_id (self, priv_donor->physical_id); fu_device_set_physical_id (self, priv_donor->physical_id);
if (priv->logical_id == NULL && priv_donor->logical_id != NULL) if (priv->logical_id == NULL && priv_donor->logical_id != NULL)
fu_device_set_logical_id (self, priv_donor->logical_id); fu_device_set_logical_id (self, priv_donor->logical_id);
if (priv->protocol == NULL && priv_donor->protocol != NULL)
fu_device_set_protocol (self, priv_donor->protocol);
if (priv->quirks == NULL) if (priv->quirks == NULL)
fu_device_set_quirks (self, fu_device_get_quirks (donor)); fu_device_set_quirks (self, fu_device_get_quirks (donor));
g_rw_lock_reader_lock (&priv_donor->parent_guids_mutex); g_rw_lock_reader_lock (&priv_donor->parent_guids_mutex);
@ -2489,7 +2608,29 @@ fu_device_incorporate (FuDevice *self, FuDevice *donor)
} }
/** /**
* fu_device_incorporate_from_component: * fu_device_incorporate_flag:
* @self: A #FuDevice
* @donor: Another #FuDevice
* @flag: A #FwupdDeviceFlags value
*
* Copy the value of a specific flag from the donor object.
*
* Since: 1.3.5
**/
void
fu_device_incorporate_flag (FuDevice *self, FuDevice *donor, FwupdDeviceFlags flag)
{
if (fu_device_has_flag (donor, flag) && !fu_device_has_flag (self, flag)) {
g_debug ("donor set %s", fwupd_device_flag_to_string (flag));
fu_device_add_flag (self, flag);
} else if (!fu_device_has_flag (donor, flag) && fu_device_has_flag (self, flag)) {
g_debug ("donor unset %s", fwupd_device_flag_to_string (flag));
fu_device_remove_flag (self, flag);
}
}
/**
* fu_device_incorporate_from_component: (skip):
* @device: A #FuDevice * @device: A #FuDevice
* @component: A #XbNode * @component: A #XbNode
* *
@ -2535,6 +2676,11 @@ fu_device_class_init (FuDeviceClass *klass)
G_PARAM_STATIC_NAME); G_PARAM_STATIC_NAME);
g_object_class_install_property (object_class, PROP_LOGICAL_ID, pspec); g_object_class_install_property (object_class, PROP_LOGICAL_ID, pspec);
pspec = g_param_spec_string ("protocol", NULL, NULL, NULL,
G_PARAM_READWRITE |
G_PARAM_STATIC_NAME);
g_object_class_install_property (object_class, PROP_PROTOCOL, pspec);
pspec = g_param_spec_uint ("progress", NULL, NULL, pspec = g_param_spec_uint ("progress", NULL, NULL,
0, 100, 0, 0, 100, 0,
G_PARAM_READWRITE | G_PARAM_READWRITE |
@ -2546,6 +2692,13 @@ fu_device_class_init (FuDeviceClass *klass)
G_PARAM_READWRITE | G_PARAM_READWRITE |
G_PARAM_STATIC_NAME); G_PARAM_STATIC_NAME);
g_object_class_install_property (object_class, PROP_QUIRKS, pspec); g_object_class_install_property (object_class, PROP_QUIRKS, pspec);
pspec = g_param_spec_object ("parent", NULL, NULL,
FU_TYPE_DEVICE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_NAME);
g_object_class_install_property (object_class, PROP_PARENT, pspec);
} }
static void static void
@ -2586,10 +2739,18 @@ fu_device_finalize (GObject *object)
g_free (priv->equivalent_id); g_free (priv->equivalent_id);
g_free (priv->physical_id); g_free (priv->physical_id);
g_free (priv->logical_id); g_free (priv->logical_id);
g_free (priv->protocol);
G_OBJECT_CLASS (fu_device_parent_class)->finalize (object); G_OBJECT_CLASS (fu_device_parent_class)->finalize (object);
} }
/**
* fu_device_new:
*
* Creates a new #Fudevice
*
* Since: 0.1.0
**/
FuDevice * FuDevice *
fu_device_new (void) fu_device_new (void)
{ {

View File

@ -186,6 +186,9 @@ void fu_device_set_physical_id (FuDevice *self,
const gchar *fu_device_get_logical_id (FuDevice *self); const gchar *fu_device_get_logical_id (FuDevice *self);
void fu_device_set_logical_id (FuDevice *self, void fu_device_set_logical_id (FuDevice *self,
const gchar *logical_id); const gchar *logical_id);
const gchar *fu_device_get_protocol (FuDevice *self);
void fu_device_set_protocol (FuDevice *self,
const gchar *protocol);
void fu_device_add_flag (FuDevice *self, void fu_device_add_flag (FuDevice *self,
FwupdDeviceFlags flag); FwupdDeviceFlags flag);
const gchar *fu_device_get_custom_flags (FuDevice *self); const gchar *fu_device_get_custom_flags (FuDevice *self);
@ -243,6 +246,9 @@ gboolean fu_device_cleanup (FuDevice *self,
GError **error); GError **error);
void fu_device_incorporate (FuDevice *self, void fu_device_incorporate (FuDevice *self,
FuDevice *donor); FuDevice *donor);
void fu_device_incorporate_flag (FuDevice *self,
FuDevice *donor,
FwupdDeviceFlags flag);
gboolean fu_device_open (FuDevice *self, gboolean fu_device_open (FuDevice *self,
GError **error); GError **error);
gboolean fu_device_close (FuDevice *self, gboolean fu_device_close (FuDevice *self,

View File

@ -11,6 +11,15 @@
#include "fu-common.h" #include "fu-common.h"
#include "fu-dfu-firmware.h" #include "fu-dfu-firmware.h"
/**
* SECTION:fu-dfu-firmware
* @short_description: DFU firmware image
*
* An object that represents a DFU firmware image.
*
* See also: #FuFirmware
*/
typedef struct { typedef struct {
guint16 vid; guint16 vid;
guint16 pid; guint16 pid;
@ -39,6 +48,8 @@ fu_dfu_firmware_to_string (FuFirmware *firmware, guint idt, GString *str)
* Gets the vendor ID, or 0xffff for no restriction. * Gets the vendor ID, or 0xffff for no restriction.
* *
* Return value: integer * Return value: integer
*
* Since: 1.3.3
**/ **/
guint16 guint16
fu_dfu_firmware_get_vid (FuDfuFirmware *self) fu_dfu_firmware_get_vid (FuDfuFirmware *self)
@ -55,6 +66,8 @@ fu_dfu_firmware_get_vid (FuDfuFirmware *self)
* Gets the product ID, or 0xffff for no restriction. * Gets the product ID, or 0xffff for no restriction.
* *
* Return value: integer * Return value: integer
*
* Since: 1.3.3
**/ **/
guint16 guint16
fu_dfu_firmware_get_pid (FuDfuFirmware *self) fu_dfu_firmware_get_pid (FuDfuFirmware *self)
@ -71,6 +84,8 @@ fu_dfu_firmware_get_pid (FuDfuFirmware *self)
* Gets the device ID, or 0xffff for no restriction. * Gets the device ID, or 0xffff for no restriction.
* *
* Return value: integer * Return value: integer
*
* Since: 1.3.3
**/ **/
guint16 guint16
fu_dfu_firmware_get_release (FuDfuFirmware *self) fu_dfu_firmware_get_release (FuDfuFirmware *self)
@ -87,6 +102,8 @@ fu_dfu_firmware_get_release (FuDfuFirmware *self)
* Gets the file format version with is 0x0100 by default. * Gets the file format version with is 0x0100 by default.
* *
* Return value: integer * Return value: integer
*
* Since: 1.3.3
**/ **/
guint16 guint16
fu_dfu_firmware_get_version (FuDfuFirmware *self) fu_dfu_firmware_get_version (FuDfuFirmware *self)
@ -102,6 +119,8 @@ fu_dfu_firmware_get_version (FuDfuFirmware *self)
* @vid: vendor ID, or 0xffff if the firmware should match any vendor * @vid: vendor ID, or 0xffff if the firmware should match any vendor
* *
* Sets the vendor ID. * Sets the vendor ID.
*
* Since: 1.3.3
**/ **/
void void
fu_dfu_firmware_set_vid (FuDfuFirmware *self, guint16 vid) fu_dfu_firmware_set_vid (FuDfuFirmware *self, guint16 vid)
@ -117,6 +136,8 @@ fu_dfu_firmware_set_vid (FuDfuFirmware *self, guint16 vid)
* @pid: product ID, or 0xffff if the firmware should match any product * @pid: product ID, or 0xffff if the firmware should match any product
* *
* Sets the product ID. * Sets the product ID.
*
* Since: 1.3.3
**/ **/
void void
fu_dfu_firmware_set_pid (FuDfuFirmware *self, guint16 pid) fu_dfu_firmware_set_pid (FuDfuFirmware *self, guint16 pid)
@ -129,9 +150,11 @@ fu_dfu_firmware_set_pid (FuDfuFirmware *self, guint16 pid)
/** /**
* fu_dfu_firmware_set_release: * fu_dfu_firmware_set_release:
* @self: a #FuDfuFirmware * @self: a #FuDfuFirmware
* @release: device ID, or 0xffff if the firmware should match any release * @release: release, or 0xffff if the firmware should match any release
* *
* Sets the device ID. * Sets the release for the dfu firmware.
*
* Since: 1.3.3
**/ **/
void void
fu_dfu_firmware_set_release (FuDfuFirmware *self, guint16 release) fu_dfu_firmware_set_release (FuDfuFirmware *self, guint16 release)
@ -147,6 +170,8 @@ fu_dfu_firmware_set_release (FuDfuFirmware *self, guint16 release)
* @version: integer * @version: integer
* *
* Sets the file format version. * Sets the file format version.
*
* Since: 1.3.3
**/ **/
void void
fu_dfu_firmware_set_version (FuDfuFirmware *self, guint16 version) fu_dfu_firmware_set_version (FuDfuFirmware *self, guint16 version)
@ -366,6 +391,13 @@ fu_dfu_firmware_class_init (FuDfuFirmwareClass *klass)
klass_firmware->write = fu_dfu_firmware_write; klass_firmware->write = fu_dfu_firmware_write;
} }
/**
* fu_dfu_firmware_new:
*
* Creates a new #FuFirmware of sub type Dfu
*
* Since: 1.3.3
**/
FuFirmware * FuFirmware *
fu_dfu_firmware_new (void) fu_dfu_firmware_new (void)
{ {

View File

@ -22,6 +22,8 @@
* length of @data. Checking the size must be done in the caller. * length of @data. Checking the size must be done in the caller.
* *
* Return value: A parsed value, or 0 for error * Return value: A parsed value, or 0 for error
*
* Since: 1.3.1
**/ **/
guint8 guint8
fu_firmware_strparse_uint4 (const gchar *data) fu_firmware_strparse_uint4 (const gchar *data)
@ -42,6 +44,8 @@ fu_firmware_strparse_uint4 (const gchar *data)
* length of @data. Checking the size must be done in the caller. * length of @data. Checking the size must be done in the caller.
* *
* Return value: A parsed value, or 0 for error * Return value: A parsed value, or 0 for error
*
* Since: 1.3.1
**/ **/
guint8 guint8
fu_firmware_strparse_uint8 (const gchar *data) fu_firmware_strparse_uint8 (const gchar *data)
@ -62,6 +66,8 @@ fu_firmware_strparse_uint8 (const gchar *data)
* length of @data. Checking the size must be done in the caller. * length of @data. Checking the size must be done in the caller.
* *
* Return value: A parsed value, or 0 for error * Return value: A parsed value, or 0 for error
*
* Since: 1.3.1
**/ **/
guint16 guint16
fu_firmware_strparse_uint16 (const gchar *data) fu_firmware_strparse_uint16 (const gchar *data)
@ -82,6 +88,8 @@ fu_firmware_strparse_uint16 (const gchar *data)
* length of @data. Checking the size must be done in the caller. * length of @data. Checking the size must be done in the caller.
* *
* Return value: A parsed value, or 0 for error * Return value: A parsed value, or 0 for error
*
* Since: 1.3.1
**/ **/
guint32 guint32
fu_firmware_strparse_uint24 (const gchar *data) fu_firmware_strparse_uint24 (const gchar *data)
@ -102,6 +110,8 @@ fu_firmware_strparse_uint24 (const gchar *data)
* length of @data. Checking the size must be done in the caller. * length of @data. Checking the size must be done in the caller.
* *
* Return value: A parsed value, or 0 for error * Return value: A parsed value, or 0 for error
*
* Since: 1.3.1
**/ **/
guint32 guint32
fu_firmware_strparse_uint32 (const gchar *data) fu_firmware_strparse_uint32 (const gchar *data)

View File

@ -354,7 +354,6 @@ fu_firmware_image_class_init (FuFirmwareImageClass *klass)
/** /**
* fu_firmware_image_new: * fu_firmware_image_new:
* @id: Optional ID
* @bytes: Optional #GBytes * @bytes: Optional #GBytes
* *
* Creates an empty firmware_image object. * Creates an empty firmware_image object.

View File

@ -17,6 +17,7 @@
* @short_description: a firmware file * @short_description: a firmware file
* *
* An object that represents a firmware file. * An object that represents a firmware file.
* See also: #FuDfuFirmware, #FuIhexFirmware, #FuSrecFirmware
*/ */
typedef struct { typedef struct {
@ -66,7 +67,7 @@ fu_firmware_set_version (FuFirmware *self, const gchar *version)
/** /**
* fu_firmware_tokenize: * fu_firmware_tokenize:
* @self: A #FuFirmware * @self: A #FuFirmware
* @image: A #GBytes * @fw: A #GBytes
* @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE * @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE
* @error: A #GError, or %NULL * @error: A #GError, or %NULL
* *
@ -98,7 +99,7 @@ fu_firmware_tokenize (FuFirmware *self, GBytes *fw,
/** /**
* fu_firmware_parse_full: * fu_firmware_parse_full:
* @self: A #FuFirmware * @self: A #FuFirmware
* @image: A #GBytes * @fw: A #GBytes
* @addr_start: Start address, useful for ignoring a bootloader * @addr_start: Start address, useful for ignoring a bootloader
* @addr_end: End address, useful for ignoring config bytes * @addr_end: End address, useful for ignoring config bytes
* @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE * @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE
@ -142,7 +143,7 @@ fu_firmware_parse_full (FuFirmware *self,
/** /**
* fu_firmware_parse: * fu_firmware_parse:
* @self: A #FuFirmware * @self: A #FuFirmware
* @image: A #GBytes * @fw: A #GBytes
* @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE * @flags: some #FwupdInstallFlags, e.g. %FWUPD_INSTALL_FLAG_FORCE
* @error: A #GError, or %NULL * @error: A #GError, or %NULL
* *
@ -259,7 +260,7 @@ fu_firmware_add_image (FuFirmware *self, FuFirmwareImage *img)
/** /**
* fu_firmware_get_images: * fu_firmware_get_images:
* @self: a #FuPlugin * @self: a #FuFirmware
* *
* Returns all the images in the firmware. * Returns all the images in the firmware.
* *
@ -520,7 +521,7 @@ fu_firmware_new (void)
/** /**
* fu_firmware_new_from_bytes: * fu_firmware_new_from_bytes:
* @self: A #GBytes image * @fw: A #GBytes image
* *
* Creates a firmware object with the provided image set as default. * Creates a firmware object with the provided image set as default.
* *

View File

@ -68,7 +68,7 @@ gboolean fu_firmware_write_file (FuFirmware *self,
GError **error); GError **error);
void fu_firmware_add_image (FuFirmware *self, void fu_firmware_add_image (FuFirmware *self,
FuFirmwareImage *image); FuFirmwareImage *img);
GPtrArray *fu_firmware_get_images (FuFirmware *self); GPtrArray *fu_firmware_get_images (FuFirmware *self);
FuFirmwareImage *fu_firmware_get_image_by_id (FuFirmware *self, FuFirmwareImage *fu_firmware_get_image_by_id (FuFirmware *self,
const gchar *id, const gchar *id,

View File

@ -36,6 +36,8 @@ G_DEFINE_TYPE (FuHwids, fu_hwids, G_TYPE_OBJECT)
* for display. * for display.
* *
* Returns: the string, e.g. `1.2.3`, or %NULL if not found * Returns: the string, e.g. `1.2.3`, or %NULL if not found
*
* Since: 0.9.3
**/ **/
const gchar * const gchar *
fu_hwids_get_value (FuHwids *self, const gchar *key) fu_hwids_get_value (FuHwids *self, const gchar *key)
@ -51,6 +53,8 @@ fu_hwids_get_value (FuHwids *self, const gchar *key)
* Finds out if a hardware GUID exists. * Finds out if a hardware GUID exists.
* *
* Returns: %TRUE if the GUID exists * Returns: %TRUE if the GUID exists
*
* Since: 0.9.3
**/ **/
gboolean gboolean
fu_hwids_has_guid (FuHwids *self, const gchar *guid) fu_hwids_has_guid (FuHwids *self, const gchar *guid)
@ -64,7 +68,9 @@ fu_hwids_has_guid (FuHwids *self, const gchar *guid)
* *
* Returns all the defined HWIDs * Returns all the defined HWIDs
* *
* Returns: (transfer none) (element-type utf-8): An array of GUIDs * Returns: (transfer none) (element-type utf8): An array of GUIDs
*
* Since: 0.9.3
**/ **/
GPtrArray * GPtrArray *
fu_hwids_get_guids (FuHwids *self) fu_hwids_get_guids (FuHwids *self)
@ -108,6 +114,8 @@ fu_hwids_get_guid_for_str (const gchar *str, GError **error)
* Gets the replacement key for a well known value. * Gets the replacement key for a well known value.
* *
* Returns: the replacement value, e.g. `Manufacturer&ProductName`, or %NULL for error. * Returns: the replacement value, e.g. `Manufacturer&ProductName`, or %NULL for error.
*
* Since: 0.9.3
**/ **/
const gchar * const gchar *
fu_hwids_get_replace_keys (FuHwids *self, const gchar *key) fu_hwids_get_replace_keys (FuHwids *self, const gchar *key)
@ -197,6 +205,8 @@ fu_hwids_get_replace_keys (FuHwids *self, const gchar *key)
* Gets the replacement values for a HardwareID key or plain key. * Gets the replacement values for a HardwareID key or plain key.
* *
* Returns: a string, e.g. `LENOVO&ThinkPad T440s`, or %NULL for error. * Returns: a string, e.g. `LENOVO&ThinkPad T440s`, or %NULL for error.
*
* Since: 0.9.3
**/ **/
gchar * gchar *
fu_hwids_get_replace_values (FuHwids *self, const gchar *keys, GError **error) fu_hwids_get_replace_values (FuHwids *self, const gchar *keys, GError **error)
@ -235,6 +245,8 @@ fu_hwids_get_replace_values (FuHwids *self, const gchar *keys, GError **error)
* Gets the GUID for a specific key. * Gets the GUID for a specific key.
* *
* Returns: a string, or %NULL for error. * Returns: a string, or %NULL for error.
*
* Since: 0.9.3
**/ **/
gchar * gchar *
fu_hwids_get_guid (FuHwids *self, const gchar *keys, GError **error) fu_hwids_get_guid (FuHwids *self, const gchar *keys, GError **error)
@ -316,6 +328,8 @@ fu_hwids_convert_integer_cb (FuSmbios *smbios,
* Reads all the SMBIOS values from the hardware. * Reads all the SMBIOS values from the hardware.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
*
* Since: 0.9.3
**/ **/
gboolean gboolean
fu_hwids_setup (FuHwids *self, FuSmbios *smbios, GError **error) fu_hwids_setup (FuHwids *self, FuSmbios *smbios, GError **error)
@ -440,6 +454,13 @@ fu_hwids_init (FuHwids *self)
self->array_guids = g_ptr_array_new_with_free_func (g_free); self->array_guids = g_ptr_array_new_with_free_func (g_free);
} }
/**
* fu_hwids_new:
*
* Creates a new #FuHwids
*
* Since: 0.9.3
**/
FuHwids * FuHwids *
fu_hwids_new (void) fu_hwids_new (void)
{ {

View File

@ -14,6 +14,15 @@
#include "fu-firmware-common.h" #include "fu-firmware-common.h"
#include "fu-ihex-firmware.h" #include "fu-ihex-firmware.h"
/**
* SECTION:fu-ihex-firmware
* @short_description: Ihex firmware image
*
* An object that represents a Ihex firmware image.
*
* See also: #FuFirmware
*/
struct _FuIhexFirmware { struct _FuIhexFirmware {
FuFirmware parent_instance; FuFirmware parent_instance;
GPtrArray *records; GPtrArray *records;
@ -434,6 +443,13 @@ fu_ihex_firmware_class_init (FuIhexFirmwareClass *klass)
klass_firmware->write = fu_ihex_firmware_write; klass_firmware->write = fu_ihex_firmware_write;
} }
/**
* fu_ihex_firmware_new:
*
* Creates a new #FuFirmware of sub type Ihex
*
* Since: 1.3.1
**/
FuFirmware * FuFirmware *
fu_ihex_firmware_new (void) fu_ihex_firmware_new (void)
{ {

View File

@ -12,8 +12,11 @@
#include <fcntl.h> #include <fcntl.h>
#include <gio/gio.h> #include <gio/gio.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#ifdef HAVE_POLL_H
#include <poll.h> #include <poll.h>
#endif
#include <string.h> #include <string.h>
#include <sys/stat.h>
#include "fwupd-error.h" #include "fwupd-error.h"
#include "fu-common.h" #include "fu-common.h"
@ -268,7 +271,7 @@ fu_io_channel_read_bytes (FuIOChannel *self,
* *
* Reads bytes from the TTY, that will fail if exceeding @timeout_ms. * Reads bytes from the TTY, that will fail if exceeding @timeout_ms.
* *
* Returns: a #GByteArray, or %NULL for error * Returns: (transfer full): a #GByteArray, or %NULL for error
* *
* Since: 1.3.2 * Since: 1.3.2
**/ **/
@ -459,6 +462,8 @@ fu_io_channel_init (FuIOChannel *self)
* Creates a new object to write and read from. * Creates a new object to write and read from.
* *
* Returns: a #FuIOChannel * Returns: a #FuIOChannel
*
* Since: 1.2.2
**/ **/
FuIOChannel * FuIOChannel *
fu_io_channel_unix_new (gint fd) fu_io_channel_unix_new (gint fd)
@ -477,10 +482,13 @@ fu_io_channel_unix_new (gint fd)
* Creates a new object to write and read from. * Creates a new object to write and read from.
* *
* Returns: a #FuIOChannel * Returns: a #FuIOChannel
*
* Since: 1.2.2
**/ **/
FuIOChannel * FuIOChannel *
fu_io_channel_new_file (const gchar *filename, GError **error) fu_io_channel_new_file (const gchar *filename, GError **error)
{ {
#ifdef HAVE_POLL_H
gint fd = g_open (filename, O_RDWR | O_NONBLOCK, S_IRWXU); gint fd = g_open (filename, O_RDWR | O_NONBLOCK, S_IRWXU);
if (fd < 0) { if (fd < 0) {
g_set_error (error, g_set_error (error,
@ -490,4 +498,11 @@ fu_io_channel_new_file (const gchar *filename, GError **error)
return NULL; return NULL;
} }
return fu_io_channel_unix_new (fd); return fu_io_channel_unix_new (fd);
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <poll.h> is unavailable");
return NULL;
#endif
} }

View File

@ -10,9 +10,8 @@
#include "fu-plugin.h" #include "fu-plugin.h"
#include "fu-smbios.h" #include "fu-smbios.h"
#define FU_OFFLINE_TRIGGER_FILENAME FU_OFFLINE_DESTDIR "/system-update"
FuPlugin *fu_plugin_new (void); FuPlugin *fu_plugin_new (void);
gboolean fu_plugin_is_open (FuPlugin *self);
void fu_plugin_set_usb_context (FuPlugin *self, void fu_plugin_set_usb_context (FuPlugin *self,
GUsbContext *usb_ctx); GUsbContext *usb_ctx);
void fu_plugin_set_hwids (FuPlugin *self, void fu_plugin_set_hwids (FuPlugin *self,
@ -112,12 +111,6 @@ gboolean fu_plugin_runner_clear_results (FuPlugin *self,
gboolean fu_plugin_runner_get_results (FuPlugin *self, gboolean fu_plugin_runner_get_results (FuPlugin *self,
FuDevice *device, FuDevice *device,
GError **error); GError **error);
gboolean fu_plugin_runner_schedule_update (FuPlugin *self,
FuDevice *device,
FwupdRelease *release,
GBytes *blob_cab,
FwupdInstallFlags flags,
GError **error);
gint fu_plugin_name_compare (FuPlugin *plugin1, gint fu_plugin_name_compare (FuPlugin *plugin1,
FuPlugin *plugin2); FuPlugin *plugin2);
gint fu_plugin_order_compare (FuPlugin *plugin1, gint fu_plugin_order_compare (FuPlugin *plugin1,

View File

@ -0,0 +1,337 @@
/*
* Copyright (C) 2016-2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include "fu-plugin.h"
#include "fu-device.h"
/**
* SECTION:fu-plugin-vfuncs
* @short_description: Virtual functions for plugins
*
* Optional functions that a plugin can implement. If implemented they will
* be automatically called by the daemon as part of the plugin lifecycle.
*
* See also: #FuPlugin
*/
/**
* fu_plugin_init:
* @plugin: A #FuPlugin
*
* Initializes the plugin.
* Sets up any static data structures fo the plugin.
* Most plugins should call fu_plugin_set_build_hash in here.
*
* Since: 0.8.0
**/
void fu_plugin_init (FuPlugin *plugin);
/**
* fu_plugin_destroy:
* @plugin: A #FuPlugin
*
* Destroys the plugin.
* Any allocated memory should be freed here.
*
* Since: 0.8.0
**/
void fu_plugin_destroy (FuPlugin *plugin);
/**
* fu_plugin_startup:
* @plugin: A #FuPlugin
* @error: A #GError
*
* Tries to start the plugin.
* Returns: TRUE for success or FALSE for failure.
*
* Any plugins not intended for the system or that have failure communicating
* with the device should return FALSE.
* Any allocated memory should be freed here.
*
* Since: 0.8.0
**/
gboolean fu_plugin_startup (FuPlugin *plugin,
GError **error);
/**
* fu_plugin_coldplug:
* @plugin: A #FuPlugin
* @error: A #GError
*
* Probes for devices.
*
* Since: 0.8.0
**/
gboolean fu_plugin_coldplug (FuPlugin *plugin,
GError **error);
/**
* fu_plugin_coldplug_prepare:
* @plugin: A #FuPlugin
* @error: A #GError
*
* Prepares to probe for devices.
*
* Since: 0.8.0
**/
gboolean fu_plugin_coldplug_prepare (FuPlugin *plugin,
GError **error);
/**
* fu_plugin_coldplug_cleanup:
* @plugin: A #FuPlugin
* @error: A #GError
*
* Cleans up from probe for devices.
*
* Since: 0.8.0
**/
gboolean fu_plugin_coldplug_cleanup (FuPlugin *plugin,
GError **error);
/**
* fu_plugin_recoldplug:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @flags: A #FuPluginVerifyFlags
* @error: A #GError or NULL
*
* Re-runs the coldplug routine for devices.
*
* Since: 1.0.4
**/
gboolean fu_plugin_recoldplug (FuPlugin *plugin,
GError **error);
/**
* fu_plugin_update:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @blob_fw: A #GBytes
* @flags: A #FwupdInstallFlags
* @error: A #GError or NULL
*
* Updates the firmware on the device with blob_fw
*
* Since: 0.9.7
**/
gboolean fu_plugin_update (FuPlugin *plugin,
FuDevice *dev,
GBytes *blob_fw,
FwupdInstallFlags flags,
GError **error);
/**
* fu_plugin_verify:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @flags: A #FuPluginVerifyFlags
* @error: A #GError or NULL
*
* Verifies the firmware on the device matches the value stored in the database
*
* Since: 0.8.0
**/
gboolean fu_plugin_verify (FuPlugin *plugin,
FuDevice *dev,
FuPluginVerifyFlags flags,
GError **error);
/**
* fu_plugin_unlock:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @error: A #GError or NULL
*
* Unlocks the device for writes.
*
* Since: 0.8.0
**/
gboolean fu_plugin_unlock (FuPlugin *plugin,
FuDevice *dev,
GError **error);
/**
* fu_plugin_activate:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @error: A #GError or NULL
*
* Activates the new firmware on the device.
*
* This is intended for devices that it is not safe to immediately activate
* the firmware. It may be called at a more convenient time instead.
*
* Since: 1.2.6
**/
gboolean fu_plugin_activate (FuPlugin *plugin,
FuDevice *dev,
GError **error);
/**
* fu_plugin_clear_results:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @error: A #GError or NULL
*
* Clears stored update results for the device.
*
* Since: 0.8.0
**/
gboolean fu_plugin_clear_results (FuPlugin *plugin,
FuDevice *dev,
GError **error);
/**
* fu_plugin_get_results:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @error: A #GError or NULL
*
* Obtains historical update results for the device.
*
* Since: 0.8.0
**/
gboolean fu_plugin_get_results (FuPlugin *plugin,
FuDevice *dev,
GError **error);
/**
* fu_plugin_update_attach:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @error: A #GError or NULL
*
* Swaps the device from bootloader mode to runtime mode.
*
* Since: 1.0.2
**/
gboolean fu_plugin_update_attach (FuPlugin *plugin,
FuDevice *dev,
GError **error);
/**
* fu_plugin_update_detach:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @error: A #GError or NULL
*
* Swaps the device from runtime mode to bootloader mode.
*
* Since: 1.0.2
**/
gboolean fu_plugin_update_detach (FuPlugin *plugin,
FuDevice *dev,
GError **error);
/**
* fu_plugin_update_prepare:
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @error: A #GError or NULL
*
* Prepares the device to receive an update.
*
* Since: 0.8.0
**/
gboolean fu_plugin_update_prepare (FuPlugin *plugin,
FwupdInstallFlags flags,
FuDevice *dev,
GError **error);
/**
* fu_plugin_update_cleanup
* @plugin: A #FuPlugin
* @dev: A #FuDevice
* @error: A #GError or NULL
*
* Cleans up the device after receiving an update.
*
* Since: 0.8.0
**/
gboolean fu_plugin_update_cleanup (FuPlugin *plugin,
FwupdInstallFlags flags,
FuDevice *dev,
GError **error);
/**
* fu_plugin_composite_prepare
* @plugin: A #FuPlugin
* @devices: A #GPtrArray of #FuDevice
* @error: A #GError or NULL
*
* Function run before updating group of composite devices.
*
* Since: 1.0.9
**/
gboolean fu_plugin_composite_prepare (FuPlugin *plugin,
GPtrArray *devices,
GError **error);
/**
* fu_plugin_composite_cleanup
* @plugin: A #FuPlugin
* @devices: A #GPtrArray of #FuDevice
* @error: A #GError or NULL
*
* Function run after updating group of composite devices.
*
* Since: 1.0.9
**/
gboolean fu_plugin_composite_cleanup (FuPlugin *plugin,
GPtrArray *devices,
GError **error);
/**
* fu_plugin_usb_device_added
* @plugin: A #FuPlugin
* @device: A #FuUsbDevice
* @error: A #GError or NULL
*
* Function run after USB device added to daemon.
*
* Since: 1.0.2
**/
gboolean fu_plugin_usb_device_added (FuPlugin *plugin,
FuUsbDevice *device,
GError **error);
/**
* fu_plugin_udev_device_added
* @plugin: A #FuPlugin
* @device: A #FuUdevDevice
* @error: A #GError or NULL
*
* Function run after Udev device added to daemon.
*
* Since: 1.1.2
**/
gboolean fu_plugin_udev_device_added (FuPlugin *plugin,
FuUdevDevice *device,
GError **error);
/**
* fu_plugin_udev_device_changed
* @plugin: A #FuPlugin
* @device: A #FuUdevDevice
* @error: A #GError or NULL
*
* Function run when Udev device changed.
*
* Since: 1.1.2
**/
gboolean fu_plugin_udev_device_changed (FuPlugin *plugin,
FuUdevDevice *device,
GError **error);
/**
* fu_plugin_device_removed
* @plugin: A #FuPlugin
* @device: A #FuDevice
* @error: A #GError or NULL
*
* Function run when device removed.
*
* Since: 1.1.2
**/
gboolean fu_plugin_device_removed (FuPlugin *plugin,
FuDevice *device,
GError **error);
/**
* fu_plugin_device_removed
* @plugin: A #FuPlugin
* @device: A #FuDevice
*
* Function run when device registered from another plugin.
*
* Since: 0.9.7
**/
void fu_plugin_device_registered (FuPlugin *plugin,
FuDevice *dev);

View File

@ -19,7 +19,6 @@
#include "fu-device-private.h" #include "fu-device-private.h"
#include "fu-plugin-private.h" #include "fu-plugin-private.h"
#include "fu-history.h"
#include "fu-mutex.h" #include "fu-mutex.h"
/** /**
@ -106,6 +105,23 @@ typedef gboolean (*FuPluginUdevDeviceAddedFunc) (FuPlugin *self,
FuUdevDevice *device, FuUdevDevice *device,
GError **error); GError **error);
/**
* fu_plugin_is_open:
* @self: A #FuPlugin
*
* Determines if the plugin is opened
*
* Returns: TRUE for opened, FALSE for not
*
* Since: 1.3.5
**/
gboolean
fu_plugin_is_open (FuPlugin *self)
{
FuPluginPrivate *priv = GET_PRIVATE (self);
return priv->module != NULL;
}
/** /**
* fu_plugin_get_name: * fu_plugin_get_name:
* @self: A #FuPlugin * @self: A #FuPlugin
@ -124,6 +140,15 @@ fu_plugin_get_name (FuPlugin *self)
return priv->name; return priv->name;
} }
/**
* fu_plugin_set_name:
* @self: A #FuPlugin
* @name: A string
*
* Sets the plugin name.
*
* Since: 0.8.0
**/
void void
fu_plugin_set_name (FuPlugin *self, const gchar *name) fu_plugin_set_name (FuPlugin *self, const gchar *name)
{ {
@ -154,6 +179,16 @@ fu_plugin_set_build_hash (FuPlugin *self, const gchar *build_hash)
priv->build_hash = g_strdup (build_hash); priv->build_hash = g_strdup (build_hash);
} }
/**
* fu_plugin_get_build_hash:
* @self: A #FuPlugin
*
* Gets the build hash a plugin was generated with.
*
* Returns: (transfer none): a #gchar, or %NULL for unset.
*
* Since: 1.2.4
**/
const gchar * const gchar *
fu_plugin_get_build_hash (FuPlugin *self) fu_plugin_get_build_hash (FuPlugin *self)
{ {
@ -198,7 +233,7 @@ void
fu_plugin_cache_add (FuPlugin *self, const gchar *id, gpointer dev) fu_plugin_cache_add (FuPlugin *self, const gchar *id, gpointer dev)
{ {
FuPluginPrivate *priv = GET_PRIVATE (self); FuPluginPrivate *priv = GET_PRIVATE (self);
g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&priv->devices_mutex); g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&priv->devices_mutex);
g_return_if_fail (FU_IS_PLUGIN (self)); g_return_if_fail (FU_IS_PLUGIN (self));
g_return_if_fail (id != NULL); g_return_if_fail (id != NULL);
g_return_if_fail (locker != NULL); g_return_if_fail (locker != NULL);
@ -218,7 +253,7 @@ void
fu_plugin_cache_remove (FuPlugin *self, const gchar *id) fu_plugin_cache_remove (FuPlugin *self, const gchar *id)
{ {
FuPluginPrivate *priv = GET_PRIVATE (self); FuPluginPrivate *priv = GET_PRIVATE (self);
g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_writer_locker_new (&priv->devices_mutex); g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&priv->devices_mutex);
g_return_if_fail (FU_IS_PLUGIN (self)); g_return_if_fail (FU_IS_PLUGIN (self));
g_return_if_fail (id != NULL); g_return_if_fail (id != NULL);
g_return_if_fail (locker != NULL); g_return_if_fail (locker != NULL);
@ -245,7 +280,7 @@ fu_plugin_get_data (FuPlugin *self)
} }
/** /**
* fu_plugin_alloc_data: * fu_plugin_alloc_data: (skip):
* @self: A #FuPlugin * @self: A #FuPlugin
* @data_sz: the size to allocate * @data_sz: the size to allocate
* *
@ -286,6 +321,15 @@ fu_plugin_get_usb_context (FuPlugin *self)
return priv->usb_ctx; return priv->usb_ctx;
} }
/**
* fu_plugin_set_usb_context:
* @self: A #FuPlugin
* @usb_ctx: A #FGUsbContext
*
* Sets the shared USB context for a plugin
*
* Since: 0.8.0
**/
void void
fu_plugin_set_usb_context (FuPlugin *self, GUsbContext *usb_ctx) fu_plugin_set_usb_context (FuPlugin *self, GUsbContext *usb_ctx)
{ {
@ -329,6 +373,16 @@ fu_plugin_set_enabled (FuPlugin *self, gboolean enabled)
priv->enabled = enabled; priv->enabled = enabled;
} }
/**
* fu_plugin_guess_name_from_fn:
* @filename: filename to guess
*
* Tries to guess the name of the plugin from a filename
*
* Returns: (transfer full): the guessed name of the plugin
*
* Since: 1.0.8
**/
gchar * gchar *
fu_plugin_guess_name_from_fn (const gchar *filename) fu_plugin_guess_name_from_fn (const gchar *filename)
{ {
@ -342,6 +396,18 @@ fu_plugin_guess_name_from_fn (const gchar *filename)
return name; return name;
} }
/**
* fu_plugin_open:
* @self: A #FuPlugin
* @filename: The shared object filename to open
* @error: A #GError or NULL
*
* Opens the plugin module
*
* Returns: TRUE for success, FALSE for fail
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_open (FuPlugin *self, const gchar *filename, GError **error) fu_plugin_open (FuPlugin *self, const gchar *filename, GError **error)
{ {
@ -540,7 +606,7 @@ fu_plugin_get_hwid_replace_value (FuPlugin *self, const gchar *keys, GError **er
* Returns all the HWIDs defined in the system. All hardware IDs on a * Returns all the HWIDs defined in the system. All hardware IDs on a
* specific system can be shown using the `fwupdmgr hwids` command. * specific system can be shown using the `fwupdmgr hwids` command.
* *
* Returns: (transfer none) (element-type utf-8): An array of GUIDs * Returns: (transfer none) (element-type utf8): An array of GUIDs
* *
* Since: 1.1.1 * Since: 1.1.1
**/ **/
@ -678,6 +744,15 @@ fu_plugin_get_smbios_data (FuPlugin *self, guint8 structure_type)
return fu_smbios_get_data (priv->smbios, structure_type, NULL); return fu_smbios_get_data (priv->smbios, structure_type, NULL);
} }
/**
* fu_plugin_set_hwids:
* @self: A #FuPlugin
* @hwids: A #FuHwids
*
* Sets the hwids for a plugin
*
* Since: 0.9.7
**/
void void
fu_plugin_set_hwids (FuPlugin *self, FuHwids *hwids) fu_plugin_set_hwids (FuPlugin *self, FuHwids *hwids)
{ {
@ -685,6 +760,15 @@ fu_plugin_set_hwids (FuPlugin *self, FuHwids *hwids)
g_set_object (&priv->hwids, hwids); g_set_object (&priv->hwids, hwids);
} }
/**
* fu_plugin_set_udev_subsystems:
* @self: A #FuPlugin
* @udev_subsystems: (element-type utf8): A #GPtrArray
*
* Sets the udev subsystems used by a plugin
*
* Since: 1.1.2
**/
void void
fu_plugin_set_udev_subsystems (FuPlugin *self, GPtrArray *udev_subsystems) fu_plugin_set_udev_subsystems (FuPlugin *self, GPtrArray *udev_subsystems)
{ {
@ -694,6 +778,15 @@ fu_plugin_set_udev_subsystems (FuPlugin *self, GPtrArray *udev_subsystems)
priv->udev_subsystems = g_ptr_array_ref (udev_subsystems); priv->udev_subsystems = g_ptr_array_ref (udev_subsystems);
} }
/**
* fu_plugin_set_quirks:
* @self: A #FuPlugin
* @quirks: A #FuQuirks
*
* Sets the quirks for a plugin
*
* Since: 1.0.1
**/
void void
fu_plugin_set_quirks (FuPlugin *self, FuQuirks *quirks) fu_plugin_set_quirks (FuPlugin *self, FuQuirks *quirks)
{ {
@ -719,6 +812,15 @@ fu_plugin_get_quirks (FuPlugin *self)
return priv->quirks; return priv->quirks;
} }
/**
* fu_plugin_set_runtime_versions:
* @self: A #FuPlugin
* @runtime_versions: A #GHashTables
*
* Sets the runtime versions for a plugin
*
* Since: 1.0.7
**/
void void
fu_plugin_set_runtime_versions (FuPlugin *self, GHashTable *runtime_versions) fu_plugin_set_runtime_versions (FuPlugin *self, GHashTable *runtime_versions)
{ {
@ -749,6 +851,15 @@ fu_plugin_add_runtime_version (FuPlugin *self,
g_strdup (version)); g_strdup (version));
} }
/**
* fu_plugin_set_compile_versions:
* @self: A #FuPlugin
* @compile_versions: A #GHashTables
*
* Sets the compile time versions for a plugin
*
* Since: 1.0.7
**/
void void
fu_plugin_set_compile_versions (FuPlugin *self, GHashTable *compile_versions) fu_plugin_set_compile_versions (FuPlugin *self, GHashTable *compile_versions)
{ {
@ -811,7 +922,7 @@ fu_plugin_lookup_quirk_by_id (FuPlugin *self, const gchar *group, const gchar *k
* an integer value. Values are assumed base 10, unless prefixed with "0x" * an integer value. Values are assumed base 10, unless prefixed with "0x"
* where they are parsed as base 16. * where they are parsed as base 16.
* *
* Returns: (transfer none): value from the database, or 0 if not found * Returns: guint64 id or 0 if not found
* *
* Since: 1.1.2 * Since: 1.1.2
**/ **/
@ -821,6 +932,15 @@ fu_plugin_lookup_quirk_by_id_as_uint64 (FuPlugin *self, const gchar *group, cons
return fu_common_strtoull (fu_plugin_lookup_quirk_by_id (self, group, key)); return fu_common_strtoull (fu_plugin_lookup_quirk_by_id (self, group, key));
} }
/**
* fu_plugin_set_smbios:
* @self: A #FuPlugin
* @smbios: A #FuSmbios
*
* Sets the smbios for a plugin
*
* Since: 1.0.0
**/
void void
fu_plugin_set_smbios (FuPlugin *self, FuSmbios *smbios) fu_plugin_set_smbios (FuPlugin *self, FuSmbios *smbios)
{ {
@ -954,6 +1074,17 @@ fu_plugin_device_read_firmware (FuPlugin *self, FuDevice *device, GError **error
return fu_device_attach (device, error); return fu_device_attach (device, error);
} }
/**
* fu_plugin_runner_startup:
* @self: a #FuPlugin
* @error: a #GError or NULL
*
* Runs the startup routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_runner_startup (FuPlugin *self, GError **error) fu_plugin_runner_startup (FuPlugin *self, GError **error)
{ {
@ -991,60 +1122,6 @@ fu_plugin_runner_startup (FuPlugin *self, GError **error)
return TRUE; return TRUE;
} }
static gboolean
fu_plugin_runner_offline_invalidate (GError **error)
{
g_autoptr(GError) error_local = NULL;
g_autoptr(GFile) file1 = NULL;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
file1 = g_file_new_for_path (FU_OFFLINE_TRIGGER_FILENAME);
if (!g_file_query_exists (file1, NULL))
return TRUE;
if (!g_file_delete (file1, NULL, &error_local)) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_INTERNAL,
"Cannot delete %s: %s",
FU_OFFLINE_TRIGGER_FILENAME,
error_local->message);
return FALSE;
}
return TRUE;
}
static gboolean
fu_plugin_runner_offline_setup (GError **error)
{
gint rc;
g_autofree gchar *filename = NULL;
g_autofree gchar *symlink_target = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
/* does already exist */
filename = fu_common_realpath (FU_OFFLINE_TRIGGER_FILENAME, NULL);
if (g_strcmp0 (filename, symlink_target) == 0) {
g_debug ("%s already points to %s, skipping creation",
FU_OFFLINE_TRIGGER_FILENAME, symlink_target);
return TRUE;
}
/* create symlink for the systemd-system-update-generator */
rc = symlink (symlink_target, FU_OFFLINE_TRIGGER_FILENAME);
if (rc < 0) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_INTERNAL,
"Failed to create symlink %s to %s: %s",
FU_OFFLINE_TRIGGER_FILENAME,
"/var/lib", strerror (errno));
return FALSE;
}
return TRUE;
}
static gboolean static gboolean
fu_plugin_runner_device_generic (FuPlugin *self, FuDevice *device, fu_plugin_runner_device_generic (FuPlugin *self, FuDevice *device,
const gchar *symbol_name, const gchar *symbol_name,
@ -1169,6 +1246,17 @@ fu_plugin_runner_device_array_generic (FuPlugin *self, GPtrArray *devices,
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_coldplug:
* @self: a #FuPlugin
* @error: a #GError or NULL
*
* Runs the coldplug routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_runner_coldplug (FuPlugin *self, GError **error) fu_plugin_runner_coldplug (FuPlugin *self, GError **error)
{ {
@ -1205,6 +1293,17 @@ fu_plugin_runner_coldplug (FuPlugin *self, GError **error)
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_recoldplug:
* @self: a #FuPlugin
* @error: a #GError or NULL
*
* Runs the recoldplug routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.0.4
**/
gboolean gboolean
fu_plugin_runner_recoldplug (FuPlugin *self, GError **error) fu_plugin_runner_recoldplug (FuPlugin *self, GError **error)
{ {
@ -1242,6 +1341,17 @@ fu_plugin_runner_recoldplug (FuPlugin *self, GError **error)
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_coldplug_prepare:
* @self: a #FuPlugin
* @error: a #GError or NULL
*
* Runs the coldplug_prepare routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_runner_coldplug_prepare (FuPlugin *self, GError **error) fu_plugin_runner_coldplug_prepare (FuPlugin *self, GError **error)
{ {
@ -1279,6 +1389,17 @@ fu_plugin_runner_coldplug_prepare (FuPlugin *self, GError **error)
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_coldplug_cleanup:
* @self: a #FuPlugin
* @error: a #GError or NULL
*
* Runs the coldplug_cleanup routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_runner_coldplug_cleanup (FuPlugin *self, GError **error) fu_plugin_runner_coldplug_cleanup (FuPlugin *self, GError **error)
{ {
@ -1316,6 +1437,18 @@ fu_plugin_runner_coldplug_cleanup (FuPlugin *self, GError **error)
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_composite_prepare:
* @self: a #FuPlugin
* @devices: (element-type FuDevice): a #GPtrArray of devices
* @error: a #GError or NULL
*
* Runs the composite_prepare routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.0.9
**/
gboolean gboolean
fu_plugin_runner_composite_prepare (FuPlugin *self, GPtrArray *devices, GError **error) fu_plugin_runner_composite_prepare (FuPlugin *self, GPtrArray *devices, GError **error)
{ {
@ -1324,6 +1457,18 @@ fu_plugin_runner_composite_prepare (FuPlugin *self, GPtrArray *devices, GError *
error); error);
} }
/**
* fu_plugin_runner_composite_cleanup:
* @self: a #FuPlugin
* @devices: (element-type FuDevice): a #GPtrArray of devices
* @error: a #GError or NULL
*
* Runs the composite_cleanup routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.0.9
**/
gboolean gboolean
fu_plugin_runner_composite_cleanup (FuPlugin *self, GPtrArray *devices, GError **error) fu_plugin_runner_composite_cleanup (FuPlugin *self, GPtrArray *devices, GError **error)
{ {
@ -1332,6 +1477,17 @@ fu_plugin_runner_composite_cleanup (FuPlugin *self, GPtrArray *devices, GError *
error); error);
} }
/**
* fu_plugin_runner_update_prepare:
* @self: a #FuPlugin
* @error: a #GError or NULL
*
* Runs the update_prepare routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.1.2
**/
gboolean gboolean
fu_plugin_runner_update_prepare (FuPlugin *self, FwupdInstallFlags flags, FuDevice *device, fu_plugin_runner_update_prepare (FuPlugin *self, FwupdInstallFlags flags, FuDevice *device,
GError **error) GError **error)
@ -1341,6 +1497,17 @@ fu_plugin_runner_update_prepare (FuPlugin *self, FwupdInstallFlags flags, FuDevi
error); error);
} }
/**
* fu_plugin_runner_update_cleanup:
* @self: a #FuPlugin
* @error: a #GError or NULL
*
* Runs the update_cleanup routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.1.2
**/
gboolean gboolean
fu_plugin_runner_update_cleanup (FuPlugin *self, FwupdInstallFlags flags, FuDevice *device, fu_plugin_runner_update_cleanup (FuPlugin *self, FwupdInstallFlags flags, FuDevice *device,
GError **error) GError **error)
@ -1350,6 +1517,18 @@ fu_plugin_runner_update_cleanup (FuPlugin *self, FwupdInstallFlags flags, FuDevi
error); error);
} }
/**
* fu_plugin_runner_update_attach:
* @self: a #FuPlugin
* @device: a #FuDevice
* @error: a #GError or NULL
*
* Runs the update_attach routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.1.2
**/
gboolean gboolean
fu_plugin_runner_update_attach (FuPlugin *self, FuDevice *device, GError **error) fu_plugin_runner_update_attach (FuPlugin *self, FuDevice *device, GError **error)
{ {
@ -1359,6 +1538,18 @@ fu_plugin_runner_update_attach (FuPlugin *self, FuDevice *device, GError **error
error); error);
} }
/**
* fu_plugin_runner_update_detach:
* @self: a #FuPlugin
* @device: A #FuDevice
* @error: a #GError or NULL
*
* Runs the update_detach routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.1.2
**/
gboolean gboolean
fu_plugin_runner_update_detach (FuPlugin *self, FuDevice *device, GError **error) fu_plugin_runner_update_detach (FuPlugin *self, FuDevice *device, GError **error)
{ {
@ -1368,6 +1559,17 @@ fu_plugin_runner_update_detach (FuPlugin *self, FuDevice *device, GError **error
error); error);
} }
/**
* fu_plugin_runner_update_reload:
* @self: a #FuPlugin
* @error: a #GError or NULL
*
* Runs reload routine for a device
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.1.2
**/
gboolean gboolean
fu_plugin_runner_update_reload (FuPlugin *self, FuDevice *device, GError **error) fu_plugin_runner_update_reload (FuPlugin *self, FuDevice *device, GError **error)
{ {
@ -1393,6 +1595,8 @@ fu_plugin_runner_update_reload (FuPlugin *self, FuDevice *device, GError **error
* Registers the udev subsystem to be watched by the daemon. * Registers the udev subsystem to be watched by the daemon.
* *
* Plugins can use this method only in fu_plugin_init() * Plugins can use this method only in fu_plugin_init()
*
* Since: 1.1.2
**/ **/
void void
fu_plugin_add_udev_subsystem (FuPlugin *self, const gchar *subsystem) fu_plugin_add_udev_subsystem (FuPlugin *self, const gchar *subsystem)
@ -1428,6 +1632,18 @@ fu_plugin_set_device_gtype (FuPlugin *self, GType device_gtype)
priv->device_gtype = device_gtype; priv->device_gtype = device_gtype;
} }
/**
* fu_plugin_add_firmware_gtype:
* @self: a #FuPlugin
* @id: A string describing the type
* @gtype: a #GType `FU_TYPE_DEVICE`
*
* Adds a firmware #GType which is used when creating devices.
* *
* Plugins can use this method only in fu_plugin_init()
*
* Since: 1.3.3
**/
void void
fu_plugin_add_firmware_gtype (FuPlugin *self, const gchar *id, GType gtype) fu_plugin_add_firmware_gtype (FuPlugin *self, const gchar *id, GType gtype)
{ {
@ -1521,6 +1737,18 @@ fu_plugin_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError **erro
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_usb_device_added:
* @self: a #FuPlugin
* @device: a #FuUsbDevice
* @error: a #GError or NULL
*
* Call the usb_device_added routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.0.2
**/
gboolean gboolean
fu_plugin_runner_usb_device_added (FuPlugin *self, FuUsbDevice *device, GError **error) fu_plugin_runner_usb_device_added (FuPlugin *self, FuUsbDevice *device, GError **error)
{ {
@ -1564,6 +1792,18 @@ fu_plugin_runner_usb_device_added (FuPlugin *self, FuUsbDevice *device, GError *
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_udev_device_added:
* @self: a #FuPlugin
* @device: a #FuUdevDevice
* @error: a #GError or NULL
*
* Call the udev_device_added routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.0.2
**/
gboolean gboolean
fu_plugin_runner_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError **error) fu_plugin_runner_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError **error)
{ {
@ -1607,6 +1847,18 @@ fu_plugin_runner_udev_device_added (FuPlugin *self, FuUdevDevice *device, GError
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_udev_device_changed:
* @self: a #FuPlugin
* @device: a #FuUdevDevice
* @error: a #GError or NULL
*
* Call the udev_device_changed routine for the plugin
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.0.2
**/
gboolean gboolean
fu_plugin_runner_udev_device_changed (FuPlugin *self, FuUdevDevice *device, GError **error) fu_plugin_runner_udev_device_changed (FuPlugin *self, FuUdevDevice *device, GError **error)
{ {
@ -1644,6 +1896,15 @@ fu_plugin_runner_udev_device_changed (FuPlugin *self, FuUdevDevice *device, GErr
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_device_removed:
* @self: a #FuPlugin
* @device: a #FuDevice
*
* Call the device_removed routine for the plugin
*
* Since: 1.1.2
**/
void void
fu_plugin_runner_device_removed (FuPlugin *self, FuDevice *device) fu_plugin_runner_device_removed (FuPlugin *self, FuDevice *device)
{ {
@ -1656,6 +1917,15 @@ fu_plugin_runner_device_removed (FuPlugin *self, FuDevice *device)
g_warning ("%s", error_local->message); g_warning ("%s", error_local->message);
} }
/**
* fu_plugin_runner_device_register:
* @self: a #FuPlugin
* @device: a #FuDevice
*
* Call the device_registered routine for the plugin
*
* Since: 0.9.7
**/
void void
fu_plugin_runner_device_register (FuPlugin *self, FuDevice *device) fu_plugin_runner_device_register (FuPlugin *self, FuDevice *device)
{ {
@ -1680,73 +1950,19 @@ fu_plugin_runner_device_register (FuPlugin *self, FuDevice *device)
} }
} }
gboolean /**
fu_plugin_runner_schedule_update (FuPlugin *self, * fu_plugin_runner_verify:
FuDevice *device, * @self: a #FuPlugin
FwupdRelease *release, * @device: a #FuDevice
GBytes *blob_cab, * @flags: #FuPluginVerifyFlags
FwupdInstallFlags flags, * @error: A #GError or NULL
GError **error) *
{ * Call into the plugin's verify routine
gchar tmpname[] = {"XXXXXX.cab"}; *
g_autofree gchar *dirname = NULL; * Returns: #TRUE for success, #FALSE for failure
g_autofree gchar *filename = NULL; *
g_autoptr(FuHistory) history = NULL; * Since: 0.8.0
g_autoptr(GFile) file = NULL; **/
/* id already exists */
history = fu_history_new ();
if ((flags & FWUPD_INSTALL_FLAG_FORCE) == 0) {
g_autoptr(FuDevice) res_tmp = NULL;
res_tmp = fu_history_get_device_by_id (history, fu_device_get_id (device), NULL);
if (res_tmp != NULL &&
fu_device_get_update_state (res_tmp) == FWUPD_UPDATE_STATE_PENDING) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_ALREADY_PENDING,
"%s is already scheduled to be updated",
fu_device_get_id (device));
return FALSE;
}
}
/* create directory */
dirname = fu_common_get_path (FU_PATH_KIND_LOCALSTATEDIR_PKG);
file = g_file_new_for_path (dirname);
if (!g_file_query_exists (file, NULL)) {
if (!g_file_make_directory_with_parents (file, NULL, error))
return FALSE;
}
/* get a random filename */
for (guint i = 0; i < 6; i++)
tmpname[i] = (gchar) g_random_int_range ('A', 'Z');
filename = g_build_filename (dirname, tmpname, NULL);
/* just copy to the temp file */
fu_device_set_status (device, FWUPD_STATUS_SCHEDULING);
if (!g_file_set_contents (filename,
g_bytes_get_data (blob_cab, NULL),
(gssize) g_bytes_get_size (blob_cab),
error))
return FALSE;
/* schedule for next boot */
g_debug ("schedule %s to be installed to %s on next boot",
filename, fu_device_get_id (device));
fwupd_release_set_filename (release, filename);
/* add to database */
fu_device_add_flag (device, FWUPD_DEVICE_FLAG_NEEDS_REBOOT);
fu_device_set_update_state (device, FWUPD_UPDATE_STATE_PENDING);
if (!fu_history_add_device (history, device, release, error))
return FALSE;
/* next boot we run offline */
fu_device_set_progress (device, 100);
return fu_plugin_runner_offline_setup (error);
}
gboolean gboolean
fu_plugin_runner_verify (FuPlugin *self, fu_plugin_runner_verify (FuPlugin *self,
FuDevice *device, FuDevice *device,
@ -1820,6 +2036,18 @@ fu_plugin_runner_verify (FuPlugin *self,
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_activate:
* @self: a #FuPlugin
* @device: a #FuDevice
* @error: A #GError or NULL
*
* Call into the plugin's activate routine
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 1.2.6
**/
gboolean gboolean
fu_plugin_runner_activate (FuPlugin *self, FuDevice *device, GError **error) fu_plugin_runner_activate (FuPlugin *self, FuDevice *device, GError **error)
{ {
@ -1849,6 +2077,18 @@ fu_plugin_runner_activate (FuPlugin *self, FuDevice *device, GError **error)
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_unlock:
* @self: a #FuPlugin
* @device: a #FuDevice
* @error: A #GError or NULL
*
* Call into the plugin's unlock routine
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_runner_unlock (FuPlugin *self, FuDevice *device, GError **error) fu_plugin_runner_unlock (FuPlugin *self, FuDevice *device, GError **error)
{ {
@ -1879,6 +2119,20 @@ fu_plugin_runner_unlock (FuPlugin *self, FuDevice *device, GError **error)
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_update:
* @self: a #FuPlugin
* @device: a #FuDevice
* @blob_fw: A #GBytes
* @flags: A #FwupdInstallFlags
* @error: A #GError or NULL
*
* Call into the plugin's update routine
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_runner_update (FuPlugin *self, fu_plugin_runner_update (FuPlugin *self,
FuDevice *device, FuDevice *device,
@ -1888,8 +2142,6 @@ fu_plugin_runner_update (FuPlugin *self,
{ {
FuPluginPrivate *priv = GET_PRIVATE (self); FuPluginPrivate *priv = GET_PRIVATE (self);
FuPluginUpdateFunc update_func; FuPluginUpdateFunc update_func;
g_autoptr(FuHistory) history = NULL;
g_autoptr(FuDevice) device_pending = NULL;
g_autoptr(GError) error_local = NULL; g_autoptr(GError) error_local = NULL;
/* not enabled */ /* not enabled */
@ -1911,13 +2163,7 @@ fu_plugin_runner_update (FuPlugin *self,
return fu_plugin_device_write_firmware (self, device, blob_fw, flags, error); return fu_plugin_device_write_firmware (self, device, blob_fw, flags, error);
} }
/* cancel the pending action */
if (!fu_plugin_runner_offline_invalidate (error))
return FALSE;
/* online */ /* online */
history = fu_history_new ();
device_pending = fu_history_get_device_by_id (history, fu_device_get_id (device), NULL);
if (!update_func (self, device, blob_fw, flags, &error_local)) { if (!update_func (self, device, blob_fw, flags, &error_local)) {
if (error_local == NULL) { if (error_local == NULL) {
g_critical ("unset error in plugin %s for update()", g_critical ("unset error in plugin %s for update()",
@ -1940,36 +2186,22 @@ fu_plugin_runner_update (FuPlugin *self,
g_ptr_array_set_size (checksums, 0); g_ptr_array_set_size (checksums, 0);
} }
/* cleanup */ /* success */
if (device_pending != NULL) {
const gchar *tmp;
FwupdRelease *release;
/* update history database */
fu_device_set_update_state (device, FWUPD_UPDATE_STATE_SUCCESS);
if (!fu_history_modify_device (history, device, error))
return FALSE;
/* delete cab file */
release = fu_device_get_release_default (device_pending);
tmp = fwupd_release_get_filename (release);
if (tmp != NULL && g_str_has_prefix (tmp, LIBEXECDIR)) {
g_autoptr(GError) error_delete = NULL;
g_autoptr(GFile) file = NULL;
file = g_file_new_for_path (tmp);
if (!g_file_delete (file, NULL, &error_delete)) {
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_INVALID_FILE,
"Failed to delete %s: %s",
tmp, error_delete->message);
return FALSE;
}
}
}
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_clear_results:
* @self: a #FuPlugin
* @device: a #FuDevice
* @error: A #GError or NULL
*
* Call into the plugin's clear results routine
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_runner_clear_results (FuPlugin *self, FuDevice *device, GError **error) fu_plugin_runner_clear_results (FuPlugin *self, FuDevice *device, GError **error)
{ {
@ -2007,6 +2239,18 @@ fu_plugin_runner_clear_results (FuPlugin *self, FuDevice *device, GError **error
return TRUE; return TRUE;
} }
/**
* fu_plugin_runner_get_results:
* @self: a #FuPlugin
* @device: a #FuDevice
* @error: A #GError or NULL
*
* Call into the plugin's get results routine
*
* Returns: #TRUE for success, #FALSE for failure
*
* Since: 0.8.0
**/
gboolean gboolean
fu_plugin_runner_get_results (FuPlugin *self, FuDevice *device, GError **error) fu_plugin_runner_get_results (FuPlugin *self, FuDevice *device, GError **error)
{ {
@ -2052,6 +2296,8 @@ fu_plugin_runner_get_results (FuPlugin *self, FuDevice *device, GError **error)
* numbers. * numbers.
* *
* Returns: the integer value * Returns: the integer value
*
* Since: 1.0.0
**/ **/
guint guint
fu_plugin_get_order (FuPlugin *self) fu_plugin_get_order (FuPlugin *self)
@ -2067,6 +2313,8 @@ fu_plugin_get_order (FuPlugin *self)
* *
* Sets the plugin order, where higher numbers are run after lower * Sets the plugin order, where higher numbers are run after lower
* numbers. * numbers.
*
* Since: 1.0.0
**/ **/
void void
fu_plugin_set_order (FuPlugin *self, guint order) fu_plugin_set_order (FuPlugin *self, guint order)
@ -2082,6 +2330,8 @@ fu_plugin_set_order (FuPlugin *self, guint order)
* Gets the plugin priority, where higher numbers are better. * Gets the plugin priority, where higher numbers are better.
* *
* Returns: the integer value * Returns: the integer value
*
* Since: 1.1.1
**/ **/
guint guint
fu_plugin_get_priority (FuPlugin *self) fu_plugin_get_priority (FuPlugin *self)
@ -2096,6 +2346,8 @@ fu_plugin_get_priority (FuPlugin *self)
* @priority: a integer value * @priority: a integer value
* *
* Sets the plugin priority, where higher numbers are better. * Sets the plugin priority, where higher numbers are better.
*
* Since: 1.0.0
**/ **/
void void
fu_plugin_set_priority (FuPlugin *self, guint priority) fu_plugin_set_priority (FuPlugin *self, guint priority)
@ -2116,6 +2368,8 @@ fu_plugin_set_priority (FuPlugin *self, guint priority)
* *
* NOTE: The depsolver is iterative and may not solve overly-complicated rules; * NOTE: The depsolver is iterative and may not solve overly-complicated rules;
* If depsolving fails then fwupd will not start. * If depsolving fails then fwupd will not start.
*
* Since: 1.0.0
**/ **/
void void
fu_plugin_add_rule (FuPlugin *self, FuPluginRule rule, const gchar *name) fu_plugin_add_rule (FuPlugin *self, FuPluginRule rule, const gchar *name)
@ -2133,6 +2387,8 @@ fu_plugin_add_rule (FuPlugin *self, FuPluginRule rule, const gchar *name)
* Gets the plugin IDs that should be run after this plugin. * Gets the plugin IDs that should be run after this plugin.
* *
* Returns: (element-type utf8) (transfer none): the list of plugin names, e.g. ['appstream'] * Returns: (element-type utf8) (transfer none): the list of plugin names, e.g. ['appstream']
*
* Since: 1.0.0
**/ **/
GPtrArray * GPtrArray *
fu_plugin_get_rules (FuPlugin *self, FuPluginRule rule) fu_plugin_get_rules (FuPlugin *self, FuPluginRule rule)
@ -2150,6 +2406,8 @@ fu_plugin_get_rules (FuPlugin *self, FuPluginRule rule)
* Gets the plugin IDs that should be run after this plugin. * Gets the plugin IDs that should be run after this plugin.
* *
* Returns: %TRUE if the name exists for the specific rule * Returns: %TRUE if the name exists for the specific rule
*
* Since: 1.0.0
**/ **/
gboolean gboolean
fu_plugin_has_rule (FuPlugin *self, FuPluginRule rule, const gchar *name) fu_plugin_has_rule (FuPlugin *self, FuPluginRule rule, const gchar *name)
@ -2174,6 +2432,8 @@ fu_plugin_has_rule (FuPlugin *self, FuPluginRule rule, const gchar *name)
* *
* Any data included here will be sent to the metadata server after user * Any data included here will be sent to the metadata server after user
* confirmation. * confirmation.
*
* Since: 1.0.4
**/ **/
void void
fu_plugin_add_report_metadata (FuPlugin *self, const gchar *key, const gchar *value) fu_plugin_add_report_metadata (FuPlugin *self, const gchar *key, const gchar *value)
@ -2189,6 +2449,8 @@ fu_plugin_add_report_metadata (FuPlugin *self, const gchar *key, const gchar *va
* Returns the list of additional metadata to be added when filing a report. * Returns the list of additional metadata to be added when filing a report.
* *
* Returns: (transfer none): the map of report metadata * Returns: (transfer none): the map of report metadata
*
* Since: 1.0.4
**/ **/
GHashTable * GHashTable *
fu_plugin_get_report_metadata (FuPlugin *self) fu_plugin_get_report_metadata (FuPlugin *self)
@ -2236,6 +2498,8 @@ fu_plugin_get_config_value (FuPlugin *self, const gchar *key)
* Compares two plugins by their names. * Compares two plugins by their names.
* *
* Returns: 1, 0 or -1 if @plugin1 is greater, equal, or less than @plugin2. * Returns: 1, 0 or -1 if @plugin1 is greater, equal, or less than @plugin2.
*
* Since: 1.0.8
**/ **/
gint gint
fu_plugin_name_compare (FuPlugin *plugin1, FuPlugin *plugin2) fu_plugin_name_compare (FuPlugin *plugin1, FuPlugin *plugin2)
@ -2253,6 +2517,8 @@ fu_plugin_name_compare (FuPlugin *plugin1, FuPlugin *plugin2)
* Compares two plugins by their depsolved order. * Compares two plugins by their depsolved order.
* *
* Returns: 1, 0 or -1 if @plugin1 is greater, equal, or less than @plugin2. * Returns: 1, 0 or -1 if @plugin1 is greater, equal, or less than @plugin2.
*
* Since: 1.0.8
**/ **/
gint gint
fu_plugin_order_compare (FuPlugin *plugin1, FuPlugin *plugin2) fu_plugin_order_compare (FuPlugin *plugin1, FuPlugin *plugin2)
@ -2384,6 +2650,13 @@ fu_plugin_finalize (GObject *object)
G_OBJECT_CLASS (fu_plugin_parent_class)->finalize (object); G_OBJECT_CLASS (fu_plugin_parent_class)->finalize (object);
} }
/**
* fu_plugin_new:
*
* Creates a new #FuPlugin
*
* Since: 0.8.0
**/
FuPlugin * FuPlugin *
fu_plugin_new (void) fu_plugin_new (void)
{ {

View File

@ -8,7 +8,6 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <gusb.h> #include <gusb.h>
#include <gudev/gudev.h>
#include "fu-common.h" #include "fu-common.h"
#include "fu-common-guid.h" #include "fu-common-guid.h"
@ -18,7 +17,9 @@
#include "fu-quirks.h" #include "fu-quirks.h"
#include "fu-hwids.h" #include "fu-hwids.h"
#include "fu-usb-device.h" #include "fu-usb-device.h"
#ifdef HAVE_GUDEV
#include "fu-udev-device.h" #include "fu-udev-device.h"
#endif
#include "fwupd-common.h" #include "fwupd-common.h"
#define FU_TYPE_PLUGIN (fu_plugin_get_type ()) #define FU_TYPE_PLUGIN (fu_plugin_get_type ())
@ -70,7 +71,6 @@ typedef enum {
* @FU_PLUGIN_RULE_RUN_BEFORE: Order the plugin before another * @FU_PLUGIN_RULE_RUN_BEFORE: Order the plugin before another
* @FU_PLUGIN_RULE_BETTER_THAN: Is better than another plugin * @FU_PLUGIN_RULE_BETTER_THAN: Is better than another plugin
* @FU_PLUGIN_RULE_INHIBITS_IDLE: The plugin inhibits the idle shutdown * @FU_PLUGIN_RULE_INHIBITS_IDLE: The plugin inhibits the idle shutdown
* @FU_PLUGIN_RULE_SUPPORTS_PROTOCOL: The plugin supports a well known protocol
* *
* The rules used for ordering plugins. * The rules used for ordering plugins.
* Plugins are expected to add rules in fu_plugin_initialize(). * Plugins are expected to add rules in fu_plugin_initialize().
@ -81,7 +81,6 @@ typedef enum {
FU_PLUGIN_RULE_RUN_BEFORE, FU_PLUGIN_RULE_RUN_BEFORE,
FU_PLUGIN_RULE_BETTER_THAN, FU_PLUGIN_RULE_BETTER_THAN,
FU_PLUGIN_RULE_INHIBITS_IDLE, FU_PLUGIN_RULE_INHIBITS_IDLE,
FU_PLUGIN_RULE_SUPPORTS_PROTOCOL,
/*< private >*/ /*< private >*/
FU_PLUGIN_RULE_LAST FU_PLUGIN_RULE_LAST
} FuPluginRule; } FuPluginRule;
@ -110,7 +109,7 @@ void fu_plugin_set_coldplug_delay (FuPlugin *self,
guint duration); guint duration);
void fu_plugin_set_device_gtype (FuPlugin *self, void fu_plugin_set_device_gtype (FuPlugin *self,
GType device_gtype); GType device_gtype);
void fu_plugin_add_firmware_gtype (FuPlugin *plugin, void fu_plugin_add_firmware_gtype (FuPlugin *self,
const gchar *id, const gchar *id,
GType gtype); GType gtype);
gpointer fu_plugin_cache_lookup (FuPlugin *self, gpointer fu_plugin_cache_lookup (FuPlugin *self,

View File

@ -300,9 +300,9 @@ fu_quirks_lookup_by_id (FuQuirks *self, const gchar *group, const gchar *key)
/** /**
* fu_quirks_lookup_by_id_iter: * fu_quirks_lookup_by_id_iter:
* @self: A #FuPlugin * @self: A #FuQuirks
* @guid: a GUID * @group: string of group to lookup
* @iter_cb: A #FuQuirksIter * @iter_cb: (scope async): A #FuQuirksIter
* @user_data: user data passed to @iter_cb * @user_data: user data passed to @iter_cb
* *
* Looks up all entries in the hardware database using a GUID value. * Looks up all entries in the hardware database using a GUID value.
@ -370,6 +370,7 @@ fu_quirks_lookup_by_id_iter (FuQuirks *self, const gchar *group,
/** /**
* fu_quirks_load: (skip) * fu_quirks_load: (skip)
* @self: A #FuQuirks * @self: A #FuQuirks
* @load_flags: A #FuQuirksLoadFlags
* @error: A #GError, or %NULL * @error: A #GError, or %NULL
* *
* Loads the various files that define the hardware quirks used in plugins. * Loads the various files that define the hardware quirks used in plugins.
@ -413,6 +414,8 @@ fu_quirks_finalize (GObject *obj)
* Creates a new quirks object. * Creates a new quirks object.
* *
* Return value: a new #FuQuirks * Return value: a new #FuQuirks
*
* Since: 1.0.1
**/ **/
FuQuirks * FuQuirks *
fu_quirks_new (void) fu_quirks_new (void)

View File

@ -40,7 +40,7 @@ const gchar *fu_quirks_lookup_by_id (FuQuirks *self,
const gchar *key); const gchar *key);
gboolean fu_quirks_lookup_by_id_iter (FuQuirks *self, gboolean fu_quirks_lookup_by_id_iter (FuQuirks *self,
const gchar *group, const gchar *group,
FuQuirksIter iter, FuQuirksIter iter_cb,
gpointer user_data); gpointer user_data);
#define FU_QUIRKS_PLUGIN "Plugin" #define FU_QUIRKS_PLUGIN "Plugin"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2017 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
#include <glib-object.h>
#include "fu-smbios.h"
gboolean fu_smbios_setup (FuSmbios *self,
GError **error);
gboolean fu_smbios_setup_from_path (FuSmbios *self,
const gchar *path,
GError **error);
gboolean fu_smbios_setup_from_file (FuSmbios *self,
const gchar *filename,
GError **error);

View File

@ -12,7 +12,7 @@
#include <string.h> #include <string.h>
#include "fu-common.h" #include "fu-common.h"
#include "fu-smbios.h" #include "fu-smbios-private.h"
#include "fwupd-error.h" #include "fwupd-error.h"
struct _FuSmbios { struct _FuSmbios {
@ -127,6 +127,8 @@ fu_smbios_setup_from_data (FuSmbios *self, const guint8 *buf, gsize sz, GError *
* Reads all the SMBIOS values from a DMI blob. * Reads all the SMBIOS values from a DMI blob.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
*
* Since: 1.0.0
**/ **/
gboolean gboolean
fu_smbios_setup_from_file (FuSmbios *self, const gchar *filename, GError **error) fu_smbios_setup_from_file (FuSmbios *self, const gchar *filename, GError **error)
@ -228,7 +230,7 @@ fu_smbios_parse_ep64 (FuSmbios *self, const gchar *buf, gsize sz, GError **error
} }
/** /**
* fu_smbios_setup: * fu_smbios_setup_from_path:
* @self: A #FuSmbios * @self: A #FuSmbios
* @path: A path, e.g. `/sys/firmware/dmi/tables` * @path: A path, e.g. `/sys/firmware/dmi/tables`
* @error: A #GError or %NULL * @error: A #GError or %NULL
@ -236,6 +238,8 @@ fu_smbios_parse_ep64 (FuSmbios *self, const gchar *buf, gsize sz, GError **error
* Reads all the SMBIOS values from a specific path. * Reads all the SMBIOS values from a specific path.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
*
* Since: 1.0.0
**/ **/
gboolean gboolean
fu_smbios_setup_from_path (FuSmbios *self, const gchar *path, GError **error) fu_smbios_setup_from_path (FuSmbios *self, const gchar *path, GError **error)
@ -308,6 +312,8 @@ fu_smbios_setup_from_path (FuSmbios *self, const gchar *path, GError **error)
* Reads all the SMBIOS values from the hardware. * Reads all the SMBIOS values from the hardware.
* *
* Returns: %TRUE for success * Returns: %TRUE for success
*
* Since: 1.0.0
**/ **/
gboolean gboolean
fu_smbios_setup (FuSmbios *self, GError **error) fu_smbios_setup (FuSmbios *self, GError **error)
@ -327,6 +333,8 @@ fu_smbios_setup (FuSmbios *self, GError **error)
* Dumps the parsed SMBIOS data to a string. * Dumps the parsed SMBIOS data to a string.
* *
* Returns: a UTF-8 string * Returns: a UTF-8 string
*
* Since: 1.0.0
**/ **/
gchar * gchar *
fu_smbios_to_string (FuSmbios *self) fu_smbios_to_string (FuSmbios *self)
@ -371,6 +379,8 @@ fu_smbios_get_item_for_type (FuSmbios *self, guint8 type)
* Reads a SMBIOS data blob, which includes the SMBIOS section header. * Reads a SMBIOS data blob, which includes the SMBIOS section header.
* *
* Returns: (transfer full): a #GBytes, or %NULL if invalid or not found * Returns: (transfer full): a #GBytes, or %NULL if invalid or not found
*
* Since: 1.0.0
**/ **/
GBytes * GBytes *
fu_smbios_get_data (FuSmbios *self, guint8 type, GError **error) fu_smbios_get_data (FuSmbios *self, guint8 type, GError **error)
@ -401,6 +411,8 @@ fu_smbios_get_data (FuSmbios *self, guint8 type, GError **error)
* https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf * https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.1.1.pdf
* *
* Returns: a string, or %NULL if invalid or not found * Returns: a string, or %NULL if invalid or not found
*
* Since: 1.0.0
**/ **/
const gchar * const gchar *
fu_smbios_get_string (FuSmbios *self, guint8 type, guint8 offset, GError **error) fu_smbios_get_string (FuSmbios *self, guint8 type, guint8 offset, GError **error)
@ -486,6 +498,8 @@ fu_smbios_init (FuSmbios *self)
* Creates a new object to parse SMBIOS data. * Creates a new object to parse SMBIOS data.
* *
* Returns: a #FuSmbios * Returns: a #FuSmbios
*
* Since: 1.0.0
**/ **/
FuSmbios * FuSmbios *
fu_smbios_new (void) fu_smbios_new (void)

View File

@ -19,14 +19,6 @@ FuSmbios *fu_smbios_new (void);
#define FU_SMBIOS_STRUCTURE_TYPE_BASEBOARD 0x02 #define FU_SMBIOS_STRUCTURE_TYPE_BASEBOARD 0x02
#define FU_SMBIOS_STRUCTURE_TYPE_CHASSIS 0x03 #define FU_SMBIOS_STRUCTURE_TYPE_CHASSIS 0x03
gboolean fu_smbios_setup (FuSmbios *self,
GError **error);
gboolean fu_smbios_setup_from_path (FuSmbios *self,
const gchar *path,
GError **error);
gboolean fu_smbios_setup_from_file (FuSmbios *self,
const gchar *filename,
GError **error);
gchar *fu_smbios_to_string (FuSmbios *self); gchar *fu_smbios_to_string (FuSmbios *self);
const gchar *fu_smbios_get_string (FuSmbios *self, const gchar *fu_smbios_get_string (FuSmbios *self,

View File

@ -14,6 +14,15 @@
#include "fu-firmware-common.h" #include "fu-firmware-common.h"
#include "fu-srec-firmware.h" #include "fu-srec-firmware.h"
/**
* SECTION:fu-srec-firmware
* @short_description: SREC firmware image
*
* An object that represents a SREC firmware image.
*
* See also: #FuFirmware
*/
struct _FuSrecFirmware { struct _FuSrecFirmware {
FuFirmware parent_instance; FuFirmware parent_instance;
GPtrArray *records; GPtrArray *records;
@ -48,6 +57,18 @@ fu_srec_firmware_record_free (FuSrecFirmwareRecord *rcd)
g_free (rcd); g_free (rcd);
} }
/**
* fu_srec_firmware_record_new: (skip):
* @ln: unsigned integer
* @kind: #FuFirmwareSrecRecordKind
* @addr: unsigned integer
*
* Returns a single firmware record
*
* Returns: (transfer full) (element-type FuSrecFirmwareRecord): records
*
* Since: 1.3.2
**/
FuSrecFirmwareRecord * FuSrecFirmwareRecord *
fu_srec_firmware_record_new (guint ln, FuFirmareSrecRecordKind kind, guint32 addr) fu_srec_firmware_record_new (guint ln, FuFirmareSrecRecordKind kind, guint32 addr)
{ {
@ -372,6 +393,13 @@ fu_srec_firmware_class_init (FuSrecFirmwareClass *klass)
klass_firmware->tokenize = fu_srec_firmware_tokenize; klass_firmware->tokenize = fu_srec_firmware_tokenize;
} }
/**
* fu_srec_firmware_new:
*
* Creates a new #FuFirmware of sub type Srec
*
* Since: 1.3.2
**/
FuFirmware * FuFirmware *
fu_srec_firmware_new (void) fu_srec_firmware_new (void)
{ {

View File

@ -10,8 +10,12 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#ifdef HAVE_ERRNO_H
#include <sys/errno.h> #include <sys/errno.h>
#endif
#ifdef HAVE_IOCTL_H
#include <sys/ioctl.h> #include <sys/ioctl.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
@ -80,6 +84,7 @@ fu_udev_device_emit_changed (FuUdevDevice *self)
static guint32 static guint32
fu_udev_device_get_sysfs_attr_as_uint32 (GUdevDevice *udev_device, const gchar *name) fu_udev_device_get_sysfs_attr_as_uint32 (GUdevDevice *udev_device, const gchar *name)
{ {
#ifdef HAVE_GUDEV
guint64 tmp = fu_common_strtoull (g_udev_device_get_sysfs_attr (udev_device, name)); guint64 tmp = fu_common_strtoull (g_udev_device_get_sysfs_attr (udev_device, name));
if (tmp > G_MAXUINT32) { if (tmp > G_MAXUINT32) {
g_warning ("reading %s for %s overflowed", g_warning ("reading %s for %s overflowed",
@ -88,11 +93,15 @@ fu_udev_device_get_sysfs_attr_as_uint32 (GUdevDevice *udev_device, const gchar *
return G_MAXUINT32; return G_MAXUINT32;
} }
return tmp; return tmp;
#else
return G_MAXUINT32;
#endif
} }
static guint8 static guint8
fu_udev_device_get_sysfs_attr_as_uint8 (GUdevDevice *udev_device, const gchar *name) fu_udev_device_get_sysfs_attr_as_uint8 (GUdevDevice *udev_device, const gchar *name)
{ {
#ifdef HAVE_GUDEV
guint64 tmp = fu_common_strtoull (g_udev_device_get_sysfs_attr (udev_device, name)); guint64 tmp = fu_common_strtoull (g_udev_device_get_sysfs_attr (udev_device, name));
if (tmp > G_MAXUINT8) { if (tmp > G_MAXUINT8) {
g_warning ("reading %s for %s overflowed", g_warning ("reading %s for %s overflowed",
@ -101,32 +110,38 @@ fu_udev_device_get_sysfs_attr_as_uint8 (GUdevDevice *udev_device, const gchar *n
return G_MAXUINT8; return G_MAXUINT8;
} }
return tmp; return tmp;
#else
return G_MAXUINT8;
#endif
} }
static void static void
fu_udev_device_dump_internal (GUdevDevice *udev_device) fu_udev_device_to_string (FuDevice *device, guint idt, GString *str)
{ {
#ifdef HAVE_GUDEV
FuUdevDevice *self = FU_UDEV_DEVICE (device);
FuUdevDevicePrivate *priv = GET_PRIVATE (self);
const gchar * const *keys; const gchar * const *keys;
keys = g_udev_device_get_property_keys (udev_device);
for (guint i = 0; keys[i] != NULL; i++) {
g_debug ("%s={%s}", keys[i],
g_udev_device_get_property (udev_device, keys[i]));
}
keys = g_udev_device_get_sysfs_attr_keys (udev_device);
for (guint i = 0; keys[i] != NULL; i++) {
g_debug ("%s=[%s]", keys[i],
g_udev_device_get_sysfs_attr (udev_device, keys[i]));
}
}
void
fu_udev_device_dump (FuUdevDevice *self)
{
FuUdevDevicePrivate *priv = GET_PRIVATE (self);
if (priv->udev_device == NULL) if (priv->udev_device == NULL)
return; return;
fu_udev_device_dump_internal (priv->udev_device);
if (g_getenv ("FU_UDEV_DEVICE_DEBUG") == NULL)
return;
keys = g_udev_device_get_property_keys (priv->udev_device);
for (guint i = 0; keys[i] != NULL; i++) {
fu_common_string_append_kv (str, idt, keys[i],
g_udev_device_get_property (priv->udev_device,
keys[i]));
}
keys = g_udev_device_get_sysfs_attr_keys (priv->udev_device);
for (guint i = 0; keys[i] != NULL; i++) {
fu_common_string_append_kv (str, idt, keys[i],
g_udev_device_get_sysfs_attr (priv->udev_device,
keys[i]));
}
#endif
} }
static gboolean static gboolean
@ -135,10 +150,12 @@ fu_udev_device_probe (FuDevice *device, GError **error)
FuUdevDeviceClass *klass = FU_UDEV_DEVICE_GET_CLASS (device); FuUdevDeviceClass *klass = FU_UDEV_DEVICE_GET_CLASS (device);
FuUdevDevice *self = FU_UDEV_DEVICE (device); FuUdevDevice *self = FU_UDEV_DEVICE (device);
FuUdevDevicePrivate *priv = GET_PRIVATE (self); FuUdevDevicePrivate *priv = GET_PRIVATE (self);
#ifdef HAVE_GUDEV
const gchar *tmp; const gchar *tmp;
g_autofree gchar *subsystem = NULL; g_autofree gchar *subsystem = NULL;
g_autoptr(GUdevDevice) udev_parent = NULL; g_autoptr(GUdevDevice) udev_parent = NULL;
g_autoptr(GUdevDevice) parent_i2c = NULL; g_autoptr(GUdevDevice) parent_i2c = NULL;
#endif
/* nothing to do */ /* nothing to do */
if (priv->udev_device == NULL) if (priv->udev_device == NULL)
@ -149,6 +166,7 @@ fu_udev_device_probe (FuDevice *device, GError **error)
priv->model = fu_udev_device_get_sysfs_attr_as_uint32 (priv->udev_device, "device"); priv->model = fu_udev_device_get_sysfs_attr_as_uint32 (priv->udev_device, "device");
priv->revision = fu_udev_device_get_sysfs_attr_as_uint8 (priv->udev_device, "revision"); priv->revision = fu_udev_device_get_sysfs_attr_as_uint8 (priv->udev_device, "revision");
#ifdef HAVE_GUDEV
/* fallback to the parent */ /* fallback to the parent */
udev_parent = g_udev_device_get_parent (priv->udev_device); udev_parent = g_udev_device_get_parent (priv->udev_device);
if (udev_parent != NULL && if (udev_parent != NULL &&
@ -267,7 +285,7 @@ fu_udev_device_probe (FuDevice *device, GError **error)
} }
/* add GUIDs in order of priority */ /* add GUIDs in order of priority */
if (priv->vendor != 0x0000 && priv->model != 0x0000 && priv->revision != 0x00) { if (priv->vendor != 0x0000 && priv->model != 0x0000) {
g_autofree gchar *devid = NULL; g_autofree gchar *devid = NULL;
devid = g_strdup_printf ("%s\\VEN_%04X&DEV_%04X&REV_%02X", devid = g_strdup_printf ("%s\\VEN_%04X&DEV_%04X&REV_%02X",
subsystem, priv->vendor, subsystem, priv->vendor,
@ -298,6 +316,7 @@ fu_udev_device_probe (FuDevice *device, GError **error)
"i2c", NULL); "i2c", NULL);
if (parent_i2c != NULL) if (parent_i2c != NULL)
fu_device_add_flag (device, FWUPD_DEVICE_FLAG_INTERNAL); fu_device_add_flag (device, FWUPD_DEVICE_FLAG_INTERNAL);
#endif
/* subclassed */ /* subclassed */
if (klass->probe != NULL) { if (klass->probe != NULL) {
@ -320,13 +339,27 @@ fu_udev_device_set_dev (FuUdevDevice *self, GUdevDevice *udev_device)
g_set_object (&priv->udev_device, udev_device); g_set_object (&priv->udev_device, udev_device);
if (priv->udev_device == NULL) if (priv->udev_device == NULL)
return; return;
#ifdef HAVE_GUDEV
priv->subsystem = g_strdup (g_udev_device_get_subsystem (priv->udev_device)); priv->subsystem = g_strdup (g_udev_device_get_subsystem (priv->udev_device));
priv->device_file = g_strdup (g_udev_device_get_device_file (priv->udev_device)); priv->device_file = g_strdup (g_udev_device_get_device_file (priv->udev_device));
#endif
} }
/**
* fu_udev_device_get_slot_depth:
* @self: A #FuUdevDevice
* @subsystem: a subsystem
*
* Determine how far up a chain a given device is
*
* Returns: unsigned integer
*
* Since: 1.2.4
**/
guint guint
fu_udev_device_get_slot_depth (FuUdevDevice *self, const gchar *subsystem) fu_udev_device_get_slot_depth (FuUdevDevice *self, const gchar *subsystem)
{ {
#ifdef HAVE_GUDEV
GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (self)); GUdevDevice *udev_device = fu_udev_device_get_dev (FU_UDEV_DEVICE (self));
g_autoptr(GUdevDevice) device_tmp = NULL; g_autoptr(GUdevDevice) device_tmp = NULL;
@ -339,6 +372,7 @@ fu_udev_device_get_slot_depth (FuUdevDevice *self, const gchar *subsystem)
return i; return i;
g_set_object (&device_tmp, parent); g_set_object (&device_tmp, parent);
} }
#endif
return 0; return 0;
} }
@ -426,11 +460,13 @@ fu_udev_device_get_device_file (FuUdevDevice *self)
const gchar * const gchar *
fu_udev_device_get_sysfs_path (FuUdevDevice *self) fu_udev_device_get_sysfs_path (FuUdevDevice *self)
{ {
#ifdef HAVE_GUDEV
FuUdevDevicePrivate *priv = GET_PRIVATE (self); FuUdevDevicePrivate *priv = GET_PRIVATE (self);
g_return_val_if_fail (FU_IS_UDEV_DEVICE (self), NULL); g_return_val_if_fail (FU_IS_UDEV_DEVICE (self), NULL);
if (priv->udev_device == NULL) if (priv->udev_device != NULL)
return NULL;
return g_udev_device_get_sysfs_path (priv->udev_device); return g_udev_device_get_sysfs_path (priv->udev_device);
#endif
return NULL;
} }
/** /**
@ -487,6 +523,7 @@ fu_udev_device_get_revision (FuUdevDevice *self)
return priv->revision; return priv->revision;
} }
#ifdef HAVE_GUDEV
static GString * static GString *
fu_udev_device_get_parent_subsystems (FuUdevDevice *self) fu_udev_device_get_parent_subsystems (FuUdevDevice *self)
{ {
@ -509,6 +546,7 @@ fu_udev_device_get_parent_subsystems (FuUdevDevice *self)
g_string_truncate (str, str->len - 1); g_string_truncate (str, str->len - 1);
return str; return str;
} }
#endif
/** /**
* fu_udev_device_set_physical_id: * fu_udev_device_set_physical_id:
@ -527,6 +565,7 @@ fu_udev_device_get_parent_subsystems (FuUdevDevice *self)
gboolean gboolean
fu_udev_device_set_physical_id (FuUdevDevice *self, const gchar *subsystem, GError **error) fu_udev_device_set_physical_id (FuUdevDevice *self, const gchar *subsystem, GError **error)
{ {
#ifdef HAVE_GUDEV
FuUdevDevicePrivate *priv = GET_PRIVATE (self); FuUdevDevicePrivate *priv = GET_PRIVATE (self);
const gchar *tmp; const gchar *tmp;
g_autofree gchar *physical_id = NULL; g_autofree gchar *physical_id = NULL;
@ -600,6 +639,13 @@ fu_udev_device_set_physical_id (FuUdevDevice *self, const gchar *subsystem, GErr
/* success */ /* success */
fu_device_set_physical_id (FU_DEVICE (self), physical_id); fu_device_set_physical_id (FU_DEVICE (self), physical_id);
return TRUE; return TRUE;
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <gudev.h> is unavailable");
return FALSE;
#endif
} }
/** /**
@ -668,7 +714,19 @@ fu_udev_device_open (FuDevice *device, GError **error)
/* open device */ /* open device */
if (priv->device_file != NULL) { if (priv->device_file != NULL) {
priv->fd = g_open (priv->device_file, priv->readonly ? O_RDONLY : O_RDWR); if (priv->readonly) {
priv->fd = g_open (priv->device_file, O_RDONLY, 0);
if (priv->fd < 0) {
g_set_error (error,
G_IO_ERROR,
G_IO_ERROR_FAILED,
"failed to open %s for reading: %s",
priv->device_file,
strerror (errno));
return FALSE;
}
} else {
priv->fd = g_open (priv->device_file, O_RDWR, 0);
if (priv->fd < 0) { if (priv->fd < 0) {
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
@ -679,6 +737,7 @@ fu_udev_device_open (FuDevice *device, GError **error)
return FALSE; return FALSE;
} }
} }
}
/* subclassed */ /* subclassed */
if (klass->open != NULL) { if (klass->open != NULL) {
@ -735,6 +794,7 @@ fu_udev_device_ioctl (FuUdevDevice *self,
gint *rc, gint *rc,
GError **error) GError **error)
{ {
#ifdef HAVE_IOCTL_H
FuUdevDevicePrivate *priv = GET_PRIVATE (self); FuUdevDevicePrivate *priv = GET_PRIVATE (self);
gint rc_tmp; gint rc_tmp;
@ -762,6 +822,13 @@ fu_udev_device_ioctl (FuUdevDevice *self,
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
#else
g_set_error (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <sys/ioctl.h> not found");
return FALSE;
#endif
} }
/** /**
@ -786,6 +853,7 @@ fu_udev_device_pwrite (FuUdevDevice *self, goffset port, guint8 data, GError **e
g_return_val_if_fail (port != 0x0, FALSE); g_return_val_if_fail (port != 0x0, FALSE);
g_return_val_if_fail (priv->fd > 0, FALSE); g_return_val_if_fail (priv->fd > 0, FALSE);
#ifdef HAVE_PWRITE
if (pwrite (priv->fd, &data, 1, port) != 1) { if (pwrite (priv->fd, &data, 1, port) != 1) {
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
@ -796,6 +864,13 @@ fu_udev_device_pwrite (FuUdevDevice *self, goffset port, guint8 data, GError **e
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as pwrite() is unavailable");
return FALSE;
#endif
} }
/** /**
@ -821,6 +896,7 @@ fu_udev_device_pread (FuUdevDevice *self, goffset port, guint8 *data, GError **e
g_return_val_if_fail (data != NULL, FALSE); g_return_val_if_fail (data != NULL, FALSE);
g_return_val_if_fail (priv->fd > 0, FALSE); g_return_val_if_fail (priv->fd > 0, FALSE);
#ifdef HAVE_PWRITE
if (pread (priv->fd, data, 1, port) != 1) { if (pread (priv->fd, data, 1, port) != 1) {
g_set_error (error, g_set_error (error,
G_IO_ERROR, G_IO_ERROR,
@ -831,6 +907,13 @@ fu_udev_device_pread (FuUdevDevice *self, goffset port, guint8 *data, GError **e
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as pread() is unavailable");
return FALSE;
#endif
} }
static void static void
@ -912,6 +995,7 @@ fu_udev_device_class_init (FuUdevDeviceClass *klass)
device_class->incorporate = fu_udev_device_incorporate; device_class->incorporate = fu_udev_device_incorporate;
device_class->open = fu_udev_device_open; device_class->open = fu_udev_device_open;
device_class->close = fu_udev_device_close; device_class->close = fu_udev_device_close;
device_class->to_string = fu_udev_device_to_string;
signals[SIGNAL_CHANGED] = signals[SIGNAL_CHANGED] =
g_signal_new ("changed", g_signal_new ("changed",

View File

@ -7,7 +7,13 @@
#pragma once #pragma once
#include <glib-object.h> #include <glib-object.h>
#ifdef HAVE_GUDEV
#include <gudev/gudev.h> #include <gudev/gudev.h>
#else
#define G_UDEV_TYPE_DEVICE G_TYPE_OBJECT
#define GUdevDevice GObject
#endif
#include "fu-plugin.h" #include "fu-plugin.h"
@ -39,7 +45,6 @@ guint fu_udev_device_get_slot_depth (FuUdevDevice *self,
gboolean fu_udev_device_set_physical_id (FuUdevDevice *self, gboolean fu_udev_device_set_physical_id (FuUdevDevice *self,
const gchar *subsystem, const gchar *subsystem,
GError **error); GError **error);
void fu_udev_device_dump (FuUdevDevice *self);
void fu_udev_device_set_readonly (FuUdevDevice *self, void fu_udev_device_set_readonly (FuUdevDevice *self,
gboolean readonly); gboolean readonly);

View File

@ -430,17 +430,18 @@ fu_usb_device_set_dev (FuUsbDevice *device, GUsbDevice *usb_device)
/** /**
* fu_usb_device_find_udev_device: * fu_usb_device_find_udev_device:
* @device: A #FuUsbDevice * @device: A #FuUsbDevice
* @usb_device: A #GUsbDevice, or %NULL * @error: A #GError, or %NULL
* *
* Gets the matching #GUdevDevice for the #GUsbDevice. * Gets the matching #GUdevDevice for the #GUsbDevice.
* *
* Returns: a #GUdevDevice, or NULL if unset or invalid * Returns: (transfer full): a #GUdevDevice, or NULL if unset or invalid
* *
* Since: 1.3.2 * Since: 1.3.2
**/ **/
GUdevDevice * GUdevDevice *
fu_usb_device_find_udev_device (FuUsbDevice *device, GError **error) fu_usb_device_find_udev_device (FuUsbDevice *device, GError **error)
{ {
#ifdef HAVE_GUDEV
FuUsbDevicePrivate *priv = GET_PRIVATE (device); FuUsbDevicePrivate *priv = GET_PRIVATE (device);
g_autoptr(GList) devices = NULL; g_autoptr(GList) devices = NULL;
g_autoptr(GUdevClient) gudev_client = g_udev_client_new (NULL); g_autoptr(GUdevClient) gudev_client = g_udev_client_new (NULL);
@ -473,6 +474,12 @@ fu_usb_device_find_udev_device (FuUsbDevice *device, GError **error)
"could not find sysfs device for %u:%u", "could not find sysfs device for %u:%u",
g_usb_device_get_bus (priv->usb_device), g_usb_device_get_bus (priv->usb_device),
g_usb_device_get_address (priv->usb_device)); g_usb_device_get_address (priv->usb_device));
#else
g_set_error_literal (error,
FWUPD_ERROR,
FWUPD_ERROR_NOT_SUPPORTED,
"Not supported as <gudev.h> is unavailable");
#endif
return NULL; return NULL;
} }

View File

@ -8,22 +8,22 @@
#include <glib-object.h> #include <glib-object.h>
#include <gusb.h> #include <gusb.h>
#include <gudev/gudev.h>
#include "fu-plugin.h" #include "fu-plugin.h"
#include "fu-udev-device.h"
#define FU_TYPE_USB_DEVICE (fu_usb_device_get_type ()) #define FU_TYPE_USB_DEVICE (fu_usb_device_get_type ())
G_DECLARE_DERIVABLE_TYPE (FuUsbDevice, fu_usb_device, FU, USB_DEVICE, FuDevice) G_DECLARE_DERIVABLE_TYPE (FuUsbDevice, fu_usb_device, FU, USB_DEVICE, FuDevice)
/* HID */ /* HID */
#define HID_REPORT_GET 0x01 #define FU_HID_REPORT_GET 0x01
#define HID_REPORT_SET 0x09 #define FU_HID_REPORT_SET 0x09
#define HID_REPORT_TYPE_INPUT 0x01 #define FU_HID_REPORT_TYPE_INPUT 0x01
#define HID_REPORT_TYPE_OUTPUT 0x02 #define FU_HID_REPORT_TYPE_OUTPUT 0x02
#define HID_REPORT_TYPE_FEATURE 0x03 #define FU_HID_REPORT_TYPE_FEATURE 0x03
#define HID_FEATURE 0x0300 #define FU_HID_FEATURE 0x0300
struct _FuUsbDeviceClass struct _FuUsbDeviceClass
{ {

View File

@ -0,0 +1,44 @@
/*
* Copyright (C) 2015 Richard Hughes <richard@hughsie.com>
*
* SPDX-License-Identifier: LGPL-2.1+
*/
#pragma once
/**
* SECTION:fwupdplugin
* @short_description: Helper objects for plugins interacting with fwupd daemon
*/
#define __FWUPDPLUGIN_H_INSIDE__
#include <libfwupdplugin/fu-archive.h>
#include <libfwupdplugin/fu-chunk.h>
#include <libfwupdplugin/fu-common.h>
#include <libfwupdplugin/fu-common-cab.h>
#include <libfwupdplugin/fu-common-guid.h>
#include <libfwupdplugin/fu-common-version.h>
#include <libfwupdplugin/fu-device.h>
#include <libfwupdplugin/fu-device-locker.h>
#include <libfwupdplugin/fu-device-metadata.h>
#include <libfwupdplugin/fu-dfu-firmware.h>
#include <libfwupdplugin/fu-firmware.h>
#include <libfwupdplugin/fu-firmware-common.h>
#include <libfwupdplugin/fu-firmware-image.h>
#include <libfwupdplugin/fu-hwids.h>
#include <libfwupdplugin/fu-ihex-firmware.h>
#include <libfwupdplugin/fu-io-channel.h>
#include <libfwupdplugin/fu-plugin.h>
#include <libfwupdplugin/fu-plugin-vfuncs.h>
#include <libfwupdplugin/fu-quirks.h>
#include <libfwupdplugin/fu-smbios.h>
#include <libfwupdplugin/fu-srec-firmware.h>
#include <libfwupdplugin/fu-udev-device.h>
#include <libfwupdplugin/fu-usb-device.h>
#ifndef FWUPD_DISABLE_DEPRECATED
#include <libfwupdplugin/fu-deprecated.h>
#endif
#undef __FWUPDPLUGIN_H_INSIDE__

View File

@ -0,0 +1,520 @@
# generated automatically, do not edit!
LIBFWUPDPLUGIN_0.1.0 {
global:
fu_device_add_flag;
fu_device_get_metadata;
fu_device_get_type;
fu_device_new;
fu_device_set_metadata;
local: *;
};
LIBFWUPDPLUGIN_0.3.5 {
global:
fu_common_vercmp;
local: *;
} LIBFWUPDPLUGIN_0.1.0;
LIBFWUPDPLUGIN_0.6.1 {
global:
fu_device_get_equivalent_id;
fu_device_set_equivalent_id;
local: *;
} LIBFWUPDPLUGIN_0.3.5;
LIBFWUPDPLUGIN_0.7.1 {
global:
fu_device_set_id;
fu_device_set_name;
local: *;
} LIBFWUPDPLUGIN_0.6.1;
LIBFWUPDPLUGIN_0.7.2 {
global:
fu_device_add_guid;
fu_device_get_alternate;
fu_device_set_alternate;
local: *;
} LIBFWUPDPLUGIN_0.7.1;
LIBFWUPDPLUGIN_0.8.0 {
global:
fu_plugin_alloc_data;
fu_plugin_cache_add;
fu_plugin_cache_lookup;
fu_plugin_cache_remove;
fu_plugin_device_add;
fu_plugin_device_remove;
fu_plugin_get_data;
fu_plugin_get_enabled;
fu_plugin_get_name;
fu_plugin_get_type;
fu_plugin_get_usb_context;
fu_plugin_new;
fu_plugin_open;
fu_plugin_request_recoldplug;
fu_plugin_runner_clear_results;
fu_plugin_runner_coldplug;
fu_plugin_runner_coldplug_cleanup;
fu_plugin_runner_coldplug_prepare;
fu_plugin_runner_get_results;
fu_plugin_runner_startup;
fu_plugin_runner_unlock;
fu_plugin_runner_update;
fu_plugin_runner_verify;
fu_plugin_set_coldplug_delay;
fu_plugin_set_enabled;
fu_plugin_set_name;
fu_plugin_set_usb_context;
local: *;
} LIBFWUPDPLUGIN_0.7.2;
LIBFWUPDPLUGIN_0.9.1 {
global:
fu_plugin_check_hwid;
local: *;
} LIBFWUPDPLUGIN_0.8.0;
LIBFWUPDPLUGIN_0.9.3 {
global:
fu_hwids_get_guid;
fu_hwids_get_guids;
fu_hwids_get_replace_keys;
fu_hwids_get_replace_values;
fu_hwids_get_type;
fu_hwids_get_value;
fu_hwids_has_guid;
fu_hwids_new;
fu_hwids_setup;
local: *;
} LIBFWUPDPLUGIN_0.9.1;
LIBFWUPDPLUGIN_0.9.5 {
global:
fu_common_get_contents_fd;
fu_common_set_contents_bytes;
local: *;
} LIBFWUPDPLUGIN_0.9.3;
LIBFWUPDPLUGIN_0.9.7 {
global:
fu_common_extract_archive;
fu_common_firmware_builder;
fu_common_get_contents_bytes;
fu_common_mkdir_parent;
fu_common_rmtree;
fu_common_spawn_sync;
fu_device_get_metadata_boolean;
fu_device_get_metadata_integer;
fu_device_set_metadata_boolean;
fu_device_set_metadata_integer;
fu_plugin_device_register;
fu_plugin_get_dmi_value;
fu_plugin_runner_device_register;
fu_plugin_set_hwids;
local: *;
} LIBFWUPDPLUGIN_0.9.5;
LIBFWUPDPLUGIN_0.9.8 {
global:
fu_device_to_string;
fu_plugin_get_smbios_data;
fu_plugin_get_smbios_string;
local: *;
} LIBFWUPDPLUGIN_0.9.7;
LIBFWUPDPLUGIN_1.0.0 {
global:
fu_device_locker_get_type;
fu_device_locker_new;
fu_device_locker_new_full;
fu_plugin_add_rule;
fu_plugin_get_order;
fu_plugin_get_rules;
fu_plugin_has_rule;
fu_plugin_set_order;
fu_plugin_set_priority;
fu_plugin_set_smbios;
fu_smbios_get_data;
fu_smbios_get_string;
fu_smbios_get_type;
fu_smbios_new;
fu_smbios_setup;
fu_smbios_setup_from_file;
fu_smbios_setup_from_path;
fu_smbios_to_string;
local: *;
} LIBFWUPDPLUGIN_0.9.8;
LIBFWUPDPLUGIN_1.0.1 {
global:
fu_chunk_array_to_string;
fu_plugin_get_quirks;
fu_plugin_lookup_quirk_by_id;
fu_plugin_set_quirks;
fu_quirks_get_type;
fu_quirks_load;
fu_quirks_lookup_by_id;
fu_quirks_new;
local: *;
} LIBFWUPDPLUGIN_1.0.0;
LIBFWUPDPLUGIN_1.0.2 {
global:
fu_device_get_remove_delay;
fu_device_set_remove_delay;
fu_plugin_runner_udev_device_added;
fu_plugin_runner_udev_device_changed;
fu_plugin_runner_usb_device_added;
fu_usb_device_get_dev;
fu_usb_device_get_type;
fu_usb_device_new;
fu_usb_device_set_dev;
local: *;
} LIBFWUPDPLUGIN_1.0.1;
LIBFWUPDPLUGIN_1.0.3 {
global:
fu_common_read_uint16;
fu_common_read_uint32;
fu_common_write_uint16;
fu_common_write_uint32;
fu_device_get_progress;
fu_device_get_quirks;
fu_device_get_status;
fu_device_set_progress;
fu_device_set_progress_full;
fu_device_set_quirks;
fu_device_set_status;
fu_usb_device_is_open;
local: *;
} LIBFWUPDPLUGIN_1.0.2;
LIBFWUPDPLUGIN_1.0.4 {
global:
fu_plugin_add_report_metadata;
fu_plugin_get_report_metadata;
fu_plugin_runner_recoldplug;
local: *;
} LIBFWUPDPLUGIN_1.0.3;
LIBFWUPDPLUGIN_1.0.5 {
global:
fu_device_get_release_default;
local: *;
} LIBFWUPDPLUGIN_1.0.4;
LIBFWUPDPLUGIN_1.0.6 {
global:
fu_common_get_files_recursive;
fu_plugin_get_config_value;
local: *;
} LIBFWUPDPLUGIN_1.0.5;
LIBFWUPDPLUGIN_1.0.7 {
global:
fu_plugin_add_compile_version;
fu_plugin_add_runtime_version;
fu_plugin_set_compile_versions;
fu_plugin_set_runtime_versions;
local: *;
} LIBFWUPDPLUGIN_1.0.6;
LIBFWUPDPLUGIN_1.0.8 {
global:
fu_common_error_array_get_best;
fu_common_get_path;
fu_device_add_child;
fu_device_add_parent_guid;
fu_device_attach;
fu_device_detach;
fu_device_get_children;
fu_device_get_guids_as_str;
fu_device_get_order;
fu_device_get_parent;
fu_device_get_parent_guids;
fu_device_has_parent_guid;
fu_device_read_firmware;
fu_device_set_order;
fu_device_set_parent;
fu_device_write_firmware;
fu_plugin_guess_name_from_fn;
fu_plugin_name_compare;
fu_plugin_order_compare;
local: *;
} LIBFWUPDPLUGIN_1.0.7;
LIBFWUPDPLUGIN_1.0.9 {
global:
fu_plugin_runner_composite_cleanup;
fu_plugin_runner_composite_prepare;
local: *;
} LIBFWUPDPLUGIN_1.0.8;
LIBFWUPDPLUGIN_1.1.0 {
global:
fu_device_get_alternate_id;
fu_device_get_custom_flags;
fu_device_has_custom_flag;
fu_device_incorporate;
fu_device_set_alternate_id;
fu_device_set_custom_flags;
local: *;
} LIBFWUPDPLUGIN_1.0.9;
LIBFWUPDPLUGIN_1.1.1 {
global:
fu_device_get_priority;
fu_device_set_priority;
fu_plugin_get_hwids;
fu_plugin_get_priority;
local: *;
} LIBFWUPDPLUGIN_1.1.0;
LIBFWUPDPLUGIN_1.1.2 {
global:
fu_chunk_array_new;
fu_chunk_array_new_from_bytes;
fu_chunk_new;
fu_common_find_program_in_path;
fu_common_strstrip;
fu_common_strtoull;
fu_device_add_counterpart_guid;
fu_device_close;
fu_device_ensure_id;
fu_device_get_logical_id;
fu_device_get_physical_id;
fu_device_open;
fu_device_poll;
fu_device_prepare_firmware;
fu_device_probe;
fu_device_probe_invalidate;
fu_device_set_firmware_size_max;
fu_device_set_firmware_size_min;
fu_device_set_logical_id;
fu_device_set_physical_id;
fu_device_set_poll_interval;
fu_device_setup;
fu_plugin_add_udev_subsystem;
fu_plugin_lookup_quirk_by_id_as_uint64;
fu_plugin_runner_device_removed;
fu_plugin_runner_update_attach;
fu_plugin_runner_update_cleanup;
fu_plugin_runner_update_detach;
fu_plugin_runner_update_prepare;
fu_plugin_runner_update_reload;
fu_plugin_set_udev_subsystems;
fu_udev_device_emit_changed;
fu_udev_device_get_dev;
fu_udev_device_get_model;
fu_udev_device_get_revision;
fu_udev_device_get_subsystem;
fu_udev_device_get_sysfs_path;
fu_udev_device_get_type;
fu_udev_device_get_vendor;
fu_udev_device_new;
fu_udev_device_set_physical_id;
fu_usb_device_get_pid;
fu_usb_device_get_platform_id;
fu_usb_device_get_vid;
local: *;
} LIBFWUPDPLUGIN_1.1.1;
LIBFWUPDPLUGIN_1.2.0 {
global:
fu_common_cab_build_silo;
fu_common_string_replace;
fu_common_version_from_uint16;
fu_common_version_from_uint32;
fu_common_version_guess_format;
fu_common_version_parse;
local: *;
} LIBFWUPDPLUGIN_1.1.2;
LIBFWUPDPLUGIN_1.2.2 {
global:
fu_archive_get_type;
fu_archive_lookup_by_fn;
fu_archive_new;
fu_common_dump_bytes;
fu_common_dump_raw;
fu_device_has_guid;
fu_io_channel_get_type;
fu_io_channel_new_file;
fu_io_channel_read_bytes;
fu_io_channel_read_raw;
fu_io_channel_shutdown;
fu_io_channel_unix_get_fd;
fu_io_channel_unix_new;
fu_io_channel_write_bytes;
fu_io_channel_write_raw;
local: *;
} LIBFWUPDPLUGIN_1.2.0;
LIBFWUPDPLUGIN_1.2.4 {
global:
fu_common_bytes_align;
fu_common_dump_full;
fu_common_string_append_kb;
fu_common_string_append_ku;
fu_common_string_append_kv;
fu_common_string_append_kx;
fu_device_incorporate_from_component;
fu_plugin_get_build_hash;
fu_plugin_set_build_hash;
fu_udev_device_get_slot_depth;
local: *;
} LIBFWUPDPLUGIN_1.2.2;
LIBFWUPDPLUGIN_1.2.5 {
global:
fu_common_guid_is_plausible;
fu_device_add_instance_id;
fu_device_convert_instance_ids;
local: *;
} LIBFWUPDPLUGIN_1.2.4;
LIBFWUPDPLUGIN_1.2.6 {
global:
fu_common_bytes_compare;
fu_common_bytes_is_empty;
fu_common_realpath;
fu_device_activate;
fu_device_get_firmware_size_max;
fu_device_get_firmware_size_min;
fu_device_set_firmware_size;
fu_plugin_runner_activate;
local: *;
} LIBFWUPDPLUGIN_1.2.5;
LIBFWUPDPLUGIN_1.2.9 {
global:
fu_common_version_ensure_semver;
fu_common_version_verify_format;
fu_device_add_instance_id_full;
fu_device_set_version;
local: *;
} LIBFWUPDPLUGIN_1.2.6;
LIBFWUPDPLUGIN_1.3.1 {
global:
fu_byte_array_append_uint16;
fu_byte_array_append_uint32;
fu_byte_array_append_uint8;
fu_common_bytes_pad;
fu_common_strnsplit;
fu_device_rescan;
fu_firmware_add_image;
fu_firmware_get_image_by_id;
fu_firmware_get_image_by_id_bytes;
fu_firmware_get_image_by_idx;
fu_firmware_get_image_by_idx_bytes;
fu_firmware_get_image_default;
fu_firmware_get_image_default_bytes;
fu_firmware_get_images;
fu_firmware_get_type;
fu_firmware_image_get_addr;
fu_firmware_image_get_id;
fu_firmware_image_get_idx;
fu_firmware_image_get_type;
fu_firmware_image_new;
fu_firmware_image_set_addr;
fu_firmware_image_set_bytes;
fu_firmware_image_set_id;
fu_firmware_image_set_idx;
fu_firmware_image_to_string;
fu_firmware_image_write_chunk;
fu_firmware_new;
fu_firmware_new_from_bytes;
fu_firmware_parse;
fu_firmware_parse_full;
fu_firmware_strparse_uint16;
fu_firmware_strparse_uint24;
fu_firmware_strparse_uint32;
fu_firmware_strparse_uint4;
fu_firmware_strparse_uint8;
fu_firmware_to_string;
fu_firmware_write;
fu_ihex_firmware_get_type;
fu_ihex_firmware_new;
fu_memcpy_safe;
fu_plugin_has_custom_flag;
fu_udev_device_get_device_file;
local: *;
} LIBFWUPDPLUGIN_1.2.9;
LIBFWUPDPLUGIN_1.3.2 {
global:
fu_common_bytes_compare_raw;
fu_common_strwidth;
fu_firmware_tokenize;
fu_io_channel_read_byte_array;
fu_io_channel_write_byte_array;
fu_srec_firmware_get_records;
fu_srec_firmware_get_type;
fu_srec_firmware_new;
fu_srec_firmware_record_new;
fu_usb_device_find_udev_device;
local: *;
} LIBFWUPDPLUGIN_1.3.1;
LIBFWUPDPLUGIN_1.3.3 {
global:
fu_common_read_uint16_safe;
fu_common_read_uint32_safe;
fu_common_read_uint8_safe;
fu_common_version_parse_from_format;
fu_device_cleanup;
fu_device_get_possible_plugins;
fu_device_get_specialized_gtype;
fu_device_prepare;
fu_device_reload;
fu_device_remove_metadata;
fu_dfu_firmware_get_pid;
fu_dfu_firmware_get_release;
fu_dfu_firmware_get_type;
fu_dfu_firmware_get_version;
fu_dfu_firmware_get_vid;
fu_dfu_firmware_new;
fu_dfu_firmware_set_pid;
fu_dfu_firmware_set_release;
fu_dfu_firmware_set_version;
fu_dfu_firmware_set_vid;
fu_firmware_get_version;
fu_firmware_image_write;
fu_firmware_parse_file;
fu_firmware_set_version;
fu_firmware_write_file;
fu_plugin_add_firmware_gtype;
fu_plugin_get_hwid_replace_value;
fu_plugin_set_device_gtype;
fu_quirks_lookup_by_id_iter;
fu_udev_device_get_fd;
fu_udev_device_ioctl;
fu_udev_device_pread;
fu_udev_device_pwrite;
fu_udev_device_set_fd;
fu_udev_device_set_readonly;
local: *;
} LIBFWUPDPLUGIN_1.3.2;
LIBFWUPDPLUGIN_1.3.4 {
global:
fu_archive_iterate;
fu_firmware_image_get_version;
fu_firmware_image_set_version;
fu_ihex_firmware_get_records;
fu_usb_device_get_spec;
local: *;
} LIBFWUPDPLUGIN_1.3.3;
LIBFWUPDPLUGIN_1.3.5 {
global:
fu_common_fnmatch;
fu_device_get_protocol;
fu_device_incorporate_flag;
fu_device_set_protocol;
fu_plugin_is_open;
local: *;
} LIBFWUPDPLUGIN_1.3.4;

246
libfwupdplugin/meson.build Normal file
View File

@ -0,0 +1,246 @@
fwupdplugin_src = [
'fu-archive.c',
'fu-chunk.c',
'fu-common.c',
'fu-common-cab.c',
'fu-common-guid.c',
'fu-common-version.c',
'fu-device-locker.c',
'fu-device.c',
'fu-dfu-firmware.c',
'fu-firmware.c',
'fu-firmware-common.c',
'fu-firmware-image.c',
'fu-hwids.c',
'fu-ihex-firmware.c',
'fu-io-channel.c',
'fu-plugin.c',
'fu-quirks.c',
'fu-smbios.c',
'fu-srec-firmware.c',
'fu-udev-device.c',
'fu-usb-device.c',
]
fwupdplugin_headers = [
'fu-archive.h',
'fu-chunk.h',
'fu-common.h',
'fu-common-cab.h',
'fu-common-guid.h',
'fu-common-version.h',
'fu-device.h',
'fu-device-metadata.h',
'fu-device-locker.h',
'fu-dfu-firmware.h',
'fu-firmware.h',
'fu-firmware-common.h',
'fu-firmware-image.h',
'fu-hwids.h',
'fu-ihex-firmware.h',
'fu-io-channel.h',
'fu-plugin.h',
'fu-quirks.h',
'fu-smbios.h',
'fu-srec-firmware.h',
'fu-udev-device.h',
'fu-usb-device.h',
]
install_headers(
'fwupdplugin.h',
subdir : 'fwupd-1',
)
install_headers([fwupdplugin_headers, 'fu-plugin-vfuncs.h'],
subdir : 'fwupd-1/libfwupdplugin',
)
fu_hash = custom_target(
'fu-hash.h',
input : fwupdplugin_src,
output : 'fu-hash.h',
command : [python3.path(),
join_paths(meson.current_source_dir(), 'fu-hash.py'),
'@OUTPUT@', '@INPUT@']
)
fwupdplugin_headers_private = [
fu_hash,
'fu-device-private.h',
'fu-plugin-private.h',
'fu-smbios-private.h',
'fu-usb-device-private.h',
]
introspection_deps = [
libxmlb,
giounix,
gusb,
]
if get_option('gudev')
fwupdplugin_headers_private += 'fu-udev-device-private.h'
introspection_deps += gudev
endif
library_deps = [
introspection_deps,
gmodule,
libarchive,
libjsonglib,
libgcab,
valgrind,
]
fwupdplugin_mapfile = 'fwupdplugin.map'
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), fwupdplugin_mapfile)
fwupdplugin = shared_library(
'fwupdplugin',
sources : [
fwupdplugin_src,
fwupdplugin_headers
],
soversion : libfwupdplugin_lt_current,
version : libfwupdplugin_lt_version,
include_directories : [
root_incdir,
fwupd_incdir,
],
dependencies : [
library_deps
],
link_with : [
fwupd,
],
link_args : vflag,
link_depends : fwupdplugin_mapfile,
install : true
)
fwupdplugin_pkgg = import('pkgconfig')
fwupdplugin_pkgg.generate(
libraries : fwupdplugin,
requires : [ 'gio-2.0',
'gmodule-2.0',
'gobject-2.0',
'gusb',
'fwupd',
'json-glib-1.0',
'libarchive',
'libgcab-1.0',
'libsoup-2.4',
'xmlb',
],
subdirs : 'fwupd-1',
version : meson.project_version(),
name : 'fwupdplugin',
filebase : 'fwupdplugin',
description : 'library for plugins to use to interact with fwupd daemon',
)
if get_option('introspection')
gir_dep = declare_dependency(sources: fwupd_gir)
fwupdplugin_gir = gnome.generate_gir(fwupd,
sources : [
fwupdplugin_src,
fwupdplugin_headers,
fwupdplugin_headers_private,
],
nsversion : '1.0',
namespace : 'FwupdPlugin',
symbol_prefix : 'fu',
identifier_prefix : 'Fu',
export_packages : 'fu',
include_directories : [
fwupd_incdir,
],
dependencies : [
gir_dep,
introspection_deps
],
link_with : [
fwupdplugin,
],
includes : [
'Gio-2.0',
'GObject-2.0',
'GUsb-1.0',
fwupd_gir[0],
],
install : true
)
gnome.generate_vapi('fwupdplugin',
sources : fwupd_gir[0],
packages : ['gio-2.0'],
install : true,
)
# Verify the map file is correct -- note we can't actually use the generated
# file for two reasons:
#
# 1. We don't hard depend on GObject Introspection
# 2. The map file is required to build the lib that the GIR is built from
#
# To avoid the circular dep, and to ensure we don't change exported API
# accidentally actually check in a version of the version script to git.
fwupdplugin_mapfile_target = custom_target('fwupdplugin_mapfile',
input: fwupdplugin_gir[0],
output: 'fwupdplugin.map',
command: [
join_paths(meson.source_root(), 'contrib', 'generate-version-script.py'),
'LIBFWUPDPLUGIN',
'@INPUT@',
'@OUTPUT@',
],
)
test('fwupdplugin-exported-api', diffcmd,
args : [
'-urNp',
join_paths(meson.current_source_dir(), 'fwupdplugin.map'),
fwupdplugin_mapfile_target,
],
)
endif
if get_option('tests')
test_deps = [
colorhug_test_firmware,
builder_test_firmware,
hwid_test_firmware,
noreqs_test_firmware,
fu_hash,
]
if get_option('pkcs7')
test_deps += colorhug_pkcs7_signature
endif
testdatadir_src = join_paths(meson.source_root(), 'data', 'tests')
testdatadir_dst = join_paths(meson.build_root(), 'data', 'tests')
pluginbuilddir = join_paths(meson.build_root(), 'plugins', 'test')
e = executable(
'fwupdplugin-self-test',
test_deps,
sources : [
fwupdplugin_src,
'fu-self-test.c'
],
include_directories : [
root_incdir,
fwupd_incdir,
],
dependencies : [
library_deps
],
link_with : [
fwupd,
fwupdplugin
],
c_args : [
'-DTESTDATADIR_SRC="' + testdatadir_src + '"',
'-DTESTDATADIR_DST="' + testdatadir_dst + '"',
'-DPLUGINBUILDDIR="' + pluginbuilddir + '"',
],
)
test('fwupdplugin-self-test', e, is_parallel:false, timeout:180)
endif
fwupdplugin_incdir = include_directories('.')

View File

@ -40,10 +40,14 @@ conf.set_quoted('PACKAGE_VERSION', fwupd_version)
# - If the interface is the same as the previous version, but bugs are # - If the interface is the same as the previous version, but bugs are
# fixed, change: # fixed, change:
# REVISION += 1 # REVISION += 1
lt_current = '2' libfwupd_lt_current = '2'
lt_revision = '0' libfwupd_lt_revision = '0'
lt_age = '0' libfwupd_lt_age = '0'
lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision) libfwupd_lt_version = '@0@.@1@.@2@'.format(libfwupd_lt_current, libfwupd_lt_age, libfwupd_lt_revision)
libfwupdplugin_lt_current = '1'
libfwupdplugin_lt_revision = '0'
libfwupdplugin_lt_age = '0'
libfwupdplugin_lt_version = '@0@.@1@.@2@'.format(libfwupdplugin_lt_current, libfwupdplugin_lt_age, libfwupdplugin_lt_revision)
# get supported warning flags # get supported warning flags
warning_flags = [ warning_flags = [
@ -158,16 +162,25 @@ localstatedir = join_paths(prefix, get_option('localstatedir'))
mandir = join_paths(prefix, get_option('mandir')) mandir = join_paths(prefix, get_option('mandir'))
localedir = join_paths(prefix, get_option('localedir')) localedir = join_paths(prefix, get_option('localedir'))
diffcmd = find_program('diff')
gio = dependency('gio-2.0', version : '>= 2.45.8') gio = dependency('gio-2.0', version : '>= 2.45.8')
giounix = dependency('gio-unix-2.0', version : '>= 2.45.8') giounix = dependency('gio-unix-2.0', version : '>= 2.45.8', required: false)
if giounix.found()
conf.set('HAVE_GIO_UNIX', '1')
endif
if gio.version().version_compare ('>= 2.55.0') if gio.version().version_compare ('>= 2.55.0')
conf.set('HAVE_GIO_2_55_0', '1') conf.set('HAVE_GIO_2_55_0', '1')
endif endif
if build_standalone if build_standalone
gmodule = dependency('gmodule-2.0') gmodule = dependency('gmodule-2.0')
gudev = dependency('gudev-1.0', version : '>= 232') if get_option('gudev')
gudev = dependency('gudev-1.0', version : '>= 232')
conf.set('HAVE_GUDEV', '1')
else
gudev = dependency('', required : false)
endif
libxmlb = dependency('xmlb', version : '>= 0.1.13', fallback : ['libxmlb', 'libxmlb_dep']) libxmlb = dependency('xmlb', version : '>= 0.1.13', fallback : ['libxmlb', 'libxmlb_dep'])
gusb = dependency('gusb', version : '>= 0.2.9') gusb = dependency('gusb', version : '>= 0.2.9', fallback : ['gusb', 'gusb_dep'])
sqlite = dependency('sqlite3') sqlite = dependency('sqlite3')
libarchive = dependency('libarchive') libarchive = dependency('libarchive')
endif endif
@ -199,7 +212,7 @@ if get_option('gpg')
conf.set('ENABLE_GPG', '1') conf.set('ENABLE_GPG', '1')
endif endif
libm = cc.find_library('m', required: false) libm = cc.find_library('m', required: false)
libgcab = dependency('libgcab-1.0') libgcab = dependency('libgcab-1.0', fallback : ['gcab', 'gcab_dep'])
if libgcab.version().version_compare('>= 0.8') if libgcab.version().version_compare('>= 0.8')
conf.set('HAVE_GCAB_0_8', '1') conf.set('HAVE_GCAB_0_8', '1')
endif endif
@ -222,6 +235,34 @@ if build_standalone and get_option('plugin_altos')
libelf = dependency('libelf') libelf = dependency('libelf')
endif endif
if cc.has_header('sys/utsname.h')
conf.set('HAVE_UTSNAME_H', '1')
endif
if cc.has_header('sys/ioctl.h')
conf.set('HAVE_IOCTL_H', '1')
endif
if cc.has_header('sys/errno.h')
conf.set('HAVE_ERRNO_H', '1')
endif
if cc.has_header('poll.h')
conf.set('HAVE_POLL_H', '1')
endif
if cc.has_header('fnmatch.h')
conf.set('HAVE_FNMATCH_H', '1')
endif
if cc.has_function('getuid')
conf.set('HAVE_GETUID', '1')
endif
if cc.has_function('realpath')
conf.set('HAVE_REALPATH', '1')
endif
if cc.has_header_symbol('locale.h', 'LC_MESSAGES')
conf.set('HAVE_LC_MESSAGES', '1')
endif
if cc.has_function('pwrite', args : '-D_XOPEN_SOURCE')
conf.set('HAVE_PWRITE', '1')
endif
if build_standalone and get_option('plugin_uefi') if build_standalone and get_option('plugin_uefi')
cairo = dependency('cairo') cairo = dependency('cairo')
fontconfig = cc.find_library('fontconfig') fontconfig = cc.find_library('fontconfig')
@ -319,21 +360,21 @@ endif
gnome = import('gnome') gnome = import('gnome')
i18n = import('i18n') i18n = import('i18n')
conf.set_quoted('BINDIR', bindir) conf.set_quoted('FWUPD_BINDIR', bindir)
conf.set_quoted('LIBEXECDIR', libexecdir) conf.set_quoted('FWUPD_LIBEXECDIR', libexecdir)
conf.set_quoted('DATADIR', datadir) conf.set_quoted('FWUPD_DATADIR', datadir)
conf.set_quoted('LOCALSTATEDIR', localstatedir) conf.set_quoted('FWUPD_LOCALSTATEDIR', localstatedir)
conf.set_quoted('SYSCONFDIR', sysconfdir) conf.set_quoted('FWUPD_SYSCONFDIR', sysconfdir)
conf.set_quoted('FWUPD_LOCALEDIR', localedir)
if build_standalone if build_standalone
plugin_dir = join_paths(libdir, 'fwupd-plugins-3') plugin_dir = join_paths(libdir, 'fwupd-plugins-3')
conf.set_quoted('PLUGINDIR', plugin_dir) conf.set_quoted('FWUPD_PLUGINDIR', plugin_dir)
endif endif
conf.set_quoted('GETTEXT_PACKAGE', meson.project_name()) conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
conf.set_quoted('PACKAGE_NAME', meson.project_name()) conf.set_quoted('PACKAGE_NAME', meson.project_name())
conf.set_quoted('VERSION', meson.project_version()) conf.set_quoted('VERSION', meson.project_version())
conf.set_quoted('LOCALEDIR', localedir)
configure_file( configure_file(
output : 'config.h', output : 'config.h',
configuration : conf configuration : conf
@ -351,6 +392,8 @@ if build_standalone
plugin_deps += gudev plugin_deps += gudev
endif endif
root_incdir = include_directories('.')
if get_option('gtkdoc') if get_option('gtkdoc')
gtkdocscan = find_program('gtkdoc-scan', required : true) gtkdocscan = find_program('gtkdoc-scan', required : true)
subdir('docs') subdir('docs')
@ -362,6 +405,7 @@ endif
if build_standalone if build_standalone
subdir('data') subdir('data')
subdir('po') subdir('po')
subdir('libfwupdplugin')
subdir('src') subdir('src')
subdir('plugins') subdir('plugins')
subdir('contrib') subdir('contrib')

View File

@ -7,6 +7,7 @@ option('gtkdoc', type : 'boolean', value : false, description : 'enable develope
option('introspection', type : 'boolean', value : true, description : 'generate GObject Introspection data') option('introspection', type : 'boolean', value : true, description : 'generate GObject Introspection data')
option('lvfs', type : 'boolean', value : true, description : 'enable LVFS remotes') option('lvfs', type : 'boolean', value : true, description : 'enable LVFS remotes')
option('man', type : 'boolean', value : true, description : 'enable man pages') option('man', type : 'boolean', value : true, description : 'enable man pages')
option('gudev', type : 'boolean', value : true, description : 'enable GUdev support')
option('pkcs7', type : 'boolean', value : true, description : 'enable the PKCS7 verification support') option('pkcs7', type : 'boolean', value : true, description : 'enable the PKCS7 verification support')
option('plugin_altos', type : 'boolean', value : true, description : 'enable altos support') option('plugin_altos', type : 'boolean', value : true, description : 'enable altos support')
option('plugin_amt', type : 'boolean', value : true, description : 'enable Intel AMT support') option('plugin_amt', type : 'boolean', value : true, description : 'enable Intel AMT support')

View File

@ -10,7 +10,6 @@
#include <poll.h> #include <poll.h>
#include <string.h> #include <string.h>
#include <termios.h> #include <termios.h>
#include <errno.h>
#include "fu-io-channel.h" #include "fu-io-channel.h"
#include "fu-altos-device.h" #include "fu-altos-device.h"
@ -546,6 +545,7 @@ fu_altos_device_init (FuAltosDevice *self)
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_vendor (FU_DEVICE (self), "altusmetrum.org"); fu_device_set_vendor (FU_DEVICE (self), "altusmetrum.org");
fu_device_set_summary (FU_DEVICE (self), "A USB hardware random number generator"); fu_device_set_summary (FU_DEVICE (self), "A USB hardware random number generator");
fu_device_set_protocol (FU_DEVICE (self), "org.altusmetrum.altos");
/* requires manual step */ /* requires manual step */
if (!fu_device_has_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER)) if (!fu_device_has_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_IS_BOOTLOADER))

View File

@ -7,6 +7,7 @@
#include "config.h" #include "config.h"
#include "fu-plugin-vfuncs.h" #include "fu-plugin-vfuncs.h"
#include "fu-hash.h"
#include "fu-altos-device.h" #include "fu-altos-device.h"
#include "fu-altos-firmware.h" #include "fu-altos-firmware.h"
@ -15,7 +16,6 @@ void
fu_plugin_init (FuPlugin *plugin) fu_plugin_init (FuPlugin *plugin)
{ {
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.altusmetrum.altos");
fu_plugin_set_device_gtype (plugin, FU_TYPE_ALTOS_DEVICE); fu_plugin_set_device_gtype (plugin, FU_TYPE_ALTOS_DEVICE);
fu_plugin_add_firmware_gtype (plugin, "altos", FU_TYPE_ALTOS_FIRMWARE); fu_plugin_add_firmware_gtype (plugin, "altos", FU_TYPE_ALTOS_FIRMWARE);
} }

View File

@ -12,14 +12,15 @@ shared_module('fu_plugin_altos',
'fu-plugin-altos.c', 'fu-plugin-altos.c',
], ],
include_directories : [ include_directories : [
include_directories('../..'), root_incdir,
include_directories('../../src'), fwupd_incdir,
include_directories('../../libfwupd'), fwupdplugin_incdir,
], ],
install : true, install : true,
install_dir: plugin_dir, install_dir: plugin_dir,
link_with : [ link_with : [
libfwupdprivate, fwupd,
fwupdplugin,
], ],
c_args : cargs, c_args : cargs,
dependencies : [ dependencies : [

View File

@ -15,6 +15,7 @@
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include "fu-plugin-vfuncs.h" #include "fu-plugin-vfuncs.h"
#include "fu-hash.h"
typedef struct { typedef struct {
uuid_le guid; uuid_le guid;

View File

@ -6,14 +6,15 @@ shared_module('fu_plugin_amt',
'fu-plugin-amt.c', 'fu-plugin-amt.c',
], ],
include_directories : [ include_directories : [
include_directories('../..'), root_incdir,
include_directories('../../src'), fwupd_incdir,
include_directories('../../libfwupd'), fwupdplugin_incdir,
], ],
install : true, install : true,
install_dir: plugin_dir, install_dir: plugin_dir,
link_with : [ link_with : [
libfwupdprivate, fwupd,
fwupdplugin,
], ],
c_args : cargs, c_args : cargs,
dependencies : [ dependencies : [

View File

@ -661,6 +661,7 @@ fu_ata_device_init (FuAtaDevice *self)
fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE); fu_device_add_flag (FU_DEVICE (self), FWUPD_DEVICE_FLAG_UPDATABLE);
fu_device_set_summary (FU_DEVICE (self), "ATA Drive"); fu_device_set_summary (FU_DEVICE (self), "ATA Drive");
fu_device_add_icon (FU_DEVICE (self), "drive-harddisk"); fu_device_add_icon (FU_DEVICE (self), "drive-harddisk");
fu_device_set_protocol (FU_DEVICE (self), "org.t13.ata");
fu_udev_device_set_readonly (FU_UDEV_DEVICE (self), TRUE); fu_udev_device_set_readonly (FU_UDEV_DEVICE (self), TRUE);
} }

View File

@ -7,6 +7,7 @@
#include "config.h" #include "config.h"
#include "fu-plugin-vfuncs.h" #include "fu-plugin-vfuncs.h"
#include "fu-hash.h"
#include "fu-ata-device.h" #include "fu-ata-device.h"
@ -15,6 +16,5 @@ fu_plugin_init (FuPlugin *plugin)
{ {
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_udev_subsystem (plugin, "block"); fu_plugin_add_udev_subsystem (plugin, "block");
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "org.t13.ata");
fu_plugin_set_device_gtype (plugin, FU_TYPE_ATA_DEVICE); fu_plugin_set_device_gtype (plugin, FU_TYPE_ATA_DEVICE);
} }

View File

@ -9,7 +9,6 @@
#include <fwupd.h> #include <fwupd.h>
#include "fu-ata-device.h" #include "fu-ata-device.h"
#include "fu-test.h"
static void static void
fu_ata_id_func (void) fu_ata_id_func (void)
@ -21,8 +20,7 @@ fu_ata_id_func (void)
g_autoptr(FuAtaDevice) dev = NULL; g_autoptr(FuAtaDevice) dev = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
path = fu_test_get_filename (TESTDATADIR, "StarDrive-SBFM61.2.bin"); path = g_build_filename (TESTDATADIR, "StarDrive-SBFM61.2.bin", NULL);
g_assert_nonnull (path);
ret = g_file_get_contents (path, &data, &sz, &error); ret = g_file_get_contents (path, &data, &sz, &error);
g_assert_no_error (error); g_assert_no_error (error);
g_assert (ret); g_assert (ret);

View File

@ -13,9 +13,9 @@ shared_module('fu_plugin_ata',
'fu-ata-device.c', 'fu-ata-device.c',
], ],
include_directories : [ include_directories : [
include_directories('../..'), root_incdir,
include_directories('../../src'), fwupd_incdir,
include_directories('../../libfwupd'), fwupdplugin_incdir,
], ],
install : true, install : true,
install_dir: plugin_dir, install_dir: plugin_dir,
@ -24,7 +24,8 @@ shared_module('fu_plugin_ata',
'-DLOCALSTATEDIR="' + localstatedir + '"', '-DLOCALSTATEDIR="' + localstatedir + '"',
], ],
link_with : [ link_with : [
libfwupdprivate, fwupd,
fwupdplugin,
], ],
dependencies : [ dependencies : [
plugin_deps, plugin_deps,
@ -42,16 +43,16 @@ if get_option('tests')
'fu-ata-device.c', 'fu-ata-device.c',
], ],
include_directories : [ include_directories : [
include_directories('..'), root_incdir,
include_directories('../..'), fwupd_incdir,
include_directories('../../libfwupd'), fwupdplugin_incdir,
include_directories('../../src'),
], ],
dependencies : [ dependencies : [
plugin_deps, plugin_deps,
], ],
link_with : [ link_with : [
libfwupdprivate, fwupd,
fwupdplugin,
], ],
c_args : cargs c_args : cargs
) )

View File

@ -455,6 +455,7 @@ fu_colorhug_device_init (FuColorhugDevice *self)
{ {
/* this is the application code */ /* this is the application code */
self->start_addr = CH_EEPROM_ADDR_RUNCODE; self->start_addr = CH_EEPROM_ADDR_RUNCODE;
fu_device_set_protocol (FU_DEVICE (self), "com.hughski.colorhug");
fu_device_set_remove_delay (FU_DEVICE (self), fu_device_set_remove_delay (FU_DEVICE (self),
FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE); FU_DEVICE_REMOVE_DELAY_RE_ENUMERATE);
} }

View File

@ -7,6 +7,7 @@
#include "config.h" #include "config.h"
#include "fu-plugin-vfuncs.h" #include "fu-plugin-vfuncs.h"
#include "fu-hash.h"
#include "fu-colorhug-device.h" #include "fu-colorhug-device.h"
@ -14,6 +15,5 @@ void
fu_plugin_init (FuPlugin *plugin) fu_plugin_init (FuPlugin *plugin)
{ {
fu_plugin_set_build_hash (plugin, FU_BUILD_HASH); fu_plugin_set_build_hash (plugin, FU_BUILD_HASH);
fu_plugin_add_rule (plugin, FU_PLUGIN_RULE_SUPPORTS_PROTOCOL, "com.hughski.colorhug");
fu_plugin_set_device_gtype (plugin, FU_TYPE_COLORHUG_DEVICE); fu_plugin_set_device_gtype (plugin, FU_TYPE_COLORHUG_DEVICE);
} }

View File

@ -14,14 +14,15 @@ shared_module('fu_plugin_colorhug',
'fu-plugin-colorhug.c', 'fu-plugin-colorhug.c',
], ],
include_directories : [ include_directories : [
include_directories('../..'), root_incdir,
include_directories('../../src'), fwupd_incdir,
include_directories('../../libfwupd'), fwupdplugin_incdir,
], ],
install : true, install : true,
install_dir: plugin_dir, install_dir: plugin_dir,
link_with : [ link_with : [
libfwupdprivate, fwupd,
fwupdplugin,
], ],
c_args : cargs, c_args : cargs,
dependencies : [ dependencies : [

View File

@ -20,13 +20,24 @@ coreboot can be detected the following ways:
coreboot version string coreboot version string
----------------------- -----------------------
The coreboot version string always starts with `CBET`. The coreboot version string can have an optional prefix (see below).
After the prefix the *version*, *major*, *minor* string follows and finally After the optional prefix the *major*, *minor* string follows and finally
the *build string*, containing the exact commit and repository state, follows. the *build string*, containing the exact commit and repository state, follows.
For example:
> 4.10-989-gc8a4e4b9c5-dirty
**Exception on Lenovo devices:**
The thinkpad_acpi kernel module requires a specific pattern in the DMI version
string. To satisfy those requirements coreboot adds the CBETxxxx prefix to the
DMI version string on all Lenovo devices.
For example: For example:
> CBET4000 4.10-989-gc8a4e4b9c5-dirty > CBET4000 4.10-989-gc8a4e4b9c5-dirty
The coreboot DMI version string always starts with `CBET`.
GUID Generation GUID Generation
--------------- ---------------

View File

@ -0,0 +1,2 @@
[SmbiosManufacturer=LENOVO]
CorebootVersionQuirks = lenovo-cbet-prefix

Some files were not shown because too many files have changed in this diff Show More