GsPlugin Helpers

GsPlugin Helpers — Runtime-loaded modules providing functionality

Stability Level

Unstable, unless otherwise indicated

Functions

Properties

guint64 flags Read / Write

Signals

void reload Run Last
void status-changed Run Last
void updates-changed Run Last

Types and Values

#define GS_TYPE_PLUGIN
struct GsPluginClass
typedef GsPluginData
enum GsPluginStatus
#define GS_PLUGIN_FLAGS_NONE
#define GS_PLUGIN_FLAGS_RUNNING_SELF
#define GS_PLUGIN_FLAGS_RUNNING_OTHER
#define GS_PLUGIN_FLAGS_EXCLUSIVE
#define GS_PLUGIN_FLAGS_RECENT
#define GS_PLUGIN_FLAGS_GLOBAL_CACHE
typedef GsPluginFlags
enum GsPluginError
#define GS_PLUGIN_REFINE_FLAGS_DEFAULT
#define GS_PLUGIN_REFINE_FLAGS_USE_HISTORY
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS
#define GS_PLUGIN_REFINE_FLAGS_ALLOW_PACKAGES
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_SEVERITY
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_KEY_COLORS
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI
#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME
typedef GsPluginRefineFlags
enum GsPluginRefreshFlags
enum GsPluginRule
#define GS_PLUGIN_ERROR
  GsPlugin

Object Hierarchy

    GObject
    ╰── GsPlugin

Includes

#include <gnome-software.h>

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_error_quark ()

GQuark
gs_plugin_error_quark (void);

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.

Parameters

plugin

a GsPlugin

 

sz

the size of data to allocate, e.g. sizeof(FooPluginPrivate)

 

Returns

the GsPluginData, cleared to NUL butes

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.

Parameters

plugin

a GsPlugin

 

Returns

the GsPluginData, or NULL

Since: 3.22


gs_plugin_get_name ()

const gchar *
gs_plugin_get_name (GsPlugin *plugin);

Gets the plugin name.

Parameters

plugin

a GsPlugin

 

Returns

a string, e.g. "fwupd"

Since: 3.22


gs_plugin_get_enabled ()

gboolean
gs_plugin_get_enabled (GsPlugin *plugin);

Gets if the plugin is enabled.

Parameters

plugin

a GsPlugin

 

Returns

TRUE if 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().

Parameters

plugin

a GsPlugin

 

enabled

the enabled state

 

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.

Parameters

plugin

a GsPlugin

 

flags

a GsPluginFlags, e.g. GS_PLUGIN_FLAGS_RUNNING_SELF

 

Returns

TRUE if the flag is set

Since: 3.22


gs_plugin_add_flags ()

void
gs_plugin_add_flags (GsPlugin *plugin,
                     GsPluginFlags flags);

Adds specific flags to the plugin.

Parameters

plugin

a GsPlugin

 

flags

a GsPluginFlags, e.g. GS_PLUGIN_FLAGS_RUNNING_SELF

 

Since: 3.22


gs_plugin_remove_flags ()

void
gs_plugin_remove_flags (GsPlugin *plugin,
                        GsPluginFlags flags);

Removes specific flags from the plugin.

Parameters

plugin

a GsPlugin

 

flags

a GsPluginFlags, e.g. GS_PLUGIN_FLAGS_RUNNING_SELF

 

Since: 3.22


gs_plugin_get_scale ()

guint
gs_plugin_get_scale (GsPlugin *plugin);

Gets the window scale factor.

Parameters

plugin

a GsPlugin

 

Returns

the factor, usually 1 for standard screens or 2 for HiDPI

Since: 3.22


gs_plugin_get_locale ()

const gchar *
gs_plugin_get_locale (GsPlugin *plugin);

Gets the user locale.

Parameters

plugin

a GsPlugin

 

Returns

the locale string, e.g. "en_GB"

Since: 3.22


gs_plugin_get_language ()

const gchar *
gs_plugin_get_language (GsPlugin *plugin);

Gets the user language from the locale.

Parameters

plugin

a GsPlugin

 

Returns

the language string, e.g. "fr"

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.

Parameters

plugin

a GsPlugin

 

Returns

the AsProfile

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.

Parameters

plugin

a GsPlugin

 

Returns

the SoupSession

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.

Parameters

plugin

a GsPlugin

 

auth

a GsAuth

 

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.

Parameters

plugin

a GsPlugin

 

provider_id

an ID, e.g. "dummy-sso"

 

Returns

the GsAuth, or NULL if not found

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. GS_PLUGIN_RULE_CONFLICTS

 

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.

Parameters

plugin

a GsPlugin

 

app

a GsApp, or NULL

 

uri

a remote URI

 

cancellable

a GCancellable, or NULL

 

error

a GError, or NULL

 

Returns

the downloaded data, or NULL

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.

Parameters

plugin

a GsPlugin

 

app

a GsApp, or NULL

 

uri

a remote URI

 

filename

a local filename

 

cancellable

a GCancellable, or NULL

 

error

a GError, or NULL

 

Returns

TRUE for success

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.

Parameters

plugin

a GsPlugin

 

distro_id

a distro ID, e.g. "fedora"

 

Returns

TRUE if 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

Parameters

plugin

a GsPlugin

 

key

a string

 

Returns

the GsApp, or NULL.

[transfer full][nullable]

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.

Parameters

plugin

a GsPlugin

 

key

a string, or NULL if the unique ID should be used

 

app

a GsApp

 

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.

Parameters

plugin

a GsPlugin

 

key

a key which matches

 

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.

Parameters

plugin

a GsPlugin

 

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.

Parameters

plugin

a GsPlugin

 

app

a GsApp, or NULL

 

status

a GsPluginStatus, e.g. GS_PLUGIN_STATUS_DOWNLOADING

 

Since: 3.22


gs_plugin_app_launch ()

gboolean
gs_plugin_app_launch (GsPlugin *plugin,
                      GsApp *app,
                      GError **error);

Launches the application using GAppInfo.

Parameters

plugin

a GsPlugin

 

app

a GsApp

 

error

a GError, or NULL

 

Returns

TRUE for success

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.

Parameters

plugin

a GsPlugin

 

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.

Parameters

plugin

a GsPlugin

 

Since: 3.22


gs_plugin_status_to_string ()

const gchar *
gs_plugin_status_to_string (GsPluginStatus status);

Converts the GsPluginStatus enum to a string.

Parameters

Returns

the string representation, or "unknown"

Since: 3.22

Types and Values

GS_TYPE_PLUGIN

#define GS_TYPE_PLUGIN (gs_plugin_get_type ())

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);
	gpointer		 padding[28];
};

GsPluginData

typedef struct GsPluginData GsPluginData;

enum GsPluginStatus

The ststus of the plugin.

Members

GS_PLUGIN_STATUS_UNKNOWN

Unknown status

 

GS_PLUGIN_STATUS_WAITING

Waiting

 

GS_PLUGIN_STATUS_FINISHED

Finished

 

GS_PLUGIN_STATUS_SETUP

Setup in progress

 

GS_PLUGIN_STATUS_DOWNLOADING

Downloading in progress

 

GS_PLUGIN_STATUS_QUERYING

Querying in progress

 

GS_PLUGIN_STATUS_INSTALLING

Installing in progress

 

GS_PLUGIN_STATUS_REMOVING

Removing in progress

 

GS_PLUGIN_FLAGS_NONE

#define GS_PLUGIN_FLAGS_NONE		(0u)

GS_PLUGIN_FLAGS_RUNNING_SELF

#define GS_PLUGIN_FLAGS_RUNNING_SELF (1u << 0)

GS_PLUGIN_FLAGS_RUNNING_OTHER

#define GS_PLUGIN_FLAGS_RUNNING_OTHER (1u << 1)

GS_PLUGIN_FLAGS_EXCLUSIVE

#define GS_PLUGIN_FLAGS_EXCLUSIVE (1u << 2)

GS_PLUGIN_FLAGS_RECENT

#define GS_PLUGIN_FLAGS_RECENT		(1u << 3)

GS_PLUGIN_FLAGS_GLOBAL_CACHE

#define GS_PLUGIN_FLAGS_GLOBAL_CACHE (1u << 4)

GsPluginFlags

typedef guint64 GsPluginFlags;

The flags for the plugin at this point in time.


enum GsPluginError

The failure error types.

Members

GS_PLUGIN_ERROR_FAILED

Generic failure

 

GS_PLUGIN_ERROR_NOT_SUPPORTED

Action not supported

 

GS_PLUGIN_ERROR_CANCELLED

Action was cancelled

 

GS_PLUGIN_ERROR_NO_NETWORK

No network connection available

 

GS_PLUGIN_ERROR_NO_SECURITY

Security policy forbid action

 

GS_PLUGIN_ERROR_NO_SPACE

No disk space to allow action

 

GS_PLUGIN_ERROR_AUTH_REQUIRED

Authentication was required

 

GS_PLUGIN_ERROR_AUTH_INVALID

Provided authentication was invalid

 

GS_PLUGIN_ERROR_PIN_REQUIRED

PIN required for authentication

 

GS_PLUGIN_ERROR_ACCOUNT_SUSPENDED

User account has been suspended

 

GS_PLUGIN_ERROR_ACCOUNT_DEACTIVATED

User account has been deactivated

 

GS_PLUGIN_ERROR_PLUGIN_DEPSOLVE_FAILED

The plugins installed are incompatible

 

GS_PLUGIN_ERROR_DOWNLOAD_FAILED

The download action failed

 

GS_PLUGIN_ERROR_WRITE_FAILED

The save-to-disk failed

 

GS_PLUGIN_ERROR_INVALID_FORMAT

The data format is invalid

 

GS_PLUGIN_ERROR_DELETE_FAILED

The delete action failed

 

GS_PLUGIN_REFINE_FLAGS_DEFAULT

#define GS_PLUGIN_REFINE_FLAGS_DEFAULT			(0u)

GS_PLUGIN_REFINE_FLAGS_USE_HISTORY

#define GS_PLUGIN_REFINE_FLAGS_USE_HISTORY		(1u << 0)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_LICENSE		(1u << 1)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_URL		(1u << 2)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION (1u << 3)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SIZE		(1u << 4)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING		(1u << 5)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_VERSION		(1u << 6)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_HISTORY		(1u << 7)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION (1u << 8)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_DETAILS (1u << 9)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN		(1u << 10)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RELATED		(1u << 11)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_MENU_PATH (1u << 12)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ADDONS		(1u << 13)

GS_PLUGIN_REFINE_FLAGS_ALLOW_PACKAGES

#define GS_PLUGIN_REFINE_FLAGS_ALLOW_PACKAGES		(1u << 14)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_SEVERITY

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPDATE_SEVERITY (1u << 15)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_UPGRADE_REMOVED (1u << 16)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_PROVENANCE (1u << 17)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEWS		(1u << 18)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_REVIEW_RATINGS (1u << 19)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_KEY_COLORS

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_KEY_COLORS (1u << 20)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON		(1u << 21)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS (1u << 22)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME (1u << 23)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_UI (1u << 24)

GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME

#define GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME		(1u << 25)

GsPluginRefineFlags

typedef guint64 GsPluginRefineFlags;

The refine flags.


enum GsPluginRefreshFlags

The flags used for refresh. Regeneration and downloading is only done if the cache is older than the cache_age.

The GS_PLUGIN_REFRESH_FLAGS_METADATA can be used to make sure there's enough metadata to start the application. The GS_PLUGIN_REFRESH_FLAGS_PAYLOAD flag should only be used when the session is idle and bandwidth is unmetered as the amount of data and IO may be large.

Members

GS_PLUGIN_REFRESH_FLAGS_NONE

Generate new metadata if possible

 

GS_PLUGIN_REFRESH_FLAGS_METADATA

Download new metadata

 

GS_PLUGIN_REFRESH_FLAGS_PAYLOAD

Download any pending payload

 

GS_PLUGIN_REFRESH_FLAGS_INTERACTIVE

Running by user request

 

enum GsPluginRule

The rules used for ordering plugins. Plugins are expected to add rules in gs_plugin_initialize().

Members

GS_PLUGIN_RULE_CONFLICTS

The plugin conflicts with another

 

GS_PLUGIN_RULE_RUN_AFTER

Order the plugin after another

 

GS_PLUGIN_RULE_RUN_BEFORE

Order the plugin before another

 

GS_PLUGIN_RULE_BETTER_THAN

Results are better than another

 

GS_PLUGIN_ERROR

#define GS_PLUGIN_ERROR					gs_plugin_error_quark ()

GsPlugin

typedef struct _GsPlugin GsPlugin;

Property Details

The “flags” property

  “flags”                    guint64

Flags: Read / Write

Default value: 0

Signal Details

The “reload” signal

void
user_function (GsPlugin *gsplugin,
               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


The “updates-changed” signal

void
user_function (GsPlugin *gsplugin,
               gpointer  user_data)

Flags: Run Last