Convert to g_autoptr

tingping/wmclass
Alexander Larsson 2015-03-20 16:21:19 +01:00
parent 22ac447fc6
commit c856556b8a
22 changed files with 357 additions and 321 deletions

View File

@ -2,6 +2,8 @@ AC_PREREQ([2.63])
AC_INIT([xdg-app],[0.0.1])
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AM_PROG_CC_C_O
AC_DISABLE_STATIC
@ -14,7 +16,6 @@ AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.11 no-define no-dist-gzip dist-bzip2 tar-ustar foreign subdir-objects])
AC_PROG_SED
AC_USE_SYSTEM_EXTENSIONS
# Enable silent rules is available
AM_SILENT_RULES([yes])

View File

@ -3,8 +3,10 @@
#include <locale.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -25,10 +27,10 @@ xdg_app_builtin_add_remote (int argc, char **argv, GCancellable *cancellable, GE
{
GOptionContext *context;
gboolean ret = FALSE;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_variant_builder GVariantBuilder *optbuilder = NULL;
gs_unref_hashtable GHashTable *refs = NULL;
gs_free char *title = NULL;
g_autoptr(XdgAppDir) dir = NULL;
g_autoptr(GVariantBuilder) optbuilder = NULL;
g_autoptr(GHashTable) refs = NULL;
g_autofree char *title = NULL;
const char *remote_name;
const char *remote_url;

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -24,9 +25,9 @@ static gboolean
metadata_get_arch (GFile *file, char **out_arch, GError **error)
{
gboolean ret = FALSE;
gs_free char *path = NULL;
gs_unref_keyfile GKeyFile *keyfile = NULL;
gs_free char *runtime = NULL;
g_autofree char *path = NULL;
g_autoptr(GKeyFile) keyfile = NULL;
g_autofree char *runtime = NULL;
gs_strfreev char **parts = NULL;
keyfile = g_key_file_new ();
@ -55,8 +56,8 @@ out:
static gboolean
is_empty_directory (GFile *file, GCancellable *cancellable)
{
gs_unref_object GFileEnumerator *file_enum = NULL;
gs_unref_object GFileInfo *child_info = NULL;
g_autoptr(GFileEnumerator) file_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
file_enum = g_file_enumerate_children (file, G_FILE_ATTRIBUTE_STANDARD_NAME,
G_FILE_QUERY_INFO_NONE,
@ -97,25 +98,25 @@ xdg_app_builtin_build_export (int argc, char **argv, GCancellable *cancellable,
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object GFile *base = NULL;
gs_unref_object GFile *files = NULL;
gs_unref_object GFile *metadata = NULL;
gs_unref_object GFile *export = NULL;
gs_unref_object GFile *repofile = NULL;
gs_unref_object GFile *arg = NULL;
gs_unref_object GFile *root = NULL;
gs_unref_object OstreeRepo *repo = NULL;
g_autoptr(GFile) base = NULL;
g_autoptr(GFile) files = NULL;
g_autoptr(GFile) metadata = NULL;
g_autoptr(GFile) export = NULL;
g_autoptr(GFile) repofile = NULL;
g_autoptr(GFile) arg = NULL;
g_autoptr(GFile) root = NULL;
g_autoptr(OstreeRepo) repo = NULL;
const char *location;
const char *directory;
const char *name;
const char *branch;
gs_free char *arch = NULL;
gs_free char *full_branch = NULL;
gs_free char *parent = NULL;
gs_free char *commit_checksum = NULL;
gs_unref_object OstreeMutableTree *mtree = NULL;
g_autofree char *arch = NULL;
g_autofree char *full_branch = NULL;
g_autofree char *parent = NULL;
g_autofree char *commit_checksum = NULL;
g_autoptr(OstreeMutableTree) mtree = NULL;
char *subject = NULL;
gs_free char *body = NULL;
g_autofree char *body = NULL;
OstreeRepoTransactionStats stats;
OstreeRepoCommitModifier *modifier = NULL;

View File

@ -7,6 +7,7 @@
#include <ftw.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -27,8 +28,8 @@ show_export (const char *fpath, const struct stat *sb, int typeflag)
{
if (typeflag == FTW_F)
{
gs_unref_object GFile *file;
gs_free char *relpath;
g_autoptr(GFile) file;
g_autofree char *relpath;
file = g_file_new_for_path (fpath);
relpath = g_file_get_relative_path (show_export_base, file);
@ -42,8 +43,8 @@ static gboolean
collect_exports (GFile *base, GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *files = NULL;
gs_unref_object GFile *export = NULL;
g_autoptr(GFile) files = NULL;
g_autoptr(GFile) export = NULL;
const char *paths[] = {
"share/applications", /* Copy desktop files */
"share/icons/hicolor", /* Icons */
@ -62,13 +63,13 @@ collect_exports (GFile *base, GCancellable *cancellable, GError **error)
for (i = 0; paths[i]; i++)
{
gs_unref_object GFile *src = NULL;
g_autoptr(GFile) src = NULL;
src = g_file_resolve_relative_path (files, paths[i]);
if (g_file_query_exists (src, cancellable))
{
g_debug ("Exporting from %s", paths[i]);
gs_unref_object GFile *dest = NULL;
gs_unref_object GFile *dest_parent = NULL;
g_autoptr(GFile) dest = NULL;
g_autoptr(GFile) dest_parent = NULL;
dest = g_file_resolve_relative_path (export, paths[i]);
dest_parent = g_file_get_parent (dest);
g_debug ("Ensuring export/%s parent exists", paths[i]);
@ -95,9 +96,9 @@ static gboolean
update_metadata (GFile *base, GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *metadata = NULL;
gs_free char *path = NULL;
gs_unref_keyfile GKeyFile *keyfile = NULL;
g_autoptr(GFile) metadata = NULL;
g_autofree char *path = NULL;
g_autoptr(GKeyFile) keyfile = NULL;
GError *temp_error = NULL;
const char *environment_keys[] = {
"x11", "wayland", "ipc", "pulseaudio", "system-dbus", "session-dbus",
@ -130,10 +131,10 @@ update_metadata (GFile *base, GCancellable *cancellable, GError **error)
}
else
{
gs_free char *command = NULL;
gs_unref_object GFile *bin_dir = NULL;
gs_unref_object GFileEnumerator *bin_enum = NULL;
gs_unref_object GFileInfo *child_info = NULL;
g_autofree char *command = NULL;
g_autoptr(GFile) bin_dir = NULL;
g_autoptr(GFileEnumerator) bin_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
g_debug ("Looking for executables");
@ -210,15 +211,15 @@ xdg_app_builtin_build_finish (int argc, char **argv, GCancellable *cancellable,
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object GFile *base = NULL;
gs_unref_object GFile *files_dir = NULL;
gs_unref_object GFile *export_dir = NULL;
gs_unref_object GFile *var_dir = NULL;
gs_unref_object GFile *var_tmp_dir = NULL;
gs_unref_object GFile *var_run_dir = NULL;
gs_unref_object GFile *metadata_file = NULL;
gs_unref_object XdgAppDir *user_dir = NULL;
gs_unref_object XdgAppDir *system_dir = NULL;
g_autoptr(GFile) base = NULL;
g_autoptr(GFile) files_dir = NULL;
g_autoptr(GFile) export_dir = NULL;
g_autoptr(GFile) var_dir = NULL;
g_autoptr(GFile) var_tmp_dir = NULL;
g_autoptr(GFile) var_run_dir = NULL;
g_autoptr(GFile) metadata_file = NULL;
g_autoptr(XdgAppDir) user_dir = NULL;
g_autoptr(XdgAppDir) system_dir = NULL;
const char *directory;
context = g_option_context_new ("DIRECTORY - Convert a directory to a bundle");

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -24,26 +25,26 @@ xdg_app_builtin_build_init (int argc, char **argv, GCancellable *cancellable, GE
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object GFile *runtime_deploy_base = NULL;
gs_unref_object GFile *sdk_deploy_base = NULL;
gs_unref_object GFile *var_deploy_base = NULL;
gs_unref_object GFile *var_deploy_files = NULL;
gs_unref_object GFile *base = NULL;
gs_unref_object GFile *files_dir = NULL;
gs_unref_object GFile *var_dir = NULL;
gs_unref_object GFile *var_tmp_dir = NULL;
gs_unref_object GFile *var_run_dir = NULL;
gs_unref_object GFile *metadata_file = NULL;
gs_unref_object XdgAppDir *user_dir = NULL;
gs_unref_object XdgAppDir *system_dir = NULL;
g_autoptr(GFile) runtime_deploy_base = NULL;
g_autoptr(GFile) sdk_deploy_base = NULL;
g_autoptr(GFile) var_deploy_base = NULL;
g_autoptr(GFile) var_deploy_files = NULL;
g_autoptr(GFile) base = NULL;
g_autoptr(GFile) files_dir = NULL;
g_autoptr(GFile) var_dir = NULL;
g_autoptr(GFile) var_tmp_dir = NULL;
g_autoptr(GFile) var_run_dir = NULL;
g_autoptr(GFile) metadata_file = NULL;
g_autoptr(XdgAppDir) user_dir = NULL;
g_autoptr(XdgAppDir) system_dir = NULL;
const char *directory;
const char *sdk;
const char *runtime;
const char *branch = "master";
gs_free char *runtime_ref = NULL;
gs_free char *var_ref = NULL;
gs_free char *sdk_ref = NULL;
gs_free char *metadata_contents = NULL;
g_autofree char *runtime_ref = NULL;
g_autofree char *var_ref = NULL;
g_autofree char *sdk_ref = NULL;
g_autofree char *metadata_contents = NULL;
context = g_option_context_new ("DIRECTORY SDK RUNTIME [BRANCH] - Initialize a directory for building");

View File

@ -7,6 +7,7 @@
#include <errno.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -28,27 +29,27 @@ xdg_app_builtin_build (int argc, char **argv, GCancellable *cancellable, GError
{
GOptionContext *context;
gboolean ret = FALSE;
gs_unref_object XdgAppDir *user_dir = NULL;
gs_unref_variant_builder GVariantBuilder *optbuilder = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *var = NULL;
gs_unref_object GFile *var_tmp = NULL;
gs_unref_object GFile *var_run = NULL;
gs_unref_object GFile *app_deploy = NULL;
gs_unref_object GFile *app_files = NULL;
gs_unref_object GFile *runtime_deploy = NULL;
gs_unref_object GFile *runtime_files = NULL;
gs_unref_object GFile *metadata = NULL;
gs_free char *metadata_contents = NULL;
gs_free char *runtime = NULL;
gs_free char *default_command = NULL;
gs_free char *runtime_ref = NULL;
gs_free char *app_ref = NULL;
gs_unref_keyfile GKeyFile *metakey = NULL;
gs_free_error GError *my_error = NULL;
gs_free_error GError *my_error2 = NULL;
gs_unref_ptrarray GPtrArray *argv_array = NULL;
gs_unref_ptrarray GPtrArray *env_array = NULL;
g_autoptr(XdgAppDir) user_dir = NULL;
g_autoptr(GVariantBuilder) optbuilder = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) var = NULL;
g_autoptr(GFile) var_tmp = NULL;
g_autoptr(GFile) var_run = NULL;
g_autoptr(GFile) app_deploy = NULL;
g_autoptr(GFile) app_files = NULL;
g_autoptr(GFile) runtime_deploy = NULL;
g_autoptr(GFile) runtime_files = NULL;
g_autoptr(GFile) metadata = NULL;
g_autofree char *metadata_contents = NULL;
g_autofree char *runtime = NULL;
g_autofree char *default_command = NULL;
g_autofree char *runtime_ref = NULL;
g_autofree char *app_ref = NULL;
g_autoptr(GKeyFile) metakey = NULL;
g_autoptr (GError) my_error = NULL;
g_autoptr (GError) my_error2 = NULL;
g_autoptr(GPtrArray) argv_array = NULL;
g_autoptr(GPtrArray) env_array = NULL;
gsize metadata_size;
const char *directory = NULL;
const char *command = "/bin/sh";

View File

@ -3,8 +3,10 @@
#include <locale.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
@ -13,7 +15,7 @@ xdg_app_builtin_delete_remote (int argc, char **argv, GCancellable *cancellable,
{
GOptionContext *context;
gboolean ret = FALSE;
gs_unref_object XdgAppDir *dir = NULL;
g_autoptr(XdgAppDir) dir = NULL;
const char *remote_name;
context = g_option_context_new ("NAME - Delete a remote repository");

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -22,13 +23,13 @@ xdg_app_builtin_install_runtime (int argc, char **argv, GCancellable *cancellabl
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *origin = NULL;
g_autoptr(XdgAppDir) dir = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) origin = NULL;
const char *repository;
const char *runtime;
const char *branch = "master";
gs_free char *ref = NULL;
g_autofree char *ref = NULL;
gboolean created_deploy_base = FALSE;
context = g_option_context_new ("REPOSITORY RUNTIME [BRANCH] - Install a runtime");
@ -102,13 +103,13 @@ xdg_app_builtin_install_app (int argc, char **argv, GCancellable *cancellable, G
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *origin = NULL;
g_autoptr(XdgAppDir) dir = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) origin = NULL;
const char *repository;
const char *app;
const char *branch = "master";
gs_free char *ref = NULL;
g_autofree char *ref = NULL;
gboolean created_deploy_base = FALSE;
context = g_option_context_new ("REPOSITORY APP [BRANCH] - Install an application");

View File

@ -6,6 +6,7 @@
#include <unistd.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
@ -21,7 +22,7 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable,
{
GOptionContext *context;
gboolean ret = FALSE;
gs_unref_object XdgAppDir *dir = NULL;
g_autoptr(XdgAppDir) dir = NULL;
gs_strfreev char **remotes = NULL;
guint ii, n_remotes = 0;
@ -41,7 +42,7 @@ xdg_app_builtin_list_remotes (int argc, char **argv, GCancellable *cancellable,
for (ii = 0; ii < n_remotes; ii++)
{
gs_free char *remote_url = NULL;
g_autofree char *remote_url = NULL;
if (!ostree_repo_remote_get_url (xdg_app_dir_get_repo (dir), remotes[ii], &remote_url, error))
goto out;

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -26,15 +27,15 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
{
gboolean ret = FALSE;
gs_strfreev gchar **refs = NULL;
gs_free char *last_ref = NULL;
gs_free char *last = NULL;
g_autofree char *last_ref = NULL;
g_autofree char *last = NULL;
gs_strfreev char **system = NULL;
gs_strfreev char **user = NULL;
int s, u;
if (print_user)
{
gs_unref_object XdgAppDir *dir = NULL;
g_autoptr(XdgAppDir) dir = NULL;
dir = xdg_app_dir_get (TRUE);
if (!xdg_app_dir_list_refs (dir, kind, &user, cancellable, error))
@ -45,7 +46,7 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
if (print_system)
{
gs_unref_object XdgAppDir *dir = NULL;
g_autoptr(XdgAppDir) dir = NULL;
dir = xdg_app_dir_get (FALSE);
if (!xdg_app_dir_list_refs (dir, kind, &system, cancellable, error))
@ -92,8 +93,8 @@ print_installed_refs (const char *kind, gboolean print_system, gboolean print_us
if (strcmp (kind, "app") == 0)
{
gs_free char *current;
gs_unref_object XdgAppDir *dir = NULL;
g_autofree char *current;
g_autoptr(XdgAppDir) dir = NULL;
dir = xdg_app_dir_get (is_user);
current = xdg_app_dir_current_ref (dir, parts[1], cancellable);

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -22,12 +23,12 @@ xdg_app_builtin_make_current_app (int argc, char **argv, GCancellable *cancellab
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *origin = NULL;
g_autoptr(XdgAppDir) dir = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) origin = NULL;
const char *app;
const char *branch = "master";
gs_free char *ref = NULL;
g_autofree char *ref = NULL;
context = g_option_context_new ("APP BRANCH - Make branch of application current");

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -28,18 +29,18 @@ xdg_app_builtin_repo_contents (int argc, char **argv, GCancellable *cancellable,
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
g_autoptr(XdgAppDir) dir = NULL;
OstreeRepo *repo = NULL;
gs_unref_hashtable GHashTable *refs = NULL;
gs_free char *title = NULL;
g_autoptr(GHashTable) refs = NULL;
g_autofree char *title = NULL;
GHashTableIter iter;
gpointer key;
gpointer value;
gs_unref_ptrarray GPtrArray *names = NULL;
g_autoptr(GPtrArray) names = NULL;
int i;
const char *repository;
gs_free char *url = NULL;
gs_unref_bytes GBytes *bytes = NULL;
g_autofree char *url = NULL;
g_autoptr(GBytes) bytes = NULL;
context = g_option_context_new (" REPOSITORY - Show available runtimes and applications");
@ -68,8 +69,8 @@ xdg_app_builtin_repo_contents (int argc, char **argv, GCancellable *cancellable,
{
const char *refspec = key;
const char *checksum = value;
gs_free char *remote = NULL;
gs_free char *ref = NULL;
g_autofree char *remote = NULL;
g_autofree char *ref = NULL;
char *name = NULL;
char *p;
@ -81,7 +82,7 @@ xdg_app_builtin_repo_contents (int argc, char **argv, GCancellable *cancellable,
if (opt_only_updates)
{
gs_free char *deployed = NULL;
g_autofree char *deployed = NULL;
deployed = xdg_app_dir_read_active (dir, ref, cancellable);
if (deployed == NULL)

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -23,8 +24,8 @@ xdg_app_builtin_repo_update (int argc, char **argv, GCancellable *cancellable, G
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object GFile *repofile = NULL;
gs_unref_object OstreeRepo *repo = NULL;
g_autoptr(GFile) repofile = NULL;
g_autoptr(OstreeRepo) repo = NULL;
const char *location;
GVariant *extra = NULL;

View File

@ -5,8 +5,10 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -37,9 +39,9 @@ add_extension_arg (const char *directory,
const char *type, const char *extension, const char *arch, const char *branch,
GPtrArray *argv_array, GCancellable *cancellable)
{
gs_free char *extension_ref;
gs_unref_object GFile *deploy = NULL;
gs_free char *full_directory = NULL;
g_autofree char *extension_ref;
g_autoptr(GFile) deploy = NULL;
g_autofree char *full_directory = NULL;
gboolean is_app;
is_app = strcmp (type, "app") == 0;
@ -50,7 +52,7 @@ add_extension_arg (const char *directory,
deploy = xdg_app_find_deploy_dir_for_ref (extension_ref, cancellable, NULL);
if (deploy != NULL)
{
gs_unref_object GFile *files = g_file_get_child (deploy, "files");
g_autoptr(GFile) files = g_file_get_child (deploy, "files");
g_ptr_array_add (argv_array, g_strdup ("-b"));
g_ptr_array_add (argv_array, g_strdup_printf ("%s=%s", full_directory, gs_file_get_path_cached (files)));
}
@ -82,7 +84,7 @@ add_extension_args (GKeyFile *metakey, const char *full_ref,
if (g_str_has_prefix (groups[i], "Extension ") &&
*(extension = (groups[i] + strlen ("Extension "))) != 0)
{
gs_free char *directory = g_key_file_get_string (metakey, groups[i], "directory", NULL);
g_autofree char *directory = g_key_file_get_string (metakey, groups[i], "directory", NULL);
if (directory == NULL)
continue;
@ -90,7 +92,7 @@ add_extension_args (GKeyFile *metakey, const char *full_ref,
if (g_key_file_get_boolean (metakey, groups[i],
"subdirectories", NULL))
{
gs_free char *prefix = g_strconcat (extension, ".", NULL);
g_autofree char *prefix = g_strconcat (extension, ".", NULL);
gs_strfreev char **refs = NULL;
int i;
@ -101,7 +103,7 @@ add_extension_args (GKeyFile *metakey, const char *full_ref,
for (i = 0; refs[i] != NULL; i++)
{
gs_free char *extended_dir = g_build_filename (directory, refs[i] + strlen (prefix), NULL);
g_autofree char *extended_dir = g_build_filename (directory, refs[i] + strlen (prefix), NULL);
add_extension_arg (extended_dir, parts[0], refs[i], parts[2], parts[3],
argv_array, cancellable);
}
@ -122,32 +124,32 @@ xdg_app_builtin_run (int argc, char **argv, GCancellable *cancellable, GError **
{
GOptionContext *context;
gboolean ret = FALSE;
gs_unref_variant_builder GVariantBuilder *optbuilder = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *app_deploy = NULL;
gs_unref_object GFile *app_files = NULL;
gs_unref_object GFile *runtime_deploy = NULL;
gs_unref_object GFile *runtime_files = NULL;
gs_unref_object GFile *metadata = NULL;
gs_unref_object GFile *app_id_dir = NULL;
gs_unref_object GFile *app_id_dir_data = NULL;
gs_unref_object GFile *app_id_dir_config = NULL;
gs_unref_object GFile *app_id_dir_cache = NULL;
gs_unref_object GFile *runtime_metadata = NULL;
gs_unref_object XdgAppSessionHelper *session_helper = NULL;
gs_free char *metadata_contents = NULL;
gs_free char *runtime_metadata_contents = NULL;
gs_free char *runtime = NULL;
gs_free char *default_command = NULL;
gs_free char *runtime_ref = NULL;
gs_free char *app_ref = NULL;
gs_free char *path = NULL;
gs_unref_keyfile GKeyFile *metakey = NULL;
gs_unref_keyfile GKeyFile *runtime_metakey = NULL;
gs_free_error GError *my_error = NULL;
gs_free_error GError *my_error2 = NULL;
gs_unref_ptrarray GPtrArray *argv_array = NULL;
gs_free char *monitor_path = NULL;
g_autoptr(GVariantBuilder) optbuilder = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) app_deploy = NULL;
g_autoptr(GFile) app_files = NULL;
g_autoptr(GFile) runtime_deploy = NULL;
g_autoptr(GFile) runtime_files = NULL;
g_autoptr(GFile) metadata = NULL;
g_autoptr(GFile) app_id_dir = NULL;
g_autoptr(GFile) app_id_dir_data = NULL;
g_autoptr(GFile) app_id_dir_config = NULL;
g_autoptr(GFile) app_id_dir_cache = NULL;
g_autoptr(GFile) runtime_metadata = NULL;
g_autoptr(XdgAppSessionHelper) session_helper = NULL;
g_autofree char *metadata_contents = NULL;
g_autofree char *runtime_metadata_contents = NULL;
g_autofree char *runtime = NULL;
g_autofree char *default_command = NULL;
g_autofree char *runtime_ref = NULL;
g_autofree char *app_ref = NULL;
g_autofree char *path = NULL;
g_autoptr(GKeyFile) metakey = NULL;
g_autoptr(GKeyFile) runtime_metakey = NULL;
g_autoptr (GError) my_error = NULL;
g_autoptr (GError) my_error2 = NULL;
g_autoptr(GPtrArray) argv_array = NULL;
g_autofree char *monitor_path = NULL;
gsize metadata_size, runtime_metadata_size;
const char *app;
const char *branch = "master";

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -26,17 +27,17 @@ xdg_app_builtin_uninstall_runtime (int argc, char **argv, GCancellable *cancella
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *arch_dir = NULL;
gs_unref_object GFile *top_dir = NULL;
gs_unref_object GFile *origin = NULL;
gs_unref_object OstreeRepo *repo = NULL;
g_autoptr(XdgAppDir) dir = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) arch_dir = NULL;
g_autoptr(GFile) top_dir = NULL;
g_autoptr(GFile) origin = NULL;
g_autoptr(OstreeRepo) repo = NULL;
const char *name;
const char *arch;
const char *branch;
gs_free char *ref = NULL;
gs_free char *repository = NULL;
g_autofree char *ref = NULL;
g_autofree char *repository = NULL;
gs_strfreev char **deployed = NULL;
int i;
GError *temp_error = NULL;
@ -156,18 +157,18 @@ xdg_app_builtin_uninstall_app (int argc, char **argv, GCancellable *cancellable,
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *arch_dir = NULL;
gs_unref_object GFile *top_dir = NULL;
gs_unref_object GFile *origin = NULL;
gs_unref_object OstreeRepo *repo = NULL;
g_autoptr(XdgAppDir) dir = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) arch_dir = NULL;
g_autoptr(GFile) top_dir = NULL;
g_autoptr(GFile) origin = NULL;
g_autoptr(OstreeRepo) repo = NULL;
const char *name;
const char *arch;
const char *branch;
gs_free char *ref = NULL;
gs_free char *repository = NULL;
gs_free char *current_ref = NULL;
g_autofree char *ref = NULL;
g_autofree char *repository = NULL;
g_autofree char *current_ref = NULL;
gs_strfreev char **deployed = NULL;
int i;
GError *temp_error = NULL;

View File

@ -6,6 +6,7 @@
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-builtins.h"
#include "xdg-app-utils.h"
@ -26,14 +27,14 @@ xdg_app_builtin_update_runtime (int argc, char **argv, GCancellable *cancellable
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *origin = NULL;
g_autoptr(XdgAppDir) dir = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) origin = NULL;
const char *runtime;
const char *branch = "master";
gs_free char *previous_deployment = NULL;
gs_free char *ref = NULL;
gs_free char *repository = NULL;
g_autofree char *previous_deployment = NULL;
g_autofree char *ref = NULL;
g_autofree char *repository = NULL;
GError *my_error;
context = g_option_context_new ("RUNTIME [BRANCH] - Update a runtime");
@ -117,14 +118,14 @@ xdg_app_builtin_update_app (int argc, char **argv, GCancellable *cancellable, GE
{
gboolean ret = FALSE;
GOptionContext *context;
gs_unref_object XdgAppDir *dir = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *origin = NULL;
g_autoptr(XdgAppDir) dir = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) origin = NULL;
const char *app;
const char *branch = "master";
gs_free char *ref = NULL;
gs_free char *repository = NULL;
gs_free char *previous_deployment = NULL;
g_autofree char *ref = NULL;
g_autofree char *repository = NULL;
g_autofree char *previous_deployment = NULL;
GError *my_error;
context = g_option_context_new ("APP [BRANCH] - Update an application");

View File

@ -6,6 +6,7 @@
#include <gio/gio.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-dir.h"
#include "xdg-app-utils.h"
@ -47,7 +48,7 @@ xdg_app_get_system_base_dir_location (void)
GFile *
xdg_app_get_user_base_dir_location (void)
{
gs_free char *base = g_build_filename (g_get_user_data_dir (), "xdg-app", NULL);
g_autofree char *base = g_build_filename (g_get_user_data_dir (), "xdg-app", NULL);
return g_file_new_for_path (base);
}
@ -188,8 +189,8 @@ xdg_app_dir_ensure_repo (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *repodir = NULL;
gs_unref_object OstreeRepo *repo = NULL;
g_autoptr(GFile) repodir = NULL;
g_autoptr(OstreeRepo) repo = NULL;
if (self->repo == NULL)
{
@ -213,7 +214,7 @@ xdg_app_dir_ensure_repo (XdgAppDir *self,
{
if (!ostree_repo_open (repo, cancellable, error))
{
gs_free char *repopath = NULL;
g_autofree char *repopath = NULL;
repopath = g_file_get_path (repodir);
g_prefix_error (error, "While opening repository %s: ", repopath);
@ -238,7 +239,7 @@ xdg_app_dir_pull (XdgAppDir *self,
{
gboolean ret = FALSE;
GSConsole *console = NULL;
gs_unref_object OstreeAsyncProgress *progress = NULL;
g_autoptr(OstreeAsyncProgress) progress = NULL;
const char *refs[2];
if (!xdg_app_dir_ensure_repo (self, cancellable, error))
@ -275,10 +276,10 @@ xdg_app_dir_current_ref (XdgAppDir *self,
const char *name,
GCancellable *cancellable)
{
gs_unref_object GFile *base = NULL;
gs_unref_object GFile *dir = NULL;
gs_unref_object GFile *current_link = NULL;
gs_unref_object GFileInfo *file_info = NULL;
g_autoptr(GFile) base = NULL;
g_autoptr(GFile) dir = NULL;
g_autoptr(GFile) current_link = NULL;
g_autoptr(GFileInfo) file_info = NULL;
base = g_file_get_child (xdg_app_dir_get_path (self), "app");
dir = g_file_get_child (base, name);
@ -300,9 +301,9 @@ xdg_app_dir_drop_current_ref (XdgAppDir *self,
GCancellable *cancellable,
GError **error)
{
gs_unref_object GFile *base = NULL;
gs_unref_object GFile *dir = NULL;
gs_unref_object GFile *current_link = NULL;
g_autoptr(GFile) base = NULL;
g_autoptr(GFile) dir = NULL;
g_autoptr(GFile) current_link = NULL;
base = g_file_get_child (xdg_app_dir_get_path (self), "app");
dir = g_file_get_child (base, name);
@ -318,11 +319,11 @@ xdg_app_dir_make_current_ref (XdgAppDir *self,
GCancellable *cancellable,
GError **error)
{
gs_unref_object GFile *base = NULL;
gs_unref_object GFile *dir = NULL;
gs_unref_object GFile *current_link = NULL;
g_autoptr(GFile) base = NULL;
g_autoptr(GFile) dir = NULL;
g_autoptr(GFile) current_link = NULL;
gs_strfreev char **ref_parts = NULL;
gs_free char *rest = NULL;
g_autofree char *rest = NULL;
gboolean ret = FALSE;
ref_parts = g_strsplit (ref, "/", -1);
@ -365,12 +366,12 @@ xdg_app_dir_list_refs_for_name (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *base = NULL;
gs_unref_object GFile *dir = NULL;
gs_unref_object GFileEnumerator *dir_enum = NULL;
gs_unref_object GFileInfo *child_info = NULL;
g_autoptr(GFile) base = NULL;
g_autoptr(GFile) dir = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
GError *temp_error = NULL;
gs_unref_ptrarray GPtrArray *refs = NULL;
g_autoptr(GPtrArray) refs = NULL;
base = g_file_get_child (xdg_app_dir_get_path (self), kind);
dir = g_file_get_child (base, name);
@ -391,9 +392,9 @@ xdg_app_dir_list_refs_for_name (XdgAppDir *self,
while ((child_info = g_file_enumerator_next_file (dir_enum, cancellable, &temp_error)))
{
gs_unref_object GFile *child = NULL;
gs_unref_object GFileEnumerator *dir_enum2 = NULL;
gs_unref_object GFileInfo *child_info2 = NULL;
g_autoptr(GFile) child = NULL;
g_autoptr(GFileEnumerator) dir_enum2 = NULL;
g_autoptr(GFileInfo) child_info2 = NULL;
const char *arch;
arch = g_file_info_get_name (child_info);
@ -463,11 +464,11 @@ xdg_app_dir_list_refs (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *base;
gs_unref_object GFileEnumerator *dir_enum = NULL;
gs_unref_object GFileInfo *child_info = NULL;
g_autoptr(GFile) base;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
GError *temp_error = NULL;
gs_unref_ptrarray GPtrArray *refs = NULL;
g_autoptr(GPtrArray) refs = NULL;
refs = g_ptr_array_new ();
@ -535,9 +536,9 @@ xdg_app_dir_read_active (XdgAppDir *self,
const char *ref,
GCancellable *cancellable)
{
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *active_link = NULL;
gs_unref_object GFileInfo *file_info = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) active_link = NULL;
g_autoptr(GFileInfo) file_info = NULL;
deploy_base = xdg_app_dir_get_deploy_dir (self, ref);
active_link = g_file_get_child (deploy_base, "active");
@ -559,11 +560,11 @@ xdg_app_dir_set_active (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *deploy_base = NULL;
gs_free char *tmpname = NULL;
gs_unref_object GFile *active_tmp_link = NULL;
gs_unref_object GFile *active_link = NULL;
gs_free_error GError *my_error = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autofree char *tmpname = NULL;
g_autoptr(GFile) active_tmp_link = NULL;
g_autoptr(GFile) active_link = NULL;
g_autoptr (GError) my_error = NULL;
deploy_base = xdg_app_dir_get_deploy_dir (self, ref);
active_link = g_file_get_child (deploy_base, "active");
@ -603,10 +604,10 @@ xdg_app_dir_run_triggers (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFileEnumerator *dir_enum = NULL;
gs_unref_object GFileInfo *child_info = NULL;
gs_unref_object GFile *triggersdir = NULL;
gs_unref_object GFile *exports = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
g_autoptr(GFile) triggersdir = NULL;
g_autoptr(GFile) exports = NULL;
GError *temp_error = NULL;
g_debug ("running triggers");
@ -622,7 +623,7 @@ xdg_app_dir_run_triggers (XdgAppDir *self,
while ((child_info = g_file_enumerator_next_file (dir_enum, cancellable, &temp_error)) != NULL)
{
gs_unref_object GFile *child = NULL;
g_autoptr(GFile) child = NULL;
const char *name;
GError *trigger_error = NULL;
@ -633,7 +634,7 @@ xdg_app_dir_run_triggers (XdgAppDir *self,
if (g_file_info_get_file_type (child_info) == G_FILE_TYPE_REGULAR &&
g_str_has_suffix (name, ".trigger"))
{
gs_unref_ptrarray GPtrArray *argv_array = NULL;
g_autoptr(GPtrArray) argv_array = NULL;
g_debug ("running trigger %s", name);
@ -750,19 +751,19 @@ export_desktop_file (const char *app,
{
gboolean ret = FALSE;
gs_fd_close int desktop_fd = -1;
gs_free char *tmpfile_name = NULL;
gs_unref_object GOutputStream *out_stream = NULL;
gs_free gchar *data = NULL;
g_autofree char *tmpfile_name = NULL;
g_autoptr(GOutputStream) out_stream = NULL;
g_autofree gchar *data = NULL;
gsize data_len;
gs_free gchar *new_data = NULL;
g_autofree gchar *new_data = NULL;
gsize new_data_len;
gs_unref_keyfile GKeyFile *keyfile = NULL;
gs_free gchar *old_exec = NULL;
g_autoptr(GKeyFile) keyfile = NULL;
g_autofree gchar *old_exec = NULL;
gint old_argc;
gs_strfreev gchar **old_argv = NULL;
gs_strfreev gchar **groups = NULL;
GString *new_exec = NULL;
gs_free char *escaped_app = g_shell_quote (app);
g_autofree char *escaped_app = g_shell_quote (app);
int i;
if (!gs_file_openat_noatime (parent_fd, name, &desktop_fd, cancellable, error))
@ -777,8 +778,8 @@ export_desktop_file (const char *app,
if (g_str_has_suffix (name, ".service"))
{
gs_free gchar *dbus_name = NULL;
gs_free gchar *expected_dbus_name = g_strndup (name, strlen (name) - strlen (".service"));
g_autofree gchar *dbus_name = NULL;
g_autofree gchar *expected_dbus_name = g_strndup (name, strlen (name) - strlen (".service"));
dbus_name = g_key_file_get_string (keyfile, "D-BUS Service", "Name", NULL);
@ -805,7 +806,7 @@ export_desktop_file (const char *app,
if (old_exec && g_shell_parse_argv (old_exec, &old_argc, &old_argv, NULL) && old_argc >= 1)
{
int i;
gs_free char *command = g_shell_quote (old_argv[0]);
g_autofree char *command = g_shell_quote (old_argv[0]);
g_string_append_printf (new_exec, " --command=%s", command);
@ -814,7 +815,7 @@ export_desktop_file (const char *app,
for (i = 1; i < old_argc; i++)
{
gs_free char *arg = g_shell_quote (old_argv[i]);
g_autofree char *arg = g_shell_quote (old_argv[i]);
g_string_append (new_exec, " ");
g_string_append (new_exec, arg);
}
@ -863,7 +864,7 @@ rewrite_export_dir (const char *app,
{
gboolean ret = FALSE;
gs_dirfd_iterator_cleanup GSDirFdIterator source_iter = {0};
gs_unref_hashtable GHashTable *visited_children = NULL;
g_autoptr(GHashTable) visited_children = NULL;
struct dirent *dent;
if (!gs_dirfd_iterator_init_at (source_parent_fd, source_name, FALSE, &source_iter, error))
@ -908,7 +909,7 @@ rewrite_export_dir (const char *app,
}
else if (S_ISREG (stbuf.st_mode))
{
gs_free gchar *target = NULL;
g_autofree gchar *target = NULL;
if (!xdg_app_has_name_prefix (dent->d_name, app))
{
@ -922,7 +923,7 @@ rewrite_export_dir (const char *app,
if (g_str_has_suffix (dent->d_name, ".desktop") || g_str_has_suffix (dent->d_name, ".service"))
{
gs_free gchar *new_name = NULL;
g_autofree gchar *new_name = NULL;
if (!export_desktop_file (app, branch, arch, source_iter.fd, dent->d_name, &stbuf, &new_name, cancellable, error))
goto out;
@ -1036,8 +1037,8 @@ export_dir (int source_parent_fd,
if (S_ISDIR (stbuf.st_mode))
{
gs_free gchar *child_symlink_prefix = g_build_filename ("..", source_symlink_prefix, dent->d_name, NULL);
gs_free gchar *child_relpath = g_strconcat (source_relpath, dent->d_name, "/", NULL);
g_autofree gchar *child_symlink_prefix = g_build_filename ("..", source_symlink_prefix, dent->d_name, NULL);
g_autofree gchar *child_relpath = g_strconcat (source_relpath, dent->d_name, "/", NULL);
if (!export_dir (source_iter.fd, dent->d_name, child_symlink_prefix, child_relpath, destination_dfd, dent->d_name,
cancellable, error))
@ -1045,7 +1046,7 @@ export_dir (int source_parent_fd,
}
else if (S_ISREG (stbuf.st_mode))
{
gs_free gchar *target = NULL;
g_autofree gchar *target = NULL;
target = g_build_filename (source_symlink_prefix, dent->d_name, NULL);
@ -1100,10 +1101,10 @@ xdg_app_dir_update_exports (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *exports = NULL;
gs_free char *current_ref = NULL;
gs_free char *active_id = NULL;
gs_free char *symlink_prefix = NULL;
g_autoptr(GFile) exports = NULL;
g_autofree char *current_ref = NULL;
g_autofree char *active_id = NULL;
g_autofree char *symlink_prefix = NULL;
exports = xdg_app_dir_get_exports_dir (self);
@ -1114,9 +1115,9 @@ xdg_app_dir_update_exports (XdgAppDir *self,
(current_ref = xdg_app_dir_current_ref (self, changed_app, cancellable)) &&
(active_id = xdg_app_dir_read_active (self, current_ref, cancellable)))
{
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *active = NULL;
gs_unref_object GFile *export = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) active = NULL;
g_autoptr(GFile) export = NULL;
deploy_base = xdg_app_dir_get_deploy_dir (self, current_ref);
active = g_file_get_child (deploy_base, active_id);
@ -1153,14 +1154,14 @@ xdg_app_dir_deploy (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_free char *resolved_ref = NULL;
gs_unref_object GFile *root = NULL;
gs_unref_object GFileInfo *file_info = NULL;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *checkoutdir = NULL;
gs_unref_object GFile *dotref = NULL;
gs_unref_object GFile *export = NULL;
gs_unref_object GFile *exports = NULL;
g_autofree char *resolved_ref = NULL;
g_autoptr(GFile) root = NULL;
g_autoptr(GFileInfo) file_info = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) checkoutdir = NULL;
g_autoptr(GFile) dotref = NULL;
g_autoptr(GFile) export = NULL;
g_autoptr(GFile) exports = NULL;
if (!xdg_app_dir_ensure_repo (self, cancellable, error))
goto out;
@ -1180,17 +1181,17 @@ xdg_app_dir_deploy (XdgAppDir *self,
}
else
{
gs_unref_object GFile *root = NULL;
gs_free char *commit = NULL;
g_autoptr(GFile) root = NULL;
g_autofree char *commit = NULL;
g_debug ("Looking for checksum %s in local repo", checksum);
if (!ostree_repo_read_commit (self->repo, checksum, &root, &commit, cancellable, NULL))
{
GSConsole *console = NULL;
gs_unref_object OstreeAsyncProgress *progress = NULL;
g_autoptr(OstreeAsyncProgress) progress = NULL;
const char *refs[2];
gs_unref_object GFile *origin = NULL;
gs_free char *repository = NULL;
g_autoptr(GFile) origin = NULL;
g_autofree char *repository = NULL;
refs[0] = checksum;
refs[1] = NULL;
@ -1247,8 +1248,8 @@ xdg_app_dir_deploy (XdgAppDir *self,
OSTREE_REPO_FILE (root), file_info,
cancellable, error))
{
gs_free char *rootpath = NULL;
gs_free char *checkoutpath = NULL;
g_autofree char *rootpath = NULL;
g_autofree char *checkoutpath = NULL;
rootpath = g_file_get_path (root);
checkoutpath = g_file_get_path (checkoutdir);
@ -1294,9 +1295,9 @@ xdg_app_dir_collect_deployed_refs (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *dir = NULL;
gs_unref_object GFileEnumerator *dir_enum = NULL;
gs_unref_object GFileInfo *child_info = NULL;
g_autoptr(GFile) dir = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
GError *temp_error = NULL;
dir = g_file_get_child (self->basedir, type);
@ -1317,10 +1318,10 @@ xdg_app_dir_collect_deployed_refs (XdgAppDir *self,
if (g_file_info_get_file_type (child_info) == G_FILE_TYPE_DIRECTORY &&
name[0] != '.' && (name_prefix == NULL || g_str_has_prefix (name, name_prefix)))
{
gs_unref_object GFile *child1 = g_file_get_child (dir, name);
gs_unref_object GFile *child2 = g_file_get_child (child1, branch);
gs_unref_object GFile *child3 = g_file_get_child (child2, arch);
gs_unref_object GFile *active = g_file_get_child (child3, "active");
g_autoptr(GFile) child1 = g_file_get_child (dir, name);
g_autoptr(GFile) child2 = g_file_get_child (child1, branch);
g_autoptr(GFile) child3 = g_file_get_child (child2, arch);
g_autoptr(GFile) active = g_file_get_child (child3, "active");
if (g_file_query_exists (active, cancellable))
g_hash_table_add (hash, g_strdup (name));
@ -1348,12 +1349,12 @@ xdg_app_dir_list_deployed (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_ptrarray GPtrArray *checksums = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GPtrArray) checksums = NULL;
GError *temp_error = NULL;
gs_unref_object GFileEnumerator *dir_enum = NULL;
gs_unref_object GFile *child = NULL;
gs_unref_object GFileInfo *child_info = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFile) child = NULL;
g_autoptr(GFileInfo) child_info = NULL;
deploy_base = xdg_app_dir_get_deploy_dir (self, ref);
@ -1404,7 +1405,7 @@ dir_is_locked (GFile *dir)
{
gs_fd_close int ref_fd = -1;
struct flock lock = {0};
gs_unref_object GFile *reffile = NULL;
g_autoptr(GFile) reffile = NULL;
reffile = g_file_resolve_relative_path (dir, "files/.ref");
@ -1432,12 +1433,12 @@ xdg_app_dir_undeploy (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *checkoutdir = NULL;
gs_unref_object GFile *removed_subdir = NULL;
gs_unref_object GFile *removed_dir = NULL;
gs_free char *tmpname = NULL;
gs_free char *active = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) checkoutdir = NULL;
g_autoptr(GFile) removed_subdir = NULL;
g_autoptr(GFile) removed_dir = NULL;
g_autofree char *tmpname = NULL;
g_autofree char *active = NULL;
int i;
g_assert (ref != NULL);
@ -1514,9 +1515,9 @@ xdg_app_dir_cleanup_removed (XdgAppDir *self,
GError **error)
{
gboolean ret = FALSE;
gs_unref_object GFile *removed_dir = NULL;
gs_unref_object GFileEnumerator *dir_enum = NULL;
gs_unref_object GFileInfo *child_info = NULL;
g_autoptr(GFile) removed_dir = NULL;
g_autoptr(GFileEnumerator) dir_enum = NULL;
g_autoptr(GFileInfo) child_info = NULL;
GError *temp_error = NULL;
removed_dir = xdg_app_dir_get_removed_dir (self);
@ -1533,7 +1534,7 @@ xdg_app_dir_cleanup_removed (XdgAppDir *self,
while ((child_info = g_file_enumerator_next_file (dir_enum, cancellable, &temp_error)) != NULL)
{
const char *name = g_file_info_get_name (child_info);
gs_unref_object GFile *child = g_file_get_child (removed_dir, name);
g_autoptr(GFile) child = g_file_get_child (removed_dir, name);
if (g_file_info_get_file_type (child_info) == G_FILE_TYPE_DIRECTORY &&
!dir_is_locked (child))
@ -1564,7 +1565,7 @@ xdg_app_dir_prune (XdgAppDir *self,
gboolean ret = FALSE;
gint objects_total, objects_pruned;
guint64 pruned_object_size_total;
gs_free char *formatted_freed_size = NULL;
g_autofree char *formatted_freed_size = NULL;
if (!xdg_app_dir_ensure_repo (self, cancellable, error))
goto out;
@ -1593,8 +1594,8 @@ xdg_app_dir_get_if_deployed (XdgAppDir *self,
const char *checksum,
GCancellable *cancellable)
{
gs_unref_object GFile *deploy_base = NULL;
gs_unref_object GFile *deploy_dir = NULL;
g_autoptr(GFile) deploy_base = NULL;
g_autoptr(GFile) deploy_dir = NULL;
deploy_base = xdg_app_dir_get_deploy_dir (self, ref);
deploy_dir = g_file_get_child (deploy_base, checksum ? checksum : "active");
@ -1617,7 +1618,7 @@ xdg_app_dir_get_system (void)
if (system == NULL)
{
gs_unref_object GFile *path = xdg_app_get_system_base_dir_location ();
g_autoptr(GFile) path = xdg_app_get_system_base_dir_location ();
system = xdg_app_dir_new (path, FALSE);
}
@ -1631,7 +1632,7 @@ xdg_app_dir_get_user (void)
if (user == NULL)
{
gs_unref_object GFile *path = xdg_app_get_user_base_dir_location ();
g_autoptr(GFile) path = xdg_app_get_user_base_dir_location ();
user = xdg_app_dir_new (path, TRUE);
}

View File

@ -11,6 +11,8 @@ typedef struct XdgAppDir XdgAppDir;
GType xdg_app_dir_get_type (void);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppDir, g_object_unref)
#define XDG_APP_DIR_ERROR xdg_app_dir_error_quark()
typedef enum {

View File

@ -2,9 +2,11 @@
#include <locale.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <gio/gio.h>
#include "libglnx/libglnx.h"
#include "libgsystem.h"
#include "xdg-app-builtins.h"
@ -94,7 +96,7 @@ xdg_app_usage (XdgAppCommand *commands,
gboolean is_error)
{
GOptionContext *context;
gs_free char *help;
g_autofree char *help;
context = xdg_app_option_context_new_with_commands (commands);
@ -123,7 +125,7 @@ xdg_app_option_context_parse (GOptionContext *context,
GError **error)
{
gboolean success = FALSE;
gs_unref_object XdgAppDir *dir = NULL;
g_autoptr(XdgAppDir) dir = NULL;
if (!(flags & XDG_APP_BUILTIN_FLAG_NO_DIR))
g_option_context_add_main_entries (context, user_entries, NULL);
@ -167,7 +169,7 @@ xdg_app_option_context_parse (GOptionContext *context,
void
usage_error (GOptionContext *context, const char *message, GError **error)
{
gs_free gchar *help = g_option_context_get_help (context, TRUE, NULL);
g_autofree gchar *help = g_option_context_get_help (context, TRUE, NULL);
g_printerr ("%s", help);
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED, message);
}
@ -182,7 +184,7 @@ xdg_app_run (int argc,
GError *error = NULL;
GCancellable *cancellable = NULL;
const char *command_name = NULL;
gs_free char *prgname = NULL;
g_autofree char *prgname = NULL;
gboolean success = FALSE;
int in, out;
@ -220,7 +222,7 @@ xdg_app_run (int argc,
if (!command->fn)
{
GOptionContext *context;
gs_free char *help;
g_autofree char *help;
context = xdg_app_option_context_new_with_commands (commands);
@ -270,7 +272,7 @@ main (int argc,
char **argv)
{
GError *error = NULL;
gs_free const char *old_env = NULL;
g_autofree const char *old_env = NULL;
int ret;
setlocale (LC_ALL, "");

View File

@ -7,6 +7,7 @@
#include <gio/gio.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include "xdg-app-run.h"
#include "xdg-app-utils.h"
@ -68,7 +69,7 @@ xdg_app_run_add_x11_args (GPtrArray *argv_array)
{
const char *display_nr = &display[1];
const char *display_nr_end = display_nr;
gs_free char *d = NULL;
g_autofree char *d = NULL;
while (g_ascii_isdigit (*display_nr_end))
display_nr_end++;
@ -317,8 +318,8 @@ xdg_app_run_setup_minimal_env (GPtrArray *env_array,
GFile *
xdg_app_get_data_dir (const char *app_id)
{
gs_unref_object GFile *home = g_file_new_for_path (g_get_home_dir ());
gs_unref_object GFile *var_app = g_file_resolve_relative_path (home, ".var/app");
g_autoptr(GFile) home = g_file_new_for_path (g_get_home_dir ());
g_autoptr(GFile) var_app = g_file_resolve_relative_path (home, ".var/app");
return g_file_get_child (var_app, app_id);
}
@ -328,10 +329,10 @@ xdg_app_ensure_data_dir (const char *app_id,
GCancellable *cancellable,
GError **error)
{
gs_unref_object GFile *dir = xdg_app_get_data_dir (app_id);
gs_unref_object GFile *data_dir = g_file_get_child (dir, "data");
gs_unref_object GFile *cache_dir = g_file_get_child (dir, "cache");
gs_unref_object GFile *config_dir = g_file_get_child (dir, "config");
g_autoptr(GFile) dir = xdg_app_get_data_dir (app_id);
g_autoptr(GFile) data_dir = g_file_get_child (dir, "data");
g_autoptr(GFile) cache_dir = g_file_get_child (dir, "cache");
g_autoptr(GFile) config_dir = g_file_get_child (dir, "config");
if (!gs_file_ensure_directory (data_dir, TRUE, cancellable, error))
return NULL;

View File

@ -4,7 +4,9 @@
#include "xdg-app-dir.h"
#include <glib.h>
#include <string.h>
#include "libgsystem.h"
#include "libglnx/libglnx.h"
#include <libsoup/soup.h>
#include <stdlib.h>
@ -254,10 +256,10 @@ xdg_app_list_deployed_refs (const char *type,
GError **error)
{
gchar **ret = NULL;
gs_unref_ptrarray GPtrArray *names = NULL;
gs_unref_hashtable GHashTable *hash = NULL;
gs_unref_object XdgAppDir *user_dir = NULL;
gs_unref_object XdgAppDir *system_dir = NULL;
g_autoptr(GPtrArray) names = NULL;
g_autoptr(GHashTable) hash = NULL;
g_autoptr(XdgAppDir) user_dir = NULL;
g_autoptr(XdgAppDir) system_dir = NULL;
const char *key;
GHashTableIter iter;
@ -296,8 +298,8 @@ xdg_app_find_deploy_dir_for_ref (const char *ref,
GCancellable *cancellable,
GError **error)
{
gs_unref_object XdgAppDir *user_dir = NULL;
gs_unref_object XdgAppDir *system_dir = NULL;
g_autoptr(XdgAppDir) user_dir = NULL;
g_autoptr(XdgAppDir) system_dir = NULL;
GFile *deploy = NULL;
user_dir = xdg_app_dir_get_user ();
@ -382,14 +384,14 @@ overlay_symlink_tree_dir (int source_parent_fd,
if (is_dir)
{
gs_free gchar *target = g_build_filename ("..", source_symlink_prefix, dent->d_name, NULL);
g_autofree gchar *target = g_build_filename ("..", source_symlink_prefix, dent->d_name, NULL);
if (!overlay_symlink_tree_dir (source_iter.fd, dent->d_name, target, destination_dfd, dent->d_name,
cancellable, error))
goto out;
}
else
{
gs_free gchar *target = g_build_filename (source_symlink_prefix, dent->d_name, NULL);
g_autofree gchar *target = g_build_filename (source_symlink_prefix, dent->d_name, NULL);
if (unlinkat (destination_dfd, dent->d_name, 0) != 0 && errno != ENOENT)
{
@ -529,14 +531,14 @@ static gboolean
load_contents (const char *uri, GBytes **contents, GCancellable *cancellable, GError **error)
{
gboolean ret = FALSE;
gs_free char *scheme = NULL;
g_autofree char *scheme = NULL;
scheme = g_uri_parse_scheme (uri);
if (strcmp (scheme, "file") == 0)
{
char *buffer;
gsize length;
gs_unref_object GFile *file = NULL;
g_autoptr(GFile) file = NULL;
g_debug ("Loading summary %s using GIO", uri);
file = g_file_new_for_uri (uri);
@ -547,8 +549,8 @@ load_contents (const char *uri, GBytes **contents, GCancellable *cancellable, GE
}
else
{
gs_unref_object SoupSession *session = NULL;
gs_unref_object SoupMessage *msg = NULL;
g_autoptr(SoupSession) session = NULL;
g_autoptr(SoupMessage) msg = NULL;
g_debug ("Loading summary %s using libsoup", uri);
session = soup_session_new ();
@ -577,19 +579,19 @@ ostree_repo_load_summary (const char *repository_url,
GError **error)
{
gboolean ret = FALSE;
gs_free char *summary_url = NULL;
gs_unref_bytes GBytes *bytes = NULL;
gs_unref_hashtable GHashTable *local_refs = NULL;
gs_free char *local_title = NULL;
g_autofree char *summary_url = NULL;
g_autoptr(GBytes) bytes = NULL;
g_autoptr(GHashTable) local_refs = NULL;
g_autofree char *local_title = NULL;
local_refs = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
summary_url = g_build_filename (repository_url, "summary", NULL);
if (load_contents (summary_url, &bytes, cancellable, NULL))
{
gs_unref_variant GVariant *summary;
gs_unref_variant GVariant *ref_list;
gs_unref_variant GVariant *extensions;
g_autoptr(GVariant) summary;
g_autoptr(GVariant) ref_list;
g_autoptr(GVariant) extensions;
GVariantDict dict;
int i, n;
@ -601,8 +603,8 @@ ostree_repo_load_summary (const char *repository_url,
g_debug ("Summary contains %d refs", n);
for (i = 0; i < n; i++)
{
gs_unref_variant GVariant *ref = NULL;
gs_unref_variant GVariant *csum_v = NULL;
g_autoptr(GVariant) ref = NULL;
g_autoptr(GVariant) csum_v = NULL;
char *refname;
char *checksum;

View File

@ -2,6 +2,8 @@
#define __XDG_APP_UTILS_H__
#include <gio/gio.h>
#include <libsoup/soup.h>
#include "xdg-app-dbus.h"
#include <ostree.h>
const char * xdg_app_get_arch (void);
@ -100,4 +102,11 @@ g_strv_subset (const gchar * const *strv,
return NULL;
}
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeRepo, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeMutableTree, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(OstreeAsyncProgress, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupSession, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(SoupMessage, g_object_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(XdgAppSessionHelper, g_object_unref)
#endif /* __XDG_APP_UTILS_H__ */