AsDataPool

AsDataPool — Provides access to the AppStream metadata pool.

Functions

Types and Values

Object Hierarchy

    GObject
    ╰── AsDataPool

Description

This class loads AppStream metadata from various sources and refines it with existing knowledge about the system (e.g. by setting absolute pazhs for cached icons). An AsDataPool will use an on-disk cache to store metadata is has read and refined to speed up the loading time when the same data is requested a second time.

You can find AppStream metadata matching farious criteria, and also add new metadata to the pool. The caching behavior can be controlled by the application using AsDataPool.

An AppStream cache object can also be created and read using the appstreamcli(1) utility.

See also: AsComponent

Functions

as_data_pool_error_quark ()

GQuark
as_data_pool_error_quark (void);

Returns

An error quark.


as_data_pool_new ()

AsDataPool *
as_data_pool_new (void);

Creates a new AsDataPool.

Returns

a AsDataPool.

[transfer full]


as_data_pool_get_locale ()

const gchar *
as_data_pool_get_locale (AsDataPool *dpool);

Gets the currently used locale.

Parameters

dpool

An instance of AsDataPool.

 

Returns

Locale used for metadata parsing.


as_data_pool_set_locale ()

void
as_data_pool_set_locale (AsDataPool *dpool,
                         const gchar *locale);

Sets the current locale which should be used when parsing metadata.

Parameters

dpool

An instance of AsDataPool.

 

locale

the locale.

 

as_data_pool_load ()

gboolean
as_data_pool_load (AsDataPool *dpool,
                   GCancellable *cancellable,
                   GError **error);

Builds an index of all found components in the watched locations. The function will try to get as much data into the pool as possible, so even if the update completes with FALSE, it might still have added components to the pool.

The function will load from all possible data sources, preferring caches if they are up to date.

Parameters

dpool

An instance of AsDataPool.

 

error

A GError or NULL.

 

Returns

TRUE if update completed without error.


as_data_pool_load_metadata ()

gboolean
as_data_pool_load_metadata (AsDataPool *dpool);

Load fresh metadata from AppStream directories.


as_data_pool_load_cache_file ()

gboolean
as_data_pool_load_cache_file (AsDataPool *dpool,
                              const gchar *fname,
                              GError **error);

Load AppStream metadata from a cache file.

Parameters

dpool

An instance of AsDataPool.

 

fname

Filename of the cache file to load into the pool.

 

error

A GError or NULL.

 

as_data_pool_save_cache_file ()

gboolean
as_data_pool_save_cache_file (AsDataPool *dpool,
                              const gchar *fname,
                              GError **error);

Serialize AppStream metadata to a cache file.

Parameters

dpool

An instance of AsDataPool.

 

fname

Filename of the cache file the pool contents should be dumped to.

 

error

A GError or NULL.

 

as_data_pool_clear ()

void
as_data_pool_clear (AsDataPool *dpool);

Remove all metadat from the pool.

Parameters

dpool

An AsDataPool.

 

as_data_pool_add_component ()

gboolean
as_data_pool_add_component (AsDataPool *dpool,
                            AsComponent *cpt,
                            GError **error);

Register a new component in the AppStream metadata pool.

Parameters

dpool

An instance of AsDataPool

 

cpt

The AsComponent to add to the pool.

 

error

A GError or NULL

 

Returns

TRUE if the new component was successfully added to the pool.


as_data_pool_get_components ()

GPtrArray *
as_data_pool_get_components (AsDataPool *dpool);

Get a list of found components.

Parameters

dpool

An instance of AsDataPool.

 

Returns

an array of AsComponent instances.

[element-type AsComponent][transfer full]


as_data_pool_get_component_by_id ()

AsComponent *
as_data_pool_get_component_by_id (AsDataPool *dpool,
                                  const gchar *id);

Get a specific component by its ID.

Parameters

dpool

An instance of AsDataPool.

 

id

The AppStream-ID to look for.

 

Returns

An AsComponent.

[transfer full]


as_data_pool_get_components_by_provided_item ()

GPtrArray *
as_data_pool_get_components_by_provided_item
                               (AsDataPool *dpool,
                                AsProvidedKind kind,
                                const gchar *item,
                                GError **error);

Find components in the AppStream data pool whcih provide a certain item.

Parameters

dpool

An instance of AsDataPool.

 

kind

An AsProvidesKind

 

item

The value of the provided item.

 

error

A GError or NULL.

 

Returns

an array of AsComponent objects which have been found.

[element-type AsComponent][transfer full]


as_data_pool_get_components_by_kind ()

GPtrArray *
as_data_pool_get_components_by_kind (AsDataPool *dpool,
                                     AsComponentKind kind,
                                     GError **error);

Return a list of all components in the pool which are of a certain kind.

Parameters

dpool

An instance of AsDatabase.

 

kind

An AsComponentKind.

 

error

A GError or NULL.

 

Returns

an array of AsComponent objects which have been found.

[element-type AsComponent][transfer full]


as_data_pool_get_components_by_categories ()

GPtrArray *
as_data_pool_get_components_by_categories
                               (AsDataPool *dpool,
                                const gchar *categories);

Return a list of components which are in one of the categories.

Parameters

dpool

An instance of AsDatabase.

 

categories

A semicolon-separated list of XDG categories to include.

 

Returns

an array of AsComponent objects which have been found.

[element-type AsComponent][transfer full]


as_data_pool_search ()

GPtrArray *
as_data_pool_search (AsDataPool *dpool,
                     const gchar *search);

Search for a list of components matching the search terms. The list will be unordered.

Parameters

dpool

An instance of AsDataPool

 

search

A search string

 

Returns

an array of the found AsComponent objects.

[element-type AsComponent][transfer full]

Since: 0.9.7


as_data_pool_get_metadata_locations ()

GPtrArray *
as_data_pool_get_metadata_locations (AsDataPool *dpool);

Return a list of all locations which are searched for metadata.

Parameters

dpool

An instance of AsDataPool.

 

Returns

A string-list of watched (absolute) filepaths.

[transfer none][element-type utf8]


as_data_pool_set_metadata_locations ()

void
as_data_pool_set_metadata_locations (AsDataPool *dpool,
                                     gchar **dirs);

Set locations for the data pool to read it's data from. This is mainly used for testing purposes. Each location should have an "xmls" and/or "yaml" subdirectory with the actual data as (compressed) AppStream XML or DEP-11 YAML in it.

Parameters

dpool

An instance of AsDataPool.

 

dirs

a zero-terminated array of data input directories.

[array zero-terminated=1]

as_data_pool_get_cache_flags ()

AsCacheFlags
as_data_pool_get_cache_flags (AsDataPool *dpool);

Get the AsCacheFlags for this data pool.

Parameters

dpool

An instance of AsDataPool.

 

as_data_pool_set_cache_flags ()

void
as_data_pool_set_cache_flags (AsDataPool *dpool,
                              AsCacheFlags flags);

Set the AsCacheFlags for this data pool.

Parameters

dpool

An instance of AsDataPool.

 

flags

The new AsCacheFlags.

 

as_data_pool_refresh_cache ()

gboolean
as_data_pool_refresh_cache (AsDataPool *dpool,
                            gboolean force,
                            GError **error);

Update the AppStream cache. There is normally no need to call this function manually, because cache updates are handled transparently in the background.

Parameters

dpool

An instance of AsDataPool.

 

force

Enforce refresh, even if source data has not changed.

 

Returns

TRUE if the cache was updated, FALSE on error or if the cache update was not necessary and has been skipped.


as_data_pool_get_cache_age ()

time_t
as_data_pool_get_cache_age (AsDataPool *dpool);

Get the age of our internal cache.

Parameters

dpool

An instance of AsDataPool.

 

as_data_pool_update ()

gboolean
as_data_pool_update (AsDataPool *dpool,
                     GError **error);

as_data_pool_update is deprecated and should not be used in newly-written code.

Types and Values

AS_TYPE_DATA_POOL

#define AS_TYPE_DATA_POOL (as_data_pool_get_type ())


struct AsDataPoolClass

struct AsDataPoolClass {
	GObjectClass parent_class;
};


enum AsCacheFlags

Flags on how caching should be used.

Members

AS_CACHE_FLAG_NONE

Type invalid or not known

 

AS_CACHE_FLAG_USE_USER

Create an user-specific metadata cache.

 

AS_CACHE_FLAG_USE_SYSTEM

Use and - if possible - update the global metadata cache.

 

enum AsDataPoolError

A metadata pool error.

Members

AS_DATA_POOL_ERROR_FAILED

Generic failure

 

AS_DATA_POOL_ERROR_TARGET_NOT_WRITABLE

We do not have write-access to the cache target location.

 

AS_DATA_POOL_ERROR_INCOMPLETE

The pool was loaded, but we had to ignore some metadata.

 

AS_DATA_POOL_ERROR_COLLISION

An AppStream-ID collision occured (a component with that ID already existed in the pool)

 

AS_DATA_POOL_ERROR_TERM_INVALID

A search or selection term was invalid.

 

AS_DATA_POOL_ERROR

#define AS_DATA_POOL_ERROR as_data_pool_error_quark ()


AsDataPool

typedef struct _AsDataPool AsDataPool;