[packagekit] packagekit: Branch 'master' - 12 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Thu Nov 15 15:35:52 PST 2007
AUTHORS | 1
backends/box/pk-backend-box.c | 12 ++
backends/conary/helpers/Makefile.am | 2
backends/conary/helpers/conaryCallback.py | 20 ++--
backends/zypp/pk-backend-zypp.cpp | 133 ++++++++++++++++++++++++++----
configure.ac | 2
libpackagekit/pk-enum.c | 4
libpackagekit/pk-enum.h | 4
src/Makefile.am | 1
src/pk-backend-internal.h | 4
src/pk-backend.c | 67 ++++++++++++++-
src/pk-engine.c | 128 ++++++++++++++++++++++++++--
12 files changed, 341 insertions(+), 37 deletions(-)
New commits:
commit 5d2fc21e28dda57d46a98e94fc4e065cef5f3885
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Nov 15 23:29:39 2007 +0000
flow through connection changed to the daemon
diff --git a/src/pk-backend.c b/src/pk-backend.c
index eef2e47..d770ba0 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -110,6 +110,7 @@ enum {
PK_BACKEND_CHANGE_TRANSACTION_DATA,
PK_BACKEND_FINISHED,
PK_BACKEND_ALLOW_INTERRUPT,
+ PK_BACKEND_CALLER_ACTIVE_CHANGED,
PK_BACKEND_REPO_DETAIL,
PK_BACKEND_LAST_SIGNAL
};
@@ -1188,7 +1189,7 @@ pk_backend_allow_interrupt (PkBackend *backend, gboolean allow_restart)
pk_inhibit_add (backend->priv->inhibit, backend);
}
- g_signal_emit (backend, signals [PK_BACKEND_ALLOW_INTERRUPT], 0);
+ g_signal_emit (backend, signals [PK_BACKEND_ALLOW_INTERRUPT], 0, allow_restart);
return TRUE;
}
@@ -1868,7 +1869,7 @@ static void
pk_backend_connection_changed_cb (LibGBus *libgbus, gboolean connected, PkBackend *backend)
{
pk_warning ("client disconnected.... %i", connected);
-// g_signal_emit (backend , signals [CONNECTION_CHANGED], 0, connected);
+ g_signal_emit (backend, signals [PK_BACKEND_CALLER_ACTIVE_CHANGED], 0, FALSE);
}
/**
@@ -1995,6 +1996,11 @@ pk_backend_class_init (PkBackendClass *klass)
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ signals [PK_BACKEND_CALLER_ACTIVE_CHANGED] =
+ g_signal_new ("caller-active-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
signals [PK_BACKEND_REPO_DETAIL] =
g_signal_new ("repo-detail",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 304930b..d58fbf4 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -594,6 +594,27 @@ pk_engine_allow_interrupt_cb (PkBackend *backend, gboolean allow_kill, PkEngine
}
/**
+ * pk_engine_caller_active_changed_cb:
+ **/
+static void
+pk_engine_caller_active_changed_cb (PkBackend *backend, gboolean is_active, PkEngine *engine)
+{
+ PkTransactionItem *item;
+
+ 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;
+ }
+
+ pk_debug ("emitting caller-active-changed tid:%s, %i", item->tid, is_active);
+ g_signal_emit (engine, signals [PK_ENGINE_CALLER_ACTIVE_CHANGED], 0, item->tid, is_active);
+}
+
+/**
* pk_engine_change_transaction_data_cb:
**/
static void
@@ -685,6 +706,8 @@ pk_engine_backend_new (PkEngine *engine)
G_CALLBACK (pk_engine_change_transaction_data_cb), engine);
g_signal_connect (backend, "repo-detail",
G_CALLBACK (pk_engine_repo_detail_cb), engine);
+ g_signal_connect (backend, "caller-active-changed",
+ G_CALLBACK (pk_engine_caller_active_changed_cb), engine);
/* initialise some stuff */
pk_engine_reset_timer (engine);
commit c8f3726f8794628120ac1527e9b9294538182b26
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Nov 15 23:18:17 2007 +0000
add the initial user tracking code to is_caller_active
diff --git a/src/Makefile.am b/src/Makefile.am
index a9629d8..6d9de76 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,6 +26,7 @@ INCLUDES = \
-DLOCALSTATEDIR=\""$(localstatedir)"\" \
-I$(top_srcdir)/libpackagekit \
-I$(top_srcdir)/libselftest \
+ -I$(top_srcdir)/libgbus \
$(NULL)
pkbackendincludedir=$(includedir)/packagekit-backend
diff --git a/src/pk-backend-internal.h b/src/pk-backend-internal.h
index 168c597..f71c7c0 100644
--- a/src/pk-backend-internal.h
+++ b/src/pk-backend-internal.h
@@ -121,6 +121,10 @@ gboolean pk_backend_get_progress (PkBackend *backend,
guint *remaining);
gboolean pk_backend_get_package (PkBackend *backend,
gchar **package_id);
+gboolean pk_backend_set_dbus_name (PkBackend *backend,
+ const gchar *dbus_name);
+gboolean pk_backend_is_caller_active (PkBackend *backend,
+ gboolean *is_active);
/* these are external in nature, but we shouldn't be using them in helpers */
gboolean pk_backend_set_role (PkBackend *backend,
diff --git a/src/pk-backend.c b/src/pk-backend.c
index efb7545..eef2e47 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -37,6 +37,8 @@
#include <glib/gi18n.h>
#include <gmodule.h>
+#include <libgbus.h>
+
#include <pk-common.h>
#include <pk-package-id.h>
#include <pk-enum.h>
@@ -74,6 +76,7 @@ struct _PkBackendPrivate
PkExitEnum exit;
PkTime *time;
PkSpawn *spawn;
+ LibGBus *libgbus;
gboolean is_killable;
gboolean during_initialize;
gboolean assigned;
@@ -86,6 +89,7 @@ struct _PkBackendPrivate
guint last_subpercentage;
guint last_remaining;
gchar *last_package;
+ gchar *dbus_name;
PkThreadList *thread_list;
gulong signal_finished;
gulong signal_stdout;
@@ -1693,6 +1697,9 @@ PkEnumList *
pk_backend_get_actions (PkBackend *backend)
{
PkEnumList *elist;
+
+ g_return_val_if_fail (backend != NULL, NULL);
+
elist = pk_enum_list_new ();
pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ROLE);
if (backend->desc->cancel != NULL) {
@@ -1773,6 +1780,9 @@ PkEnumList *
pk_backend_get_groups (PkBackend *backend)
{
PkEnumList *elist;
+
+ g_return_val_if_fail (backend != NULL, NULL);
+
elist = pk_enum_list_new ();
pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_GROUP);
if (backend->desc->get_groups != NULL) {
@@ -1790,6 +1800,9 @@ PkEnumList *
pk_backend_get_filters (PkBackend *backend)
{
PkEnumList *elist;
+
+ g_return_val_if_fail (backend != NULL, NULL);
+
elist = pk_enum_list_new ();
pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_FILTER);
if (backend->desc->get_filters != NULL) {
@@ -1806,6 +1819,7 @@ pk_backend_get_filters (PkBackend *backend)
guint
pk_backend_get_runtime (PkBackend *backend)
{
+ g_return_val_if_fail (backend != NULL, 0);
return pk_time_get_elapsed (backend->priv->time);
}
@@ -1815,10 +1829,49 @@ pk_backend_get_runtime (PkBackend *backend)
gboolean
pk_backend_network_is_online (PkBackend *backend)
{
+ g_return_val_if_fail (backend != NULL, FALSE);
return pk_network_is_online (backend->priv->network);
}
/**
+ * pk_backend_set_dbus_name:
+ */
+gboolean
+pk_backend_set_dbus_name (PkBackend *backend, const gchar *dbus_name)
+{
+ g_return_val_if_fail (backend != NULL, FALSE);
+ if (backend->priv->dbus_name != NULL) {
+ pk_warning ("you can't assign more than once!");
+ return FALSE;
+ }
+ backend->priv->dbus_name = g_strdup (dbus_name);
+ pk_debug ("assiging %s to %p", dbus_name, backend);
+ libgbus_assign (backend->priv->libgbus, LIBGBUS_SYSTEM, dbus_name);
+ return TRUE;
+}
+
+/**
+ * pk_backend_is_caller_active:
+ */
+gboolean
+pk_backend_is_caller_active (PkBackend *backend, gboolean *is_active)
+{
+ g_return_val_if_fail (backend != NULL, FALSE);
+ *is_active = libgbus_is_connected (backend->priv->libgbus);
+ return TRUE;
+}
+
+/**
+ * pk_backend_connection_changed_cb:
+ **/
+static void
+pk_backend_connection_changed_cb (LibGBus *libgbus, gboolean connected, PkBackend *backend)
+{
+ pk_warning ("client disconnected.... %i", connected);
+// g_signal_emit (backend , signals [CONNECTION_CHANGED], 0, connected);
+}
+
+/**
* pk_backend_finalize:
**/
static void
@@ -1840,6 +1893,7 @@ pk_backend_finalize (GObject *object)
pk_backend_unload (backend);
g_free (backend->priv->last_package);
+ g_free (backend->priv->dbus_name);
g_free (backend->priv->xcached_package_id);
g_free (backend->priv->xcached_transaction_id);
g_free (backend->priv->xcached_filter);
@@ -1964,6 +2018,7 @@ pk_backend_init (PkBackend *backend)
backend->priv->finished = FALSE;
backend->priv->spawn = NULL;
backend->priv->handle = NULL;
+ backend->priv->dbus_name = NULL;
backend->priv->xcached_enabled = FALSE;
backend->priv->xcached_package_id = NULL;
backend->priv->xcached_transaction_id = NULL;
@@ -1984,6 +2039,10 @@ pk_backend_init (PkBackend *backend)
backend->priv->inhibit = pk_inhibit_new ();
backend->priv->network = pk_network_new ();
backend->priv->thread_list = pk_thread_list_new ();
+
+ backend->priv->libgbus = libgbus_new ();
+ g_signal_connect (backend->priv->libgbus, "connection-changed",
+ G_CALLBACK (pk_backend_connection_changed_cb), backend);
}
/**
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 24c47ae..304930b 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -841,6 +841,9 @@ pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force, DBu
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
/* we unref the update cache if it exists */
if (engine->priv->updates_cache != NULL) {
pk_debug ("unreffing updates cache");
@@ -893,6 +896,9 @@ pk_engine_get_updates (PkEngine *engine, const gchar *tid, DBusGMethodInvocation
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
/* try and reuse cache */
if (engine->priv->updates_cache != NULL) {
PkPackageItem *package;
@@ -1050,6 +1056,9 @@ pk_engine_search_name (PkEngine *engine, const gchar *tid, const gchar *filter,
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_search_name (item->backend, filter, search);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1109,6 +1118,9 @@ pk_engine_search_details (PkEngine *engine, const gchar *tid, const gchar *filte
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_search_details (item->backend, filter, search);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1168,6 +1180,9 @@ pk_engine_search_group (PkEngine *engine, const gchar *tid, const gchar *filter,
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_search_group (item->backend, filter, search);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1227,6 +1242,9 @@ pk_engine_search_file (PkEngine *engine, const gchar *tid, const gchar *filter,
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_search_file (item->backend, filter, search);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1288,6 +1306,9 @@ pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *filter,
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_resolve (item->backend, filter, package);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1351,6 +1372,9 @@ pk_engine_get_depends (PkEngine *engine, const gchar *tid, const gchar *package_
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_get_depends (item->backend, package_id, recursive);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1414,6 +1438,9 @@ pk_engine_get_requires (PkEngine *engine, const gchar *tid, const gchar *package
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_get_requires (item->backend, package_id, recursive);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1477,6 +1504,9 @@ pk_engine_get_update_detail (PkEngine *engine, const gchar *tid, const gchar *pa
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_get_update_detail (item->backend, package_id);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1540,6 +1570,9 @@ pk_engine_get_description (PkEngine *engine, const gchar *tid, const gchar *pack
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_get_description (item->backend, package_id);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1603,6 +1636,9 @@ pk_engine_get_files (PkEngine *engine, const gchar *tid, const gchar *package_id
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_get_files (item->backend, package_id);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1665,6 +1701,9 @@ pk_engine_update_system (PkEngine *engine, const gchar *tid, DBusGMethodInvocati
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_update_system (item->backend);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1739,6 +1778,9 @@ pk_engine_remove_package (PkEngine *engine, const gchar *tid, const gchar *packa
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_remove_package (item->backend, package_id, allow_deps);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1813,6 +1855,9 @@ pk_engine_install_package (PkEngine *engine, const gchar *tid, const gchar *pack
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_install_package (item->backend, package_id);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1878,6 +1923,9 @@ pk_engine_install_file (PkEngine *engine, const gchar *tid, const gchar *full_pa
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_install_file (item->backend, full_path);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -1943,6 +1991,9 @@ pk_engine_rollback (PkEngine *engine, const gchar *tid, const gchar *transaction
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_rollback (item->backend, transaction_id);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -2016,6 +2067,9 @@ pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *packa
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_update_package (item->backend, package_id);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -2061,6 +2115,9 @@ pk_engine_get_repo_list (PkEngine *engine, const gchar *tid, DBusGMethodInvocati
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_get_repo_list (item->backend);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -2125,6 +2182,9 @@ pk_engine_repo_enable (PkEngine *engine, const gchar *tid, const gchar *repo_id,
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_repo_enable (item->backend, repo_id, enabled);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -2191,6 +2251,9 @@ pk_engine_repo_set_data (PkEngine *engine, const gchar *tid, const gchar *repo_i
return;
}
+ /* set the dbus name, so we can get the disconnect */
+ pk_backend_set_dbus_name (item->backend, dbus_g_method_get_sender (context));
+
ret = pk_backend_repo_set_data (item->backend, repo_id, parameter, value);
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
@@ -2414,6 +2477,38 @@ pk_engine_cancel (PkEngine *engine, const gchar *tid, GError **error)
}
/**
+ * pk_engine_is_caller_active:
+ **/
+gboolean
+pk_engine_is_caller_active (PkEngine *engine, const gchar *tid, gboolean *is_active, GError **error)
+{
+ gboolean ret;
+ PkTransactionItem *item;
+
+ g_return_val_if_fail (engine != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+
+ pk_debug ("is caller active: %s", tid);
+
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
+ "No tid:%s", tid);
+ return FALSE;
+ }
+
+ /* is the caller still active? */
+ ret = pk_backend_is_caller_active (item->backend, is_active);
+ if (ret == FALSE) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED, "We don't know if the caller is still there");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
* pk_engine_get_actions:
**/
gboolean
@@ -2477,16 +2572,6 @@ pk_engine_get_backend_detail (PkEngine *engine, gchar **name, gchar **author, GE
}
/**
- * pk_engine_is_caller_active:
- **/
-gboolean
-pk_engine_is_caller_active (PkEngine *engine, const gchar *tid, gboolean *is_active, GError **error)
-{
- //FIXME: handle NOC
- return TRUE;
-}
-
-/**
* pk_engine_transaction_cb:
**/
static void
commit 40c950b406aca882fff32a936273a8a5aae2b832
Author: Boyd Timothy <btimothy at gmail.com>
Date: Thu Nov 15 16:16:49 2007 -0700
Stubbed out backend_get_description in zypp backend.
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 1c767b7..eb1fdef 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -23,6 +23,7 @@
#include <glib.h>
#include <string.h>
#include <pk-backend.h>
+#include <unistd.h>
#include <pk-debug.h>
#include <zypp/ZYppFactory.h>
@@ -38,6 +39,79 @@
#include <zypp/Repository.h>
#include <zypp/RepoManager.h>
+typedef struct {
+ gchar *package_id;
+ gint type;
+} ThreadData;
+
+// some typedefs and functions to shorten Zypp names
+typedef zypp::ResPoolProxy ZyppPool;
+inline ZyppPool zyppPool() { return zypp::getZYpp()->poolProxy(); }
+typedef zypp::ui::Selectable::Ptr ZyppSelectable;
+typedef zypp::ui::Selectable* ZyppSelectablePtr;
+typedef zypp::ResObject::constPtr ZyppObject;
+typedef zypp::Package::constPtr ZyppPackage;
+typedef zypp::Patch::constPtr ZyppPatch;
+typedef zypp::Pattern::constPtr ZyppPattern;
+typedef zypp::Language::constPtr ZyppLanguage;
+inline ZyppPackage tryCastToZyppPkg (ZyppObject obj)
+ { return zypp::dynamic_pointer_cast <const zypp::Package> (obj); }
+
+static gboolean
+backend_get_description_thread (PkBackend *backend, gpointer data)
+{
+ PkPackageId *pi;
+ ThreadData *d = (ThreadData*) data;
+
+ pi = pk_package_id_new_from_string (d->package_id);
+ if (pi == NULL) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "invalid package id");
+ pk_package_id_free (pi);
+ g_free (d->package_id);
+ g_free (d);
+ return FALSE;
+ }
+
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+
+ // FIXME: Call libzypp here to get the "Selectable"
+
+ pk_backend_description (backend,
+ pi->name, // package_id
+ "unknown", // const gchar *license
+ PK_GROUP_ENUM_OTHER, // PkGroupEnum group
+ "FIXME: put package description here", // const gchar *description
+ "FIXME: add package URL here", // const gchar *url
+ 0, // gulong size
+ "FIXME: put package filelist here"); // const gchar *filelist
+
+ pk_package_id_free (pi);
+ g_free (d->package_id);
+ g_free (d);
+
+ return TRUE;
+}
+
+/**
+ * backend_get_description:
+ */
+static void
+backend_get_description (PkBackend *backend, const gchar *package_id)
+{
+ g_return_if_fail (backend != NULL);
+
+ ThreadData *data = g_new0(ThreadData, 1);
+ if (data == NULL) {
+ pk_backend_error_code(backend, PK_ERROR_ENUM_OOM, "Failed to allocate memory in backend_get_description");
+ pk_backend_finished (backend);
+ } else {
+ data->package_id = g_strdup(package_id);
+ pk_backend_thread_helper (backend, backend_get_description_thread, data);
+ }
+}
+
+
+
/**
* backend_get_repo_list:
*/
@@ -97,7 +171,7 @@ extern "C" PK_BACKEND_OPTIONS (
NULL, /* get_filters */
NULL, /* cancel */
NULL, /* get_depends */
- NULL, /* get_description */
+ backend_get_description, /* get_description */
NULL, /* get_files */
NULL, /* get_requires */
NULL, /* get_update_detail */
commit 92ade53f9bac3eea92fa579228f7b91af4709e65
Author: Boyd Timothy <btimothy at gmail.com>
Date: Thu Nov 15 14:25:43 2007 -0700
Making zypp's backend_get_repo_list a bit more robust and stubbing out backend_repo_enable
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 0377e05..1c767b7 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -23,18 +23,19 @@
#include <glib.h>
#include <string.h>
#include <pk-backend.h>
+#include <pk-debug.h>
-//#include <zypp/ZYppFactory.h>
-//#include <zypp/ResObject.h>
-//#include <zypp/ResPoolProxy.h>
-//#include <zypp/ui/Selectable.h>
-//#include <zypp/Patch.h>
-//#include <zypp/Selection.h>
-//#include <zypp/Package.h>
-//#include <zypp/Pattern.h>
-//#include <zypp/Language.h>
-//#include <zypp/Product.h>
-//#include <zypp/Repository.h>
+#include <zypp/ZYppFactory.h>
+#include <zypp/ResObject.h>
+#include <zypp/ResPoolProxy.h>
+#include <zypp/ui/Selectable.h>
+#include <zypp/Patch.h>
+#include <zypp/Selection.h>
+#include <zypp/Package.h>
+#include <zypp/Pattern.h>
+#include <zypp/Language.h>
+#include <zypp/Product.h>
+#include <zypp/Repository.h>
#include <zypp/RepoManager.h>
/**
@@ -45,18 +46,48 @@ backend_get_repo_list (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+
zypp::RepoManager manager;
std::list <zypp::RepoInfo> repos = manager.knownRepositories();
for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) {
+ // RepoInfo::alias - Unique identifier for this source.
+ // RepoInfo::name - Short label or description of the
+ // repository, to be used on the user interface
pk_backend_repo_detail (backend,
- it->name().c_str(),
it->alias().c_str(),
+ it->name().c_str(),
it->enabled());
}
pk_backend_finished (backend);
}
+/**
+ * backend_repo_enable:
+ */
+static void
+backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
+{
+ g_return_if_fail (backend != NULL);
+
+ zypp::RepoManager manager;
+ zypp::RepoInfo repo;
+
+ try {
+ repo = manager.getRepositoryInfo (rid);
+ } catch (...) { // FIXME: Don't just catch all exceptions
+ pk_backend_error_code (backend, PK_ERROR_ENUM_REPO_NOT_FOUND, "Couldn't find the specified repository");
+ pk_backend_finished (backend);
+ return;
+ }
+
+ // FIXME: Do we need to check for errors when calling repo.setEnabled ()?
+ repo.setEnabled (enabled);
+
+ pk_backend_finished (backend);
+}
+
extern "C" PK_BACKEND_OPTIONS (
"Zypp", /* description */
"Boyd Timothy <btimothy at gmail.com>, Scott Reeves <sreeves at novell.com>", /* author */
@@ -84,6 +115,6 @@ extern "C" PK_BACKEND_OPTIONS (
NULL, /* update_package */
NULL, /* update_system */
backend_get_repo_list, /* get_repo_list */
- NULL, /* repo_enable */
+ backend_repo_enable, /* repo_enable */
NULL /* repo_set_data */
);
commit e3eb05a96870f71d7539970231b91c3840be02e6
Author: Scott Reeves <sreeves at novell.com>
Date: Thu Nov 15 13:24:45 2007 -0700
First commit to test access - add myself to AUTHORS
diff --git a/AUTHORS b/AUTHORS
index c43a27b..8db406c 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -13,3 +13,4 @@ Backend: pisi
Backend: zypp
Boyd Timothy <btimothy at gmail.com>
+ Scott Reeves <sreeves at novell.com>
commit c60f3f3cedbb199add3074a8e898b05ed7a5a2b8
Author: Ken VanDine <ken at vandine.org>
Date: Thu Nov 15 15:14:32 2007 -0500
Added get-files.py and resolve.py to dist files
diff --git a/backends/conary/helpers/Makefile.am b/backends/conary/helpers/Makefile.am
index 8749b54..85e2364 100644
--- a/backends/conary/helpers/Makefile.am
+++ b/backends/conary/helpers/Makefile.am
@@ -12,8 +12,10 @@ dist_helper_DATA = \
install.py \
refresh-cache.py \
remove.py \
+ resolve.py \
update-system.py \
get-description.py \
+ get-files.py \
conaryBackend.py \
conaryCallback.py \
$(NULL)
commit 2b871db719772e2a633863aeb2e8fd943ab54f83
Author: Elliot Peele <elliot at enki.rdu.rpath.com>
Date: Thu Nov 15 14:29:15 2007 -0500
use new enums
diff --git a/backends/conary/helpers/conaryCallback.py b/backends/conary/helpers/conaryCallback.py
index b454b6a..ce500d7 100644
--- a/backends/conary/helpers/conaryCallback.py
+++ b/backends/conary/helpers/conaryCallback.py
@@ -15,15 +15,15 @@ from packagekit.backend import *
class UpdateCallback(callbacks.UpdateCallback):
def resolvingDependencies(self):
#self.backend.status('Resolving Dependencies')
- pass
+ self.backend.status(STATUS_DEP_RESOLVE)
def creatingRollback(self):
#self.backend.status('Creating Rollback')
- pass
+ self.backend.status(STATUS_ROLLBACK)
def committingTransaction(self):
#self.backend.status('Committing Transaction')
- pass
+ self.backend.status(STATUS_COMMIT)
def downloadingFileContents(self, got, need):
#self.backend.status('Downloading files for changeset')
@@ -34,11 +34,11 @@ class UpdateCallback(callbacks.UpdateCallback):
def requestingFileContents(self):
#self.backend.status('Requesting File Contents')
- pass
+ self.backend.status(STATUS_REQUEST)
def requestingChangeSet(self):
#self.backend.status('Requesting Changeset')
- pass
+ self.backend.status(STATUS_REQUEST)
def done(self):
#self.backend.status('Done')
commit 170009aa87dae36458afcd215d4908523f1b0624
Merge: ffee345... 58934bf...
Author: Elliot Peele <elliot at enki.rdu.rpath.com>
Date: Thu Nov 15 14:24:09 2007 -0500
Merge branch 'master' of git+ssh://git.packagekit.org/srv/git/PackageKit
commit 58934bf14bd58b374b79564f274e7921921330a9
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date: Thu Nov 15 19:27:53 2007 +0000
[box] set status
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index 1906df1..48ff087 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -337,6 +337,8 @@ backend_get_files_thread (PkBackend *backend, gpointer data)
return FALSE;
}
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+
files = box_db_repos_get_files_string (db, pi->name, pi->version);
pk_backend_files (backend, d->package_id, files);
@@ -410,6 +412,8 @@ backend_remove_package_thread (PkBackend *backend, gpointer data)
return FALSE;
}
+ pk_backend_change_status (backend, PK_STATUS_ENUM_REMOVE);
+
if (!box_package_uninstall (pi->name, "/", common_progress, backend))
{
pk_backend_error_code (backend, PK_ERROR_ENUM_DEP_RESOLUTION_FAILED, "Cannot uninstall");
@@ -425,6 +429,8 @@ backend_remove_package_thread (PkBackend *backend, gpointer data)
static gboolean
backend_refresh_cache_thread (PkBackend *backend, gpointer data)
{
+ pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
+
box_repos_sync(common_progress, backend);
return TRUE;
@@ -592,7 +598,6 @@ backend_refresh_cache (PkBackend *backend, gboolean force)
pk_backend_finished (backend);
return;
}
- pk_backend_change_status (backend, PK_STATUS_ENUM_REFRESH_CACHE);
pk_backend_thread_helper (backend, backend_refresh_cache_thread, NULL);
}
@@ -694,6 +699,7 @@ backend_get_repo_list (PkBackend *backend)
g_return_if_fail (backend != NULL);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
list = box_repos_list_get ();
for (li = list; li != NULL; li=li->next)
@@ -714,6 +720,8 @@ backend_repo_enable (PkBackend *backend, const gchar *rid, gboolean enabled)
{
g_return_if_fail (backend != NULL);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+
box_repos_enable_repo(rid, enabled);
pk_backend_finished (backend);
@@ -727,6 +735,8 @@ backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parame
{
g_return_if_fail (backend != NULL);
+ pk_backend_change_status (backend, PK_STATUS_ENUM_QUERY);
+
if (!box_repos_set_param (rid, parameter, value))
{
pk_warning ("Cannot set PARAMETER '%s' TO '%s' for REPO '%s'", parameter, value, rid);
commit 83853ddd61cce91755259940772c93be1f292f56
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Nov 15 18:09:06 2007 +0000
add some more status constants
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index 222f5bb..8ec731e 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -53,6 +53,10 @@ static PkEnumMatch enum_status[] = {
{PK_STATUS_ENUM_UPDATE, "update"},
{PK_STATUS_ENUM_CLEANUP, "cleanup"},
{PK_STATUS_ENUM_OBSOLETE, "obsolete"},
+ {PK_STATUS_ENUM_DEP_RESOLVE, "dep-resolve"},
+ {PK_STATUS_ENUM_ROLLBACK, "rollback"},
+ {PK_STATUS_ENUM_COMMIT, "commit"},
+ {PK_STATUS_ENUM_REQUEST, "request"},
{0, NULL},
};
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 3d8103d..07cec3a 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -79,6 +79,10 @@ typedef enum {
PK_STATUS_ENUM_UPDATE,
PK_STATUS_ENUM_CLEANUP,
PK_STATUS_ENUM_OBSOLETE,
+ PK_STATUS_ENUM_DEP_RESOLVE,
+ PK_STATUS_ENUM_ROLLBACK,
+ PK_STATUS_ENUM_COMMIT,
+ PK_STATUS_ENUM_REQUEST,
PK_STATUS_ENUM_UNKNOWN
} PkStatusEnum;
commit 2073a2acbc456df65cf923ff714de8a75b2faaea
Author: Grzegorz Dabrowski <gdx at o2.pl>
Date: Thu Nov 15 18:47:04 2007 +0000
search database in correct place instead of '${localstatedir}/lib/PackageKit'
diff --git a/configure.ac b/configure.ac
index 707a80b..956b6e2 100755
--- a/configure.ac
+++ b/configure.ac
@@ -437,7 +437,7 @@ AC_SUBST(PK_PLUGIN_DIR, "\$(libdir)/packagekit-backend")
AC_SUBST(PK_PLUGIN_CFLAGS, "-I\$(top_srcdir)/src -I\$(top_srcdir)/libpackagekit $GLIB_CFLAGS $DBUS_CFLAGS $GMODULE_CFLAGS")
AC_SUBST(PK_PLUGIN_LIBS, "$GLIB_LIBS $DBUS_LIBS $GMODULE_LIBS")
-AC_DEFINE(PK_DB_DIR, "$(localstatedir)/lib/PackageKit", [database dir])
+AC_DEFINE_UNQUOTED(PK_DB_DIR, "${localstatedir}/lib/PackageKit", [database dir])
AM_CONDITIONAL(BACKEND_TYPE_DUMMY, [test x$with_default_backend = xdummy], [using dummy backend])
AM_CONDITIONAL(BACKEND_TYPE_APT, [test x$with_default_backend = xapt], [using APT backend])
commit ffee345e37ec0c21fec6634c74f9d02e48b80117
Author: Elliot Peele <elliot at enki.rdu.rpath.com>
Date: Wed Nov 14 19:35:20 2007 -0500
switch to using correct enums
diff --git a/backends/conary/helpers/conaryCallback.py b/backends/conary/helpers/conaryCallback.py
index cc578b7..b454b6a 100644
--- a/backends/conary/helpers/conaryCallback.py
+++ b/backends/conary/helpers/conaryCallback.py
@@ -27,10 +27,10 @@ class UpdateCallback(callbacks.UpdateCallback):
def downloadingFileContents(self, got, need):
#self.backend.status('Downloading files for changeset')
- self.backend.status(INFO_DOWNLOADING)
+ self.backend.status(STATUS_DOWNLOAD)
def downloadingChangeSet(self, got, need):
- self.backend.status(INFO_DOWNLOADING)
+ self.backend.status(STATUS_DOWNLOAD)
def requestingFileContents(self):
#self.backend.status('Requesting File Contents')
@@ -61,15 +61,15 @@ class UpdateCallback(callbacks.UpdateCallback):
newVersion, newFlavor = job[2]
if oldVersion and newVersion:
- self.backend.status(INFO_UPDATING)
+ self.backend.status(STATUS_UPDATE)
id = self.backend.get_package_id(name, newVersion, newFlavor)
self.backend.package(id, INFO_UPDATING, '')
elif oldVersion and not newVersion:
- self.backend.status(INFO_REMOVING)
+ self.backend.status(STATUS_REMOVE)
id = self.backend.get_package_id(name, oldVersion, oldFlavor)
self.backend.package(id, INFO_REMOVING, '')
elif not oldVersion and newVersion:
- self.backend.status(INFO_INSTALLING)
+ self.backend.status(STATUS_INSTALL)
id = self.backend.get_package_id(name, newVersion, newFlavor)
self.backend.package(id, INFO_INSTALLING, '')
More information about the PackageKit
mailing list