static gboolean handle_get_os (RPMOSTreeSysroot *object, GDBusMethodInvocation *invocation, const char *arg_name) { RpmostreedSysroot *self = RPMOSTREED_SYSROOT (object); glnx_unref_object GDBusInterfaceSkeleton *os_interface = NULL; if (arg_name[0] == '\0') { rpmostree_sysroot_complete_get_os (object, invocation, rpmostree_sysroot_dup_booted (object)); goto out; } os_interface = g_hash_table_lookup (self->os_interfaces, arg_name); if (os_interface != NULL) g_object_ref (os_interface); if (os_interface != NULL) { const char *object_path; object_path = g_dbus_interface_skeleton_get_object_path (os_interface); rpmostree_sysroot_complete_get_os (object, invocation, object_path); } else { g_dbus_method_invocation_return_error (invocation, G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "OS name \"%s\" not found", arg_name); } out: return TRUE; }
gboolean rpmostree_load_os_proxies (RPMOSTreeSysroot *sysroot_proxy, gchar *opt_osname, GCancellable *cancellable, RPMOSTreeOS **out_os_proxy, RPMOSTreeOSExperimental **out_osexperimental_proxy, GError **error) { g_autofree char *os_object_path = NULL; if (opt_osname == NULL) os_object_path = rpmostree_sysroot_dup_booted (sysroot_proxy); if (os_object_path == NULL) { /* Usually if opt_osname is null and the property isn't populated that means the daemon isn't listen on the bus make the call anyways to get the standard error. */ if (!opt_osname) opt_osname = ""; if (!rpmostree_sysroot_call_get_os_sync (sysroot_proxy, opt_osname, &os_object_path, cancellable, error)) return FALSE; } /* owned by sysroot_proxy */ GDBusConnection *connection = g_dbus_proxy_get_connection (G_DBUS_PROXY (sysroot_proxy)); const char *bus_name; if (g_dbus_connection_get_unique_name (connection) != NULL) bus_name = BUS_NAME; glnx_unref_object RPMOSTreeOS *os_proxy = rpmostree_os_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, bus_name, os_object_path, cancellable, error); if (os_proxy == NULL) return FALSE; glnx_unref_object RPMOSTreeOSExperimental *ret_osexperimental_proxy = NULL; if (out_osexperimental_proxy) { ret_osexperimental_proxy = rpmostree_osexperimental_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, bus_name, os_object_path, cancellable, error); if (!ret_osexperimental_proxy) return FALSE; } *out_os_proxy = g_steal_pointer (&os_proxy); if (out_osexperimental_proxy) *out_osexperimental_proxy = g_steal_pointer (&ret_osexperimental_proxy); return TRUE; }