コード例 #1
0
/**
 * gs_plugin_xdg_app_set_metadata_installed:
 */
static void
gs_plugin_xdg_app_set_metadata_installed (GsApp *app, XdgAppInstalledRef *xref)
{
	guint64 mtime;
	guint64 size_installed;
	g_autofree gchar *metadata_fn = NULL;
	g_autoptr(GFile) file = NULL;
	g_autoptr(GFileInfo) info = NULL;

	/* for all types */
	gs_plugin_xdg_app_set_metadata (app, XDG_APP_REF (xref));

	/* get the last time the app was updated */
	metadata_fn = g_build_filename (xdg_app_installed_ref_get_deploy_dir (xref),
					"..",
					"active",
					NULL);
	file = g_file_new_for_path (metadata_fn);
	info = g_file_query_info (file,
				  G_FILE_ATTRIBUTE_TIME_MODIFIED,
				  G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
				  NULL, NULL);
	if (info != NULL) {
		mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
		gs_app_set_install_date (app, mtime);
	}

	/* this is faster than resolving */
	gs_app_set_origin (app, xdg_app_installed_ref_get_origin (xref));

	/* this is faster than xdg_app_installation_fetch_remote_size_sync() */
	size_installed = xdg_app_installed_ref_get_installed_size (xref);
	if (size_installed != 0)
		gs_app_set_size_installed (app, size_installed);
}
コード例 #2
0
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);
}