/** * gs_plugin_add_updates: */ gboolean gs_plugin_add_updates (GsPlugin *plugin, GList **list, GCancellable *cancellable, GError **error) { GsPluginData *priv = gs_plugin_get_data (plugin); guint i; g_autoptr(GPtrArray) xrefs = NULL; /* get all the installed apps (no network I/O) */ xrefs = xdg_app_installation_list_installed_refs (priv->installation, cancellable, error); if (xrefs == NULL) return FALSE; for (i = 0; i < xrefs->len; i++) { XdgAppInstalledRef *xref = g_ptr_array_index (xrefs, i); const gchar *commit; const gchar *latest_commit; g_autoptr(GsApp) app = NULL; g_autoptr(GError) error_local = NULL; /* check the application has already been downloaded */ commit = xdg_app_ref_get_commit (XDG_APP_REF (xref)); latest_commit = xdg_app_installed_ref_get_latest_commit (xref); if (g_strcmp0 (commit, latest_commit) == 0) { g_debug ("no downloaded update for %s", xdg_app_ref_get_name (XDG_APP_REF (xref))); continue; } /* we have an update to show */ g_debug ("%s has a downloaded update %s->%s", xdg_app_ref_get_name (XDG_APP_REF (xref)), commit, latest_commit); app = gs_plugin_xdg_app_create_installed (plugin, xref, &error_local); if (app == NULL) { g_warning ("failed to add xdg-app: %s", error_local->message); continue; } if (gs_app_get_state (app) == AS_APP_STATE_INSTALLED) gs_app_set_state (app, AS_APP_STATE_UNKNOWN); gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE); gs_app_list_add (list, app); } return TRUE; }
XdgApplication::XdgApplication(XdgAppInstalledRef *app_ref, SoftwareBackend *backend) : Application(backend) { m_state = Application::Installed; m_id = xdg_app_ref_get_name(XDG_APP_REF(app_ref)); m_branch = xdg_app_ref_get_branch(XDG_APP_REF(app_ref)); m_origin = xdg_app_installed_ref_get_origin(app_ref); m_name = m_id; m_arch = xdg_app_ref_get_arch(XDG_APP_REF(app_ref)); m_currentCommit = xdg_app_ref_get_commit(XDG_APP_REF(app_ref)); m_latestCommit = xdg_app_installed_ref_get_latest_commit(app_ref); if (m_branch.isEmpty()) m_branch = "master"; QString desktopId; switch (xdg_app_ref_get_kind(XDG_APP_REF(app_ref))) { case XDG_APP_REF_KIND_APP: m_type = Application::App; desktopId = m_name + ".desktop"; break; case XDG_APP_REF_KIND_RUNTIME: m_type = Application::Runtime; m_icon = QIcon::fromTheme("package-x-generic"); m_summary = "Framework for applications"; desktopId = m_name + ".runtime"; break; default: // TODO: Handle errors here! break; } QString deployDir = xdg_app_installed_ref_get_deploy_dir(app_ref); QString desktopPath = deployDir + "/files/share/applications"; QString appdataPath = deployDir + "/files/share/appdata"; Appstream::Store store; store.load(desktopPath); store.load(appdataPath); Appstream::Component component = store.componentById(desktopId); if (!component.isNull()) refineFromAppstream(component); }