Exemplo n.º 1
0
static GsApp*
gs_plugin_app_from_pki (LiPkgInfo *pki)
{
	const gchar *cptkind_str;
	GsApp *app;

	cptkind_str = li_pkg_info_get_component_kind (pki);
	if ((cptkind_str != NULL) && (g_strcmp0 (cptkind_str, "desktop") == 0)) {
		g_autofree gchar *tmp = NULL;
		/* type=desktop AppStream components result in a Limba bundle name which has the .desktop stripped away.
		 * We need to re-add it for GNOME Software.
		 * In any other case, the Limba bundle name equals the AppStream ID of the component it contains */
		tmp = g_strdup_printf ("%s.desktop", li_pkg_info_get_name (pki));
		app = gs_app_new (tmp);
		gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
	} else {
		app = gs_app_new (li_pkg_info_get_name (pki));
		gs_app_set_kind (app, AS_APP_KIND_GENERIC);
	}

	/* TODO: scope?, branch? */
	gs_app_set_management_plugin (app, "limba");
	gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
	gs_app_set_bundle_kind (app, AS_BUNDLE_KIND_LIMBA);
	gs_app_set_name (app,
			 GS_APP_QUALITY_LOWEST,
			 li_pkg_info_get_name (pki));
	gs_app_set_summary (app,
			    GS_APP_QUALITY_LOWEST,
			    li_pkg_info_get_name (pki));
	gs_app_set_version (app, li_pkg_info_get_version (pki));
	gs_app_add_source (app, li_pkg_info_get_id (pki));

	return app;
}
Exemplo n.º 2
0
/**
 * gs_plugin_add_updates:
 */
gboolean
gs_plugin_add_updates (GsPlugin *plugin,
			GList **list,
			GCancellable *cancellable,
			GError **error)
{
	g_autoptr(GList) updates = NULL;
	GList *l;
	g_autoptr(GError) error_local = NULL;

	updates = li_manager_get_update_list (plugin->priv->mgr, &error_local);
	if (error_local != NULL) {
		g_set_error (error,
				GS_PLUGIN_ERROR,
				GS_PLUGIN_ERROR_FAILED,
				"Failed to list updates: %s",
				error_local->message);
		return FALSE;
	}

	for (l = updates; l != NULL; l = l->next) {
		LiPkgInfo *old_pki;
		LiPkgInfo *new_pki;
		const gchar *cptkind_str;
		g_autoptr(GsApp) app = NULL;
		LiUpdateItem *uitem = LI_UPDATE_ITEM (l->data);

		old_pki = li_update_item_get_installed_pkg (uitem);
		new_pki = li_update_item_get_available_pkg (uitem);

		cptkind_str = li_pkg_info_get_component_kind (old_pki);
		if ((cptkind_str != NULL) && (g_strcmp0 (cptkind_str, "desktop") == 0)) {
			g_autofree gchar *tmp = NULL;
			/* type=desktop AppStream components result in a Limba bundle name which has the .desktop stripped away.
			 * We need to re-add it for GNOME Software.
			 * In any other case, the Limba bundle name equals the AppStream ID of the component it contains */
			tmp = g_strdup_printf ("%s.desktop", li_pkg_info_get_name (old_pki));
			app = gs_app_new (tmp);
			gs_app_set_kind (app, AS_APP_KIND_DESKTOP);
		} else {
			app = gs_app_new (li_pkg_info_get_name (old_pki));
		}

		gs_app_set_management_plugin (app, "Limba");
		gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
		gs_app_set_kind (app, AS_APP_KIND_GENERIC);
		gs_plugin_add_app (list, app);
		gs_app_set_name (app,
				 GS_APP_QUALITY_LOWEST,
				 li_pkg_info_get_name (old_pki));
		gs_app_set_summary (app,
				    GS_APP_QUALITY_LOWEST,
				    li_pkg_info_get_name (old_pki));
		gs_app_set_version (app,
				    li_pkg_info_get_version (old_pki));
		gs_app_set_update_version (app,
					   li_pkg_info_get_version (new_pki));
		gs_app_add_source (app,
				   li_pkg_info_get_id (old_pki));
		gs_plugin_add_app (list, app);
	}

	return TRUE;
}