[packagekit] packagekit: Branch 'master'

Richard Hughes hughsient at kemper.freedesktop.org
Wed Sep 5 16:49:53 PDT 2007


 backends/apt/Makefile.am            |    6 
 backends/apt/pk-backend-apt.c       |  192 ++++++++++++++++++++++
 backends/box/Makefile.am            |    6 
 backends/box/pk-backend-box.c       |  192 ++++++++++++++++++++++
 backends/conary/Makefile.am         |    6 
 backends/conary/pk-backend-conary.c |  150 +++++++++++++++++
 backends/dummy/Makefile.am          |    6 
 backends/dummy/pk-backend-dummy.c   |  305 ++++++++++++++++++++++++++++++++++++
 backends/test/Makefile.am           |    6 
 backends/test/pk-backend-test.c     |  206 ++++++++++++++++++++++++
 backends/yum/Makefile.am            |    6 
 backends/yum/pk-backend-yum.c       |  237 +++++++++++++++++++++++++++
 12 files changed, 1318 insertions(+)

New commits:
diff-tree 1451794d8315f447f85fa51a639c0b85effc06c5 (from 75864ee38b3f0efb517f84a07bd3cc51f541f7d7)
Author: Richard Hughes <richard at hughsie.com>
Date:   Thu Sep 6 00:49:41 2007 +0100

    add the incomplete porting of some of the backends. I've yet to do box or apt, which I'll do tomorrow

diff --git a/backends/apt/Makefile.am b/backends/apt/Makefile.am
index e69de29..934daf1 100644
--- a/backends/apt/Makefile.am
+++ b/backends/apt/Makefile.am
@@ -0,0 +1,6 @@
+#plugindir = @PK_PLUGIN_DIR@
+#plugin_LTLIBRARIES = libpk_backend_apt.la
+#libpk_backend_apt_la_SOURCES = pk-backend-apt.c
+#libpk_backend_apt_la_LIBADD = @PK_PLUGIN_LIBS@
+#libpk_backend_apt_la_LDFLAGS = -module -avoid-version
+#libpk_backend_apt_la_CFLAGS = @PK_PLUGIN_CFLAGS@
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
new file mode 100644
index 0000000..183eb9e
--- /dev/null
+++ b/backends/apt/pk-backend-apt.c
@@ -0,0 +1,192 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+
+/**
+ * backend_initalize:
+ */
+static void
+backend_initalize (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_destroy:
+ */
+static void
+backend_destroy (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_cancel_job_try:
+ */
+static void
+backend_cancel_job_try (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_depends:
+ */
+static void
+backend_get_depends (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_description:
+ */
+static void
+backend_get_description (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_requires:
+ */
+static void
+backend_get_requires (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_updates:
+ */
+static void
+backend_get_updates (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_install_package:
+ */
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_remove_package:
+ */
+static void
+backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_search_details:
+ */
+static void
+backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_search_file:
+ */
+static void
+backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_search_group:
+ */
+static void
+backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_search_name:
+ */
+static void
+backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_update_package:
+ */
+static void
+backend_update_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_update_system:
+ */
+static void
+backend_update_system (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+PK_BACKEND_OPTIONS (
+	"Dummy Backend",		/* description */
+	"0.0.1",			/* version */
+	"richard at hughsie.com",		/* author */
+	backend_initalize,		/* initalize */
+	backend_destroy,		/* destroy */
+	backend_cancel_job_try,		/* cancel_job_try */
+	backend_get_depends,		/* get_depends */
+	backend_get_description,	/* get_description */
+	backend_get_requires,		/* get_requires */
+	backend_get_updates,		/* get_updates */
+	backend_install_package,	/* install_package */
+	backend_refresh_cache,		/* refresh_cache */
+	backend_remove_package,		/* remove_package */
+	backend_search_details,		/* search_details */
+	backend_search_file,		/* search_file */
+	backend_search_group,		/* search_group */
+	backend_search_name,		/* search_name */
+	backend_update_package,		/* update_package */
+	backend_update_system		/* update_system */
+);
+
diff --git a/backends/box/Makefile.am b/backends/box/Makefile.am
index 7d4fa85..1e554ae 100644
--- a/backends/box/Makefile.am
+++ b/backends/box/Makefile.am
@@ -1,2 +1,8 @@
 SUBDIRS = helpers
+#plugindir = @PK_PLUGIN_DIR@
+#plugin_LTLIBRARIES = libpk_backend_box.la
+#libpk_backend_box_la_SOURCES = pk-backend-box.c
+#libpk_backend_box_la_LIBADD = @PK_PLUGIN_LIBS@
+#libpk_backend_box_la_LDFLAGS = -module -avoid-version
+#libpk_backend_box_la_CFLAGS = @PK_PLUGIN_CFLAGS@
 
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
new file mode 100644
index 0000000..183eb9e
--- /dev/null
+++ b/backends/box/pk-backend-box.c
@@ -0,0 +1,192 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+
+/**
+ * backend_initalize:
+ */
+static void
+backend_initalize (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_destroy:
+ */
+static void
+backend_destroy (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_cancel_job_try:
+ */
+static void
+backend_cancel_job_try (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_depends:
+ */
+static void
+backend_get_depends (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_description:
+ */
+static void
+backend_get_description (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_requires:
+ */
+static void
+backend_get_requires (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_updates:
+ */
+static void
+backend_get_updates (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_install_package:
+ */
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_remove_package:
+ */
+static void
+backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_search_details:
+ */
+static void
+backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_search_file:
+ */
+static void
+backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_search_group:
+ */
+static void
+backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_search_name:
+ */
+static void
+backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_update_package:
+ */
+static void
+backend_update_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_update_system:
+ */
+static void
+backend_update_system (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+PK_BACKEND_OPTIONS (
+	"Dummy Backend",		/* description */
+	"0.0.1",			/* version */
+	"richard at hughsie.com",		/* author */
+	backend_initalize,		/* initalize */
+	backend_destroy,		/* destroy */
+	backend_cancel_job_try,		/* cancel_job_try */
+	backend_get_depends,		/* get_depends */
+	backend_get_description,	/* get_description */
+	backend_get_requires,		/* get_requires */
+	backend_get_updates,		/* get_updates */
+	backend_install_package,	/* install_package */
+	backend_refresh_cache,		/* refresh_cache */
+	backend_remove_package,		/* remove_package */
+	backend_search_details,		/* search_details */
+	backend_search_file,		/* search_file */
+	backend_search_group,		/* search_group */
+	backend_search_name,		/* search_name */
+	backend_update_package,		/* update_package */
+	backend_update_system		/* update_system */
+);
+
diff --git a/backends/conary/Makefile.am b/backends/conary/Makefile.am
index 9cc7655..080caa6 100644
--- a/backends/conary/Makefile.am
+++ b/backends/conary/Makefile.am
@@ -1 +1,7 @@
 SUBDIRS = helpers
+#plugindir = @PK_PLUGIN_DIR@
+#plugin_LTLIBRARIES = libpk_backend_conary.la
+#libpk_backend_conary_la_SOURCES = pk-backend-conary.c
+#libpk_backend_conary_la_LIBADD = @PK_PLUGIN_LIBS@
+#libpk_backend_conary_la_LDFLAGS = -module -avoid-version
+#libpk_backend_conary_la_CFLAGS = @PK_PLUGIN_CFLAGS@
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
new file mode 100644
index 0000000..0da201e
--- /dev/null
+++ b/backends/conary/pk-backend-conary.c
@@ -0,0 +1,150 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ * Copyright (C) 2007 Ken VanDine <ken at vandine.org>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+
+/**
+ * backend_get_description:
+ */
+static void
+backend_get_description (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+	pk_backend_spawn_helper (backend, "get-description.py", package_id, NULL);
+}
+
+/**
+ * backend_get_updates:
+ */
+static void
+backend_get_updates (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, NULL);
+	pk_backend_spawn_helper (backend, "get-updates.py", NULL);
+}
+
+/**
+ * backend_install_package:
+ */
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	/* check network state */
+	if (pk_backend_network_is_online (backend) == FALSE) {
+		pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot install when offline");
+		pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+		return;
+	}
+
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_INSTALL, package_id);
+	pk_backend_spawn_helper (backend, "install.py", package_id, NULL);
+}
+
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+	g_return_if_fail (backend != NULL);
+	/* check network state */
+	if (pk_backend_network_is_online (backend) == FALSE) {
+		pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot refresh cache whilst offline");
+		pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+		return;
+	}
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_REFRESH_CACHE, NULL);
+	pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
+}
+
+/**
+ * backend_remove_package:
+ */
+static void
+backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
+{
+	g_return_if_fail (backend != NULL);
+	const gchar *deps;
+	if (allow_deps == TRUE) {
+		deps = "yes";
+	} else {
+		deps = "no";
+	}
+
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_REMOVE, package_id);
+	pk_backend_spawn_helper (backend, "remove.py", deps, package_id, NULL);
+}
+
+/**
+ * backend_search_details:
+ */
+static void
+backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_spawn_helper (backend, "search-details.py", filter, search, NULL);
+}
+
+/**
+ * backend_search_name:
+ */
+static void
+backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_no_percentage_updates (backend);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_spawn_helper (backend, "search-name.py", filter, search, NULL);
+}
+
+PK_BACKEND_OPTIONS (
+	"Conary Backend",		/* description */
+	"0.0.1",			/* version */
+	"ken at vandine.org",		/* author */
+	NULL,				/* initalize */
+	NULL,				/* destroy */
+	NULL,				/* cancel_job_try */
+	NULL,				/* get_depends */
+	backend_get_description,	/* get_description */
+	NULL,				/* get_requires */
+	backend_get_updates,		/* get_updates */
+	backend_install_package,	/* install_package */
+	backend_refresh_cache,		/* refresh_cache */
+	backend_remove_package,		/* remove_package */
+	backend_search_details,		/* search_details */
+	NULL,				/* search_file */
+	NULL,				/* search_group */
+	backend_search_name,		/* search_name */
+	NULL,				/* update_package */
+	NULL				/* update_system */
+);
+
diff --git a/backends/dummy/Makefile.am b/backends/dummy/Makefile.am
index e69de29..4ad84c2 100644
--- a/backends/dummy/Makefile.am
+++ b/backends/dummy/Makefile.am
@@ -0,0 +1,6 @@
+#plugindir = @PK_PLUGIN_DIR@
+#plugin_LTLIBRARIES = libpk_backend_dummy.la
+#libpk_backend_dummy_la_SOURCES = pk-backend-dummy.c
+#libpk_backend_dummy_la_LIBADD = @PK_PLUGIN_LIBS@
+#libpk_backend_dummy_la_LDFLAGS = -module -avoid-version
+#libpk_backend_dummy_la_CFLAGS = @PK_PLUGIN_CFLAGS@
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
new file mode 100644
index 0000000..9607822
--- /dev/null
+++ b/backends/dummy/pk-backend-dummy.c
@@ -0,0 +1,305 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+
+static guint progress_percentage;
+
+/**
+ * backend_initalize:
+ */
+static void
+backend_initalize (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	progress_percentage = 0;
+}
+
+/**
+ * backend_destroy:
+ */
+static void
+backend_destroy (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_cancel_job_try:
+ */
+static void
+backend_cancel_job_try (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_get_depends:
+ */
+static void
+backend_get_depends (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+	pk_backend_package (backend, 1, "glib2;2.14.0;i386;fedora",
+			 "The GLib library");
+	pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
+			 "GTK+ Libraries for GIMP");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+/**
+ * backend_get_description:
+ */
+static void
+backend_get_description (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+	pk_backend_description (backend, "gnome-power-manager;2.6.19;i386;fedora", PK_TASK_GROUP_PROGRAMMING,
+"Scribus is an desktop open source page layout program with "
+"the aim of producing commercial grade output in PDF and "
+"Postscript, primarily, though not exclusively for Linux.\n"
+"\n"
+"While the goals of the program are for ease of use and simple easy to "
+"understand tools, Scribus offers support for professional publishing "
+"features, such as CMYK color, easy PDF creation, Encapsulated Postscript "
+"import/export and creation of color separations.", "http://live.gnome.org/GnomePowerManager");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+/**
+ * backend_get_requires:
+ */
+static void
+backend_get_requires (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+	pk_backend_package (backend, 1, "glib2;2.14.0;i386;fedora",
+			 "The GLib library");
+	pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
+			 "GTK+ Libraries for GIMP");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+/**
+ * backend_get_updates:
+ */
+static void
+backend_get_updates (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, NULL);
+	pk_backend_package (backend, 0, "powertop;1.8-1.fc8;i386;fedora",
+			 "Power consumption monitor");
+	pk_backend_package (backend, 1, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
+			 "The Linux kernel (the core of the Linux operating system)");
+	pk_backend_package (backend, 1, "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+static gboolean
+backend_install_timeout (gpointer data)
+{
+	PkBackend *backend = (PkBackend *) data;
+	if (progress_percentage == 100) {
+		pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+		return FALSE;
+	}
+	if (progress_percentage == 50) {
+		pk_backend_change_job_status (backend, PK_TASK_STATUS_INSTALL);
+	}
+	progress_percentage += 10;
+	pk_backend_change_percentage (backend, progress_percentage);
+	return TRUE;
+}
+
+/**
+ * backend_install_package:
+ */
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_INSTALL, package_id);
+	progress_percentage = 0;
+	g_timeout_add (1000, backend_install_timeout, backend);
+}
+
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_REFRESH_CACHE, NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+/**
+ * backend_remove_package:
+ */
+static void
+backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_REMOVE, package_id);
+	pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "No network connection available");
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_search_details:
+ */
+static void
+backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
+			 "The vips documentation package.");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+/**
+ * backend_search_file:
+ */
+static void
+backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
+			 "The vips documentation package.");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+/**
+ * backend_search_group:
+ */
+static void
+backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
+			 "The vips documentation package.");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+/**
+ * backend_search_name_timeout:
+ **/
+gboolean
+backend_search_name_timeout (gpointer data)
+{
+	PkBackend *backend = (PkBackend *) data;
+	pk_backend_package (backend, 1, "evince;0.9.3-5.fc8;i386;installed",
+			 "PDF Document viewer");
+	pk_backend_package (backend, 1, "tetex;3.0-41.fc8;i386;fedora",
+			 "TeTeX is an implementation of TeX for Linux or UNIX systems.");
+	pk_backend_package (backend, 0, "scribus;1.3.4-1.fc8;i386;fedora",
+			 "Scribus is an desktop open source page layout program");
+	pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
+			 "The vips documentation package.");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+	return FALSE;
+}
+
+/**
+ * backend_search_name:
+ */
+static void
+backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_no_percentage_updates (backend);
+	g_timeout_add (2000, backend_search_name_timeout, backend);
+}
+
+/**
+ * backend_update_package:
+ */
+static void
+backend_update_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_UPDATE, package_id);
+	pk_backend_package (backend, 1, package_id, "The same thing");
+	pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+}
+
+static gboolean
+backend_update_system_timeout (gpointer data)
+{
+	PkBackend *backend = (PkBackend *) data;
+	if (progress_percentage == 100) {
+		pk_backend_finished (backend, PK_TASK_EXIT_SUCCESS);
+		return FALSE;
+	}
+	pk_backend_change_job_status (backend, PK_TASK_STATUS_UPDATE);
+	progress_percentage += 10;
+	pk_backend_change_percentage (backend, progress_percentage);
+	return TRUE;
+}
+
+/**
+ * backend_update_system:
+ */
+static void
+backend_update_system (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_SYSTEM_UPDATE, NULL);
+	pk_backend_change_job_status (backend, PK_TASK_STATUS_DOWNLOAD);
+	progress_percentage = 0;
+	pk_backend_require_restart (backend, PK_TASK_RESTART_SYSTEM, NULL);
+	g_timeout_add (1000, backend_update_system_timeout, backend);
+}
+
+PK_BACKEND_OPTIONS (
+	"Dummy Backend",		/* description */
+	"0.0.1",			/* version */
+	"richard at hughsie.com",		/* author */
+	backend_initalize,		/* initalize */
+	backend_destroy,		/* destroy */
+	backend_cancel_job_try,		/* cancel_job_try */
+	backend_get_depends,		/* get_depends */
+	backend_get_description,	/* get_description */
+	backend_get_requires,		/* get_requires */
+	backend_get_updates,		/* get_updates */
+	backend_install_package,	/* install_package */
+	backend_refresh_cache,		/* refresh_cache */
+	backend_remove_package,		/* remove_package */
+	backend_search_details,		/* search_details */
+	backend_search_file,		/* search_file */
+	backend_search_group,		/* search_group */
+	backend_search_name,		/* search_name */
+	backend_update_package,		/* update_package */
+	backend_update_system		/* update_system */
+);
+
diff --git a/backends/test/Makefile.am b/backends/test/Makefile.am
index e69de29..74178c4 100644
--- a/backends/test/Makefile.am
+++ b/backends/test/Makefile.am
@@ -0,0 +1,6 @@
+#plugindir = @PK_PLUGIN_DIR@
+#plugin_LTLIBRARIES = libpk_backend_test.la
+#libpk_backend_test_la_SOURCES = pk-backend-test.c
+#libpk_backend_test_la_LIBADD = @PK_PLUGIN_LIBS@
+#libpk_backend_test_la_LDFLAGS = -module -avoid-version
+#libpk_backend_test_la_CFLAGS = @PK_PLUGIN_CFLAGS@
diff --git a/backends/test/pk-backend-test.c b/backends/test/pk-backend-test.c
new file mode 100644
index 0000000..1d6d35b
--- /dev/null
+++ b/backends/test/pk-backend-test.c
@@ -0,0 +1,206 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+
+/**
+ * backend_initalize:
+ */
+static void
+backend_initalize (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_destroy:
+ */
+static void
+backend_destroy (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+}
+
+/**
+ * backend_cancel_job_try:
+ */
+static void
+backend_cancel_job_try (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_get_depends:
+ */
+static void
+backend_get_depends (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_get_description:
+ */
+static void
+backend_get_description (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_get_requires:
+ */
+static void
+backend_get_requires (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_get_updates:
+ */
+static void
+backend_get_updates (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_install_package:
+ */
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_remove_package:
+ */
+static void
+backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_search_details:
+ */
+static void
+backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_search_file:
+ */
+static void
+backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_search_group:
+ */
+static void
+backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_search_name:
+ */
+static void
+backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_update_package:
+ */
+static void
+backend_update_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+/**
+ * backend_update_system:
+ */
+static void
+backend_update_system (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+}
+
+PK_BACKEND_OPTIONS (
+	"Dummy Backend",		/* description */
+	"0.0.1",			/* version */
+	"richard at hughsie.com",		/* author */
+	backend_initalize,		/* initalize */
+	backend_destroy,		/* destroy */
+	backend_cancel_job_try,		/* cancel_job_try */
+	backend_get_depends,		/* get_depends */
+	backend_get_description,	/* get_description */
+	backend_get_requires,		/* get_requires */
+	backend_get_updates,		/* get_updates */
+	backend_install_package,	/* install_package */
+	backend_refresh_cache,		/* refresh_cache */
+	backend_remove_package,		/* remove_package */
+	backend_search_details,		/* search_details */
+	backend_search_file,		/* search_file */
+	backend_search_group,		/* search_group */
+	backend_search_name,		/* search_name */
+	backend_update_package,		/* update_package */
+	backend_update_system		/* update_system */
+);
+
diff --git a/backends/yum/Makefile.am b/backends/yum/Makefile.am
index 9cc7655..fc32e63 100644
--- a/backends/yum/Makefile.am
+++ b/backends/yum/Makefile.am
@@ -1 +1,7 @@
 SUBDIRS = helpers
+#plugindir = @PK_PLUGIN_DIR@
+#plugin_LTLIBRARIES = libpk_backend_yum.la
+#libpk_backend_yum_la_SOURCES = pk-backend-yum.c
+#libpk_backend_yum_la_LIBADD = @PK_PLUGIN_LIBS@
+#libpk_backend_yum_la_LDFLAGS = -module -avoid-version
+#libpk_backend_yum_la_CFLAGS = @PK_PLUGIN_CFLAGS@
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
new file mode 100644
index 0000000..fa1b396
--- /dev/null
+++ b/backends/yum/pk-backend-yum.c
@@ -0,0 +1,237 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+
+/**
+ * backend_cancel_job_try:
+ */
+static void
+backend_cancel_job_try (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	/* this feels bad... */
+	pk_backend_spawn_kill (backend);
+}
+
+/**
+ * backend_get_depends:
+ */
+static void
+backend_get_depends (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+	pk_backend_spawn_helper (backend, "get-depends.py", package_id, NULL);
+}
+
+/**
+ * backend_get_description:
+ */
+static void
+backend_get_description (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+	pk_backend_spawn_helper (backend, "get-description.py", package_id, NULL);
+}
+
+/**
+ * backend_get_requires:
+ */
+static void
+backend_get_requires (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, package_id);
+	pk_backend_spawn_helper (backend, "get-requires.py", package_id, NULL);
+}
+
+/**
+ * backend_get_updates:
+ */
+static void
+backend_get_updates (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, NULL);
+	pk_backend_spawn_helper (backend, "get-updates.py", NULL);
+}
+
+/**
+ * backend_install_package:
+ */
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	/* check network state */
+	if (pk_backend_network_is_online (backend) == FALSE) {
+		pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot install when offline");
+		pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+		return;
+	}
+
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_INSTALL, package_id);
+	pk_backend_spawn_helper (backend, "install.py", package_id, NULL);
+}
+
+/**
+ * backend_refresh_cache:
+ */
+static void
+backend_refresh_cache (PkBackend *backend, gboolean force)
+{
+	g_return_if_fail (backend != NULL);
+	/* check network state */
+	if (pk_backend_network_is_online (backend) == FALSE) {
+		pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot refresh cache whilst offline");
+		pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+		return;
+	}
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_REFRESH_CACHE, NULL);
+	pk_backend_spawn_helper (backend, "refresh-cache.py", NULL);
+}
+
+/**
+ * backend_remove_package:
+ */
+static void
+backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean allow_deps)
+{
+	g_return_if_fail (backend != NULL);
+	const gchar *deps;
+	if (allow_deps == TRUE) {
+		deps = "yes";
+	} else {
+		deps = "no";
+	}
+
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_REMOVE, package_id);
+	pk_backend_spawn_helper (backend, "remove.py", deps, package_id, NULL);
+}
+
+/**
+ * backend_search_details:
+ */
+static void
+backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_spawn_helper (backend, "search-details.py", filter, search, NULL);
+}
+
+/**
+ * backend_search_file:
+ */
+static void
+backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_not_implemented_yet (backend, "SearchFile");
+}
+
+/**
+ * backend_search_group:
+ */
+static void
+backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_spawn_helper (backend, "search-group.py", filter, search, NULL);
+}
+
+/**
+ * backend_search_name:
+ */
+static void
+backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_allow_interrupt (backend, TRUE);
+	pk_backend_no_percentage_updates (backend);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_QUERY, search);
+	pk_backend_spawn_helper (backend, "search-name.py", filter, search, NULL);
+}
+
+/**
+ * backend_update_package:
+ */
+static void
+backend_update_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	/* check network state */
+	if (pk_backend_network_is_online (backend) == FALSE) {
+		pk_backend_error_code (backend, PK_TASK_ERROR_CODE_NO_NETWORK, "Cannot update when offline");
+		pk_backend_finished (backend, PK_TASK_EXIT_FAILED);
+		return;
+	}
+
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_PACKAGE_UPDATE, package_id);
+	pk_backend_spawn_helper (backend, "update.py", package_id, NULL);
+}
+
+/**
+ * backend_update_system:
+ */
+static void
+backend_update_system (PkBackend *backend)
+{
+	g_return_if_fail (backend != NULL);
+	pk_backend_set_job_role (backend, PK_TASK_ROLE_SYSTEM_UPDATE, NULL);
+	pk_backend_spawn_helper (backend, "update-system.py", NULL);
+}
+
+PK_BACKEND_OPTIONS (
+	"Dummy Backend",		/* description */
+	"0.0.1",			/* version */
+	"richard at hughsie.com",		/* author */
+	NULL,				/* initalize */
+	NULL,				/* destroy */
+	backend_cancel_job_try,		/* cancel_job_try */
+	backend_get_depends,		/* get_depends */
+	backend_get_description,	/* get_description */
+	backend_get_requires,		/* get_requires */
+	backend_get_updates,		/* get_updates */
+	backend_install_package,	/* install_package */
+	backend_refresh_cache,		/* refresh_cache */
+	backend_remove_package,		/* remove_package */
+	backend_search_details,		/* search_details */
+	backend_search_file,		/* search_file */
+	backend_search_group,		/* search_group */
+	backend_search_name,		/* search_name */
+	backend_update_package,		/* update_package */
+	backend_update_system		/* update_system */
+);
+



More information about the PackageKit mailing list