mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-04 07:25:53 +00:00
trivial: Allow the daemon to run without any idle sources
We need this if we want to run plugins without a daemon process.
This commit is contained in:
parent
c2de52a5b8
commit
5b5f655e0b
@ -24,6 +24,12 @@
|
||||
|
||||
#include <gio/gio.h>
|
||||
|
||||
typedef enum {
|
||||
FU_APP_FLAGS_NONE = 0,
|
||||
FU_APP_FLAGS_NO_IDLE_SOURCES = 1 << 0,
|
||||
FU_APP_FLAGS_LAST
|
||||
} FuAppFlags;
|
||||
|
||||
typedef void (*FuOutputHandler) (const gchar *line,
|
||||
gpointer user_data);
|
||||
|
||||
|
@ -56,6 +56,7 @@ static void fu_engine_finalize (GObject *obj);
|
||||
struct _FuEngine
|
||||
{
|
||||
GObject parent_instance;
|
||||
FuAppFlags app_flags;
|
||||
GUsbContext *usb_ctx;
|
||||
FuConfig *config;
|
||||
FuDeviceList *device_list;
|
||||
@ -2818,6 +2819,11 @@ fu_engine_plugin_recoldplug_cb (FuPlugin *plugin, FuEngine *self)
|
||||
g_warning ("coldplug already running, cannot recoldplug");
|
||||
return;
|
||||
}
|
||||
if (self->app_flags & FU_APP_FLAGS_NO_IDLE_SOURCES) {
|
||||
g_debug ("doing direct recoldplug");
|
||||
fu_engine_plugins_coldplug (self, TRUE);
|
||||
return;
|
||||
}
|
||||
g_debug ("scheduling a recoldplug");
|
||||
if (self->coldplug_id != 0)
|
||||
g_source_remove (self->coldplug_id);
|
||||
@ -3382,9 +3388,10 @@ fu_engine_finalize (GObject *obj)
|
||||
}
|
||||
|
||||
FuEngine *
|
||||
fu_engine_new (void)
|
||||
fu_engine_new (FuAppFlags app_flags)
|
||||
{
|
||||
FuEngine *self;
|
||||
self = g_object_new (FU_TYPE_ENGINE, NULL);
|
||||
self->app_flags = app_flags;
|
||||
return FU_ENGINE (self);
|
||||
}
|
||||
|
@ -30,12 +30,13 @@ G_BEGIN_DECLS
|
||||
#include "fwupd-device.h"
|
||||
#include "fwupd-enums.h"
|
||||
|
||||
#include "fu-common.h"
|
||||
#include "fu-plugin.h"
|
||||
|
||||
#define FU_TYPE_ENGINE (fu_engine_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (FuEngine, fu_engine, FU, ENGINE, GObject)
|
||||
|
||||
FuEngine *fu_engine_new (void);
|
||||
FuEngine *fu_engine_new (FuAppFlags app_flags);
|
||||
gboolean fu_engine_load (FuEngine *self,
|
||||
GError **error);
|
||||
FwupdStatus fu_engine_get_status (FuEngine *self);
|
||||
|
@ -1311,7 +1311,7 @@ main (int argc, char *argv[])
|
||||
priv->loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
/* load engine */
|
||||
priv->engine = fu_engine_new ();
|
||||
priv->engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_signal_connect (priv->engine, "changed",
|
||||
G_CALLBACK (fu_main_engine_changed_cb),
|
||||
priv);
|
||||
|
@ -58,7 +58,7 @@ fu_engine_requirements_missing_func (void)
|
||||
gboolean ret;
|
||||
g_autoptr(AsApp) app = as_app_new ();
|
||||
g_autoptr(AsRequire) req = as_require_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
/* set up a dummy version */
|
||||
@ -83,7 +83,7 @@ fu_engine_requirements_unsupported_func (void)
|
||||
gboolean ret;
|
||||
g_autoptr(AsApp) app = as_app_new ();
|
||||
g_autoptr(AsRequire) req = as_require_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
/* set up a dummy version */
|
||||
@ -107,7 +107,7 @@ fu_engine_requirements_func (void)
|
||||
gboolean ret;
|
||||
g_autoptr(AsApp) app = as_app_new ();
|
||||
g_autoptr(AsRequire) req = as_require_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
/* set up some dummy versions */
|
||||
@ -136,7 +136,7 @@ fu_engine_requirements_device_func (void)
|
||||
g_autoptr(AsRequire) req2 = as_require_new ();
|
||||
g_autoptr(AsRequire) req3 = as_require_new ();
|
||||
g_autoptr(FuDevice) device = fu_device_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
/* set up a dummy device */
|
||||
@ -172,7 +172,7 @@ fu_engine_device_parent_func (void)
|
||||
g_autoptr(FuDevice) device1 = fu_device_new ();
|
||||
g_autoptr(FuDevice) device2 = fu_device_new ();
|
||||
g_autoptr(FuDevice) device3 = fu_device_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
|
||||
/* add child */
|
||||
fu_device_set_id (device1, "child");
|
||||
@ -212,7 +212,7 @@ fu_engine_partial_hash_func (void)
|
||||
gboolean ret;
|
||||
g_autoptr(FuDevice) device1 = fu_device_new ();
|
||||
g_autoptr(FuDevice) device2 = fu_device_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(FuPlugin) plugin = fu_plugin_new ();
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(GError) error_none = NULL;
|
||||
@ -273,7 +273,7 @@ fu_engine_require_hwid_func (void)
|
||||
g_autofree gchar *filename = NULL;
|
||||
g_autoptr(AsStore) store = NULL;
|
||||
g_autoptr(FuDevice) device = fu_device_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(GBytes) blob_cab = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
@ -324,7 +324,7 @@ fu_engine_downgrade_func (void)
|
||||
gboolean ret;
|
||||
g_autofree gchar *testdatadir = NULL;
|
||||
g_autoptr(FuDevice) device = fu_device_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(GError) error = NULL;
|
||||
g_autoptr(GPtrArray) devices = NULL;
|
||||
g_autoptr(GPtrArray) devices_pre = NULL;
|
||||
@ -480,7 +480,7 @@ fu_engine_history_func (void)
|
||||
g_autoptr(FwupdDevice) device3 = NULL;
|
||||
g_autoptr(FwupdDevice) device4 = NULL;
|
||||
g_autoptr(FuDevice) device = fu_device_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(FuHistory) history = NULL;
|
||||
g_autoptr(FuPlugin) plugin = fu_plugin_new ();
|
||||
g_autoptr(GBytes) blob_cab = NULL;
|
||||
@ -598,7 +598,7 @@ fu_engine_history_error_func (void)
|
||||
g_autoptr(AsStore) store = NULL;
|
||||
g_autoptr(FuDevice) device2 = NULL;
|
||||
g_autoptr(FuDevice) device = fu_device_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new ();
|
||||
g_autoptr(FuEngine) engine = fu_engine_new (FU_APP_FLAGS_NONE);
|
||||
g_autoptr(FuHistory) history = NULL;
|
||||
g_autoptr(FuPlugin) plugin = fu_plugin_new ();
|
||||
g_autoptr(GBytes) blob_cab = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user