Top |
Functions
Signals
void | allow-updates | Run Last |
void | reload | Run Last |
void | report-event | Run Last |
void | status-changed | Run Last |
void | updates-changed | Run Last |
Types and Values
#define | GS_TYPE_PLUGIN |
struct | GsPluginClass |
typedef | GsPluginData |
#define | GS_PLUGIN_ERROR |
GsPlugin |
Description
Plugins are modules that are loaded at runtime to provide information about requests and to service user actions like installing, removing and updating. This allows different distributions to pick and choose how the application installer gathers data.
Plugins also have a priority system where the largest number gets run first. That means if one plugin requires some property or metadata set by another plugin then it **must** depend on the other plugin to be run in the correct order.
As a general rule, try to make plugins as small and self-contained as possible and remember to cache as much data as possible for speed. Memory is cheap, time less so.
Functions
gs_plugin_alloc_data ()
GsPluginData * gs_plugin_alloc_data (GsPlugin *plugin
,gsize sz
);
Allocates a private data area for the plugin which can be retrieved
using gs_plugin_get_data()
.
This is normally called in gs_plugin_initialize()
and the data should
not be manually freed.
Since: 3.22
gs_plugin_get_data ()
GsPluginData *
gs_plugin_get_data (GsPlugin *plugin
);
Gets the private data for the plugin if gs_plugin_alloc_data()
has
been called.
Since: 3.22
gs_plugin_get_name ()
const gchar *
gs_plugin_get_name (GsPlugin *plugin
);
Gets the plugin name.
Since: 3.22
gs_plugin_get_appstream_id ()
const gchar *
gs_plugin_get_appstream_id (GsPlugin *plugin
);
Sets the plugin AppStream ID.
Since: 3.24
gs_plugin_set_appstream_id ()
void gs_plugin_set_appstream_id (GsPlugin *plugin
,const gchar *appstream_id
);
gs_plugin_get_enabled ()
gboolean
gs_plugin_get_enabled (GsPlugin *plugin
);
Gets if the plugin is enabled.
Since: 3.22
gs_plugin_set_enabled ()
void gs_plugin_set_enabled (GsPlugin *plugin
,gboolean enabled
);
Enables or disables a plugin.
This is normally only called from gs_plugin_initialize()
.
Since: 3.22
gs_plugin_has_flags ()
gboolean gs_plugin_has_flags (GsPlugin *plugin
,GsPluginFlags flags
);
Finds out if a plugin has a specific flag set.
Since: 3.22
gs_plugin_add_flags ()
void gs_plugin_add_flags (GsPlugin *plugin
,GsPluginFlags flags
);
Adds specific flags to the plugin.
Since: 3.22
gs_plugin_remove_flags ()
void gs_plugin_remove_flags (GsPlugin *plugin
,GsPluginFlags flags
);
Removes specific flags from the plugin.
Since: 3.22
gs_plugin_get_scale ()
guint
gs_plugin_get_scale (GsPlugin *plugin
);
Gets the window scale factor.
Since: 3.22
gs_plugin_get_locale ()
const gchar *
gs_plugin_get_locale (GsPlugin *plugin
);
Gets the user locale.
Since: 3.22
gs_plugin_get_language ()
const gchar *
gs_plugin_get_language (GsPlugin *plugin
);
Gets the user language from the locale.
Since: 3.22
gs_plugin_get_profile ()
AsProfile *
gs_plugin_get_profile (GsPlugin *plugin
);
Gets the profile object to be used for the plugin. This can be used to make plugin actions appear in the global profile output.
Since: 3.22
gs_plugin_get_soup_session ()
SoupSession *
gs_plugin_get_soup_session (GsPlugin *plugin
);
Gets the soup session that plugins can use when downloading.
Since: 3.22
gs_plugin_add_auth ()
void gs_plugin_add_auth (GsPlugin *plugin
,GsAuth *auth
);
Adds an authentication object that can be used for all the plugins.
Since: 3.22
gs_plugin_get_auth_by_id ()
GsAuth * gs_plugin_get_auth_by_id (GsPlugin *plugin
,const gchar *provider_id
);
Gets a specific authentication object.
Since: 3.22
gs_plugin_add_rule ()
void gs_plugin_add_rule (GsPlugin *plugin
,GsPluginRule rule
,const gchar *name
);
If the plugin name is found, the rule will be used to sort the plugin list,
for example the plugin specified by name
will be ordered after this plugin
when GS_PLUGIN_RULE_RUN_AFTER
is used.
NOTE: The depsolver is iterative and may not solve overly-complicated rules; If depsolving fails then gnome-software will not start.
Parameters
plugin |
a GsPlugin |
|
rule |
a GsPluginRule, e.g. |
|
name |
a plugin name, e.g. "appstream" |
Since: 3.22
gs_plugin_download_data ()
GBytes * gs_plugin_download_data (GsPlugin *plugin
,GsApp *app
,const gchar *uri
,GCancellable *cancellable
,GError **error
);
Downloads data.
Since: 3.22
gs_plugin_download_file ()
gboolean gs_plugin_download_file (GsPlugin *plugin
,GsApp *app
,const gchar *uri
,const gchar *filename
,GCancellable *cancellable
,GError **error
);
Downloads data and saves it to a file.
Since: 3.22
gs_plugin_check_distro_id ()
gboolean gs_plugin_check_distro_id (GsPlugin *plugin
,const gchar *distro_id
);
Checks if the distro is compatible.
Since: 3.22
gs_plugin_cache_lookup ()
GsApp * gs_plugin_cache_lookup (GsPlugin *plugin
,const gchar *key
);
Looks up an application object from the per-plugin cache
Since: 3.22
gs_plugin_cache_add ()
void gs_plugin_cache_add (GsPlugin *plugin
,const gchar *key
,GsApp *app
);
Adds an application to the per-plugin cache. This is optional, and the plugin can use the cache however it likes.
Since: 3.22
gs_plugin_cache_remove ()
void gs_plugin_cache_remove (GsPlugin *plugin
,const gchar *key
);
Removes an application from the per-plugin cache.
Since: 3.22
gs_plugin_cache_invalidate ()
void
gs_plugin_cache_invalidate (GsPlugin *plugin
);
Invalidate the per-plugin cache by marking all entries as invalid. This is optional, and the plugin can evict the cache whenever it likes. Using this function may mean the front-end and the plugin may be operating on a different GsApp with the same cache ID.
Most plugins do not need to call this funtion; if a suitable cache key is being used the old cache item can remain.
Since: 3.22
gs_plugin_status_update ()
void gs_plugin_status_update (GsPlugin *plugin
,GsApp *app
,GsPluginStatus status
);
Update the state of the plugin so any UI can be updated.
Since: 3.22
gs_plugin_app_launch ()
gboolean gs_plugin_app_launch (GsPlugin *plugin
,GsApp *app
,GError **error
);
Launches the application using GAppInfo.
Since: 3.22
gs_plugin_updates_changed ()
void
gs_plugin_updates_changed (GsPlugin *plugin
);
Emit a signal that tells the plugin loader that the list of updates may have changed.
Since: 3.22
gs_plugin_reload ()
void
gs_plugin_reload (GsPlugin *plugin
);
Plugins that call this function should expect that all panels will reload after a small delay, causing mush flashing, wailing and gnashing of teeth.
Plugins should not call this unless absolutely required.
Since: 3.22
gs_plugin_status_to_string ()
const gchar *
gs_plugin_status_to_string (GsPluginStatus status
);
Converts the GsPluginStatus enum to a string.
Since: 3.22
gs_plugin_report_event ()
void gs_plugin_report_event (GsPlugin *plugin
,GsPluginEvent *event
);
Report a non-fatal event to the UI. Plugins should not assume that a specific event is actually shown to the user as it may be ignored automatically.
Since: 3.24
gs_plugin_set_allow_updates ()
void gs_plugin_set_allow_updates (GsPlugin *plugin
,gboolean allow_updates
);
This allows plugins to inhibit the showing of the updates panel. This will typically be used when the required permissions are not possible to obtain, or when a LiveUSB image is low on space.
By default, the updates panel is shown so plugins do not need to call this
function unless they called gs_plugin_set_allow_updates()
with FALSE
.
Since: 3.24
Types and Values
struct GsPluginClass
struct GsPluginClass { GObjectClass parent_class; void (*updates_changed) (GsPlugin *plugin); void (*status_changed) (GsPlugin *plugin, GsApp *app, guint status); void (*reload) (GsPlugin *plugin); void (*report_event) (GsPlugin *plugin, GsPluginEvent *event); void (*allow_updates) (GsPlugin *plugin, gboolean allow_updates); gpointer padding[26]; };
Signal Details
The “allow-updates”
signal
void user_function (GsPlugin *gsplugin, gboolean arg1, gpointer user_data)
Flags: Run Last
The “report-event”
signal
void user_function (GsPlugin *gsplugin, GsPluginEvent *arg1, gpointer user_data)
Flags: Run Last
The “status-changed”
signal
void user_function (GsPlugin *gsplugin, GsApp *arg1, guint arg2, gpointer user_data)
Flags: Run Last