socsvn commit: r254265 - in soc2013/mattbw/backend: . actions

mattbw at FreeBSD.org mattbw at FreeBSD.org
Sat Jul 6 23:59:28 UTC 2013


Author: mattbw
Date: Sat Jul  6 23:59:27 2013
New Revision: 254265
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=254265

Log:
  major cleanup and removal of dummy stubs

Modified:
  soc2013/mattbw/backend/Makefile
  soc2013/mattbw/backend/actions/get-files.c
  soc2013/mattbw/backend/actions/get-repo-list.c
  soc2013/mattbw/backend/actions/install-packages.c
  soc2013/mattbw/backend/pk-backend-pkgng.c
  soc2013/mattbw/backend/query.c

Modified: soc2013/mattbw/backend/Makefile
==============================================================================
--- soc2013/mattbw/backend/Makefile	Sat Jul  6 22:51:56 2013	(r254264)
+++ soc2013/mattbw/backend/Makefile	Sat Jul  6 23:59:27 2013	(r254265)
@@ -15,6 +15,7 @@
 		actions/get-details.c		\
 		actions/get-files.c		\
 		actions/get-repo-list.c		\
+		actions/install-files.c		\
 		actions/install-packages.c
 
 LIBDIR=		/usr/local/lib/packagekit-backend

Modified: soc2013/mattbw/backend/actions/get-files.c
==============================================================================
--- soc2013/mattbw/backend/actions/get-files.c	Sat Jul  6 22:51:56 2013	(r254264)
+++ soc2013/mattbw/backend/actions/get-files.c	Sat Jul  6 23:59:27 2013	(r254265)
@@ -44,6 +44,7 @@
 get_files_thread(PkBackend *backend)
 {
 
+	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
 	return query_match_id_to_emitter(backend, LOAD_FLAGS, emit);
 }
 

Modified: soc2013/mattbw/backend/actions/get-repo-list.c
==============================================================================
--- soc2013/mattbw/backend/actions/get-repo-list.c	Sat Jul  6 22:51:56 2013	(r254264)
+++ soc2013/mattbw/backend/actions/get-repo-list.c	Sat Jul  6 23:59:27 2013	(r254265)
@@ -37,11 +37,17 @@
 
 	repo = NULL;
 
+	(void)pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
+	(void)pk_backend_set_percentage(backend,
+	    PK_BACKEND_PERCENTAGE_INVALID);
+
 	for (HASH_FOR(err, pkg_repos, &repo))
 		pk_backend_repo_detail(backend,
 				       pkg_repo_ident(repo),
 				       pkg_repo_name(repo),
 				       pkg_repo_enabled(repo));
 
+	(void)pk_backend_finished(backend);
+
 	return (err == EPKG_END ? TRUE : FALSE);
 }

Modified: soc2013/mattbw/backend/actions/install-packages.c
==============================================================================
--- soc2013/mattbw/backend/actions/install-packages.c	Sat Jul  6 22:51:56 2013	(r254264)
+++ soc2013/mattbw/backend/actions/install-packages.c	Sat Jul  6 23:59:27 2013	(r254265)
@@ -45,6 +45,7 @@
 install_packages_thread(PkBackend *backend)
 {
 
+	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
 	return query_match_id_to_job(backend, PKG_JOBS_INSTALL, job);
 }
 

Modified: soc2013/mattbw/backend/pk-backend-pkgng.c
==============================================================================
--- soc2013/mattbw/backend/pk-backend-pkgng.c	Sat Jul  6 22:51:56 2013	(r254264)
+++ soc2013/mattbw/backend/pk-backend-pkgng.c	Sat Jul  6 23:59:27 2013	(r254265)
@@ -23,8 +23,6 @@
 #include <glib.h>
 #include <string.h>
 #include <stdlib.h>
-#include <gio/gio.h>
-#include <gio/gunixsocketaddress.h>
 
 #include "pk-backend.h"
 #include "pkg.h"
@@ -33,23 +31,6 @@
 #include "groups.h"		/* available_groups */
 #include "actions/actions.h"	/* Actions threads */
 
-/* static bodges */
-static guint	_progress_percentage = 0;
-static gulong	_signal_timeout = 0;
-static gchar  **_package_ids;
-static gchar  **_values;
-static guint	_package_current = 0;
-static gboolean	_updated_gtkhtml = FALSE;
-static gboolean	_updated_kernel = FALSE;
-static gboolean	_updated_powertop = FALSE;
-static gboolean	_has_signature = FALSE;
-static gboolean	_use_eula = FALSE;
-static gboolean	_use_gpg = FALSE;
-static gboolean	_use_distro_upgrade = FALSE;
-static PkBitfield _filters = 0;
-static GSocket *_socket = NULL;
-static guint	_socket_listen_id = 0;
-
 /**
  * pk_backend_initialize:
  */
@@ -58,8 +39,6 @@
 {
 	int		err;
 
-	_progress_percentage = 0;
-
 	err = EPKG_OK;
 
 	if (!pkg_initialized())
@@ -81,1190 +60,120 @@
 	pkg_shutdown();
 }
 
-/*
- * Return all groups available from this backend.
- * 
- * The business end of this function is in "groups.c".
- */
-PkBitfield
-pk_backend_get_groups(PkBackend *backend)
-{
-
-	INTENTIONALLY_IGNORE(backend);
-	return available_groups();
-}
-
-/**
- * pk_backend_get_filters:
- */
-PkBitfield
-pk_backend_get_filters(PkBackend *backend)
+gchar          *
+pk_backend_get_description(PkBackend *backend)
 {
 
 	INTENTIONALLY_IGNORE(backend);
-	return pk_bitfield_from_enums(PK_FILTER_ENUM_GUI,
-	    PK_FILTER_ENUM_INSTALLED,
-	    PK_FILTER_ENUM_DEVELOPMENT,
-	    -1);
+	return g_strdup("pkgng");
 }
 
-/**
- * pk_backend_get_mime_types:
- */
 gchar          *
-pk_backend_get_mime_types(PkBackend *backend)
+pk_backend_get_author(PkBackend *backend)
 {
 
 	INTENTIONALLY_IGNORE(backend);
-	return g_strdup("application/x-rpm;application/x-deb");
+	return g_strdup("Matt Windsor <mattbw at FreeBSD.org>");
 }
 
-/*
- * To implement:
- * 
- * - pk_backend_cancel
- */
-
 /**
- * pk_backend_get_depends:
+ * ACTION STUBS
+ *
+ * In roughly alphabetical order; usually the thread code corresponding to these
+ * can be found in actions/name_of_action.c.
+ *
+ * If an action is missing here and not otherwise mentioned, it is probably
+ * awaiting implementation.
+ *
+ * Not supported due to unavailable pkgng features:
+ * - pk_backend_get_files on a non-installed package
+ * - pk_backend_repo_enable
+ * - pk_backend_repo_set_data
  */
-void
-pk_backend_get_depends(PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive)
-{
-	INTENTIONALLY_IGNORE(filters);
-	INTENTIONALLY_IGNORE(recursive);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-
-	if (g_strcmp0(package_ids[0], "scribus;1.3.4-1.fc8;i386;fedora") == 0) {
-		pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-		    "scribus-clipart;1.3.4-1.fc8;i386;fedora", "Clipart for scribus");
-	} else {
-		pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-		    "glib2;2.14.0;i386;fedora", "The GLib library");
-		pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-		    "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
-	}
-	pk_backend_finished(backend);
-}
 
-/*
- * Spawns a thread to get the details of the package IDs requested. The
- * thread code proper is in "get-details.c".
- */
 void
 pk_backend_get_details(PkBackend *backend, gchar **package_ids)
 {
-	INTENTIONALLY_IGNORE(package_ids);	/* can be retrieved from
-						 * backend */
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
 
+	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
 	pk_backend_thread_create(backend, get_details_thread);
 }
 
-/**
- * pk_backend_get_distro_upgrades:
- */
-void
-pk_backend_get_distro_upgrades(PkBackend *backend)
-{
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	if (!_use_distro_upgrade)
-		goto out;
-	pk_backend_distro_upgrade(backend, PK_DISTRO_UPGRADE_ENUM_STABLE,
-	    "fedora-9", "Fedora 9");
-	pk_backend_distro_upgrade(backend, PK_DISTRO_UPGRADE_ENUM_UNSTABLE,
-	    "fedora-10-rc1", "Fedora 10 RC1");
-out:
-	pk_backend_finished(backend);
-}
-
-/**
- * pk_backend_get_files:
- */
 void
 pk_backend_get_files(PkBackend *backend, gchar **package_ids)
 {
-	INTENTIONALLY_IGNORE(package_ids);	/* can be retrieved from
-						 * backend */
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
 
+	INTENTIONALLY_IGNORE(package_ids);	/* retrieved from backend */
 	pk_backend_thread_create(backend, get_files_thread);
 }
 
-/**
- * pk_backend_get_requires:
- */
-void
-pk_backend_get_requires(PkBackend *backend, PkBitfield filters, gchar **package_ids, gboolean recursive)
-{
-	INTENTIONALLY_IGNORE(filters);
-	INTENTIONALLY_IGNORE(package_ids);
-	INTENTIONALLY_IGNORE(recursive);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-	    "glib2;2.14.0;i386;fedora", "The GLib library");
-	pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-	    "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
-	pk_backend_finished(backend);
-}
-
-/**
- * pk_backend_get_update_detail_timeout:
- **/
-static gboolean
-pk_backend_get_update_detail_timeout(gpointer data)
-{
-	guint		i;
-	guint		len;
-	const gchar    *package_id;
-	PkBackend      *backend = (PkBackend *)data;
-	const gchar    *changelog;
-
-	/* dummy */
-	changelog = "**Thu Mar 12 2009** Adam Jackson <ajax at redhat.com> 1.6.0-13\n"
-	    "- xselinux-1.6.0-selinux-nlfd.patch: Acquire the netlink socket from selinux,\n"
-	    "  check it ourselves rather than having libselinux bang on it all the time.\n"
-	    "\n"
-	    "**Wed Mar 11 2009** Adam Jackson <ajax at redhat.com> 1.6.0-10\n"
-	    "- xserver-1.6.0-selinux-less.patch: Don't init selinux unless the policy\n"
-	    "  says to be an object manager.\n"
-	    "\n"
-	    "**Wed Mar 11 2009** Adam Jackson <ajax at redhat.com> 1.6.0-11\n"
-	    "- xserver-1.6.0-less-acpi-brokenness.patch: Don't build the (broken)\n"
-	    "  ACPI code.\n"
-	    "\n"
-	    "**Wed Mar 11 2009** Adam Jackson <ajax at redhat.com> 1.6.0-12\n"
-	    "- Requires: pixman >= 0.14.0\n"
-	    "\n"
-	    "**Fri Mar  6 2009** Adam Jackson <ajax at redhat.com> 1.6.0-8\n"
-	    "- xserver-1.6.0-primary.patch: Really, only look at VGA devices. (#488869)\n";
-
-	/* each one has a different detail for testing */
-	pk_backend_set_percentage(backend, 0);
-	len = g_strv_length(_package_ids);
-	for (i = 0; i < len; i++) {
-		package_id = _package_ids[i];
-		if (g_strcmp0(package_id, "powertop;1.8-1.fc8;i386;fedora") == 0) {
-			pk_backend_update_detail(backend, package_id,
-			    "powertop;1.7-1.fc8;i386;installed", "",
-			    "http://www.distro-update.org/page?moo;Bugfix release for powertop",
-			    "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344",
-			    "", PK_RESTART_ENUM_NONE, "Update to newest upstream source",
-			    changelog, PK_UPDATE_STATE_ENUM_STABLE, "2009-11-17T09:19:00", "2009-11-19T09:19:00");
-		} else if (g_strcmp0(package_id, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed") == 0) {
-			pk_backend_update_detail(backend, package_id,
-			    "kernel;2.6.22-0.104.rc3.git6.fc8;i386;installed"
-			    PK_PACKAGE_IDS_DELIM
-			    "kernel;2.6.22-0.105.rc3.git7.fc8;i386;installed", "",
-			    "http://www.distro-update.org/page?moo;Bugfix release for kernel",
-			    "http://bgzilla.fd.org/result.php?#12344;Freedesktop Bugzilla #12344;"
-			    "http://bgzilla.gnome.org/result.php?#9876;GNOME Bugzilla #9876",
-			    "http://nvd.nist.gov/nvd.cfm?cvename=CVE-2007-3381;CVE-2007-3381",
-			    PK_RESTART_ENUM_SYSTEM,
-			    "Update to newest upstream version.\n"
-			    "* This should fix many driver bugs when using nouveau\n"
-			    " * This also introduces the new `frobnicator` driver for *vibrating* rabbit hardware.",
-			    changelog, PK_UPDATE_STATE_ENUM_UNSTABLE, "2008-06-28T09:19:00", NULL);
-		} else if (g_strcmp0(package_id, "gtkhtml2;2.19.1-4.fc8;i386;fedora") == 0) {
-			pk_backend_update_detail(backend, package_id,
-			    "gtkhtml2;2.18.1-22.fc8;i386;installed", "",
-			    "http://www.distro-update.org/page?moo;Bugfix release for gtkhtml",
-			    "http://bgzilla.gnome.org/result.php?#9876;GNOME Bugzilla #9876",
-			    NULL, PK_RESTART_ENUM_SESSION,
-			    "Update to latest *whizz* **bang** version\n"
-			    "* support this new thing\n"
-			    "* something else\n"
-			    "- and that new thing",
-			    changelog, PK_UPDATE_STATE_ENUM_UNKNOWN, "2008-07-25T09:19:00", NULL);
-
-		} else if (g_strcmp0(package_id, "vino;2.24.2.fc9;i386;fedora") == 0) {
-			pk_backend_update_detail(backend, package_id,
-			    "vino;2.24.1.fc9;i386;fedora", "",
-			    "", "", NULL, PK_RESTART_ENUM_NONE,
-			    "Cannot get update as update conflics with vncviewer",
-			    changelog, PK_UPDATE_STATE_ENUM_UNKNOWN, "2008-07-25", NULL);
-		} else {
-			/* signal to UI */
-			pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "the package update detail was not found for %s", package_id);
-		}
-	}
-	pk_backend_set_percentage(backend, 100);
-	pk_backend_finished(backend);
-	_signal_timeout = 0;
-	return FALSE;
-}
-
-/**
- * pk_backend_get_update_detail:
- */
-void
-pk_backend_get_update_detail(PkBackend *backend, gchar **package_ids)
-{
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	_package_ids = package_ids;
-	_signal_timeout = g_timeout_add(500, pk_backend_get_update_detail_timeout, backend);
-}
-
-/**
- * pk_backend_get_updates_timeout:
- **/
-static gboolean
-pk_backend_get_updates_timeout(gpointer data)
-{
-	PkBackend      *backend = (PkBackend *)data;
-
-	if (!_updated_powertop) {
-		pk_backend_package(backend, PK_INFO_ENUM_NORMAL,
-		    "powertop;1.8-1.fc8;i386;fedora",
-		    "Power consumption monitor");
-	}
-	if (!_updated_kernel) {
-		pk_backend_package(backend, PK_INFO_ENUM_BUGFIX,
-		    "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
-		    "The Linux kernel (the core of the Linux operating system)");
-	}
-	if (!_updated_gtkhtml) {
-		pk_backend_package(backend, PK_INFO_ENUM_SECURITY,
-		    "gtkhtml2;2.19.1-4.fc8;i386;fedora",
-		    "An HTML widget for GTK+ 2.0");
-	}
-	pk_backend_finished(backend);
-	_signal_timeout = 0;
-	return FALSE;
-}
-
-/**
- * pk_backend_get_updates:
- */
-void
-pk_backend_get_updates(PkBackend *backend, PkBitfield filters)
-{
-	INTENTIONALLY_IGNORE(filters);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
-	/* check network state */
-	if (!pk_backend_is_online(backend)) {
-		pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot check when offline");
-		pk_backend_finished(backend);
-		return;
-	}
-	_signal_timeout = g_timeout_add(1000, pk_backend_get_updates_timeout, backend);
-}
-
-/**
- * pk_backend_install_packages:
- */
-void
-pk_backend_install_packages(PkBackend *backend, gboolean only_trusted, gchar **package_ids)
-{
-	INTENTIONALLY_IGNORE(only_trusted);
-	INTENTIONALLY_IGNORE(package_ids);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
-
-	pk_backend_thread_create(backend, install_packages_thread);
-}
-
-/**
- * pk_backend_install_signature:
- */
-void
-pk_backend_install_signature(PkBackend *backend, PkSigTypeEnum type,
-    const gchar *key_id, const gchar *package_id)
-{
-	pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL);
-	if (type == PK_SIGTYPE_ENUM_GPG &&
-	/* egg_strequal (package_id, "vips-doc;7.12.4-2.fc8;noarch;linva") && */
-	    g_strcmp0(key_id, "BB7576AC") == 0) {
-		g_debug("installed signature %s for %s", key_id, package_id);
-		_has_signature = TRUE;
-	} else {
-		pk_backend_error_code(backend, PK_ERROR_ENUM_GPG_FAILURE,
-		    "GPG key %s not recognised for package_id %s",
-		    key_id, package_id);
-	}
-	pk_backend_finished(backend);
-}
-
-/**
- * pk_backend_refresh_cache_timeout:
- */
-static gboolean
-pk_backend_install_files_timeout(gpointer data)
-{
-	PkBackend      *backend = (PkBackend *)data;
-	pk_backend_finished(backend);
-	return FALSE;
-}
-
-/**
- * pk_backend_install_files:
- */
-void
-pk_backend_install_files(PkBackend *backend, gboolean only_trusted, gchar **full_paths)
-{
-	INTENTIONALLY_IGNORE(only_trusted);
-	INTENTIONALLY_IGNORE(full_paths);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_INSTALL);
-	pk_backend_set_percentage(backend, 101);
-	_signal_timeout = g_timeout_add(2000, pk_backend_install_files_timeout, backend);
-}
-
-/**
- * pk_backend_refresh_cache_timeout:
- */
-static gboolean
-pk_backend_refresh_cache_timeout(gpointer data)
-{
-	PkBackend      *backend = (PkBackend *)data;
-	if (_progress_percentage == 100) {
-		pk_backend_finished(backend);
-		return FALSE;
-	}
-	if (_progress_percentage == 80)
-		pk_backend_set_allow_cancel(backend, FALSE);
-	_progress_percentage += 10;
-	pk_backend_set_percentage(backend, _progress_percentage);
-	return TRUE;
-}
-
-/**
- * pk_backend_refresh_cache:
- */
-void
-pk_backend_refresh_cache(PkBackend *backend, gboolean force)
-{
-	INTENTIONALLY_IGNORE(force);
-
-	_progress_percentage = 0;
-
-	/* reset */
-	_updated_gtkhtml = FALSE;
-	_updated_kernel = FALSE;
-	_updated_powertop = FALSE;
-
-	pk_backend_set_allow_cancel(backend, TRUE);
-	pk_backend_set_status(backend, PK_STATUS_ENUM_REFRESH_CACHE);
-	_signal_timeout = g_timeout_add(500, pk_backend_refresh_cache_timeout, backend);
-}
-
-/**
- * pk_backend_resolve_timeout:
- */
-static gboolean
-pk_backend_resolve_timeout(gpointer data)
-{
-	PkBackend      *backend = (PkBackend *)data;
-	guint		i;
-	guint		len;
-	gchar         **packages = _package_ids;
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_percentage(backend, 0);
-
-	/* each one has a different detail for testing */
-	len = g_strv_length(packages);
-	for (i = 0; i < len; i++) {
-		if (g_strcmp0(packages[i], "vips-doc") == 0 || g_strcmp0(packages[i], "vips-doc;7.12.4-2.fc8;noarch;linva") == 0) {
-			if (!pk_bitfield_contain(_filters, PK_FILTER_ENUM_INSTALLED)) {
-				pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-				    "vips-doc;7.12.4-2.fc8;noarch;linva", "The vips documentation package.");
-			}
-		} else if (g_strcmp0(packages[i], "glib2") == 0 || g_strcmp0(packages[i], "glib2;2.14.0;i386;fedora") == 0) {
-			if (!pk_bitfield_contain(_filters, PK_FILTER_ENUM_NOT_INSTALLED)) {
-				pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-				    "glib2;2.14.0;i386;fedora", "The GLib library");
-			}
-		} else if (g_strcmp0(packages[i], "powertop") == 0 || g_strcmp0(packages[i], "powertop;1.8-1.fc8;i386;fedora") == 0)
-			pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-			    "powertop;1.8-1.fc8;i386;fedora", "Power consumption monitor");
-		else if (g_strcmp0(packages[i], "kernel") == 0 || g_strcmp0(packages[i], "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed") == 0)
-			pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-			    "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed", "The Linux kernel (the core of the Linux operating system)");
-		else if (g_strcmp0(packages[i], "gtkhtml2") == 0 || g_strcmp0(packages[i], "gtkhtml2;2.19.1-4.fc8;i386;fedora") == 0)
-			pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-			    "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0");
-	}
-	pk_backend_set_percentage(backend, 100);
-	pk_backend_finished(backend);
-
-	/* never repeat */
-	return FALSE;
-}
-
-/**
- * pk_backend_resolve:
- */
-void
-pk_backend_resolve(PkBackend *backend, PkBitfield filters, gchar **packages)
-{
-	_filters = filters;
-	_package_ids = packages;
-	_signal_timeout = g_timeout_add(20, pk_backend_resolve_timeout, backend);
-}
-
-/**
- * pk_backend_rollback_timeout:
- */
-static gboolean
-pk_backend_rollback_timeout(gpointer data)
-{
-	PkBackend      *backend = (PkBackend *)data;
-	if (_progress_percentage == 0) {
-		_updated_gtkhtml = FALSE;
-		_updated_kernel = FALSE;
-		_updated_powertop = FALSE;
-		pk_backend_set_status(backend, PK_STATUS_ENUM_ROLLBACK);
-	}
-	if (_progress_percentage == 20)
-		pk_backend_set_allow_cancel(backend, FALSE);
-	if (_progress_percentage == 100) {
-		pk_backend_finished(backend);
-		return FALSE;
-	}
-	_progress_percentage += 10;
-	pk_backend_set_percentage(backend, _progress_percentage);
-	return TRUE;
-}
-
-
-/**
- * pk_backend_rollback:
- */
-void
-pk_backend_rollback(PkBackend *backend, const gchar *transaction_id)
-{
-	/* allow testing error condition */
-	if (g_strcmp0(transaction_id, "/397_eeecadad_data") == 0) {
-		pk_backend_error_code(backend, PK_ERROR_ENUM_TRANSACTION_ERROR, "invalid transaction_id");
-		pk_backend_finished(backend);
-		return;
-	}
-	_progress_percentage = 0;
-	pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
-	pk_backend_set_allow_cancel(backend, TRUE);
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	_signal_timeout = g_timeout_add(2000, pk_backend_rollback_timeout, backend);
-}
-
-/**
- * pk_backend_remove_packages:
- */
-void
-pk_backend_remove_packages(PkBackend *backend, gchar **package_ids, gboolean allow_deps, gboolean autoremove)
-{
-	INTENTIONALLY_IGNORE(package_ids);
-	INTENTIONALLY_IGNORE(allow_deps);
-	INTENTIONALLY_IGNORE(autoremove);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_REMOVE);
-	pk_backend_error_code(backend, PK_ERROR_ENUM_NO_NETWORK, "No network connection available");
-	pk_backend_finished(backend);
-}
-
-/**
- * pk_backend_search_details:
- */
-void
-pk_backend_search_details(PkBackend *backend, PkBitfield filters, gchar **values)
-{
-	INTENTIONALLY_IGNORE(filters);
-	INTENTIONALLY_IGNORE(values);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_allow_cancel(backend, TRUE);
-	pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-	    "vips-doc;7.12.4-2.fc8;noarch;linva",
-	    "The vips \"documentation\" package.");
-	pk_backend_finished(backend);
-}
-
-/**
- * pk_backend_search_files:
- */
-void
-pk_backend_search_files(PkBackend *backend, PkBitfield filters, gchar **values)
-{
-	INTENTIONALLY_IGNORE(values);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_allow_cancel(backend, TRUE);
-	if (!pk_bitfield_contain(filters, PK_FILTER_ENUM_INSTALLED))
-		pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-		    "vips-doc;7.12.4-2.fc8;noarch;linva",
-		    "The vips documentation package");
-	else
-		pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-		    "vips-doc;7.12.4-2.fc8;noarch;linva",
-		    "The vips documentation package");
-	pk_backend_finished(backend);
-}
-
-/**
- * pk_backend_search_groups:
- */
-void
-pk_backend_search_groups(PkBackend *backend, PkBitfield filters, gchar **values)
-{
-	INTENTIONALLY_IGNORE(filters);
-	INTENTIONALLY_IGNORE(values);
-
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	pk_backend_set_allow_cancel(backend, TRUE);
-	pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-	    "vips-doc;7.12.4-2.fc8;noarch;linva",
-	    "The vips documentation package.");
-	pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-	    "bǣwulf-utf8;0.1;noarch;hughsie",
-	    "The bǣwulf server test name.");
-	pk_backend_finished(backend);
-}
-
-/**
- * pk_backend_search_name_timeout:
- **/
-static gboolean
-pk_backend_search_name_timeout(gpointer data)
+PkBitfield
+pk_backend_get_filters(PkBackend *backend)
 {
-	gchar          *locale;
-	PkBackend      *backend = (PkBackend *)data;
-	locale = pk_backend_get_locale(backend);
-
-	g_debug("locale is %s", locale);
-	if (g_strcmp0(locale, "en_GB.utf8") != 0) {
-		pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-		    "evince;0.9.3-5.fc8;i386;installed",
-		    "PDF Dokument Ƥrŏgrȃɱ");
-	} else {
-		pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-		    "evince;0.9.3-5.fc8;i386;installed",
-		    "PDF Document viewer");
-	}
-	pk_backend_package(backend, PK_INFO_ENUM_INSTALLED,
-	    "tetex;3.0-41.fc8;i386;fedora",
-	    "TeTeX is an implementation of TeX for Linux or UNIX systems.");
-	pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-	    "scribus;1.3.4-1.fc8;i386;fedora",
-	    "Scribus is an desktop open source page layout program");
-	pk_backend_package(backend, PK_INFO_ENUM_AVAILABLE,
-	    "vips-doc;7.12.4-2.fc8;noarch;linva",
-	    "The vips documentation package.");
-	pk_backend_finished(backend);
-	return FALSE;
-}
 
-/**
- * pk_backend_search_names:
- */
-void
-pk_backend_search_names(PkBackend *backend, PkBitfield filters, gchar **values)
-{
-	INTENTIONALLY_IGNORE(filters);
-	INTENTIONALLY_IGNORE(values);
+	INTENTIONALLY_IGNORE(backend);
 
-	pk_backend_set_percentage(backend, PK_BACKEND_PERCENTAGE_INVALID);
-	pk_backend_set_allow_cancel(backend, TRUE);
-	pk_backend_set_status(backend, PK_STATUS_ENUM_QUERY);
-	_signal_timeout = g_timeout_add(2000, pk_backend_search_name_timeout, backend);
+	/* TODO: support more filters */
+	return pk_bitfield_from_enums(PK_FILTER_ENUM_INSTALLED,
+	    -1);
 }
 
-/**
- * pk_backend_update_packages_download_timeout:
- **/
-static gboolean
-pk_backend_update_packages_download_timeout(gpointer data)
+PkBitfield
+pk_backend_get_groups(PkBackend *backend)
 {
-	PkBackend      *backend = (PkBackend *)data;
-	guint		sub;
 
-	if (_progress_percentage == 100) {
-		pk_backend_finished(backend);
-		return FALSE;
-	}
-	if (_progress_percentage == 0 && !_updated_powertop) {
-		pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING,
-		    "powertop;1.8-1.fc8;i386;fedora",
-		    "Power consumption monitor");
-		pk_backend_set_sub_percentage(backend, 0);
-	}
-	if (_progress_percentage == 20 && !_updated_kernel) {
-		pk_backend_set_sub_percentage(backend, 100);
-		pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING,
-		    "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
-		    "The Linux kernel (the core of the Linux operating system)");
-		pk_backend_set_sub_percentage(backend, 0);
-		pk_backend_require_restart(backend, PK_RESTART_ENUM_SYSTEM, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed");
-	}
-	if (_progress_percentage == 30 && !_updated_gtkhtml) {
-		pk_backend_message(backend, PK_MESSAGE_ENUM_NEWER_PACKAGE_EXISTS, "A newer package preupgrade is available in fedora-updates-testing");
-		pk_backend_message(backend, PK_MESSAGE_ENUM_CONFIG_FILES_CHANGED, "/etc/X11/xorg.conf has been auto-merged, please check before rebooting");
-		pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing metadata is invalid");
-		pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-debuginfo metadata is invalid");
-		pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid");
-		pk_backend_set_sub_percentage(backend, 100);
-		pk_backend_package(backend, PK_INFO_ENUM_INSTALLING,
-		    "gtkhtml2;2.19.1-4.fc8;i386;fedora",
-		    "An HTML widget for GTK+ 2.0");
-		_updated_gtkhtml = TRUE;
-		pk_backend_set_sub_percentage(backend, 0);
-	}
-	if (_progress_percentage == 40 && !_updated_powertop) {
-		pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE);
-		pk_backend_set_allow_cancel(backend, FALSE);
-		pk_backend_set_sub_percentage(backend, 100);
-		pk_backend_package(backend, PK_INFO_ENUM_INSTALLING,
-		    "powertop;1.8-1.fc8;i386;fedora",
-		    "Power consumption monitor");
-		_updated_powertop = TRUE;
-		pk_backend_set_sub_percentage(backend, 0);
-	}
-	if (_progress_percentage == 60 && !_updated_kernel) {
-		pk_backend_set_sub_percentage(backend, 100);
-		pk_backend_package(backend, PK_INFO_ENUM_UPDATING,
-		    "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
-		    "The Linux kernel (the core of the Linux operating system)");
-		_updated_kernel = TRUE;
-		pk_backend_set_sub_percentage(backend, 0);
-	}
-	if (_progress_percentage == 80 && !_updated_kernel) {
-		pk_backend_set_sub_percentage(backend, 100);
-		pk_backend_package(backend, PK_INFO_ENUM_CLEANUP,
-		    "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
-		    "The Linux kernel (the core of the Linux operating system)");
-		pk_backend_set_sub_percentage(backend, 0);
-	}
-	_progress_percentage += 1;
-	pk_backend_set_percentage(backend, _progress_percentage);
-	sub = (_progress_percentage % 10) * 10;
-	if (sub != 0)
-		pk_backend_set_sub_percentage(backend, sub);
-	return TRUE;
-}
-
-/**
- * pk_backend_update_packages:
- */
-void
-pk_backend_update_packages(PkBackend *backend, gboolean only_trusted, gchar **package_ids)
-{
-	const gchar    *eula_id;
-	const gchar    *license_agreement;
-	gboolean	has_eula;
-
-	/* FIXME: support only_trusted */
-	INTENTIONALLY_IGNORE(only_trusted);
-
-	if (_use_gpg && !_has_signature) {
-		pk_backend_repo_signature_required(backend, package_ids[0], "updates",
-		    "http://example.com/gpgkey",
-		    "Test Key (Fedora) fedora at example.com",
-		    "BB7576AC",
-		    "D8CC 06C2 77EC 9C53 372F C199 B1EE 1799 F24F 1B08",
-		    "2007-10-04", PK_SIGTYPE_ENUM_GPG);
-		pk_backend_error_code(backend, PK_ERROR_ENUM_GPG_FAILURE,
-		    "GPG signed package could not be verified");
-		pk_backend_finished(backend);
-		return;
-	}
-	eula_id = "eula_hughsie_dot_com";
-	has_eula = pk_backend_is_eula_valid(backend, eula_id);
-	if (_use_eula && !has_eula) {
-		license_agreement = "Narrator: In A.D. 2101, war was beginning.\n"
-		    "Captain: What happen ?\n"
-		    "Mechanic: Somebody set up us the bomb.\n\n"
-		    "Operator: We get signal.\n"
-		    "Captain: What !\n"
-		    "Operator: Main screen turn on.\n"
-		    "Captain: It's you !!\n"
-		    "CATS: How are you gentlemen !!\n"
-		    "CATS: All your base are belong to us.\n"
-		    "CATS: You are on the way to destruction.\n\n"
-		    "Captain: What you say !!\n"
-		    "CATS: You have no chance to survive make your time.\n"
-		    "CATS: Ha Ha Ha Ha ....\n\n"
-		    "Operator: Captain!! *\n"
-		    "Captain: Take off every 'ZIG' !!\n"
-		    "Captain: You know what you doing.\n"
-		    "Captain: Move 'ZIG'.\n"
-		    "Captain: For great justice.\n";
-		pk_backend_eula_required(backend, eula_id, package_ids[0],
-		    "CATS Inc.", license_agreement);
-		pk_backend_error_code(backend, PK_ERROR_ENUM_NO_LICENSE_AGREEMENT,
-		    "licence not installed so cannot install");
-		pk_backend_finished(backend);
-		return;
-	}
-	_package_ids = package_ids;
-	_package_current = 0;
-	_progress_percentage = 0;
-	pk_backend_set_allow_cancel(backend, TRUE);
-	pk_backend_set_percentage(backend, 0);
-	pk_backend_set_status(backend, PK_STATUS_ENUM_DOWNLOAD);
-	_signal_timeout = g_timeout_add(200, pk_backend_update_packages_download_timeout, backend);
+	INTENTIONALLY_IGNORE(backend);
+	return available_groups();
 }
 
-static gboolean
-pk_backend_update_system_timeout(gpointer data)
+gchar          *
+pk_backend_get_mime_types(PkBackend *backend)
 {
-	PkBackend      *backend = (PkBackend *)data;
-	if (_progress_percentage == 100) {
-
-		/* cleanup socket stuff */
-		if (_socket != NULL)
-			g_object_unref(_socket);
-		if (_socket_listen_id != 0)
-			g_source_remove(_socket_listen_id);
-
-		pk_backend_finished(backend);
-		return FALSE;
-	}
-	if (_progress_percentage == 0 && !_updated_powertop) {
-		pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING,
-		    "powertop;1.8-1.fc8;i386;fedora",
-		    "Power consumption monitor");
-	}
-	if (_progress_percentage == 20 && !_updated_kernel) {
-		pk_backend_package(backend, PK_INFO_ENUM_DOWNLOADING,
-		    "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
-		    "The Linux kernel (the core of the Linux operating system)");
-	}
-	if (_progress_percentage == 30 && !_updated_gtkhtml) {
-		pk_backend_message(backend, PK_MESSAGE_ENUM_NEWER_PACKAGE_EXISTS, "A newer package preupgrade is available in fedora-updates-testing");
-		pk_backend_message(backend, PK_MESSAGE_ENUM_CONFIG_FILES_CHANGED, "/etc/X11/xorg.conf has been auto-merged, please check before rebooting");
-		pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing metadata is invalid");
-		pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-debuginfo metadata is invalid");
-		pk_backend_message(backend, PK_MESSAGE_ENUM_BROKEN_MIRROR, "fedora-updates-testing-source metadata is invalid");
-		pk_backend_package(backend, PK_INFO_ENUM_INSTALLING,
-		    "gtkhtml2;2.19.1-4.fc8;i386;fedora",
-		    "An HTML widget for GTK+ 2.0");
-		_updated_gtkhtml = TRUE;
-	}
-	if (_progress_percentage == 40 && !_updated_powertop) {
-		pk_backend_set_status(backend, PK_STATUS_ENUM_UPDATE);
-		pk_backend_set_allow_cancel(backend, FALSE);
-		pk_backend_package(backend, PK_INFO_ENUM_INSTALLING,
-		    "powertop;1.8-1.fc8;i386;fedora",
-		    "Power consumption monitor");
-		_updated_powertop = TRUE;
-	}
-	if (_progress_percentage == 60 && !_updated_kernel) {
-		pk_backend_package(backend, PK_INFO_ENUM_UPDATING,
-		    "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
-		    "The Linux kernel (the core of the Linux operating system)");
-		_updated_kernel = TRUE;
-	}
-	if (_progress_percentage == 80 && !_updated_kernel) {
-		pk_backend_package(backend, PK_INFO_ENUM_CLEANUP,
-		    "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
-		    "The Linux kernel (the core of the Linux operating system)");
-	}
-	_progress_percentage += 1;
-	pk_backend_set_percentage(backend, _progress_percentage);
-	pk_backend_set_sub_percentage(backend, (_progress_percentage % 10) * 10);
-	return TRUE;
-}
 
+	INTENTIONALLY_IGNORE(backend);
 
-/**
- * pk_backend_socket_has_data_cb:
- **/
-static gboolean
-pk_backend_socket_has_data_cb(GSocket * socket, GIOCondition condition, PkBackend *backend)
-{
-	GError         *error = NULL;
-	gsize		len;
-	gchar		buffer   [1024];
-	gboolean	ret = TRUE;
-	gint		wrote = 0;
-
-	/* the helper process exited */
-	if ((condition & G_IO_HUP) > 0) {
-		pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR,
-		    "socket was disconnected");
-		pk_backend_finished(backend);
-		ret = FALSE;
-		goto out;
-	}
-	/* there is data */
-	if ((condition & G_IO_IN) > 0) {
-		len = g_socket_receive(socket, buffer, 1024, NULL, &error);
-		if (error != NULL) {
-			pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR,
-			    "failed to read: %s", error->message);
-			pk_backend_finished(backend);
-			g_error_free(error);
-			ret = FALSE;
-			goto out;
-		}
-		if (len == 0)
-			goto out;
-		buffer[len] = '\0';
-		if (g_strcmp0(buffer, "pong\n") == 0) {
-			/* send a message so we can verify in the self checks */
-			pk_backend_message(backend, PK_MESSAGE_ENUM_PARAMETER_INVALID, buffer);
-
-			/* verify we can write into the socket */
-			wrote = g_socket_send(_socket, "invalid\n", 8, NULL, &error);
-			if (error != NULL) {
-				pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR,
-				    "failed to write to socket: %s", error->message);
-				pk_backend_finished(backend);
-				g_error_free(error);
-				goto out;
-			}
-			if (wrote != 8) {
-				pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR,
-				    "failed to write, only %i bytes", wrote);
-				pk_backend_finished(backend);
-				goto out;
-			}
-		} else if (g_strcmp0(buffer, "you said to me: invalid\n") == 0) {
-			g_debug("ignoring invalid data (one is good)");
-		} else {
-			pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR,
-			    "unexpected data: %s", buffer);
-			g_source_remove(_signal_timeout);
-			pk_backend_finished(backend);
-			goto out;
-		}
-	}
-out:
-	return ret;
+	 /* (Backformed from pkg.h: pkg_formats) */
+	return g_strdup("application/x-gzip;"
+	    "application/x-tar;"
+	    "application/x-bzip2;"
+	    "application/x-xz;");
 }
 
-/**
- * pk_backend_update_system:
- */
-void
-pk_backend_update_system(PkBackend *backend, gboolean only_trusted)

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-soc-all mailing list