/** * gs_plugin_setup: */ gboolean gs_plugin_setup (GsPlugin *plugin, GCancellable *cancellable, GError **error) { GsPluginData *priv = gs_plugin_get_data (plugin); g_autofree gchar *install_path = NULL; g_autoptr(AsProfileTask) ptask = NULL; g_autoptr(GFile) install_file = NULL; /* If we're running INSIDE the xdg-app environment we'll have the * env var XDG_DATA_HOME set to "~/.var/app/org.gnome.Software/data" * so specify the path manually to get the real data */ install_path = g_build_filename (g_get_home_dir (), ".local", "share", "xdg-app", NULL); install_file = g_file_new_for_path (install_path); /* FIXME: this should default to system-wide, but we need a permissions * helper to elevate privs */ ptask = as_profile_start_literal (gs_plugin_get_profile (plugin), "xdg-app::ensure-origin"); priv->installation = xdg_app_installation_new_for_path (install_file, TRUE, cancellable, error); if (priv->installation == NULL) return FALSE; /* watch for changes */ priv->monitor = xdg_app_installation_create_monitor (priv->installation, cancellable, error); if (priv->monitor == NULL) return FALSE; g_signal_connect (priv->monitor, "changed", G_CALLBACK (gs_plugin_xdg_app_changed_cb), plugin); /* success */ return TRUE; }
void XdgAppBackend::initialize() throw(InitializationFailedException) { // Don't reinitialize if (m_installation != nullptr) return; // TODO: Do something with these GCancellable *cancellable = nullptr; GError *error = nullptr; m_installation = xdg_app_installation_new_user(cancellable, &error); if (m_installation == nullptr) throw InitializationFailedException(error); m_monitor = xdg_app_installation_create_monitor(m_installation, cancellable, &error); if (m_monitor == nullptr) throw InitializationFailedException(error); g_signal_connect(m_monitor, "changed", G_CALLBACK(xdgAppChanged), this); }