[packagekit] packagekit: Branch 'master' - 6 commits

Richard Hughes hughsient at kemper.freedesktop.org
Wed Nov 28 14:10:47 PST 2007


 backends/box/pk-backend-box.c          |   34 +++--
 backends/pisi/helpers/get-depends.py   |    2 
 backends/pisi/helpers/get-requires.py  |    2 
 backends/pisi/helpers/pisiBackend.py   |   11 +
 backends/test/pk-backend-test-thread.c |   13 +-
 backends/zypp/Makefile.am              |    3 
 backends/zypp/pk-backend-zypp.cpp      |  193 ++++++++++++++++++---------------
 backends/zypp/zypp-events.h            |    4 
 backends/zypp/zypp-utils.cpp           |   29 ++++
 backends/zypp/zypp-utils.h             |   13 ++
 html/pk-faq.html                       |    6 +
 src/pk-backend.c                       |   30 -----
 src/pk-backend.h                       |    3 
 src/pk-spawn.c                         |    2 
 14 files changed, 207 insertions(+), 138 deletions(-)

New commits:
commit 3a4421680b9adaee15e24d12b52125dc993efe72
Merge: 2e2fafc... 4b1fba2...
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 28 22:09:42 2007 +0000

    Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit

commit 4b1fba24f84971eefbd256f0683b46fd02af6716
Author: Boyd Timothy <btimothy at gmail.com>
Date:   Wed Nov 28 14:42:20 2007 -0700

    Added some sub_progress information for general repo events in zypp backend.

diff --git a/backends/zypp/zypp-events.h b/backends/zypp/zypp-events.h
index e6c7a75..a868c77 100644
--- a/backends/zypp/zypp-events.h
+++ b/backends/zypp/zypp-events.h
@@ -205,11 +205,13 @@ struct RepoProgressReportReceiver : public zypp::callback::ReceiveReport<zypp::P
 	virtual void start (const zypp::ProgressData &data)
 	{
 		//fprintf (stderr, "\n\n----> RepoProgressReportReceiver::start()\n\n");
+		reset_sub_percentage ();
 	}
 
 	virtual bool progress (const zypp::ProgressData &data)
 	{
 		//fprintf (stderr, "\n\n----> RepoProgressReportReceiver::progress(), %s:%d\n\n", data.name().c_str(), (int)data.val());
+		update_sub_percentage ((int)data.val ());
 		return true;
 	}
 
@@ -224,11 +226,13 @@ struct RepoReportReceiver : public zypp::callback::ReceiveReport<zypp::repo::Rep
 	virtual void start (const zypp::ProgressData &data)
 	{
 		//fprintf (stderr, "\n\n----> RepoReportReceiver::start()\n");
+		reset_sub_percentage ();
 	}
 
 	virtual bool progress (const zypp::ProgressData &data)
 	{
 		//fprintf (stderr, "\n\n----> RepoReportReceiver::progress(), %s:%d\n", data.name().c_str(), (int)data.val());
+		update_sub_percentage ((int)data.val ());
 		return true;
 	}
 
commit edb7849c444f4b0714182372f62779d969051e3e
Author: Boyd Timothy <btimothy at gmail.com>
Date:   Wed Nov 28 14:40:08 2007 -0700

    Starting to add in backend_refresh_cache for zypp backend

diff --git a/backends/zypp/Makefile.am b/backends/zypp/Makefile.am
index 0885b55..f14f672 100644
--- a/backends/zypp/Makefile.am
+++ b/backends/zypp/Makefile.am
@@ -2,7 +2,8 @@
 plugindir = @PK_PLUGIN_DIR@
 plugin_LTLIBRARIES = libpk_backend_zypp.la
 libpk_backend_zypp_la_SOURCES =		\
-	pk-backend-zypp.cpp
+	pk-backend-zypp.cpp		\
+	zypp-utils.cpp
 libpk_backend_zypp_la_LIBADD = @PK_PLUGIN_LIBS@
 libpk_backend_zypp_la_LDFLAGS = -module -avoid-version $(ZYPP_LIBS)
 libpk_backend_zypp_la_CFLAGS = @PK_PLUGIN_CFLAGS@
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 734483b..596e28b 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -46,6 +46,7 @@
 
 #include <map>
 
+#include "zypp-utils.h"
 #include "zypp-events.h"
 
 enum PkgSearchType {
@@ -354,6 +355,104 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 fprintf (stderr, "\n\n\n\n============== Returning from backend_install_package =============\n\n\n\n");
 }
 
+static gboolean
+backend_refresh_cache_thread (PkBackend *backend, gpointer data)
+{
+	RefreshData *d = (RefreshData*) data;
+	gboolean force = d->force;
+	g_free (d);
+
+	pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+	pk_backend_change_percentage (backend, 0);
+
+	zypp::RepoManager manager;
+	std::list <zypp::RepoInfo> repos;
+	try
+	{
+		repos = manager.knownRepositories();
+	}
+	catch ( const zypp::Exception &e)
+	{
+		// FIXME: make sure this dumps out the right sring.
+		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, e.asUserString().c_str() );
+		pk_backend_finished (backend);
+		return FALSE;
+	}
+
+	int i = 1;
+	int num_of_repos = repos.size ();
+	int percentage_increment = 100 / num_of_repos;
+	for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++, i++) {
+		zypp::RepoInfo repo (*it);
+
+		// skip disabled repos
+		if (repo.enabled () == false)
+			continue;
+
+		// skip changeable meda (DVDs and CDs).  Without doing this,
+		// the disc would be required to be physically present.
+		if (is_changeable_media (*repo.baseUrlsBegin ()) == true)
+			continue;
+
+		try {
+fprintf (stderr, "\n\n *** Refreshing metadata ***\n\n");
+			manager.refreshMetadata (repo, force == TRUE ?
+				zypp::RepoManager::RefreshForced :
+				zypp::RepoManager::RefreshIfNeeded);
+		} catch (const zypp::Exception &ex) {
+			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString ().c_str ());
+			return FALSE;
+		}
+
+		try {
+fprintf (stderr, "\n\n *** Building cache ***\n\n");
+			manager.buildCache (repo, force == TRUE ?
+				zypp::RepoManager::BuildForced :
+				zypp::RepoManager::BuildIfNeeded);
+		//} catch (const zypp::repo::RepoNoUrlException &ex) {
+		//} catch (const zypp::repo::RepoNoAliasException &ex) {
+		//} catch (const zypp::repo::RepoUnknownTypeException &ex) {
+		//} catch (const zypp::repo::RepoException &ex) {
+		} catch (const zypp::Exception &ex) {
+			// TODO: Handle the exceptions in manager.refreshMetadata
+			pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, ex.asUserString().c_str() );
+			return FALSE;
+		}
+
+		// Update the percentage completed
+		pk_backend_change_percentage (backend,
+					      i == num_of_repos ?
+						100 :
+						i * percentage_increment);
+	}
+
+	return TRUE;
+}
+
+/**
+ * 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_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
+		pk_backend_finished (backend);
+		return;
+	}
+	RefreshData *data = g_new(RefreshData, 1);
+	if (data == NULL) {
+		pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory in backend_refresh_cache");
+		pk_backend_finished (backend);
+	} else {
+		data->force = force;
+		pk_backend_thread_create (backend, backend_refresh_cache_thread, data);
+	}
+}
+
 static int
 select_callback (void* data,int argc ,char** argv, char** cl_name)
 {
@@ -449,86 +548,6 @@ backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_i
 	}
 }
 
-/*
-static gboolean
-backend_refresh_cache_thread (PkBackend *backend, gpointer data)
-{
-	RefreshData *d = (RefreshData*) data;
-	pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
-	pk_backend_no_percentage_updates (backend);
-	unsigned processed = 0;
-	unsigned repo_count = 0;
-
-	zypp::RepoManager manager;
-	std::list <zypp::RepoInfo> repos;
-	try
-	{
-		repos = manager.knownRepositories();
-	}
-	catch ( const zypp::Exception &e)
-	{
-		// FIXME: make sure this dumps out the right sring.
-		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, e.asUserString().c_str() );
-		g_free (d);
-		return FALSE;
-	}
-
-	repo_count = repos.size ();
-
-	for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) {
-		if (it->enabled()) {
-			//refresh_raw_metadata (it, false);
-
-			// Build the Cache
-			try {
-				manager.buildCache (*it,
-						    d->force ?
-							zypp::RepoManager::BuildForced :
-							zypp::RepoManager::BuildIfNeeded);
-			} catch (const zypp::parser::ParseException &ex) {
-				pk_backend_error_code (backend,
-						       PK_ERROR_ENUM_INTERNAL_ERROR,
-						       "Error parsing metadata for '%s'",
-						       it->alias().c_str());
-				continue;
-			}
-
-			processed++;
-			pk_backend_change_percentage (backend, (int) ((processed / repo_count) * 100));
-		}
-	}
-
-	g_free (d);
-	pk_backend_finished (backend);
-
-	return TRUE;
-}
-
-//
-// 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_ERROR_ENUM_NO_NETWORK, "Cannot refresh cache whilst offline");
-		pk_backend_finished (backend);
-		return;
-	}
-
-	RefreshData *data = g_new0(RefreshData, 1);
-	if (data == NULL) {
-		pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory in backend_refresh_cache");
-		pk_backend_finished (backend);
-	} else {
-		data->force = force;
-		pk_backend_thread_create (backend, backend_refresh_cache_thread, data);
-	}
-}
-*/
-
 /* TODO: this was taken directly from pk-backend-box.c.  Perhaps this
  * ought to be part of libpackagekit? */
 static void
@@ -738,7 +757,7 @@ extern "C" PK_BACKEND_OPTIONS (
 	NULL,					/* get_updates */
 	backend_install_package,		/* install_package */
 	NULL,					/* install_file */
-	NULL,//backend_refresh_cache,			/* refresh_cache */
+	backend_refresh_cache,			/* refresh_cache */
 	NULL,					/* remove_package */
 	backend_resolve,			/* resolve */
 	NULL,					/* rollback */
diff --git a/backends/zypp/zypp-utils.cpp b/backends/zypp/zypp-utils.cpp
new file mode 100644
index 0000000..aecd27e
--- /dev/null
+++ b/backends/zypp/zypp-utils.cpp
@@ -0,0 +1,29 @@
+#ifndef _ZYPP_UTILS_H_
+#define _ZYPP_UTILS_H_
+
+#include <stdlib.h>
+#include <glib.h>
+#include <zypp/RepoManager.h>
+#include <zypp/media/MediaManager.h>
+#include <zypp/Resolvable.h>
+
+#include "zypp-utils.h"
+
+gboolean
+is_changeable_media (const zypp::Url &url)
+{
+	gboolean is_cd = false;
+	try {
+		zypp::media::MediaManager mm;
+		zypp::media::MediaAccessId id = mm.open (url);
+		is_cd = mm.isChangeable (id);
+		mm.close (id);
+	} catch (const zypp::media::MediaException &e) {
+		// TODO: Do anything about this?
+	}
+
+	return is_cd;
+}
+
+#endif // _ZYPP_UTILS_H_
+
diff --git a/backends/zypp/zypp-utils.h b/backends/zypp/zypp-utils.h
new file mode 100644
index 0000000..4941019
--- /dev/null
+++ b/backends/zypp/zypp-utils.h
@@ -0,0 +1,13 @@
+#ifndef _ZYPP_UTILS_H_
+#define _ZYPP_UTILS_H_
+
+#include <stdlib.h>
+#include <glib.h>
+#include <zypp/RepoManager.h>
+#include <zypp/media/MediaManager.h>
+#include <zypp/Resolvable.h>
+
+gboolean is_changeable_media (const zypp::Url &url);
+
+#endif // _ZYPP_UTILS_H_
+
commit 2e2fafc10ac5473eac705246768b52fbb1880a97
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 28 21:29:59 2007 +0000

    add note about gnome localisation to the faq

diff --git a/html/pk-faq.html b/html/pk-faq.html
index a3f585c..054fe30 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -183,6 +183,12 @@ transaction has started, and messages or notices about the transaction
 can only be shown after the transaction has completed.</i>
 </p>
 
+<h3>How do I translate gnome-packagekit?</h3>
+<p>
+Please see the <a href="http://l10n.gnome.org/teams">GNOME Translation Team</a>
+web pages for how to contribute to GNOME localisation.
+</p>
+
 <h3>Is there an organization or corporation sponsoring development of PackageKit?</h3>
 <p>
 PackageKit is not sponsored by anyone.
commit 11da642e6546fe1ae9052d574fb3bcc76938cdcd
Author: Richard Hughes <richard at hughsie.com>
Date:   Wed Nov 28 21:13:33 2007 +0000

    do the threading correctly, Boyd noticed that we join when we use the helper, which sort of negates the point in threads altogether - fix this in all the threaded backends

diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 7fe9580..504c835 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -233,6 +233,7 @@ backend_find_packages_thread (PkBackend *backend, gpointer data)
 	g_free(d->search);
 	g_free(d->filter);
 	g_free(d);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -252,7 +253,7 @@ find_packages (PkBackend *backend, const gchar *search, const gchar *filter, gin
 		data->search = g_strdup(search);
 		data->filter = g_strdup(filter);
 		data->mode = mode;
-		pk_backend_thread_helper (backend, backend_find_packages_thread, data);
+		pk_backend_thread_create (backend, backend_find_packages_thread, data);
 	}
 }
 
@@ -271,6 +272,7 @@ backend_get_updates_thread (PkBackend *backend, gpointer data)
 	box_db_repos_package_list_free (list);
 
 	db_close (db);
+	pk_backend_finished (backend);
 	return TRUE;
 }
 
@@ -280,6 +282,7 @@ backend_update_system_thread (PkBackend *backend, gpointer data)
 	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
 
 	box_upgrade_dist("/", common_progress, backend);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -306,6 +309,7 @@ backend_install_package_thread (PkBackend *backend, gpointer data)
 
 	g_free (d->package_id);
 	g_free (d);
+	pk_backend_finished (backend);
 
 	return result;
 }
@@ -323,6 +327,7 @@ backend_install_file_thread (PkBackend *backend, gpointer data)
 
 	g_free (d->package_id);
 	g_free (d);
+	pk_backend_finished (backend);
 
 	return result;
 }
@@ -372,6 +377,7 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 
 	g_free (d->package_id);
 	g_free (d);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -408,6 +414,7 @@ backend_get_files_thread (PkBackend *backend, gpointer data)
 	g_free (files);
 	g_free (d->package_id);
 	g_free (d);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -446,6 +453,7 @@ backend_get_depends_requires_thread (PkBackend *backend, gpointer data)
 
 	g_free (d->package_id);
 	g_free (d);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -474,6 +482,7 @@ backend_remove_package_thread (PkBackend *backend, gpointer data)
 	pk_package_id_free (pi);
 	g_free (d->package_id);
 	g_free (d);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -484,6 +493,7 @@ backend_refresh_cache_thread (PkBackend *backend, gpointer data)
 	pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
 
     	box_repos_sync(common_progress, backend);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -538,7 +548,7 @@ backend_get_depends (PkBackend *backend, const gchar *package_id, gboolean recur
 	} else {
 		data->package_id = g_strdup(package_id);
 		data->type = DEPS_TYPE_DEPENDS;
-		pk_backend_thread_helper (backend, backend_get_depends_requires_thread, data);
+		pk_backend_thread_create (backend, backend_get_depends_requires_thread, data);
 	}
 }
 
@@ -557,7 +567,7 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 		pk_backend_finished (backend);
 	} else {
 		data->package_id = g_strdup(package_id);
-		pk_backend_thread_helper (backend, backend_get_description_thread, data);
+		pk_backend_thread_create (backend, backend_get_description_thread, data);
 	}
 }
 
@@ -576,7 +586,7 @@ backend_get_files (PkBackend *backend, const gchar *package_id)
 		pk_backend_finished (backend);
 	} else {
 		data->package_id = g_strdup(package_id);
-		pk_backend_thread_helper (backend, backend_get_files_thread, data);
+		pk_backend_thread_create (backend, backend_get_files_thread, data);
 	}
 }
 
@@ -596,7 +606,7 @@ backend_get_requires (PkBackend *backend, const gchar *package_id, gboolean recu
 	} else {
 		data->package_id = g_strdup(package_id);
 		data->type = DEPS_TYPE_REQUIRES;
-		pk_backend_thread_helper (backend, backend_get_depends_requires_thread, data);
+		pk_backend_thread_create (backend, backend_get_depends_requires_thread, data);
 	}
 }
 
@@ -607,7 +617,7 @@ static void
 backend_get_updates (PkBackend *backend)
 {
 	g_return_if_fail (backend != NULL);
-	pk_backend_thread_helper (backend, backend_get_updates_thread, NULL);
+	pk_backend_thread_create (backend, backend_get_updates_thread, NULL);
 }
 
 
@@ -632,7 +642,7 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 		pk_backend_finished (backend);
 	} else {
 		data->package_id = g_strdup(package_id);
-		pk_backend_thread_helper (backend, backend_install_package_thread, data);
+		pk_backend_thread_create (backend, backend_install_package_thread, data);
 	}
 }
 
@@ -651,7 +661,7 @@ backend_install_file (PkBackend *backend, const gchar *file)
 		pk_backend_finished (backend);
 	} else {
 		data->package_id = g_strdup(file);
-		pk_backend_thread_helper (backend, backend_install_file_thread, data);
+		pk_backend_thread_create (backend, backend_install_file_thread, data);
 	}
 }
 
@@ -668,7 +678,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
 		pk_backend_finished (backend);
 		return;
 	}
-	pk_backend_thread_helper (backend, backend_refresh_cache_thread, NULL);
+	pk_backend_thread_create (backend, backend_refresh_cache_thread, NULL);
 }
 
 /**
@@ -688,7 +698,7 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
 	}
 	data->package_id = g_strdup (package_id);
     
-	pk_backend_thread_helper (backend, backend_remove_package_thread, data);
+	pk_backend_thread_create (backend, backend_remove_package_thread, data);
 }
 
 /**
@@ -752,7 +762,7 @@ backend_update_package (PkBackend *backend, const gchar *package_id)
 		pk_backend_finished (backend);
 	} else {
 		data->package_id = g_strdup(package_id);
-		pk_backend_thread_helper (backend, backend_install_package_thread, data);
+		pk_backend_thread_create (backend, backend_install_package_thread, data);
 	}
 }
 
@@ -763,7 +773,7 @@ static void
 backend_update_system (PkBackend *backend)
 {
 	g_return_if_fail (backend != NULL);
-	pk_backend_thread_helper (backend, backend_update_system_thread, NULL);
+	pk_backend_thread_create (backend, backend_update_system_thread, NULL);
 }
 
 /**
diff --git a/backends/test/pk-backend-test-thread.c b/backends/test/pk-backend-test-thread.c
index e80cfc9..0493c20 100644
--- a/backends/test/pk-backend-test-thread.c
+++ b/backends/test/pk-backend-test-thread.c
@@ -44,7 +44,7 @@ static void
 backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
 {
 	g_return_if_fail (backend != NULL);
-	pk_backend_thread_helper (backend, backend_search_group_thread, NULL);
+	pk_backend_thread_create (backend, backend_search_group_thread, NULL);
 }
 
 /**
@@ -55,21 +55,28 @@ backend_search_name_thread (PkBackend *backend, gpointer data)
 {
 	GTimer *timer;
 	gdouble elapsed;
+	guint percentage;
 
 	pk_debug ("started task (%p,%p)", backend, data);
+	pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
 	timer = g_timer_new ();
+	percentage = 0;
 	do {
+		pk_backend_change_percentage (backend, percentage);
+		percentage += 1;
 		g_usleep (1000*100);
 		elapsed = g_timer_elapsed (timer, NULL);
 		pk_debug ("elapsed task (%p,%p) = %f", backend, data, elapsed);
-	} while (elapsed < 5.0);
+	} while (elapsed < 10.0);
 	g_timer_destroy (timer);
+	pk_backend_change_percentage (backend, 100);
 	pk_debug ("exited task (%p,%p)", backend, data);
 
 	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);
 	return TRUE;
 }
 
@@ -80,7 +87,7 @@ static void
 backend_search_name (PkBackend *backend, const gchar *filter, const gchar *search)
 {
 	g_return_if_fail (backend != NULL);
-	pk_backend_thread_helper (backend, backend_search_name_thread, NULL);
+	pk_backend_thread_create (backend, backend_search_name_thread, NULL);
 }
 
 PK_BACKEND_OPTIONS (
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index c72cca6..734483b 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -198,6 +198,7 @@ backend_get_description_thread (PkBackend *backend, gpointer data)
 	pk_package_id_free (pi);
 	g_free (d->package_id);
 	g_free (d);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -216,7 +217,7 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 		pk_backend_finished (backend);
 	} else {
 		data->package_id = g_strdup(package_id);
-		pk_backend_thread_helper (backend, backend_get_description_thread, data);
+		pk_backend_thread_create (backend, backend_get_description_thread, data);
 	}
 }
 
@@ -334,6 +335,7 @@ printf ("Finished the installation.\n");
 
 	g_free (package_id);
 	pk_package_id_free (pi);
+	pk_backend_finished (backend);
 	return TRUE;
 }
 
@@ -347,7 +349,7 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 
 	//printf("package_id is %s\n", package_id);
 	gchar *package_to_install = g_strdup (package_id);
-	pk_backend_thread_helper (backend, backend_install_package_thread, package_to_install);
+	pk_backend_thread_create (backend, backend_install_package_thread, package_to_install);
 	//pk_backend_thread_create (backend, backend_install_package_thread, package_to_install);
 fprintf (stderr, "\n\n\n\n============== Returning from backend_install_package =============\n\n\n\n");
 }
@@ -424,6 +426,7 @@ backend_resolve_thread (PkBackend *backend, gpointer data)
 	g_free (full_version);
 	g_free (package_id);
 	g_free (select_statement);
+	pk_backend_finished (backend);
 	return TRUE;
 }
 
@@ -442,7 +445,7 @@ backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_i
 	} else {
 		data->name = g_strdup (package_id);
 		data->filter = g_strdup (filter);
-		pk_backend_thread_helper (backend, backend_resolve_thread, data);
+		pk_backend_thread_create (backend, backend_resolve_thread, data);
 	}
 }
 
@@ -521,7 +524,7 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
 		pk_backend_finished (backend);
 	} else {
 		data->force = force;
-		pk_backend_thread_helper (backend, backend_refresh_cache_thread, data);
+		pk_backend_thread_create (backend, backend_refresh_cache_thread, data);
 	}
 }
 */
@@ -623,6 +626,7 @@ backend_find_packages_thread (PkBackend *backend, gpointer data)
 	g_free(d->search);
 	g_free(d->filter);
 	g_free(d);
+	pk_backend_finished (backend);
 
 	return TRUE;
 }
@@ -641,7 +645,7 @@ find_packages (PkBackend *backend, const gchar *search, const gchar *filter, gin
 		data->search = g_strdup(search);
 		data->filter = g_strdup(filter);
 		data->mode = mode;
-		pk_backend_thread_helper (backend, backend_find_packages_thread, data);
+		pk_backend_thread_create (backend, backend_find_packages_thread, data);
 	}
 }
 
diff --git a/src/pk-backend.c b/src/pk-backend.c
index b700469..8a494c9 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -234,25 +234,6 @@ pk_backend_thread_create (PkBackend *backend, PkBackendThreadFunc func, gpointer
 }
 
 /**
- * pk_backend_thread_helper:
- **/
-gboolean
-pk_backend_thread_helper (PkBackend *backend, PkBackendThreadFunc func, gpointer data)
-{
-	if (pk_backend_thread_create (backend, func, data) == FALSE) {
-		pk_backend_error_code (backend, PK_ERROR_ENUM_CREATE_THREAD_FAILED, "Failed to create thread");
-		pk_backend_finished (backend);
-		return FALSE;
-	}
-
-	pk_debug ("waiting for all threads in this backend");
-	pk_thread_list_wait (backend->priv->thread_list);
-
-	pk_backend_finished (backend);
-	return TRUE;
-}
-
-/**
  * pk_backend_parse_common_output:
  *
  * If you are editing this function creating a new backend,
@@ -1116,15 +1097,8 @@ pk_backend_finished (PkBackend *backend)
 
 	/* check we have no threads running */
 	if (pk_thread_list_number_running (backend->priv->thread_list) != 0) {
-		pk_backend_message (backend, PK_MESSAGE_ENUM_DAEMON,
-				    "There are threads running and the task has been asked to finish!\n"
-				    "If you are using :\n"
-				    "* pk_backend_thread_helper\n"
-				    "   - You should _not_ use pk_backend_finished directly"
-				    "   - Return from the function like normal\n"
-				    "* pk_thread_list_create:\n"
-				    "   -  If used internally you _have_ to use pk_thread_list_wait");
-		return FALSE;
+		/* wait for threads to complete */
+		//pk_thread_list_wait (backend->priv->thread_list);
 	}
 
 	/* check we have not already finished */
diff --git a/src/pk-backend.h b/src/pk-backend.h
index c54b3ac..cd3b99c 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -101,9 +101,6 @@ typedef gboolean (*PkBackendThreadFunc)			(PkBackend	*backend,
 gboolean	 pk_backend_thread_create		(PkBackend	*backend,
 							 PkBackendThreadFunc func,
 							 gpointer	 data);
-gboolean	 pk_backend_thread_helper		(PkBackend	*backend,
-							 PkBackendThreadFunc func,
-							 gpointer	 data);
 
 /* repo stuff */
 gboolean	 pk_backend_get_repo_list		(PkBackend	*backend);
diff --git a/src/pk-spawn.c b/src/pk-spawn.c
index f4246b9..f7816c7 100644
--- a/src/pk-spawn.c
+++ b/src/pk-spawn.c
@@ -204,7 +204,7 @@ pk_spawn_check_child (PkSpawn *spawn)
 }
 
 /**
- * pk_spawn_check_child:
+ * pk_spawn_sigkill_cb:
  **/
 static gboolean
 pk_spawn_sigkill_cb (PkSpawn *spawn)
commit cfd80a2988f302f1ebd7e0398428ab7b18d9914a
Author: S.Çağlar Onur <caglar at pardus.org.tr>
Date:   Wed Nov 28 09:42:39 2007 +0200

    PiSi: Provide status informations

diff --git a/backends/pisi/helpers/get-depends.py b/backends/pisi/helpers/get-depends.py
index cd70da1..0bc09a6 100644
--- a/backends/pisi/helpers/get-depends.py
+++ b/backends/pisi/helpers/get-depends.py
@@ -14,6 +14,6 @@ import sys
 import pisiBackend
 
 backend = pisiBackend.PackageKitPisiBackend(sys.argv[1:])
-backend.get_depends(sys.argv[1])
+backend.get_depends(sys.argv[1], sys.argv[2])
 
 sys.exit()
diff --git a/backends/pisi/helpers/get-requires.py b/backends/pisi/helpers/get-requires.py
index 3c13910..dab0289 100644
--- a/backends/pisi/helpers/get-requires.py
+++ b/backends/pisi/helpers/get-requires.py
@@ -14,6 +14,6 @@ import sys
 import pisiBackend
 
 backend = pisiBackend.PackageKitPisiBackend(sys.argv[1:])
-backend.get_requires(sys.argv[1])
+backend.get_requires(sys.argv[1], sys.argv[2])
 
 sys.exit()
diff --git a/backends/pisi/helpers/pisiBackend.py b/backends/pisi/helpers/pisiBackend.py
index 4b308e8..9ae9a32 100644
--- a/backends/pisi/helpers/pisiBackend.py
+++ b/backends/pisi/helpers/pisiBackend.py
@@ -150,7 +150,7 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
 
         return self.package(id, status, pkg.summary)
 
-    def get_depends(self, package_id):
+    def get_depends(self, package_id, recursive):
         """ Prints a list of depends for a given package """
         self.allow_interrupt(True)
         self.percentage(None)
@@ -212,7 +212,7 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
             # FIXME: Use repository enabled/disabled state
             self.repo_detail(repo, self.repodb.get_repo(repo).indexuri.get_uri(), "true")
 
-    def get_requires(self, package_id):
+    def get_requires(self, package_id, recursive):
         """ Prints a list of requires for a given package """
         self.allow_interrupt(True)
         self.percentage(None)
@@ -278,6 +278,7 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
         """ Updates repository indexes """
         self.allow_interrupt(False);
         self.percentage(0)
+        self.status(STATUS_REFRESH_CACHE)
 
         slice = (100/len(pisi.api.list_repos()))/2
 
@@ -341,7 +342,8 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
         """ Prints a detailed list of packages contains search term """
         self.allow_interrupt(True)
         self.percentage(None)
-
+        self.status(STATUS_INFO)
+        
         # Internal FIXME: Use search_details instead of _package when API gains that ability :)
         for pkg in pisi.api.search_package([key]):
             self.__get_package(pkg, filters)
@@ -350,6 +352,7 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
         """ Prints the installed package which contains the specified file """
         self.allow_interrupt(True)
         self.percentage(None)
+        self.status(STATUS_INFO)
 
         # Internal FIXME: Why it is needed?
         key = key.lstrip("/")
@@ -361,6 +364,7 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
         """ Prints a list of packages belongs to searched group """
         self.allow_interrupt(True)
         self.percentage(None)
+        self.status(STATUS_INFO)
 
         try:
             for key in self.groups.keys():
@@ -374,6 +378,7 @@ class PackageKitPisiBackend(PackageKitBaseBackend):
         """ Prints a list of packages contains search term in its name """
         self.allow_interrupt(True)
         self.percentage(None)
+        self.status(STATUS_INFO)
 
         for pkg in pisi.api.search_package([package]):
             self.__get_package(pkg, filters)



More information about the PackageKit mailing list