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

Richard Hughes hughsient at kemper.freedesktop.org
Tue Nov 20 13:13:30 PST 2007


 TODO                              |    1 
 backends/zypp/pk-backend-zypp.cpp |  220 +++++++++++++++++++++++++++++++++++++-
 html/pk-faq.html                  |    2 
 libpackagekit/pk-client.c         |   30 +++++
 libpackagekit/pk-client.h         |    3 
 man/Makefile.am                   |    4 
 src/pk-engine.c                   |  120 +++++++++++++++-----
 src/pk-engine.h                   |    4 
 src/pk-interface.xml              |    4 
 9 files changed, 347 insertions(+), 41 deletions(-)

New commits:
commit c99ba2d7335ff354fd145cc6872f358c45d96b77
Merge: 05790b1... e4863ab...
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Nov 20 21:08:24 2007 +0000

    Merge branch 'master' into time

commit 05790b11515dfdd50cc699d3f3dceb8b53f8a3ac
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Nov 20 20:22:36 2007 +0000

    Add GetTimeSinceAction client API code

diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index e62db2e..d6bace6 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -2177,6 +2177,36 @@ pk_client_get_backend_detail (PkClient *client, gchar **name, gchar **author)
 }
 
 /**
+ * pk_client_get_time_since_action:
+ **/
+gboolean
+pk_client_get_time_since_action (PkClient *client, PkRoleEnum role, guint *seconds)
+{
+	gboolean ret;
+	GError *error;
+	const gchar *role_text;
+
+	g_return_val_if_fail (client != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+	error = NULL;
+	role_text = pk_role_enum_to_text (role);
+	ret = dbus_g_proxy_call (client->priv->proxy, "GetTimeSinceAction", &error,
+				 G_TYPE_STRING, role_text,
+				 G_TYPE_INVALID,
+				 G_TYPE_UINT, seconds,
+				 G_TYPE_INVALID);
+	if (ret == FALSE) {
+		/* abort as the DBUS method failed */
+		pk_warning ("GetTimeSinceAction failed :%s", error->message);
+		g_error_free (error);
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+/**
  * pk_client_is_caller_active:
  **/
 gboolean
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index 844c910..1e35bd7 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -152,6 +152,9 @@ gboolean	 pk_client_get_old_transactions		(PkClient	*client,
 gboolean	 pk_client_get_backend_detail		(PkClient	*client,
 							 gchar		**name,
 							 gchar		**author);
+gboolean	 pk_client_get_time_since_action	(PkClient	*client,
+							 PkRoleEnum	 role,
+							 guint		*seconds);
 gboolean	 pk_client_is_caller_active		(PkClient	*client,
 							 gboolean	*is_active);
 
commit 71cb90800557ac194fdc46f0429ab21dca496a8c
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Nov 20 20:08:27 2007 +0000

    add stub code for GetTimeSinceAction

diff --git a/TODO b/TODO
index 84c1183..d286490 100644
--- a/TODO
+++ b/TODO
@@ -3,7 +3,6 @@ Order of no particular importance:
 *** Make the daemon aware on how long between updates ***
 Requires writing to a database for config stuff
  - Probably should move the job number stuff there too
-New method GetHoursSinceLastUpdate
 Use this in the update icon
 
 *** package->status ***
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 73cbe9d..2f803c8 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -2633,6 +2633,22 @@ pk_engine_get_backend_detail (PkEngine *engine, gchar **name, gchar **author, GE
 }
 
 /**
+ * pk_engine_get_time_since_action:
+ *
+ * @seconds: Number of seconds since the role was called, or zero is unknown
+ **/
+gboolean
+pk_engine_get_time_since_action	(PkEngine *engine, const gchar *role_text, guint *seconds, GError **error)
+{
+	PkRoleEnum role;
+	g_return_val_if_fail (engine != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+	role = pk_role_enum_from_text (role_text);
+	*seconds = 0;
+	return TRUE;
+}
+
+/**
  * pk_engine_transaction_cb:
  **/
 static void
diff --git a/src/pk-engine.h b/src/pk-engine.h
index 29b96e4..5d7f7a8 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -182,6 +182,10 @@ gboolean	 pk_engine_get_backend_detail		(PkEngine	*engine,
 							 gchar		**name,
 							 gchar		**author,
 							 GError		**error);
+gboolean	 pk_engine_get_time_since_action	(PkEngine	*engine,
+							 const gchar	*role_text,
+							 guint		*seconds,
+							 GError		**error);
 gboolean	 pk_engine_get_actions			(PkEngine	*engine,
 							 gchar		**actions,
 							 GError		**error);
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index c94142b..fb86a02 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -261,6 +261,10 @@
     </signal>
 
     <!-- General methods -->
+    <method name="GetTimeSinceAction">
+      <arg type="s" name="role" direction="in"/>
+      <arg type="u" name="seconds" direction="out"/>
+    </method>
     <method name="GetBackendDetail">
       <arg type="s" name="name" direction="out"/>
       <arg type="s" name="author" direction="out"/>
commit e4863abd1b3a4c67f720485cb87cd32b0bf4ae77
Merge: b17b0ec... b817396...
Author: Scott Reeves <sreeves at novell.com>
Date:   Tue Nov 20 12:21:03 2007 -0700

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

commit b17b0ec05b972ca6fc453209e0f1ee20e1c56db3
Author: Scott Reeves <sreeves at novell.com>
Date:   Tue Nov 20 12:19:21 2007 -0700

    add backend_install_package

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 68c59fe..dbd2854 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -42,6 +42,7 @@
 #include <zypp/repo/RepoException.h>
 #include <zypp/parser/ParseException.h>
 #include <zypp/Pathname.h>
+#include <sqlite3.h>
 
 enum PkgSearchType {
 	SEARCH_TYPE_NAME = 0,
@@ -57,6 +58,16 @@ typedef struct {
 } FindData;
 
 typedef struct {
+	gchar *name;
+	gchar *filter;
+} ResolveData;
+
+typedef struct {
+	gchar *name;
+	gchar *filter;
+} SQLData;
+
+typedef struct {
 	gchar *package_id;
 	gint type;
 } ThreadData;
@@ -205,7 +216,6 @@ backend_install_package_thread (PkBackend *backend, gpointer data)
 		return FALSE;
 	}
 
-	pk_backend_finished (backend);
 	g_free (package_id);
 	return TRUE;
 }
@@ -218,6 +228,7 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
 
+	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);
 
@@ -240,6 +251,105 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
 	*/
 }
 
+static int
+select_callback (void* sql_data,int argc ,char** argv, char** cl_name)
+{
+	printf("\n\nEnter select_callback\n");
+	for (int i = 0; i < argc; i++) {
+		printf ("%s=%s\n", cl_name[i], argv[i] ? argv[i] : "null");
+	}
+	return 0;
+}
+
+static gboolean
+backend_resolve_thread (PkBackend *backend, gpointer data)
+{
+	char * error_string;
+	const char * select_statement_template = "SELECT p.name,p.version,p.release,t.name FROM resolvables p JOIN types t ON p.arch = t.id WHERE p.name LIKE \"%s\"";
+	gchar *select_statement;
+	SQLData *sql_data = g_new0(SQLData, 1);
+							  
+
+	printf("\n\nEnter backend_resolve_thread\n");
+	ResolveData *rdata = (ResolveData*) data;
+
+	sqlite3 *db;
+	if (sqlite3_open("/var/cache/zypp/zypp.db", &db) != 0) {
+		pk_backend_error_code(backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Failed to open database");
+		return FALSE;
+	}
+
+	select_statement = g_strdup_printf (select_statement_template, rdata->name);
+	sqlite3_exec (db, select_statement, select_callback, sql_data, &error_string);
+	/*
+	zypp::Target_Ptr target;
+	zypp::ZYpp::Ptr zypp;
+	zypp = get_zypp ();
+
+	target = zypp->target ();
+
+	// Load all the local system "resolvables" (packages)
+	zypp->addResolvables (target->resolvables(), TRUE);
+
+	// Load resolvables from all the enabled repositories
+	zypp::RepoManager manager;
+	std::list <zypp::RepoInfo> repos;
+	try
+	{
+		// TODO: Split the code up so it's not all just in one bit try/catch
+		repos = manager.knownRepositories();
+		for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) {
+			zypp::Repository repository = manager.createFromCache (*it);
+			zypp->addResolvables (repository.resolvables ());
+		}
+
+		// Iterate over the resolvables and mark the ones we want to install
+		//zypp->start ();
+		for (zypp::ResPoolProxy::const_iterator it = zypp->poolProxy().byKindBegin <zypp::Package>();
+				it != zypp->poolProxy().byKindEnd <zypp::Package>(); it++) {
+			zypp::ui::Selectable::Ptr selectable = *it;
+
+		}
+	} catch (const zypp::repo::RepoNotFoundException &ex) {
+		// TODO: make sure this dumps out the right sring.
+		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
+		g_free (package_id);
+		return FALSE;
+	} catch (const zypp::Exception &ex) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Error enumerating repositories");
+		g_free (package_id);
+		return FALSE;
+	}
+	*/
+
+	g_free (rdata->name);
+	g_free (rdata->filter);
+	g_free (rdata);
+	g_free (select_statement);
+	pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+			    "glib2;2.14.0;i386;fedora", "The GLib library");
+	return TRUE;
+}
+
+/**
+ * backend_resolve:
+ */
+static void
+backend_resolve (PkBackend *backend, const gchar *filter, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+	printf("Enter backend_resolve - filter:%s, package_id:%s\n", filter, package_id);
+	ResolveData *data = g_new0(ResolveData, 1);
+	if (data == NULL) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory in backend_resolve");
+		pk_backend_finished (backend);
+	} else {
+		data->name = g_strdup (package_id);
+		data->filter = g_strdup (filter);
+		pk_backend_thread_helper (backend, backend_resolve_thread, data);
+	}
+}
+
 /*
 static gboolean
 backend_refresh_cache_thread (PkBackend *backend, gpointer data)
@@ -530,7 +640,7 @@ extern "C" PK_BACKEND_OPTIONS (
 	NULL,					/* install_file */
 	NULL,//backend_refresh_cache,			/* refresh_cache */
 	NULL,					/* remove_package */
-	NULL,					/* resolve */
+	backend_resolve,		/* resolve */
 	NULL,					/* rollback */
 	NULL,					/* search_details */
 	NULL,					/* search_file */
commit b817396ea3fc8181e84bb2e3b5482574b02bbdbf
Merge: 7c33efb... 5da7daa...
Author: Luke Macken <lmacken at redhat.com>
Date:   Tue Nov 20 13:13:37 2007 -0500

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

commit 7c33efbb58d0889de007b0bdd7b25776b3f2251d
Author: Luke Macken <lmacken at redhat.com>
Date:   Tue Nov 20 13:13:31 2007 -0500

    Fix the manpage corruption issue described in Bug #12796.

diff --git a/man/Makefile.am b/man/Makefile.am
index b03e121..27b73bc 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -10,10 +10,10 @@ endif
 
 if HAVE_DOCBOOK2MAN
 pkcon.1: pkcon.sgml
-	docbook2man $? > $@
+	docbook2man $? > /dev/null
 
 pkmon.1: pkmon.sgml
-	docbook2man $? > $@
+	docbook2man $? > /dev/null
 endif
 
 clean-local :
commit 5da7daae69f19e363a5ec4bb529477d1a6ad64c4
Author: Richard Hughes <richard at hughsie.com>
Date:   Tue Nov 20 18:06:29 2007 +0000

    fix two things. first, we should only invalidate the cache if the transaction succeeded which stops a failed update-system from clearing the update-cache. While we are here, add a small delay to updates-changed so we don't cause a flood

diff --git a/src/pk-engine.c b/src/pk-engine.c
index d58fbf4..73cbe9d 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -58,6 +58,7 @@ static void     pk_engine_init		(PkEngine      *engine);
 static void     pk_engine_finalize	(GObject       *object);
 
 #define PK_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_ENGINE, PkEnginePrivate))
+#define PK_ENGINE_UPDATES_CHANGED_TIMEOUT	100 /* ms */
 
 struct PkEnginePrivate
 {
@@ -480,33 +481,34 @@ pk_engine_files_cb (PkBackend *backend, const gchar *package_id,
 }
 
 /**
- * pk_engine_finished_cb:
+ * pk_engine_finished_updates_changed_cb:
  **/
-static void
-pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
+static gboolean
+pk_engine_finished_updates_changed_cb (gpointer data)
 {
-	PkTransactionItem *item;
-	PkRoleEnum role;
-	const gchar *exit_text;
-	guint time;
-	gchar *packages;
+	const gchar *tid;
+	PkEngine *engine = PK_ENGINE (data);
 
-	g_return_if_fail (engine != NULL);
-	g_return_if_fail (PK_IS_ENGINE (engine));
+	g_return_val_if_fail (engine != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
 
-	item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
-	if (item == NULL) {
-		pk_warning ("could not find backend");
-		return;
-	}
-	/* we might not have this set yet */
-	if (item->backend == NULL) {
-		g_warning ("Backend not set yet!");
-		return;
-	}
+	tid = (const gchar *) g_object_get_data (G_OBJECT (engine), "calling-tid");
 
-	/* get what the role was */
-	pk_backend_get_role (item->backend, &role, NULL);
+	pk_debug ("emitting updates-changed tid:%s", tid);
+	g_signal_emit (engine, signals [PK_ENGINE_UPDATES_CHANGED], 0, tid);
+	return FALSE;
+}
+
+/**
+ * pk_engine_finish_invalidate_caches:
+ **/
+static gboolean
+pk_engine_finish_invalidate_caches (PkEngine *engine, PkTransactionItem *item, PkRoleEnum role)
+{
+	g_return_val_if_fail (engine != NULL, FALSE);
+	g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+
+	pk_debug ("invalidating caches");
 
 	/* copy this into the cache if we are getting updates */
 	if (role == PK_ROLE_ENUM_GET_UPDATES) {
@@ -538,9 +540,53 @@ pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
 			g_object_unref (engine->priv->updates_cache);
 			engine->priv->updates_cache = NULL;
 		}
-		/* this should cause the client program to requeue an update */
-		pk_debug ("emitting updates-changed tid: %s", item->tid);
-		g_signal_emit (engine, signals [PK_ENGINE_UPDATES_CHANGED], 0, item->tid);
+	}
+
+	/* could the update list have changed? */
+	if (role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
+	    role == PK_ROLE_ENUM_UPDATE_PACKAGE ||
+	    role == PK_ROLE_ENUM_REPO_ENABLE ||
+	    role == PK_ROLE_ENUM_REPO_SET_DATA ||
+	    role == PK_ROLE_ENUM_REFRESH_CACHE) {
+		/* this needs to be done after a small delay */
+		g_object_set_data (G_OBJECT (engine), "calling-tid", item->tid);
+		g_timeout_add (PK_ENGINE_UPDATES_CHANGED_TIMEOUT, pk_engine_finished_updates_changed_cb, engine);
+	}
+	return TRUE;
+}
+
+/**
+ * pk_engine_finished_cb:
+ **/
+static void
+pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
+{
+	PkTransactionItem *item;
+	PkRoleEnum role;
+	const gchar *exit_text;
+	guint time;
+	gchar *packages;
+
+	g_return_if_fail (engine != NULL);
+	g_return_if_fail (PK_IS_ENGINE (engine));
+
+	item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
+	if (item == NULL) {
+		pk_warning ("could not find backend");
+		return;
+	}
+	/* we might not have this set yet */
+	if (item->backend == NULL) {
+		g_warning ("Backend not set yet!");
+		return;
+	}
+
+	/* get what the role was */
+	pk_backend_get_role (item->backend, &role, NULL);
+
+	/* invalidate some caches if we succeeded*/
+	if (exit == PK_EXIT_ENUM_SUCCESS) {
+		pk_engine_finish_invalidate_caches (engine, item, role);
 	}
 
 	/* find the length of time we have been running */
@@ -556,14 +602,6 @@ pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
 	pk_debug ("backend was running for %i ms", time);
 	pk_transaction_db_set_finished (engine->priv->transaction_db, item->tid, TRUE, time);
 
-	/* could the update list have changed? */
-	if (role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
-	    role == PK_ROLE_ENUM_UPDATE_PACKAGE ||
-	    role == PK_ROLE_ENUM_REFRESH_CACHE) {
-		pk_debug ("emitting updates-changed tid:%s", item->tid);
-		g_signal_emit (engine, signals [PK_ENGINE_UPDATES_CHANGED], 0, item->tid);
-	}
-
 	exit_text = pk_exit_enum_to_text (exit);
 	pk_debug ("emitting finished transaction:%s, '%s', %i", item->tid, exit_text, time);
 	g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, exit_text, time);
commit d13ddb5462d174cfd21fca6c09d3999117638119
Author: Luke Macken <lmacken at redhat.com>
Date:   Tue Nov 20 11:43:30 2007 -0500

    Fix incorrect title on FAQ page

diff --git a/html/pk-faq.html b/html/pk-faq.html
index ed0fe5a..88cabc4 100644
--- a/html/pk-faq.html
+++ b/html/pk-faq.html
@@ -8,7 +8,7 @@
 <table align="center" class="title">
 <tr>
  <td><center><img src="img/packagekit.png"/></center></td>
- <td width="95%" valign="middle"><p class="title">Screenshots</p></td>
+ <td width="95%" valign="middle"><p class="title">Frequently asked questions</p></td>
  <td><center><img src="img/packagekit.png"/></center></td>
 </tr>
 </table>
commit 4c025ab7dddc64a26634a5ba6fc04376997258b6
Author: Boyd Timothy <btimothy at gmail.com>
Date:   Fri Nov 16 09:41:21 2007 -0700

    More backend_install_package updates for zypp backend.

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 663f812..68c59fe 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -180,6 +180,7 @@ backend_install_package_thread (PkBackend *backend, gpointer data)
 	std::list <zypp::RepoInfo> repos;
 	try
 	{
+		// TODO: Split the code up so it's not all just in one bit try/catch
 		repos = manager.knownRepositories();
 		for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) {
 			zypp::Repository repository = manager.createFromCache (*it);
@@ -188,9 +189,13 @@ backend_install_package_thread (PkBackend *backend, gpointer data)
 
 		// Iterate over the resolvables and mark the ones we want to install
 		//zypp->start ();
-		
+		for (zypp::ResPoolProxy::const_iterator it = zypp->poolProxy().byKindBegin <zypp::Package>();
+				it != zypp->poolProxy().byKindEnd <zypp::Package>(); it++) {
+			zypp::ui::Selectable::Ptr selectable = *it;
+			
+		}
 	} catch (const zypp::repo::RepoNotFoundException &ex) {
-		// FIXME: make sure this dumps out the right sring.
+		// TODO: make sure this dumps out the right sring.
 		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
 		g_free (package_id);
 		return FALSE;
@@ -200,6 +205,7 @@ backend_install_package_thread (PkBackend *backend, gpointer data)
 		return FALSE;
 	}
 
+	pk_backend_finished (backend);
 	g_free (package_id);
 	return TRUE;
 }
commit 826273343ea657a6d48c0ca2457854c102edbdeb
Author: Boyd Timothy <btimothy at gmail.com>
Date:   Fri Nov 16 09:08:28 2007 -0700

    Stubbing out more of the backend_install_package for zypp backend.

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index e9aaaa3..663f812 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -78,6 +78,28 @@ typedef zypp::Language::constPtr	ZyppLanguage;
 inline ZyppPackage tryCastToZyppPkg (ZyppObject obj)
 	{ return zypp::dynamic_pointer_cast <const zypp::Package> (obj); }
 
+/**
+ * Initialize Zypp (Factory method)
+ */
+static zypp::ZYpp::Ptr
+get_zypp ()
+{
+	static gboolean initialized = FALSE;
+	zypp::ZYpp::Ptr zypp = NULL;
+
+	zypp = zypp::ZYppFactory::instance ().getZYpp ();
+	
+	// TODO: Make this threadsafe
+	if (initialized == FALSE) {
+		zypp::filesystem::Pathname pathname("/");
+		zypp->initializeTarget (pathname);
+
+		initialized = TRUE;
+	}
+
+	return zypp;
+}
+
 static gboolean
 backend_get_description_thread (PkBackend *backend, gpointer data)
 {
@@ -138,20 +160,60 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 		pk_backend_thread_helper (backend, backend_get_description_thread, data);
 	}
 }
+
+static gboolean
+backend_install_package_thread (PkBackend *backend, gpointer data)
+{
+	gchar *package_id = (gchar *)data;
+	zypp::Target_Ptr target;
+
+	zypp::ZYpp::Ptr zypp;
+	zypp = get_zypp ();
+
+	target = zypp->target ();
+
+	// Load all the local system "resolvables" (packages)
+	zypp->addResolvables (target->resolvables(), TRUE);
+
+	// Load resolvables from all the enabled repositories
+	zypp::RepoManager manager;
+	std::list <zypp::RepoInfo> repos;
+	try
+	{
+		repos = manager.knownRepositories();
+		for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) {
+			zypp::Repository repository = manager.createFromCache (*it);
+			zypp->addResolvables (repository.resolvables ());
+		}
+
+		// Iterate over the resolvables and mark the ones we want to install
+		//zypp->start ();
+		
+	} catch (const zypp::repo::RepoNotFoundException &ex) {
+		// FIXME: make sure this dumps out the right sring.
+		pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, ex.asUserString().c_str() );
+		g_free (package_id);
+		return FALSE;
+	} catch (const zypp::Exception &ex) {
+		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Error enumerating repositories");
+		g_free (package_id);
+		return FALSE;
+	}
+
+	g_free (package_id);
+	return TRUE;
+}
+
 /**
  * backend_install_package:
  */
-
 static void
 backend_install_package (PkBackend *backend, const gchar *package_id)
 {
 	g_return_if_fail (backend != NULL);
 
-	zypp::filesystem::Pathname pathname("/");
-	//zypp::ZYpp zypper;
-
-	//zypper.initializeTarget(pathname);
-
+	gchar *package_to_install = g_strdup (package_id);
+	pk_backend_thread_helper (backend, backend_install_package_thread, package_to_install);
 
 	/*
 	if(strcmp(package_id,"signedpackage;1.0-1.fc8;i386;fedora") == 0) {
commit db83798a2d6cb6abb913be49a0059bed9bbdb20f
Author: Scott Reeves <sreeves at novell.com>
Date:   Mon Nov 19 18:35:33 2007 -0700

    stub out backend_install_package

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 83e4f31..e9aaaa3 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -41,6 +41,7 @@
 #include <zypp/RepoInfo.h>
 #include <zypp/repo/RepoException.h>
 #include <zypp/parser/ParseException.h>
+#include <zypp/Pathname.h>
 
 enum PkgSearchType {
 	SEARCH_TYPE_NAME = 0,
@@ -137,6 +138,39 @@ backend_get_description (PkBackend *backend, const gchar *package_id)
 		pk_backend_thread_helper (backend, backend_get_description_thread, data);
 	}
 }
+/**
+ * backend_install_package:
+ */
+
+static void
+backend_install_package (PkBackend *backend, const gchar *package_id)
+{
+	g_return_if_fail (backend != NULL);
+
+	zypp::filesystem::Pathname pathname("/");
+	//zypp::ZYpp zypper;
+
+	//zypper.initializeTarget(pathname);
+
+
+	/*
+	if(strcmp(package_id,"signedpackage;1.0-1.fc8;i386;fedora") == 0) {
+		pk_backend_repo_signature_required(backend, "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);
+	}
+
+	progress_percentage = 0;
+	pk_backend_package (backend, PK_INFO_ENUM_DOWNLOADING,
+			    "gtkhtml2;2.19.1-4.fc8;i386;fedora",
+			    "An HTML widget for GTK+ 2.0");
+	g_timeout_add (1000, backend_install_timeout, backend);
+	*/
+}
 
 /*
 static gboolean
@@ -424,7 +458,7 @@ extern "C" PK_BACKEND_OPTIONS (
 	NULL,					/* get_requires */
 	NULL,					/* get_update_detail */
 	NULL,					/* get_updates */
-	NULL,					/* install_package */
+	backend_install_package,		/* install_package */
 	NULL,					/* install_file */
 	NULL,//backend_refresh_cache,			/* refresh_cache */
 	NULL,					/* remove_package */
commit 3ab798fd0c5c9a2e099cd135a746f11305b91deb
Merge: c545f1d... 94843f6...
Author: Scott Reeves <sreeves at novell.com>
Date:   Mon Nov 19 18:03:49 2007 -0700

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

commit c545f1d3f626bdc4e1c4840724bff5b5b4f919a4
Author: Scott Reeves <sreeves at novell.com>
Date:   Mon Nov 19 17:43:39 2007 -0700

    minor indent cleanup

diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 9734a29..431cc94 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -305,7 +305,7 @@ backend_get_repo_list (PkBackend *backend)
 static void
 backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
 {
-        g_return_if_fail (backend != NULL);
+	g_return_if_fail (backend != NULL);
 
 	zypp::RepoManager manager;
 	zypp::RepoInfo repo;
@@ -322,7 +322,7 @@ backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
 		pk_backend_error_code (backend, PK_ERROR_ENUM_INTERNAL_ERROR, "Could not enable/disable the repo");
 	}
 
-        pk_backend_finished (backend);
+	pk_backend_finished (backend);
 }
 
 extern "C" PK_BACKEND_OPTIONS (



More information about the PackageKit mailing list