From 1ffdf27d927c7944e3bce9b1cd3c101d823fd826 Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Fri, 6 May 2016 16:03:27 +0200 Subject: uncruftify: Initial run, all non-problematic changes --- lib/test-lib.c | 169 +++++++++++---------- lib/xdg-app-bundle-ref.c | 35 ++--- lib/xdg-app-bundle-ref.h | 30 ++-- lib/xdg-app-error.c | 2 +- lib/xdg-app-error.h | 4 +- lib/xdg-app-installation.c | 285 +++++++++++++++++++----------------- lib/xdg-app-installation.h | 272 +++++++++++++++++----------------- lib/xdg-app-installed-ref-private.h | 16 +- lib/xdg-app-installed-ref.c | 57 ++++---- lib/xdg-app-installed-ref.h | 30 ++-- lib/xdg-app-ref.c | 34 +++-- lib/xdg-app-ref.h | 28 ++-- lib/xdg-app-remote-private.h | 5 +- lib/xdg-app-remote-ref-private.h | 2 +- lib/xdg-app-remote-ref.c | 17 ++- lib/xdg-app-remote-ref.h | 12 +- lib/xdg-app-remote.c | 24 +-- lib/xdg-app-remote.h | 26 ++-- 18 files changed, 545 insertions(+), 503 deletions(-) (limited to 'lib') diff --git a/lib/test-lib.c b/lib/test-lib.c index df641df..2526764 100644 --- a/lib/test-lib.c +++ b/lib/test-lib.c @@ -8,17 +8,17 @@ static void progress_cb (const char *status, - guint progress, - gboolean estimating, - gpointer user_data) + guint progress, + gboolean estimating, + gpointer user_data) { g_print ("status: %s, progress: %d estimating: %d, user_data: %p\n", status, progress, estimating, user_data); } static gboolean -monitor_callback (GFileMonitor* monitor, - GFile* child, - GFile* other_file, +monitor_callback (GFileMonitor * monitor, + GFile * child, + GFile * other_file, GFileMonitorEvent eflags) { g_print ("Database changed\n"); @@ -32,6 +32,7 @@ main (int argc, char *argv[]) XdgAppInstalledRef *app1; XdgAppInstalledRef *app2; XdgAppRemoteRef *remote_ref; + g_autoptr(GPtrArray) remotes = NULL; GError *error = NULL; int i, j; @@ -48,7 +49,7 @@ main (int argc, char *argv[]) GFileMonitor * monitor = xdg_app_installation_create_monitor (installation, NULL, NULL); GMainLoop *main_loop; - g_signal_connect (monitor, "changed", (GCallback)monitor_callback, NULL); + g_signal_connect (monitor, "changed", (GCallback) monitor_callback, NULL); main_loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (main_loop); } @@ -60,7 +61,7 @@ main (int argc, char *argv[]) XDG_APP_REF_KIND_APP, argv[2], NULL, NULL, - progress_cb, (gpointer)0xdeadbeef, + progress_cb, (gpointer) 0xdeadbeef, NULL, &error); if (app1 == NULL) g_print ("Error: %s\n", error->message); @@ -78,7 +79,7 @@ main (int argc, char *argv[]) XDG_APP_REF_KIND_APP, argv[1], NULL, NULL, - progress_cb, (gpointer)0xdeadbeef, + progress_cb, (gpointer) 0xdeadbeef, NULL, &error); if (app1 == NULL) g_print ("Error: %s\n", error->message); @@ -103,15 +104,15 @@ main (int argc, char *argv[]) g_autofree char *path = g_file_get_path (xdg_app_bundle_ref_get_file (bundle)); g_autoptr(GBytes) metadata = xdg_app_bundle_ref_get_metadata (bundle); g_autoptr(GBytes) appdata = xdg_app_bundle_ref_get_appstream (bundle); - g_print ("%d %s %s %s %s %s %"G_GUINT64_FORMAT"\n%s\n", - xdg_app_ref_get_kind (XDG_APP_REF(bundle)), - xdg_app_ref_get_name (XDG_APP_REF(bundle)), - xdg_app_ref_get_arch (XDG_APP_REF(bundle)), - xdg_app_ref_get_branch (XDG_APP_REF(bundle)), - xdg_app_ref_get_commit (XDG_APP_REF(bundle)), + g_print ("%d %s %s %s %s %s %"G_GUINT64_FORMAT "\n%s\n", + xdg_app_ref_get_kind (XDG_APP_REF (bundle)), + xdg_app_ref_get_name (XDG_APP_REF (bundle)), + xdg_app_ref_get_arch (XDG_APP_REF (bundle)), + xdg_app_ref_get_branch (XDG_APP_REF (bundle)), + xdg_app_ref_get_commit (XDG_APP_REF (bundle)), path, xdg_app_bundle_ref_get_installed_size (bundle), - (char *)g_bytes_get_data (metadata, NULL)); + (char *) g_bytes_get_data (metadata, NULL)); if (appdata != NULL) { @@ -150,13 +151,13 @@ main (int argc, char *argv[]) { for (i = 0; i < updates->len; i++) { - XdgAppInstalledRef *ref = g_ptr_array_index(updates,i); - g_print ("%d %s %s %s %s %s %s %s %d %"G_GUINT64_FORMAT"\n", - xdg_app_ref_get_kind (XDG_APP_REF(ref)), - xdg_app_ref_get_name (XDG_APP_REF(ref)), - xdg_app_ref_get_arch (XDG_APP_REF(ref)), - xdg_app_ref_get_branch (XDG_APP_REF(ref)), - xdg_app_ref_get_commit (XDG_APP_REF(ref)), + XdgAppInstalledRef *ref = g_ptr_array_index (updates, i); + g_print ("%d %s %s %s %s %s %s %s %d %"G_GUINT64_FORMAT "\n", + xdg_app_ref_get_kind (XDG_APP_REF (ref)), + xdg_app_ref_get_name (XDG_APP_REF (ref)), + xdg_app_ref_get_arch (XDG_APP_REF (ref)), + xdg_app_ref_get_branch (XDG_APP_REF (ref)), + xdg_app_ref_get_commit (XDG_APP_REF (ref)), xdg_app_installed_ref_get_latest_commit (ref), xdg_app_installed_ref_get_origin (ref), xdg_app_installed_ref_get_deploy_dir (ref), @@ -175,13 +176,13 @@ main (int argc, char *argv[]) for (i = 0; i < refs->len; i++) { - XdgAppInstalledRef *ref = g_ptr_array_index(refs,i); - g_print ("%d %s %s %s %s %s %s %s %d %"G_GUINT64_FORMAT"\n", - xdg_app_ref_get_kind (XDG_APP_REF(ref)), - xdg_app_ref_get_name (XDG_APP_REF(ref)), - xdg_app_ref_get_arch (XDG_APP_REF(ref)), - xdg_app_ref_get_branch (XDG_APP_REF(ref)), - xdg_app_ref_get_commit (XDG_APP_REF(ref)), + XdgAppInstalledRef *ref = g_ptr_array_index (refs, i); + g_print ("%d %s %s %s %s %s %s %s %d %"G_GUINT64_FORMAT "\n", + xdg_app_ref_get_kind (XDG_APP_REF (ref)), + xdg_app_ref_get_name (XDG_APP_REF (ref)), + xdg_app_ref_get_arch (XDG_APP_REF (ref)), + xdg_app_ref_get_branch (XDG_APP_REF (ref)), + xdg_app_ref_get_commit (XDG_APP_REF (ref)), xdg_app_installed_ref_get_latest_commit (ref), xdg_app_installed_ref_get_origin (ref), xdg_app_installed_ref_get_deploy_dir (ref), @@ -200,20 +201,20 @@ main (int argc, char *argv[]) for (i = 0; i < apps->len; i++) { - XdgAppInstalledRef *app = g_ptr_array_index(apps,i); - - g_print ("%d %s %s %s %s %s %s %s %d %"G_GUINT64_FORMAT"\n", - xdg_app_ref_get_kind (XDG_APP_REF(app)), - xdg_app_ref_get_name (XDG_APP_REF(app)), - xdg_app_ref_get_arch (XDG_APP_REF(app)), - xdg_app_ref_get_branch (XDG_APP_REF(app)), - xdg_app_ref_get_commit (XDG_APP_REF(app)), + XdgAppInstalledRef *app = g_ptr_array_index (apps, i); + + g_print ("%d %s %s %s %s %s %s %s %d %"G_GUINT64_FORMAT "\n", + xdg_app_ref_get_kind (XDG_APP_REF (app)), + xdg_app_ref_get_name (XDG_APP_REF (app)), + xdg_app_ref_get_arch (XDG_APP_REF (app)), + xdg_app_ref_get_branch (XDG_APP_REF (app)), + xdg_app_ref_get_commit (XDG_APP_REF (app)), xdg_app_installed_ref_get_latest_commit (app), xdg_app_installed_ref_get_origin (app), xdg_app_installed_ref_get_deploy_dir (app), xdg_app_installed_ref_get_is_current (app), xdg_app_installed_ref_get_installed_size (app)); - g_print ("metadata:\n%s\n", (char *)g_bytes_get_data (xdg_app_installed_ref_load_metadata (app, NULL, NULL), NULL)); + g_print ("metadata:\n%s\n", (char *) g_bytes_get_data (xdg_app_installed_ref_load_metadata (app, NULL, NULL), NULL)); } } @@ -227,13 +228,13 @@ main (int argc, char *argv[]) for (i = 0; i < runtimes->len; i++) { - XdgAppInstalledRef *runtime = g_ptr_array_index(runtimes,i); + XdgAppInstalledRef *runtime = g_ptr_array_index (runtimes, i); g_print ("%d %s %s %s %s %s %s %d\n", - xdg_app_ref_get_kind (XDG_APP_REF(runtime)), - xdg_app_ref_get_name (XDG_APP_REF(runtime)), - xdg_app_ref_get_arch (XDG_APP_REF(runtime)), - xdg_app_ref_get_branch (XDG_APP_REF(runtime)), - xdg_app_ref_get_commit (XDG_APP_REF(runtime)), + xdg_app_ref_get_kind (XDG_APP_REF (runtime)), + xdg_app_ref_get_name (XDG_APP_REF (runtime)), + xdg_app_ref_get_arch (XDG_APP_REF (runtime)), + xdg_app_ref_get_branch (XDG_APP_REF (runtime)), + xdg_app_ref_get_commit (XDG_APP_REF (runtime)), xdg_app_installed_ref_get_origin (runtime), xdg_app_installed_ref_get_deploy_dir (runtime), xdg_app_installed_ref_get_is_current (runtime)); @@ -248,11 +249,11 @@ main (int argc, char *argv[]) if (app1) { g_print ("gedit master: %d %s %s %s %s %s %s %d\n", - xdg_app_ref_get_kind (XDG_APP_REF(app1)), - xdg_app_ref_get_name (XDG_APP_REF(app1)), - xdg_app_ref_get_arch (XDG_APP_REF(app1)), - xdg_app_ref_get_branch (XDG_APP_REF(app1)), - xdg_app_ref_get_commit (XDG_APP_REF(app1)), + xdg_app_ref_get_kind (XDG_APP_REF (app1)), + xdg_app_ref_get_name (XDG_APP_REF (app1)), + xdg_app_ref_get_arch (XDG_APP_REF (app1)), + xdg_app_ref_get_branch (XDG_APP_REF (app1)), + xdg_app_ref_get_commit (XDG_APP_REF (app1)), xdg_app_installed_ref_get_origin (app1), xdg_app_installed_ref_get_deploy_dir (app1), xdg_app_installed_ref_get_is_current (app1)); @@ -271,15 +272,17 @@ main (int argc, char *argv[]) "org.gnome.gedit", NULL, NULL); if (app2) - g_print ("gedit current: %d %s %s %s %s %s %s %d\n", - xdg_app_ref_get_kind (XDG_APP_REF(app2)), - xdg_app_ref_get_name (XDG_APP_REF(app2)), - xdg_app_ref_get_arch (XDG_APP_REF(app2)), - xdg_app_ref_get_branch (XDG_APP_REF(app2)), - xdg_app_ref_get_commit (XDG_APP_REF(app2)), - xdg_app_installed_ref_get_origin (app2), - xdg_app_installed_ref_get_deploy_dir (app2), - xdg_app_installed_ref_get_is_current (app2)); + { + g_print ("gedit current: %d %s %s %s %s %s %s %d\n", + xdg_app_ref_get_kind (XDG_APP_REF (app2)), + xdg_app_ref_get_name (XDG_APP_REF (app2)), + xdg_app_ref_get_arch (XDG_APP_REF (app2)), + xdg_app_ref_get_branch (XDG_APP_REF (app2)), + xdg_app_ref_get_commit (XDG_APP_REF (app2)), + xdg_app_installed_ref_get_origin (app2), + xdg_app_installed_ref_get_deploy_dir (app2), + xdg_app_installed_ref_get_is_current (app2)); + } g_print ("\n**** Listing remotes\n"); @@ -288,7 +291,7 @@ main (int argc, char *argv[]) for (i = 0; i < remotes->len; i++) { - XdgAppRemote *remote = g_ptr_array_index(remotes, i); + XdgAppRemote *remote = g_ptr_array_index (remotes, i); g_autoptr(GPtrArray) refs = NULL; g_print ("\nRemote: %s %d %s %s %d %d %s\n", xdg_app_remote_get_name (remote), @@ -306,13 +309,13 @@ main (int argc, char *argv[]) { for (j = 0; j < refs->len; j++) { - XdgAppRemoteRef *ref = g_ptr_array_index(refs,j); + XdgAppRemoteRef *ref = g_ptr_array_index (refs, j); g_print ("%d %s %s %s %s %s\n", - xdg_app_ref_get_kind (XDG_APP_REF(ref)), - xdg_app_ref_get_name (XDG_APP_REF(ref)), - xdg_app_ref_get_arch (XDG_APP_REF(ref)), - xdg_app_ref_get_branch (XDG_APP_REF(ref)), - xdg_app_ref_get_commit (XDG_APP_REF(ref)), + xdg_app_ref_get_kind (XDG_APP_REF (ref)), + xdg_app_ref_get_name (XDG_APP_REF (ref)), + xdg_app_ref_get_arch (XDG_APP_REF (ref)), + xdg_app_ref_get_branch (XDG_APP_REF (ref)), + xdg_app_ref_get_commit (XDG_APP_REF (ref)), xdg_app_remote_ref_get_remote_name (ref)); if (j == 0) @@ -321,7 +324,7 @@ main (int argc, char *argv[]) guint64 installed_size; if (!xdg_app_installation_fetch_remote_size_sync (installation, xdg_app_remote_get_name (remote), - xdg_app_ref_get_commit (XDG_APP_REF(ref)), + xdg_app_ref_get_commit (XDG_APP_REF (ref)), &download_size, &installed_size, NULL, &error)) @@ -330,12 +333,14 @@ main (int argc, char *argv[]) g_clear_error (&error); } else - g_print ("Download size: %"G_GUINT64_FORMAT" Installed size: %"G_GUINT64_FORMAT"\n", - download_size, installed_size); + { + g_print ("Download size: %"G_GUINT64_FORMAT " Installed size: %"G_GUINT64_FORMAT "\n", + download_size, installed_size); + } if (!xdg_app_installation_fetch_remote_size_sync2 (installation, xdg_app_remote_get_name (remote), - XDG_APP_REF(ref), + XDG_APP_REF (ref), &download_size, &installed_size, NULL, &error)) @@ -344,8 +349,10 @@ main (int argc, char *argv[]) g_clear_error (&error); } else - g_print ("Download size2: %"G_GUINT64_FORMAT" Installed size2: %"G_GUINT64_FORMAT"\n", - download_size, installed_size); + { + g_print ("Download size2: %"G_GUINT64_FORMAT " Installed size2: %"G_GUINT64_FORMAT "\n", + download_size, installed_size); + } } } @@ -363,18 +370,18 @@ main (int argc, char *argv[]) GBytes *metadata2; g_print ("%d %s %s %s %s %s\n", - xdg_app_ref_get_kind (XDG_APP_REF(remote_ref)), - xdg_app_ref_get_name (XDG_APP_REF(remote_ref)), - xdg_app_ref_get_arch (XDG_APP_REF(remote_ref)), - xdg_app_ref_get_branch (XDG_APP_REF(remote_ref)), - xdg_app_ref_get_commit (XDG_APP_REF(remote_ref)), + xdg_app_ref_get_kind (XDG_APP_REF (remote_ref)), + xdg_app_ref_get_name (XDG_APP_REF (remote_ref)), + xdg_app_ref_get_arch (XDG_APP_REF (remote_ref)), + xdg_app_ref_get_branch (XDG_APP_REF (remote_ref)), + xdg_app_ref_get_commit (XDG_APP_REF (remote_ref)), xdg_app_remote_ref_get_remote_name (remote_ref)); metadata = xdg_app_installation_fetch_remote_metadata_sync (installation, xdg_app_remote_get_name (remote), - xdg_app_ref_get_commit (XDG_APP_REF(remote_ref)), NULL, &error); + xdg_app_ref_get_commit (XDG_APP_REF (remote_ref)), NULL, &error); if (metadata) { - g_print ("metadata: %s\n", (char *)g_bytes_get_data (metadata, NULL)); + g_print ("metadata: %s\n", (char *) g_bytes_get_data (metadata, NULL)); } else { @@ -384,10 +391,10 @@ main (int argc, char *argv[]) } metadata2 = xdg_app_installation_fetch_remote_metadata_sync2 (installation, xdg_app_remote_get_name (remote), - XDG_APP_REF(remote_ref), NULL, &error); + XDG_APP_REF (remote_ref), NULL, &error); if (metadata2) { - g_print ("metadata2: %s\n", (char *)g_bytes_get_data (metadata2, NULL)); + g_print ("metadata2: %s\n", (char *) g_bytes_get_data (metadata2, NULL)); } else { diff --git a/lib/xdg-app-bundle-ref.c b/lib/xdg-app-bundle-ref.c index 5a669fa..512eab9 100644 --- a/lib/xdg-app-bundle-ref.c +++ b/lib/xdg-app-bundle-ref.c @@ -30,8 +30,8 @@ typedef struct _XdgAppBundleRefPrivate XdgAppBundleRefPrivate; struct _XdgAppBundleRefPrivate { - GFile *file; - char *origin; + GFile *file; + char *origin; GBytes *metadata; GBytes *appstream; GBytes *icon_64; @@ -65,10 +65,10 @@ xdg_app_bundle_ref_finalize (GObject *object) } static void -xdg_app_bundle_ref_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +xdg_app_bundle_ref_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XdgAppBundleRef *self = XDG_APP_BUNDLE_REF (object); XdgAppBundleRefPrivate *priv = xdg_app_bundle_ref_get_instance_private (self); @@ -86,10 +86,10 @@ xdg_app_bundle_ref_set_property (GObject *object, } static void -xdg_app_bundle_ref_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +xdg_app_bundle_ref_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XdgAppBundleRef *self = XDG_APP_BUNDLE_REF (object); XdgAppBundleRefPrivate *priv = xdg_app_bundle_ref_get_instance_private (self); @@ -154,7 +154,7 @@ xdg_app_bundle_ref_get_file (XdgAppBundleRef *self) * Returns: (transfer full) : an #GBytes with the metadata contents, or %NULL */ GBytes * -xdg_app_bundle_ref_get_metadata (XdgAppBundleRef *self) +xdg_app_bundle_ref_get_metadata (XdgAppBundleRef *self) { XdgAppBundleRefPrivate *priv = xdg_app_bundle_ref_get_instance_private (self); @@ -172,7 +172,7 @@ xdg_app_bundle_ref_get_metadata (XdgAppBundleRef *self) * Returns: (transfer full) : an #GBytes with the appstream contents, or %NULL */ GBytes * -xdg_app_bundle_ref_get_appstream (XdgAppBundleRef *self) +xdg_app_bundle_ref_get_appstream (XdgAppBundleRef *self) { XdgAppBundleRefPrivate *priv = xdg_app_bundle_ref_get_instance_private (self); @@ -191,8 +191,8 @@ xdg_app_bundle_ref_get_appstream (XdgAppBundleRef *self) * Returns: (transfer full) : an #GBytes with png contents */ GBytes * -xdg_app_bundle_ref_get_icon (XdgAppBundleRef *self, - int size) +xdg_app_bundle_ref_get_icon (XdgAppBundleRef *self, + int size) { XdgAppBundleRefPrivate *priv = xdg_app_bundle_ref_get_instance_private (self); @@ -214,7 +214,7 @@ xdg_app_bundle_ref_get_icon (XdgAppBundleRef *self, * Returns: (transfer full) : an url string, or %NULL */ char * -xdg_app_bundle_ref_get_origin (XdgAppBundleRef *self) +xdg_app_bundle_ref_get_origin (XdgAppBundleRef *self) { XdgAppBundleRefPrivate *priv = xdg_app_bundle_ref_get_instance_private (self); @@ -222,7 +222,7 @@ xdg_app_bundle_ref_get_origin (XdgAppBundleRef *self) } guint64 -xdg_app_bundle_ref_get_installed_size (XdgAppBundleRef *self) +xdg_app_bundle_ref_get_installed_size (XdgAppBundleRef *self) { XdgAppBundleRefPrivate *priv = xdg_app_bundle_ref_get_instance_private (self); @@ -231,11 +231,12 @@ xdg_app_bundle_ref_get_installed_size (XdgAppBundleRef *self) XdgAppBundleRef * -xdg_app_bundle_ref_new (GFile *file, +xdg_app_bundle_ref_new (GFile *file, GError **error) { XdgAppRefKind kind = XDG_APP_REF_KIND_APP; XdgAppBundleRefPrivate *priv; + g_auto(GStrv) parts = NULL; XdgAppBundleRef *ref; g_autoptr(GVariant) metadata = NULL; diff --git a/lib/xdg-app-bundle-ref.h b/lib/xdg-app-bundle-ref.h index 9abf1be..33bddc4 100644 --- a/lib/xdg-app-bundle-ref.h +++ b/lib/xdg-app-bundle-ref.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif @@ -30,33 +30,35 @@ typedef struct _XdgAppBundleRef XdgAppBundleRef; #include #include -#define XDG_APP_TYPE_BUNDLE_REF xdg_app_bundle_ref_get_type() +#define XDG_APP_TYPE_BUNDLE_REF xdg_app_bundle_ref_get_type () #define XDG_APP_BUNDLE_REF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_BUNDLE_REF, XdgAppBundleRef)) #define XDG_APP_IS_BUNDLE_REF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XDG_APP_TYPE_BUNDLE_REF)) XDG_APP_EXTERN GType xdg_app_bundle_ref_get_type (void); -struct _XdgAppBundleRef { +struct _XdgAppBundleRef +{ XdgAppRef parent; }; -typedef struct { +typedef struct +{ XdgAppRefClass parent_class; } XdgAppBundleRefClass; -XDG_APP_EXTERN XdgAppBundleRef *xdg_app_bundle_ref_new (GFile *file, - GError **error); -XDG_APP_EXTERN GFile *xdg_app_bundle_ref_get_file (XdgAppBundleRef *self); -XDG_APP_EXTERN GBytes *xdg_app_bundle_ref_get_metadata (XdgAppBundleRef *self); -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); +XDG_APP_EXTERN XdgAppBundleRef *xdg_app_bundle_ref_new (GFile *file, + GError **error); +XDG_APP_EXTERN GFile *xdg_app_bundle_ref_get_file (XdgAppBundleRef *self); +XDG_APP_EXTERN GBytes *xdg_app_bundle_ref_get_metadata (XdgAppBundleRef *self); +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); #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC -G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppBundleRef, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (XdgAppBundleRef, g_object_unref) #endif #endif /* __XDG_APP_BUNDLE_REF_H__ */ diff --git a/lib/xdg-app-error.c b/lib/xdg-app-error.c index 37a2d63..e74c8a1 100644 --- a/lib/xdg-app-error.c +++ b/lib/xdg-app-error.c @@ -31,4 +31,4 @@ * */ -G_DEFINE_QUARK (xdg-app-error-quark, xdg_app_error) +G_DEFINE_QUARK (xdg - app - error - quark, xdg_app_error) diff --git a/lib/xdg-app-error.h b/lib/xdg-app-error.h index b83385c..149ef97 100644 --- a/lib/xdg-app-error.h +++ b/lib/xdg-app-error.h @@ -38,9 +38,9 @@ typedef enum { XDG_APP_ERROR_NOT_INSTALLED, } XdgAppError; -#define XDG_APP_ERROR xdg_app_error_quark() +#define XDG_APP_ERROR xdg_app_error_quark () -XDG_APP_EXTERN GQuark xdg_app_error_quark (void); +XDG_APP_EXTERN GQuark xdg_app_error_quark (void); G_END_DECLS diff --git a/lib/xdg-app-installation.c b/lib/xdg-app-installation.c index 4566677..9f0a7da 100644 --- a/lib/xdg-app-installation.c +++ b/lib/xdg-app-installation.c @@ -75,10 +75,10 @@ xdg_app_installation_finalize (GObject *object) } static void -xdg_app_installation_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +xdg_app_installation_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { switch (prop_id) @@ -90,10 +90,10 @@ xdg_app_installation_set_property (GObject *object, } static void -xdg_app_installation_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +xdg_app_installation_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { switch (prop_id) @@ -121,9 +121,9 @@ xdg_app_installation_init (XdgAppInstallation *self) } static XdgAppInstallation * -xdg_app_installation_new_for_dir (XdgAppDir *dir, - GCancellable *cancellable, - GError **error) +xdg_app_installation_new_for_dir (XdgAppDir *dir, + GCancellable *cancellable, + GError **error) { XdgAppInstallation *self; XdgAppInstallationPrivate *priv; @@ -166,7 +166,7 @@ xdg_app_get_default_arch (void) */ XdgAppInstallation * xdg_app_installation_new_system (GCancellable *cancellable, - GError **error) + GError **error) { return xdg_app_installation_new_for_dir (xdg_app_dir_get_system (), cancellable, error); } @@ -182,7 +182,7 @@ xdg_app_installation_new_system (GCancellable *cancellable, */ XdgAppInstallation * xdg_app_installation_new_user (GCancellable *cancellable, - GError **error) + GError **error) { return xdg_app_installation_new_for_dir (xdg_app_dir_get_user (), cancellable, error); } @@ -257,16 +257,17 @@ xdg_app_installation_get_path (XdgAppInstallation *self) * Returns: %TRUE, unless an error occurred */ gboolean -xdg_app_installation_launch (XdgAppInstallation *self, - const char *name, - const char *arch, - const char *branch, - const char *commit, - GCancellable *cancellable, - GError **error) +xdg_app_installation_launch (XdgAppInstallation *self, + const char *name, + const char *arch, + const char *branch, + const char *commit, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_autofree char *app_ref = NULL; + g_autoptr(XdgAppDeploy) app_deploy = NULL; app_ref = @@ -292,10 +293,11 @@ xdg_app_installation_launch (XdgAppInstallation *self, static XdgAppInstalledRef * get_ref (XdgAppInstallation *self, - const char *full_ref, - GCancellable *cancellable) + const char *full_ref, + GCancellable *cancellable) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_auto(GStrv) parts = NULL; const char *origin = NULL; const char *commit = NULL; @@ -356,14 +358,15 @@ get_ref (XdgAppInstallation *self, */ XdgAppInstalledRef * xdg_app_installation_get_installed_ref (XdgAppInstallation *self, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, - GCancellable *cancellable, - GError **error) + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_autoptr(GFile) deploy = NULL; g_autofree char *ref = NULL; @@ -403,11 +406,12 @@ xdg_app_installation_get_installed_ref (XdgAppInstallation *self, */ XdgAppInstalledRef * xdg_app_installation_get_current_installed_app (XdgAppInstallation *self, - const char *name, - GCancellable *cancellable, - GError **error) + const char *name, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_autoptr(GFile) deploy = NULL; g_autofree char *current = xdg_app_dir_current_ref (priv->dir, name, cancellable); @@ -439,10 +443,11 @@ xdg_app_installation_get_current_installed_app (XdgAppInstallation *self, */ GPtrArray * xdg_app_installation_list_installed_refs (XdgAppInstallation *self, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_auto(GStrv) raw_refs_app = NULL; g_auto(GStrv) raw_refs_runtime = NULL; g_autoptr(GPtrArray) refs = g_ptr_array_new_with_free_func (g_object_unref); @@ -467,7 +472,7 @@ xdg_app_installation_list_installed_refs (XdgAppInstallation *self, for (i = 0; raw_refs_runtime[i] != NULL; i++) g_ptr_array_add (refs, get_ref (self, raw_refs_runtime[i], cancellable)); - + return g_steal_pointer (&refs); } @@ -485,18 +490,19 @@ xdg_app_installation_list_installed_refs (XdgAppInstallation *self, */ GPtrArray * xdg_app_installation_list_installed_refs_by_kind (XdgAppInstallation *self, - XdgAppRefKind kind, - GCancellable *cancellable, - GError **error) + XdgAppRefKind kind, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_auto(GStrv) raw_refs = NULL; g_autoptr(GPtrArray) refs = g_ptr_array_new_with_free_func (g_object_unref); int i; if (!xdg_app_dir_list_refs (priv->dir, kind == XDG_APP_REF_KIND_APP ? "app" : "runtime", -&raw_refs, + &raw_refs, cancellable, error)) return NULL; @@ -523,8 +529,8 @@ xdg_app_installation_list_installed_refs_by_kind (XdgAppInstallation *self, */ GPtrArray * xdg_app_installation_list_installed_refs_for_update (XdgAppInstallation *self, - GCancellable *cancellable, - GError **error) + GCancellable *cancellable, + GError **error) { g_autoptr(GPtrArray) updates = NULL; g_autoptr(GPtrArray) installed = NULL; @@ -605,11 +611,12 @@ xdg_app_installation_list_installed_refs_for_update (XdgAppInstallation *self, * #XdgAppRemote instances */ GPtrArray * -xdg_app_installation_list_remotes (XdgAppInstallation *self, - GCancellable *cancellable, - GError **error) +xdg_app_installation_list_remotes (XdgAppInstallation *self, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_auto(GStrv) remote_names = NULL; g_autoptr(GPtrArray) remotes = g_ptr_array_new_with_free_func (g_object_unref); int i; @@ -638,11 +645,12 @@ xdg_app_installation_list_remotes (XdgAppInstallation *self, */ XdgAppRemote * xdg_app_installation_get_remote_by_name (XdgAppInstallation *self, - const gchar *name, - GCancellable *cancellable, - GError **error) + const gchar *name, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_auto(GStrv) remote_names = NULL; int i; @@ -674,10 +682,10 @@ xdg_app_installation_get_remote_by_name (XdgAppInstallation *self, * or %NULL if an error occurred */ char * -xdg_app_installation_load_app_overrides (XdgAppInstallation *self, - const char *app_id, - GCancellable *cancellable, - GError **error) +xdg_app_installation_load_app_overrides (XdgAppInstallation *self, + const char *app_id, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_autofree char *metadata_contents = NULL; @@ -694,7 +702,7 @@ static void progress_cb (OstreeAsyncProgress *progress, gpointer user_data) { XdgAppProgressCallback progress_cb = g_object_get_data (G_OBJECT (progress), "callback"); - guint last_progress = GPOINTER_TO_UINT(g_object_get_data (G_OBJECT (progress), "last_progress")); + guint last_progress = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (progress), "last_progress")); GString *buf; g_autofree char *status = NULL; guint outstanding_fetches; @@ -742,9 +750,7 @@ progress_cb (OstreeAsyncProgress *progress, gpointer user_data) if (!bytes_sec) // Ignore first second formatted_bytes_sec = g_strdup ("-"); else - { - formatted_bytes_sec = g_format_size (bytes_sec); - } + formatted_bytes_sec = g_format_size (bytes_sec); if (total_delta_parts > 0) { @@ -773,7 +779,7 @@ progress_cb (OstreeAsyncProgress *progress, gpointer user_data) { new_progress = (100 * fetched) / requested; g_string_append_printf (buf, "Receiving objects: %u%% (%u/%u) %s/s %s", - (guint)((((double)fetched) / requested) * 100), + (guint) ((((double) fetched) / requested) * 100), fetched, requested, formatted_bytes_sec, formatted_bytes_transferred); } } @@ -788,7 +794,7 @@ progress_cb (OstreeAsyncProgress *progress, gpointer user_data) if (new_progress < last_progress) new_progress = last_progress; - g_object_set_data (G_OBJECT (progress), "last_progress", GUINT_TO_POINTER(new_progress)); + g_object_set_data (G_OBJECT (progress), "last_progress", GUINT_TO_POINTER (new_progress)); progress_cb (buf->str, new_progress, estimating, user_data); @@ -810,16 +816,17 @@ progress_cb (OstreeAsyncProgress *progress, gpointer user_data) * Returns: (transfer full): The ref for the newly installed app or %NULL on failure */ XdgAppInstalledRef * -xdg_app_installation_install_bundle (XdgAppInstallation *self, - GFile *file, - XdgAppProgressCallback progress, - gpointer progress_data, - GCancellable *cancellable, - GError **error) +xdg_app_installation_install_bundle (XdgAppInstallation *self, + GFile *file, + XdgAppProgressCallback progress, + gpointer progress_data, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_autofree char *ref = NULL; gboolean added_remote = FALSE; + g_autoptr(GFile) deploy_base = NULL; g_autoptr(XdgAppDir) dir_clone = NULL; XdgAppInstalledRef *result = NULL; @@ -891,7 +898,7 @@ xdg_app_installation_install_bundle (XdgAppInstallation *self, result = get_ref (self, ref, cancellable); - out: +out: if (added_remote && result == NULL) ostree_repo_remote_delete (xdg_app_dir_get_repo (priv->dir), remote, NULL, NULL); @@ -917,19 +924,20 @@ xdg_app_installation_install_bundle (XdgAppInstallation *self, * Returns: (transfer full): The ref for the newly installed app or %NULL on failure */ XdgAppInstalledRef * -xdg_app_installation_install (XdgAppInstallation *self, - const char *remote_name, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, +xdg_app_installation_install (XdgAppInstallation *self, + const char *remote_name, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, XdgAppProgressCallback progress, - gpointer progress_data, - GCancellable *cancellable, - GError **error) + gpointer progress_data, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_autofree char *ref = NULL; + g_autoptr(GFile) deploy_base = NULL; g_autoptr(XdgAppDir) dir_clone = NULL; g_autoptr(GMainContext) main_context = NULL; @@ -962,7 +970,7 @@ xdg_app_installation_install (XdgAppInstallation *self, { ostree_progress = ostree_async_progress_new_and_connect (progress_cb, progress_data); g_object_set_data (G_OBJECT (ostree_progress), "callback", progress); - g_object_set_data (G_OBJECT (ostree_progress), "last_progress", GUINT_TO_POINTER(0)); + g_object_set_data (G_OBJECT (ostree_progress), "last_progress", GUINT_TO_POINTER (0)); } if (!xdg_app_dir_install (dir_clone, FALSE, FALSE, ref, remote_name, NULL, @@ -971,7 +979,7 @@ xdg_app_installation_install (XdgAppInstallation *self, result = get_ref (self, ref, cancellable); - out: +out: if (main_context) g_main_context_pop_thread_default (main_context); @@ -999,19 +1007,20 @@ xdg_app_installation_install (XdgAppInstallation *self, * Returns: (transfer full): The ref for the newly updated app (or the same if no update) or %NULL on failure */ XdgAppInstalledRef * -xdg_app_installation_update (XdgAppInstallation *self, - XdgAppUpdateFlags flags, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, +xdg_app_installation_update (XdgAppInstallation *self, + XdgAppUpdateFlags flags, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, XdgAppProgressCallback progress, - gpointer progress_data, - GCancellable *cancellable, - GError **error) + gpointer progress_data, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_autofree char *ref = NULL; + g_autoptr(GFile) deploy_base = NULL; g_autoptr(XdgAppDir) dir_clone = NULL; g_autoptr(GMainContext) main_context = NULL; @@ -1052,7 +1061,7 @@ xdg_app_installation_update (XdgAppInstallation *self, { ostree_progress = ostree_async_progress_new_and_connect (progress_cb, progress_data); g_object_set_data (G_OBJECT (ostree_progress), "callback", progress); - g_object_set_data (G_OBJECT (ostree_progress), "last_progress", GUINT_TO_POINTER(0)); + g_object_set_data (G_OBJECT (ostree_progress), "last_progress", GUINT_TO_POINTER (0)); } if (!xdg_app_dir_update (dir_clone, @@ -1064,7 +1073,7 @@ xdg_app_installation_update (XdgAppInstallation *self, result = get_ref (self, ref, cancellable); - out: +out: if (main_context) g_main_context_pop_thread_default (main_context); @@ -1091,20 +1100,21 @@ xdg_app_installation_update (XdgAppInstallation *self, * Returns: %TRUE on success */ XDG_APP_EXTERN gboolean -xdg_app_installation_uninstall (XdgAppInstallation *self, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, - XdgAppProgressCallback progress, - gpointer progress_data, - GCancellable *cancellable, - GError **error) +xdg_app_installation_uninstall (XdgAppInstallation *self, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, + XdgAppProgressCallback progress, + gpointer progress_data, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_autofree char *ref = NULL; g_autofree char *remote_name = NULL; g_autofree char *current_ref = NULL; + g_autoptr(GFile) deploy_base = NULL; g_autoptr(XdgAppDir) dir_clone = NULL; gboolean was_deployed = FALSE; @@ -1201,13 +1211,13 @@ xdg_app_installation_uninstall (XdgAppInstallation *self, * Returns: %TRUE, unless an error occurred */ gboolean -xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self, - const char *remote_name, - const char *commit, - guint64 *download_size, - guint64 *installed_size, - GCancellable *cancellable, - GError **error) +xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self, + const char *remote_name, + const char *commit, + guint64 *download_size, + guint64 *installed_size, + GCancellable *cancellable, + GError **error) { return xdg_app_fail (error, "Deprecated function call xdg_app_installation_fetch_remote_size_sync"); } @@ -1233,13 +1243,13 @@ xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self, * Returns: %TRUE, unless an error occurred */ gboolean -xdg_app_installation_fetch_remote_size_sync2 (XdgAppInstallation *self, - const char *remote_name, - XdgAppRef *ref, - guint64 *download_size, - guint64 *installed_size, - GCancellable *cancellable, - GError **error) +xdg_app_installation_fetch_remote_size_sync2 (XdgAppInstallation *self, + const char *remote_name, + XdgAppRef *ref, + guint64 *download_size, + guint64 *installed_size, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_autofree char *full_ref = xdg_app_ref_format_ref (ref); @@ -1268,12 +1278,13 @@ xdg_app_installation_fetch_remote_size_sync2 (XdgAppInstallation *self, */ GBytes * xdg_app_installation_fetch_remote_metadata_sync (XdgAppInstallation *self, - const char *remote_name, - const char *commit, - GCancellable *cancellable, - GError **error) + const char *remote_name, + const char *commit, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_autoptr(GBytes) bytes = NULL; bytes = xdg_app_dir_fetch_metadata (priv->dir, @@ -1302,10 +1313,10 @@ xdg_app_installation_fetch_remote_metadata_sync (XdgAppInstallation *self, */ GBytes * xdg_app_installation_fetch_remote_metadata_sync2 (XdgAppInstallation *self, - const char *remote_name, - XdgAppRef *ref, - GCancellable *cancellable, - GError **error) + const char *remote_name, + XdgAppRef *ref, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); g_autofree char *full_ref = xdg_app_ref_format_ref (ref); @@ -1334,11 +1345,12 @@ xdg_app_installation_fetch_remote_metadata_sync2 (XdgAppInstallation *self, */ GPtrArray * xdg_app_installation_list_remote_refs_sync (XdgAppInstallation *self, - const char *remote_name, - GCancellable *cancellable, - GError **error) + const char *remote_name, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_autoptr(GPtrArray) refs = g_ptr_array_new_with_free_func (g_object_unref); g_autoptr(GHashTable) ht = NULL; GHashTableIter iter; @@ -1385,15 +1397,16 @@ xdg_app_installation_list_remote_refs_sync (XdgAppInstallation *self, */ XdgAppRemoteRef * xdg_app_installation_fetch_remote_ref_sync (XdgAppInstallation *self, - const char *remote_name, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, - GCancellable *cancellable, - GError **error) + const char *remote_name, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_autoptr(GHashTable) ht = NULL; g_autofree char *ref = NULL; const char *checksum; @@ -1446,14 +1459,15 @@ no_progress_cb (OstreeAsyncProgress *progress, gpointer user_data) * Returns: %TRUE on success, or %FALSE on error */ gboolean -xdg_app_installation_update_appstream_sync (XdgAppInstallation *self, - const char *remote_name, - const char *arch, - gboolean *out_changed, - GCancellable *cancellable, - GError **error) +xdg_app_installation_update_appstream_sync (XdgAppInstallation *self, + const char *remote_name, + const char *arch, + gboolean *out_changed, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_autoptr(XdgAppDir) dir_clone = NULL; g_autoptr(OstreeAsyncProgress) ostree_progress = NULL; g_autoptr(GMainContext) main_context = NULL; @@ -1500,11 +1514,12 @@ xdg_app_installation_update_appstream_sync (XdgAppInstallation *self, * Returns: (transfer full): a new #GFileMonitor instance, or %NULL on error */ GFileMonitor * -xdg_app_installation_create_monitor (XdgAppInstallation *self, - GCancellable *cancellable, - GError **error) +xdg_app_installation_create_monitor (XdgAppInstallation *self, + GCancellable *cancellable, + GError **error) { XdgAppInstallationPrivate *priv = xdg_app_installation_get_instance_private (self); + g_autoptr(GFile) path = NULL; path = xdg_app_dir_get_changed_path (priv->dir); diff --git a/lib/xdg-app-installation.h b/lib/xdg-app-installation.h index 8a1595f..7a8bea5 100644 --- a/lib/xdg-app-installation.h +++ b/lib/xdg-app-installation.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif @@ -31,17 +31,19 @@ typedef struct _XdgAppInstallation XdgAppInstallation; #include #include -#define XDG_APP_TYPE_INSTALLATION xdg_app_installation_get_type() +#define XDG_APP_TYPE_INSTALLATION xdg_app_installation_get_type () #define XDG_APP_INSTALLATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_INSTALLATION, XdgAppInstallation)) #define XDG_APP_IS_INSTALLATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XDG_APP_TYPE_INSTALLATION)) XDG_APP_EXTERN GType xdg_app_installation_get_type (void); -struct _XdgAppInstallation { +struct _XdgAppInstallation +{ GObject parent; }; -typedef struct { +typedef struct +{ GObjectClass parent_class; } XdgAppInstallationClass; @@ -55,25 +57,25 @@ typedef struct { */ typedef enum { XDG_APP_UPDATE_FLAGS_NONE = 0, - XDG_APP_UPDATE_FLAGS_NO_DEPLOY = (1<<0), - XDG_APP_UPDATE_FLAGS_NO_PULL = (1<<1), + XDG_APP_UPDATE_FLAGS_NO_DEPLOY = (1 << 0), + XDG_APP_UPDATE_FLAGS_NO_PULL = (1 << 1), } XdgAppUpdateFlags; #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC -G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppInstallation, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (XdgAppInstallation, g_object_unref) #endif XDG_APP_EXTERN const char *xdg_app_get_default_arch (void); XDG_APP_EXTERN XdgAppInstallation *xdg_app_installation_new_system (GCancellable *cancellable, - GError **error); + GError **error); XDG_APP_EXTERN XdgAppInstallation *xdg_app_installation_new_user (GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN XdgAppInstallation *xdg_app_installation_new_for_path (GFile *path, - gboolean user, + GError **error); +XDG_APP_EXTERN XdgAppInstallation *xdg_app_installation_new_for_path (GFile *path, + gboolean user, GCancellable *cancellable, - GError **error); + GError **error); /** * XdgAppProgressCallback: @@ -89,131 +91,131 @@ XDG_APP_EXTERN XdgAppInstallation *xdg_app_installation_new_for_path (GFile *pat * The callback occurs in the thread-default context of the caller. */ typedef void (*XdgAppProgressCallback)(const char *status, - guint progress, - gboolean estimating, - gpointer user_data); - -XDG_APP_EXTERN gboolean xdg_app_installation_get_is_user (XdgAppInstallation *self); -XDG_APP_EXTERN GFile *xdg_app_installation_get_path (XdgAppInstallation *self); -XDG_APP_EXTERN gboolean xdg_app_installation_launch (XdgAppInstallation *self, - const char *name, - const char *arch, - const char *branch, - const char *commit, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN GFileMonitor *xdg_app_installation_create_monitor (XdgAppInstallation *self, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs (XdgAppInstallation *self, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs_by_kind (XdgAppInstallation *self, - XdgAppRefKind kind, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs_for_update (XdgAppInstallation *self, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_get_installed_ref (XdgAppInstallation *self, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_get_current_installed_app (XdgAppInstallation *self, - const char *name, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_remotes (XdgAppInstallation *self, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN XdgAppRemote *xdg_app_installation_get_remote_by_name (XdgAppInstallation *self, - const gchar *name, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN char * xdg_app_installation_load_app_overrides (XdgAppInstallation *self, - const char *app_id, + guint progress, + gboolean estimating, + gpointer user_data); + +XDG_APP_EXTERN gboolean xdg_app_installation_get_is_user (XdgAppInstallation *self); +XDG_APP_EXTERN GFile *xdg_app_installation_get_path (XdgAppInstallation *self); +XDG_APP_EXTERN gboolean xdg_app_installation_launch (XdgAppInstallation *self, + const char *name, + const char *arch, + const char *branch, + const char *commit, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN GFileMonitor *xdg_app_installation_create_monitor (XdgAppInstallation *self, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs (XdgAppInstallation *self, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs_by_kind (XdgAppInstallation *self, + XdgAppRefKind kind, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_installed_refs_for_update (XdgAppInstallation *self, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_get_installed_ref (XdgAppInstallation *self, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_get_current_installed_app (XdgAppInstallation *self, + const char *name, GCancellable *cancellable, GError **error); -XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_install (XdgAppInstallation *self, - const char *remote_name, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, - XdgAppProgressCallback progress, - gpointer progress_data, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_update (XdgAppInstallation *self, - XdgAppUpdateFlags flags, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, - XdgAppProgressCallback progress, - gpointer progress_data, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_install_bundle (XdgAppInstallation *self, - GFile *file, - XdgAppProgressCallback progress, - gpointer progress_data, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN gboolean xdg_app_installation_uninstall (XdgAppInstallation *self, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, - XdgAppProgressCallback progress, - gpointer progress_data, - GCancellable *cancellable, - GError **error); - -XDG_APP_EXTERN gboolean xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self, - const char *remote_name, - const char *commit, - guint64 *download_size, - guint64 *installed_size, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN gboolean xdg_app_installation_fetch_remote_size_sync2 (XdgAppInstallation *self, - const char *remote_name, - XdgAppRef *ref, - guint64 *download_size, - guint64 *installed_size, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN GBytes * xdg_app_installation_fetch_remote_metadata_sync (XdgAppInstallation *self, - const char *remote_name, - const char *commit, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN GBytes * xdg_app_installation_fetch_remote_metadata_sync2 (XdgAppInstallation *self, - const char *remote_name, +XDG_APP_EXTERN GPtrArray *xdg_app_installation_list_remotes (XdgAppInstallation *self, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN XdgAppRemote *xdg_app_installation_get_remote_by_name (XdgAppInstallation *self, + const gchar *name, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN char * xdg_app_installation_load_app_overrides (XdgAppInstallation *self, + const char *app_id, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_install (XdgAppInstallation *self, + const char *remote_name, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, + XdgAppProgressCallback progress, + gpointer progress_data, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_update (XdgAppInstallation *self, + XdgAppUpdateFlags flags, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, + XdgAppProgressCallback progress, + gpointer progress_data, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN XdgAppInstalledRef * xdg_app_installation_install_bundle (XdgAppInstallation *self, + GFile *file, + XdgAppProgressCallback progress, + gpointer progress_data, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN gboolean xdg_app_installation_uninstall (XdgAppInstallation *self, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, + XdgAppProgressCallback progress, + gpointer progress_data, + GCancellable *cancellable, + GError **error); + +XDG_APP_EXTERN gboolean xdg_app_installation_fetch_remote_size_sync (XdgAppInstallation *self, + const char *remote_name, + const char *commit, + guint64 *download_size, + guint64 *installed_size, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN gboolean xdg_app_installation_fetch_remote_size_sync2 (XdgAppInstallation *self, + const char *remote_name, + XdgAppRef *ref, + guint64 *download_size, + guint64 *installed_size, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN GBytes * xdg_app_installation_fetch_remote_metadata_sync (XdgAppInstallation *self, + const char *remote_name, + const char *commit, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN GBytes * xdg_app_installation_fetch_remote_metadata_sync2 (XdgAppInstallation *self, + const char *remote_name, XdgAppRef *ref, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN GPtrArray * xdg_app_installation_list_remote_refs_sync (XdgAppInstallation *self, - const char *remote_name, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN XdgAppRemoteRef *xdg_app_installation_fetch_remote_ref_sync (XdgAppInstallation *self, - const char *remote_name, - XdgAppRefKind kind, - const char *name, - const char *arch, - const char *branch, - GCancellable *cancellable, - GError **error); -XDG_APP_EXTERN gboolean xdg_app_installation_update_appstream_sync (XdgAppInstallation *self, - const char *remote_name, - const char *arch, - gboolean *out_changed, - GCancellable *cancellable, - GError **error); + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN GPtrArray * xdg_app_installation_list_remote_refs_sync (XdgAppInstallation *self, + const char *remote_name, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN XdgAppRemoteRef *xdg_app_installation_fetch_remote_ref_sync (XdgAppInstallation *self, + const char *remote_name, + XdgAppRefKind kind, + const char *name, + const char *arch, + const char *branch, + GCancellable *cancellable, + GError **error); +XDG_APP_EXTERN gboolean xdg_app_installation_update_appstream_sync (XdgAppInstallation *self, + const char *remote_name, + const char *arch, + gboolean *out_changed, + GCancellable *cancellable, + GError **error); #endif /* __XDG_APP_INSTALLATION_H__ */ diff --git a/lib/xdg-app-installed-ref-private.h b/lib/xdg-app-installed-ref-private.h index fb07746..af39531 100644 --- a/lib/xdg-app-installed-ref-private.h +++ b/lib/xdg-app-installed-ref-private.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif @@ -28,13 +28,13 @@ #include #include -XdgAppInstalledRef *xdg_app_installed_ref_new (const char *full_ref, - const char *commit, - const char *latest_commit, - const char *origin, +XdgAppInstalledRef *xdg_app_installed_ref_new (const char *full_ref, + const char *commit, + const char *latest_commit, + const char *origin, const char **subpaths, - const char *deploy_dir, - guint64 installed_size, - gboolean current); + const char *deploy_dir, + guint64 installed_size, + gboolean current); #endif /* __XDG_APP_INSTALLED_REF_PRIVATE_H__ */ diff --git a/lib/xdg-app-installed-ref.c b/lib/xdg-app-installed-ref.c index f77e1b1..e6f543d 100644 --- a/lib/xdg-app-installed-ref.c +++ b/lib/xdg-app-installed-ref.c @@ -41,11 +41,11 @@ typedef struct _XdgAppInstalledRefPrivate XdgAppInstalledRefPrivate; struct _XdgAppInstalledRefPrivate { gboolean is_current; - char *origin; - char *latest_commit; - char *deploy_dir; - char **subpaths; - guint64 installed_size; + char *origin; + char *latest_commit; + char *deploy_dir; + char **subpaths; + guint64 installed_size; }; G_DEFINE_TYPE_WITH_PRIVATE (XdgAppInstalledRef, xdg_app_installed_ref, XDG_APP_TYPE_REF) @@ -75,10 +75,10 @@ xdg_app_installed_ref_finalize (GObject *object) } static void -xdg_app_installed_ref_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +xdg_app_installed_ref_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XdgAppInstalledRef *self = XDG_APP_INSTALLED_REF (object); XdgAppInstalledRefPrivate *priv = xdg_app_installed_ref_get_instance_private (self); @@ -120,10 +120,10 @@ xdg_app_installed_ref_set_property (GObject *object, } static void -xdg_app_installed_ref_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +xdg_app_installed_ref_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XdgAppInstalledRef *self = XDG_APP_INSTALLED_REF (object); XdgAppInstalledRefPrivate *priv = xdg_app_installed_ref_get_instance_private (self); @@ -179,10 +179,10 @@ xdg_app_installed_ref_class_init (XdgAppInstalledRefClass *klass) g_object_class_install_property (object_class, PROP_INSTALLED_SIZE, g_param_spec_uint64 ("installed-size", - "Installed Size", - "The installed size of the application", + "Installed Size", + "The installed size of the application", 0, G_MAXUINT64, 0, - G_PARAM_READWRITE)); + G_PARAM_READWRITE)); g_object_class_install_property (object_class, PROP_ORIGIN, g_param_spec_string ("origin", @@ -290,7 +290,7 @@ xdg_app_installed_ref_get_is_current (XdgAppInstalledRef *self) * * Returns: (transfer none): A strv, or %NULL */ -const char * const* +const char * const * xdg_app_installed_ref_get_subpaths (XdgAppInstalledRef *self) { XdgAppInstalledRefPrivate *priv = xdg_app_installed_ref_get_instance_private (self); @@ -326,9 +326,9 @@ xdg_app_installed_ref_get_installed_size (XdgAppInstalledRef *self) * or %NULL if an error occurred */ GBytes * -xdg_app_installed_ref_load_metadata (XdgAppInstalledRef *self, - GCancellable *cancellable, - GError **error) +xdg_app_installed_ref_load_metadata (XdgAppInstalledRef *self, + GCancellable *cancellable, + GError **error) { XdgAppInstalledRefPrivate *priv = xdg_app_installed_ref_get_instance_private (self); g_autofree char *path = NULL; @@ -350,17 +350,18 @@ xdg_app_installed_ref_load_metadata (XdgAppInstalledRef *self, } XdgAppInstalledRef * -xdg_app_installed_ref_new (const char *full_ref, - const char *commit, - const char *latest_commit, - const char *origin, - const char**subpaths, - const char *deploy_dir, - guint64 installed_size, - gboolean is_current) +xdg_app_installed_ref_new (const char *full_ref, + const char *commit, + const char *latest_commit, + const char *origin, + const char **subpaths, + const char *deploy_dir, + guint64 installed_size, + gboolean is_current) { XdgAppRefKind kind = XDG_APP_REF_KIND_APP; XdgAppInstalledRef *ref; + g_auto(GStrv) parts = NULL; parts = g_strsplit (full_ref, "/", -1); diff --git a/lib/xdg-app-installed-ref.h b/lib/xdg-app-installed-ref.h index db3524d..f29c434 100644 --- a/lib/xdg-app-installed-ref.h +++ b/lib/xdg-app-installed-ref.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif @@ -30,32 +30,34 @@ typedef struct _XdgAppInstalledRef XdgAppInstalledRef; #include #include -#define XDG_APP_TYPE_INSTALLED_REF xdg_app_installed_ref_get_type() +#define XDG_APP_TYPE_INSTALLED_REF xdg_app_installed_ref_get_type () #define XDG_APP_INSTALLED_REF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_INSTALLED_REF, XdgAppInstalledRef)) #define XDG_APP_IS_INSTALLED_REF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XDG_APP_TYPE_INSTALLED_REF)) XDG_APP_EXTERN GType xdg_app_installed_ref_get_type (void); -struct _XdgAppInstalledRef { +struct _XdgAppInstalledRef +{ XdgAppRef parent; }; -typedef struct { +typedef struct +{ XdgAppRefClass parent_class; } XdgAppInstalledRefClass; #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC -G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppInstalledRef, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (XdgAppInstalledRef, g_object_unref) #endif -XDG_APP_EXTERN const char *xdg_app_installed_ref_get_origin (XdgAppInstalledRef *self); -XDG_APP_EXTERN const char * const*xdg_app_installed_ref_get_subpaths (XdgAppInstalledRef *self); -XDG_APP_EXTERN guint64 xdg_app_installed_ref_get_installed_size (XdgAppInstalledRef *self); -XDG_APP_EXTERN const char *xdg_app_installed_ref_get_deploy_dir (XdgAppInstalledRef *self); -XDG_APP_EXTERN const char *xdg_app_installed_ref_get_latest_commit (XdgAppInstalledRef *self); -XDG_APP_EXTERN gboolean xdg_app_installed_ref_get_is_current (XdgAppInstalledRef *self); -XDG_APP_EXTERN GBytes *xdg_app_installed_ref_load_metadata (XdgAppInstalledRef *self, - GCancellable *cancellable, - GError **error); +XDG_APP_EXTERN const char *xdg_app_installed_ref_get_origin (XdgAppInstalledRef * self); +XDG_APP_EXTERN const char * const *xdg_app_installed_ref_get_subpaths (XdgAppInstalledRef *self); +XDG_APP_EXTERN guint64 xdg_app_installed_ref_get_installed_size (XdgAppInstalledRef *self); +XDG_APP_EXTERN const char *xdg_app_installed_ref_get_deploy_dir (XdgAppInstalledRef *self); +XDG_APP_EXTERN const char *xdg_app_installed_ref_get_latest_commit (XdgAppInstalledRef *self); +XDG_APP_EXTERN gboolean xdg_app_installed_ref_get_is_current (XdgAppInstalledRef *self); +XDG_APP_EXTERN GBytes *xdg_app_installed_ref_load_metadata (XdgAppInstalledRef *self, + GCancellable *cancellable, + GError **error); #endif /* __XDG_APP_INSTALLED_REF_H__ */ diff --git a/lib/xdg-app-ref.c b/lib/xdg-app-ref.c index f0c0d76..b450a5c 100644 --- a/lib/xdg-app-ref.c +++ b/lib/xdg-app-ref.c @@ -49,10 +49,10 @@ typedef struct _XdgAppRefPrivate XdgAppRefPrivate; struct _XdgAppRefPrivate { - char *name; - char *arch; - char *branch; - char *commit; + char *name; + char *arch; + char *branch; + char *commit; XdgAppRefKind kind; }; @@ -83,10 +83,10 @@ xdg_app_ref_finalize (GObject *object) } static void -xdg_app_ref_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +xdg_app_ref_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XdgAppRef *self = XDG_APP_REF (object); XdgAppRefPrivate *priv = xdg_app_ref_get_instance_private (self); @@ -124,10 +124,10 @@ xdg_app_ref_set_property (GObject *object, } static void -xdg_app_ref_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +xdg_app_ref_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XdgAppRef *self = XDG_APP_REF (object); XdgAppRefPrivate *priv = xdg_app_ref_get_instance_private (self); @@ -305,7 +305,7 @@ xdg_app_ref_get_kind (XdgAppRef *self) * Returns: (transfer full): string representation */ char * -xdg_app_ref_format_ref (XdgAppRef *self) +xdg_app_ref_format_ref (XdgAppRef *self) { XdgAppRefPrivate *priv = xdg_app_ref_get_instance_private (self); @@ -340,9 +340,13 @@ xdg_app_ref_parse (const char *ref, GError **error) XdgAppRefKind kind; if (g_strcmp0 (parts[0], "app") == 0) - kind = XDG_APP_REF_KIND_APP; + { + kind = XDG_APP_REF_KIND_APP; + } else if (g_strcmp0 (parts[0], "runtime") == 0) - kind = XDG_APP_REF_KIND_RUNTIME; + { + kind = XDG_APP_REF_KIND_RUNTIME; + } else { g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, diff --git a/lib/xdg-app-ref.h b/lib/xdg-app-ref.h index 7c060c1..9952f83 100644 --- a/lib/xdg-app-ref.h +++ b/lib/xdg-app-ref.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif @@ -29,23 +29,25 @@ typedef struct _XdgAppRef XdgAppRef; #include -#define XDG_APP_TYPE_REF xdg_app_ref_get_type() +#define XDG_APP_TYPE_REF xdg_app_ref_get_type () #define XDG_APP_REF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_REF, XdgAppRef)) #define XDG_APP_IS_REF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XDG_APP_TYPE_REF)) XDG_APP_EXTERN GType xdg_app_ref_get_type (void); -struct _XdgAppRef { +struct _XdgAppRef +{ GObject parent; }; -typedef struct { +typedef struct +{ GObjectClass parent_class; } XdgAppRefClass; #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC -G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppRef, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (XdgAppRef, g_object_unref) #endif /** @@ -60,13 +62,13 @@ typedef enum { XDG_APP_REF_KIND_RUNTIME, } XdgAppRefKind; -XDG_APP_EXTERN const char * xdg_app_ref_get_name (XdgAppRef *self); -XDG_APP_EXTERN const char * xdg_app_ref_get_arch (XdgAppRef *self); -XDG_APP_EXTERN const char * xdg_app_ref_get_branch (XdgAppRef *self); -XDG_APP_EXTERN const char * xdg_app_ref_get_commit (XdgAppRef *self); -XDG_APP_EXTERN XdgAppRefKind xdg_app_ref_get_kind (XdgAppRef *self); -XDG_APP_EXTERN char * xdg_app_ref_format_ref (XdgAppRef *self); -XDG_APP_EXTERN XdgAppRef * xdg_app_ref_parse (const char *ref, - GError **error); +XDG_APP_EXTERN const char * xdg_app_ref_get_name (XdgAppRef *self); +XDG_APP_EXTERN const char * xdg_app_ref_get_arch (XdgAppRef *self); +XDG_APP_EXTERN const char * xdg_app_ref_get_branch (XdgAppRef *self); +XDG_APP_EXTERN const char * xdg_app_ref_get_commit (XdgAppRef *self); +XDG_APP_EXTERN XdgAppRefKind xdg_app_ref_get_kind (XdgAppRef *self); +XDG_APP_EXTERN char * xdg_app_ref_format_ref (XdgAppRef *self); +XDG_APP_EXTERN XdgAppRef * xdg_app_ref_parse (const char *ref, + GError **error); #endif /* __XDG_APP_REF_H__ */ diff --git a/lib/xdg-app-remote-private.h b/lib/xdg-app-remote-private.h index fc3700f..5cf2368 100644 --- a/lib/xdg-app-remote-private.h +++ b/lib/xdg-app-remote-private.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif @@ -29,6 +29,7 @@ #include #include -XdgAppRemote *xdg_app_remote_new (XdgAppDir *dir, const char *name); +XdgAppRemote *xdg_app_remote_new (XdgAppDir *dir, + const char *name); #endif /* __XDG_APP_REMOTE_PRIVATE_H__ */ diff --git a/lib/xdg-app-remote-ref-private.h b/lib/xdg-app-remote-ref-private.h index 9ad1242..668fc1c 100644 --- a/lib/xdg-app-remote-ref-private.h +++ b/lib/xdg-app-remote-ref-private.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif diff --git a/lib/xdg-app-remote-ref.c b/lib/xdg-app-remote-ref.c index 6b397db..abed09c 100644 --- a/lib/xdg-app-remote-ref.c +++ b/lib/xdg-app-remote-ref.c @@ -62,10 +62,10 @@ xdg_app_remote_ref_finalize (GObject *object) } static void -xdg_app_remote_ref_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +xdg_app_remote_ref_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XdgAppRemoteRef *self = XDG_APP_REMOTE_REF (object); XdgAppRemoteRefPrivate *priv = xdg_app_remote_ref_get_instance_private (self); @@ -84,10 +84,10 @@ xdg_app_remote_ref_set_property (GObject *object, } static void -xdg_app_remote_ref_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +xdg_app_remote_ref_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XdgAppRemoteRef *self = XDG_APP_REMOTE_REF (object); XdgAppRemoteRefPrivate *priv = xdg_app_remote_ref_get_instance_private (self); @@ -150,6 +150,7 @@ xdg_app_remote_ref_new (const char *full_ref, const char *remote_name) { XdgAppRefKind kind = XDG_APP_REF_KIND_APP; + g_auto(GStrv) parts = NULL; XdgAppRemoteRef *ref; diff --git a/lib/xdg-app-remote-ref.h b/lib/xdg-app-remote-ref.h index 0198fc0..25c5a83 100644 --- a/lib/xdg-app-remote-ref.h +++ b/lib/xdg-app-remote-ref.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif @@ -30,24 +30,26 @@ typedef struct _XdgAppRemoteRef XdgAppRemoteRef; #include #include -#define XDG_APP_TYPE_REMOTE_REF xdg_app_remote_ref_get_type() +#define XDG_APP_TYPE_REMOTE_REF xdg_app_remote_ref_get_type () #define XDG_APP_REMOTE_REF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_REMOTE_REF, XdgAppRemoteRef)) #define XDG_APP_IS_REMOTE_REF(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XDG_APP_TYPE_REMOTE_REF)) XDG_APP_EXTERN GType xdg_app_remote_ref_get_type (void); -struct _XdgAppRemoteRef { +struct _XdgAppRemoteRef +{ XdgAppRef parent; }; -typedef struct { +typedef struct +{ XdgAppRefClass parent_class; } XdgAppRemoteRefClass; XDG_APP_EXTERN const char * xdg_app_remote_ref_get_remote_name (XdgAppRemoteRef *self); #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC -G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppRemoteRef, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (XdgAppRemoteRef, g_object_unref) #endif #endif /* __XDG_APP_REMOTE_REF_H__ */ diff --git a/lib/xdg-app-remote.c b/lib/xdg-app-remote.c index 164bf40..a852643 100644 --- a/lib/xdg-app-remote.c +++ b/lib/xdg-app-remote.c @@ -50,7 +50,7 @@ typedef struct _XdgAppRemotePrivate XdgAppRemotePrivate; struct _XdgAppRemotePrivate { - char *name; + char *name; XdgAppDir *dir; }; @@ -75,10 +75,10 @@ xdg_app_remote_finalize (GObject *object) } static void -xdg_app_remote_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) +xdg_app_remote_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) { XdgAppRemote *self = XDG_APP_REMOTE (object); XdgAppRemotePrivate *priv = xdg_app_remote_get_instance_private (self); @@ -97,10 +97,10 @@ xdg_app_remote_set_property (GObject *object, } static void -xdg_app_remote_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) +xdg_app_remote_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) { XdgAppRemote *self = XDG_APP_REMOTE (object); XdgAppRemotePrivate *priv = xdg_app_remote_get_instance_private (self); @@ -168,7 +168,7 @@ xdg_app_remote_get_name (XdgAppRemote *self) **/ GFile * xdg_app_remote_get_appstream_dir (XdgAppRemote *self, - const char *arch) + const char *arch) { XdgAppRemotePrivate *priv = xdg_app_remote_get_instance_private (self); g_autofree char *subdir = NULL; @@ -193,7 +193,7 @@ xdg_app_remote_get_appstream_dir (XdgAppRemote *self, **/ GFile * xdg_app_remote_get_appstream_timestamp (XdgAppRemote *self, - const char *arch) + const char *arch) { XdgAppRemotePrivate *priv = xdg_app_remote_get_instance_private (self); g_autofree char *subdir = NULL; @@ -313,7 +313,7 @@ xdg_app_remote_get_gpg_verify (XdgAppRemote *self) } XdgAppRemote * -xdg_app_remote_new (XdgAppDir *dir, +xdg_app_remote_new (XdgAppDir *dir, const char *name) { XdgAppRemotePrivate *priv; diff --git a/lib/xdg-app-remote.h b/lib/xdg-app-remote.h index 2040767..31154da 100644 --- a/lib/xdg-app-remote.h +++ b/lib/xdg-app-remote.h @@ -18,7 +18,7 @@ * Alexander Larsson */ -#if !defined (__XDG_APP_H_INSIDE__) && !defined (XDG_APP_COMPILATION) +#if !defined(__XDG_APP_H_INSIDE__) && !defined(XDG_APP_COMPILATION) #error "Only can be included directly." #endif @@ -30,34 +30,36 @@ typedef struct _XdgAppRemote XdgAppRemote; #include #include -#define XDG_APP_TYPE_REMOTE xdg_app_remote_get_type() +#define XDG_APP_TYPE_REMOTE xdg_app_remote_get_type () #define XDG_APP_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XDG_APP_TYPE_REMOTE, XdgAppRemote)) #define XDG_APP_IS_REMOTE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XDG_APP_TYPE_REMOTE)) XDG_APP_EXTERN GType xdg_app_remote_get_type (void); -struct _XdgAppRemote { +struct _XdgAppRemote +{ GObject parent; }; -typedef struct { +typedef struct +{ GObjectClass parent_class; } XdgAppRemoteClass; #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC -G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppRemote, g_object_unref) +G_DEFINE_AUTOPTR_CLEANUP_FUNC (XdgAppRemote, g_object_unref) #endif -XDG_APP_EXTERN const char * xdg_app_remote_get_name (XdgAppRemote *self); +XDG_APP_EXTERN const char * xdg_app_remote_get_name (XdgAppRemote * self); XDG_APP_EXTERN GFile * xdg_app_remote_get_appstream_dir (XdgAppRemote *self, const char *arch); XDG_APP_EXTERN GFile * xdg_app_remote_get_appstream_timestamp (XdgAppRemote *self, const char *arch); -XDG_APP_EXTERN char * xdg_app_remote_get_url (XdgAppRemote *self); -XDG_APP_EXTERN char * xdg_app_remote_get_title (XdgAppRemote *self); -XDG_APP_EXTERN gboolean xdg_app_remote_get_gpg_verify (XdgAppRemote *self); -XDG_APP_EXTERN gboolean xdg_app_remote_get_noenumerate (XdgAppRemote *self); -XDG_APP_EXTERN gboolean xdg_app_remote_get_disabled (XdgAppRemote *self); -XDG_APP_EXTERN int xdg_app_remote_get_prio (XdgAppRemote *self); +XDG_APP_EXTERN char * xdg_app_remote_get_url (XdgAppRemote *self); +XDG_APP_EXTERN char * xdg_app_remote_get_title (XdgAppRemote *self); +XDG_APP_EXTERN gboolean xdg_app_remote_get_gpg_verify (XdgAppRemote *self); +XDG_APP_EXTERN gboolean xdg_app_remote_get_noenumerate (XdgAppRemote *self); +XDG_APP_EXTERN gboolean xdg_app_remote_get_disabled (XdgAppRemote *self); +XDG_APP_EXTERN int xdg_app_remote_get_prio (XdgAppRemote *self); #endif /* __XDG_APP_REMOTE_H__ */ -- cgit v1.2.1