[PackageKit-commit] packagekit: Branch 'master' - 14 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Tue May 6 10:17:19 PDT 2008
backends/alpm/pk-backend-alpm.c | 60 +++++++++----------
backends/dummy/pk-backend-dummy.c | 6 +
configure.ac | 1
contrib/yum-packagekit/refresh-packagekit.py | 2
data/95packagekit | 3
docs/html/pk-faq.html | 32 ++++++++--
docs/spec/pk-methods.xml | 4 -
src/pk-engine.c | 83 ++++++++++++++++++++-------
src/pk-engine.h | 1
src/pk-interface.xml | 1
src/pk-network-unix.c | 79 +++++++++++++++++++++++++
11 files changed, 208 insertions(+), 64 deletions(-)
New commits:
commit c58d2e937cad8775a80b03616c398b105ef4b44a
Merge: 4aca401... 6914576...
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date: Tue May 6 19:19:19 2008 +0300
Merge branch 'master' of git+ssh://onestep_ua@git.packagekit.org/srv/git/PackageKit
commit 4aca40138402f2628d3ee5697f67dfb709f1a623
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date: Tue May 6 19:18:57 2008 +0300
configure: removed alpm-related warning as it's functional now
diff --git a/configure.ac b/configure.ac
index 82ddaf6..df2c2e0 100755
--- a/configure.ac
+++ b/configure.ac
@@ -542,7 +542,6 @@ fi
if test x$enable_alpm = xyes; then
with_default_backend=dummy
- AC_MSG_WARN([The alpm backend doesn't work at all!])
AC_CHECK_HEADER([alpm.h],
[with_default_backend=alpm],
[AC_MSG_WARN([No alpm headers found - falling back to dummy backend])])
commit 6914576e838643b5c6b0e70ac1432ee71b3a9fb3
Merge: 9650aba... 6473f24...
Author: Richard Hughes <richard at hughsie.com>
Date: Tue May 6 17:06:33 2008 +0100
Merge branch 'master' of git+ssh://hughsie@git.packagekit.org/srv/git/PackageKit
commit 81048a48a39bf917608b60956508c419b52063b8
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date: Tue May 6 19:06:10 2008 +0300
docs: updated list of operations supported by alpm
diff --git a/docs/html/pk-faq.html b/docs/html/pk-faq.html
index 5c92c9c..e88a4e4 100644
--- a/docs/html/pk-faq.html
+++ b/docs/html/pk-faq.html
@@ -67,7 +67,7 @@
<td><b>Resolve</b></td>
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt2 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- box -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
@@ -82,7 +82,7 @@
<td><b>RefreshCache</b></td>
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt2 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- box -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg -->
@@ -142,7 +142,7 @@
<td><b>SearchDetails</b></td>
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt2 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- box -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg -->
@@ -202,7 +202,7 @@
<td><b>InstallFile</b></td>
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt2 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- box -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- conary -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
@@ -277,7 +277,7 @@
<td><b>GetDetails</b></td>
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- apt2 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- box -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- opkg -->
@@ -292,7 +292,7 @@
<td><b>GetFiles</b></td>
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt2 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
+<td><img src="img/status-good.png" alt="[yes]"/></td><!-- alpm -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- box -->
<td><img src="img/status-good.png" alt="[yes]"/></td><!-- conary -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- opkg -->
@@ -412,7 +412,7 @@
<td><b>GetPackages</b></td>
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt -->
<td><img src="img/status-bad.png" alt="[no]"/></td><!-- apt2 -->
-<td><img src="img/status-bad.png" alt="[no]"/></td><!-- alpm -->
+<td><img src="img/status-good.png" alt="[yes]"/></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 -->
commit 9650abafe396ac93054b3a4910ea34017e277729
Author: Richard Hughes <richard at hughsie.com>
Date: Tue May 6 17:05:02 2008 +0100
if NetworkManager is not available, then search for an
active gateway so we can detect the presence of an internet connection
diff --git a/src/pk-network-unix.c b/src/pk-network-unix.c
index 43fa500..11c23a2 100644
--- a/src/pk-network-unix.c
+++ b/src/pk-network-unix.c
@@ -44,6 +44,7 @@
#include <glib/gi18n.h>
+#include "pk-common.h"
#include "pk-debug.h"
#include "pk-network-unix.h"
#include "pk-marshal.h"
@@ -72,6 +73,8 @@ enum {
static guint signals [PK_NETWORK_UNIX_LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE (PkNetworkUnix, pk_network_unix, G_TYPE_OBJECT)
+#define PK_NETWORK_PROC_ROUTE "/proc/net/route"
+
/**
* pk_network_unix_get_network_state:
@@ -82,9 +85,81 @@ G_DEFINE_TYPE (PkNetworkUnix, pk_network_unix, G_TYPE_OBJECT)
PkNetworkEnum
pk_network_unix_get_network_state (PkNetworkUnix *network_unix)
{
+ gchar *contents = NULL;
+ gboolean ret;
+ GError *error = NULL;
+ gchar **lines;
+ gchar **sections;
+ guint number_lines;
+ guint number_sections;
+ guint i;
+ gboolean online = FALSE;
+
g_return_val_if_fail (PK_IS_NETWORK_UNIX (network_unix), PK_NETWORK_ENUM_UNKNOWN);
- /* TODO: check the default route */
- return PK_NETWORK_ENUM_ONLINE;
+
+ /* hack, because netlink is teh suck */
+ ret = g_file_get_contents (PK_NETWORK_PROC_ROUTE, &contents, NULL, &error);
+ if (!ret) {
+ pk_warning ("could not open %s: %s", PK_NETWORK_PROC_ROUTE, error->message);
+ g_error_free (error);
+ /* no idea whatsoever! */
+ return PK_NETWORK_ENUM_ONLINE;
+ }
+
+ /* something insane */
+ if (contents == NULL) {
+ pk_warning ("insane contents of %s", PK_NETWORK_PROC_ROUTE);
+ return PK_NETWORK_ENUM_ONLINE;
+ }
+
+ /* one line per interface */
+ lines = g_strsplit (contents, "\n", 0);
+ if (lines == NULL) {
+ pk_warning ("unable to split %s", PK_NETWORK_PROC_ROUTE);
+ return PK_NETWORK_ENUM_ONLINE;
+ }
+
+ number_lines = g_strv_length (lines);
+ for (i=0; i<number_lines; i++) {
+ /* empty line */
+ if (pk_strzero (lines[i])) {
+ continue;
+ }
+
+ /* tab delimited */
+ sections = g_strsplit (lines[i], "\t", 0);
+ if (sections == NULL) {
+ pk_warning ("unable to split %s", PK_NETWORK_PROC_ROUTE);
+ continue;
+ }
+
+ /* is header? */
+ if (pk_strequal (sections[0], "Iface")) {
+ continue;
+ }
+
+ /* is correct parameters? */
+ number_sections = g_strv_length (sections);
+ if (number_sections != 11) {
+ pk_warning ("invalid line '%s' (%i)", lines[i], number_sections);
+ continue;
+ }
+
+ /* is MTU and gateway nonzero? */
+ if (!pk_strequal (sections[8], "0") &&
+ !pk_strequal (sections[2], "00000000")) {
+ pk_debug ("interface %s is valid", sections[0]);
+ online = TRUE;
+ }
+ g_strfreev (sections);
+ }
+ g_strfreev (lines);
+
+ if (online) {
+ return PK_NETWORK_ENUM_ONLINE;
+ }
+
+ return PK_NETWORK_ENUM_OFFLINE;
}
/**
commit 05fd0f60ca7bf9d3480d5088236481a5b332bd5a
Author: Richard Hughes <richard at hughsie.com>
Date: Tue May 6 16:59:58 2008 +0100
DUMMY: force the network to be online in get updates so we can test the network code
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 685279b..f15e959 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -255,6 +255,12 @@ backend_get_updates (PkBackend *backend, PkFilterEnum filters)
{
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
pk_backend_no_percentage_updates (backend);
+ /* check network state */
+ if (!pk_backend_is_online (backend)) {
+ pk_backend_error_code (backend, PK_ERROR_ENUM_NO_NETWORK, "Cannot check when offline");
+ pk_backend_finished (backend);
+ return;
+ }
_signal_timeout = g_timeout_add (1000, backend_get_updates_timeout, backend);
}
commit 6473f24e3c2787cedb6d9b7951aba0e14a6e8e2e
Merge: c69f44c... 0be7a1c...
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date: Tue May 6 18:50:40 2008 +0300
Merge branch 'master' of git+ssh://onestep_ua@git.packagekit.org/srv/git/PackageKit
commit c69f44c7a3ce7b54d00ca9a4a32eac4139af10da
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date: Tue May 6 18:50:24 2008 +0300
alpm: improvements in backend_resolve, find_packages_by_name
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 1d2a4e7..3f3db24 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -243,7 +243,7 @@ find_packages_by_details (const gchar *name, pmdb_t *db)
}
alpm_list_t *
-find_packages_by_name (const gchar *name, pmdb_t *db)
+find_packages_by_name (const gchar *name, pmdb_t *db, gboolean exact)
{
if (db == NULL || name == NULL)
return NULL;
@@ -261,7 +261,13 @@ find_packages_by_name (const gchar *name, pmdb_t *db)
for (iterator = cache; iterator; iterator = alpm_list_next (iterator)) {
pmpkg_t *pkg = alpm_list_getdata (iterator);
- if (strstr (alpm_pkg_get_name (pkg), name)) {
+ gboolean match;
+ if (exact)
+ match = strcmp (alpm_pkg_get_name (pkg), name) == 0;
+ else
+ match = strstr (alpm_pkg_get_name (pkg), name) != NULL;
+
+ if (match) {
PackageSource *source = g_malloc (sizeof (PackageSource));
source->pkg = (pmpkg_t *) pkg;
@@ -1004,32 +1010,34 @@ backend_remove_package (PkBackend *backend, const gchar *package_id, gboolean al
/**
* backend_resolve:
- * Currently works only for local packages
*/
static void
backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package)
{
+ alpm_list_t *result = NULL;
+
pk_backend_set_status (backend, PK_STATUS_ENUM_QUERY);
- pmdb_t *localdb = alpm_option_get_localdb ();
+ gboolean search_installed = pk_enums_contain (filters, PK_FILTER_ENUM_INSTALLED);
+ gboolean search_not_installed = pk_enums_contain (filters, PK_FILTER_ENUM_NOT_INSTALLED);
- /* result will be the list of PackageSource */
- alpm_list_t *result = find_packages_by_name (package, localdb);
+ if (!search_not_installed) {
+ // Search in local db
+ result = alpm_list_join (result, find_packages_by_name (package, alpm_option_get_localdb (), TRUE));
+ }
- if (result == NULL) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "Package is not installed");
- pk_backend_finished (backend);
- return;
- } else
- pk_debug ("alpm: package %s found, trying to resolve...", package);
+ if (!search_installed) {
+ // Search in sync dbs
+ alpm_list_t *iterator;
+ for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator))
+ result = alpm_list_join (result, find_packages_by_name (package, (pmdb_t *) alpm_list_getdata(iterator), TRUE));
+ }
- pmpkg_t *pkg = ((PackageSource *) alpm_list_getdata (result))->pkg;
- pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
- pk_package_id_build (alpm_pkg_get_name (pkg), alpm_pkg_get_version (pkg), alpm_pkg_get_arch (pkg), "local"),
- alpm_pkg_get_desc (pkg));
+ add_packages_from_list (backend, alpm_list_first (result));
alpm_list_free_inner (result, (alpm_list_fn_free) package_source_free);
alpm_list_free (result);
+
pk_backend_finished (backend);
}
@@ -1081,14 +1089,14 @@ backend_search_name (PkBackend *backend, PkFilterEnum filters, const gchar *sear
if (!search_not_installed) {
// Search in local db
- result = alpm_list_join (result, find_packages_by_name (search, alpm_option_get_localdb ()));
+ result = alpm_list_join (result, find_packages_by_name (search, alpm_option_get_localdb (), FALSE));
}
if (!search_installed) {
// Search in sync dbs
alpm_list_t *iterator;
for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator))
- result = alpm_list_join (result, find_packages_by_name (search, (pmdb_t *) alpm_list_getdata(iterator)));
+ result = alpm_list_join (result, find_packages_by_name (search, (pmdb_t *) alpm_list_getdata(iterator), FALSE));
}
add_packages_from_list (backend, alpm_list_first (result));
commit 0be7a1c7001e456d6b4947da87d07d61a0220967
Author: Richard Hughes <richard at hughsie.com>
Date: Tue May 6 15:41:05 2008 +0100
build fix
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 0638e4d..db81d36 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -351,7 +351,7 @@ pk_engine_state_has_changed (PkEngine *engine, const gchar *reason, GError **err
}
/* don't bombard the user 10 seconds after resuming */
- if (pk_strcmp (reason, "resume")) {
+ if (pk_strequal (reason, "resume")) {
is_priority = FALSE;
}
commit f74549b6fd746b5e795230f75aa6a551d50e566a
Author: Aurelien Lefebvre <alefebvre at mandriva.com>
Date: Tue May 6 16:34:44 2008 +0200
Little fix in doc.
diff --git a/docs/spec/pk-methods.xml b/docs/spec/pk-methods.xml
index 21761c5..3a359d1 100644
--- a/docs/spec/pk-methods.xml
+++ b/docs/spec/pk-methods.xml
@@ -469,7 +469,7 @@
</sect1>
<sect1 id="methods-what-provides">
- <title>Get Depends</title>
+ <title>What Provides</title>
<para>
WhatProvides should return packages that provide the supplied attributes.
This method is useful for finding out what package(s) provide a modalias
@@ -497,7 +497,7 @@
<row>
<entry><literal>type</literal></entry>
<entry>
- A PkProvideType, e.g. <literal>PK_PROVIDE_ENUM_CODEC</literal>.
+ A PkProvideType, e.g. <literal>PK_PROVIDES_ENUM_CODEC</literal>.
</entry>
</row>
<row>
commit 4b1303c2d5dd0c5197b5f6bc57de7434e3904e33
Author: Valeriy Lyasotskiy <onestep at ukr.net>
Date: Tue May 6 17:30:23 2008 +0300
alpm: fix backend_resolve
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index bc188bb..1d2a4e7 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -209,7 +209,7 @@ add_packages_from_list (PkBackend *backend, alpm_list_t *list)
}
alpm_list_t *
-find_packages_by_desc (const gchar *name, pmdb_t *db)
+find_packages_by_details (const gchar *name, pmdb_t *db)
{
if (db == NULL || name == NULL)
return NULL;
@@ -319,7 +319,7 @@ pkg_is_installed (const gchar *name, const gchar *version)
if (localdb == NULL)
return FALSE;
- result = find_packages_by_desc (name, localdb);
+ result = find_packages_by_details (name, localdb);
if (result == NULL)
return FALSE;
if (!alpm_list_count (result))
@@ -842,7 +842,7 @@ backend_install_package (PkBackend *backend, const gchar *package_id)
// Next generation code?
/*
for (; syncdbs; syncdbs = alpm_list_next (syncdbs))
- result = alpm_list_join (result, find_packages_by_desc (id->name, (pmdb_t *) syncdbs->data));
+ result = alpm_list_join (result, find_packages_by_details (id->name, (pmdb_t *) syncdbs->data));
if (result == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_ID_INVALID, "Package not found");
@@ -1014,24 +1014,16 @@ backend_resolve (PkBackend *backend, PkFilterEnum filters, const gchar *package)
pmdb_t *localdb = alpm_option_get_localdb ();
/* result will be the list of PackageSource */
- alpm_list_t *result = find_packages_by_desc (package, localdb);
-
- if (result != NULL)
- pk_debug ("alpm: package %s found, trying to resolve...", package);
+ alpm_list_t *result = find_packages_by_name (package, localdb);
if (result == NULL) {
pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "Package is not installed");
pk_backend_finished (backend);
return;
- } else if (alpm_list_count (result) != 1 || strcmp (alpm_pkg_get_name (((PackageSource *) result->data)->pkg), package) != 0) {
- pk_backend_error_code (backend, PK_ERROR_ENUM_PACKAGE_NOT_INSTALLED, "Package is not installed");
- pk_backend_finished (backend);
- alpm_list_free_inner (result, (alpm_list_fn_free) package_source_free);
- alpm_list_free (result);
- return;
- }
+ } else
+ pk_debug ("alpm: package %s found, trying to resolve...", package);
- pmpkg_t *pkg = ((PackageSource *) result->data)->pkg;
+ pmpkg_t *pkg = ((PackageSource *) alpm_list_getdata (result))->pkg;
pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
pk_package_id_build (alpm_pkg_get_name (pkg), alpm_pkg_get_version (pkg), alpm_pkg_get_arch (pkg), "local"),
alpm_pkg_get_desc (pkg));
@@ -1056,14 +1048,14 @@ backend_search_details (PkBackend *backend, PkFilterEnum filters, const gchar *s
if (!search_not_installed) {
// Search in local db
- result = alpm_list_join (result, find_packages_by_desc (search, alpm_option_get_localdb ()));
+ result = alpm_list_join (result, find_packages_by_details (search, alpm_option_get_localdb ()));
}
if (!search_installed) {
// Search in sync dbs
alpm_list_t *iterator;
for (iterator = alpm_option_get_syncdbs (); iterator; iterator = alpm_list_next (iterator))
- result = alpm_list_join (result, find_packages_by_desc (search, (pmdb_t *) alpm_list_getdata(iterator)));
+ result = alpm_list_join (result, find_packages_by_details (search, (pmdb_t *) alpm_list_getdata(iterator)));
}
add_packages_from_list (backend, alpm_list_first (result));
commit 7c525b30da88af3303a3a5b0bef0022e3c996d92
Merge: cc3f96c... a4e7b83...
Author: Richard Hughes <richard at hughsie.com>
Date: Tue May 6 14:27:51 2008 +0100
Merge branch 'master' into state-changed-reason
commit a4e7b83aec9827447beeaec22f20a2b59ce74ac7
Author: Richard Hughes <richard at hughsie.com>
Date: Tue May 6 14:24:17 2008 +0100
add a python example to the FAQ page
diff --git a/docs/html/pk-faq.html b/docs/html/pk-faq.html
index f07c3eb..5c92c9c 100644
--- a/docs/html/pk-faq.html
+++ b/docs/html/pk-faq.html
@@ -641,6 +641,24 @@ if (!ret) {
}
</pre>
<p>
+or in python...
+</p>
+<pre>
+import dbus
+
+try:
+ bus = dbus.SessionBus()
+except dbus.DBusException, e:
+ print 'Unable to connect to dbus: %s' % str(e)
+ sys.exit()
+try:
+ proxy = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
+ iface = dbus.Interface(proxy, 'org.freedesktop.PackageKit')
+ iface.InstallPackageName('openoffice-clipart')
+except dbus.DBusException, e:
+ print 'Unable to use PackageKit: %s' % str(e)
+</pre>
+<p>
The methods available on this interface are:
</p>
<ul>
commit cc3f96c5c10c8398ab7cfe0aa79d6393cd1df670
Author: Richard Hughes <richard at hughsie.com>
Date: Tue May 6 10:26:16 2008 +0100
add a 'reason' parameter to StateHasChanged() so we can
wait different timeouts for priority and normal reasons. fixes rh#445292
diff --git a/contrib/yum-packagekit/refresh-packagekit.py b/contrib/yum-packagekit/refresh-packagekit.py
index 247be9b..634d585 100644
--- a/contrib/yum-packagekit/refresh-packagekit.py
+++ b/contrib/yum-packagekit/refresh-packagekit.py
@@ -34,7 +34,7 @@ def posttrans_hook(conduit):
packagekit_proxy = bus.get_object('org.freedesktop.PackageKit',
'/org/freedesktop/PackageKit')
packagekit_iface = dbus.Interface(packagekit_proxy, 'org.freedesktop.PackageKit')
- packagekit_iface.StateHasChanged()
+ packagekit_iface.StateHasChanged('posttrans')
except dbus.DBusException, e:
conduit.info(2, "Unable to send message to PackageKit")
conduit.info(6, "%s" %(e,))
diff --git a/data/95packagekit b/data/95packagekit
index f6e72c3..407cd1a 100755
--- a/data/95packagekit
+++ b/data/95packagekit
@@ -13,7 +13,8 @@ case "$1" in
dbus-send --system --dest=org.freedesktop.PackageKit \
--type=method_call --print-reply \
/org/freedesktop/PackageKit \
- org.freedesktop.PackageKit.StateHasChanged
+ org.freedesktop.PackageKit.StateHasChanged \
+ string:'resume'
;;
*)
;;
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 654b126..0638e4d 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -68,16 +68,26 @@ static void pk_engine_finalize (GObject *object);
#define PK_ENGINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_ENGINE, PkEnginePrivate))
/**
- * PK_ENGINE_STATE_CHANGED_TIMEOUT:
+ * PK_ENGINE_STATE_CHANGED_PRIORITY_TIMEOUT:
*
* The timeout in seconds to wait when we get the StateHasChanged method.
- * We don't want to queue these transactions if one is already in progress.
+ * We don't queue these transactions if one is already in progress.
*
- * We probably also need to wait for NetworkManager to come back up if we are
- * resuming, and we probably don't want to be doing this at a busy time after
- * a yum transaction.
+ * This should be used when a native tool has been used, and the update UI should
+ * be updated to reflect reality.
*/
-#define PK_ENGINE_STATE_CHANGED_TIMEOUT 10 /* seconds */
+#define PK_ENGINE_STATE_CHANGED_PRIORITY_TIMEOUT 5 /* seconds */
+
+/**
+ * PK_ENGINE_STATE_CHANGED_NORMAL_TIMEOUT:
+ *
+ * The timeout in seconds to wait when we get the StateHasChanged method (for selected reasons).
+ * We don't queue these transactions if one is already in progress.
+ *
+ * We probably don't want to be doing an update check at the busy time after a resume, or for
+ * other non-critical reasons.
+ */
+#define PK_ENGINE_STATE_CHANGED_NORMAL_TIMEOUT 10*60 /* seconds */
struct PkEnginePrivate
{
@@ -95,7 +105,8 @@ struct PkEnginePrivate
PkRoleEnum actions;
PkGroupEnum groups;
PkFilterEnum filters;
- gboolean signal_state_timeout; /* don't queue StateHasChanged */
+ guint signal_state_priority_timeout;
+ guint signal_state_normal_timeout;
};
enum {
@@ -302,7 +313,7 @@ pk_engine_state_changed_cb (gpointer data)
/* if network is not up, then just reschedule */
state = pk_network_get_network_state (engine->priv->network);
if (state == PK_NETWORK_ENUM_OFFLINE) {
- /* wait another timeout of PK_ENGINE_STATE_CHANGED_TIMEOUT */
+ /* wait another timeout of PK_ENGINE_STATE_CHANGED_x_TIMEOUT */
return TRUE;
}
@@ -312,7 +323,8 @@ pk_engine_state_changed_cb (gpointer data)
pk_notify_updates_changed (engine->priv->notify);
/* reset, now valid */
- engine->priv->signal_state_timeout = 0;
+ engine->priv->signal_state_priority_timeout = 0;
+ engine->priv->signal_state_normal_timeout = 0;
return FALSE;
}
@@ -324,21 +336,47 @@ pk_engine_state_changed_cb (gpointer data)
* have finished their transaction, and the update cache may not be valid.
**/
gboolean
-pk_engine_state_has_changed (PkEngine *engine, GError **error)
+pk_engine_state_has_changed (PkEngine *engine, const gchar *reason, GError **error)
{
+ gboolean is_priority = TRUE;
+
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- if (engine->priv->signal_state_timeout != 0) {
+ /* have we already scheduled priority? */
+ if (engine->priv->signal_state_priority_timeout != 0) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INVALID_STATE,
- "Already asked to refresh state less than %i seconds ago",
- PK_ENGINE_STATE_CHANGED_TIMEOUT);
+ "Already asked to refresh priority state less than %i seconds ago",
+ PK_ENGINE_STATE_CHANGED_PRIORITY_TIMEOUT);
return FALSE;
}
- /* wait a little delay in case we get multiple requests */
- engine->priv->signal_state_timeout = g_timeout_add_seconds (PK_ENGINE_STATE_CHANGED_TIMEOUT,
- pk_engine_state_changed_cb, engine);
+ /* don't bombard the user 10 seconds after resuming */
+ if (pk_strcmp (reason, "resume")) {
+ is_priority = FALSE;
+ }
+ /* are we normal, and already scheduled normal? */
+ if (!is_priority && engine->priv->signal_state_normal_timeout != 0) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INVALID_STATE,
+ "Already asked to refresh normal state less than %i seconds ago",
+ PK_ENGINE_STATE_CHANGED_NORMAL_TIMEOUT);
+ return FALSE;
+ }
+
+ /* are we priority, and already scheduled normal? */
+ if (is_priority && engine->priv->signal_state_normal_timeout != 0) {
+ /* clear normal, as we are about to schedule a priority */
+ g_source_remove (engine->priv->signal_state_normal_timeout);
+ engine->priv->signal_state_normal_timeout = 0; }
+
+ /* wait a little delay in case we get multiple requests */
+ if (is_priority) {
+ engine->priv->signal_state_priority_timeout = g_timeout_add_seconds (PK_ENGINE_STATE_CHANGED_PRIORITY_TIMEOUT,
+ pk_engine_state_changed_cb, engine);
+ } else {
+ engine->priv->signal_state_normal_timeout = g_timeout_add_seconds (PK_ENGINE_STATE_CHANGED_NORMAL_TIMEOUT,
+ pk_engine_state_changed_cb, engine);
+ }
return TRUE;
}
@@ -575,7 +613,8 @@ pk_engine_init (PkEngine *engine)
engine->priv->cache = pk_cache_new ();
/* we need to be able to clear this */
- engine->priv->signal_state_timeout = 0;
+ engine->priv->signal_state_priority_timeout = 0;
+ engine->priv->signal_state_normal_timeout = 0;
/* get another connection */
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
@@ -637,9 +676,13 @@ pk_engine_finalize (GObject *object)
}
/* if we set an state changed notifier, clear */
- if (engine->priv->signal_state_timeout != 0) {
- g_source_remove (engine->priv->signal_state_timeout);
- engine->priv->signal_state_timeout = 0;
+ if (engine->priv->signal_state_priority_timeout != 0) {
+ g_source_remove (engine->priv->signal_state_priority_timeout);
+ engine->priv->signal_state_priority_timeout = 0;
+ }
+ if (engine->priv->signal_state_normal_timeout != 0) {
+ g_source_remove (engine->priv->signal_state_normal_timeout);
+ engine->priv->signal_state_normal_timeout = 0;
}
/* compulsory gobjects */
diff --git a/src/pk-engine.h b/src/pk-engine.h
index 017f847..c59b1f3 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -96,6 +96,7 @@ gboolean pk_engine_get_transaction_list (PkEngine *engine,
gchar ***transaction_list,
GError **error);
gboolean pk_engine_state_has_changed (PkEngine *engine,
+ const gchar *reason,
GError **error);
gboolean pk_engine_suggest_daemon_quit (PkEngine *engine,
GError **error);
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 1790530..e9e74e1 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -26,6 +26,7 @@
<arg type="as" name="transactions" direction="out"/>
</method>
<method name="StateHasChanged">
+ <arg type="s" name="reason" direction="in"/>
</method>
<method name="SuggestDaemonQuit">
</method>
More information about the PackageKit-commit
mailing list