Commit c5e6ae5d authored by Kalev Lember's avatar Kalev Lember

GsApp: Add get/set_origin_appstream for keeping track of appstream origin

This makes it possible to store package repo origin and appstream origin
separately. On a regular Fedora install, we have a single appstream
metadata file (/usr/share/app-info/xmls/fedora.xml.gz) that covers all
of Fedora repos, and doesn't have a 1:1 matching with the repo
names.
parent fa9e8e96
......@@ -88,6 +88,7 @@ typedef struct
GsAppQuality license_quality;
gchar **menu_path;
gchar *origin;
gchar *origin_appstream;
gchar *origin_hostname;
gchar *update_version;
gchar *update_version_ui;
......@@ -535,6 +536,8 @@ gs_app_to_string_append (GsApp *app, GString *str)
gs_app_kv_lpad (str, "branch", priv->branch);
if (priv->origin != NULL && priv->origin[0] != '\0')
gs_app_kv_lpad (str, "origin", priv->origin);
if (priv->origin_appstream != NULL && priv->origin_appstream[0] != '\0')
gs_app_kv_lpad (str, "origin-appstream", priv->origin_appstream);
if (priv->origin_hostname != NULL && priv->origin_hostname[0] != '\0')
gs_app_kv_lpad (str, "origin-hostname", priv->origin_hostname);
if (priv->rating != -1)
......@@ -2476,6 +2479,50 @@ gs_app_set_origin (GsApp *app, const gchar *origin)
priv->unique_id_valid = FALSE;
}
/**
* gs_app_get_origin_appstream:
* @app: a #GsApp
*
* Gets the appstream origin for the application, e.g. "fedora".
*
* Returns: a string, or %NULL for unset
*
* Since: 3.28
**/
const gchar *
gs_app_get_origin_appstream (GsApp *app)
{
GsAppPrivate *priv = gs_app_get_instance_private (app);
g_return_val_if_fail (GS_IS_APP (app), NULL);
return priv->origin_appstream;
}
/**
* gs_app_set_origin_appstream:
* @app: a #GsApp
* @origin_appstream: a string, or %NULL
*
* The appstream origin is the appstream source of the application e.g. "fedora"
*
* Since: 3.28
**/
void
gs_app_set_origin_appstream (GsApp *app, const gchar *origin_appstream)
{
GsAppPrivate *priv = gs_app_get_instance_private (app);
g_autoptr(GMutexLocker) locker = NULL;
g_return_if_fail (GS_IS_APP (app));
locker = g_mutex_locker_new (&priv->mutex);
/* same */
if (g_strcmp0 (origin_appstream, priv->origin_appstream) == 0)
return;
g_free (priv->origin_appstream);
priv->origin_appstream = g_strdup (origin_appstream);
}
/**
* gs_app_get_origin_hostname:
* @app: a #GsApp
......@@ -4154,6 +4201,7 @@ gs_app_finalize (GObject *object)
g_free (priv->license);
g_strfreev (priv->menu_path);
g_free (priv->origin);
g_free (priv->origin_appstream);
g_free (priv->origin_hostname);
g_ptr_array_unref (priv->sources);
g_ptr_array_unref (priv->source_ids);
......
......@@ -202,6 +202,9 @@ void gs_app_set_menu_path (GsApp *app,
const gchar *gs_app_get_origin (GsApp *app);
void gs_app_set_origin (GsApp *app,
const gchar *origin);
const gchar *gs_app_get_origin_appstream (GsApp *app);
void gs_app_set_origin_appstream (GsApp *app,
const gchar *origin_appstream);
const gchar *gs_app_get_origin_hostname (GsApp *app);
void gs_app_set_origin_hostname (GsApp *app,
const gchar *origin_hostname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment