/* command-list.c * * Copyright 2018 Florian Müllner * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * * SPDX-License-Identifier: GPL-3.0-or-later */ #include #include #include "commands.h" #include "common.h" static gboolean list_extensions (void) { g_autoptr (GDBusProxy) proxy = NULL; g_autoptr (GVariant) response = NULL; g_autoptr (GVariant) extensions = NULL; g_autoptr (GError) error = NULL; GVariantIter iter; GVariant *value; char *uuid; proxy = get_shell_proxy (&error); if (proxy == NULL) return FALSE; response = g_dbus_proxy_call_sync (proxy, "ListExtensions", NULL, 0, -1, NULL, &error); if (response == NULL) return FALSE; extensions = g_variant_get_child_value (response, 0); g_variant_iter_init (&iter, extensions); while (g_variant_iter_loop (&iter, "{s@a{sv}}", &uuid, &value)) g_print ("%s\n", uuid); return TRUE; } int handle_list (int argc, char *argv[], gboolean do_help) { g_autoptr (GOptionContext) context = NULL; g_autoptr (GError) error = NULL; g_set_prgname ("gnome-extensions list"); context = g_option_context_new (NULL); g_option_context_set_help_enabled (context, FALSE); g_option_context_set_summary (context, _("List installed extensions")); if (do_help) { show_help (context, NULL); return 0; } if (!g_option_context_parse (context, &argc, &argv, &error)) { show_help (context, error->message); return 1; } if (argc > 1) { show_help (context, _("Unknown arguments")); return 1; } return list_extensions () ? 0 : 2; }