[gnome-packagekit/glib2: 43/79] Moo
- From: Richard Hughes <rhughes src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-packagekit/glib2: 43/79] Moo
- Date: Tue, 6 Oct 2009 09:48:21 +0000 (UTC)
commit 6da184f577cb6add17683046a9fb8c4767ec84c3
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 24 19:27:00 2009 +0100
Moo
src/Makefile.am | 2 ++
src/gpk-check-update.c | 31 +++++++++++++++++++------------
src/gpk-dbus-task.c | 20 +++++++++++++-------
src/gpk-firmware.c | 5 ++++-
src/gpk-hardware.c | 5 ++++-
src/gpk-update-icon.c | 2 +-
src/gpk-watch.c | 31 ++++++++++++++++++-------------
7 files changed, 61 insertions(+), 35 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 2e1ecf2..bb9ad32 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -88,6 +88,8 @@ libgpkshared_a_SOURCES = \
gpk-gnome.h \
gpk-common.c \
gpk-common.h \
+ gpk-task.c \
+ gpk-task.h \
gpk-error.c \
gpk-error.h \
$(NULL)
diff --git a/src/gpk-check-update.c b/src/gpk-check-update.c
index 20e5d86..50a6f23 100644
--- a/src/gpk-check-update.c
+++ b/src/gpk-check-update.c
@@ -44,12 +44,13 @@
#include "egg-string.h"
#include "egg-dbus-monitor.h"
-#include "gpk-common.h"
-#include "gpk-gnome.h"
#include "gpk-auto-refresh.h"
#include "gpk-check-update.h"
+#include "gpk-common.h"
#include "gpk-enum.h"
#include "gpk-error.h"
+#include "gpk-gnome.h"
+#include "gpk-task.h"
static void gpk_check_update_finalize (GObject *object);
static void gpk_check_update_libnotify_cb (NotifyNotification *notification, gchar *action, gpointer data);
@@ -379,7 +380,6 @@ gpk_check_update_finished_notify (GpkCheckUpdate *cupdate, PkResults *results)
}
g_strfreev (split);
}
- g_object_unref (array);
/* notify the user if there were skipped entries */
if (skipped_number > 0) {
@@ -448,14 +448,13 @@ out:
* gpk_check_update_update_system_finished_cb:
**/
static void
-gpk_check_update_update_system_finished_cb (GObject *object, GAsyncResult *res, GpkCheckUpdate *cupdate)
+gpk_check_update_update_system_finished_cb (PkTask *task, GAsyncResult *res, GpkCheckUpdate *cupdate)
{
- PkClient *client = PK_CLIENT(object);
PkResults *results;
GError *error = NULL;
/* get the results */
- results = pk_client_generic_finish (PK_CLIENT(client), res, &error);
+ results = pk_task_generic_finish (task, res, &error);
if (results == NULL) {
egg_warning ("failed to update system: %s", error->message);
g_error_free (error);
@@ -491,9 +490,15 @@ out:
static void
gpk_check_update_activate_update_cb (GtkStatusIcon *status_icon, GpkCheckUpdate *icon)
{
+ gboolean ret;
+ GError *error = NULL;
const gchar *command = "gpk-update-viewer";
- if (!g_spawn_command_line_async (command, NULL))
- egg_warning ("Couldn't execute command: %s", command);
+
+ ret = g_spawn_command_line_async (command, &error);
+ if (!ret) {
+ egg_warning ("Couldn't execute %s: %s", command, error->message);
+ g_error_free (error);
+ }
}
/**
@@ -544,7 +549,9 @@ gpk_check_update_libnotify_cb (NotifyNotification *notification, gchar *action,
/* just update the important updates */
package_ids = pk_ptr_array_to_strv (cupdate->priv->important_updates_array);
- pk_task_update_packages_async (cupdate->priv->task, package_ids, cupdate->priv->cancellable, NULL, NULL,
+ egg_warning ("package_ids=%p", package_ids);
+ egg_warning ("package_ids[0]=%s", package_ids[0]);
+ pk_client_update_packages_async (PK_CLIENT(cupdate->priv->task), TRUE, package_ids, cupdate->priv->cancellable, NULL, NULL,
(GAsyncReadyCallback) gpk_check_update_update_system_finished_cb, cupdate);
g_strfreev (package_ids);
@@ -1211,7 +1218,7 @@ gpk_check_update_get_distro_upgrades_finished_cb (GObject *object, GAsyncResult
PkClient *client = PK_CLIENT(object);
PkResults *results;
GError *error = NULL;
- GPtrArray *array;
+ GPtrArray *array = NULL;
gboolean ret;
guint i;
PkItemDistroUpgrade *item;
@@ -1257,7 +1264,7 @@ gpk_check_update_get_distro_upgrades_finished_cb (GObject *object, GAsyncResult
notification = notify_notification_new_with_status_icon (title, string->str, "help-browser", cupdate->priv->status_icon);
if (notification == NULL) {
egg_warning ("failed to make bubble");
- return;
+ goto out;
}
notify_notification_set_timeout (notification, NOTIFY_EXPIRES_NEVER);
notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);
@@ -1435,7 +1442,7 @@ gpk_check_update_init (GpkCheckUpdate *cupdate)
G_CALLBACK (gpk_cupdate_connection_changed_cb), cupdate);
/* use an asynchronous query object */
- cupdate->priv->task = pk_task_new ();
+ cupdate->priv->task = PK_TASK(pk_task_new ());
cupdate->priv->control = pk_control_new ();
g_signal_connect (cupdate->priv->control, "updates-changed",
diff --git a/src/gpk-dbus-task.c b/src/gpk-dbus-task.c
index 93a580f..db3ce0a 100644
--- a/src/gpk-dbus-task.c
+++ b/src/gpk-dbus-task.c
@@ -839,11 +839,15 @@ out:
void
gpk_dbus_task_search_file (GpkDbusTask *task, const gchar *search_file)
{
+ gchar **values = NULL;
+
/* get the package list for the installed packages */
egg_debug ("package_name=%s", search_file);
- pk_client_search_file_async (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), search_file, NULL,
+ values = g_strsplit (search_file, "&", -1);
+ pk_client_search_file_async (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), values, NULL,
(PkProgressCallback) gpk_dbus_task_progress_cb, task,
(GAsyncReadyCallback) gpk_dbus_task_search_file_search_file_cb, task);
+ g_strfreev (values);
}
/**
@@ -1311,7 +1315,7 @@ skip_checks:
gpk_modal_dialog_set_image_status (task->priv->dialog, PK_STATUS_ENUM_WAIT);
/* do search */
- pk_client_search_file_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1), full_paths[0], NULL,
+ pk_client_search_file_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1), full_paths, NULL,
(PkProgressCallback) gpk_dbus_task_progress_cb, task,
(GAsyncReadyCallback) gpk_dbus_task_install_provide_files_search_file_cb, task);
@@ -1582,7 +1586,7 @@ skip_checks:
/* get codec packages */
pk_client_what_provides_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED, PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1),
- PK_PROVIDES_ENUM_CODEC, parts[0], NULL,
+ PK_PROVIDES_ENUM_CODEC, parts, NULL,
(PkProgressCallback) gpk_dbus_task_progress_cb, task,
(GAsyncReadyCallback) gpk_dbus_task_codec_what_provides_cb, task);
out:
@@ -1746,7 +1750,7 @@ skip_checks:
/* action */
pk_client_what_provides_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED, PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1),
- PK_PROVIDES_ENUM_MIMETYPE, mime_types[0], NULL,
+ PK_PROVIDES_ENUM_MIMETYPE, mime_types, NULL,
(PkProgressCallback) gpk_dbus_task_progress_cb, task,
(GAsyncReadyCallback) gpk_dbus_task_mime_what_provides_cb, task);
/* wait for async reply */
@@ -2071,7 +2075,7 @@ skip_checks:
/* do each one */
pk_client_what_provides_async (task->priv->client, pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED, PK_FILTER_ENUM_ARCH, PK_FILTER_ENUM_NEWEST, -1),
- PK_PROVIDES_ENUM_FONT, fonts[0], NULL,
+ PK_PROVIDES_ENUM_FONT, fonts, NULL,
(PkProgressCallback) gpk_dbus_task_progress_cb, task,
(GAsyncReadyCallback) gpk_dbus_task_fontconfig_what_provides_cb, task);
out:
@@ -2229,9 +2233,11 @@ gpk_dbus_task_get_package_for_exec (GpkDbusTask *task, const gchar *exec)
GPtrArray *array = NULL;
const PkItemPackage *item;
PkResults *results = NULL;
+ gchar **values = NULL;
/* find the package name */
- results = pk_client_search_file (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), exec, NULL, NULL, NULL, &error);
+ values = g_strsplit (exec, "&", -1);
+ results = pk_client_search_file (task->priv->client, pk_bitfield_value (PK_FILTER_ENUM_INSTALLED), values, NULL, NULL, NULL, &error);
if (results == NULL) {
egg_warning ("failed to search file: %s", error->message);
g_error_free (error);
@@ -2256,7 +2262,7 @@ gpk_dbus_task_get_package_for_exec (GpkDbusTask *task, const gchar *exec)
package = g_strdup (item->package_id);
egg_debug ("got package %s", package);
out:
- /* use the exec name if we can't find an installed package */
+ g_strfreev (values);
if (array != NULL)
g_ptr_array_unref (array);
if (results != NULL)
diff --git a/src/gpk-firmware.c b/src/gpk-firmware.c
index abcc9d4..d6d5da5 100644
--- a/src/gpk-firmware.c
+++ b/src/gpk-firmware.c
@@ -480,10 +480,12 @@ gpk_firmware_check_available (GpkFirmware *firmware, const gchar *filename)
PkItemPackage *item = NULL;
PkBitfield filter;
PkResults *results;
+ gchar **values = NULL;
/* search for newest not installed package */
filter = pk_bitfield_from_enums (PK_FILTER_ENUM_NOT_INSTALLED, PK_FILTER_ENUM_NEWEST, -1);
- results = pk_client_search_file (firmware->priv->client, filter, filename, NULL, NULL, NULL, &error);
+ values = g_strsplit (filename, "&", -1);
+ results = pk_client_search_file (firmware->priv->client, filter, values, NULL, NULL, NULL, &error);
if (results == NULL) {
egg_warning ("failed to search file %s: %s", filename, error->message);
g_error_free (error);
@@ -499,6 +501,7 @@ gpk_firmware_check_available (GpkFirmware *firmware, const gchar *filename)
else
item = pk_item_package_ref (g_ptr_array_index (array, 0));
out:
+ g_strfreev (values);
if (array != NULL)
g_object_unref (array);
if (results != NULL)
diff --git a/src/gpk-hardware.c b/src/gpk-hardware.c
index c104888..71aca6d 100644
--- a/src/gpk-hardware.c
+++ b/src/gpk-hardware.c
@@ -195,9 +195,12 @@ out:
static void
gpk_hardware_check_for_driver_available (GpkHardware *hardware, const gchar *udi)
{
+ gchar **values = NULL;
+ values = g_strsplit (udi, "&", -1);
pk_client_what_provides_async (hardware->priv->client, pk_bitfield_value (PK_FILTER_ENUM_NOT_INSTALLED),
- PK_PROVIDES_ENUM_HARDWARE_DRIVER, udi, NULL, NULL, NULL,
+ PK_PROVIDES_ENUM_HARDWARE_DRIVER, values, NULL, NULL, NULL,
(GAsyncReadyCallback) gpk_hardware_what_provides_cb, hardware);
+ g_strfreev (values);
}
static gboolean
diff --git a/src/gpk-update-icon.c b/src/gpk-update-icon.c
index ea57d29..2bde05f 100644
--- a/src/gpk-update-icon.c
+++ b/src/gpk-update-icon.c
@@ -141,8 +141,8 @@ main (int argc, char *argv[])
if (! g_thread_supported ())
g_thread_init (NULL);
- dbus_g_thread_init ();
g_type_init ();
+ dbus_g_thread_init ();
notify_init ("gpk-update-icon");
/* TRANSLATORS: program name, a session wide daemon to watch for updates and changing system state */
diff --git a/src/gpk-watch.c b/src/gpk-watch.c
index c0b0c87..116b6e2 100644
--- a/src/gpk-watch.c
+++ b/src/gpk-watch.c
@@ -201,9 +201,8 @@ gpk_watch_refresh_tooltip (GpkWatch *watch)
/* any restart required? */
text = gpk_watch_get_restart_required_tooltip (watch);
- if (text != NULL) {
+ if (text != NULL)
g_string_append (string, text);
- }
g_free (text);
/* do we have any cached messages to show? */
@@ -219,6 +218,8 @@ gpk_watch_refresh_tooltip (GpkWatch *watch)
egg_debug ("nothing to show");
goto out;
}
+
+ /* print all the running transactions */
for (i=0; i<array->len; i++) {
progress = g_ptr_array_index (array, i);
g_object_get (progress,
@@ -226,20 +227,19 @@ gpk_watch_refresh_tooltip (GpkWatch *watch)
NULL);
/* should we display the text */
- g_string_append_printf (string, "%s", gpk_status_enum_to_localised_text (status));
+ g_string_append_printf (string, "%s\n", gpk_status_enum_to_localised_text (status));
/* don't fill the screen with a giant tooltip */
if (i > GPK_WATCH_MAXIMUM_TOOLTIP_LINES) {
/* TRANSLATORS: if the menu won't fit, inform the user there are a few more things waiting */
trailer = ngettext ("(%i more task)", "(%i more tasks)", i - GPK_WATCH_MAXIMUM_TOOLTIP_LINES);
- g_string_append_printf (string, "%s", trailer);
+ g_string_append_printf (string, "%s\n", trailer);
break;
}
}
- if (string->len == 0)
- g_string_append (string, "Doing something...");
- else
- g_string_set_size (string, string->len-1);
+ /* remove trailing newline */
+ if (string->len > 0)
+ g_string_set_size (string, string->len-1);
out:
gtk_status_icon_set_tooltip_text (watch->priv->status_icon, string->str);
g_string_free (string, TRUE);
@@ -348,7 +348,7 @@ gpk_watch_refresh_icon (GpkWatch *watch)
PK_STATUS_ENUM_REPACKAGING,
PK_STATUS_ENUM_WAIT,
PK_STATUS_ENUM_WAITING_FOR_LOCK,
- PK_STATUS_ENUM_FINISHED, -1);
+ -1);
}
/* only set if in the list and not unknown */
@@ -1197,6 +1197,7 @@ gpk_watch_set_connected (GpkWatch *watch, gboolean connected)
}
/* daemon has just appeared */
+ egg_debug ("dameon has just appeared");
gpk_watch_refresh_icon (watch);
gpk_watch_refresh_tooltip (watch);
gpk_watch_set_proxies (watch);
@@ -1572,12 +1573,14 @@ gpk_watch_progress_cb (PkProgress *progress, PkProgressType type, GpkWatch *watc
/* add if not already in list */
array = watch->priv->array_progress;
for (i=0; i<array->len; i++) {
- progress = g_ptr_array_index (array, i);
+ progress_tmp = g_ptr_array_index (array, i);
if (progress_tmp == progress)
ret = TRUE;
}
- if (!ret)
+ if (!ret) {
+ egg_debug ("adding progress %p", progress);
g_ptr_array_add (array, g_object_ref (progress));
+ }
/* get data */
g_object_get (progress,
@@ -1590,8 +1593,10 @@ gpk_watch_progress_cb (PkProgress *progress, PkProgressType type, GpkWatch *watc
NULL);
/* refresh both */
- gpk_watch_refresh_icon (watch);
- gpk_watch_refresh_tooltip (watch);
+ if (type == PK_PROGRESS_TYPE_STATUS) {
+ gpk_watch_refresh_icon (watch);
+ gpk_watch_refresh_tooltip (watch);
+ }
/* is not the watched transaction */
if (g_strcmp0 (transaction_id, watch->priv->transaction_id) != 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]