GsUtils

GsUtils — Utilities that plugins can use

Stability Level

Unstable, unless otherwise indicated

Functions

Types and Values

Includes

#include <gnome-software.h>

Description

These functions provide useful functionality that makes it easy to add new plugin functions.

Functions

gs_utils_get_file_age ()

guint
gs_utils_get_file_age (GFile *file);

Gets a file age.

Parameters

file

A GFile

 

Returns

The time in seconds since the file was modified, or G_MAXUINT for error


gs_utils_get_content_type ()

gchar *
gs_utils_get_content_type (GFile *file,
                           GCancellable *cancellable,
                           GError **error);

Gets the standard content type for a file.

Parameters

file

A GFile

 

cancellable

A GCancellable, or NULL

 

error

A GError, or NULL

 

Returns

the content type, or NULL, e.g. "text/plain"


gs_mkdir_parent ()

gboolean
gs_mkdir_parent (const gchar *path,
                 GError **error);

Creates any required directories, including any parent directories.

Parameters

path

A full pathname

 

error

A GError, or NULL

 

Returns

TRUE for success


gs_utils_get_cache_filename ()

gchar *
gs_utils_get_cache_filename (const gchar *kind,
                             const gchar *basename,
                             GsUtilsCacheFlags flags,
                             GError **error);

Returns a filename that points into the cache. This may be per-system or per-user, the latter being more likely when GS_UTILS_CACHE_FLAG_WRITEABLE is specified in flags .

Parameters

kind

A cache kind, e.g. "firmware" or "screenshots/123x456"

 

basename

A filename basename, e.g. "system.bin"

 

flags

Some GsUtilsCacheFlags, e.g. GS_UTILS_CACHE_FLAG_WRITEABLE

 

error

A GError, or NULL

 

Returns

The full path and filename, which may or may not exist, or NULL


gs_utils_get_user_hash ()

gchar *
gs_utils_get_user_hash (GError **error);

This SHA1 hash is composed of the contents of machine-id and your usename and is also salted with a hardcoded value.

This provides an identifier that can be used to identify a specific user on a machine, allowing them to cast only one vote or perform one review on each application.

There is no known way to calculate the machine ID or username from the machine hash and there should be no privacy issue.

Parameters

error

A GError, or NULL

 

Returns

The user hash, or NULL on error


gs_utils_get_permission ()

GPermission *
gs_utils_get_permission (const gchar *id);

Gets a permission object for an ID.

Parameters

id

A PolicyKit ID, e.g. "org.gnome.Desktop"

 

Returns

a GPermission, or NULL if this if not possible.


gs_utils_strv_fnmatch ()

gboolean
gs_utils_strv_fnmatch (gchar **strv,
                       const gchar *str);

Matches a string against a list of globs.

Parameters

strv

A NUL-terminated list of strings

 

str

A string

 

Returns

TRUE if the list matches


gs_utils_get_desktop_app_info ()

GDesktopAppInfo *
gs_utils_get_desktop_app_info (const gchar *id);

Gets a a GDesktopAppInfo taking into account the kde4- prefix.

Parameters

id

A desktop ID, e.g. "gimp.desktop"

 

Returns

a GDesktopAppInfo for a specific ID, or NULL

Types and Values

enum GsUtilsCacheFlags

The cache flags.

Members

GS_UTILS_CACHE_FLAG_NONE

No flags set

 

GS_UTILS_CACHE_FLAG_WRITEABLE

A writable directory is required