From 87be89a7b8c389bb19b1f7f1866b138bbc25f2a7 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 26 Feb 2016 14:20:28 +0100 Subject: lib: Add xdg_app_bundle_ref_get_origin() --- lib/xdg-app-bundle-ref.c | 23 ++++++++++++++++++++++- lib/xdg-app-bundle-ref.h | 1 + 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/xdg-app-bundle-ref.c b/lib/xdg-app-bundle-ref.c index 5539db6..5a669fa 100644 --- a/lib/xdg-app-bundle-ref.c +++ b/lib/xdg-app-bundle-ref.c @@ -31,6 +31,7 @@ typedef struct _XdgAppBundleRefPrivate XdgAppBundleRefPrivate; struct _XdgAppBundleRefPrivate { GFile *file; + char *origin; GBytes *metadata; GBytes *appstream; GBytes *icon_64; @@ -58,6 +59,7 @@ xdg_app_bundle_ref_finalize (GObject *object) g_bytes_unref (priv->appstream); g_bytes_unref (priv->icon_64); g_bytes_unref (priv->icon_128); + g_free (priv->origin); G_OBJECT_CLASS (xdg_app_bundle_ref_parent_class)->finalize (object); } @@ -203,6 +205,22 @@ xdg_app_bundle_ref_get_icon (XdgAppBundleRef *self, return NULL; } +/** + * xdg_app_bundle_ref_get_origin: + * @self: a #XdgAppInstallation + * + * Get the origin url stored in the bundle + * + * Returns: (transfer full) : an url string, or %NULL + */ +char * +xdg_app_bundle_ref_get_origin (XdgAppBundleRef *self) +{ + XdgAppBundleRefPrivate *priv = xdg_app_bundle_ref_get_instance_private (self); + + return g_strdup (priv->origin); +} + guint64 xdg_app_bundle_ref_get_installed_size (XdgAppBundleRef *self) { @@ -223,13 +241,14 @@ xdg_app_bundle_ref_new (GFile *file, g_autoptr(GVariant) metadata = NULL; g_autofree char *commit = NULL; g_autofree char *full_ref = NULL; + g_autofree char *origin = NULL; g_autofree char *metadata_contents = NULL; g_autoptr(GVariant) appstream = NULL; g_autoptr(GVariant) icon_64 = NULL; g_autoptr(GVariant) icon_128 = NULL; guint64 installed_size; - metadata = xdg_app_bundle_load (file, &commit, &full_ref, NULL, &installed_size, + metadata = xdg_app_bundle_load (file, &commit, &full_ref, &origin, &installed_size, NULL, error); if (metadata == NULL) return NULL; @@ -273,5 +292,7 @@ xdg_app_bundle_ref_new (GFile *file, priv->installed_size = installed_size; + priv->origin = g_steal_pointer (&origin); + return ref; } diff --git a/lib/xdg-app-bundle-ref.h b/lib/xdg-app-bundle-ref.h index a74e026..9abf1be 100644 --- a/lib/xdg-app-bundle-ref.h +++ b/lib/xdg-app-bundle-ref.h @@ -51,6 +51,7 @@ XDG_APP_EXTERN GBytes *xdg_app_bundle_ref_get_metadata (XdgAppBundleR XDG_APP_EXTERN GBytes *xdg_app_bundle_ref_get_appstream (XdgAppBundleRef *self); XDG_APP_EXTERN GBytes *xdg_app_bundle_ref_get_icon (XdgAppBundleRef *self, int size); +XDG_APP_EXTERN char *xdg_app_bundle_ref_get_origin (XdgAppBundleRef *self); XDG_APP_EXTERN guint64 xdg_app_bundle_ref_get_installed_size (XdgAppBundleRef *self); -- cgit v1.2.1