Top | ![]() |
![]() |
![]() |
![]() |
#define | GS_TYPE_PLUGIN |
struct | GsPluginClass |
typedef | GsPluginData |
#define | GS_PLUGIN_ERROR |
GsPlugin |
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.
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
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
const gchar *
gs_plugin_get_name (GsPlugin *plugin
);
Gets the plugin name.
Since: 3.22
const gchar *
gs_plugin_get_appstream_id (GsPlugin *plugin
);
Gets the plugin AppStream ID.
Since: 3.24
void gs_plugin_set_appstream_id (GsPlugin *plugin
,const gchar *appstream_id
);
Sets the plugin AppStream ID.
Since: 3.24
gboolean
gs_plugin_get_enabled (GsPlugin *plugin
);
Gets if the plugin is enabled.
Since: 3.22
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
gboolean gs_plugin_has_flags (GsPlugin *plugin
,GsPluginFlags flags
);
Finds out if a plugin has a specific flag set.
Since: 3.22
void gs_plugin_add_flags (GsPlugin *plugin
,GsPluginFlags flags
);
Adds specific flags to the plugin.
Since: 3.22
void gs_plugin_remove_flags (GsPlugin *plugin
,GsPluginFlags flags
);
Removes specific flags from the plugin.
Since: 3.22
guint
gs_plugin_get_scale (GsPlugin *plugin
);
Gets the window scale factor.
Since: 3.22
const gchar *
gs_plugin_get_locale (GsPlugin *plugin
);
Gets the user locale. This is in the form documented in man 3 setlocale
:
language[_territory][.codeset][@modifier]
where language
is an
ISO 639 language code,
territory
is an
ISO 3166 country code, and
codeset
is a character set or encoding identifier like ISO-8859-1
or
UTF-8
. For a list of all supported locales, run locale -a
.
Since: 3.22
const gchar *
gs_plugin_get_language (GsPlugin *plugin
);
Gets the user language from the locale. This is the first component of the locale.
Typically you should use the full locale rather than the language, as the same language can be used quite differently in different territories.
Since: 3.22
SoupSession *
gs_plugin_get_soup_session (GsPlugin *plugin
);
Gets the soup session that this plugin can use when downloading.
Since: 3.22
void gs_plugin_set_soup_session (GsPlugin *plugin
,SoupSession *soup_session
);
Sets the soup session that this plugin will use when downloading.
Since: 3.22
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.
plugin |
a GsPlugin |
|
rule |
a GsPluginRule, e.g. |
|
name |
a plugin name, e.g. "appstream" |
Since: 3.22
GBytes * gs_plugin_download_data (GsPlugin *plugin
,GsApp *app
,const gchar *uri
,GCancellable *cancellable
,GError **error
);
Downloads data.
Since: 3.22
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
gchar * gs_plugin_download_rewrite_resource (GsPlugin *plugin
,GsApp *app
,const gchar *resource
,GCancellable *cancellable
,GError **error
);
Downloads remote assets and rewrites a CSS resource to use cached local URIs.
Since: 3.26
gboolean gs_plugin_check_distro_id (GsPlugin *plugin
,const gchar *distro_id
);
Checks if the distro is compatible.
Since: 3.22
GsApp * gs_plugin_cache_lookup (GsPlugin *plugin
,const gchar *key
);
Looks up an application object from the per-plugin cache
Since: 3.22
void gs_plugin_cache_lookup_by_state (GsPlugin *plugin
,GsAppList *list
,AsAppState state
);
Adds each cached GsApp with state state
into the list
.
When the state is AS_APP_STATE_UNKNOWN
, then adds all
cached applications.
Since: 3.36.1-8
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
void gs_plugin_cache_remove (GsPlugin *plugin
,const gchar *key
);
Removes an application from the per-plugin cache.
Since: 3.22
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 function; if a suitable cache key is being used the old cache item can remain.
Since: 3.22
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
gboolean gs_plugin_app_launch (GsPlugin *plugin
,GsApp *app
,GError **error
);
Launches the application using GAppInfo.
Since: 3.22
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
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
const gchar *
gs_plugin_status_to_string (GsPluginStatus status
);
Converts the GsPluginStatus enum to a string.
Since: 3.22
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
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
gboolean
gs_plugin_get_network_available (GsPlugin *plugin
);
Gets whether a network connectivity is available.
Since: 3.28
void gs_plugin_basic_auth_start (GsPlugin *plugin
,const gchar *remote
,const gchar *realm
,GCallback callback
,gpointer user_data
);
Emit the basic-auth-start signal in the main thread.
plugin |
a GsPlugin |
|
remote |
a string |
|
realm |
a string |
|
callback |
callback to invoke to submit the user/password |
|
user_data |
callback data to pass to the callback |
Since: 3.38
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); void (*basic_auth_start) (GsPlugin *plugin, const gchar *remote, const gchar *realm, GCallback callback, gpointer user_data); gpointer padding[25]; };