[packagekit] packagekit: Branch 'master' - 14 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Mon Oct 1 10:17:05 PDT 2007
TODO | 24 +--
backends/alpm/pk-backend-alpm.c | 155 ++----------------------
backends/apt/pk-backend-apt.cpp | 7 -
backends/box/pk-backend-box.c | 8 -
backends/conary/helpers/conaryBackend.py | 4
backends/conary/helpers/search-name-live.py | 21 ---
backends/dummy/pk-backend-dummy.c | 80 ++++++++----
backends/test/pk-backend-test-thread.c | 16 +-
backends/yum/helpers/yumBackend.py | 38 +++---
client/pk-console.c | 25 ++--
docs/introduction.xml | 96 ++++++++++++---
libpackagekit/pk-client.c | 174 ++++++++++++++++++++++++----
libpackagekit/pk-client.h | 6
libpackagekit/pk-enum.c | 32 +++++
libpackagekit/pk-enum.h | 17 ++
python/packagekit/backend.py | 13 +-
src/pk-backend.c | 41 +++++-
src/pk-backend.h | 3
src/pk-engine.c | 78 ++++++++++--
src/pk-interface.xml | 6
src/pk-marshal.list | 5
src/pk-transaction-db.c | 38 +++++-
src/pk-transaction-db.h | 3
src/pk-transaction-list.c | 2
src/pk-transaction-list.h | 1
25 files changed, 575 insertions(+), 318 deletions(-)
New commits:
diff-tree 0b860848bc7253bf30eaac526e6b8110b586d783 (from 8c68baf551711fd1364dcbb103d324dbdbc5b50c)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Mon Oct 1 09:12:42 2007 +0200
Changed yum backend to use new package signals
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 918543a..65acde4 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -64,7 +64,7 @@ class PackageKitYumBackend(PackageKitBas
break
count+=1
# are we installed?
- if self.yumbase.rpmdb.installed(pkg.name):
+ if pkg.repoid == 'installed':
installed = INFO_INSTALLED
else:
installed = INFO_AVAILABLE
@@ -72,6 +72,7 @@ class PackageKitYumBackend(PackageKitBas
if self._do_filtering(pkg,fltlist,installed):
self._show_package(pkg, installed)
+
def _do_filtering(self,pkg,filterList,installed):
''' Filter the package, based on the filter in filterList '''
@@ -79,9 +80,9 @@ class PackageKitYumBackend(PackageKitBas
do_print = False;
if filterList == ['none']: # 'none' = all packages.
return True
- elif 'installed' in filterList and installed == '1':
+ elif 'installed' in filterList and installed == INFO_INSTALLED:
do_print = True
- elif '~installed' in filterList and installed == '0':
+ elif '~installed' in filterList and installed == INFO_AVAILABLE:
do_print = True
if len(filterList) == 1: # Only one filter, return
@@ -180,7 +181,7 @@ class PackageKitYumBackend(PackageKitBas
filelist = pkg.filelist
for fn in filelist:
if key in fn and not found.has_key(str(pkg)):
- self._show_package(pkg, INFO_INSTALLED)
+ self._show_package(pkg, INFO_AVAILABLE)
found[str(pkg)] = 1
@@ -369,7 +370,7 @@ class PackageKitYumBackend(PackageKitBas
if txmbr:
self._runYumTransaction()
else:
- self.error(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
+ self.erhror(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
else:
self.error(ERROR_PACKAGE_NOT_INSTALLED,"Package is not installed")
@@ -547,9 +548,9 @@ class PackageKitCallback(RPMBaseCallback
pct = int(self.startPct + (ts_current * bump))
return pct
- def _showName(self):
+ def _showName(self,status):
id = self.base.get_package_id(self.curpkg, '', '', '')
- self.base.package(id,1, "")
+ self.base.package(id,status, "")
def event(self, package, action, te_current, te_total, ts_current, ts_total):
@@ -557,9 +558,11 @@ class PackageKitCallback(RPMBaseCallback
self.curpkg = str(package)
if action in TS_INSTALL_STATES:
self.base.status(STATE_INSTALL)
+ status = INFO_INSTALLING
elif action in TS_REMOVE_STATES:
self.base.status(STATE_REMOVE)
- self._showName()
+ status = INFO_REMOVING
+ self._showName(status)
pct = self._calcTotalPct(ts_current, ts_total)
self.base.percentage(pct)
val = (ts_current*100L)/ts_total
diff-tree 8c68baf551711fd1364dcbb103d324dbdbc5b50c (from 06a542953df0d9aedfa3916695c8308b257f3b44)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Oct 1 07:54:01 2007 +0100
try to convert the yum backend to the new enums
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 07d4181..918543a 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -65,9 +65,9 @@ class PackageKitYumBackend(PackageKitBas
count+=1
# are we installed?
if self.yumbase.rpmdb.installed(pkg.name):
- installed = '1'
+ installed = INFO_INSTALLED
else:
- installed = '0'
+ installed = INFO_AVAILABLE
if self._do_filtering(pkg,fltlist,installed):
self._show_package(pkg, installed)
@@ -171,7 +171,7 @@ class PackageKitYumBackend(PackageKitBas
filelist = pkg.filelist
for fn in filelist:
if key in fn and not found.has_key(str(pkg)):
- self._show_package(pkg, 1)
+ self._show_package(pkg, INFO_INSTALLED)
found[str(pkg)] = 1
if not 'installed' in fltlist:
# Check available for file
@@ -180,7 +180,7 @@ class PackageKitYumBackend(PackageKitBas
filelist = pkg.filelist
for fn in filelist:
if key in fn and not found.has_key(str(pkg)):
- self._show_package(pkg, 1)
+ self._show_package(pkg, INFO_INSTALLED)
found[str(pkg)] = 1
diff-tree 06a542953df0d9aedfa3916695c8308b257f3b44 (from 26e0cf450a7b8fdbe6802022d04ae37d27eb3918)
Author: Ken VanDine <ken at vandine.org>
Date: Sun Sep 30 22:24:30 2007 -0400
Removed the live search
diff --git a/backends/conary/helpers/search-name-live.py b/backends/conary/helpers/search-name-live.py
deleted file mode 100755
index 2abc674..0000000
--- a/backends/conary/helpers/search-name-live.py
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/python
-#
-# Copyright (C) 2007 Ken VanDine <ken at vandine.org>
-#
-# 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.
-
-import sys
-
-options = sys.argv[1]
-searchlist = sys.argv[2]
-
-from conaryBackend import PackageKitConaryBackend
-
-backend = PackageKitConaryBackend(sys.argv[1:])
-backend.search_name_live(options,searchlist)
-sys.exit(0)
diff-tree 26e0cf450a7b8fdbe6802022d04ae37d27eb3918 (from 85f5ac2e220732a0f146d02a6477a2a3a0c4a4a9)
Author: Ken VanDine <ken at vandine.org>
Date: Sun Sep 30 22:22:32 2007 -0400
Updated to return INFO_INSTALLED and INFO_AVAILABLE
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 15cd9fe..b71771e 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -174,9 +174,9 @@ class PackageKitConaryBackend(PackageKit
try:
troveTuple = troveTuple[0], troveTuple[1], troveTuple[2]
localInstall = db.findTrove(None, troveTuple)
- installed = 1
+ installed = INFO_INSTALLED
except:
- installed = 0
+ installed = INFO_AVAILABLE
return installed
def search_name(self, options, searchlist):
diff-tree 85f5ac2e220732a0f146d02a6477a2a3a0c4a4a9 (from c35564d8ee4355b8ae28419c768dc4837aaae6b8)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 23:00:48 2007 +0100
add the data to the transaction signal so we can get what was added or removed
diff --git a/TODO b/TODO
index 8ccc634..3f4b12c 100644
--- a/TODO
+++ b/TODO
@@ -19,13 +19,6 @@ Refresh the query list after an install
*** Prepare download to refresh system ***
Either use a flag or a new method. I'm not sure which yet.
-*** cache signal responses from methods ***
-Need to cache packages in the daemon. yes the daemon.
-We need this for transaction logging of what was removed or added.
-Need to convert the gptrarray to a Gstring
-installed,moo;1.23.;i386;fedora,removed,foo;1.23.;i386;fedora and save
-to database
-
*** Add a way to import GPG keys ***
In fedora, if you add a signed repo you have to agree to the GPG key.
diff --git a/client/pk-console.c b/client/pk-console.c
index e9b150e..df2b7c7 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -101,7 +101,8 @@ pk_console_package_cb (PkClient *client,
**/
static void
pk_console_transaction_cb (PkClient *client, const gchar *tid, const gchar *timespec,
- gboolean succeeded, PkRoleEnum role, guint duration, gpointer data)
+ gboolean succeeded, PkRoleEnum role, guint duration,
+ const gchar *data, gpointer user_data)
{
const gchar *role_text;
role_text = pk_role_enum_to_text (role);
@@ -110,6 +111,7 @@ pk_console_transaction_cb (PkClient *cli
g_print (" succeeded : %i\n", succeeded);
g_print (" role : %s\n", role_text);
g_print (" duration : %i (seconds)\n", duration);
+ g_print (" data : %s\n", data);
}
/**
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index d9887ab..9488d5d 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -377,7 +377,7 @@ static void
pk_client_transaction_cb (DBusGProxy *proxy,
const gchar *tid, const gchar *old_tid, const gchar *timespec,
gboolean succeeded, const gchar *role_text, guint duration,
- PkClient *client)
+ const gchar *data, PkClient *client)
{
PkRoleEnum role;
g_return_if_fail (client != NULL);
@@ -385,8 +385,8 @@ pk_client_transaction_cb (DBusGProxy *pr
if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
role = pk_role_enum_from_text (role_text);
- pk_debug ("emitting transaction %s, %s, %i, %s, %i", old_tid, timespec, succeeded, role_text, duration);
- g_signal_emit (client, signals [PK_CLIENT_TRANSACTION], 0, tid, timespec, succeeded, role, duration);
+ pk_debug ("emitting transaction %s, %s, %i, %s, %i, %s", old_tid, timespec, succeeded, role_text, duration, data);
+ g_signal_emit (client, signals [PK_CLIENT_TRANSACTION], 0, tid, timespec, succeeded, role, duration, data);
}
}
@@ -1702,8 +1702,9 @@ pk_client_class_init (PkClientClass *kla
signals [PK_CLIENT_TRANSACTION] =
g_signal_new ("transaction",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_BOOL_UINT_UINT,
- G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_UINT, G_TYPE_UINT);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_BOOL_UINT_UINT_STRING,
+ G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_BOOLEAN, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING);
signals [PK_CLIENT_UPDATE_DETAIL] =
g_signal_new ("update-detail",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
@@ -1822,9 +1823,9 @@ pk_client_init (PkClient *client)
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
/* transaction */
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_BOOL_STRING_UINT,
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_BOOL_STRING_UINT_STRING,
G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN,
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_add_signal (proxy, "Finished",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
@@ -1858,7 +1859,7 @@ pk_client_init (PkClient *client)
dbus_g_proxy_add_signal (proxy, "Transaction",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "Transaction",
G_CALLBACK (pk_client_transaction_cb), client, NULL);
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 2ad1297..7faf3a7 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1849,15 +1849,16 @@ pk_engine_get_filters (PkEngine *engine,
**/
static void
pk_engine_transaction_cb (PkTransactionDb *tdb, const gchar *old_tid, const gchar *timespec,
- gboolean succeeded, PkRoleEnum role, guint duration, PkEngine *engine)
+ gboolean succeeded, PkRoleEnum role, guint duration,
+ const gchar *data, PkEngine *engine)
{
const gchar *role_text;
const gchar *tid;
tid = engine->priv->sync_item->tid;
role_text = pk_role_enum_to_text (role);
- pk_debug ("emitting transaction %s, %s, %s, %i, %s, %i", tid, old_tid, timespec, succeeded, role_text, duration);
- g_signal_emit (engine, signals [PK_ENGINE_TRANSACTION], 0, tid, old_tid, timespec, succeeded, role_text, duration);
+ pk_debug ("emitting transaction %s, %s, %s, %i, %s, %i, %s", tid, old_tid, timespec, succeeded, role_text, duration, data);
+ g_signal_emit (engine, signals [PK_ENGINE_TRANSACTION], 0, tid, old_tid, timespec, succeeded, role_text, duration, data);
}
/**
@@ -1968,9 +1969,9 @@ pk_engine_class_init (PkEngineClass *kla
signals [PK_ENGINE_TRANSACTION] =
g_signal_new ("transaction",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_BOOL_STRING_UINT,
- G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_BOOL_STRING_UINT_STRING,
+ G_TYPE_NONE, 7, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (PkEnginePrivate));
}
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index e690be3..fa6b524 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -193,6 +193,7 @@
<arg type="b" name="succeeded" direction="out"/>
<arg type="s" name="role" direction="out"/>
<arg type="u" name="duration" direction="out"/>
+ <arg type="s" name="data" direction="out"/>
</signal>
<!-- General methods -->
diff --git a/src/pk-marshal.list b/src/pk-marshal.list
index e14b4a8..6713374 100644
--- a/src/pk-marshal.list
+++ b/src/pk-marshal.list
@@ -16,6 +16,6 @@ VOID:STRING,STRING,STRING,STRING,STRING,
VOID:STRING,STRING,UINT,STRING,STRING
VOID:STRING,UINT,STRING,STRING
VOID:STRING,STRING,UINT,UINT,UINT
-VOID:STRING,STRING,BOOL,UINT,UINT
-VOID:STRING,STRING,STRING,BOOL,STRING,UINT
+VOID:STRING,STRING,BOOL,UINT,UINT,STRING
+VOID:STRING,STRING,STRING,BOOL,STRING,UINT,STRING
diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c
index 542a602..69c1b95 100644
--- a/src/pk-transaction-db.c
+++ b/src/pk-transaction-db.c
@@ -153,7 +153,8 @@ pk_transaction_sqlite_callback (void *da
/* emit signal */
g_signal_emit (tdb, signals [PK_TRANSACTION_DB_TRANSACTION], 0,
- item.tid, item.timespec, item.succeeded, item.role, item.duration);
+ item.tid, item.timespec, item.succeeded, item.role,
+ item.duration, item.data);
pk_transaction_db_item_free (&item);
return 0;
@@ -313,8 +314,9 @@ pk_transaction_db_class_init (PkTransact
signals [PK_TRANSACTION_DB_TRANSACTION] =
g_signal_new ("transaction",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_BOOL_UINT_UINT,
- G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_UINT, G_TYPE_UINT);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_BOOL_UINT_UINT_STRING,
+ G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_BOOLEAN, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING);
g_type_class_add_private (klass, sizeof (PkTransactionDbPrivate));
}
diff-tree c35564d8ee4355b8ae28419c768dc4837aaae6b8 (from 3b2fbecc640bb4da62d50bdeb36bad1d1382ab44)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 22:31:29 2007 +0100
cache the packages as they are emitted in a text string
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index b7f7c5e..9f31248 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -170,7 +170,16 @@ backend_install_timeout (gpointer data)
pk_backend_finished (backend);
return FALSE;
}
+ if (progress_percentage == 30) {
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLING,
+ "gtkhtml2;2.19.1-4.fc8;i386;fedora",
+ "An HTML widget for GTK+ 2.0");
+ pk_backend_change_status (backend, PK_STATUS_ENUM_INSTALL);
+ }
if (progress_percentage == 50) {
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLING,
+ "gtkhtml2-devel;2.19.1-0.fc8;i386;fedora",
+ "Devel files for gtkhtml");
pk_backend_change_status (backend, PK_STATUS_ENUM_INSTALL);
}
progress_percentage += 10;
@@ -186,6 +195,9 @@ backend_install_package (PkBackend *back
{
g_return_if_fail (backend != NULL);
progress_percentage = 0;
+ pk_backend_package (backend, PK_INFO_ENUM_DOWNLOADING,
+ "gtkhtml2;2.19.1-4.fc8;i386;fedora",
+ "An HTML widget for GTK+ 2.0");
g_timeout_add (1000, backend_install_timeout, backend);
}
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 9c7a74e..2ad1297 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -267,6 +267,7 @@ pk_engine_package_cb (PkBackend *backend
{
PkTransactionItem *item;
const gchar *info_text;
+ gchar *cache;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
@@ -277,6 +278,13 @@ pk_engine_package_cb (PkBackend *backend
return;
}
info_text = pk_info_enum_to_text (info);
+
+ /* add to package cache */
+ cache = g_strdup_printf ("%s\t%s\t%s\n", info_text, package_id, summary);
+ pk_debug ("cache='%s'", cache);
+ g_string_append (item->package_cache, cache);
+ g_free (cache);
+
pk_debug ("emitting package tid:%s info=%s %s, %s", item->tid, info_text, package_id, summary);
g_signal_emit (engine, signals [PK_ENGINE_PACKAGE], 0, item->tid, info_text, package_id, summary);
pk_engine_reset_timer (engine);
@@ -422,6 +430,12 @@ pk_engine_finished_cb (PkBackend *backen
/* find the length of time we have been running */
time = pk_backend_get_runtime (backend);
+ /* add to the database */
+ if (item->package_cache->len != 0) {
+ g_string_set_size (item->package_cache, item->package_cache->len-1);
+ pk_transaction_db_set_data (engine->priv->transaction_db, item->tid, item->package_cache->str);
+ }
+
pk_debug ("backend was running for %f seconds", time);
pk_transaction_db_set_finished (engine->priv->transaction_db, item->tid, TRUE, time);
diff --git a/src/pk-transaction-db.c b/src/pk-transaction-db.c
index 1f9bead..542a602 100644
--- a/src/pk-transaction-db.c
+++ b/src/pk-transaction-db.c
@@ -66,6 +66,7 @@ typedef struct {
guint duration;
PkRoleEnum role;
gchar *tid;
+ gchar *data;
gchar *timespec;
} PkTransactionDbItem;
@@ -79,6 +80,7 @@ pk_transaction_db_item_clear (PkTransact
item->duration = 0;
item->role = PK_ROLE_ENUM_UNKNOWN;
item->tid = NULL;
+ item->data = NULL;
item->timespec = NULL;
return TRUE;
}
@@ -90,6 +92,7 @@ static gboolean
pk_transaction_db_item_free (PkTransactionDbItem *item)
{
g_free (item->tid);
+ g_free (item->data);
g_free (item->timespec);
return TRUE;
}
@@ -128,6 +131,10 @@ pk_transaction_sqlite_callback (void *da
if (value != NULL) {
item.timespec = g_strdup (value);
}
+ } else if (strcmp (col, "data") == 0) {
+ if (value != NULL) {
+ item.data = g_strdup (value);
+ }
} else if (strcmp (col, "duration") == 0) {
if (value != NULL) {
item.duration = atoi (value);
@@ -142,6 +149,7 @@ pk_transaction_sqlite_callback (void *da
g_print (" succeeded : %i\n", item.succeeded);
g_print (" role : %s\n", pk_role_enum_to_text (item.role));
g_print (" duration : %i (seconds)\n", item.duration);
+ g_print (" data : %s\n", item.data);
/* emit signal */
g_signal_emit (tdb, signals [PK_TRANSACTION_DB_TRANSACTION], 0,
@@ -184,7 +192,7 @@ pk_transaction_db_get_list (PkTransactio
g_return_val_if_fail (tdb != NULL, FALSE);
g_return_val_if_fail (PK_IS_TRANSACTION_DB (tdb), FALSE);
- statement = g_strdup_printf ("SELECT transaction_id, timespec, succeeded, duration, role "
+ statement = g_strdup_printf ("SELECT transaction_id, timespec, succeeded, duration, role, data "
"FROM transactions ORDER BY transaction_id DESC LIMIT %i", limit);
pk_transaction_db_sql_statement (tdb, statement);
g_free (statement);
@@ -241,6 +249,24 @@ pk_transaction_db_set_role (PkTransactio
}
/**
+ * pk_transaction_db_set_data:
+ **/
+gboolean
+pk_transaction_db_set_data (PkTransactionDb *tdb, const gchar *tid, const gchar *data)
+{
+ gchar *statement;
+
+ g_return_val_if_fail (tdb != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_TRANSACTION_DB (tdb), FALSE);
+
+ statement = g_strdup_printf ("UPDATE transactions SET data = \"%s\" WHERE transaction_id = '%s'",
+ data, tid);
+ pk_transaction_db_sql_statement (tdb, statement);
+ g_free (statement);
+ return TRUE;
+}
+
+/**
* pk_transaction_db_set_finished:
**/
gboolean
@@ -316,6 +342,8 @@ pk_transaction_db_init (PkTransactionDb
/* add extra tables */
statement = "ALTER table transactions ADD timespec TEXT;";
sqlite3_exec (tdb->priv->db, statement, NULL, 0, NULL);
+ statement = "ALTER table transactions ADD data TEXT;";
+ sqlite3_exec (tdb->priv->db, statement, NULL, 0, NULL);
}
/**
diff --git a/src/pk-transaction-db.h b/src/pk-transaction-db.h
index c1fcb26..856829f 100644
--- a/src/pk-transaction-db.h
+++ b/src/pk-transaction-db.h
@@ -59,6 +59,9 @@ gboolean pk_transaction_db_set_finished
const gchar *tid,
gboolean success,
guint runtime);
+gboolean pk_transaction_db_set_data (PkTransactionDb *tdb,
+ const gchar *tid,
+ const gchar *data);
gboolean pk_transaction_db_get_list (PkTransactionDb *tdb,
guint limit);
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 318468d..44b86e8 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -104,6 +104,7 @@ pk_transaction_list_create (PkTransactio
item->committed = FALSE;
item->running = FALSE;
item->backend = NULL;
+ item->package_cache = g_string_new ("");
item->tid = pk_transaction_id_generate ();
g_ptr_array_add (tlist->priv->array, item);
return item;
@@ -121,6 +122,7 @@ pk_transaction_list_remove (PkTransactio
/* valid item */
g_ptr_array_remove (tlist->priv->array, item);
g_free (item->tid);
+ g_string_free (item->package_cache, TRUE);
g_free (item);
/* we have changed what is running */
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index ba7c6bf..818f815 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -54,6 +54,7 @@ typedef struct {
gboolean running;
PkBackend *backend;
gchar *tid;
+ GString *package_cache;
} PkTransactionItem;
GType pk_transaction_list_get_type (void);
diff-tree 3b2fbecc640bb4da62d50bdeb36bad1d1382ab44 (from 38177b00969884d619fac3136860d87a32d4e6b2)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 22:29:19 2007 +0100
don't segfault on package
diff --git a/client/pk-console.c b/client/pk-console.c
index f510544..e9b150e 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -43,8 +43,10 @@ pk_console_make_space (const gchar *data
{
gint size;
gchar *padding;
- *extra = 0;
+ if (extra != NULL) {
+ *extra = 0;
+ }
size = length;
if (data != NULL) {
size = (length - strlen(data));
diff-tree 38177b00969884d619fac3136860d87a32d4e6b2 (from f34485199c05ffd607e9a4e3a41b3873c6c802a9)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 21:26:43 2007 +0100
update TODO
diff --git a/TODO b/TODO
index 283c5f8..8ccc634 100644
--- a/TODO
+++ b/TODO
@@ -5,11 +5,6 @@ Do automatic updates at login time when
* needs gnome-screensaver integration
NOTE: RELEASE BLOCKER
-*** installed, available checkboxes to go comboboxes ***
-Show: [Installed packages, Available packages, All packages]
-Type Filter: [Only graphical packages, Only text packages, All packages]
-Development Filter: [Only normal packages, Only development packages, All packages]
-
*** Add new callback for status ***
TimeRemaining()
diff-tree f34485199c05ffd607e9a4e3a41b3873c6c802a9 (from f5b0c17b15205058c93d437a8ecf1b5a42f268ba)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 17:10:42 2007 +0100
add client side support for InstallFile
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index c9c98f0..d9887ab 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -1402,7 +1402,73 @@ pk_client_install_package (PkClient *cli
}
}
- /* only wait if the command succeeded. False is usually due to PolicyKit auth failure */
+ return ret;
+}
+
+/**
+ * pk_client_install_file_action:
+ **/
+gboolean
+pk_client_install_file_action (PkClient *client, const gchar *file, GError **error)
+{
+ gboolean ret;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ *error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "InstallFile", error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_STRING, file,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("InstallFile failed!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_install_file:
+ **/
+gboolean
+pk_client_install_file (PkClient *client, const gchar *file)
+{
+ gboolean ret;
+ GError *error;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ /* check to see if we already have a transaction */
+ ret = pk_client_allocate_transaction_id (client);
+ if (ret == FALSE) {
+ pk_warning ("Failed to get transaction ID");
+ return FALSE;
+ }
+
+ /* hopefully do the operation first time */
+ ret = pk_client_install_file_action (client, file, &error);
+
+ /* we were refused by policy then try to get auth */
+ if (ret == FALSE) {
+ if (pk_polkit_client_error_denied_by_policy (error) == TRUE) {
+ /* retry the action if we succeeded */
+ if (pk_polkit_client_gain_privilege_str (client->priv->polkit, error->message) == TRUE) {
+ pk_debug ("gained priv");
+ g_error_free (error);
+ /* do it all over again */
+ ret = pk_client_install_file_action (client, file, &error);
+ }
+ }
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ }
+
return ret;
}
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index b778876..6b6d7fb 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -112,6 +112,8 @@ gboolean pk_client_refresh_cache (PkCl
gboolean force);
gboolean pk_client_install_package (PkClient *client,
const gchar *package_id);
+gboolean pk_client_install_file (PkClient *client,
+ const gchar *full_path);
gboolean pk_client_resolve (PkClient *client,
const gchar *package);
gboolean pk_client_cancel (PkClient *client);
diff-tree f5b0c17b15205058c93d437a8ecf1b5a42f268ba (from edffdf452ca4ff8b0eb9b1025c85f2229497b764)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 16:44:45 2007 +0100
add the resolve method into the client helper
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index d183836..c9c98f0 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -984,7 +984,6 @@ pk_client_search_group (PkClient *client
pk_warning ("SearchGroup failed!");
return FALSE;
}
- /* only assign on success */
return TRUE;
}
@@ -1026,7 +1025,6 @@ pk_client_search_file (PkClient *client,
pk_warning ("SearchFile failed!");
return FALSE;
}
- /* only assign on success */
return TRUE;
}
@@ -1067,7 +1065,6 @@ pk_client_get_depends (PkClient *client,
pk_warning ("GetDepends failed!");
return FALSE;
}
- /* only assign on success */
return TRUE;
}
@@ -1108,7 +1105,6 @@ pk_client_get_requires (PkClient *client
pk_warning ("GetRequires failed!");
return FALSE;
}
- /* only assign on success */
return TRUE;
}
@@ -1149,7 +1145,46 @@ pk_client_get_update_detail (PkClient *c
pk_warning ("GetUpdateDetail failed!");
return FALSE;
}
- /* only assign on success */
+
+ return TRUE;
+}
+
+/**
+ * pk_client_resolve:
+ **/
+gboolean
+pk_client_resolve (PkClient *client, const gchar *package)
+{
+ gboolean ret;
+ GError *error;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ /* check to see if we already have a transaction */
+ ret = pk_client_allocate_transaction_id (client);
+ if (ret == FALSE) {
+ pk_warning ("Failed to get transaction ID");
+ return FALSE;
+ }
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "Resolve", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_STRING, package,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (error != NULL) {
+ const gchar *error_name;
+ error_name = pk_client_get_error_name (error);
+ pk_debug ("ERROR: %s: %s", error_name, error->message);
+ g_error_free (error);
+ }
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("Resolve failed!");
+ return FALSE;
+ }
return TRUE;
}
@@ -1190,7 +1225,6 @@ pk_client_get_description (PkClient *cli
pk_warning ("GetDescription failed!");
return FALSE;
}
- /* only assign on success */
return TRUE;
}
@@ -1300,7 +1334,6 @@ pk_client_refresh_cache (PkClient *clien
pk_warning ("RefreshCache failed!");
return FALSE;
}
- /* only assign on success */
return TRUE;
}
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index 4bd4125..b778876 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -112,6 +112,8 @@ gboolean pk_client_refresh_cache (PkCl
gboolean force);
gboolean pk_client_install_package (PkClient *client,
const gchar *package_id);
+gboolean pk_client_resolve (PkClient *client,
+ const gchar *package);
gboolean pk_client_cancel (PkClient *client);
/* cached stuff */
diff-tree edffdf452ca4ff8b0eb9b1025c85f2229497b764 (from 7cdf92448e6f4c62d0ea79c247f4a0310c72f170)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 16:16:11 2007 +0100
allow backends to emit updates-changed
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index 9f1d96d..b7f7c5e 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -311,6 +311,7 @@ backend_update_package (PkBackend *backe
{
g_return_if_fail (backend != NULL);
pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, "The same thing");
+ pk_backend_updates_changed (backend);
pk_backend_finished (backend);
}
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 00feda1..7cdeba2 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -90,6 +90,7 @@ enum {
PK_BACKEND_PACKAGE,
PK_BACKEND_UPDATE_DETAIL,
PK_BACKEND_ERROR_CODE,
+ PK_BACKEND_UPDATES_CHANGED,
PK_BACKEND_REQUIRE_RESTART,
PK_BACKEND_FINISHED,
PK_BACKEND_ALLOW_INTERRUPT,
@@ -739,6 +740,20 @@ pk_backend_description (PkBackend *backe
}
/**
+ * pk_backend_updates_changed:
+ **/
+gboolean
+pk_backend_updates_changed (PkBackend *backend)
+{
+ g_return_val_if_fail (backend != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
+
+ pk_debug ("emit updates-changed");
+ g_signal_emit (backend, signals [PK_BACKEND_UPDATES_CHANGED], 0);
+ return TRUE;
+}
+
+/**
* pk_backend_error_code:
**/
gboolean
@@ -1471,6 +1486,11 @@ pk_backend_class_init (PkBackendClass *k
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, pk_marshal_VOID__UINT_STRING,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_STRING);
+ signals [PK_BACKEND_UPDATES_CHANGED] =
+ g_signal_new ("updates-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
signals [PK_BACKEND_FINISHED] =
g_signal_new ("finished",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 933c287..d9be55f 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -65,6 +65,7 @@ gboolean pk_backend_description (PkBa
gboolean pk_backend_error_code (PkBackend *backend,
guint code,
const gchar *details, ...);
+gboolean pk_backend_updates_changed (PkBackend *backend);
gboolean pk_backend_spawn_helper (PkBackend *backend,
const gchar *script, ...);
gboolean pk_backend_spawn_kill (PkBackend *backend);
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 76e4ea6..9c7a74e 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -309,6 +309,26 @@ pk_engine_update_detail_cb (PkBackend *b
}
/**
+ * pk_engine_updates_changed_cb:
+ **/
+static void
+pk_engine_updates_changed_cb (PkBackend *backend, PkEngine *engine)
+{
+ PkTransactionItem *item;
+
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
+
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
+ if (item == NULL) {
+ pk_warning ("could not find backend");
+ return;
+ }
+ pk_debug ("emitting updates-changed tid:%s", item->tid);
+ g_signal_emit (engine, signals [PK_ENGINE_UPDATES_CHANGED], 0, item->tid);
+}
+
+/**
* pk_engine_error_code_cb:
**/
static void
@@ -478,6 +498,8 @@ pk_engine_new_backend (PkEngine *engine)
G_CALLBACK (pk_engine_update_detail_cb), engine);
g_signal_connect (backend, "error-code",
G_CALLBACK (pk_engine_error_code_cb), engine);
+ g_signal_connect (backend, "updates-changed",
+ G_CALLBACK (pk_engine_updates_changed_cb), engine);
g_signal_connect (backend, "require-restart",
G_CALLBACK (pk_engine_require_restart_cb), engine);
g_signal_connect (backend, "finished",
diff-tree 7cdf92448e6f4c62d0ea79c247f4a0310c72f170 (from 50f55e02c2bd35a39b5425f08eec2e5d94223606)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 16:01:15 2007 +0100
add the UpdatesChanged signal to signal the client update watcher(s) to refresh
diff --git a/TODO b/TODO
index 8690c8f..283c5f8 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,5 @@
Order of no particular importance:
-*** Have to have an UpdatesChanged signal ***
-For the icon to update after we've done a system upgrade
-NOTE: RELEASE BLOCKER
-
*** pk-notify-icon (client) ***
Do automatic updates at login time when system has gone idle
* needs gnome-screensaver integration
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index ab24fad..d183836 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -67,6 +67,7 @@ typedef enum {
PK_CLIENT_NO_PERCENTAGE_UPDATES,
PK_CLIENT_PACKAGE,
PK_CLIENT_PERCENTAGE_CHANGED,
+ PK_CLIENT_UPDATES_CHANGED,
PK_CLIENT_REQUIRE_RESTART,
PK_CLIENT_SUB_PERCENTAGE_CHANGED,
PK_CLIENT_TRANSACTION,
@@ -355,6 +356,21 @@ pk_client_package_cb (DBusGProxy *prox
}
/**
+ * pk_client_updates_changed_cb:
+ */
+static void
+pk_client_updates_changed_cb (DBusGProxy *proxy, const gchar *tid, PkClient *client)
+{
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (PK_IS_CLIENT (client));
+
+ /* we always emit, even if the tid does not match */
+ pk_debug ("emitting updates-changed");
+ g_signal_emit (client, signals [PK_CLIENT_UPDATES_CHANGED], 0);
+
+}
+
+/**
* pk_client_transaction_cb:
*/
static void
@@ -1559,6 +1575,11 @@ pk_client_class_init (PkClientClass *kla
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, g_cclosure_marshal_VOID__UINT,
G_TYPE_NONE, 1, G_TYPE_UINT);
+ signals [PK_CLIENT_UPDATES_CHANGED] =
+ g_signal_new ("updates-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
signals [PK_CLIENT_PERCENTAGE_CHANGED] =
g_signal_new ("percentage-changed",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
@@ -1742,6 +1763,11 @@ pk_client_init (PkClient *client)
dbus_g_proxy_connect_signal (proxy, "Transaction",
G_CALLBACK (pk_client_transaction_cb), client, NULL);
+ dbus_g_proxy_add_signal (proxy, "UpdatesChanged",
+ G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "UpdatesChanged",
+ G_CALLBACK (pk_client_updates_changed_cb), client, NULL);
+
dbus_g_proxy_add_signal (proxy, "UpdateDetail",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
@@ -1788,6 +1814,8 @@ pk_client_finalize (GObject *object)
G_CALLBACK (pk_client_no_percentage_updates_cb), client);
dbus_g_proxy_disconnect_signal (client->priv->proxy, "TransactionStatusChanged",
G_CALLBACK (pk_client_transaction_status_changed_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "UpdatesChanged",
+ G_CALLBACK (pk_client_updates_changed_cb), client);
dbus_g_proxy_disconnect_signal (client->priv->proxy, "Package",
G_CALLBACK (pk_client_package_cb), client);
dbus_g_proxy_disconnect_signal (client->priv->proxy, "Transaction",
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 29b21f8..76e4ea6 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -77,6 +77,7 @@ enum {
PK_ENGINE_TRANSACTION,
PK_ENGINE_ERROR_CODE,
PK_ENGINE_REQUIRE_RESTART,
+ PK_ENGINE_UPDATES_CHANGED,
PK_ENGINE_FINISHED,
PK_ENGINE_UPDATE_DETAIL,
PK_ENGINE_DESCRIPTION,
@@ -348,7 +349,7 @@ pk_engine_require_restart_cb (PkBackend
return;
}
restart_text = pk_restart_enum_to_text (restart);
- pk_debug ("emitting error-code tid:%s %s, '%s'", item->tid, restart_text, details);
+ pk_debug ("emitting require-restart tid:%s %s, '%s'", item->tid, restart_text, details);
g_signal_emit (engine, signals [PK_ENGINE_REQUIRE_RESTART], 0, item->tid, restart_text, details);
pk_engine_reset_timer (engine);
}
@@ -384,6 +385,7 @@ static void
pk_engine_finished_cb (PkBackend *backend, PkExitEnum exit, PkEngine *engine)
{
PkTransactionItem *item;
+ PkRoleEnum role;
const gchar *exit_text;
gdouble time;
@@ -403,6 +405,14 @@ pk_engine_finished_cb (PkBackend *backen
pk_debug ("backend was running for %f seconds", time);
pk_transaction_db_set_finished (engine->priv->transaction_db, item->tid, TRUE, time);
+ /* could the update list have changed? */
+ pk_backend_get_role (item->backend, &role, NULL);
+ if (role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
+ role == PK_ROLE_ENUM_UPDATE_PACKAGE) {
+ pk_debug ("emitting updates-changed tid:%s", item->tid);
+ g_signal_emit (engine, signals [PK_ENGINE_UPDATES_CHANGED], 0, item->tid);
+ }
+
pk_debug ("emitting finished transaction:%s, '%s', %i", item->tid, exit_text, (guint) time);
g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, exit_text, (guint) time);
@@ -1892,6 +1902,11 @@ pk_engine_class_init (PkEngineClass *kla
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING,
G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ signals [PK_ENGINE_UPDATES_CHANGED] =
+ g_signal_new ("updates-changed",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, pk_marshal_VOID__STRING,
+ G_TYPE_NONE, 1, G_TYPE_STRING);
signals [PK_ENGINE_DESCRIPTION] =
g_signal_new ("description",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index abd3c35..e690be3 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -137,6 +137,9 @@
<arg type="s" name="type" direction="out"/> <!-- system,application,session -->
<arg type="s" name="details" direction="out"/> <!-- non-localized detail -->
</signal>
+ <signal name="UpdatesChanged">
+ <arg type="s" name="tid" direction="out"/>
+ </signal>
<!-- Do things or query transactions -->
<method name="Cancel"> <!-- might not succeed for all manner or reasons -->
diff --git a/src/pk-marshal.list b/src/pk-marshal.list
index 53ea3cd..e14b4a8 100644
--- a/src/pk-marshal.list
+++ b/src/pk-marshal.list
@@ -2,6 +2,7 @@ VOID:UINT,STRING,STRING
VOID:UINT,STRING
VOID:UINT,STRING,UINT
VOID:UINT,UINT
+VOID:STRING
VOID:STRING,BOOL
VOID:STRING,UINT
VOID:STRING,STRING,UINT
diff-tree 50f55e02c2bd35a39b5425f08eec2e5d94223606 (from 70295a6e0b0859d39510ab9e33086642dc528d91)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 15:25:12 2007 +0100
switch the Package signal to use enumerated types rather than magic numbers
diff --git a/TODO b/TODO
index 4b70639..8690c8f 100644
--- a/TODO
+++ b/TODO
@@ -4,12 +4,6 @@ Order of no particular importance:
For the icon to update after we've done a system upgrade
NOTE: RELEASE BLOCKER
-*** convert the magic number in Package to a string type ***
-Define Package to be (s,s) not (i,s) where the first status is
-"installed, removed, updated, security, normal, etc"
-Need to convert to enumerated types early on, and in the client library
-NOTE: RELEASE BLOCKER
-
*** pk-notify-icon (client) ***
Do automatic updates at login time when system has gone idle
* needs gnome-screensaver integration
diff --git a/backends/alpm/pk-backend-alpm.c b/backends/alpm/pk-backend-alpm.c
index 268380b..f3ad228 100644
--- a/backends/alpm/pk-backend-alpm.c
+++ b/backends/alpm/pk-backend-alpm.c
@@ -192,6 +192,7 @@ list_cmp_fn (const void *n1, const void
static void
add_package (PkBackend *backend, PackageSource *package)
{
+ PkInfoEnum info;
gchar *pkg_string;
gchar *arch = (gchar *)alpm_pkg_get_arch (package->pkg);
@@ -201,8 +202,11 @@ add_package (PkBackend *backend, Package
alpm_pkg_get_version (package->pkg),
arch,
package->repo);
-
- pk_backend_package (backend, package->installed, pkg_string, alpm_pkg_get_desc (package->pkg));
+ if (package->installed)
+ info = PK_INFO_ENUM_INSTALLED;
+ else
+ info = PK_INFO_ENUM_AVAILABLE;
+ pk_backend_package (backend, info, pkg_string, alpm_pkg_get_desc (package->pkg));
g_free(pkg_string);
}
@@ -374,61 +378,6 @@ backend_initialize (PkBackend *backend)
}
/**
- * backend_get_depends:
- */
-static void
-backend_get_depends (PkBackend *backend, const gchar *package_id)
-{
- g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 1, "glib2;2.14.0;i386;fedora",
- "The GLib library");
- pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
- "GTK+ Libraries for GIMP");
- pk_backend_finished (backend);
-}
-
-/**
- * backend_get_description:
- */
-static void
-backend_get_description (PkBackend *backend, const gchar *package_id)
-{
- g_return_if_fail (backend != NULL);
- //PkPackageId *id = pk_package_id_new_from_string (package_id);
- //pk_backend_description (backend, package_id, "unknown", PK_GROUP_ENUM_PROGRAMMING, "sdgd");
- pk_backend_finished (backend);
-}
-
-/**
- * backend_get_requires:
- */
-static void
-backend_get_requires (PkBackend *backend, const gchar *package_id)
-{
- g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 1, "glib2;2.14.0;i386;fedora",
- "The GLib library");
- pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
- "GTK+ Libraries for GIMP");
- pk_backend_finished (backend);
-}
-
-/**
- * backend_get_updates:
- */
-static void
-backend_get_updates (PkBackend *backend)
-{
- g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 0, "powertop;1.8-1.fc8;i386;fedora",
- "Power consumption monitor");
- pk_backend_package (backend, 1, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
- "The Linux kernel (the core of the Linux operating system)");
- pk_backend_package (backend, 1, "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0");
- pk_backend_finished (backend);
-}
-
-/**
* backend_install_package:
*/
static void
@@ -656,42 +605,6 @@ backend_remove_package (PkBackend *backe
}
/**
- * backend_search_details:
- */
-static void
-backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
- "The vips documentation package.");
- pk_backend_finished (backend);
-}
-
-/**
- * backend_search_file:
- */
-static void
-backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
- "The vips documentation package.");
- pk_backend_finished (backend);
-}
-
-/**
- * backend_search_group:
- */
-static void
-backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
-{
- g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
- "The vips documentation package.");
- pk_backend_finished (backend);
-}
-
-/**
* backend_search_name:
*/
static void
@@ -762,44 +675,6 @@ backend_search_name (PkBackend *backend,
pk_backend_finished (backend);
}
-/**
- * backend_update_package:
- */
-static void
-backend_update_package (PkBackend *backend, const gchar *package_id)
-{
- g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 1, package_id, "The same thing");
- pk_backend_finished (backend);
-}
-
-static gboolean
-backend_update_system_timeout (gpointer data)
-{
- PkBackend *backend = (PkBackend *) data;
- if (progress_percentage == 100) {
- pk_backend_finished (backend);
- return FALSE;
- }
- pk_backend_change_status (backend, PK_STATUS_ENUM_UPDATE);
- progress_percentage += 10;
- pk_backend_change_percentage (backend, progress_percentage);
- return TRUE;
-}
-
-/**
- * backend_update_system:
- */
-static void
-backend_update_system (PkBackend *backend)
-{
- g_return_if_fail (backend != NULL);
- pk_backend_change_status (backend, PK_STATUS_ENUM_DOWNLOAD);
- progress_percentage = 0;
- pk_backend_require_restart (backend, PK_RESTART_ENUM_SYSTEM, NULL);
- g_timeout_add (1000, backend_update_system_timeout, backend);
-}
-
static void
backend_get_groups (PkBackend *backend, PkEnumList *list)
{
@@ -867,21 +742,21 @@ PK_BACKEND_OPTIONS (
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
NULL, /* cancel */
- backend_get_depends, /* get_depends */
- backend_get_description, /* get_description */
- backend_get_requires, /* get_requires */
+ NULL, /* get_depends */
+ NULL, /* get_description */
+ NULL, /* get_requires */
NULL, /* get_update_detail */
- backend_get_updates, /* get_updates */
+ NULL, /* get_updates */
backend_install_package, /* install_package */
backend_install_file, /* install_file */
backend_refresh_cache, /* refresh_cache */
backend_remove_package, /* remove_package */
NULL, /* resolve */
- backend_search_details, /* search_details */
- backend_search_file, /* search_file */
- backend_search_group, /* search_group */
+ NULL, /* search_details */
+ NULL, /* search_file */
+ NULL, /* search_group */
backend_search_name, /* search_name */
- backend_update_package, /* update_package */
- backend_update_system /* update_system */
+ NULL, /* update_package */
+ NULL /* update_system */
);
diff --git a/backends/apt/pk-backend-apt.cpp b/backends/apt/pk-backend-apt.cpp
index e82dd17..6ae221f 100644
--- a/backends/apt/pk-backend-apt.cpp
+++ b/backends/apt/pk-backend-apt.cpp
@@ -439,7 +439,12 @@ static gboolean backend_search_packages_
if (Match == true)// && pk_backend_filter_package_name(backend,P.Name().c_str()))
{
gchar *pid = pk_package_id_build(P.Name().c_str(),J->verstr,J->arch,J->repo);
- pk_backend_package(backend, J->installed, pid, P.ShortDesc().c_str());
+ PkInfoEnum info;
+ if (J->installed)
+ info = PK_INFO_ENUM_INSTALLED;
+ else
+ info = PK_INFO_ENUM_AVAILABLE;
+ pk_backend_package(backend, info, pid, P.ShortDesc().c_str());
g_free(pid);
}
}
diff --git a/backends/box/pk-backend-box.c b/backends/box/pk-backend-box.c
index a935337..35f5434 100644
--- a/backends/box/pk-backend-box.c
+++ b/backends/box/pk-backend-box.c
@@ -76,12 +76,16 @@ add_packages_from_list (PkBackend *backe
PackageSearch *package = NULL;
GList *li = NULL;
gchar *pkg_string = NULL;
+ PkInfoEnum info;
for (li = list; li != NULL; li = li->next) {
package = (PackageSearch*)li->data;
pkg_string = pk_package_id_build(package->package, package->version, package->arch, package->reponame);
-
- pk_backend_package (backend, package->installed, pkg_string, package->description);
+ if (package->installed)
+ info = PK_INFO_ENUM_INSTALLED;
+ else
+ info = PK_INFO_ENUM_AVAILABLE;
+ pk_backend_package (backend, info, pkg_string, package->description);
g_free(pkg_string);
}
diff --git a/backends/dummy/pk-backend-dummy.c b/backends/dummy/pk-backend-dummy.c
index df70d51..9f1d96d 100644
--- a/backends/dummy/pk-backend-dummy.c
+++ b/backends/dummy/pk-backend-dummy.c
@@ -89,10 +89,10 @@ static void
backend_get_depends (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 1, "glib2;2.14.0;i386;fedora",
- "The GLib library");
- pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
- "GTK+ Libraries for GIMP");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "glib2;2.14.0;i386;fedora", "The GLib library");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
pk_backend_finished (backend);
}
@@ -122,10 +122,10 @@ static void
backend_get_requires (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 1, "glib2;2.14.0;i386;fedora",
- "The GLib library");
- pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
- "GTK+ Libraries for GIMP");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "glib2;2.14.0;i386;fedora", "The GLib library");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
pk_backend_finished (backend);
}
@@ -150,11 +150,15 @@ static void
backend_get_updates (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 0, "powertop;1.8-1.fc8;i386;fedora",
- "Power consumption monitor");
- pk_backend_package (backend, 1, "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
- "The Linux kernel (the core of the Linux operating system)");
- pk_backend_package (backend, 1, "gtkhtml2;2.19.1-4.fc8;i386;fedora", "An HTML widget for GTK+ 2.0");
+ pk_backend_package (backend, PK_INFO_ENUM_NORMAL,
+ "powertop;1.8-1.fc8;i386;fedora",
+ "Power consumption monitor");
+ pk_backend_package (backend, PK_INFO_ENUM_SECURITY,
+ "kernel;2.6.23-0.115.rc3.git1.fc8;i386;installed",
+ "The Linux kernel (the core of the Linux operating system)");
+ pk_backend_package (backend, PK_INFO_ENUM_SECURITY,
+ "gtkhtml2;2.19.1-4.fc8;i386;fedora",
+ "An HTML widget for GTK+ 2.0");
pk_backend_finished (backend);
}
@@ -233,8 +237,9 @@ static void
backend_search_details (PkBackend *backend, const gchar *filter, const gchar *search)
{
g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
- "The vips documentation package.");
+ pk_backend_package (backend, PK_INFO_ENUM_AVAILABLE,
+ "vips-doc;7.12.4-2.fc8;noarch;linva",
+ "The vips documentation package.");
pk_backend_finished (backend);
}
@@ -245,8 +250,9 @@ static void
backend_search_file (PkBackend *backend, const gchar *filter, const gchar *search)
{
g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
- "The vips documentation package.");
+ pk_backend_package (backend, PK_INFO_ENUM_AVAILABLE,
+ "vips-doc;7.12.4-2.fc8;noarch;linva",
+ "The vips documentation package.");
pk_backend_finished (backend);
}
@@ -257,8 +263,9 @@ static void
backend_search_group (PkBackend *backend, const gchar *filter, const gchar *search)
{
g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
- "The vips documentation package.");
+ pk_backend_package (backend, PK_INFO_ENUM_AVAILABLE,
+ "vips-doc;7.12.4-2.fc8;noarch;linva",
+ "The vips documentation package.");
pk_backend_finished (backend);
}
@@ -269,14 +276,18 @@ gboolean
backend_search_name_timeout (gpointer data)
{
PkBackend *backend = (PkBackend *) data;
- pk_backend_package (backend, 1, "evince;0.9.3-5.fc8;i386;installed",
- "PDF Document viewer");
- pk_backend_package (backend, 1, "tetex;3.0-41.fc8;i386;fedora",
- "TeTeX is an implementation of TeX for Linux or UNIX systems.");
- pk_backend_package (backend, 0, "scribus;1.3.4-1.fc8;i386;fedora",
- "Scribus is an desktop open source page layout program");
- pk_backend_package (backend, 0, "vips-doc;7.12.4-2.fc8;noarch;linva",
- "The vips documentation package.");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "evince;0.9.3-5.fc8;i386;installed",
+ "PDF Document viewer");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "tetex;3.0-41.fc8;i386;fedora",
+ "TeTeX is an implementation of TeX for Linux or UNIX systems.");
+ pk_backend_package (backend, PK_INFO_ENUM_AVAILABLE,
+ "scribus;1.3.4-1.fc8;i386;fedora",
+ "Scribus is an desktop open source page layout program");
+ pk_backend_package (backend, PK_INFO_ENUM_AVAILABLE,
+ "vips-doc;7.12.4-2.fc8;noarch;linva",
+ "The vips documentation package.");
pk_backend_finished (backend);
return FALSE;
}
@@ -299,7 +310,7 @@ static void
backend_update_package (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
- pk_backend_package (backend, 1, package_id, "The same thing");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED, package_id, "The same thing");
pk_backend_finished (backend);
}
diff --git a/backends/test/pk-backend-test-thread.c b/backends/test/pk-backend-test-thread.c
index 071337c..c6efd32 100644
--- a/backends/test/pk-backend-test-thread.c
+++ b/backends/test/pk-backend-test-thread.c
@@ -30,10 +30,10 @@
static gboolean
backend_search_group_thread (PkBackend *backend, gpointer data)
{
- pk_backend_package (backend, 1, "glib2;2.14.0;i386;fedora",
- "The GLib library");
- pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
- "GTK+ Libraries for GIMP");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "glib2;2.14.0;i386;fedora", "The GLib library");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
return TRUE;
}
@@ -66,10 +66,10 @@ backend_search_name_thread (PkBackend *b
g_timer_destroy (timer);
pk_debug ("exited task (%p,%p)", backend, data);
- pk_backend_package (backend, 1, "glib2;2.14.0;i386;fedora",
- "The GLib library");
- pk_backend_package (backend, 1, "gtk2;gtk2-2.11.6-6.fc8;i386;fedora",
- "GTK+ Libraries for GIMP");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "glib2;2.14.0;i386;fedora", "The GLib library");
+ pk_backend_package (backend, PK_INFO_ENUM_INSTALLED,
+ "gtk2;gtk2-2.11.6-6.fc8;i386;fedora", "GTK+ Libraries for GIMP");
return TRUE;
}
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index eb8bc89..07d4181 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -247,7 +247,8 @@ class PackageKitYumBackend(PackageKitBas
if pkg.name != name:
pkgver = self._get_package_ver(pkg)
id = self.get_package_id(pkg.name, pkgver, pkg.arch, pkg.repo)
- self.package(id, 1, pkg.summary)
+ # TODO: we need to find out if this is installed or not...
+ self.package(id, PK_INFO_ENUM_UNKNOWN, pkg.summary)
def update_system(self):
'''
@@ -400,9 +401,9 @@ class PackageKitYumBackend(PackageKitBas
ut = notice['type']
# TODO : Add more types to check
if ut == 'security':
- return 1
+ return INFO_SECURITY
else:
- return 0
+ return INFO_NORMAL
def get_updates(self):
@@ -427,7 +428,7 @@ class PackageKitYumBackend(PackageKitBas
status = self._get_status(notice)
self._show_package(pkg,status)
else:
- self._show_package(pkg,0)
+ self._show_package(pkg,INFO_NORMAL)
def _setup_yum(self):
@@ -526,10 +527,10 @@ class DownloadCallback( BaseMeter ):
if self.showNames:
pkg = self._getPackage(name)
if pkg: # show package to download
- self.base._show_package(pkg,1)
+ self.base._show_package(pkg,INFO_DOWNLOADING)
else:
id = self.base.get_package_id(name, '', '', '')
- self.base.package(id,1, "Repository MetaData")
+ self.base.package(id,INFO_DOWNLOADING, "Repository MetaData")
class PackageKitCallback(RPMBaseCallback):
diff --git a/client/pk-console.c b/client/pk-console.c
index 08d04d5..f510544 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -49,7 +49,9 @@ pk_console_make_space (const gchar *data
if (data != NULL) {
size = (length - strlen(data));
if (size < 0) {
- *extra = -size;
+ if (extra != NULL) {
+ *extra = -size;
+ }
size = 0;
}
}
@@ -61,19 +63,14 @@ pk_console_make_space (const gchar *data
* pk_console_package_cb:
**/
static void
-pk_console_package_cb (PkClient *client, guint value, const gchar *package_id, const gchar *summary, gpointer data)
+pk_console_package_cb (PkClient *client, PkInfoEnum info, const gchar *package_id, const gchar *summary, gpointer data)
{
PkPackageId *ident;
PkPackageId *spacing;
- const gchar *installed;
+ gchar *info_text;
guint extra;
- if (value == 0) {
- installed = "no ";
- } else {
- installed = "yes ";
- }
-
+ info_text = pk_console_make_space (pk_info_enum_to_text (info), 10, NULL);
spacing = pk_package_id_new ();
ident = pk_package_id_new_from_string (package_id);
@@ -85,7 +82,7 @@ pk_console_package_cb (PkClient *client,
spacing->data = pk_console_make_space (ident->data, 7-extra, &extra);
/* pretty print */
- g_print ("%s %s%s %s%s %s%s %s%s %s\n", installed,
+ g_print ("%s %s%s %s%s %s%s %s%s %s\n", info_text,
ident->name, spacing->name,
ident->version, spacing->version,
ident->arch, spacing->arch,
diff --git a/docs/introduction.xml b/docs/introduction.xml
index 44ad21c..9e74280 100644
--- a/docs/introduction.xml
+++ b/docs/introduction.xml
@@ -1244,7 +1244,7 @@
<title>Package</title>
<para>
If updating, as packages are updated then emit them to the screen.
- This allows a summary to be presented after the transaction.
+ This allows a summary to be presented after the transaction.
</para>
<informaltable>
<tgroup cols="2">
@@ -1256,24 +1256,8 @@
</thead>
<tbody>
<row>
- <entry><literal>status</literal></entry>
- <entry>
- <para>
- When searching: "1" if installed, "0" if not
- </para>
- <para>
- When getting updates: "0" for normal priority updates,
- "1" for security updates, "2" for important updates,
- "3" for low priority updates.
- </para>
- <para>
- When processing packages: "0" if downloading,
- "1" if updating or installing.
- </para>
- <para>
- Else, set as "1"
- </para>
- </entry>
+ <entry><literal>info</literal></entry>
+ <entry>A valid <literal>info</literal> string enumunerated type</entry>
</row>
<row>
<entry><literal>package_id</literal></entry>
@@ -1286,6 +1270,80 @@
</tbody>
</tgroup>
</informaltable>
+
+ <para>
+ The <literal>info</literal> enumunerated type
+ </para>
+
+ <informaltable>
+ <tgroup cols="3">
+ <thead>
+ <row>
+ <entry>Situation</entry>
+ <entry>Value</entry>
+ <entry>Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry>Searching</entry>
+ <entry><literal>installed</literal></entry>
+ <entry>If installed</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><literal>available</literal></entry>
+ <entry>If available to install</entry>
+ </row>
+ <row>
+ <entry>Getting Updates</entry>
+ <entry><literal>low</literal></entry>
+ <entry>If update is of low severity</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><literal>normal</literal></entry>
+ <entry>If update is of normal severity</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><literal>important</literal></entry>
+ <entry>If update is very important</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><literal>security</literal></entry>
+ <entry>If the update is security sensitive</entry>
+ </row>
+ <row>
+ <entry>Installing/Updating/Removing</entry>
+ <entry><literal>downloading</literal></entry>
+ <entry>If we are downloading this package</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><literal>updating</literal></entry>
+ <entry>If we are updating this package</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><literal>installing</literal></entry>
+ <entry>If we are installing this package</entry>
+ </row>
+ <row>
+ <entry></entry>
+ <entry><literal>removing</literal></entry>
+ <entry>If we are removing this package</entry>
+ </row>
+ <row>
+ <entry>Otherwise</entry>
+ <entry><literal>unknown</literal></entry>
+ <entry>If we cannot use any other option</entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </informaltable>
+
</sect2>
<sect2 id="backends-spawn-description">
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 7ccc3e1..ab24fad 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -327,24 +327,26 @@ pk_client_transaction_status_changed_cb
static void
pk_client_package_cb (DBusGProxy *proxy,
const gchar *tid,
- guint value,
+ const gchar *info_text,
const gchar *package_id,
const gchar *summary,
PkClient *client)
{
PkClientPackageItem *item;
+ PkInfoEnum info;
g_return_if_fail (client != NULL);
g_return_if_fail (PK_IS_CLIENT (client));
if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
- pk_debug ("emit package %i, %s, %s", value, package_id, summary);
- g_signal_emit (client , signals [PK_CLIENT_PACKAGE], 0, value, package_id, summary);
+ pk_debug ("emit package %s, %s, %s", info_text, package_id, summary);
+ info = pk_info_enum_from_text (info_text);
+ g_signal_emit (client , signals [PK_CLIENT_PACKAGE], 0, info, package_id, summary);
/* cache */
if (client->priv->use_buffer == TRUE) {
- pk_debug ("adding to cache array package %i, %s, %s", value, package_id, summary);
+ pk_debug ("adding to cache array package %i, %s, %s", info, package_id, summary);
item = g_new0 (PkClientPackageItem, 1);
- item->value = value;
+ item->info = info;
item->package_id = g_strdup (package_id);
item->summary = g_strdup (summary);
g_ptr_array_add (client->priv->cache_package, item);
@@ -1730,7 +1732,7 @@ pk_client_init (PkClient *client)
G_CALLBACK (pk_client_transaction_status_changed_cb), client, NULL);
dbus_g_proxy_add_signal (proxy, "Package",
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (proxy, "Package",
G_CALLBACK (pk_client_package_cb), client, NULL);
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
index 59b8644..4bd4125 100644
--- a/libpackagekit/pk-client.h
+++ b/libpackagekit/pk-client.h
@@ -51,7 +51,7 @@ typedef struct
/* used if we are collecting packages sync */
typedef struct
{
- guint value;
+ PkInfoEnum info;
gchar *package_id;
gchar *summary;
} PkClientPackageItem;
diff --git a/libpackagekit/pk-enum.c b/libpackagekit/pk-enum.c
index c015a19..4adc7ab 100644
--- a/libpackagekit/pk-enum.c
+++ b/libpackagekit/pk-enum.c
@@ -141,6 +141,20 @@ static PkTaskEnumMatch task_update[] = {
{0, NULL},
};
+static PkTaskEnumMatch task_info[] = {
+ {PK_INFO_ENUM_INSTALLED, "installed"},
+ {PK_INFO_ENUM_AVAILABLE, "available"},
+ {PK_INFO_ENUM_LOW, "low"},
+ {PK_INFO_ENUM_NORMAL, "normal"},
+ {PK_INFO_ENUM_IMPORTANT, "important"},
+ {PK_INFO_ENUM_SECURITY, "security"},
+ {PK_INFO_ENUM_DOWNLOADING, "downloading"},
+ {PK_INFO_ENUM_UPDATING, "updating"},
+ {PK_INFO_ENUM_INSTALLING, "installing"},
+ {PK_INFO_ENUM_REMOVING, "removing"},
+ {0, NULL},
+};
+
/**
* pk_task_enum_find_value:
*/
@@ -190,6 +204,24 @@ pk_task_enum_find_string (PkTaskEnumMatc
}
/**
+ * pk_info_enum_from_text:
+ */
+PkInfoEnum
+pk_info_enum_from_text (const gchar *info)
+{
+ return pk_task_enum_find_value (task_info, info);
+}
+
+/**
+ * pk_info_enum_to_text:
+ **/
+const gchar *
+pk_info_enum_to_text (PkInfoEnum info)
+{
+ return pk_task_enum_find_string (task_info, info);
+}
+
+/**
* pk_exit_enum_from_text:
*/
PkExitEnum
diff --git a/libpackagekit/pk-enum.h b/libpackagekit/pk-enum.h
index 3959229..bddda8b 100644
--- a/libpackagekit/pk-enum.h
+++ b/libpackagekit/pk-enum.h
@@ -129,6 +129,23 @@ typedef enum {
PK_UPDATE_ENUM_NONE,
} PkUpdateEnum;
+typedef enum {
+ PK_INFO_ENUM_INSTALLED,
+ PK_INFO_ENUM_AVAILABLE,
+ PK_INFO_ENUM_LOW,
+ PK_INFO_ENUM_NORMAL,
+ PK_INFO_ENUM_IMPORTANT,
+ PK_INFO_ENUM_SECURITY,
+ PK_INFO_ENUM_DOWNLOADING,
+ PK_INFO_ENUM_UPDATING,
+ PK_INFO_ENUM_INSTALLING,
+ PK_INFO_ENUM_REMOVING,
+ PK_INFO_ENUM_UNKNOWN
+} PkInfoEnum;
+
+PkInfoEnum pk_info_enum_from_text (const gchar *info);
+const gchar *pk_info_enum_to_text (PkInfoEnum info);
+
PkUpdateEnum pk_update_enum_from_text (const gchar *update);
const gchar *pk_update_enum_to_text (PkUpdateEnum update);
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
index 4bf0d34..8eca7b4 100644
--- a/python/packagekit/backend.py
+++ b/python/packagekit/backend.py
@@ -46,6 +46,17 @@ RESTART_SYSTEM = "system"
RESTART_APPLICATION = "application"
RESTART_SESSION = "session"
+INFO_INSTALLED = "installed"
+INFO_AVAILABLE = "available"
+INFO_LOW = "low"
+INFO_NORMAL = "normal"
+INFO_IMPORTANT = "important"
+INFO_SECURITY = "security"
+INFO_DOWNLOADING = "downloading"
+INFO_UPDATING = "updating"
+INFO_INSTALLING = "installing"
+INFO_REMOVING = "removing"
+
# Classes
class PackageKitBaseBackend:
@@ -84,7 +95,7 @@ class PackageKitBaseBackend:
def package(self,id,status,summary):
'''
send 'package' signal
- @param status: 1 = Installed, 0 = not
+ @param info: the enumerated INFO_* string
@param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
@param summary: The package Summary
'''
diff --git a/src/pk-backend.c b/src/pk-backend.c
index 0e501be..00feda1 100644
--- a/src/pk-backend.c
+++ b/src/pk-backend.c
@@ -236,9 +236,9 @@ pk_backend_parse_common_output (PkBacken
{
gchar **sections;
guint size;
- guint value = 0;
gchar *command;
gboolean ret = TRUE;
+ PkInfoEnum info;
PkGroupEnum group;
/* check if output line */
@@ -259,9 +259,16 @@ pk_backend_parse_common_output (PkBacken
goto out;
}
if (pk_package_id_check (sections[2]) == TRUE) {
- value = atoi(sections[1]);
- pk_debug ("value=%i, package='%s' shortdesc='%s'", value, sections[2], sections[3]);
- pk_backend_package (backend, value, sections[2], sections[3]);
+ info = pk_info_enum_from_text (sections[1]);
+ /* just until we've converted the backends */
+ if (info == PK_INFO_ENUM_UNKNOWN) {
+ g_print ("Info enumerated type '%s' not recognised\n", sections[1]);
+ g_print ("See src/pk-enum.c for allowed values.\n");
+ pk_error ("Runtime error, cannot continue");
+ }
+ pk_debug ("info=%s, package='%s' shortdesc='%s'",
+ pk_info_enum_to_text (info), sections[2], sections[3]);
+ pk_backend_package (backend, info, sections[2], sections[3]);
} else {
pk_warning ("invalid package_id");
}
@@ -614,7 +621,7 @@ pk_backend_change_status (PkBackend *bac
* pk_backend_package:
**/
gboolean
-pk_backend_package (PkBackend *backend, guint value, const gchar *package, const gchar *summary)
+pk_backend_package (PkBackend *backend, PkInfoEnum info, const gchar *package, const gchar *summary)
{
g_return_val_if_fail (backend != NULL, FALSE);
g_return_val_if_fail (PK_IS_BACKEND (backend), FALSE);
@@ -623,8 +630,8 @@ pk_backend_package (PkBackend *backend,
g_free (backend->priv->last_package);
backend->priv->last_package = g_strdup (package);
- pk_debug ("emit package %i, %s, %s", value, package, summary);
- g_signal_emit (backend, signals [PK_BACKEND_PACKAGE], 0, value, package, summary);
+ pk_debug ("emit package %i, %s, %s", info, package, summary);
+ g_signal_emit (backend, signals [PK_BACKEND_PACKAGE], 0, info, package, summary);
return TRUE;
}
diff --git a/src/pk-backend.h b/src/pk-backend.h
index 2e37424..933c287 100644
--- a/src/pk-backend.h
+++ b/src/pk-backend.h
@@ -43,7 +43,7 @@ gboolean pk_backend_change_status (PkB
gboolean pk_backend_no_percentage_updates (PkBackend *backend);
gboolean pk_backend_finished (PkBackend *backend);
gboolean pk_backend_package (PkBackend *backend,
- guint value,
+ PkInfoEnum info,
const gchar *package_id,
const gchar *summary);
gboolean pk_backend_update_detail (PkBackend *backend,
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 383f71c..29b21f8 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -262,9 +262,10 @@ pk_engine_no_percentage_updates_cb (PkBa
* pk_engine_package_cb:
**/
static void
-pk_engine_package_cb (PkBackend *backend, guint value, const gchar *package_id, const gchar *summary, PkEngine *engine)
+pk_engine_package_cb (PkBackend *backend, PkInfoEnum info, const gchar *package_id, const gchar *summary, PkEngine *engine)
{
PkTransactionItem *item;
+ const gchar *info_text;
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
@@ -274,8 +275,9 @@ pk_engine_package_cb (PkBackend *backend
pk_warning ("could not find backend");
return;
}
- pk_debug ("emitting package tid:%s value=%i %s, %s", item->tid, value, package_id, summary);
- g_signal_emit (engine, signals [PK_ENGINE_PACKAGE], 0, item->tid, value, package_id, summary);
+ info_text = pk_info_enum_to_text (info);
+ pk_debug ("emitting package tid:%s info=%s %s, %s", item->tid, info_text, package_id, summary);
+ g_signal_emit (engine, signals [PK_ENGINE_PACKAGE], 0, item->tid, info_text, package_id, summary);
pk_engine_reset_timer (engine);
}
@@ -1878,8 +1880,8 @@ pk_engine_class_init (PkEngineClass *kla
signals [PK_ENGINE_PACKAGE] =
g_signal_new ("package",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_UINT_STRING_STRING,
- G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
signals [PK_ENGINE_ERROR_CODE] =
g_signal_new ("error-code",
G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index c490133..abd3c35 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -97,7 +97,7 @@
</signal>
<signal name="Package">
<arg type="s" name="tid" direction="out"/>
- <arg type="u" name="value" direction="out"/> <!-- installed=1, not-installed=0 | security=1, normal=0 -->
+ <arg type="s" name="info" direction="out"/>
<arg type="s" name="package_id" direction="out"/>
<arg type="s" name="summary" direction="out"/>
</signal>
diff-tree 70295a6e0b0859d39510ab9e33086642dc528d91 (from 4d601a3570fec25fecaaa40b9f70a045db66ce34)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 30 14:23:18 2007 +0100
update TODO
diff --git a/TODO b/TODO
index c7fad3a..4b70639 100644
--- a/TODO
+++ b/TODO
@@ -15,6 +15,18 @@ Do automatic updates at login time when
* needs gnome-screensaver integration
NOTE: RELEASE BLOCKER
+*** installed, available checkboxes to go comboboxes ***
+Show: [Installed packages, Available packages, All packages]
+Type Filter: [Only graphical packages, Only text packages, All packages]
+Development Filter: [Only normal packages, Only development packages, All packages]
+
+*** Add new callback for status ***
+TimeRemaining()
+
+*** Get the deps in the UI when removing ***
+We really don't want to remove glibc...
+NOTE: RELEASE BLOCKER
+
*** pk-application (client) ***
Use an icons for installed and not-installed rather than tickboxes
Refresh the query list after an install or remove (means saving the query and re-issuing)
More information about the PackageKit
mailing list