[PackageKit-commit] packagekit: Branch 'master' - 9 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Wed Oct 8 13:10:28 PDT 2008
backends/alpm/pk-backend-alpm.c | 1
backends/apt.deprecated/pk-backend-apt.c | 1
backends/apt/pk-backend-apt.c | 1
backends/box/pk-backend-box.c | 1
backends/conary/pk-backend-conary.c | 1
backends/dummy/pk-backend-dummy.c | 29 ---
backends/opkg/pk-backend-opkg.c | 1
backends/pisi/pk-backend-pisi.c | 1
backends/poldek/pk-backend-poldek.c | 1
backends/razor/pk-backend-razor.c | 1
backends/smart/pk-backend-smart.c | 1
backends/test/pk-backend-test-dbus.c | 1
backends/test/pk-backend-test-fail.c | 1
backends/test/pk-backend-test-nop.c | 1
backends/test/pk-backend-test-spawn.c | 1
backends/test/pk-backend-test-succeed.c | 10 -
backends/test/pk-backend-test-thread.c | 1
backends/urpmi/pk-backend-urpmi.c | 1
backends/yum/pk-backend-yum.c | 1
backends/zypp/pk-backend-zypp.cpp | 1
client/pk-generate-pack.c | 26 ++
docs/html/pk-matrix.html | 14 -
libpackagekit/Makefile.am | 2
libpackagekit/egg-dbus-monitor.c | 290 ------------------------------
libpackagekit/egg-dbus-monitor.h | 70 -------
libpackagekit/pk-connection.c | 98 ++++++++--
libpackagekit/pk-enum.c | 1
libpackagekit/pk-enum.h | 1
libpackagekit/pk-package-id.c | 52 +++++
libpackagekit/pk-package-id.h | 2
libpackagekit/pk-package-list.c | 29 ++-
libpackagekit/pk-package-list.h | 2
libpackagekit/pk-package-obj.c | 20 ++
libpackagekit/pk-package-obj.h | 2
python/packagekit/backend.py | 8
python/packagekit/daemonBackend.py | 17 -
src/egg-dbus-monitor.c | 291 ++++++++++++++++++++++++++++++-
src/egg-dbus-monitor.h | 71 +++++++
src/pk-backend-dbus.c | 30 ---
src/pk-backend-dbus.h | 3
src/pk-backend.h | 6
src/pk-service-pack.c | 186 ++++++++++++++++---
src/pk-service-pack.h | 22 ++
src/pk-transaction.c | 26 --
src/pk-transaction.h | 3
45 files changed, 747 insertions(+), 582 deletions(-)
New commits:
commit 7581c4790a3407eef7e1fb83d1ae0d7dd7bde02a
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 17:35:13 2008 +0100
bugfix: add some functionality to compare PackageID's with a fuzzy arch, i.e. so that i386 == i686
This stops us downloading extra deps when using pkgenpack
diff --git a/libpackagekit/pk-package-id.c b/libpackagekit/pk-package-id.c
index 2a774e2..5154d2e 100644
--- a/libpackagekit/pk-package-id.c
+++ b/libpackagekit/pk-package-id.c
@@ -263,6 +263,58 @@ pk_package_id_free (PkPackageId *id)
}
/**
+ * pk_arch_base_ix86:
+ **/
+static gboolean
+pk_arch_base_ix86 (const gchar *arch)
+{
+ if (egg_strequal (arch, "i386") ||
+ egg_strequal (arch, "i486") ||
+ egg_strequal (arch, "i586") ||
+ egg_strequal (arch, "i686"))
+ return TRUE;
+ return FALSE;
+}
+
+/**
+ * pk_arch_fuzzy_equal:
+ * @arch1: the first %PkPackageId
+ * @arch2: the second %PkPackageId
+ *
+ * Compare the architectures in a fuzzy way
+ *
+ * Return value: %TRUE if the archs can be considered equal.
+ **/
+static gboolean
+pk_arch_fuzzy_equal (const gchar *arch1, const gchar *arch2)
+{
+ if (egg_strequal (arch1, arch2))
+ return TRUE;
+ if (pk_arch_base_ix86 (arch1) && pk_arch_base_ix86 (arch2))
+ return TRUE;
+ return FALSE;
+}
+
+/**
+ * pk_package_id_equal_fuzzy_arch:
+ * @id1: the first %PkPackageId
+ * @id2: the second %PkPackageId
+ *
+ * Only compare the name, version, and arch
+ *
+ * Return value: %TRUE if the ids can be considered equal.
+ **/
+gboolean
+pk_package_id_equal_fuzzy_arch (const PkPackageId *id1, const PkPackageId *id2)
+{
+ if (egg_strequal (id1->name, id2->name) &&
+ egg_strequal (id1->version, id2->version) &&
+ pk_arch_fuzzy_equal (id1->arch, id2->arch))
+ return TRUE;
+ return FALSE;
+}
+
+/**
* pk_package_id_equal:
* @id1: the first %PkPackageId
* @id2: the second %PkPackageId
diff --git a/libpackagekit/pk-package-id.h b/libpackagekit/pk-package-id.h
index 1a27296..a028c6e 100644
--- a/libpackagekit/pk-package-id.h
+++ b/libpackagekit/pk-package-id.h
@@ -51,6 +51,8 @@ PkPackageId *pk_package_id_copy (const PkPackageId *id)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_package_id_equal (const PkPackageId *id1,
const PkPackageId *id2);
+gboolean pk_package_id_equal_fuzzy_arch (const PkPackageId *id1,
+ const PkPackageId *id2);
gchar *pk_package_id_to_string (const PkPackageId *id)
G_GNUC_WARN_UNUSED_RESULT;
gboolean pk_package_id_free (PkPackageId *id);
diff --git a/libpackagekit/pk-package-list.c b/libpackagekit/pk-package-list.c
index 903967a..e00d91a 100644
--- a/libpackagekit/pk-package-list.c
+++ b/libpackagekit/pk-package-list.c
@@ -63,12 +63,24 @@ static void pk_package_list_finalize (GObject *object);
**/
struct _PkPackageListPrivate
{
- GPtrArray *array;
+ GPtrArray *array;
+ gboolean fuzzy_arch;
};
G_DEFINE_TYPE (PkPackageList, pk_package_list, G_TYPE_OBJECT)
/**
+ * pk_package_list_set_fuzzy_arch:
+ **/
+gboolean
+pk_package_list_set_fuzzy_arch (PkPackageList *plist, gboolean fuzzy_arch)
+{
+ g_return_val_if_fail (PK_IS_PACKAGE_LIST (plist), FALSE);
+ plist->priv->fuzzy_arch = fuzzy_arch;
+ return TRUE;
+}
+
+/**
* pk_package_list_add:
**/
gboolean
@@ -393,7 +405,11 @@ pk_package_list_remove_obj (PkPackageList *plist, const PkPackageObj *obj)
length = plist->priv->array->len;
for (i=0; i<length; i++) {
obj_temp = g_ptr_array_index (plist->priv->array, i);
- if (pk_package_obj_equal (obj_temp, obj)) {
+ if (plist->priv->fuzzy_arch)
+ ret = pk_package_obj_equal_fuzzy_arch (obj_temp, obj);
+ else
+ ret = pk_package_obj_equal (obj_temp, obj);
+ if (ret) {
pk_package_obj_free (obj_temp);
g_ptr_array_remove_index (plist->priv->array, i);
ret = TRUE;
@@ -420,10 +436,12 @@ pk_package_list_contains_obj (const PkPackageList *plist, const PkPackageObj *ob
length = plist->priv->array->len;
for (i=0; i<length; i++) {
obj_temp = g_ptr_array_index (plist->priv->array, i);
- ret = pk_package_obj_equal (obj_temp, obj);
- if (ret) {
+ if (plist->priv->fuzzy_arch)
+ ret = pk_package_obj_equal_fuzzy_arch (obj_temp, obj);
+ else
+ ret = pk_package_obj_equal (obj_temp, obj);
+ if (ret)
break;
- }
}
return ret;
}
@@ -532,6 +550,7 @@ pk_package_list_init (PkPackageList *plist)
plist->priv = PK_PACKAGE_LIST_GET_PRIVATE (plist);
plist->priv->array = g_ptr_array_new ();
+ plist->priv->fuzzy_arch = FALSE;
}
/**
diff --git a/libpackagekit/pk-package-list.h b/libpackagekit/pk-package-list.h
index a44fd64..2bba202 100644
--- a/libpackagekit/pk-package-list.h
+++ b/libpackagekit/pk-package-list.h
@@ -84,6 +84,8 @@ gboolean pk_package_list_to_file (const PkPackageList *plist,
const gchar *filename);
gboolean pk_package_list_add_file (PkPackageList *plist,
const gchar *filename);
+gboolean pk_package_list_set_fuzzy_arch (PkPackageList *plist,
+ gboolean fuzzy_arch);
G_END_DECLS
diff --git a/libpackagekit/pk-package-obj.c b/libpackagekit/pk-package-obj.c
index 3f39b4c..c7a565a 100644
--- a/libpackagekit/pk-package-obj.c
+++ b/libpackagekit/pk-package-obj.c
@@ -93,6 +93,19 @@ pk_package_obj_equal (const PkPackageObj *obj1, const PkPackageObj *obj2)
}
/**
+ * pk_package_obj_equal_fuzzy_arch:
+ *
+ * Only compares the package_id's and the info enum, being a bit fuzzy on the arch
+ **/
+gboolean
+pk_package_obj_equal_fuzzy_arch (const PkPackageObj *obj1, const PkPackageObj *obj2)
+{
+ if (obj1 == NULL || obj2 == NULL)
+ return FALSE;
+ return (obj1->info == obj2->info && pk_package_id_equal_fuzzy_arch (obj1->id, obj2->id));
+}
+
+/**
* pk_package_obj_copy:
*
* Copy a PkPackageObj
@@ -211,7 +224,7 @@ pk_package_obj_test (EggTest *test)
/************************************************************/
egg_test_title (test, "add entry");
- id = pk_package_id_new_from_string ("gnome-do;1.23;i386;data");
+ id = pk_package_id_new_from_string ("gnome;1.23;i586;data");
obj2 = pk_package_obj_new (PK_INFO_ENUM_INSTALLED, id, "GNOME doo!");
egg_test_assert (test, obj2 != NULL);
@@ -221,6 +234,11 @@ pk_package_obj_test (EggTest *test)
egg_test_assert (test, !ret);
/************************************************************/
+ egg_test_title (test, "check equal when fuzzy");
+ ret = pk_package_obj_equal_fuzzy_arch (obj1, obj2);
+ egg_test_assert (test, ret);
+
+ /************************************************************/
egg_test_title (test, "check to string");
text = pk_package_obj_to_string (obj1);
if (egg_strequal (text, "installed\tgnome;1.23;i386;data\tGNOME!"))
diff --git a/libpackagekit/pk-package-obj.h b/libpackagekit/pk-package-obj.h
index fabd6ab..22fbd8c 100644
--- a/libpackagekit/pk-package-obj.h
+++ b/libpackagekit/pk-package-obj.h
@@ -44,6 +44,8 @@ gboolean pk_package_obj_free (PkPackageObj *obj);
PkPackageObj *pk_package_obj_copy (const PkPackageObj *obj);
gboolean pk_package_obj_equal (const PkPackageObj *obj1,
const PkPackageObj *obj2);
+gboolean pk_package_obj_equal_fuzzy_arch (const PkPackageObj *obj1,
+ const PkPackageObj *obj2);
gchar *pk_package_obj_to_string (const PkPackageObj *obj);
PkPackageObj *pk_package_obj_from_string (const gchar *text);
diff --git a/src/pk-service-pack.c b/src/pk-service-pack.c
index f463f3b..7bbb1f9 100644
--- a/src/pk-service-pack.c
+++ b/src/pk-service-pack.c
@@ -626,6 +626,10 @@ pk_service_pack_package_cb (PkClient *client, const PkPackageObj *obj, PkService
g_return_if_fail (PK_IS_SERVICE_PACK (pack));
g_return_if_fail (obj != NULL);
+ /* only shown downloading */
+ if (obj->info != PK_INFO_ENUM_DOWNLOADING)
+ return;
+
egg_debug ("emit package %s", obj->id->name);
g_signal_emit (pack, signals [PK_SERVICE_PACK_PACKAGE], 0, obj);
}
@@ -701,6 +705,7 @@ pk_service_pack_create_for_package_ids (PkServicePack *pack, gchar **package_ids
list = pk_client_get_package_list (pack->priv->client);
/* remove some deps */
+ pk_package_list_set_fuzzy_arch (list, TRUE);
pk_service_pack_exclude_packages (pack, list);
/* list deps */
commit ff8c585f2163636429de838f4b36b401a0c3d1c8
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 16:43:16 2008 +0100
feature: show progress as the packages are downloaded in pkgenpack
diff --git a/client/pk-generate-pack.c b/client/pk-generate-pack.c
index 0117ef2..80eb4eb 100644
--- a/client/pk-generate-pack.c
+++ b/client/pk-generate-pack.c
@@ -149,6 +149,19 @@ pk_generate_pack_package_resolve (PkClient *client, PkBitfield filter, const gch
return pk_package_id_to_string (obj->id);
}
+/**
+ * pk_generate_pack_package_cb:
+ **/
+static void
+pk_generate_pack_package_cb (PkServicePack *pack, const PkPackageObj *obj, gpointer data)
+{
+ g_return_if_fail (obj != NULL);
+ g_print ("%s %s-%s.%s\n", _("Downloading"), obj->id->name, obj->id->version, obj->id->arch);
+}
+
+/**
+ * main:
+ **/
int
main (int argc, char *argv[])
{
@@ -283,6 +296,8 @@ main (int argc, char *argv[])
/* create pack and set initial values */
pack = pk_service_pack_new ();
+ g_signal_connect (pack, "package",
+ G_CALLBACK (pk_generate_pack_package_cb), pack);
pk_service_pack_set_filename (pack, filename);
pk_service_pack_set_temp_directory (pack, tempdir);
pk_service_pack_set_exclude_list (pack, list);
diff --git a/src/pk-service-pack.c b/src/pk-service-pack.c
index ee8321f..f463f3b 100644
--- a/src/pk-service-pack.c
+++ b/src/pk-service-pack.c
@@ -53,6 +53,12 @@ struct PkServicePackPrivate
PkClient *client;
};
+typedef enum {
+ PK_SERVICE_PACK_PACKAGE,
+ PK_SERVICE_PACK_LAST_SIGNAL
+} PkSignals;
+
+static guint signals [PK_SERVICE_PACK_LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (PkServicePack, pk_service_pack, G_TYPE_OBJECT)
/**
@@ -612,6 +618,19 @@ out:
}
/**
+ * pk_service_pack_package_cb:
+ **/
+static void
+pk_service_pack_package_cb (PkClient *client, const PkPackageObj *obj, PkServicePack *pack)
+{
+ g_return_if_fail (PK_IS_SERVICE_PACK (pack));
+ g_return_if_fail (obj != NULL);
+
+ egg_debug ("emit package %s", obj->id->name);
+ g_signal_emit (pack, signals [PK_SERVICE_PACK_PACKAGE], 0, obj);
+}
+
+/**
* pk_service_pack_setup_client:
**/
static gboolean
@@ -620,6 +639,8 @@ pk_service_pack_setup_client (PkServicePack *pack)
if (pack->priv->client != NULL)
return FALSE;
pack->priv->client = pk_client_new ();
+ g_signal_connect (pack->priv->client, "package",
+ G_CALLBACK (pk_service_pack_package_cb), pack);
pk_client_set_use_buffer (pack->priv->client, TRUE, NULL);
pk_client_set_synchronous (pack->priv->client, TRUE, NULL);
return TRUE;
@@ -840,6 +861,21 @@ pk_service_pack_class_init (PkServicePackClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = pk_service_pack_finalize;
+
+ /**
+ * PkServicePack::package:
+ * @pack: the #PkServicePack instance that emitted the signal
+ * @obj: the #PkPackageObj that has just been downloaded
+ *
+ * The ::package signal is emitted when a file is being downloaded.
+ **/
+ signals [PK_SERVICE_PACK_PACKAGE] =
+ g_signal_new ("package",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (PkServicePackClass, package),
+ NULL, NULL, g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE, 1, G_TYPE_POINTER);
+
g_type_class_add_private (klass, sizeof (PkServicePackPrivate));
}
diff --git a/src/pk-service-pack.h b/src/pk-service-pack.h
index 16d68e4..947be52 100644
--- a/src/pk-service-pack.h
+++ b/src/pk-service-pack.h
@@ -57,6 +57,14 @@ typedef struct
typedef struct
{
GObjectClass parent_class;
+ void (* package) (PkServicePack *pack,
+ const PkPackageObj *obj);
+ /* Padding for future expansion */
+ void (*_pk_reserved1) (void);
+ void (*_pk_reserved2) (void);
+ void (*_pk_reserved3) (void);
+ void (*_pk_reserved4) (void);
+ void (*_pk_reserved5) (void);
} PkServicePackClass;
GQuark pk_service_pack_error_quark (void);
commit 74a283ebb6edff34d252f49843d8ddcf1c30e576
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 16:24:36 2008 +0100
feature: remove the ServicePack transaction method as it's only half implemented and won't be ever used
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 071495b..f9e5395 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -1489,7 +1489,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
NULL, /* update_system */
NULL /* what_provides */
diff --git a/backends/apt.deprecated/pk-backend-apt.c b/backends/apt.deprecated/pk-backend-apt.c
index 638df97..f769ce3 100644
--- a/backends/apt.deprecated/pk-backend-apt.c
+++ b/backends/apt.deprecated/pk-backend-apt.c
@@ -269,7 +269,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_package, /* update_package */
backend_update_system, /* update_system */
NULL /* what_provides */
diff --git a/backends/apt/pk-backend-apt.c b/backends/apt/pk-backend-apt.c
index d43f1d4..f57e523 100644
--- a/backends/apt/pk-backend-apt.c
+++ b/backends/apt/pk-backend-apt.c
@@ -372,7 +372,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
backend_what_provides /* what_provides */
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index f22db04..4848e01 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -693,7 +693,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
NULL, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
NULL /* what_provides */
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index 6ef0b48..f13e891 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -303,7 +303,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
NULL, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
NULL /* what_provides */
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index f5c0cf4..49cd0a2 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -32,7 +32,6 @@ static gulong _signal_timeout = 0;
static gchar **_package_ids;
static const gchar *_search;
static guint _package_current = 0;
-static gboolean _has_service_pack = FALSE;
static gboolean _repo_enabled_local = FALSE;
static gboolean _repo_enabled_fedora = TRUE;
static gboolean _repo_enabled_devel = TRUE;
@@ -765,10 +764,6 @@ static void
backend_get_repo_list (PkBackend *backend, PkBitfield filters)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
- if (_has_service_pack) {
- pk_backend_repo_detail (backend, "local",
- "Local PackageKit volume", _repo_enabled_local);
- }
pk_backend_repo_detail (backend, "fedora",
"Fedora - 9", _repo_enabled_fedora);
if (!pk_bitfield_contain (filters, PK_FILTER_ENUM_NOT_DEVELOPMENT)) {
@@ -818,29 +813,6 @@ backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parame
}
/**
- * backend_service_pack:
- */
-static void
-backend_service_pack (PkBackend *backend, const gchar *location, gboolean enabled)
-{
- pk_backend_set_status (backend, PK_STATUS_ENUM_RUNNING);
- egg_warning ("service pack %i on %s device", enabled, location);
-
- /*
- * VERY IMPORTANT: THE REPO MUST BE DISABLED IF IT IS ADDED!
- * (else it's a security flaw, think of a user with a malicious USB key)
- */
- if (enabled) {
- _repo_enabled_local = FALSE;
- /* we tell the daemon what the new repo is called */
- pk_backend_repo_detail (backend, "local", NULL, FALSE);
- }
- _has_service_pack = enabled;
-
- pk_backend_finished (backend);
-}
-
-/**
* backend_what_provides_timeout:
*/
static gboolean
@@ -964,7 +936,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- backend_service_pack, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
backend_what_provides /* what_provides */
diff --git a/backends/opkg/pk-backend-opkg.c b/backends/opkg/pk-backend-opkg.c
index de98d2b..a3d118c 100644
--- a/backends/opkg/pk-backend-opkg.c
+++ b/backends/opkg/pk-backend-opkg.c
@@ -747,7 +747,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
NULL /* what_provides */
diff --git a/backends/pisi/pk-backend-pisi.c b/backends/pisi/pk-backend-pisi.c
index 5e8192d..7a0c790 100644
--- a/backends/pisi/pk-backend-pisi.c
+++ b/backends/pisi/pk-backend-pisi.c
@@ -392,7 +392,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
NULL /* what_provides */
diff --git a/backends/poldek/pk-backend-poldek.c b/backends/poldek/pk-backend-poldek.c
index 9ffd7ea..d204726 100644
--- a/backends/poldek/pk-backend-poldek.c
+++ b/backends/poldek/pk-backend-poldek.c
@@ -2873,7 +2873,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
backend_what_provides /* what_provides */
diff --git a/backends/razor/pk-backend-razor.c b/backends/razor/pk-backend-razor.c
index ac11b0a..c04bfb4 100644
--- a/backends/razor/pk-backend-razor.c
+++ b/backends/razor/pk-backend-razor.c
@@ -427,7 +427,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
NULL, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
NULL, /* update_packages */
NULL, /* update_system */
NULL /* what_provides */
diff --git a/backends/smart/pk-backend-smart.c b/backends/smart/pk-backend-smart.c
index bd9727a..ac902a2 100644
--- a/backends/smart/pk-backend-smart.c
+++ b/backends/smart/pk-backend-smart.c
@@ -490,7 +490,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
backend_what_provides /* what_provides */
diff --git a/backends/test/pk-backend-test-dbus.c b/backends/test/pk-backend-test-dbus.c
index 697e919..5d64408 100644
--- a/backends/test/pk-backend-test-dbus.c
+++ b/backends/test/pk-backend-test-dbus.c
@@ -106,7 +106,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
NULL, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
NULL, /* update_packages */
NULL, /* update_system */
NULL /* what_provides */
diff --git a/backends/test/pk-backend-test-fail.c b/backends/test/pk-backend-test-fail.c
index 27ea3f6..b1e4286 100644
--- a/backends/test/pk-backend-test-fail.c
+++ b/backends/test/pk-backend-test-fail.c
@@ -280,7 +280,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
NULL /* what_provides */
diff --git a/backends/test/pk-backend-test-nop.c b/backends/test/pk-backend-test-nop.c
index ce21b4b..edfe53b 100644
--- a/backends/test/pk-backend-test-nop.c
+++ b/backends/test/pk-backend-test-nop.c
@@ -56,7 +56,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
NULL, /* search_group */
NULL, /* search_name */
- NULL, /* service_pack */
NULL, /* update_package */
NULL, /* update_system */
NULL /* what_provides */
diff --git a/backends/test/pk-backend-test-spawn.c b/backends/test/pk-backend-test-spawn.c
index e9cac03..c983543 100644
--- a/backends/test/pk-backend-test-spawn.c
+++ b/backends/test/pk-backend-test-spawn.c
@@ -97,7 +97,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
NULL, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
NULL, /* update_package */
NULL, /* update_system */
NULL /* what_provides */
diff --git a/backends/test/pk-backend-test-succeed.c b/backends/test/pk-backend-test-succeed.c
index 6998ab7..8eb6fed 100644
--- a/backends/test/pk-backend-test-succeed.c
+++ b/backends/test/pk-backend-test-succeed.c
@@ -290,15 +290,6 @@ backend_repo_set_data (PkBackend *backend, const gchar *rid, const gchar *parame
}
/**
- * backend_service_pack:
- */
-static void
-backend_service_pack (PkBackend *backend, const gchar *location, gboolean enabled)
-{
- pk_backend_finished (backend);
-}
-
-/**
* backend_what_provides:
*/
static void
@@ -349,7 +340,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- backend_service_pack, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
backend_what_provides /* what_provides */
diff --git a/backends/test/pk-backend-test-thread.c b/backends/test/pk-backend-test-thread.c
index 05d9e3b..fbdbada 100644
--- a/backends/test/pk-backend-test-thread.c
+++ b/backends/test/pk-backend-test-thread.c
@@ -169,7 +169,6 @@ PK_BACKEND_OPTIONS (
NULL, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
NULL, /* update_package */
NULL, /* update_system */
NULL /* what_provides */
diff --git a/backends/urpmi/pk-backend-urpmi.c b/backends/urpmi/pk-backend-urpmi.c
index e7007fb..cdb9153 100644
--- a/backends/urpmi/pk-backend-urpmi.c
+++ b/backends/urpmi/pk-backend-urpmi.c
@@ -390,7 +390,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
NULL /* what_provides */
diff --git a/backends/yum/pk-backend-yum.c b/backends/yum/pk-backend-yum.c
index 7c11c0e..92e079e 100644
--- a/backends/yum/pk-backend-yum.c
+++ b/backends/yum/pk-backend-yum.c
@@ -501,7 +501,6 @@ PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
backend_what_provides /* what_provides */
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
index 3806ba2..a9fe902 100644
--- a/backends/zypp/pk-backend-zypp.cpp
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -1867,7 +1867,6 @@ extern "C" PK_BACKEND_OPTIONS (
backend_search_file, /* search_file */
backend_search_group, /* search_group */
backend_search_name, /* search_name */
- NULL, /* service_pack */
backend_update_packages, /* update_packages */
backend_update_system, /* update_system */
backend_what_provides /* what_provides */
diff --git a/docs/html/pk-matrix.html b/docs/html/pk-matrix.html
index 47c913a..dfb36a3 100644
--- a/docs/html/pk-matrix.html
+++ b/docs/html/pk-matrix.html
@@ -370,20 +370,6 @@
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- zypp -->
</tr>
<tr>
-<td><b>ServicePack</b></td>
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- box -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- pisi -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- poldek -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- smart -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- urpmi -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- yum -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- zypp -->
-</tr>
-<tr>
<td><b>UpdatePackages</b></td>
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index e110a9a..4713d67 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -110,7 +110,6 @@ static const PkEnumMatch enum_role[] = {
{PK_ROLE_ENUM_SEARCH_FILE, "search-file"},
{PK_ROLE_ENUM_SEARCH_GROUP, "search-group"},
{PK_ROLE_ENUM_SEARCH_NAME, "search-name"},
- {PK_ROLE_ENUM_SERVICE_PACK, "service-pack"},
{PK_ROLE_ENUM_UPDATE_PACKAGES, "update-packages"},
{PK_ROLE_ENUM_UPDATE_SYSTEM, "update-system"},
{PK_ROLE_ENUM_WHAT_PROVIDES, "what-provides"},
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index f808c6a..26fd804 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -68,7 +68,6 @@ typedef enum {
PK_ROLE_ENUM_SEARCH_FILE,
PK_ROLE_ENUM_SEARCH_GROUP,
PK_ROLE_ENUM_SEARCH_NAME,
- PK_ROLE_ENUM_SERVICE_PACK,
PK_ROLE_ENUM_UPDATE_PACKAGES,
PK_ROLE_ENUM_UPDATE_SYSTEM,
PK_ROLE_ENUM_WHAT_PROVIDES,
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 40fca97..8d11751 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -343,14 +343,6 @@ class PackageKitBaseBackend:
'''
self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend")
- def service_pack (self, location):
- '''
- Implement the {backend}-service-pack functionality
- Update the computer from a service pack in location
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED, "This function is not implemented in this backend")
-
def resolve(self, filters, name):
'''
Implement the {backend}-resolve functionality
diff --git a/python/packagekit/daemonBackend.py b/python/packagekit/daemonBackend.py
index 2b51277..f73796b 100644
--- a/python/packagekit/daemonBackend.py
+++ b/python/packagekit/daemonBackend.py
@@ -661,23 +661,6 @@ class PackageKitBaseBackend(dbus.service.Object):
self.Finished(EXIT_FAILED)
@dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
- in_signature='sb', out_signature='')
- def ServicePack (self, location, enabled):
- '''
- Implement the {backend}-service-pack functionality
- '''
- pklog.info("ServicePack(%s, %s)" % (location, enabled))
- self.doServicePack(location, enabled)
-
- def doServicePack(self, location, enabled):
- '''
- Should be replaced in the corresponding backend sub class
- '''
- self.ErrorCode(ERROR_NOT_SUPPORTED,
- "This function is not implemented in this backend")
- self.Finished(EXIT_FAILED)
-
- @dbus.service.method(PACKAGEKIT_DBUS_INTERFACE,
in_signature='as', out_signature='')
def UpdatePackages(self, package_ids):
'''
diff --git a/src/pk-backend-dbus.c b/src/pk-backend-dbus.c
index b856aec..e3dbba9 100644
--- a/src/pk-backend-dbus.c
+++ b/src/pk-backend-dbus.c
@@ -1410,36 +1410,6 @@ pk_backend_dbus_install_files (PkBackendDbus *backend_dbus, gboolean trusted, gc
}
/**
- * pk_backend_dbus_service_pack:
- **/
-gboolean
-pk_backend_dbus_service_pack (PkBackendDbus *backend_dbus, const gchar *location, gboolean enabled)
-{
- gboolean ret;
- GError *error = NULL;
-
- g_return_val_if_fail (PK_IS_BACKEND_DBUS (backend_dbus), FALSE);
- g_return_val_if_fail (backend_dbus->priv->proxy != NULL, FALSE);
- g_return_val_if_fail (location != NULL, FALSE);
-
- /* new sync method call */
- pk_backend_dbus_time_reset (backend_dbus);
- ret = dbus_g_proxy_call (backend_dbus->priv->proxy, "ServicePack", &error,
- G_TYPE_STRING, location,
- G_TYPE_BOOLEAN, enabled,
- G_TYPE_INVALID, G_TYPE_INVALID);
- if (error != NULL) {
- egg_warning ("%s", error->message);
- pk_backend_error_code (backend_dbus->priv->backend, PK_ERROR_ENUM_INTERNAL_ERROR, error->message);
- pk_backend_finished (backend_dbus->priv->backend);
- g_error_free (error);
- }
- if (ret)
- pk_backend_dbus_time_check (backend_dbus);
- return ret;
-}
-
-/**
* pk_backend_dbus_what_provides:
**/
gboolean
diff --git a/src/pk-backend-dbus.h b/src/pk-backend-dbus.h
index e65e1d2..24e6811 100644
--- a/src/pk-backend-dbus.h
+++ b/src/pk-backend-dbus.h
@@ -114,9 +114,6 @@ gboolean pk_backend_dbus_update_packages (PkBackendDbus *backend_dbus,
gboolean pk_backend_dbus_install_files (PkBackendDbus *backend_dbus,
gboolean trusted,
gchar **full_paths);
-gboolean pk_backend_dbus_service_pack (PkBackendDbus *backend_dbus,
- const gchar *location,
- gboolean enabled);
gboolean pk_backend_dbus_what_provides (PkBackendDbus *backend_dbus,
PkBitfield filters,
PkProvidesEnum provides,
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 8f653d4..13ac2a6 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -274,9 +274,6 @@ typedef struct {
void (*search_name) (PkBackend *backend,
PkBitfield filters,
const gchar *search);
- void (*service_pack) (PkBackend *backend,
- const gchar *location,
- gboolean enabled);
void (*update_packages) (PkBackend *backend,
gchar **package_ids);
void (*update_system) (PkBackend *backend);
@@ -293,7 +290,7 @@ typedef struct {
get_update_detail, get_updates, install_files, install_packages, \
install_signature, refresh_cache, remove_packages, repo_enable, \
repo_set_data, resolve, rollback, search_details, search_file, search_group, \
- search_name, service_pack, update_packages, update_system, what_provides) \
+ search_name, update_packages, update_system, what_provides) \
G_MODULE_EXPORT const PkBackendDesc pk_backend_desc = { \
description, \
author, \
@@ -327,7 +324,6 @@ typedef struct {
search_file, \
search_group, \
search_name, \
- service_pack, \
update_packages, \
update_system, \
what_provides, \
diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index b8a71fc..cbf8e78 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -644,8 +644,7 @@ pk_transaction_finished_cb (PkBackend *backend, PkExitEnum exit, PkTransaction *
}
/* the repo list will have changed */
- if (transaction->priv->role == PK_ROLE_ENUM_SERVICE_PACK ||
- transaction->priv->role == PK_ROLE_ENUM_REPO_ENABLE ||
+ if (transaction->priv->role == PK_ROLE_ENUM_REPO_ENABLE ||
transaction->priv->role == PK_ROLE_ENUM_REPO_SET_DATA) {
pk_notify_repo_list_changed (transaction->priv->notify);
}
@@ -1064,8 +1063,6 @@ pk_transaction_set_running (PkTransaction *transaction)
desc->install_files (priv->backend, priv->cached_trusted, priv->cached_full_paths);
else if (priv->role == PK_ROLE_ENUM_INSTALL_SIGNATURE)
desc->install_signature (priv->backend, PK_SIGTYPE_ENUM_GPG, priv->cached_key_id, priv->cached_package_id);
- else if (priv->role == PK_ROLE_ENUM_SERVICE_PACK)
- desc->service_pack (priv->backend, priv->cached_full_path, priv->cached_enabled);
else if (priv->role == PK_ROLE_ENUM_REFRESH_CACHE)
desc->refresh_cache (priv->backend, priv->cached_force);
else if (priv->role == PK_ROLE_ENUM_REMOVE_PACKAGES)
@@ -3277,27 +3274,6 @@ pk_transaction_search_name (PkTransaction *transaction, const gchar *filter,
}
/**
- * pk_transaction_service_pack:
- */
-gboolean
-pk_transaction_service_pack (PkTransaction *transaction, const gchar *location, gboolean enabled)
-{
- g_return_val_if_fail (PK_IS_TRANSACTION (transaction), FALSE);
- g_return_val_if_fail (transaction->priv->tid != NULL, FALSE);
-
- /* not implemented yet */
- if (transaction->priv->backend->desc->service_pack == NULL) {
- egg_debug ("Not implemented yet: ServicePack");
- return FALSE;
- }
- /* save so we can run later */
- transaction->priv->cached_enabled = enabled;
- transaction->priv->cached_full_path = g_strdup (location);
- pk_transaction_set_role (transaction, PK_ROLE_ENUM_SERVICE_PACK);
- return TRUE;
-}
-
-/**
* pk_transaction_set_locale:
*/
gboolean
diff --git a/src/pk-transaction.h b/src/pk-transaction.h
index 9fa46e6..49406da 100644
--- a/src/pk-transaction.h
+++ b/src/pk-transaction.h
@@ -213,9 +213,6 @@ void pk_transaction_search_name (PkTransaction *transaction,
gboolean pk_transaction_set_locale (PkTransaction *transaction,
const gchar *code,
GError **error);
-gboolean pk_transaction_service_pack (PkTransaction *transaction,
- const gchar *location,
- gboolean enabled);
void pk_transaction_update_packages (PkTransaction *transaction,
gchar **package_ids,
DBusGMethodInvocation *context);
commit b44c558e77e72801c0647251d96db143a1a46148
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 16:23:59 2008 +0100
trivial: add proper GError error codes to PkServicePack
diff --git a/src/pk-service-pack.c b/src/pk-service-pack.c
index 20d3c8a..ee8321f 100644
--- a/src/pk-service-pack.c
+++ b/src/pk-service-pack.c
@@ -55,6 +55,44 @@ struct PkServicePackPrivate
G_DEFINE_TYPE (PkServicePack, pk_service_pack, G_TYPE_OBJECT)
+/**
+ * pk_service_pack_error_quark:
+ *
+ * Return value: Our personal error quark.
+ **/
+GQuark
+pk_service_pack_error_quark (void)
+{
+ static GQuark quark = 0;
+ if (!quark)
+ quark = g_quark_from_static_string ("pk_service_pack_error");
+ return quark;
+}
+
+/**
+ * pk_service_pack_error_get_type:
+ **/
+#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
+GType
+pk_service_pack_error_get_type (void)
+{
+ static GType etype = 0;
+
+ if (etype == 0) {
+ static const GEnumValue values[] =
+ {
+ ENUM_ENTRY (PK_SERVICE_PACK_ERROR_FAILED_SETUP, "FailedSetup"),
+ ENUM_ENTRY (PK_SERVICE_PACK_ERROR_FAILED_DOWNLOAD, "FailedDownload"),
+ ENUM_ENTRY (PK_SERVICE_PACK_ERROR_FAILED_EXTRACTION, "FailedExtraction"),
+ ENUM_ENTRY (PK_SERVICE_PACK_ERROR_FAILED_CREATE, "FailedCreate"),
+ ENUM_ENTRY (PK_SERVICE_PACK_ERROR_NOTHING_TO_DO, "NothingToDo"),
+ ENUM_ENTRY (PK_SERVICE_PACK_ERROR_NOT_COMPATIBLE, "NotCompatible"),
+ { 0, NULL, NULL }
+ };
+ etype = g_enum_register_static ("PkServicePackError", values);
+ }
+ return etype;
+}
/**
* pk_service_pack_check_metadata_file:
@@ -122,7 +160,8 @@ pk_service_pack_extract (const gchar *filename, const gchar *directory, GError *
/* save the PWD as we chdir to extract */
retcwd = getcwd (buf, PATH_MAX);
if (retcwd == NULL) {
- *error = g_error_new (1, 0, "failed to get cwd");
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ "failed to get cwd");
goto out;
}
@@ -133,14 +172,16 @@ pk_service_pack_extract (const gchar *filename, const gchar *directory, GError *
/* open the tar file */
r = archive_read_open_file (arch, filename, 10240);
if (r) {
- *error = g_error_new (1, 0, "cannot open: %s", archive_error_string (arch));
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_EXTRACTION,
+ "cannot open: %s", archive_error_string (arch));
goto out;
}
/* switch to our destination directory */
retval = chdir (directory);
if (retval != 0) {
- *error = g_error_new (1, 0, "failed chdir to %s", directory);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ "failed chdir to %s", directory);
goto out;
}
@@ -150,12 +191,14 @@ pk_service_pack_extract (const gchar *filename, const gchar *directory, GError *
if (r == ARCHIVE_EOF)
break;
if (r != ARCHIVE_OK) {
- *error = g_error_new (1, 0, "cannot read header: %s", archive_error_string (arch));
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_EXTRACTION,
+ "cannot read header: %s", archive_error_string (arch));
goto out;
}
r = archive_read_extract (arch, entry, 0);
if (r != ARCHIVE_OK) {
- *error = g_error_new (1, 0, "cannot extract: %s", archive_error_string (arch));
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_EXTRACTION,
+ "cannot extract: %s", archive_error_string (arch));
goto out;
}
}
@@ -180,7 +223,8 @@ out:
gboolean
pk_service_pack_extract (const gchar *filename, const gchar *directory, GError **error)
{
- *error = g_error_new (1, 0, "Cannot check PackageKit as not built with libarchive support");
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_EXTRACTION,
+ "Cannot check PackageKit as not built with libarchive support");
return FALSE;
}
#endif /* HAVE_ARCHIVE_H */
@@ -206,7 +250,8 @@ pk_service_pack_check_valid (PkServicePack *pack, GError **error)
g_mkdir (directory, 0700);
ret = pk_service_pack_extract (pack->priv->filename, directory, &error_local);
if (!ret) {
- *error = g_error_new (1, 0, "failed to check %s: %s", pack->priv->filename, error_local->message);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, error_local->code,
+ "failed to check %s: %s", pack->priv->filename, error_local->message);
g_error_free (error_local);
goto out;
}
@@ -214,7 +259,8 @@ pk_service_pack_check_valid (PkServicePack *pack, GError **error)
/* get the files */
dir = g_dir_open (directory, 0, NULL);
if (dir == NULL) {
- *error = g_error_new (1, 0, "failed to get directory for %s", directory);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ "failed to get directory for %s", directory);
ret = FALSE;
goto out;
}
@@ -225,7 +271,8 @@ pk_service_pack_check_valid (PkServicePack *pack, GError **error)
if (egg_strequal (filename_entry, "metadata.conf")) {
ret = pk_service_pack_check_metadata_file (metafile);
if (!ret) {
- *error = g_error_new (1, 0, "Service Pack %s not compatible with your distro", pack->priv->filename);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_NOT_COMPATIBLE,
+ "Service Pack %s not compatible with your distro", pack->priv->filename);
ret = FALSE;
goto out;
}
@@ -408,7 +455,8 @@ pk_service_pack_archive_add_file (struct archive *arch, const gchar *filename, G
/* stat file */
retval = stat (filename, &st);
if (retval != 0) {
- *error = g_error_new (1, 0, "file not found %s", filename);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_CREATE,
+ "file not found %s", filename);
goto out;
}
egg_debug ("stat(%s), size=%lu bytes\n", filename, st.st_size);
@@ -426,14 +474,16 @@ pk_service_pack_archive_add_file (struct archive *arch, const gchar *filename, G
/* write header */
retval = archive_write_header (arch, entry);
if (retval != ARCHIVE_OK) {
- *error = g_error_new (1, 0, "failed to write header: %s\n", archive_error_string (arch));
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_CREATE,
+ "failed to write header: %s\n", archive_error_string (arch));
goto out;
}
/* open file to copy */
fd = open (filename, O_RDONLY);
if (fd < 0) {
- *error = g_error_new (1, 0, "failed to get fd for %s", filename);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_CREATE,
+ "failed to get fd for %s", filename);
goto out;
}
@@ -477,7 +527,8 @@ pk_service_pack_create_from_files (PkServicePack *pack, GPtrArray *file_array, G
filename = g_build_filename (g_get_tmp_dir (), "metadata.conf", NULL);
ret = pk_service_pack_create_metadata_file (filename);
if (!ret) {
- *error = g_error_new (1, 0, "failed to generate metadata file %s", filename);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_CREATE,
+ "failed to generate metadata file %s", filename);
goto out;
}
g_ptr_array_add (file_array, g_strdup (filename));
@@ -522,7 +573,8 @@ static gboolean
pk_service_pack_create_from_files (PkServicePack *pack, GPtrArray *file_array, GError **error)
{
g_return_val_if_fail (PK_IS_SERVICE_PACK (pack), FALSE);
- *error = g_error_new (1, 0, "Cannot create pack as PackageKit as not built with libarchive support");
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_CREATE,
+ "Cannot create pack as PackageKit as not built with libarchive support");
return FALSE;
}
#endif
@@ -600,7 +652,8 @@ pk_service_pack_create_for_package_ids (PkServicePack *pack, gchar **package_ids
/* download this package */
ret = pk_service_pack_download_package_ids (pack, package_ids);
if (!ret) {
- *error = g_error_new (1, 0, "failed to download main package: %s", error_local->message);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, error_local->code,
+ "failed to download main package: %s", error_local->message);
g_error_free (error_local);
goto out;
}
@@ -608,7 +661,8 @@ pk_service_pack_create_for_package_ids (PkServicePack *pack, gchar **package_ids
/* get depends */
ret = pk_client_reset (pack->priv->client, &error_local);
if (!ret) {
- *error = g_error_new (1, 0, "failed to reset: %s", error_local->message);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ "failed to reset: %s", error_local->message);
g_error_free (error_local);
goto out;
}
@@ -616,7 +670,8 @@ pk_service_pack_create_for_package_ids (PkServicePack *pack, gchar **package_ids
egg_debug ("Getting depends for %s", package_ids[0]);
ret = pk_client_get_depends (pack->priv->client, PK_FILTER_ENUM_NONE, package_ids, TRUE, &error_local);
if (!ret) {
- *error = g_error_new (1, 0, "failed to get depends: %s", error_local->message);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ "failed to get depends: %s", error_local->message);
g_error_free (error_local);
goto out;
}
@@ -645,7 +700,8 @@ pk_service_pack_create_for_package_ids (PkServicePack *pack, gchar **package_ids
/* failed to get deps */
if (!ret) {
- *error = g_error_new (1, 0, "failed to download deps of package: %s", package_ids[0]);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_DOWNLOAD,
+ "failed to download deps of package: %s", package_ids[0]);
goto out;
}
}
@@ -653,14 +709,16 @@ pk_service_pack_create_for_package_ids (PkServicePack *pack, gchar **package_ids
/* find packages that were downloaded */
file_array = pk_service_pack_scan_files_in_directory (pack);
if (file_array == NULL) {
- *error = g_error_new (1, 0, "failed to scan directory: %s", pack->priv->directory);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ "failed to scan directory: %s", pack->priv->directory);
goto out;
}
/* generate pack file */
ret = pk_service_pack_create_from_files (pack, file_array, &error_local);
if (!ret) {
- *error = g_error_new (1, 0, "failed to create archive: %s", error_local->message);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, error_local->code,
+ "failed to create archive: %s", error_local->message);
g_error_free (error_local);
goto out;
}
@@ -705,6 +763,7 @@ pk_service_pack_create_for_updates (PkServicePack *pack, GError **error)
GError *error_local = NULL;
gboolean ret = FALSE;
PkPackageList *list;
+ guint len;
g_return_val_if_fail (PK_IS_SERVICE_PACK (pack), FALSE);
g_return_val_if_fail (pack->priv->filename != NULL, FALSE);
@@ -716,7 +775,8 @@ pk_service_pack_create_for_updates (PkServicePack *pack, GError **error)
/* get updates */
ret = pk_client_reset (pack->priv->client, &error_local);
if (!ret) {
- *error = g_error_new (1, 0, "failed to reset: %s", error_local->message);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ "failed to reset: %s", error_local->message);
g_error_free (error_local);
goto out;
}
@@ -724,13 +784,24 @@ pk_service_pack_create_for_updates (PkServicePack *pack, GError **error)
egg_debug ("Getting updates");
ret = pk_client_get_updates (pack->priv->client, PK_FILTER_ENUM_NONE, &error_local);
if (!ret) {
- *error = g_error_new (1, 0, "failed to get updates: %s", error_local->message);
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ "failed to get updates: %s", error_local->message);
g_error_free (error_local);
goto out;
}
/* get the updates, and download them with deps */
list = pk_client_get_package_list (pack->priv->client);
+ len = pk_package_list_get_size (list);
+
+ /* no updates */
+ if (len == 0) {
+ *error = g_error_new (PK_SERVICE_PACK_ERROR, PK_SERVICE_PACK_ERROR_NOTHING_TO_DO,
+ "there are no updates to download");
+ ret = FALSE;
+ goto out;
+ }
+
package_ids = pk_package_list_to_strv (list);
g_object_unref (list);
ret = pk_service_pack_create_for_package_ids (pack, package_ids, error);
diff --git a/src/pk-service-pack.h b/src/pk-service-pack.h
index 328e858..16d68e4 100644
--- a/src/pk-service-pack.h
+++ b/src/pk-service-pack.h
@@ -33,9 +33,21 @@ G_BEGIN_DECLS
#define PK_IS_SERVICE_PACK(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_SERVICE_PACK))
#define PK_IS_SERVICE_PACK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_SERVICE_PACK))
#define PK_SERVICE_PACK_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_SERVICE_PACK, PkServicePackClass))
+#define PK_SERVICE_PACK_ERROR (pk_service_pack_error_quark ())
+#define PK_SERVICE_PACK_TYPE_ERROR (pk_service_pack_error_get_type ())
typedef struct PkServicePackPrivate PkServicePackPrivate;
+typedef enum
+{
+ PK_SERVICE_PACK_ERROR_FAILED_SETUP,
+ PK_SERVICE_PACK_ERROR_FAILED_DOWNLOAD,
+ PK_SERVICE_PACK_ERROR_FAILED_EXTRACTION,
+ PK_SERVICE_PACK_ERROR_FAILED_CREATE,
+ PK_SERVICE_PACK_ERROR_NOTHING_TO_DO,
+ PK_SERVICE_PACK_ERROR_NOT_COMPATIBLE
+} PkServicePackError;
+
typedef struct
{
GObject parent;
@@ -47,6 +59,8 @@ typedef struct
GObjectClass parent_class;
} PkServicePackClass;
+GQuark pk_service_pack_error_quark (void);
+GType pk_service_pack_error_get_type (void);
GType pk_service_pack_get_type (void) G_GNUC_CONST;
PkServicePack *pk_service_pack_new (void);
commit 2575c35a28c8426c2dccf485f0aa507cea43013c
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 15:39:18 2008 +0100
trivial: don't attempt to make the service pack with updates if there are no updates to add
diff --git a/client/pk-generate-pack.c b/client/pk-generate-pack.c
index c2ac69a..0117ef2 100644
--- a/client/pk-generate-pack.c
+++ b/client/pk-generate-pack.c
@@ -54,6 +54,8 @@ pk_generate_pack_get_filename (const gchar *name, const gchar *directory)
filename = g_strdup_printf ("%s/%s-%s.servicepack", directory, name, distro_id);
} else {
iso_time = pk_iso8601_present ();
+ /* don't include the time, just use the date prefix */
+ iso_time[10] = '\0';
filename = g_strdup_printf ("%s/updates-%s-%s.servicepack", directory, iso_time, distro_id);
}
g_free (distro_id);
@@ -286,12 +288,17 @@ main (int argc, char *argv[])
pk_service_pack_set_exclude_list (pack, list);
/* generate the pack */
- g_print (_("Creating service pack: %s\n"), filename);
+ g_print (_("Service pack to create: %s\n"), filename);
if (updates)
ret = pk_service_pack_create_for_updates (pack, &error);
else
ret = pk_service_pack_create_for_package_id (pack, package_id, &error);
- g_print ("%s\n", _("Done!"));
+ if (ret)
+ g_print ("%s\n", _("Done!"));
+ else {
+ g_print ("%s: %s\n", _("Failed"), error->message);
+ g_error_free (error);
+ }
out:
/* get rid of temp directory */
commit fddd9d934834a6190ef866f146859f1c01c7bbf0
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 15:16:57 2008 +0100
trivial: make the dir when we check the servicepack file
diff --git a/src/pk-service-pack.c b/src/pk-service-pack.c
index 501acac..20d3c8a 100644
--- a/src/pk-service-pack.c
+++ b/src/pk-service-pack.c
@@ -203,6 +203,7 @@ pk_service_pack_check_valid (PkServicePack *pack, GError **error)
/* ITS4: ignore, the user has no control over the daemon envp */
directory = g_build_filename (g_get_tmp_dir (), "meta", NULL);
+ g_mkdir (directory, 0700);
ret = pk_service_pack_extract (pack->priv->filename, directory, &error_local);
if (!ret) {
*error = g_error_new (1, 0, "failed to check %s: %s", pack->priv->filename, error_local->message);
commit c20205fc26daa516a87569375c3d4d9a9450b9ae
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 15:11:50 2008 +0100
trivial: fix a potential crash in the daemon if we can't chdir
diff --git a/src/pk-service-pack.c b/src/pk-service-pack.c
index eaa1585..501acac 100644
--- a/src/pk-service-pack.c
+++ b/src/pk-service-pack.c
@@ -234,7 +234,8 @@ pk_service_pack_check_valid (PkServicePack *pack, GError **error)
out:
g_rmdir (directory);
g_free (directory);
- g_dir_close (dir);
+ if (dir != NULL)
+ g_dir_close (dir);
return ret;
}
commit ea36ea097c30a02f913a188693904c523be242d4
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 15:10:10 2008 +0100
trivial: don't use PkClient by default unless we are being called by a client
diff --git a/src/pk-service-pack.c b/src/pk-service-pack.c
index 576623e..eaa1585 100644
--- a/src/pk-service-pack.c
+++ b/src/pk-service-pack.c
@@ -558,6 +558,20 @@ out:
}
/**
+ * pk_service_pack_setup_client:
+ **/
+static gboolean
+pk_service_pack_setup_client (PkServicePack *pack)
+{
+ if (pack->priv->client != NULL)
+ return FALSE;
+ pack->priv->client = pk_client_new ();
+ pk_client_set_use_buffer (pack->priv->client, TRUE, NULL);
+ pk_client_set_synchronous (pack->priv->client, TRUE, NULL);
+ return TRUE;
+}
+
+/**
* pk_service_pack_create_for_package_ids:
**/
gboolean
@@ -578,6 +592,9 @@ pk_service_pack_create_for_package_ids (PkServicePack *pack, gchar **package_ids
g_return_val_if_fail (pack->priv->filename != NULL, FALSE);
g_return_val_if_fail (pack->priv->directory != NULL, FALSE);
+ /* don't setup by default to not block the server */
+ pk_service_pack_setup_client (pack);
+
/* download this package */
ret = pk_service_pack_download_package_ids (pack, package_ids);
if (!ret) {
@@ -691,6 +708,9 @@ pk_service_pack_create_for_updates (PkServicePack *pack, GError **error)
g_return_val_if_fail (pack->priv->filename != NULL, FALSE);
g_return_val_if_fail (pack->priv->directory != NULL, FALSE);
+ /* don't setup by default to not block the server */
+ pk_service_pack_setup_client (pack);
+
/* get updates */
ret = pk_client_reset (pack->priv->client, &error_local);
if (!ret) {
@@ -731,7 +751,8 @@ pk_service_pack_finalize (GObject *object)
if (pack->priv->exclude_list != NULL)
g_object_unref (pack->priv->exclude_list);
- g_object_unref (pack->priv->client);
+ if (pack->priv->client != NULL)
+ g_object_unref (pack->priv->client);
g_free (pack->priv->directory);
g_free (pack->priv->filename);
@@ -759,9 +780,6 @@ pk_service_pack_init (PkServicePack *pack)
pack->priv->exclude_list = NULL;
pack->priv->filename = NULL;
pack->priv->directory = NULL;
- pack->priv->client = pk_client_new ();
- pk_client_set_use_buffer (pack->priv->client, TRUE, NULL);
- pk_client_set_synchronous (pack->priv->client, TRUE, NULL);
}
/**
commit 608ae9252310d67c83abac2d7dfaf57ab3e0d94e
Author: Richard Hughes <richard at hughsie.com>
Date: Wed Oct 8 15:00:00 2008 +0100
trivial: don't use EggDbusMonitor in libpackagekit, we can just copy the trivial bits into the only user PkConnection
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index ef1a439..40d55da 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -46,8 +46,6 @@ libpackagekit_la_SOURCES = \
egg-debug.h \
egg-string.c \
egg-string.h \
- egg-dbus-monitor.c \
- egg-dbus-monitor.h \
egg-obj-list.c \
egg-obj-list.h \
pk-marshal.c \
diff --git a/libpackagekit/egg-dbus-monitor.c b/libpackagekit/egg-dbus-monitor.c
deleted file mode 100644
index 90c2193..0000000
--- a/libpackagekit/egg-dbus-monitor.c
+++ /dev/null
@@ -1,290 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2006-2008 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 "config.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <glib.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus.h>
-
-#include "egg-debug.h"
-#include "egg-dbus-monitor.h"
-
-static void egg_dbus_monitor_class_init (EggDbusMonitorClass *klass);
-static void egg_dbus_monitor_init (EggDbusMonitor *dbus_monitor);
-static void egg_dbus_monitor_finalize (GObject *object);
-
-#define EGG_DBUS_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorPrivate))
-
-struct EggDbusMonitorPrivate
-{
- EggDbusMonitorType bus_type;
- gchar *service;
- DBusGProxy *proxy;
- DBusGConnection *connection;
- const gchar *unique_name;
-};
-
-enum {
- EGG_DBUS_MONITOR_CONNECTION_CHANGED,
- EGG_DBUS_MONITOR_CONNECTION_REPLACED,
- EGG_DBUS_MONITOR_LAST_SIGNAL
-};
-
-static guint signals [EGG_DBUS_MONITOR_LAST_SIGNAL] = { 0 };
-
-G_DEFINE_TYPE (EggDbusMonitor, egg_dbus_monitor, G_TYPE_OBJECT)
-
-/**
- * egg_dbus_monitor_name_owner_changed_cb:
- **/
-static void
-egg_dbus_monitor_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name,
- const gchar *prev, const gchar *new,
- EggDbusMonitor *monitor)
-{
- guint new_len;
- guint prev_len;
-
- g_return_if_fail (EGG_IS_DBUS_MONITOR (monitor));
- if (monitor->priv->proxy == NULL)
- return;
-
- /* not us */
- if (strcmp (name, monitor->priv->service) != 0)
- return;
-
- /* ITS4: ignore, not used for allocation */
- new_len = strlen (new);
- /* ITS4: ignore, not used for allocation */
- prev_len = strlen (prev);
-
- /* something --> nothing */
- if (prev_len != 0 && new_len == 0) {
- g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, FALSE);
- return;
- }
-
- /* nothing --> something */
- if (prev_len == 0 && new_len != 0) {
- g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE);
- return;
- }
-
- /* something --> something (we've replaced the old process) */
- if (prev_len != 0 && new_len != 0) {
- /* only send this to the prev client */
- if (strcmp (monitor->priv->unique_name, prev) == 0)
- g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED], 0);
- return;
- }
-}
-
-/**
- * egg_dbus_monitor_assign:
- * @monitor: This class instance
- * @bus_type: The bus type, either EGG_DBUS_MONITOR_SESSION or EGG_DBUS_MONITOR_SYSTEM
- * @service: The EGG_DBUS_MONITOR service name
- * Return value: success
- *
- * Emits connection-changed(TRUE) if connection is alive - this means you
- * have to connect up the callback before this function is called.
- **/
-gboolean
-egg_dbus_monitor_assign (EggDbusMonitor *monitor, EggDbusMonitorType bus_type, const gchar *service)
-{
- GError *error = NULL;
- gboolean connected;
- DBusConnection *conn;
-
- g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
- g_return_val_if_fail (service != NULL, FALSE);
-
- if (monitor->priv->proxy != NULL) {
- egg_warning ("already assigned!");
- return FALSE;
- }
-
- monitor->priv->service = g_strdup (service);
- monitor->priv->bus_type = bus_type;
-
- /* connect to correct bus */
- if (bus_type == EGG_DBUS_MONITOR_SESSION)
- monitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
- else
- monitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (error != NULL) {
- egg_warning ("Cannot connect to bus: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
- monitor->priv->proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->connection,
- DBUS_SERVICE_DBUS,
- DBUS_PATH_DBUS,
- DBUS_INTERFACE_DBUS,
- &error);
- if (error != NULL) {
- egg_warning ("Cannot connect to DBUS: %s", error->message);
- g_error_free (error);
- return FALSE;
- }
- dbus_g_proxy_add_signal (monitor->priv->proxy, "NameOwnerChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (monitor->priv->proxy, "NameOwnerChanged",
- G_CALLBACK (egg_dbus_monitor_name_owner_changed_cb),
- monitor, NULL);
-
- /* coldplug */
- connected = egg_dbus_monitor_is_connected (monitor);
- if (connected)
- g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE);
-
- /* save this for the replaced check */
- conn = dbus_g_connection_get_connection (monitor->priv->connection);
- monitor->priv->unique_name = dbus_bus_get_unique_name (conn);
- return TRUE;
-}
-
-/**
- * egg_dbus_monitor_is_connected:
- * @monitor: This class instance
- * Return value: if we are connected to a valid watch
- **/
-gboolean
-egg_dbus_monitor_is_connected (EggDbusMonitor *monitor)
-{
- DBusError error;
- DBusConnection *conn;
- gboolean ret;
- g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
-
- /* get raw connection */
- conn = dbus_g_connection_get_connection (monitor->priv->connection);
- dbus_error_init (&error);
- ret = dbus_bus_name_has_owner (conn, monitor->priv->service, &error);
- if (dbus_error_is_set (&error)) {
- egg_debug ("error: %s", error.message);
- dbus_error_free (&error);
- }
-
- return ret;
-}
-
-/**
- * egg_dbus_monitor_reset
- * @monitor: This class instance
- * Return value: if we reset correctly
- **/
-gboolean
-egg_dbus_monitor_reset (EggDbusMonitor *monitor)
-{
- g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
- if (monitor->priv->proxy != NULL) {
- egg_debug ("not already assigned!");
- return FALSE;
- }
- if (monitor->priv->service != NULL) {
- g_free (monitor->priv->service);
- monitor->priv->service = NULL;
- }
- if (monitor->priv->proxy != NULL) {
- g_object_unref (monitor->priv->proxy);
- monitor->priv->proxy = NULL;
- }
- return TRUE;
-}
-
-/**
- * egg_dbus_monitor_class_init:
- * @klass: The EggDbusMonitorClass
- **/
-static void
-egg_dbus_monitor_class_init (EggDbusMonitorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = egg_dbus_monitor_finalize;
- g_type_class_add_private (klass, sizeof (EggDbusMonitorPrivate));
- signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED] =
- g_signal_new ("connection-changed",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggDbusMonitorClass, connection_changed),
- NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
- G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
- signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED] =
- g_signal_new ("connection-replaced",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (EggDbusMonitorClass, connection_replaced),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-}
-
-/**
- * egg_dbus_monitor_init:
- * @monitor: This class instance
- **/
-static void
-egg_dbus_monitor_init (EggDbusMonitor *monitor)
-{
- monitor->priv = EGG_DBUS_MONITOR_GET_PRIVATE (monitor);
- monitor->priv->service = NULL;
- monitor->priv->bus_type = EGG_DBUS_MONITOR_SESSION;
- monitor->priv->proxy = NULL;
-}
-
-/**
- * egg_dbus_monitor_finalize:
- * @object: The object to finalize
- **/
-static void
-egg_dbus_monitor_finalize (GObject *object)
-{
- EggDbusMonitor *monitor;
-
- g_return_if_fail (EGG_IS_DBUS_MONITOR (object));
-
- monitor = EGG_DBUS_MONITOR (object);
-
- g_return_if_fail (monitor->priv != NULL);
-
- g_free (monitor->priv->service);
- if (monitor->priv->proxy != NULL)
- g_object_unref (monitor->priv->proxy);
-
- G_OBJECT_CLASS (egg_dbus_monitor_parent_class)->finalize (object);
-}
-
-/**
- * egg_dbus_monitor_new:
- *
- * Return value: a new EggDbusMonitor object.
- **/
-EggDbusMonitor *
-egg_dbus_monitor_new (void)
-{
- EggDbusMonitor *monitor;
- monitor = g_object_new (EGG_TYPE_DBUS_MONITOR, NULL);
- return EGG_DBUS_MONITOR (monitor);
-}
-
diff --git a/libpackagekit/egg-dbus-monitor.h b/libpackagekit/egg-dbus-monitor.h
deleted file mode 100644
index ea40f15..0000000
--- a/libpackagekit/egg-dbus-monitor.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2008 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.
- */
-
-#ifndef __EGG_DBUS_MONITOR_H
-#define __EGG_DBUS_MONITOR_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define EGG_TYPE_DBUS_MONITOR (egg_dbus_monitor_get_type ())
-#define EGG_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitor))
-#define EGG_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass))
-#define EGG_IS_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_DBUS_MONITOR))
-#define EGG_IS_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_DBUS_MONITOR))
-#define EGG_DBUS_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass))
-#define EGG_DBUS_MONITOR_ERROR (egg_dbus_monitor_error_quark ())
-#define EGG_DBUS_MONITOR_TYPE_ERROR (egg_dbus_monitor_error_get_type ())
-
-typedef struct EggDbusMonitorPrivate EggDbusMonitorPrivate;
-
-typedef struct
-{
- GObject parent;
- EggDbusMonitorPrivate *priv;
-} EggDbusMonitor;
-
-typedef struct
-{
- GObjectClass parent_class;
- void (* connection_changed) (EggDbusMonitor *watch,
- gboolean connected);
- void (* connection_replaced) (EggDbusMonitor *watch);
-} EggDbusMonitorClass;
-
-typedef enum {
- EGG_DBUS_MONITOR_SESSION,
- EGG_DBUS_MONITOR_SYSTEM
-} EggDbusMonitorType;
-
-GType egg_dbus_monitor_get_type (void) G_GNUC_CONST;
-EggDbusMonitor *egg_dbus_monitor_new (void);
-gboolean egg_dbus_monitor_reset (EggDbusMonitor *monitor);
-gboolean egg_dbus_monitor_assign (EggDbusMonitor *monitor,
- EggDbusMonitorType bus_type,
- const gchar *service);
-gboolean egg_dbus_monitor_is_connected (EggDbusMonitor *monitor);
-
-G_END_DECLS
-
-#endif /* __EGG_DBUS_MONITOR_H */
-
diff --git a/libpackagekit/pk-connection.c b/libpackagekit/pk-connection.c
index 7d8253a..54caa2a 100644
--- a/libpackagekit/pk-connection.c
+++ b/libpackagekit/pk-connection.c
@@ -41,7 +41,9 @@
#endif /* HAVE_UNISTD_H */
#include <glib/gi18n.h>
-#include <egg-dbus-monitor.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus.h>
#include "egg-debug.h"
#include "pk-common.h"
@@ -56,7 +58,8 @@
**/
struct _PkConnectionPrivate
{
- EggDbusMonitor *monitor;
+ DBusGProxy *proxy;
+ DBusGConnection *connection;
};
enum {
@@ -78,7 +81,58 @@ G_DEFINE_TYPE (PkConnection, pk_connection, G_TYPE_OBJECT)
gboolean
pk_connection_valid (PkConnection *connection)
{
- return egg_dbus_monitor_is_connected (connection->priv->monitor);
+ DBusError error;
+ DBusConnection *conn;
+ gboolean ret;
+ g_return_val_if_fail (PK_IS_CONNECTION (connection), FALSE);
+
+ /* get raw connection */
+ conn = dbus_g_connection_get_connection (connection->priv->connection);
+ dbus_error_init (&error);
+ ret = dbus_bus_name_has_owner (conn, PK_DBUS_SERVICE, &error);
+ if (dbus_error_is_set (&error)) {
+ egg_debug ("error: %s", error.message);
+ dbus_error_free (&error);
+ }
+
+ return ret;
+}
+
+/**
+ * egg_dbus_connection_name_owner_changed_cb:
+ **/
+static void
+egg_dbus_connection_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name,
+ const gchar *prev, const gchar *new,
+ PkConnection *connection)
+{
+ guint new_len;
+ guint prev_len;
+
+ g_return_if_fail (PK_IS_CONNECTION (connection));
+ if (connection->priv->proxy == NULL)
+ return;
+
+ /* not us */
+ if (strcmp (name, PK_DBUS_SERVICE) != 0)
+ return;
+
+ /* ITS4: ignore, not used for allocation */
+ new_len = strlen (new);
+ /* ITS4: ignore, not used for allocation */
+ prev_len = strlen (prev);
+
+ /* something --> nothing */
+ if (prev_len != 0 && new_len == 0) {
+ g_signal_emit (connection , signals [CONNECTION_CHANGED], 0, FALSE);
+ return;
+ }
+
+ /* nothing --> something */
+ if (prev_len == 0 && new_len != 0) {
+ g_signal_emit (connection , signals [CONNECTION_CHANGED], 0, TRUE);
+ return;
+ }
}
/**
@@ -93,7 +147,7 @@ pk_connection_finalize (GObject *object)
connection = PK_CONNECTION (object);
g_return_if_fail (connection->priv != NULL);
- g_object_unref (connection->priv->monitor);
+ g_object_unref (connection->priv->proxy);
G_OBJECT_CLASS (pk_connection_parent_class)->finalize (object);
}
@@ -121,28 +175,34 @@ pk_connection_class_init (PkConnectionClass *klass)
}
/**
- * pk_connection_connection_changed_cb:
- **/
-static void
-pk_connection_connection_changed_cb (EggDbusMonitor *egg_dbus_monitor, gboolean connected, PkConnection *connection)
-{
- egg_debug ("emit connection-changed: %i", connected);
- g_signal_emit (connection , signals [CONNECTION_CHANGED], 0, connected);
-}
-
-/**
* pk_connection_init:
**/
static void
pk_connection_init (PkConnection *connection)
{
+ GError *error = NULL;
connection->priv = PK_CONNECTION_GET_PRIVATE (connection);
- connection->priv->monitor = egg_dbus_monitor_new ();
- g_signal_connect (connection->priv->monitor, "connection-changed",
- G_CALLBACK (pk_connection_connection_changed_cb), connection);
- /* hardcode to PackageKit */
- egg_dbus_monitor_assign (connection->priv->monitor, EGG_DBUS_MONITOR_SYSTEM, PK_DBUS_SERVICE);
+ /* connect to correct bus */
+ connection->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (error != NULL) {
+ egg_warning ("Cannot connect to bus: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+ connection->priv->proxy = dbus_g_proxy_new_for_name_owner (connection->priv->connection,
+ DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS, &error);
+ if (error != NULL) {
+ egg_warning ("Cannot connect to proxy: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+ dbus_g_proxy_add_signal (connection->priv->proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (connection->priv->proxy, "NameOwnerChanged",
+ G_CALLBACK (egg_dbus_connection_name_owner_changed_cb),
+ connection, NULL);
}
/**
diff --git a/src/egg-dbus-monitor.c b/src/egg-dbus-monitor.c
deleted file mode 120000
index b58b973..90c2193
--- a/src/egg-dbus-monitor.c
+++ /dev/null
@@ -1 +0,0 @@
-../libpackagekit/egg-dbus-monitor.c
\ No newline at end of file
diff --git a/src/egg-dbus-monitor.c b/src/egg-dbus-monitor.c
new file mode 100644
index b58b973..90c2193
--- /dev/null
+++ b/src/egg-dbus-monitor.c
@@ -0,0 +1,290 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2006-2008 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 "config.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus.h>
+
+#include "egg-debug.h"
+#include "egg-dbus-monitor.h"
+
+static void egg_dbus_monitor_class_init (EggDbusMonitorClass *klass);
+static void egg_dbus_monitor_init (EggDbusMonitor *dbus_monitor);
+static void egg_dbus_monitor_finalize (GObject *object);
+
+#define EGG_DBUS_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorPrivate))
+
+struct EggDbusMonitorPrivate
+{
+ EggDbusMonitorType bus_type;
+ gchar *service;
+ DBusGProxy *proxy;
+ DBusGConnection *connection;
+ const gchar *unique_name;
+};
+
+enum {
+ EGG_DBUS_MONITOR_CONNECTION_CHANGED,
+ EGG_DBUS_MONITOR_CONNECTION_REPLACED,
+ EGG_DBUS_MONITOR_LAST_SIGNAL
+};
+
+static guint signals [EGG_DBUS_MONITOR_LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (EggDbusMonitor, egg_dbus_monitor, G_TYPE_OBJECT)
+
+/**
+ * egg_dbus_monitor_name_owner_changed_cb:
+ **/
+static void
+egg_dbus_monitor_name_owner_changed_cb (DBusGProxy *proxy, const gchar *name,
+ const gchar *prev, const gchar *new,
+ EggDbusMonitor *monitor)
+{
+ guint new_len;
+ guint prev_len;
+
+ g_return_if_fail (EGG_IS_DBUS_MONITOR (monitor));
+ if (monitor->priv->proxy == NULL)
+ return;
+
+ /* not us */
+ if (strcmp (name, monitor->priv->service) != 0)
+ return;
+
+ /* ITS4: ignore, not used for allocation */
+ new_len = strlen (new);
+ /* ITS4: ignore, not used for allocation */
+ prev_len = strlen (prev);
+
+ /* something --> nothing */
+ if (prev_len != 0 && new_len == 0) {
+ g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, FALSE);
+ return;
+ }
+
+ /* nothing --> something */
+ if (prev_len == 0 && new_len != 0) {
+ g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE);
+ return;
+ }
+
+ /* something --> something (we've replaced the old process) */
+ if (prev_len != 0 && new_len != 0) {
+ /* only send this to the prev client */
+ if (strcmp (monitor->priv->unique_name, prev) == 0)
+ g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED], 0);
+ return;
+ }
+}
+
+/**
+ * egg_dbus_monitor_assign:
+ * @monitor: This class instance
+ * @bus_type: The bus type, either EGG_DBUS_MONITOR_SESSION or EGG_DBUS_MONITOR_SYSTEM
+ * @service: The EGG_DBUS_MONITOR service name
+ * Return value: success
+ *
+ * Emits connection-changed(TRUE) if connection is alive - this means you
+ * have to connect up the callback before this function is called.
+ **/
+gboolean
+egg_dbus_monitor_assign (EggDbusMonitor *monitor, EggDbusMonitorType bus_type, const gchar *service)
+{
+ GError *error = NULL;
+ gboolean connected;
+ DBusConnection *conn;
+
+ g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
+ g_return_val_if_fail (service != NULL, FALSE);
+
+ if (monitor->priv->proxy != NULL) {
+ egg_warning ("already assigned!");
+ return FALSE;
+ }
+
+ monitor->priv->service = g_strdup (service);
+ monitor->priv->bus_type = bus_type;
+
+ /* connect to correct bus */
+ if (bus_type == EGG_DBUS_MONITOR_SESSION)
+ monitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ else
+ monitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (error != NULL) {
+ egg_warning ("Cannot connect to bus: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ monitor->priv->proxy = dbus_g_proxy_new_for_name_owner (monitor->priv->connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS,
+ &error);
+ if (error != NULL) {
+ egg_warning ("Cannot connect to DBUS: %s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ dbus_g_proxy_add_signal (monitor->priv->proxy, "NameOwnerChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (monitor->priv->proxy, "NameOwnerChanged",
+ G_CALLBACK (egg_dbus_monitor_name_owner_changed_cb),
+ monitor, NULL);
+
+ /* coldplug */
+ connected = egg_dbus_monitor_is_connected (monitor);
+ if (connected)
+ g_signal_emit (monitor, signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED], 0, TRUE);
+
+ /* save this for the replaced check */
+ conn = dbus_g_connection_get_connection (monitor->priv->connection);
+ monitor->priv->unique_name = dbus_bus_get_unique_name (conn);
+ return TRUE;
+}
+
+/**
+ * egg_dbus_monitor_is_connected:
+ * @monitor: This class instance
+ * Return value: if we are connected to a valid watch
+ **/
+gboolean
+egg_dbus_monitor_is_connected (EggDbusMonitor *monitor)
+{
+ DBusError error;
+ DBusConnection *conn;
+ gboolean ret;
+ g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
+
+ /* get raw connection */
+ conn = dbus_g_connection_get_connection (monitor->priv->connection);
+ dbus_error_init (&error);
+ ret = dbus_bus_name_has_owner (conn, monitor->priv->service, &error);
+ if (dbus_error_is_set (&error)) {
+ egg_debug ("error: %s", error.message);
+ dbus_error_free (&error);
+ }
+
+ return ret;
+}
+
+/**
+ * egg_dbus_monitor_reset
+ * @monitor: This class instance
+ * Return value: if we reset correctly
+ **/
+gboolean
+egg_dbus_monitor_reset (EggDbusMonitor *monitor)
+{
+ g_return_val_if_fail (EGG_IS_DBUS_MONITOR (monitor), FALSE);
+ if (monitor->priv->proxy != NULL) {
+ egg_debug ("not already assigned!");
+ return FALSE;
+ }
+ if (monitor->priv->service != NULL) {
+ g_free (monitor->priv->service);
+ monitor->priv->service = NULL;
+ }
+ if (monitor->priv->proxy != NULL) {
+ g_object_unref (monitor->priv->proxy);
+ monitor->priv->proxy = NULL;
+ }
+ return TRUE;
+}
+
+/**
+ * egg_dbus_monitor_class_init:
+ * @klass: The EggDbusMonitorClass
+ **/
+static void
+egg_dbus_monitor_class_init (EggDbusMonitorClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = egg_dbus_monitor_finalize;
+ g_type_class_add_private (klass, sizeof (EggDbusMonitorPrivate));
+ signals [EGG_DBUS_MONITOR_CONNECTION_CHANGED] =
+ g_signal_new ("connection-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggDbusMonitorClass, connection_changed),
+ NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+ signals [EGG_DBUS_MONITOR_CONNECTION_REPLACED] =
+ g_signal_new ("connection-replaced",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (EggDbusMonitorClass, connection_replaced),
+ NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+}
+
+/**
+ * egg_dbus_monitor_init:
+ * @monitor: This class instance
+ **/
+static void
+egg_dbus_monitor_init (EggDbusMonitor *monitor)
+{
+ monitor->priv = EGG_DBUS_MONITOR_GET_PRIVATE (monitor);
+ monitor->priv->service = NULL;
+ monitor->priv->bus_type = EGG_DBUS_MONITOR_SESSION;
+ monitor->priv->proxy = NULL;
+}
+
+/**
+ * egg_dbus_monitor_finalize:
+ * @object: The object to finalize
+ **/
+static void
+egg_dbus_monitor_finalize (GObject *object)
+{
+ EggDbusMonitor *monitor;
+
+ g_return_if_fail (EGG_IS_DBUS_MONITOR (object));
+
+ monitor = EGG_DBUS_MONITOR (object);
+
+ g_return_if_fail (monitor->priv != NULL);
+
+ g_free (monitor->priv->service);
+ if (monitor->priv->proxy != NULL)
+ g_object_unref (monitor->priv->proxy);
+
+ G_OBJECT_CLASS (egg_dbus_monitor_parent_class)->finalize (object);
+}
+
+/**
+ * egg_dbus_monitor_new:
+ *
+ * Return value: a new EggDbusMonitor object.
+ **/
+EggDbusMonitor *
+egg_dbus_monitor_new (void)
+{
+ EggDbusMonitor *monitor;
+ monitor = g_object_new (EGG_TYPE_DBUS_MONITOR, NULL);
+ return EGG_DBUS_MONITOR (monitor);
+}
+
diff --git a/src/egg-dbus-monitor.h b/src/egg-dbus-monitor.h
deleted file mode 120000
index f11d764..ea40f15
--- a/src/egg-dbus-monitor.h
+++ /dev/null
@@ -1 +0,0 @@
-../libpackagekit/egg-dbus-monitor.h
\ No newline at end of file
diff --git a/src/egg-dbus-monitor.h b/src/egg-dbus-monitor.h
new file mode 100644
index f11d764..ea40f15
--- /dev/null
+++ b/src/egg-dbus-monitor.h
@@ -0,0 +1,70 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2008 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.
+ */
+
+#ifndef __EGG_DBUS_MONITOR_H
+#define __EGG_DBUS_MONITOR_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EGG_TYPE_DBUS_MONITOR (egg_dbus_monitor_get_type ())
+#define EGG_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitor))
+#define EGG_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass))
+#define EGG_IS_DBUS_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EGG_TYPE_DBUS_MONITOR))
+#define EGG_IS_DBUS_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EGG_TYPE_DBUS_MONITOR))
+#define EGG_DBUS_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EGG_TYPE_DBUS_MONITOR, EggDbusMonitorClass))
+#define EGG_DBUS_MONITOR_ERROR (egg_dbus_monitor_error_quark ())
+#define EGG_DBUS_MONITOR_TYPE_ERROR (egg_dbus_monitor_error_get_type ())
+
+typedef struct EggDbusMonitorPrivate EggDbusMonitorPrivate;
+
+typedef struct
+{
+ GObject parent;
+ EggDbusMonitorPrivate *priv;
+} EggDbusMonitor;
+
+typedef struct
+{
+ GObjectClass parent_class;
+ void (* connection_changed) (EggDbusMonitor *watch,
+ gboolean connected);
+ void (* connection_replaced) (EggDbusMonitor *watch);
+} EggDbusMonitorClass;
+
+typedef enum {
+ EGG_DBUS_MONITOR_SESSION,
+ EGG_DBUS_MONITOR_SYSTEM
+} EggDbusMonitorType;
+
+GType egg_dbus_monitor_get_type (void) G_GNUC_CONST;
+EggDbusMonitor *egg_dbus_monitor_new (void);
+gboolean egg_dbus_monitor_reset (EggDbusMonitor *monitor);
+gboolean egg_dbus_monitor_assign (EggDbusMonitor *monitor,
+ EggDbusMonitorType bus_type,
+ const gchar *service);
+gboolean egg_dbus_monitor_is_connected (EggDbusMonitor *monitor);
+
+G_END_DECLS
+
+#endif /* __EGG_DBUS_MONITOR_H */
+
More information about the PackageKit-commit
mailing list