int main (int argc, char **argv) { guint owner_id; GMainLoop *loop; GOptionContext *context; g_autoptr(GError) error = NULL; setlocale (LC_ALL, ""); g_setenv ("GIO_USE_VFS", "local", TRUE); g_set_prgname (argv[0]); flatpak_migrate_from_xdg_app (); g_set_printerr_handler (printerr_handler); context = g_option_context_new ("- permission store"); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("Option parsing failed: %s", error->message); return 1; } if (opt_version) { g_print ("%s\n", PACKAGE_STRING); exit (EXIT_SUCCESS); } if (opt_verbose) g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, message_handler, NULL); g_set_prgname (argv[0]); owner_id = g_bus_own_name (G_BUS_TYPE_SESSION, "org.freedesktop.impl.portal.PermissionStore", G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT | (opt_replace ? G_BUS_NAME_OWNER_FLAGS_REPLACE : 0), on_bus_acquired, on_name_acquired, on_name_lost, NULL, NULL); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); g_bus_unown_name (owner_id); return 0; }
int main (int argc, char **argv) { GError *error = NULL; g_autofree const char *old_env = NULL; int ret; setlocale (LC_ALL, ""); g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, message_handler, NULL); g_set_prgname (argv[0]); /* avoid gvfs (http://bugzilla.gnome.org/show_bug.cgi?id=526454) */ old_env = g_strdup (g_getenv ("GIO_USE_VFS")); g_setenv ("GIO_USE_VFS", "local", TRUE); g_vfs_get_default (); if (old_env) g_setenv ("GIO_USE_VFS", old_env, TRUE); else g_unsetenv ("GIO_USE_VFS"); if (argc >= 4 && strcmp (argv[1], "complete") == 0) return complete (argc, argv); flatpak_migrate_from_xdg_app (); ret = flatpak_run (argc, argv, &error); if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) flatpak_usage (commands, TRUE); if (error != NULL) { int is_tty = isatty (1); const char *prefix = ""; const char *suffix = ""; if (is_tty) { prefix = "\x1b[31m\x1b[1m"; /* red, bold */ suffix = "\x1b[22m\x1b[0m"; /* bold off, color reset */ } g_printerr ("%serror: %s%s\n", prefix, suffix, error->message); g_error_free (error); } return ret; }