[packagekit] packagekit: Branch 'master' - 24 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Tue Sep 25 10:23:40 PDT 2007
Makefile.am | 6
backends/conary/helpers/Makefile.am | 1
backends/conary/helpers/conaryBackend.py | 49
backends/conary/helpers/get-depends.py | 4
backends/conary/helpers/packagekit | 1
backends/conary/helpers/packagekit.py | 1
backends/conary/pk-backend-conary.c | 15
backends/yum/helpers/Makefile.am | 1
backends/yum/helpers/packagekit | 1
backends/yum/helpers/yumBackend.py | 2
client/pk-console.c | 180 +--
libpackagekit/Makefile.am | 17
libpackagekit/README | 3
libpackagekit/pk-client.c | 1644 ++++++++++++++++++-------------
libpackagekit/pk-client.h | 136 ++
libpackagekit/pk-job-list.c | 2
libpackagekit/pk-task-client.h | 115 --
libpackagekit/pk-task-list.c | 23
libpackagekit/pk-task-list.h | 4
libpackagekit/pk-task-monitor.c | 793 --------------
libpackagekit/pk-task-monitor.h | 71 -
src/pk-engine.c | 613 +++++------
src/pk-engine.h | 39
src/pk-interface.xml | 37
src/pk-main.c | 19
src/pk-transaction-list.c | 32
src/pk-transaction-list.h | 9
tools/add-method.sh | 2
28 files changed, 1666 insertions(+), 2154 deletions(-)
New commits:
diff-tree c159de635aed991684c1dbf5299ed2ecdf623e50 (from 5fa4d72283c964e8753210ac7160b06ae3d3dc20)
Author: Tom Parker <palfrey at tevp.net>
Date: Tue Sep 25 15:41:48 2007 +0200
Clarify reasons for startup failure
Previously, all startup failures were reported as
"Already running on this machine", when it was also possible
that it was due to lack of security permissions.
pk_object_register now takes a GError** arg in order so it
can communicate the exact problem back to main
diff --git a/src/pk-main.c b/src/pk-main.c
index b83ce01..952abcb 100644
--- a/src/pk-main.c
+++ b/src/pk-main.c
@@ -49,10 +49,10 @@ static guint exit_idle_time;
**/
static gboolean
pk_object_register (DBusGConnection *connection,
- GObject *object)
+ GObject *object,
+ GError **error)
{
DBusGProxy *bus_proxy = NULL;
- GError *error = NULL;
guint request_name_result;
gboolean ret;
@@ -61,19 +61,20 @@ pk_object_register (DBusGConnection *con
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
- ret = dbus_g_proxy_call (bus_proxy, "RequestName", &error,
+ ret = dbus_g_proxy_call (bus_proxy, "RequestName", error,
G_TYPE_STRING, PK_DBUS_SERVICE,
G_TYPE_UINT, 0,
G_TYPE_INVALID,
G_TYPE_UINT, &request_name_result,
G_TYPE_INVALID);
- if (error) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
+ if (error && *error) {
+ pk_debug ("ERROR: %s", (*error)->message);
}
if (ret == FALSE) {
/* abort as the DBUS method failed */
pk_warning ("RequestName failed!");
+ g_clear_error(error);
+ g_set_error(error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_DENIED, "Acquiring D-Bus name %s failed due to security policies on this machine",PK_DBUS_SERVICE);
return FALSE;
}
@@ -82,6 +83,7 @@ pk_object_register (DBusGConnection *con
/* already running */
if (request_name_result != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
+ g_set_error(error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_DENIED, "Already running on this machine");
return FALSE;
}
@@ -216,8 +218,9 @@ main (int argc, char *argv[])
engine = pk_engine_new ();
pk_engine_use_backend (engine, backend);
- if (!pk_object_register (system_connection, G_OBJECT (engine))) {
- g_error ("Already running on this machine");
+ if (!pk_object_register (system_connection, G_OBJECT (engine), &error)) {
+ g_error ("Error trying to start: %s", error->message);
+ g_error_free (error);
return 0;
}
diff-tree 5fa4d72283c964e8753210ac7160b06ae3d3dc20 (from 28d70f4d057f01b61397479d43d7549d8cba0cc6)
Author: Ken VanDine <ken at vandine.org>
Date: Tue Sep 25 09:06:49 2007 -0400
get-depends helper script
diff --git a/backends/conary/helpers/get-depends.py b/backends/conary/helpers/get-depends.py
index 339fca9..7028b63 100755
--- a/backends/conary/helpers/get-depends.py
+++ b/backends/conary/helpers/get-depends.py
@@ -10,5 +10,9 @@
# (at your option) any later version.
import sys
+from conaryBackend import PackageKitConaryBackend
+package = sys.argv[1]
+backend = PackageKitConaryBackend(sys.argv[1:])
+backend.get_depends(package)
sys.exit(0)
diff-tree 28d70f4d057f01b61397479d43d7549d8cba0cc6 (from 1bf134e651122f91feb927b63eea45d05f0dc54d)
Author: Ken VanDine <ken at vandine.org>
Date: Tue Sep 25 09:05:15 2007 -0400
get-depends not get-requires and allow more canceling
diff --git a/backends/conary/pk-backend-conary.c b/backends/conary/pk-backend-conary.c
index fbacfd0..dffd5ef 100644
--- a/backends/conary/pk-backend-conary.c
+++ b/backends/conary/pk-backend-conary.c
@@ -47,8 +47,8 @@ backend_get_filters (PkBackend *backend,
{
g_return_if_fail (backend != NULL);
pk_enum_list_append_multiple (elist,
- PK_FILTER_ENUM_GUI,
- PK_FILTER_ENUM_INSTALLED,
+ /* PK_FILTER_ENUM_GUI, */
+ /* PK_FILTER_ENUM_INSTALLED, */
PK_FILTER_ENUM_DEVELOPMENT,
-1);
}
@@ -71,6 +71,7 @@ static void
backend_get_updates (PkBackend *backend)
{
g_return_if_fail (backend != NULL);
+ pk_backend_allow_interrupt (backend, TRUE);
pk_backend_spawn_helper (backend, "get-updates.py", NULL);
}
@@ -172,14 +173,14 @@ backend_update_system (PkBackend *backen
}
/**
- * backend_get_requires:
+ * backend_get_depends:
*/
static void
-backend_get_requires (PkBackend *backend, const gchar *package_id)
+backend_get_depends (PkBackend *backend, const gchar *package_id)
{
g_return_if_fail (backend != NULL);
pk_backend_allow_interrupt (backend, TRUE);
- pk_backend_spawn_helper (backend, "get-requires.py", package_id, NULL);
+ pk_backend_spawn_helper (backend, "get-depends.py", package_id, NULL);
}
PK_BACKEND_OPTIONS (
@@ -191,9 +192,9 @@ PK_BACKEND_OPTIONS (
backend_get_groups, /* get_groups */
backend_get_filters, /* get_filters */
NULL, /* cancel */
- NULL, /* get_depends */
+ backend_get_depends, /* get_depends */
backend_get_description, /* get_description */
- backend_get_requires, /* get_requires */
+ NULL, /* get_requires */
NULL, /* get_update_detail */
backend_get_updates, /* get_updates */
backend_install_package, /* install_package */
diff-tree 1bf134e651122f91feb927b63eea45d05f0dc54d (from 3ec379272d04305afe45ffa3bbd3c98ceed79437)
Author: Ken VanDine <ken at vandine.org>
Date: Tue Sep 25 09:04:40 2007 -0400
Use a try/except to deal with no updates available better
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 0216349..10a5d3a 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -290,25 +290,28 @@ class PackageKitConaryBackend(PackageKit
def get_updates(self):
self.percentage()
- updateItems = self.client.fullUpdateItemList()
- applyList = [ (x[0], (None, None), x[1:], True) for x in updateItems ]
- updJob, suggMap = self._do_update(applyList, apply=False)
-
- jobLists = updJob.getJobs()
-
- totalJobs = len(jobLists)
- for num, job in enumerate(jobLists):
- status = '2'
- name = job[0][0]
- version = job[0][2][0]
- flavor = job[0][2][1]
- troveTuple = []
- troveTuple.append(name)
- troveTuple.append(version)
- installed = self.check_installed(troveTuple)
- id = self.get_package_id(name, version, flavor)
- summary = ""
- self.package(id, installed, summary)
+ try:
+ updateItems = self.client.fullUpdateItemList()
+ applyList = [ (x[0], (None, None), x[1:], True) for x in updateItems ]
+ updJob, suggMap = self._do_update(applyList, apply=False)
+
+ jobLists = updJob.getJobs()
+
+ totalJobs = len(jobLists)
+ for num, job in enumerate(jobLists):
+ status = '2'
+ name = job[0][0]
+ version = job[0][2][0]
+ flavor = job[0][2][1]
+ troveTuple = []
+ troveTuple.append(name)
+ troveTuple.append(version)
+ installed = self.check_installed(troveTuple)
+ id = self.get_package_id(name, version, flavor)
+ summary = ""
+ self.package(id, installed, summary)
+ except:
+ pass
def _do_filtering(self, pkg, filterList, installed):
''' Filter the package, based on the filter in filterList '''
diff-tree 3ec379272d04305afe45ffa3bbd3c98ceed79437 (from 9310d28d723cbdae1c5ef31e78014b0d0a581dff)
Author: Tim Lauridsen <tla at rasmil.dk>
Date: Tue Sep 25 09:32:29 2007 +0200
* Moved python/__init__.py python/packagekit/__init__.py
* Moved backends/yum/helpers/packagekit.py -> python/packagekit/backend.py
So that the PackageKitBaseBackend python class used byt yum & conary is part
of the packagekit python module and be used by
'from packagekit.backend import PackageKitBaseBackend'
added links from python/packagekit to yum/helpers & conary/helpers so
that the python code will work when started in the directory.
make changes to the Makefile's to support the changes.
diff --git a/Makefile.am b/Makefile.am
index 5063b36..43fb928 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,11 @@ dbusdir = ${SYSCONFDIR}/dbus-1/system.d
dist_dbus_DATA = PackageKit.conf
packagekitpythondir = ${PYTHON_PACKAGE_DIR}
-packagekitpython_PYTHON = python/__init__.py
+packagekitpython_PYTHON = \
+ python/packagekit/__init__.py \
+ python/packagekit/backend.py \
+ $(NULL)
+
EXTRA_DIST = \
PackageKit.conf.in \
diff --git a/backends/conary/helpers/Makefile.am b/backends/conary/helpers/Makefile.am
index 0f25047..8749b54 100644
--- a/backends/conary/helpers/Makefile.am
+++ b/backends/conary/helpers/Makefile.am
@@ -16,7 +16,6 @@ dist_helper_DATA = \
get-description.py \
conaryBackend.py \
conaryCallback.py \
- packagekit.py \
$(NULL)
install-data-hook:
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 0a7960a..0216349 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -15,7 +15,7 @@ from conary.deps import deps
from conary import conarycfg, conaryclient
from conary import dbstore, queryrep, versions, updatecmd
-from packagekit import *
+from packagekit.backend import *
from conaryCallback import UpdateCallback
class PackageKitConaryBackend(PackageKitBaseBackend):
diff --git a/backends/conary/helpers/packagekit b/backends/conary/helpers/packagekit
new file mode 120000
index 0000000..8d22531
--- /dev/null
+++ b/backends/conary/helpers/packagekit
@@ -0,0 +1 @@
+../../../python/packagekit
\ No newline at end of file
diff --git a/backends/conary/helpers/packagekit.py b/backends/conary/helpers/packagekit.py
deleted file mode 120000
index 0e89ba3..0000000
--- a/backends/conary/helpers/packagekit.py
+++ /dev/null
@@ -1 +0,0 @@
-../../yum/helpers/packagekit.py
\ No newline at end of file
diff --git a/backends/yum/helpers/Makefile.am b/backends/yum/helpers/Makefile.am
index 396bc8b..eb107b2 100644
--- a/backends/yum/helpers/Makefile.am
+++ b/backends/yum/helpers/Makefile.am
@@ -18,7 +18,6 @@ dist_helper_DATA = \
refresh-cache.py \
update-system.py \
yumBackend.py \
- packagekit.py \
$(NULL)
install-data-hook:
diff --git a/backends/yum/helpers/packagekit b/backends/yum/helpers/packagekit
new file mode 120000
index 0000000..8d22531
--- /dev/null
+++ b/backends/yum/helpers/packagekit
@@ -0,0 +1 @@
+../../../python/packagekit
\ No newline at end of file
diff --git a/backends/yum/helpers/packagekit.py b/backends/yum/helpers/packagekit.py
deleted file mode 100644
index 4bf0d34..0000000
--- a/backends/yum/helpers/packagekit.py
+++ /dev/null
@@ -1,248 +0,0 @@
-#!/usr/bin/python -tt
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Library General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright (C) 2007 Tim Lauridsen <timlau at fedoraproject.org>
-
-#
-# This file contain the base classes to implement a PackageKit python backend
-#
-
-# imports
-import sys
-
-# Constants
-
-ERROR_OOM = "out-of-memory"
-ERROR_NO_NETWORK = "no-network"
-ERROR_NOT_SUPPORTED = "not-supported"
-ERROR_INTERNAL_ERROR = "internal-error"
-ERROR_GPG_FAILURE = "gpg-failure"
-ERROR_PACKAGE_NOT_INSTALLED = "package-not-installed"
-ERROR_PACKAGE_ALREADY_INSTALLED = "package-already-installed"
-ERROR_PACKAGE_DOWNLOAD_FAILED = "package-download-failed"
-ERROR_DEP_RESOLUTION_FAILED = "dep-resolution-failed"
-ERROR_CREATE_THREAD_FAILED = "create-thread-failed"
-ERROR_FILTER_INVALID = "filter-invalid"
-ERROR_TRANSACTION_ERROR = "transaction-error"
-
-STATE_DOWNLOAD = "download"
-STATE_INSTALL = "install"
-STATE_UPDATE = "update"
-STATE_REMOVE = "remove"
-
-RESTART_SYSTEM = "system"
-RESTART_APPLICATION = "application"
-RESTART_SESSION = "session"
-
-# Classes
-
-class PackageKitBaseBackend:
-
- def __init__(self,cmds):
- self.cmds = cmds
-
- def percentage(self,percent=None):
- '''
- Write progress percentage
- @param percent: Progress percentage
- '''
- if percent != None:
- print >> sys.stderr, "percentage\t%i" % (percent)
- else:
- print >> sys.stderr, "no-percentage-updates"
-
- def sub_percentage(self,percent=None):
- '''
- send 'subpercentage' signal : subprogress percentage
- @param percent: subprogress percentage
- '''
- print >> sys.stderr, "subpercentage\t%i" % (percent)
-
- def error(self,err,description,exit=True):
- '''
- send 'error'
- @param err: Error Type (ERROR_NO_NETWORK, ERROR_NOT_SUPPORTED, ERROR_INTERNAL_ERROR)
- @param description: Error description
- @param exit: exit application with rc=1, if true
- '''
- print >> sys.stderr,"error\t%s\t%s" % (err,description)
- if exit:
- sys.exit(1)
-
- def package(self,id,status,summary):
- '''
- send 'package' signal
- @param status: 1 = Installed, 0 = not
- @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
- @param summary: The package Summary
- '''
- print >> sys.stdout,"package\t%s\t%s\t%s" % (status,id,summary)
-
- def status(self,state):
- '''
- send 'status' signal
- @param state: STATE_DOWNLOAD, STATE_INSTALL, STATE_UPDATE, STATE_REMOVE
- '''
- print >> sys.stderr,"status\t%s" % (state)
-
- def data(self,data):
- '''
- send 'data' signal:
- @param data: The current worked on package
- '''
- print >> sys.stderr,"data\t%s" % (data)
-
- def description(self,id,licence,group,desc,url):
- '''
- Send 'description' signal
- @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
- @param licence: The licence of the package
- @param group: The enumerated group
- @param desc: The multi line package description
- @param url: The upstream project homepage
- '''
- print >> sys.stdout,"description\t%s\t%s\t%s\t%s\t%s" % (id,licence,group,desc,url)
-
- def require_restart(self,restart_type,details):
- '''
- Send 'requirerestart' signal
- @param restart_type: RESTART_SYSTEM, RESTART_APPLICATION,RESTART_SESSION
- @param details: Optional details about the restart
- '''
- print >> sys.stderr,"requirerestart\t%s\t%s" % (restart_type,details)
-
- def allow_interrupt(self,allow):
- '''
- send 'allow-interrupt' signal:
- @param allow: Allow the current process to be aborted.
- '''
- if allow:
- data = 'true'
- else:
- data = 'false'
- print >> sys.stderr,"allow-interrupt\t%s" % (data)
-
- def get_package_id(self,name,version,arch,data):
- return "%s;%s;%s;%s" % (name,version,arch,data)
-
- def get_package_from_id(self,id):
- ''' split up a package id name;ver;arch;data into a tuple
- containing (name,ver,arch,data)
- '''
- return tuple(id.split(';'))
-#
-# Backend Action Methods
-#
-
- def search_name(self,filters,key):
- '''
- Implement the {backend}-search-name functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def search_details(self,filters,key):
- '''
- Implement the {backend}-search-details functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def search_group(self,filters,key):
- '''
- Implement the {backend}-search-group functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def search_file(self,filters,key):
- '''
- Implement the {backend}-search-file functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
-
- def get_update_detail(self,package):
- '''
- Implement the {backend}-get-update-detail functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def get_depends(self,package):
- '''
- Implement the {backend}-get-depends functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def get_requires(self,package):
- '''
- Implement the {backend}-get-requires functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def update_system(self):
- '''
- Implement the {backend}-update-system functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
-
- def refresh_cache(self):
- '''
- Implement the {backend}-refresh_cache functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def install(self, package):
- '''
- Implement the {backend}-install functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def remove(self, allowdep, package):
- '''
- Implement the {backend}-remove functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def update(self, package):
- '''
- Implement the {backend}-update functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def get_description(self, package):
- '''
- Implement the {backend}-get-description functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
- def get_updates(self, package):
- '''
- Implement the {backend}-get-updates functionality
- Needed to be implemented in a sub class
- '''
- self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
-
diff --git a/backends/yum/helpers/yumBackend.py b/backends/yum/helpers/yumBackend.py
index 0456527..8e8fcc6 100644
--- a/backends/yum/helpers/yumBackend.py
+++ b/backends/yum/helpers/yumBackend.py
@@ -23,7 +23,7 @@
import sys
import re
-from packagekit import *
+from packagekit.backend import *
import yum
from urlgrabber.progress import BaseMeter,format_time,format_number
from yum.rpmtrans import RPMBaseCallback
diff --git a/python/__init__.py b/python/__init__.py
deleted file mode 100644
index 6c71eb7..0000000
--- a/python/__init__.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# PackageKit python interface
-#
-# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
-#
-# 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 v2 as published by
-# the Free Software Foundation.
-
-from types import *
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-import gobject
-
-class PackageKitException(Exception):
- def __init__(self):
- Exception.__init__(self)
-
- def __init__(self,e=None):
- Exception.__init__(self)
- if e == None:
- self._pk_name = None
- self._full_str = None
- else:
- if not isinstance(e,dbus.exceptions.DBusException):
- raise Exception,"Can only handle DBusExceptions"
- self._pk_name = str(e.get_dbus_name())
- self._full_str = str(e)
-
- def get_backend_name(self):
- return self._pk_name
-
- def __str__(self):
- if self._full_str!=None:
- return self._full_str
- else:
- return ""
-
-class PackageKitNotStarted(PackageKitException):
- pass
-
-class PackageKitAccessDenied(PackageKitException):
- pass
-
-class PackageKitTransactionFailure(PackageKitException):
- pass
-
-class PackageKitBackendFailure(PackageKitException):
- pass
-
-def dbusException(func):
- def wrapper(*args,**kwargs):
- try:
- return func(*args,**kwargs)
- except dbus.exceptions.DBusException,e:
- if e.get_dbus_name() == "org.freedesktop.DBus.Error.AccessDenied":
- raise PackageKitAccessDenied
- elif e.get_dbus_name() == "org.freedesktop.DBus.Error.NoReply":
- raise PackageKitBackendFailure
- else:
- raise PackageKitException(e)
- except Exception:
- print "wibble"
- raise
- return wrapper
-
-
-class PackageKit:
- def job_id(func):
- def wrapper(*args,**kwargs):
- jid = func(*args,**kwargs)
- if jid == -1:
- raise PackageKitTransactionFailure
- else:
- return jid
- return wrapper
-
- def __init__(self):
- DBusGMainLoop(set_as_default=True)
- bus = dbus.SystemBus()
- try:
- pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
- self.pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
- except dbus.exceptions.DBusException,e:
- if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
- raise PackageKitNotStarted
- else:
- raise PackageKitException(e)
-
- #self.job = None
- self.progress = 0.0
- bus.add_signal_receiver(self.catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
-
- def run(self):
- self.loop = gobject.MainLoop()
- self.loop.run()
-
- def catchall_signal_handler(self,*args, **kwargs):
- #if args[0] != self.job and kwargs['member']!="TransactionListChanged":
- # print "args",args,kwargs
- # return
- if kwargs['member'] == "Finished":
- self.loop.quit()
- self.Finish()
- elif kwargs['member'] == "PercentageChanged":
- progress = float(args[1])+(progress%1.0)
- self.Percentage(progress)
- elif kwargs['member'] == "SubPercentageChanged":
- progress = (float(args[1])/100.0)+int(progress)
- self.Percentage(progress)
- elif kwargs['member'] == "TransactionStatusChanged":
- self.JobStatus(args[1])
- elif kwargs['member'] == "Package":
- self.Package(args[2],args[3])
- elif kwargs['member'] in ["NoPercentageUpdates","TransactionListChanged"]:
- pass
- elif kwargs['member'] == "Description":
- self.Description(args[1],args[3],args[4],args[5])
- else:
- print "Caught signal %s"% kwargs['member']
- for arg in args:
- print " " + str(arg)
-
- def Percentage(self,value):
- pass
-
- def JobStatus(self,string):
- pass
-
- def Finish(self):
- pass
-
- def Package(self,package_name,package_summary):
- pass
-
- def Description(self,package_name,package_group,package_description,package_url):
- pass
-
- @dbusException
- @job_id
- def SearchName(self,pattern,filter="none"):
- return self.pk_iface.SearchName(filter,pattern)
-
- @dbusException
- @job_id
- def GetDescription(self,package_id):
- return self.pk_iface.GetDescription(package_id)
-
- @dbusException
- @job_id
- def RefreshCache(self,force=False):
- return self.pk_iface.RefreshCache(force)
-
-# hack to avoid exporting them
-#del job_id
-del dbusException
diff --git a/python/packagekit/__init__.py b/python/packagekit/__init__.py
new file mode 100644
index 0000000..6c71eb7
--- /dev/null
+++ b/python/packagekit/__init__.py
@@ -0,0 +1,157 @@
+# PackageKit python interface
+#
+# Copyright (C) 2007 Tom Parker <palfrey at tevp.net>
+#
+# 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 v2 as published by
+# the Free Software Foundation.
+
+from types import *
+import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+import gobject
+
+class PackageKitException(Exception):
+ def __init__(self):
+ Exception.__init__(self)
+
+ def __init__(self,e=None):
+ Exception.__init__(self)
+ if e == None:
+ self._pk_name = None
+ self._full_str = None
+ else:
+ if not isinstance(e,dbus.exceptions.DBusException):
+ raise Exception,"Can only handle DBusExceptions"
+ self._pk_name = str(e.get_dbus_name())
+ self._full_str = str(e)
+
+ def get_backend_name(self):
+ return self._pk_name
+
+ def __str__(self):
+ if self._full_str!=None:
+ return self._full_str
+ else:
+ return ""
+
+class PackageKitNotStarted(PackageKitException):
+ pass
+
+class PackageKitAccessDenied(PackageKitException):
+ pass
+
+class PackageKitTransactionFailure(PackageKitException):
+ pass
+
+class PackageKitBackendFailure(PackageKitException):
+ pass
+
+def dbusException(func):
+ def wrapper(*args,**kwargs):
+ try:
+ return func(*args,**kwargs)
+ except dbus.exceptions.DBusException,e:
+ if e.get_dbus_name() == "org.freedesktop.DBus.Error.AccessDenied":
+ raise PackageKitAccessDenied
+ elif e.get_dbus_name() == "org.freedesktop.DBus.Error.NoReply":
+ raise PackageKitBackendFailure
+ else:
+ raise PackageKitException(e)
+ except Exception:
+ print "wibble"
+ raise
+ return wrapper
+
+
+class PackageKit:
+ def job_id(func):
+ def wrapper(*args,**kwargs):
+ jid = func(*args,**kwargs)
+ if jid == -1:
+ raise PackageKitTransactionFailure
+ else:
+ return jid
+ return wrapper
+
+ def __init__(self):
+ DBusGMainLoop(set_as_default=True)
+ bus = dbus.SystemBus()
+ try:
+ pk = bus.get_object('org.freedesktop.PackageKit', '/org/freedesktop/PackageKit')
+ self.pk_iface = dbus.Interface(pk, dbus_interface='org.freedesktop.PackageKit')
+ except dbus.exceptions.DBusException,e:
+ if e.get_dbus_name() == "org.freedesktop.DBus.Error.ServiceUnknown":
+ raise PackageKitNotStarted
+ else:
+ raise PackageKitException(e)
+
+ #self.job = None
+ self.progress = 0.0
+ bus.add_signal_receiver(self.catchall_signal_handler, interface_keyword='dbus_interface', member_keyword='member',dbus_interface="org.freedesktop.PackageKit")
+
+ def run(self):
+ self.loop = gobject.MainLoop()
+ self.loop.run()
+
+ def catchall_signal_handler(self,*args, **kwargs):
+ #if args[0] != self.job and kwargs['member']!="TransactionListChanged":
+ # print "args",args,kwargs
+ # return
+ if kwargs['member'] == "Finished":
+ self.loop.quit()
+ self.Finish()
+ elif kwargs['member'] == "PercentageChanged":
+ progress = float(args[1])+(progress%1.0)
+ self.Percentage(progress)
+ elif kwargs['member'] == "SubPercentageChanged":
+ progress = (float(args[1])/100.0)+int(progress)
+ self.Percentage(progress)
+ elif kwargs['member'] == "TransactionStatusChanged":
+ self.JobStatus(args[1])
+ elif kwargs['member'] == "Package":
+ self.Package(args[2],args[3])
+ elif kwargs['member'] in ["NoPercentageUpdates","TransactionListChanged"]:
+ pass
+ elif kwargs['member'] == "Description":
+ self.Description(args[1],args[3],args[4],args[5])
+ else:
+ print "Caught signal %s"% kwargs['member']
+ for arg in args:
+ print " " + str(arg)
+
+ def Percentage(self,value):
+ pass
+
+ def JobStatus(self,string):
+ pass
+
+ def Finish(self):
+ pass
+
+ def Package(self,package_name,package_summary):
+ pass
+
+ def Description(self,package_name,package_group,package_description,package_url):
+ pass
+
+ @dbusException
+ @job_id
+ def SearchName(self,pattern,filter="none"):
+ return self.pk_iface.SearchName(filter,pattern)
+
+ @dbusException
+ @job_id
+ def GetDescription(self,package_id):
+ return self.pk_iface.GetDescription(package_id)
+
+ @dbusException
+ @job_id
+ def RefreshCache(self,force=False):
+ return self.pk_iface.RefreshCache(force)
+
+# hack to avoid exporting them
+#del job_id
+del dbusException
diff --git a/python/packagekit/backend.py b/python/packagekit/backend.py
new file mode 100644
index 0000000..4bf0d34
--- /dev/null
+++ b/python/packagekit/backend.py
@@ -0,0 +1,248 @@
+#!/usr/bin/python -tt
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright (C) 2007 Tim Lauridsen <timlau at fedoraproject.org>
+
+#
+# This file contain the base classes to implement a PackageKit python backend
+#
+
+# imports
+import sys
+
+# Constants
+
+ERROR_OOM = "out-of-memory"
+ERROR_NO_NETWORK = "no-network"
+ERROR_NOT_SUPPORTED = "not-supported"
+ERROR_INTERNAL_ERROR = "internal-error"
+ERROR_GPG_FAILURE = "gpg-failure"
+ERROR_PACKAGE_NOT_INSTALLED = "package-not-installed"
+ERROR_PACKAGE_ALREADY_INSTALLED = "package-already-installed"
+ERROR_PACKAGE_DOWNLOAD_FAILED = "package-download-failed"
+ERROR_DEP_RESOLUTION_FAILED = "dep-resolution-failed"
+ERROR_CREATE_THREAD_FAILED = "create-thread-failed"
+ERROR_FILTER_INVALID = "filter-invalid"
+ERROR_TRANSACTION_ERROR = "transaction-error"
+
+STATE_DOWNLOAD = "download"
+STATE_INSTALL = "install"
+STATE_UPDATE = "update"
+STATE_REMOVE = "remove"
+
+RESTART_SYSTEM = "system"
+RESTART_APPLICATION = "application"
+RESTART_SESSION = "session"
+
+# Classes
+
+class PackageKitBaseBackend:
+
+ def __init__(self,cmds):
+ self.cmds = cmds
+
+ def percentage(self,percent=None):
+ '''
+ Write progress percentage
+ @param percent: Progress percentage
+ '''
+ if percent != None:
+ print >> sys.stderr, "percentage\t%i" % (percent)
+ else:
+ print >> sys.stderr, "no-percentage-updates"
+
+ def sub_percentage(self,percent=None):
+ '''
+ send 'subpercentage' signal : subprogress percentage
+ @param percent: subprogress percentage
+ '''
+ print >> sys.stderr, "subpercentage\t%i" % (percent)
+
+ def error(self,err,description,exit=True):
+ '''
+ send 'error'
+ @param err: Error Type (ERROR_NO_NETWORK, ERROR_NOT_SUPPORTED, ERROR_INTERNAL_ERROR)
+ @param description: Error description
+ @param exit: exit application with rc=1, if true
+ '''
+ print >> sys.stderr,"error\t%s\t%s" % (err,description)
+ if exit:
+ sys.exit(1)
+
+ def package(self,id,status,summary):
+ '''
+ send 'package' signal
+ @param status: 1 = Installed, 0 = not
+ @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
+ @param summary: The package Summary
+ '''
+ print >> sys.stdout,"package\t%s\t%s\t%s" % (status,id,summary)
+
+ def status(self,state):
+ '''
+ send 'status' signal
+ @param state: STATE_DOWNLOAD, STATE_INSTALL, STATE_UPDATE, STATE_REMOVE
+ '''
+ print >> sys.stderr,"status\t%s" % (state)
+
+ def data(self,data):
+ '''
+ send 'data' signal:
+ @param data: The current worked on package
+ '''
+ print >> sys.stderr,"data\t%s" % (data)
+
+ def description(self,id,licence,group,desc,url):
+ '''
+ Send 'description' signal
+ @param id: The package ID name, e.g. openoffice-clipart;2.6.22;ppc64;fedora
+ @param licence: The licence of the package
+ @param group: The enumerated group
+ @param desc: The multi line package description
+ @param url: The upstream project homepage
+ '''
+ print >> sys.stdout,"description\t%s\t%s\t%s\t%s\t%s" % (id,licence,group,desc,url)
+
+ def require_restart(self,restart_type,details):
+ '''
+ Send 'requirerestart' signal
+ @param restart_type: RESTART_SYSTEM, RESTART_APPLICATION,RESTART_SESSION
+ @param details: Optional details about the restart
+ '''
+ print >> sys.stderr,"requirerestart\t%s\t%s" % (restart_type,details)
+
+ def allow_interrupt(self,allow):
+ '''
+ send 'allow-interrupt' signal:
+ @param allow: Allow the current process to be aborted.
+ '''
+ if allow:
+ data = 'true'
+ else:
+ data = 'false'
+ print >> sys.stderr,"allow-interrupt\t%s" % (data)
+
+ def get_package_id(self,name,version,arch,data):
+ return "%s;%s;%s;%s" % (name,version,arch,data)
+
+ def get_package_from_id(self,id):
+ ''' split up a package id name;ver;arch;data into a tuple
+ containing (name,ver,arch,data)
+ '''
+ return tuple(id.split(';'))
+#
+# Backend Action Methods
+#
+
+ def search_name(self,filters,key):
+ '''
+ Implement the {backend}-search-name functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def search_details(self,filters,key):
+ '''
+ Implement the {backend}-search-details functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def search_group(self,filters,key):
+ '''
+ Implement the {backend}-search-group functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def search_file(self,filters,key):
+ '''
+ Implement the {backend}-search-file functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+
+ def get_update_detail(self,package):
+ '''
+ Implement the {backend}-get-update-detail functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def get_depends(self,package):
+ '''
+ Implement the {backend}-get-depends functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def get_requires(self,package):
+ '''
+ Implement the {backend}-get-requires functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def update_system(self):
+ '''
+ Implement the {backend}-update-system functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+
+ def refresh_cache(self):
+ '''
+ Implement the {backend}-refresh_cache functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def install(self, package):
+ '''
+ Implement the {backend}-install functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def remove(self, allowdep, package):
+ '''
+ Implement the {backend}-remove functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def update(self, package):
+ '''
+ Implement the {backend}-update functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def get_description(self, package):
+ '''
+ Implement the {backend}-get-description functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
+ def get_updates(self, package):
+ '''
+ Implement the {backend}-get-updates functionality
+ Needed to be implemented in a sub class
+ '''
+ self.error(ERROR_NOT_SUPPORTED,"This function is not implemented in this backend")
+
diff-tree 9310d28d723cbdae1c5ef31e78014b0d0a581dff (from d4f267d2d2f98b21ded39c95ecec463c6a6c843c)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 25 08:02:48 2007 +0100
wait for install and remove to finish
diff --git a/client/pk-console.c b/client/pk-console.c
index 1af6b55..4714f29 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -257,6 +257,7 @@ pk_console_parse_multiple_commands (PkCl
goto out;
} else {
pk_client_install_package (client, value);
+ pk_client_wait ();
remove = 2;
}
} else if (strcmp (mode, "remove") == 0) {
@@ -266,6 +267,7 @@ pk_console_parse_multiple_commands (PkCl
goto out;
} else {
pk_client_remove_package (client, value, FALSE);
+ pk_client_wait ();
remove = 2;
}
} else if (strcmp (mode, "resolve") == 0) {
@@ -275,6 +277,7 @@ pk_console_parse_multiple_commands (PkCl
goto out;
} else {
pk_warning ("TODO!");
+ pk_client_wait ();
remove = 2;
}
} else if (strcmp (mode, "get") == 0) {
diff-tree d4f267d2d2f98b21ded39c95ecec463c6a6c843c (from 0272febd715a2675d1207510bb25549e5e3029c2)
Author: Richard Hughes <richard at hughsie.com>
Date: Tue Sep 25 07:41:39 2007 +0100
oops, I forgot to do dbus_g_method_return at the end of an async method (and therefor the methods timed out...)
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 01bfe25..053cbd6 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1218,6 +1218,7 @@ pk_engine_update_system (PkEngine *engin
return;
}
pk_engine_item_add (engine, item);
+ dbus_g_method_return (context);
}
/**
@@ -1277,6 +1278,7 @@ pk_engine_remove_package (PkEngine *engi
return;
}
pk_engine_item_add (engine, item);
+ dbus_g_method_return (context);
}
/**
@@ -1338,6 +1340,7 @@ pk_engine_install_package (PkEngine *eng
return;
}
pk_engine_item_add (engine, item);
+ dbus_g_method_return (context);
}
/**
@@ -1399,6 +1402,7 @@ pk_engine_install_file (PkEngine *engine
return;
}
pk_engine_item_add (engine, item);
+ dbus_g_method_return (context);
}
/**
@@ -1460,6 +1464,7 @@ pk_engine_update_package (PkEngine *engi
return;
}
pk_engine_item_add (engine, item);
+ dbus_g_method_return (context);
}
/**
diff-tree 0272febd715a2675d1207510bb25549e5e3029c2 (from 2ca20bea349b11111f945e2d837e31846551e5d1)
Author: Elliot Peele <elliot at bentlogic.net>
Date: Mon Sep 24 22:27:15 2007 -0400
request absolute changesets
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 1a1806b..0a7960a 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -169,7 +169,7 @@ class PackageKitConaryBackend(PackageKit
if name.startswith('-'):
applyList = [(name, (version, flavor), (None, None), False)]
else:
- applyList = [(name, (None, None), (version, flavor), False)]
+ applyList = [(name, (None, None), (version, flavor), True)]
updJob, suggMap = self._do_update(applyList, apply=apply)
return updJob, suggMap
diff-tree 2ca20bea349b11111f945e2d837e31846551e5d1 (from 67ed4086cd735818ea86a739718a4391d3ff0f64)
Author: Elliot Peele <elliot at bentlogic.net>
Date: Mon Sep 24 22:17:01 2007 -0400
switch check to the correct method
diff --git a/backends/conary/helpers/conaryBackend.py b/backends/conary/helpers/conaryBackend.py
index 363dcdc..1a1806b 100644
--- a/backends/conary/helpers/conaryBackend.py
+++ b/backends/conary/helpers/conaryBackend.py
@@ -37,7 +37,7 @@ class PackageKitConaryBackend(PackageKit
def get_package_id(self, name, versionObj, flavor=None):
version = versionObj.trailingRevision()
fullVersion = versionObj.asString()
- if flavor is not None and flavor != 'noarch':
+ if flavor is not None:
arch = self._get_arch(flavor)
else:
arch = ""
@@ -53,7 +53,7 @@ class PackageKitConaryBackend(PackageKit
else:
version = None
- if archString:
+ if archString and archString != 'noarch':
arches = 'is: %s' % ' '.join(archString.split(','))
flavor = deps.parseFlavor(arches)
else:
diff-tree 67ed4086cd735818ea86a739718a4391d3ff0f64 (from 9067cce6f1fcfd683dad1c2e7aa6e596a6419fdf)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 23:36:58 2007 +0100
remove stuff we don't use
diff --git a/client/pk-console.c b/client/pk-console.c
index d2ec9e2..1af6b55 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -374,29 +374,6 @@ out:
}
/**
- * pk_console_tidy_up_sync:
- **/
-static void
-pk_console_tidy_up_sync (PkClient *client)
-{
- PkClientPackageItem *item;
- GPtrArray *packages;
- guint i;
- guint length;
- gboolean sync;
-
- sync = FALSE;
- if (sync == TRUE) {
- packages = pk_client_get_package_buffer (client);
- length = packages->len;
- for (i=0; i<length; i++) {
- item = g_ptr_array_index (packages, i);
- pk_console_package_cb (client, item->value, item->package_id, item->summary, NULL);
- }
- }
-}
-
-/**
* pk_console_finished_cb:
**/
static void
@@ -494,9 +471,6 @@ main (int argc, char *argv[])
pk_console_parse_multiple_commands (client, array);
}
- /* if we are sync then print the package lists */
- pk_console_tidy_up_sync (client);
-
g_ptr_array_free (array, TRUE);
g_object_unref (client);
diff --git a/libpackagekit/README b/libpackagekit/README
index 07d2532..1ca01bb 100644
--- a/libpackagekit/README
+++ b/libpackagekit/README
@@ -1,4 +1,3 @@
-PkClient Do action, wait until completion
PkClient Watch a single job for changes
PkJobList Watch the job list for changes (list of jobs)
PkTaskList Watch the job list and emit signals for tasks in job list
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 0f316d5..5dfafcc 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -50,11 +50,10 @@ struct PkClientPrivate
{
DBusGConnection *connection;
DBusGProxy *proxy;
- gboolean assigned;
gboolean is_finished;
gboolean use_buffer;
gchar *tid;
- GPtrArray *package_items;
+ GPtrArray *cache_package;
PkConnection *pconnection;
PkPolkitClient *polkit;
PkRestartEnum require_restart;
@@ -163,22 +162,22 @@ pk_client_get_package_buffer (PkClient *
if (client->priv->use_buffer == FALSE) {
return NULL;
}
- return client->priv->package_items;
+ return client->priv->cache_package;
}
/**
- * pk_client_remove_package_items:
+ * pk_client_remove_cache_package:
**/
static void
-pk_client_remove_package_items (PkClient *client)
+pk_client_remove_cache_package (PkClient *client)
{
PkClientPackageItem *item;
- while (client->priv->package_items->len > 0) {
- item = g_ptr_array_index (client->priv->package_items, 0);
+ while (client->priv->cache_package->len > 0) {
+ item = g_ptr_array_index (client->priv->cache_package, 0);
g_free (item->package_id);
g_free (item->summary);
g_free (item);
- g_ptr_array_remove_index_fast (client->priv->package_items, 0);
+ g_ptr_array_remove_index_fast (client->priv->cache_package, 0);
}
}
@@ -194,12 +193,13 @@ pk_client_reset (PkClient *client)
if (client->priv->is_finished != TRUE) {
pk_warning ("not exit status, reset might be invalid");
}
- client->priv->assigned = FALSE;
+ g_free (client->priv->tid);
+ client->priv->tid = NULL;
client->priv->use_buffer = FALSE;
client->priv->tid = NULL;
client->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
client->priv->is_finished = FALSE;
- pk_client_remove_package_items (client);
+ pk_client_remove_cache_package (client);
return TRUE;
}
@@ -269,7 +269,7 @@ pk_client_percentage_changed_cb (DBusGPr
*/
static void
pk_client_sub_percentage_changed_cb (DBusGProxy *proxy,
- const gchar *tid,
+ const gchar *tid,
guint percentage,
PkClient *client)
{
@@ -347,7 +347,7 @@ pk_client_package_cb (DBusGProxy *prox
item->value = value;
item->package_id = g_strdup (package_id);
item->summary = g_strdup (summary);
- g_ptr_array_add (client->priv->package_items, item);
+ g_ptr_array_add (client->priv->cache_package, item);
}
}
}
@@ -677,8 +677,8 @@ pk_client_cancel (PkClient *client)
g_return_val_if_fail (client != NULL, FALSE);
g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
- /* check to see if we have an action */
- if (client->priv->assigned == FALSE) {
+ /* check to see if we have an tid */
+ if (client->priv->tid == NULL) {
pk_warning ("Transaction ID not set");
return FALSE;
}
@@ -1641,12 +1641,11 @@ pk_client_init (PkClient *client)
client->priv = PK_CLIENT_GET_PRIVATE (client);
client->priv->tid = NULL;
- client->priv->assigned = FALSE;
client->priv->use_buffer = FALSE;
client->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
client->priv->require_restart = PK_RESTART_ENUM_NONE;
client->priv->is_finished = FALSE;
- client->priv->package_items = g_ptr_array_new ();
+ client->priv->cache_package = g_ptr_array_new ();
/* check dbus connections, exit if not valid */
client->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
@@ -1802,8 +1801,8 @@ pk_client_finalize (GObject *object)
g_object_unref (client->priv->polkit);
/* removed any cached packages */
- pk_client_remove_package_items (client);
- g_ptr_array_free (client->priv->package_items, TRUE);
+ pk_client_remove_cache_package (client);
+ g_ptr_array_free (client->priv->cache_package, TRUE);
G_OBJECT_CLASS (pk_client_parent_class)->finalize (object);
}
diff-tree 9067cce6f1fcfd683dad1c2e7aa6e596a6419fdf (from 6f1f8b92d9ca47938dee6019e09e13922b974b79)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 23:18:06 2007 +0100
don't create two transaction_id's
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 563ab43..0f316d5 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -733,6 +733,8 @@ pk_client_allocate_transaction_id (PkCli
/* abort as the DBUS method failed */
pk_warning ("NewTid failed!");
return FALSE;
+ } else {
+ pk_debug ("Got tid: '%s'", client->priv->tid);
}
return TRUE;
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 98ad527..01bfe25 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -545,6 +545,7 @@ pk_engine_get_tid (PkEngine *engine, gch
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
item = pk_transaction_list_create (engine->priv->transaction_list);
+ pk_debug ("sending tid: '%s'", item->tid);
*tid = g_strdup (item->tid);
return TRUE;
}
@@ -1623,8 +1624,15 @@ pk_engine_get_old_transactions (PkEngine
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_transaction_list_create (engine->priv->transaction_list);
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
+ "No tid:%s", tid);
+ return FALSE;
+ }
engine->priv->sync_item = item;
+
pk_transaction_db_get_list (engine->priv->transaction_db, number);
pk_debug ("emitting finished transaction:%s, '%s', %i", item->tid, "", 0);
g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, "", 0);
diff-tree 6f1f8b92d9ca47938dee6019e09e13922b974b79 (from parents)
Merge: 20692badc4155eec0ab36d1b21070ab79df3c11c 87f8e8709297c1f403463f6d2e132d01fb105ab8
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 23:07:17 2007 +0100
Merge branch 'master' into tid
diff-tree 20692badc4155eec0ab36d1b21070ab79df3c11c (from b45c5060f07b8acc10927f7770029099a3df88da)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 22:32:12 2007 +0100
no need to get two proxies
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index da879a6..563ab43 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -1670,14 +1670,6 @@ pk_client_init (PkClient *client)
}
client->priv->proxy = proxy;
- /* get a connection */
- proxy = dbus_g_proxy_new_for_name (client->priv->connection,
- PK_DBUS_SERVICE, PK_DBUS_PATH, PK_DBUS_INTERFACE);
- if (proxy == NULL) {
- g_error ("Cannot connect to PackageKit.");
- }
- client->priv->proxy = proxy;
-
/* use PolicyKit */
client->priv->polkit = pk_polkit_client_new ();
diff-tree b45c5060f07b8acc10927f7770029099a3df88da (from 28dd4cee067fbb4623c5f67203e8b6689afc19aa)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 22:23:28 2007 +0100
allocate a transaction id for GetOldTransactions
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index f49b169..da879a6 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -1481,8 +1481,16 @@ pk_client_get_old_transactions (PkClient
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, "GetOldTransactions", &error,
+ G_TYPE_STRING, client->priv->tid,
G_TYPE_UINT, number,
G_TYPE_INVALID,
G_TYPE_INVALID);
diff-tree 28dd4cee067fbb4623c5f67203e8b6689afc19aa (from f44f087c2f742973860f6c61aa751e83c35f0666)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 22:22:44 2007 +0100
cruft
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 2a7dbc5..98ad527 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -1626,15 +1626,10 @@ pk_engine_get_old_transactions (PkEngine
item = pk_transaction_list_create (engine->priv->transaction_list);
engine->priv->sync_item = item;
pk_transaction_db_get_list (engine->priv->transaction_db, number);
-// pk_engine_finished_cb ();
-
pk_debug ("emitting finished transaction:%s, '%s', %i", item->tid, "", 0);
g_signal_emit (engine, signals [PK_ENGINE_FINISHED], 0, item->tid, "", 0);
-
pk_transaction_list_remove (engine->priv->transaction_list, item);
-
return TRUE;
-//xxx
}
/**
diff-tree f44f087c2f742973860f6c61aa751e83c35f0666 (from cb7a9cc268aae3596e84d9bb020a92732a1c81c2)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 21:57:31 2007 +0100
make the daemon work
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 9105172..2a7dbc5 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -478,8 +478,6 @@ pk_engine_new_backend (PkEngine *engine)
/* initialise some stuff */
pk_engine_reset_timer (engine);
- pk_transaction_list_create (engine->priv->transaction_list);
-
/* we don't add to the array or do the transaction-list-changed yet
* as this transaction might fail */
return backend;
@@ -497,7 +495,7 @@ pk_engine_item_add (PkEngine *engine, Pk
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* commit, so it appears in the JobList */
- pk_transaction_list_commit (engine->priv->transaction_list, item->backend);
+ pk_transaction_list_commit (engine->priv->transaction_list, item);
/* only save into the database for useful stuff */
pk_backend_get_role (item->backend, &role, NULL);
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index fc271cf..318468d 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -192,18 +192,14 @@ pk_transaction_list_number_running (PkTr
* pk_transaction_list_commit:
**/
gboolean
-pk_transaction_list_commit (PkTransactionList *tlist, PkBackend *backend)
+pk_transaction_list_commit (PkTransactionList *tlist, PkTransactionItem *item)
{
PkRoleEnum role;
gboolean search_okay = TRUE;
- PkTransactionItem *item;
+
g_return_val_if_fail (tlist != NULL, FALSE);
g_return_val_if_fail (PK_IS_TRANSACTION_LIST (tlist), FALSE);
- item = pk_transaction_list_get_from_backend (tlist, backend);
- if (item == NULL) {
- return FALSE;
- }
pk_debug ("marking transaction %s as committed", item->tid);
item->committed = TRUE;
@@ -212,7 +208,7 @@ pk_transaction_list_commit (PkTransactio
g_signal_emit (tlist, signals [PK_TRANSACTION_LIST_CHANGED], 0);
/* connect up finished so we can start the next backend */
- g_signal_connect (backend, "finished",
+ g_signal_connect (item->backend, "finished",
G_CALLBACK (pk_transaction_list_backend_finished_cb), tlist);
/* if we are refreshing the cache then nothing is sacred */
@@ -223,14 +219,14 @@ pk_transaction_list_commit (PkTransactio
/* if it's a query then just do the action (if safe) */
if (search_okay == TRUE) {
- pk_backend_get_role (backend, &role, NULL);
+ pk_backend_get_role (item->backend, &role, NULL);
if (role == PK_ROLE_ENUM_SEARCH_NAME ||
role == PK_ROLE_ENUM_SEARCH_FILE ||
role == PK_ROLE_ENUM_SEARCH_GROUP ||
role == PK_ROLE_ENUM_SEARCH_DETAILS) {
pk_debug ("running %s", item->tid);
item->running = TRUE;
- pk_backend_run (backend);
+ pk_backend_run (item->backend);
return TRUE;
}
}
@@ -239,7 +235,7 @@ pk_transaction_list_commit (PkTransactio
if (pk_transaction_list_number_running (tlist) == 0) {
pk_debug ("running %s", item->tid);
item->running = TRUE;
- pk_backend_run (backend);
+ pk_backend_run (item->backend);
}
return TRUE;
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index 34fe561..ba7c6bf 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -63,7 +63,7 @@ PkTransactionItem *pk_transaction_list_c
gboolean pk_transaction_list_remove (PkTransactionList *tlist,
PkTransactionItem *item);
gboolean pk_transaction_list_commit (PkTransactionList *tlist,
- PkBackend *backend);
+ PkTransactionItem *item);
gboolean pk_transaction_list_role_present (PkTransactionList *tlist,
PkRoleEnum role);
gchar **pk_transaction_list_get_array (PkTransactionList *tlist);
diff-tree cb7a9cc268aae3596e84d9bb020a92732a1c81c2 (from dada6e2084b3cee197844c4cf6494f2e74febf79)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 21:46:54 2007 +0100
use PkClient
diff --git a/client/pk-console.c b/client/pk-console.c
index 03e541e..d2ec9e2 100644
--- a/client/pk-console.c
+++ b/client/pk-console.c
@@ -29,10 +29,12 @@
#include <dbus/dbus-glib.h>
#include <pk-debug.h>
-#include <pk-task-client.h>
+#include <pk-client.h>
#include <pk-package-id.h>
#include <pk-enum-list.h>
+static GMainLoop *loop = NULL;
+
/**
* pk_console_make_space:
**/
@@ -59,7 +61,7 @@ pk_console_make_space (const gchar *data
* pk_console_package_cb:
**/
static void
-pk_console_package_cb (PkTaskClient *tclient, guint value, const gchar *package_id, const gchar *summary, gpointer data)
+pk_console_package_cb (PkClient *client, guint value, const gchar *package_id, const gchar *summary, gpointer data)
{
PkPackageId *ident;
PkPackageId *spacing;
@@ -99,7 +101,7 @@ pk_console_package_cb (PkTaskClient *tcl
* pk_console_transaction_cb:
**/
static void
-pk_console_transaction_cb (PkTaskClient *tclient, const gchar *tid, const gchar *timespec,
+pk_console_transaction_cb (PkClient *client, const gchar *tid, const gchar *timespec,
gboolean succeeded, const gchar *role, guint duration, gpointer data)
{
g_print ("tid : %s\n", tid);
@@ -113,7 +115,7 @@ pk_console_transaction_cb (PkTaskClient
* pk_console_update_detail_cb:
**/
static void
-pk_console_update_detail_cb (PkTaskClient *tclient, const gchar *package_id,
+pk_console_update_detail_cb (PkClient *client, const gchar *package_id,
const gchar *updates, const gchar *obsoletes,
const gchar *url, const gchar *restart,
const gchar *update_text, gpointer data)
@@ -131,7 +133,7 @@ pk_console_update_detail_cb (PkTaskClien
* pk_console_percentage_changed_cb:
**/
static void
-pk_console_percentage_changed_cb (PkTaskClient *tclient, guint percentage, gpointer data)
+pk_console_percentage_changed_cb (PkClient *client, guint percentage, gpointer data)
{
g_print ("%i%%\n", percentage);
}
@@ -146,32 +148,44 @@ pk_console_usage (const gchar *error)
g_print ("Error: %s\n", error);
}
g_print ("usage:\n");
- g_print (" pkcon [sync] [verbose] search name|details|group|file data\n");
- g_print (" pkcon [sync] [verbose] install <package_id>\n");
- g_print (" pkcon [sync] [verbose] remove <package_id>\n");
- g_print (" pkcon [sync] [verbose] update <package_id>\n");
- g_print (" pkcon [sync] [verbose] refresh\n");
- g_print (" pkcon [sync] [verbose] resolve\n");
- g_print (" pkcon [sync] [verbose] force-refresh\n");
- g_print (" pkcon [sync] [verbose] update-system\n");
- g_print (" pkcon [sync] [verbose] get updates\n");
- g_print (" pkcon [sync] [verbose] get depends <package_id>\n");
- g_print (" pkcon [sync] [verbose] get requires <package_id>\n");
- g_print (" pkcon [sync] [verbose] get description <package_id>\n");
- g_print (" pkcon [sync] [verbose] get updatedetail <package_id>\n");
- g_print (" pkcon [sync] [verbose] get actions\n");
- g_print (" pkcon [sync] [verbose] get groups\n");
- g_print (" pkcon [sync] [verbose] get filters\n");
- g_print (" pkcon [sync] [verbose] get transactions\n");
+ g_print (" pkcon [verbose] search name|details|group|file data\n");
+ g_print (" pkcon [verbose] install <package_id>\n");
+ g_print (" pkcon [verbose] remove <package_id>\n");
+ g_print (" pkcon [verbose] update <package_id>\n");
+ g_print (" pkcon [verbose] refresh\n");
+ g_print (" pkcon [verbose] resolve\n");
+ g_print (" pkcon [verbose] force-refresh\n");
+ g_print (" pkcon [verbose] update-system\n");
+ g_print (" pkcon [verbose] get updates\n");
+ g_print (" pkcon [verbose] get depends <package_id>\n");
+ g_print (" pkcon [verbose] get requires <package_id>\n");
+ g_print (" pkcon [verbose] get description <package_id>\n");
+ g_print (" pkcon [verbose] get updatedetail <package_id>\n");
+ g_print (" pkcon [verbose] get actions\n");
+ g_print (" pkcon [verbose] get groups\n");
+ g_print (" pkcon [verbose] get filters\n");
+ g_print (" pkcon [verbose] get transactions\n");
g_print ("\n");
g_print (" package_id is typically gimp;2:2.4.0-0.rc1.1.fc8;i386;development\n");
}
/**
+ * pk_client_wait:
+ **/
+static gboolean
+pk_client_wait (void)
+{
+ pk_debug ("starting loop");
+ loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (loop);
+ return TRUE;
+}
+
+/**
* pk_console_parse_multiple_commands:
**/
static void
-pk_console_parse_multiple_commands (PkTaskClient *tclient, GPtrArray *array)
+pk_console_parse_multiple_commands (PkClient *client, GPtrArray *array)
{
const gchar *mode;
const gchar *value = NULL;
@@ -199,8 +213,8 @@ pk_console_parse_multiple_commands (PkTa
remove = 2;
goto out;
} else {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_search_name (tclient, "none", details);
+ pk_client_search_name (client, "none", details);
+ pk_client_wait ();
remove = 3;
}
} else if (strcmp (value, "details") == 0) {
@@ -209,8 +223,8 @@ pk_console_parse_multiple_commands (PkTa
remove = 2;
goto out;
} else {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_search_details (tclient, "none", details);
+ pk_client_search_details (client, "none", details);
+ pk_client_wait ();
remove = 3;
}
} else if (strcmp (value, "group") == 0) {
@@ -219,8 +233,8 @@ pk_console_parse_multiple_commands (PkTa
remove = 2;
goto out;
} else {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_search_group (tclient, "none", details);
+ pk_client_search_group (client, "none", details);
+ pk_client_wait ();
remove = 3;
}
} else if (strcmp (value, "file") == 0) {
@@ -229,8 +243,8 @@ pk_console_parse_multiple_commands (PkTa
remove = 2;
goto out;
} else {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_search_file (tclient, "none", details);
+ pk_client_search_file (client, "none", details);
+ pk_client_wait ();
remove = 3;
}
} else {
@@ -242,7 +256,7 @@ pk_console_parse_multiple_commands (PkTa
remove = 1;
goto out;
} else {
- pk_task_client_install_package (tclient, value);
+ pk_client_install_package (client, value);
remove = 2;
}
} else if (strcmp (mode, "remove") == 0) {
@@ -251,7 +265,7 @@ pk_console_parse_multiple_commands (PkTa
remove = 1;
goto out;
} else {
- pk_task_client_remove_package (tclient, value, FALSE);
+ pk_client_remove_package (client, value, FALSE);
remove = 2;
}
} else if (strcmp (mode, "resolve") == 0) {
@@ -274,8 +288,8 @@ pk_console_parse_multiple_commands (PkTa
remove = 2;
goto out;
} else {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_get_depends (tclient, details);
+ pk_client_get_depends (client, details);
+ pk_client_wait ();
remove = 3;
}
} else if (strcmp (value, "updatedetail") == 0) {
@@ -284,8 +298,8 @@ pk_console_parse_multiple_commands (PkTa
remove = 2;
goto out;
} else {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_get_update_detail (tclient, details);
+ pk_client_get_update_detail (client, details);
+ pk_client_wait ();
remove = 3;
}
} else if (strcmp (value, "requires") == 0) {
@@ -294,8 +308,8 @@ pk_console_parse_multiple_commands (PkTa
remove = 2;
goto out;
} else {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_get_requires (tclient, details);
+ pk_client_get_requires (client, details);
+ pk_client_wait ();
remove = 3;
}
} else if (strcmp (value, "description") == 0) {
@@ -304,32 +318,32 @@ pk_console_parse_multiple_commands (PkTa
remove = 2;
goto out;
} else {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_get_description (tclient, details);
+ pk_client_get_description (client, details);
+ pk_client_wait ();
remove = 3;
}
} else if (strcmp (value, "updates") == 0) {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_get_updates (tclient);
+ pk_client_get_updates (client);
+ pk_client_wait ();
remove = 2;
} else if (strcmp (value, "actions") == 0) {
- elist = pk_task_client_get_actions (tclient);
+ elist = pk_client_get_actions (client);
pk_enum_list_print (elist);
g_object_unref (elist);
remove = 2;
} else if (strcmp (value, "filters") == 0) {
- elist = pk_task_client_get_filters (tclient);
+ elist = pk_client_get_filters (client);
pk_enum_list_print (elist);
g_object_unref (elist);
remove = 2;
} else if (strcmp (value, "groups") == 0) {
- elist = pk_task_client_get_groups (tclient);
+ elist = pk_client_get_groups (client);
pk_enum_list_print (elist);
g_object_unref (elist);
remove = 2;
} else if (strcmp (value, "transactions") == 0) {
- pk_task_client_set_sync (tclient, TRUE);
- pk_task_client_get_old_transactions (tclient, 10);
+ pk_client_get_old_transactions (client, 10);
+ pk_client_wait ();
remove = 2;
} else {
pk_console_usage ("invalid get type");
@@ -339,15 +353,11 @@ pk_console_parse_multiple_commands (PkTa
} else if (strcmp (mode, "verbose") == 0) {
pk_debug_init (TRUE);
} else if (strcmp (mode, "update-system") == 0) {
- pk_task_client_update_system (tclient);
+ pk_client_update_system (client);
} else if (strcmp (mode, "refresh") == 0) {
- pk_task_client_refresh_cache (tclient, FALSE);
+ pk_client_refresh_cache (client, FALSE);
} else if (strcmp (mode, "force-refresh") == 0) {
- pk_task_client_refresh_cache (tclient, TRUE);
- } else if (strcmp (mode, "sync") == 0) {
- pk_task_client_set_sync (tclient, TRUE);
- } else if (strcmp (mode, "async") == 0) {
- pk_task_client_set_sync (tclient, FALSE);
+ pk_client_refresh_cache (client, TRUE);
} else {
pk_console_usage ("option not yet supported");
}
@@ -367,21 +377,21 @@ out:
* pk_console_tidy_up_sync:
**/
static void
-pk_console_tidy_up_sync (PkTaskClient *tclient)
+pk_console_tidy_up_sync (PkClient *client)
{
- PkTaskClientPackageItem *item;
+ PkClientPackageItem *item;
GPtrArray *packages;
guint i;
guint length;
gboolean sync;
- sync = pk_task_client_get_sync (tclient);
+ sync = FALSE;
if (sync == TRUE) {
- packages = pk_task_client_get_package_buffer (tclient);
+ packages = pk_client_get_package_buffer (client);
length = packages->len;
for (i=0; i<length; i++) {
item = g_ptr_array_index (packages, i);
- pk_console_package_cb (tclient, item->value, item->package_id, item->summary, NULL);
+ pk_console_package_cb (client, item->value, item->package_id, item->summary, NULL);
}
}
}
@@ -390,16 +400,19 @@ pk_console_tidy_up_sync (PkTaskClient *t
* pk_console_finished_cb:
**/
static void
-pk_console_finished_cb (PkTaskClient *tclient, PkStatusEnum status, guint runtime, gpointer data)
+pk_console_finished_cb (PkClient *client, PkStatusEnum status, guint runtime, gpointer data)
{
g_print ("Runtime was %i seconds\n", runtime);
+ if (loop != NULL) {
+ g_main_loop_quit (loop);
+ }
}
/**
* pk_console_error_code_cb:
**/
static void
-pk_console_error_code_cb (PkTaskClient *tclient, PkErrorCodeEnum error_code, const gchar *details, gpointer data)
+pk_console_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gchar *details, gpointer data)
{
g_print ("Error: %s : %s\n", pk_error_enum_to_text (error_code), details);
}
@@ -408,7 +421,7 @@ pk_console_error_code_cb (PkTaskClient *
* pk_console_description_cb:
**/
static void
-pk_console_description_cb (PkTaskClient *tclient, const gchar *package_id,
+pk_console_description_cb (PkClient *client, const gchar *package_id,
const gchar *licence, PkGroupEnum group,
const gchar *description, const gchar *url, gpointer data)
{
@@ -428,7 +441,7 @@ main (int argc, char *argv[])
{
DBusGConnection *system_connection;
GError *error = NULL;
- PkTaskClient *tclient;
+ PkClient *client;
GPtrArray *array;
guint i;
@@ -455,20 +468,20 @@ main (int argc, char *argv[])
return 1;
}
- tclient = pk_task_client_new ();
- g_signal_connect (tclient, "package",
+ client = pk_client_new ();
+ g_signal_connect (client, "package",
G_CALLBACK (pk_console_package_cb), NULL);
- g_signal_connect (tclient, "transaction",
+ g_signal_connect (client, "transaction",
G_CALLBACK (pk_console_transaction_cb), NULL);
- g_signal_connect (tclient, "description",
+ g_signal_connect (client, "description",
G_CALLBACK (pk_console_description_cb), NULL);
- g_signal_connect (tclient, "update-detail",
+ g_signal_connect (client, "update-detail",
G_CALLBACK (pk_console_update_detail_cb), NULL);
- g_signal_connect (tclient, "percentage-changed",
+ g_signal_connect (client, "percentage-changed",
G_CALLBACK (pk_console_percentage_changed_cb), NULL);
- g_signal_connect (tclient, "finished",
+ g_signal_connect (client, "finished",
G_CALLBACK (pk_console_finished_cb), NULL);
- g_signal_connect (tclient, "error-code",
+ g_signal_connect (client, "error-code",
G_CALLBACK (pk_console_error_code_cb), NULL);
/* add argv to a pointer array */
@@ -478,14 +491,14 @@ main (int argc, char *argv[])
}
/* process all the commands */
while (array->len > 0) {
- pk_console_parse_multiple_commands (tclient, array);
+ pk_console_parse_multiple_commands (client, array);
}
/* if we are sync then print the package lists */
- pk_console_tidy_up_sync (tclient);
+ pk_console_tidy_up_sync (client);
g_ptr_array_free (array, TRUE);
- g_object_unref (tclient);
+ g_object_unref (client);
return 0;
}
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index 18d8d47..4d60534 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -32,8 +32,6 @@ libpackagekit_include_HEADERS = \
pk-enum.h \
pk-task-common.h \
pk-client.h \
- pk-task-monitor.h \
- pk-task-client.h \
pk-task-list.h \
pk-job-list.h \
pk-polkit-client.h \
@@ -56,10 +54,6 @@ libpackagekit_la_SOURCES = \
pk-task-common.h \
pk-client.c \
pk-client.h \
- pk-task-monitor.c \
- pk-task-monitor.h \
- pk-task-client.c \
- pk-task-client.h \
pk-task-list.c \
pk-task-list.h \
pk-job-list.c \
diff --git a/libpackagekit/README b/libpackagekit/README
index 845a440..07d2532 100644
--- a/libpackagekit/README
+++ b/libpackagekit/README
@@ -1,5 +1,5 @@
-PkTaskClient Do action, wait until completion
-PkTaskMonitor Watch a single job for changes
+PkClient Do action, wait until completion
+PkClient Watch a single job for changes
PkJobList Watch the job list for changes (list of jobs)
PkTaskList Watch the job list and emit signals for tasks in job list
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index cbf28ce..f49b169 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -713,9 +713,8 @@ pk_client_allocate_transaction_id (PkCli
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");
+ if (client->priv->tid != NULL) {
+ pk_warning ("Already has transaction ID");
return FALSE;
}
diff --git a/libpackagekit/pk-job-list.c b/libpackagekit/pk-job-list.c
index 24e54c9..0b5a1db 100644
--- a/libpackagekit/pk-job-list.c
+++ b/libpackagekit/pk-job-list.c
@@ -178,7 +178,7 @@ pk_job_list_class_init (PkJobListClass *
}
/**
- * pk_task_monitor_connect:
+ * pk_client_connect:
**/
static void
pk_job_list_connect (PkJobList *jlist)
diff --git a/libpackagekit/pk-task-client.c b/libpackagekit/pk-task-client.c
deleted file mode 100644
index 5acd644..0000000
--- a/libpackagekit/pk-task-client.c
+++ /dev/null
@@ -1,1480 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <string.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
-
-#include "pk-debug.h"
-#include "pk-marshal.h"
-#include "pk-connection.h"
-#include "pk-task-common.h"
-#include "pk-task-client.h"
-#include "pk-task-monitor.h"
-#include "pk-polkit-client.h"
-
-static void pk_task_client_class_init (PkTaskClientClass *klass);
-static void pk_task_client_init (PkTaskClient *task_client);
-static void pk_task_client_finalize (GObject *object);
-
-#define PK_TASK_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_TASK_CLIENT, PkTaskClientPrivate))
-
-struct PkTaskClientPrivate
-{
- DBusGConnection *connection;
- DBusGProxy *proxy;
- gboolean assigned;
- gboolean is_sync;
- gboolean use_buffer;
- gchar *tid;
- GMainLoop *loop;
- PkStatusEnum last_status;
- PkTaskMonitor *tmonitor;
- PkConnection *pconnection;
- PkPolkitClient *polkit;
- PkRestartEnum require_restart;
- gboolean is_finished;
- GPtrArray *package_items;
-};
-
-typedef enum {
- PK_TASK_CLIENT_TRANSACTION_STATUS_CHANGED,
- PK_TASK_CLIENT_PERCENTAGE_CHANGED,
- PK_TASK_CLIENT_SUB_PERCENTAGE_CHANGED,
- PK_TASK_CLIENT_NO_PERCENTAGE_UPDATES,
- PK_TASK_CLIENT_PACKAGE,
- PK_TASK_CLIENT_TRANSACTION,
- PK_TASK_CLIENT_UPDATE_DETAIL,
- PK_TASK_CLIENT_DESCRIPTION,
- PK_TASK_CLIENT_ERROR_CODE,
- PK_TASK_CLIENT_FINISHED,
- PK_TASK_CLIENT_LAST_SIGNAL
-} PkSignals;
-
-static guint signals [PK_TASK_CLIENT_LAST_SIGNAL] = { 0, };
-
-G_DEFINE_TYPE (PkTaskClient, pk_task_client, G_TYPE_OBJECT)
-
-/**
- * pk_task_client_set_use_buffer:
- **/
-gboolean
-pk_task_client_set_use_buffer (PkTaskClient *tclient, gboolean use_buffer)
-{
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- tclient->priv->use_buffer = use_buffer;
- return TRUE;
-}
-
-/**
- * pk_task_client_get_use_buffer:
- **/
-gboolean
-pk_task_client_get_use_buffer (PkTaskClient *tclient)
-{
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- return tclient->priv->use_buffer;
-}
-
-/**
- * pk_task_client_get_use_buffer:
- **/
-PkRestartEnum
-pk_task_client_get_require_restart (PkTaskClient *tclient)
-{
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- return tclient->priv->require_restart;
-}
-
-/**
- * pk_task_client_set_sync:
- **/
-gboolean
-pk_task_client_set_sync (PkTaskClient *tclient, gboolean is_sync)
-{
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- tclient->priv->is_sync = is_sync;
- tclient->priv->use_buffer = is_sync;
- return TRUE;
-}
-
-/**
- * pk_task_client_get_sync:
- **/
-gboolean
-pk_task_client_get_sync (PkTaskClient *tclient)
-{
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- return tclient->priv->is_sync;
-}
-
-/**
- * pk_task_client_wait_if_sync:
- **/
-static gboolean
-pk_task_client_wait_if_sync (PkTaskClient *tclient)
-{
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- pk_debug ("starting loop");
- if (tclient->priv->is_sync == TRUE) {
- tclient->priv->loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (tclient->priv->loop);
- }
- return TRUE;
-}
-
-/**
- * pk_task_client_get_package_buffer:
- **/
-GPtrArray *
-pk_task_client_get_package_buffer (PkTaskClient *tclient)
-{
- if (tclient->priv->use_buffer == FALSE) {
- return NULL;
- }
- return tclient->priv->package_items;
-}
-
-/**
- * pk_task_client_remove_package_items:
- **/
-static void
-pk_task_client_remove_package_items (PkTaskClient *tclient)
-{
- PkTaskClientPackageItem *item;
- while (tclient->priv->package_items->len > 0) {
- item = g_ptr_array_index (tclient->priv->package_items, 0);
- g_free (item->package_id);
- g_free (item->summary);
- g_free (item);
- g_ptr_array_remove_index_fast (tclient->priv->package_items, 0);
- }
-}
-
-/**
- * pk_task_client_reset:
- **/
-gboolean
-pk_task_client_reset (PkTaskClient *tclient)
-{
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- if (tclient->priv->is_finished != TRUE) {
- pk_warning ("not exit status, reset might be invalid");
- }
- tclient->priv->assigned = FALSE;
- tclient->priv->is_sync = FALSE;
- tclient->priv->use_buffer = FALSE;
- tclient->priv->tid = NULL;
- tclient->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
- tclient->priv->is_finished = FALSE;
- pk_task_client_remove_package_items (tclient);
- return TRUE;
-}
-
-/**
- * pk_task_client_get_error_name:
- **/
-static const gchar *
-pk_task_client_get_error_name (GError *error)
-{
- const gchar *name;
- if (error->domain == DBUS_GERROR &&
- error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
- name = dbus_g_error_get_name (error);
- } else {
- name = g_quark_to_string (error->domain);
- }
- return name;
-}
-
-/**
- * pk_task_client_get_updates:
- **/
-gboolean
-pk_task_client_get_updates (PkTaskClient *tclient)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
- tclient->priv->assigned = TRUE;
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetUpdates", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("GetUpdates failed!");
- return FALSE;
- }
-
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_update_system_action:
- **/
-gboolean
-pk_task_client_update_system_action (PkTaskClient *tclient, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- *error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "UpdateSystem", error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("UpdateSystem failed!");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * pk_task_client_update_system:
- **/
-gboolean
-pk_task_client_update_system (PkTaskClient *tclient)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
- tclient->priv->assigned = TRUE;
-
- /* hopefully do the operation first time */
- ret = pk_task_client_update_system_action (tclient, &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 (tclient->priv->polkit, error->message) == TRUE) {
- pk_debug ("gained priv");
- g_error_free (error);
- /* do it all over again */
- ret = pk_task_client_update_system_action (tclient, &error);
- }
- }
- if (error != NULL) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
- }
- }
-
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- if (ret == TRUE) {
- pk_task_client_wait_if_sync (tclient);
- }
-
- return ret;
-}
-
-/**
- * pk_task_client_search_name:
- **/
-gboolean
-pk_task_client_search_name (PkTaskClient *tclient, const gchar *filter, const gchar *search)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
- tclient->priv->assigned = TRUE;
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "SearchName", &error,
- G_TYPE_STRING, filter,
- G_TYPE_STRING, search,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("SearchName failed!");
- return FALSE;
- }
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_search_details:
- **/
-gboolean
-pk_task_client_search_details (PkTaskClient *tclient, const gchar *filter, const gchar *search)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "SearchDetails", &error,
- G_TYPE_STRING, filter,
- G_TYPE_STRING, search,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("SearchDetails failed!");
- return FALSE;
- }
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_search_group:
- **/
-gboolean
-pk_task_client_search_group (PkTaskClient *tclient, const gchar *filter, const gchar *search)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "SearchGroup", &error,
- G_TYPE_STRING, filter,
- G_TYPE_STRING, search,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("SearchGroup failed!");
- return FALSE;
- }
- /* only assign on success */
- tclient->priv->assigned = TRUE;
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_search_file:
- **/
-gboolean
-pk_task_client_search_file (PkTaskClient *tclient, const gchar *filter, const gchar *search)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "SearchFile", &error,
- G_TYPE_STRING, filter,
- G_TYPE_STRING, search,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("SearchFile failed!");
- return FALSE;
- }
- /* only assign on success */
- tclient->priv->assigned = TRUE;
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_get_depends:
- **/
-gboolean
-pk_task_client_get_depends (PkTaskClient *tclient, const gchar *package)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetDepends", &error,
- G_TYPE_STRING, package,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("GetDepends failed!");
- return FALSE;
- }
- /* only assign on success */
- tclient->priv->assigned = TRUE;
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_get_requires:
- **/
-gboolean
-pk_task_client_get_requires (PkTaskClient *tclient, const gchar *package)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetRequires", &error,
- G_TYPE_STRING, package,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("GetRequires failed!");
- return FALSE;
- }
- /* only assign on success */
- tclient->priv->assigned = TRUE;
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_get_update_detail:
- **/
-gboolean
-pk_task_client_get_update_detail (PkTaskClient *tclient, const gchar *package)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetUpdateDetail", &error,
- G_TYPE_STRING, package,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("GetUpdateDetail failed!");
- return FALSE;
- }
- /* only assign on success */
- tclient->priv->assigned = TRUE;
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_get_description:
- **/
-gboolean
-pk_task_client_get_description (PkTaskClient *tclient, const gchar *package)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetDescription", &error,
- G_TYPE_STRING, package,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("GetDescription failed!");
- return FALSE;
- }
- /* only assign on success */
- tclient->priv->assigned = TRUE;
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_remove_package_action:
- **/
-gboolean
-pk_task_client_remove_package_action (PkTaskClient *tclient, const gchar *package,
- gboolean allow_deps, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- *error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "RemovePackage", error,
- G_TYPE_STRING, package,
- G_TYPE_BOOLEAN, allow_deps,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("RemovePackage failed!");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * pk_task_client_remove_package:
- **/
-gboolean
-pk_task_client_remove_package (PkTaskClient *tclient, const gchar *package, gboolean allow_deps)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
- tclient->priv->assigned = TRUE;
-
- /* hopefully do the operation first time */
- ret = pk_task_client_remove_package_action (tclient, package, allow_deps, &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 (tclient->priv->polkit, error->message) == TRUE) {
- pk_debug ("gained priv");
- g_error_free (error);
- /* do it all over again */
- ret = pk_task_client_remove_package_action (tclient, package, allow_deps, &error);
- }
- }
- if (error != NULL) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
- }
- }
-
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- if (ret == TRUE) {
- pk_task_client_wait_if_sync (tclient);
- }
-
- return ret;
-}
-
-/**
- * pk_task_client_refresh_cache:
- **/
-gboolean
-pk_task_client_refresh_cache (PkTaskClient *tclient, gboolean force)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "RefreshCache", &error,
- G_TYPE_BOOLEAN, force,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (error) {
- const gchar *error_name;
- error_name = pk_task_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 ("RefreshCache failed!");
- return FALSE;
- }
- /* only assign on success */
- tclient->priv->assigned = TRUE;
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
- pk_task_client_wait_if_sync (tclient);
-
- return TRUE;
-}
-
-/**
- * pk_task_client_install_package_action:
- **/
-gboolean
-pk_task_client_install_package_action (PkTaskClient *tclient, const gchar *package, GError **error)
-{
- gboolean ret;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- *error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "InstallPackage", error,
- G_TYPE_STRING, package,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tclient->priv->tid,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("InstallPackage failed!");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * pk_task_client_install_package:
- **/
-gboolean
-pk_task_client_install_package (PkTaskClient *tclient, const gchar *package_id)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we already have an action */
- if (tclient->priv->assigned == TRUE) {
- pk_warning ("Already assigned");
- return FALSE;
- }
- tclient->priv->assigned = TRUE;
-
- /* hopefully do the operation first time */
- ret = pk_task_client_install_package_action (tclient, package_id, &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 (tclient->priv->polkit, error->message) == TRUE) {
- pk_debug ("gained priv");
- g_error_free (error);
- /* do it all over again */
- ret = pk_task_client_install_package_action (tclient, package_id, &error);
- }
- }
- if (error != NULL) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
- }
- }
-
- pk_task_monitor_set_tid (tclient->priv->tmonitor, tclient->priv->tid);
-
- /* only wait if the command succeeded. False is usually due to PolicyKit auth failure */
- if (ret == TRUE) {
- pk_task_client_wait_if_sync (tclient);
- }
-
- return ret;
-}
-
-/**
- * pk_task_client_cancel:
- **/
-gboolean
-pk_task_client_cancel (PkTaskClient *tclient)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- /* check to see if we have an action */
- if (tclient->priv->assigned == FALSE) {
- pk_warning ("Not assigned");
- return FALSE;
- }
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "Cancel", &error,
- G_TYPE_STRING, tclient->priv->tid,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("Cancel failed :%s", error->message);
- g_error_free (error);
- }
- return ret;
-}
-
-/**
- * pk_task_client_get_actions:
- **/
-PkEnumList *
-pk_task_client_get_actions (PkTaskClient *tclient)
-{
- gboolean ret;
- GError *error;
- gchar *actions;
- PkEnumList *elist;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ROLE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetActions", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &actions,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetActions failed :%s", error->message);
- g_error_free (error);
- return elist;
- }
-
- /* convert to enumerated types */
- pk_enum_list_from_string (elist, actions);
- g_free (actions);
- return elist;
-}
-
-/**
- * pk_task_client_get_backend_detail:
- **/
-gboolean
-pk_task_client_get_backend_detail (PkTaskClient *tclient, gchar **name, gchar **author, gchar **version)
-{
- gboolean ret;
- GError *error;
- gchar *tname;
- gchar *tauthor;
- gchar *tversion;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetBackendDetail", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &tname,
- G_TYPE_STRING, &tauthor,
- G_TYPE_STRING, &tversion,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetBackendDetail failed :%s", error->message);
- g_error_free (error);
- return FALSE;
- }
-
- /* copy needed bits */
- if (name != NULL) {
- *name = g_strdup (tname);
- }
- /* copy needed bits */
- if (author != NULL) {
- *author = g_strdup (tauthor);
- }
- /* copy needed bits */
- if (version != NULL) {
- *version = g_strdup (tversion);
- }
- return TRUE;
-}
-
-/**
- * pk_task_client_get_groups:
- **/
-PkEnumList *
-pk_task_client_get_groups (PkTaskClient *tclient)
-{
- gboolean ret;
- GError *error;
- gchar *groups;
- PkEnumList *elist;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_GROUP);
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetGroups", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &groups,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetGroups failed :%s", error->message);
- g_error_free (error);
- return elist;
- }
-
- /* convert to enumerated types */
- pk_enum_list_from_string (elist, groups);
- g_free (groups);
- return elist;
-}
-
-/**
- * pk_task_client_get_old_transactions:
- **/
-gboolean
-pk_task_client_get_old_transactions (PkTaskClient *tclient, guint number)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetOldTransactions", &error,
- G_TYPE_UINT, number,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetOldTransactions failed :%s", error->message);
- g_error_free (error);
- return FALSE;
- }
- pk_task_client_wait_if_sync (tclient);
- return TRUE;
-}
-
-/**
- * pk_task_client_get_filters:
- **/
-PkEnumList *
-pk_task_client_get_filters (PkTaskClient *tclient)
-{
- gboolean ret;
- GError *error;
- gchar *filters;
- PkEnumList *elist;
-
- g_return_val_if_fail (tclient != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_CLIENT (tclient), FALSE);
-
- elist = pk_enum_list_new ();
- pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_FILTER);
-
- error = NULL;
- ret = dbus_g_proxy_call (tclient->priv->proxy, "GetFilters", &error,
- G_TYPE_INVALID,
- G_TYPE_STRING, &filters,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetFilters failed :%s", error->message);
- g_error_free (error);
- return elist;
- }
-
- /* convert to enumerated types */
- pk_enum_list_from_string (elist, filters);
- g_free (filters);
- return elist;
-}
-
-/**
- * pk_task_client_finished_cb:
- */
-static void
-pk_task_client_finished_cb (PkTaskMonitor *tmonitor,
- PkExitEnum exit,
- guint runtime,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("emit finished %i, %i", exit, runtime);
- tclient->priv->is_finished = TRUE;
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_FINISHED], 0, exit, runtime);
-
- /* if we are async, then cancel */
- if (tclient->priv->loop != NULL) {
- g_main_loop_quit (tclient->priv->loop);
- }
-}
-
-/**
- * pk_task_client_percentage_changed_cb:
- */
-static void
-pk_task_client_percentage_changed_cb (PkTaskMonitor *tmonitor,
- guint percentage,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("emit percentage-changed %i", percentage);
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_PERCENTAGE_CHANGED], 0, percentage);
-}
-
-/**
- * pk_task_client_sub_percentage_changed_cb:
- */
-static void
-pk_task_client_sub_percentage_changed_cb (PkTaskMonitor *tmonitor,
- guint percentage,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("emit sub-percentage-changed %i", percentage);
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_SUB_PERCENTAGE_CHANGED], 0, percentage);
-}
-
-/**
- * pk_task_client_no_percentage_updates_cb:
- */
-static void
-pk_task_client_no_percentage_updates_cb (PkTaskMonitor *tmonitor,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("emit no-percentage-updates");
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_NO_PERCENTAGE_UPDATES], 0);
-}
-
-/**
- * pk_task_client_transaction_status_changed_cb:
- */
-static void
-pk_task_client_transaction_status_changed_cb (PkTaskMonitor *tmonitor,
- PkStatusEnum status,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("emit transaction-status-changed %i", status);
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_TRANSACTION_STATUS_CHANGED], 0, status);
- tclient->priv->last_status = status;
-}
-
-/**
- * pk_task_client_package_cb:
- */
-static void
-pk_task_client_package_cb (PkTaskMonitor *tmonitor,
- guint value,
- const gchar *package_id,
- const gchar *summary,
- PkTaskClient *tclient)
-{
- PkTaskClientPackageItem *item;
-
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- /* if sync then just add results to an array */
- if (tclient->priv->use_buffer == TRUE) {
- pk_debug ("adding to cache array package %i, %s, %s", value, package_id, summary);
- item = g_new0 (PkTaskClientPackageItem, 1);
- item->value = value;
- item->package_id = g_strdup (package_id);
- item->summary = g_strdup (summary);
- g_ptr_array_add (tclient->priv->package_items, item);
- } else {
- pk_debug ("emit package %i, %s, %s", value, package_id, summary);
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_PACKAGE], 0, value, package_id, summary);
- }
-}
-
-/**
- * pk_task_client_transaction_cb:
- */
-static void
-pk_task_client_transaction_cb (PkTaskMonitor *tmonitor,
- const gchar *tid, const gchar *timespec,
- gboolean succeeded, const gchar *role, guint duration,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("emitting transaction %s, %s, %i, %s, %i", tid, timespec, succeeded, role, duration);
- g_signal_emit (tclient, signals [PK_TASK_CLIENT_TRANSACTION], 0, tid, timespec, succeeded, role, duration);
-}
-
-/**
- * pk_task_client_update_detail_cb:
- */
-static void
-pk_task_client_update_detail_cb (PkTaskMonitor *tmonitor,
- const gchar *package_id,
- const gchar *updates,
- const gchar *obsoletes,
- const gchar *url,
- const gchar *restart,
- const gchar *update_text,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("update-detail package='%s', updates='%s', obsoletes='%s', url='%s', restart='%s', update='%s'",
- package_id, updates, obsoletes, url, restart, update_text);
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_UPDATE_DETAIL], 0,
- package_id, updates, obsoletes, url, restart, update_text);
-}
-
-/**
- * pk_task_client_description_cb:
- */
-static void
-pk_task_client_description_cb (PkTaskMonitor *tmonitor,
- const gchar *package_id,
- const gchar *licence,
- PkGroupEnum group,
- const gchar *detail,
- const gchar *url,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("emit description %s, %s, %i, %s, %s", package_id, licence, group, detail, url);
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_DESCRIPTION], 0, package_id, licence, group, detail, url);
-}
-
-/**
- * pk_task_client_error_code_cb:
- */
-static void
-pk_task_client_error_code_cb (PkTaskMonitor *tmonitor,
- PkErrorCodeEnum code,
- const gchar *details,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- pk_debug ("emit error-code %i, %s", code, details);
- g_signal_emit (tclient , signals [PK_TASK_CLIENT_ERROR_CODE], 0, code, details);
-}
-
-/**
- * pk_task_client_require_restart_cb:
- */
-static void
-pk_task_client_require_restart_cb (PkTaskMonitor *tmonitor,
- PkRestartEnum restart,
- const gchar *details,
- PkTaskClient *tclient)
-{
- g_return_if_fail (tclient != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (tclient));
-
- /* always use the 'worst' possible restart scenario */
- if (restart > tclient->priv->require_restart) {
- tclient->priv->require_restart = restart;
- pk_debug ("restart status now %s", pk_restart_enum_to_text (restart));
- }
-}
-
-/**
- * pk_task_client_class_init:
- **/
-static void
-pk_task_client_class_init (PkTaskClientClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = pk_task_client_finalize;
-
- signals [PK_TASK_CLIENT_TRANSACTION_STATUS_CHANGED] =
- g_signal_new ("transaction-status-changed",
- 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_TASK_CLIENT_PERCENTAGE_CHANGED] =
- g_signal_new ("percentage-changed",
- 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_TASK_CLIENT_SUB_PERCENTAGE_CHANGED] =
- g_signal_new ("sub-percentage-changed",
- 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_TASK_CLIENT_NO_PERCENTAGE_UPDATES] =
- g_signal_new ("no-percentage-updates",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- signals [PK_TASK_CLIENT_PACKAGE] =
- g_signal_new ("package",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
- signals [PK_TASK_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_STRING_UINT,
- G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT);
- signals [PK_TASK_CLIENT_UPDATE_DETAIL] =
- g_signal_new ("update-detail",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
- signals [PK_TASK_CLIENT_DESCRIPTION] =
- g_signal_new ("description",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT_STRING_STRING,
- G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
- signals [PK_TASK_CLIENT_ERROR_CODE] =
- g_signal_new ("error-code",
- 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_TASK_CLIENT_FINISHED] =
- g_signal_new ("finished",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
-
- g_type_class_add_private (klass, sizeof (PkTaskClientPrivate));
-}
-
-/**
- * pk_task_client_connect:
- **/
-static void
-pk_task_client_connect (PkTaskClient *tclient)
-{
- pk_debug ("connect");
-}
-
-/**
- * pk_connection_changed_cb:
- **/
-static void
-pk_connection_changed_cb (PkConnection *pconnection, gboolean connected, PkTaskClient *tclient)
-{
- pk_debug ("connected=%i", connected);
- /* do we have to requeue the action if PK exitied half way? */
-}
-
-/**
- * pk_task_client_init:
- **/
-static void
-pk_task_client_init (PkTaskClient *tclient)
-{
- GError *error = NULL;
- DBusGProxy *proxy = NULL;
-
- tclient->priv = PK_TASK_CLIENT_GET_PRIVATE (tclient);
- tclient->priv->assigned = FALSE;
- tclient->priv->is_sync = FALSE;
- tclient->priv->use_buffer = FALSE;
- tclient->priv->tid = NULL;
- tclient->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
- tclient->priv->require_restart = PK_RESTART_ENUM_NONE;
- tclient->priv->is_finished = FALSE;
- tclient->priv->package_items = g_ptr_array_new ();
-
- /* check dbus connections, exit if not valid */
- tclient->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (error) {
- pk_warning ("%s", error->message);
- g_error_free (error);
- g_error ("This program cannot start until you start the dbus system service.");
- }
-
- /* watch for PackageKit on the bus, and try to connect up at start */
- tclient->priv->pconnection = pk_connection_new ();
- g_signal_connect (tclient->priv->pconnection, "connection-changed",
- G_CALLBACK (pk_connection_changed_cb), tclient);
- if (pk_connection_valid (tclient->priv->pconnection)) {
- pk_task_client_connect (tclient);
- }
-
- /* get a connection */
- proxy = dbus_g_proxy_new_for_name (tclient->priv->connection,
- PK_DBUS_SERVICE, PK_DBUS_PATH, PK_DBUS_INTERFACE);
- if (proxy == NULL) {
- g_error ("Cannot connect to PackageKit.");
- }
- tclient->priv->proxy = proxy;
-
- tclient->priv->tmonitor = pk_task_monitor_new ();
- g_signal_connect (tclient->priv->tmonitor, "finished",
- G_CALLBACK (pk_task_client_finished_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "percentage-changed",
- G_CALLBACK (pk_task_client_percentage_changed_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "sub-percentage-changed",
- G_CALLBACK (pk_task_client_sub_percentage_changed_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "no-percentage-updates",
- G_CALLBACK (pk_task_client_no_percentage_updates_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "transaction-status-changed",
- G_CALLBACK (pk_task_client_transaction_status_changed_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "package",
- G_CALLBACK (pk_task_client_package_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "transaction",
- G_CALLBACK (pk_task_client_transaction_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "update-detail",
- G_CALLBACK (pk_task_client_update_detail_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "description",
- G_CALLBACK (pk_task_client_description_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "error-code",
- G_CALLBACK (pk_task_client_error_code_cb), tclient);
- g_signal_connect (tclient->priv->tmonitor, "require-restart",
- G_CALLBACK (pk_task_client_require_restart_cb), tclient);
-
- /* use PolicyKit */
- tclient->priv->polkit = pk_polkit_client_new ();
-}
-
-/**
- * pk_task_client_finalize:
- **/
-static void
-pk_task_client_finalize (GObject *object)
-{
- PkTaskClient *tclient;
- g_return_if_fail (object != NULL);
- g_return_if_fail (PK_IS_TASK_CLIENT (object));
- tclient = PK_TASK_CLIENT (object);
- g_return_if_fail (tclient->priv != NULL);
-
- /* free the proxy */
- g_object_unref (G_OBJECT (tclient->priv->proxy));
- g_object_unref (tclient->priv->pconnection);
- g_object_unref (tclient->priv->polkit);
-
- /* removed any cached packages */
- pk_task_client_remove_package_items (tclient);
- g_ptr_array_free (tclient->priv->package_items, TRUE);
-
- G_OBJECT_CLASS (pk_task_client_parent_class)->finalize (object);
-}
-
-/**
- * pk_task_client_new:
- **/
-PkTaskClient *
-pk_task_client_new (void)
-{
- PkTaskClient *tclient;
- tclient = g_object_new (PK_TYPE_TASK_CLIENT, NULL);
- return PK_TASK_CLIENT (tclient);
-}
-
diff --git a/libpackagekit/pk-task-client.h b/libpackagekit/pk-task-client.h
deleted file mode 100644
index 84961db..0000000
--- a/libpackagekit/pk-task-client.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __PK_TASK_CLIENT_H
-#define __PK_TASK_CLIENT_H
-
-#include <glib-object.h>
-#include "pk-enum.h"
-#include "pk-enum-list.h"
-
-G_BEGIN_DECLS
-
-#define PK_TYPE_TASK_CLIENT (pk_task_client_get_type ())
-#define PK_TASK_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_TASK_CLIENT, PkTaskClient))
-#define PK_TASK_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_TASK_CLIENT, PkTaskClientClass))
-#define PK_IS_TASK_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_TASK_CLIENT))
-#define PK_IS_TASK_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_TASK_CLIENT))
-#define PK_TASK_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_TASK_CLIENT, PkTaskClientClass))
-
-typedef struct PkTaskClientPrivate PkTaskClientPrivate;
-
-typedef struct
-{
- GObject parent;
- PkTaskClientPrivate *priv;
-} PkTaskClient;
-
-typedef struct
-{
- GObjectClass parent_class;
-} PkTaskClientClass;
-
-/* used if we are collecting packages sync */
-typedef struct
-{
- guint value;
- gchar *package_id;
- gchar *summary;
-} PkTaskClientPackageItem;
-
-GType pk_task_client_get_type (void);
-PkTaskClient *pk_task_client_new (void);
-
-gboolean pk_task_client_set_sync (PkTaskClient *tclient,
- gboolean is_sync);
-gboolean pk_task_client_get_sync (PkTaskClient *tclient);
-
-gboolean pk_task_client_set_use_buffer (PkTaskClient *tclient,
- gboolean use_buffer);
-gboolean pk_task_client_get_use_buffer (PkTaskClient *tclient);
-GPtrArray *pk_task_client_get_package_buffer (PkTaskClient *tclient);
-
-PkRestartEnum pk_task_client_get_require_restart (PkTaskClient *tclient);
-gboolean pk_task_client_get_updates (PkTaskClient *tclient);
-gboolean pk_task_client_update_system (PkTaskClient *tclient);
-gboolean pk_task_client_search_name (PkTaskClient *tclient,
- const gchar *filter,
- const gchar *search);
-gboolean pk_task_client_search_details (PkTaskClient *tclient,
- const gchar *filter,
- const gchar *search);
-gboolean pk_task_client_search_group (PkTaskClient *tclient,
- const gchar *filter,
- const gchar *search);
-gboolean pk_task_client_search_file (PkTaskClient *tclient,
- const gchar *filter,
- const gchar *search);
-gboolean pk_task_client_get_depends (PkTaskClient *tclient,
- const gchar *package_id);
-gboolean pk_task_client_get_update_detail (PkTaskClient *tclient,
- const gchar *package_id);
-gboolean pk_task_client_get_requires (PkTaskClient *tclient,
- const gchar *package_id);
-gboolean pk_task_client_get_description (PkTaskClient *tclient,
- const gchar *package_id);
-gboolean pk_task_client_remove_package (PkTaskClient *tclient,
- const gchar *package,
- gboolean allow_deps);
-gboolean pk_task_client_refresh_cache (PkTaskClient *tclient,
- gboolean force);
-gboolean pk_task_client_install_package (PkTaskClient *tclient,
- const gchar *package_id);
-gboolean pk_task_client_cancel (PkTaskClient *tclient);
-PkEnumList *pk_task_client_get_actions (PkTaskClient *tclient);
-PkEnumList *pk_task_client_get_filters (PkTaskClient *tclient);
-PkEnumList *pk_task_client_get_groups (PkTaskClient *tclient);
-gboolean pk_task_client_reset (PkTaskClient *tclient);
-gboolean pk_task_client_get_old_transactions (PkTaskClient *tclient,
- guint number);
-gboolean pk_task_client_get_backend_detail (PkTaskClient *tclient,
- gchar **name,
- gchar **author,
- gchar **version);
-
-G_END_DECLS
-
-#endif /* __PK_TASK_CLIENT_H */
diff --git a/libpackagekit/pk-task-list.c b/libpackagekit/pk-task-list.c
index 39521d2..74d6ae5 100644
--- a/libpackagekit/pk-task-list.c
+++ b/libpackagekit/pk-task-list.c
@@ -35,15 +35,14 @@
#include "pk-debug.h"
#include "pk-marshal.h"
-#include "pk-task-client.h"
+#include "pk-client.h"
#include "pk-task-common.h"
#include "pk-task-list.h"
-#include "pk-task-monitor.h"
#include "pk-job-list.h"
static void pk_task_list_class_init (PkTaskListClass *klass);
static void pk_task_list_init (PkTaskList *task_list);
-static void pk_task_list_finalize (GObject *object);
+static void pk_task_list_finalize (GObject *object);
#define PK_TASK_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_TASK_LIST, PkTaskListPrivate))
@@ -115,7 +114,7 @@ pk_task_list_find_existing_tid (PkTaskLi
* pk_task_list_job_status_changed_cb:
**/
static void
-pk_task_list_job_status_changed_cb (PkTaskMonitor *tmonitor, PkStatusEnum status, PkTaskList *tlist)
+pk_task_list_job_status_changed_cb (PkClient *client, PkStatusEnum status, PkTaskList *tlist)
{
gchar *tid;
PkTaskListItem *item;
@@ -123,7 +122,7 @@ pk_task_list_job_status_changed_cb (PkTa
g_return_if_fail (tlist != NULL);
g_return_if_fail (PK_IS_TASK_LIST (tlist));
- tid = pk_task_monitor_get_tid (tmonitor);
+ tid = pk_client_get_tid (client);
pk_debug ("tid %s is now %i", tid, status);
/* get correct item */
@@ -139,7 +138,7 @@ pk_task_list_job_status_changed_cb (PkTa
* pk_task_list_job_finished_cb:
**/
static void
-pk_task_list_job_finished_cb (PkTaskMonitor *tmonitor, PkExitEnum exit, guint runtime, PkTaskList *tlist)
+pk_task_list_job_finished_cb (PkClient *client, PkExitEnum exit, guint runtime, PkTaskList *tlist)
{
gchar *tid;
PkTaskListItem *item;
@@ -147,7 +146,7 @@ pk_task_list_job_finished_cb (PkTaskMoni
g_return_if_fail (tlist != NULL);
g_return_if_fail (PK_IS_TASK_LIST (tlist));
- tid = pk_task_monitor_get_tid (tmonitor);
+ tid = pk_client_get_tid (client);
pk_debug ("tid %s exited with %i", tid, exit);
/* get correct item */
@@ -162,7 +161,7 @@ pk_task_list_job_finished_cb (PkTaskMoni
* pk_task_list_error_code_cb:
**/
static void
-pk_task_list_error_code_cb (PkTaskMonitor *tmonitor, PkErrorCodeEnum error_code, const gchar *details, PkTaskList *tlist)
+pk_task_list_error_code_cb (PkClient *client, PkErrorCodeEnum error_code, const gchar *details, PkTaskList *tlist)
{
g_return_if_fail (tlist != NULL);
g_return_if_fail (PK_IS_TASK_LIST (tlist));
@@ -208,16 +207,16 @@ pk_task_list_refresh (PkTaskList *tlist)
pk_debug ("new job, have to create %s", tid);
item = g_new0 (PkTaskListItem, 1);
item->tid = g_strdup (tid);
- item->monitor = pk_task_monitor_new ();
+ item->monitor = pk_client_new ();
g_signal_connect (item->monitor, "transaction-status-changed",
G_CALLBACK (pk_task_list_job_status_changed_cb), tlist);
g_signal_connect (item->monitor, "finished",
G_CALLBACK (pk_task_list_job_finished_cb), tlist);
g_signal_connect (item->monitor, "error-code",
G_CALLBACK (pk_task_list_error_code_cb), tlist);
- pk_task_monitor_set_tid (item->monitor, tid);
- pk_task_monitor_get_role (item->monitor, &item->role, &item->package_id);
- pk_task_monitor_get_status (item->monitor, &item->status);
+ pk_client_set_tid (item->monitor, tid);
+ pk_client_get_role (item->monitor, &item->role, &item->package_id);
+ pk_client_get_status (item->monitor, &item->status);
/* add to watched array */
g_ptr_array_add (tlist->priv->task_list, item);
diff --git a/libpackagekit/pk-task-list.h b/libpackagekit/pk-task-list.h
index 1ff6bb4..d0a2a0d 100644
--- a/libpackagekit/pk-task-list.h
+++ b/libpackagekit/pk-task-list.h
@@ -23,7 +23,7 @@
#define __PK_TASK_LIST_H
#include <glib-object.h>
-#include "pk-task-monitor.h"
+#include "pk-client.h"
#include "pk-enum.h"
G_BEGIN_DECLS
@@ -43,7 +43,7 @@ typedef struct
PkStatusEnum status;
PkRoleEnum role;
gchar *package_id;
- PkTaskMonitor *monitor;
+ PkClient *monitor;
gboolean valid;
} PkTaskListItem;
diff --git a/libpackagekit/pk-task-monitor.c b/libpackagekit/pk-task-monitor.c
deleted file mode 100644
index 1c97dcc..0000000
--- a/libpackagekit/pk-task-monitor.c
+++ /dev/null
@@ -1,793 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <string.h>
-#include <sys/types.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif /* HAVE_UNISTD_H */
-
-#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
-
-#include "pk-debug.h"
-#include "pk-marshal.h"
-#include "pk-connection.h"
-#include "pk-task-common.h"
-#include "pk-task-monitor.h"
-
-static void pk_task_monitor_class_init (PkTaskMonitorClass *klass);
-static void pk_task_monitor_init (PkTaskMonitor *task_monitor);
-static void pk_task_monitor_finalize (GObject *object);
-
-#define PK_TASK_MONITOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_TASK_MONITOR, PkTaskMonitorPrivate))
-
-struct PkTaskMonitorPrivate
-{
- DBusGConnection *connection;
- DBusGProxy *proxy;
- gchar *tid;
- PkConnection *pconnection;
-};
-
-typedef enum {
- PK_TASK_MONITOR_TRANSACTION_STATUS_CHANGED,
- PK_TASK_MONITOR_PERCENTAGE_CHANGED,
- PK_TASK_MONITOR_SUB_PERCENTAGE_CHANGED,
- PK_TASK_MONITOR_NO_PERCENTAGE_UPDATES,
- PK_TASK_MONITOR_PACKAGE,
- PK_TASK_MONITOR_TRANSACTION,
- PK_TASK_MONITOR_UPDATE_DETAIL,
- PK_TASK_MONITOR_DESCRIPTION,
- PK_TASK_MONITOR_ERROR_CODE,
- PK_TASK_MONITOR_REQUIRE_RESTART,
- PK_TASK_MONITOR_FINISHED,
- PK_TASK_MONITOR_LAST_SIGNAL
-} PkSignals;
-
-static guint signals [PK_TASK_MONITOR_LAST_SIGNAL] = { 0, };
-
-G_DEFINE_TYPE (PkTaskMonitor, pk_task_monitor, G_TYPE_OBJECT)
-
-/**
- * pk_task_monitor_set_tid:
- **/
-gboolean
-pk_task_monitor_set_tid (PkTaskMonitor *tmonitor, const gchar *tid)
-{
- tmonitor->priv->tid = g_strdup (tid);
- return TRUE;
-}
-
-/**
- * pk_task_monitor_get_tid:
- **/
-gchar *
-pk_task_monitor_get_tid (PkTaskMonitor *tmonitor)
-{
- return g_strdup (tmonitor->priv->tid);
-}
-
-/**
- * pk_task_monitor_get_status:
- **/
-gboolean
-pk_task_monitor_get_status (PkTaskMonitor *tmonitor, PkStatusEnum *status)
-{
- gboolean ret;
- gchar *status_text;
- GError *error;
-
- g_return_val_if_fail (tmonitor != NULL, FALSE);
- g_return_val_if_fail (status != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetStatus", &error,
- G_TYPE_STRING, tmonitor->priv->tid,
- G_TYPE_INVALID,
- G_TYPE_STRING, &status_text,
- G_TYPE_INVALID);
- if (error) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
- }
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetStatus failed!");
- return FALSE;
- }
- *status = pk_status_enum_from_text (status_text);
- return TRUE;
-}
-
-/**
- * pk_task_monitor_get_package:
- **/
-gboolean
-pk_task_monitor_get_package (PkTaskMonitor *tmonitor, gchar **package)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tmonitor != NULL, FALSE);
- g_return_val_if_fail (package != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetPackage", &error,
- G_TYPE_STRING, tmonitor->priv->tid,
- G_TYPE_INVALID,
- G_TYPE_STRING, package,
- G_TYPE_INVALID);
- if (error) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
- }
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetPackage failed!");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * pk_task_monitor_cancel:
- **/
-gboolean
-pk_task_monitor_cancel (PkTaskMonitor *tmonitor)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tmonitor != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tmonitor->priv->proxy, "Cancel", &error,
- G_TYPE_STRING, tmonitor->priv->tid,
- G_TYPE_INVALID,
- G_TYPE_INVALID);
- if (error) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
- }
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("Cancel failed!");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * pk_task_monitor_get_percentage:
- **/
-gboolean
-pk_task_monitor_get_percentage (PkTaskMonitor *tmonitor, guint *percentage)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tmonitor != NULL, FALSE);
- g_return_val_if_fail (percentage != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetPercentage", &error,
- G_TYPE_STRING, tmonitor->priv->tid,
- G_TYPE_INVALID,
- G_TYPE_UINT, percentage,
- G_TYPE_INVALID);
- if (error) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
- }
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetPercentage failed!");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * pk_task_monitor_get_sub_percentage:
- **/
-gboolean
-pk_task_monitor_get_sub_percentage (PkTaskMonitor *tmonitor, guint *percentage)
-{
- gboolean ret;
- GError *error;
-
- g_return_val_if_fail (tmonitor != NULL, FALSE);
- g_return_val_if_fail (percentage != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetSubPercentage", &error,
- G_TYPE_STRING, tmonitor->priv->tid,
- G_TYPE_INVALID,
- G_TYPE_UINT, percentage,
- G_TYPE_INVALID);
- if (error) {
- pk_debug ("ERROR: %s", error->message);
- g_error_free (error);
- }
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetSubPercentage failed!");
- return FALSE;
- }
- return TRUE;
-}
-
-/**
- * pk_task_monitor_get_role:
- **/
-gboolean
-pk_task_monitor_get_role (PkTaskMonitor *tmonitor, PkRoleEnum *role, gchar **package_id)
-{
- gboolean ret;
- GError *error;
- gchar *role_text;
- gchar *package_id_temp;
-
- g_return_val_if_fail (tmonitor != NULL, FALSE);
- g_return_val_if_fail (role != NULL, FALSE);
- g_return_val_if_fail (PK_IS_TASK_MONITOR (tmonitor), FALSE);
- g_return_val_if_fail (tmonitor->priv->tid != NULL, FALSE);
-
- error = NULL;
- ret = dbus_g_proxy_call (tmonitor->priv->proxy, "GetRole", &error,
- G_TYPE_STRING, tmonitor->priv->tid,
- G_TYPE_INVALID,
- G_TYPE_STRING, &role_text,
- G_TYPE_STRING, &package_id_temp,
- G_TYPE_INVALID);
- if (ret == FALSE) {
- /* abort as the DBUS method failed */
- pk_warning ("GetRole failed :%s", error->message);
- g_error_free (error);
- return FALSE;
- }
- *role = pk_role_enum_from_text (role_text);
- if (package_id != NULL) {
- *package_id = g_strdup (package_id_temp);
- }
- return TRUE;
-}
-
-/**
- * pk_transaction_id_equal:
- * TODO: only compare first two sections...
- **/
-static gboolean
-pk_transaction_id_equal (const gchar *tid1, const gchar *tid2)
-{
- if (tid1 == NULL || tid2 == NULL) {
- pk_warning ("tid compare invalid '%s' and '%s'", tid1, tid2);
- return FALSE;
- }
- return (strcmp (tid1, tid2) == 0);
-}
-
-/**
- * pk_task_monitor_finished_cb:
- */
-static void
-pk_task_monitor_finished_cb (DBusGProxy *proxy,
- gchar *tid,
- const gchar *exit_text,
- guint runtime,
- PkTaskMonitor *tmonitor)
-{
- PkExitEnum exit;
-
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- exit = pk_exit_enum_from_text (exit_text);
- pk_debug ("emit finished %i, %i", exit, runtime);
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_FINISHED], 0, exit, runtime);
- }
-}
-
-/**
- * pk_task_monitor_percentage_changed_cb:
- */
-static void
-pk_task_monitor_percentage_changed_cb (DBusGProxy *proxy,
- const gchar *tid,
- guint percentage,
- PkTaskMonitor *tmonitor)
-{
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- pk_debug ("emit percentage-changed %i", percentage);
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_PERCENTAGE_CHANGED], 0, percentage);
- }
-}
-
-/**
- * pk_task_monitor_sub_percentage_changed_cb:
- */
-static void
-pk_task_monitor_sub_percentage_changed_cb (DBusGProxy *proxy,
- const gchar *tid,
- guint percentage,
- PkTaskMonitor *tmonitor)
-{
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- pk_debug ("emit sub-percentage-changed %i", percentage);
- g_signal_emit (tmonitor, signals [PK_TASK_MONITOR_SUB_PERCENTAGE_CHANGED], 0, percentage);
- }
-}
-
-/**
- * pk_task_monitor_no_percentage_updates_cb:
- */
-static void
-pk_task_monitor_no_percentage_updates_cb (DBusGProxy *proxy,
- const gchar *tid,
- PkTaskMonitor *tmonitor)
-{
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- pk_debug ("emit no-percentage-updates");
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_NO_PERCENTAGE_UPDATES], 0);
- }
-}
-
-/**
- * pk_task_monitor_transaction_status_changed_cb:
- */
-static void
-pk_task_monitor_transaction_status_changed_cb (DBusGProxy *proxy,
- const gchar *tid,
- const gchar *status_text,
- PkTaskMonitor *tmonitor)
-{
- PkStatusEnum status;
-
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- status = pk_status_enum_from_text (status_text);
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- pk_debug ("emit transaction-status-changed %i", status);
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_TRANSACTION_STATUS_CHANGED], 0, status);
- }
-}
-
-/**
- * pk_task_monitor_package_cb:
- */
-static void
-pk_task_monitor_package_cb (DBusGProxy *proxy,
- const gchar *tid,
- guint value,
- const gchar *package,
- const gchar *summary,
- PkTaskMonitor *tmonitor)
-{
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- pk_debug ("emit package %i, %s, %s", value, package, summary);
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_PACKAGE], 0, value, package, summary);
- }
-}
-
-/**
- * pk_task_monitor_transaction_cb:
- */
-static void
-pk_task_monitor_transaction_cb (DBusGProxy *proxy,
- const gchar *tid, const gchar *old_tid, const gchar *timespec,
- gboolean succeeded, const gchar *role, guint duration,
- PkTaskMonitor *tmonitor)
-{
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- pk_debug ("emitting transaction %s, %s, %i, %s, %i", old_tid, timespec, succeeded, role, duration);
- g_signal_emit (tmonitor, signals [PK_TASK_MONITOR_TRANSACTION], 0, tid, timespec, succeeded, role, duration);
- }
-}
-
-/**
- * pk_task_monitor_update_detail_cb:
- */
-static void
-pk_task_monitor_update_detail_cb (DBusGProxy *proxy,
- const gchar *tid,
- const gchar *package_id,
- const gchar *updates,
- const gchar *obsoletes,
- const gchar *url,
- const gchar *restart,
- const gchar *update_text,
- PkTaskMonitor *tmonitor)
-{
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- pk_debug ("emit update-detail %s, %s, %s, %s, %s, %s",
- package_id, updates, obsoletes, url, restart, update_text);
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_UPDATE_DETAIL], 0,
- package_id, updates, obsoletes, url, restart, update_text);
- }
-}
-
-/**
- * pk_task_monitor_description_cb:
- */
-static void
-pk_task_monitor_description_cb (DBusGProxy *proxy,
- const gchar *tid,
- const gchar *package_id,
- const gchar *licence,
- const gchar *group_text,
- const gchar *description,
- const gchar *url,
- PkTaskMonitor *tmonitor)
-{
- PkGroupEnum group;
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- group = pk_group_enum_from_text (group_text);
- pk_debug ("emit description %s, %s, %i, %s, %s", package_id, licence, group, description, url);
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_DESCRIPTION], 0, package_id, licence, group, description, url);
- }
-}
-
-/**
- * pk_task_monitor_error_code_cb:
- */
-static void
-pk_task_monitor_error_code_cb (DBusGProxy *proxy,
- const gchar *tid,
- const gchar *code_text,
- const gchar *details,
- PkTaskMonitor *tmonitor)
-{
- PkErrorCodeEnum code;
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- code = pk_error_enum_from_text (code_text);
- pk_debug ("emit error-code %i, %s", code, details);
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_ERROR_CODE], 0, code, details);
- }
-}
-
-/**
- * pk_task_monitor_require_restart_cb:
- */
-static void
-pk_task_monitor_require_restart_cb (DBusGProxy *proxy,
- const gchar *tid,
- const gchar *restart_text,
- const gchar *details,
- PkTaskMonitor *tmonitor)
-{
- PkRestartEnum restart;
- g_return_if_fail (tmonitor != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (tmonitor));
-
- if (pk_transaction_id_equal (tid, tmonitor->priv->tid) == TRUE) {
- restart = pk_restart_enum_from_text (restart_text);
- pk_debug ("emit require-restart %i, %s", restart, details);
- g_signal_emit (tmonitor , signals [PK_TASK_MONITOR_REQUIRE_RESTART], 0, restart, details);
- }
-}
-
-/**
- * pk_task_monitor_class_init:
- **/
-static void
-pk_task_monitor_class_init (PkTaskMonitorClass *klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = pk_task_monitor_finalize;
-
- signals [PK_TASK_MONITOR_TRANSACTION_STATUS_CHANGED] =
- g_signal_new ("transaction-status-changed",
- 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_TASK_MONITOR_PERCENTAGE_CHANGED] =
- g_signal_new ("percentage-changed",
- 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_TASK_MONITOR_SUB_PERCENTAGE_CHANGED] =
- g_signal_new ("sub-percentage-changed",
- 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_TASK_MONITOR_NO_PERCENTAGE_UPDATES] =
- g_signal_new ("no-percentage-updates",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- signals [PK_TASK_MONITOR_PACKAGE] =
- g_signal_new ("package",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
- signals [PK_TASK_MONITOR_TRANSACTION] =
- g_signal_new ("transaction",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_BOOL_STRING_UINT,
- G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT);
- signals [PK_TASK_MONITOR_UPDATE_DETAIL] =
- g_signal_new ("update-detail",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
- signals [PK_TASK_MONITOR_DESCRIPTION] =
- g_signal_new ("description",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT_STRING_STRING,
- G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
- signals [PK_TASK_MONITOR_ERROR_CODE] =
- g_signal_new ("error-code",
- 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_TASK_MONITOR_REQUIRE_RESTART] =
- g_signal_new ("require-restart",
- 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_TASK_MONITOR_FINISHED] =
- g_signal_new ("finished",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- 0, NULL, NULL, pk_marshal_VOID__UINT_UINT,
- G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
-
- g_type_class_add_private (klass, sizeof (PkTaskMonitorPrivate));
-}
-
-/**
- * pk_task_monitor_connect:
- **/
-static void
-pk_task_monitor_connect (PkTaskMonitor *tmonitor)
-{
- pk_debug ("connect");
-}
-
-/**
- * pk_connection_changed_cb:
- **/
-static void
-pk_connection_changed_cb (PkConnection *pconnection, gboolean connected, PkTaskMonitor *tmonitor)
-{
- pk_debug ("connected=%i", connected);
-
- /* TODO: if PK re-started mid-transaction then show a big fat warning */
-}
-
-/**
- * pk_task_monitor_init:
- **/
-static void
-pk_task_monitor_init (PkTaskMonitor *tmonitor)
-{
- GError *error = NULL;
- DBusGProxy *proxy = NULL;
-
- tmonitor->priv = PK_TASK_MONITOR_GET_PRIVATE (tmonitor);
- tmonitor->priv->tid = NULL;
-
- /* check dbus connections, exit if not valid */
- tmonitor->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
- if (error) {
- pk_warning ("%s", error->message);
- g_error_free (error);
- g_error ("This program cannot start until you start the dbus system service.");
- }
-
- /* watch for PackageKit on the bus, and try to connect up at start */
- tmonitor->priv->pconnection = pk_connection_new ();
- g_signal_connect (tmonitor->priv->pconnection, "connection-changed",
- G_CALLBACK (pk_connection_changed_cb), tmonitor);
- if (pk_connection_valid (tmonitor->priv->pconnection)) {
- pk_task_monitor_connect (tmonitor);
- }
-
- /* get a connection */
- proxy = dbus_g_proxy_new_for_name (tmonitor->priv->connection,
- PK_DBUS_SERVICE, PK_DBUS_PATH, PK_DBUS_INTERFACE);
- if (proxy == NULL) {
- g_error ("Cannot connect to PackageKit.");
- }
- tmonitor->priv->proxy = proxy;
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- /* Finished */
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_UINT,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
-
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT_STRING_STRING,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING_STRING,
- 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,
- G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN,
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
-
- dbus_g_proxy_add_signal (proxy, "Finished",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "Finished",
- G_CALLBACK (pk_task_monitor_finished_cb), tmonitor, NULL);
-
- dbus_g_proxy_add_signal (proxy, "PercentageChanged",
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "PercentageChanged",
- G_CALLBACK (pk_task_monitor_percentage_changed_cb), tmonitor, NULL);
-
- dbus_g_proxy_add_signal (proxy, "SubPercentageChanged",
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "SubPercentageChanged",
- G_CALLBACK (pk_task_monitor_sub_percentage_changed_cb), tmonitor, NULL);
-
- dbus_g_proxy_add_signal (proxy, "NoPercentageUpdates",
- G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "NoPercentageUpdates",
- G_CALLBACK (pk_task_monitor_no_percentage_updates_cb), tmonitor, NULL);
-
- dbus_g_proxy_add_signal (proxy, "TransactionStatusChanged",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "TransactionStatusChanged",
- G_CALLBACK (pk_task_monitor_transaction_status_changed_cb), tmonitor, NULL);
-
- dbus_g_proxy_add_signal (proxy, "Package",
- G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "Package",
- G_CALLBACK (pk_task_monitor_package_cb), tmonitor, NULL);
-
- 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);
- dbus_g_proxy_connect_signal (proxy, "Transaction",
- G_CALLBACK (pk_task_monitor_transaction_cb), tmonitor, 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);
- dbus_g_proxy_connect_signal (proxy, "UpdateDetail",
- G_CALLBACK (pk_task_monitor_update_detail_cb), tmonitor, NULL);
-
- dbus_g_proxy_add_signal (proxy, "Description",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "Description",
- G_CALLBACK (pk_task_monitor_description_cb), tmonitor, NULL);
-
- dbus_g_proxy_add_signal (proxy, "ErrorCode",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "ErrorCode",
- G_CALLBACK (pk_task_monitor_error_code_cb), tmonitor, NULL);
-
- dbus_g_proxy_add_signal (proxy, "RequireRestart",
- G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
- dbus_g_proxy_connect_signal (proxy, "RequireRestart",
- G_CALLBACK (pk_task_monitor_require_restart_cb), tmonitor, NULL);
-}
-
-/**
- * pk_task_monitor_finalize:
- **/
-static void
-pk_task_monitor_finalize (GObject *object)
-{
- PkTaskMonitor *tmonitor;
- g_return_if_fail (object != NULL);
- g_return_if_fail (PK_IS_TASK_MONITOR (object));
- tmonitor = PK_TASK_MONITOR (object);
- g_return_if_fail (tmonitor->priv != NULL);
-
- /* disconnect signal handlers */
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Finished",
- G_CALLBACK (pk_task_monitor_finished_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "PercentageChanged",
- G_CALLBACK (pk_task_monitor_percentage_changed_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "SubPercentageChanged",
- G_CALLBACK (pk_task_monitor_sub_percentage_changed_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "NoPercentageUpdates",
- G_CALLBACK (pk_task_monitor_no_percentage_updates_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "TransactionStatusChanged",
- G_CALLBACK (pk_task_monitor_transaction_status_changed_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Package",
- G_CALLBACK (pk_task_monitor_package_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Transaction",
- G_CALLBACK (pk_task_monitor_transaction_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "Description",
- G_CALLBACK (pk_task_monitor_description_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "ErrorCode",
- G_CALLBACK (pk_task_monitor_error_code_cb), tmonitor);
- dbus_g_proxy_disconnect_signal (tmonitor->priv->proxy, "RequireRestart",
- G_CALLBACK (pk_task_monitor_require_restart_cb), tmonitor);
-
- /* free the proxy */
- g_object_unref (G_OBJECT (tmonitor->priv->proxy));
- g_object_unref (tmonitor->priv->pconnection);
-
- G_OBJECT_CLASS (pk_task_monitor_parent_class)->finalize (object);
-}
-
-/**
- * pk_task_monitor_new:
- **/
-PkTaskMonitor *
-pk_task_monitor_new (void)
-{
- PkTaskMonitor *tmonitor;
- tmonitor = g_object_new (PK_TYPE_TASK_MONITOR, NULL);
- return PK_TASK_MONITOR (tmonitor);
-}
-
diff --git a/libpackagekit/pk-task-monitor.h b/libpackagekit/pk-task-monitor.h
deleted file mode 100644
index 1151641..0000000
--- a/libpackagekit/pk-task-monitor.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
- *
- * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef __PK_TASK_MONITOR_H
-#define __PK_TASK_MONITOR_H
-
-#include <glib-object.h>
-#include "pk-enum.h"
-
-G_BEGIN_DECLS
-
-#define PK_TYPE_TASK_MONITOR (pk_task_monitor_get_type ())
-#define PK_TASK_MONITOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_TASK_MONITOR, PkTaskMonitor))
-#define PK_TASK_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_TASK_MONITOR, PkTaskMonitorClass))
-#define PK_IS_TASK_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_TASK_MONITOR))
-#define PK_IS_TASK_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_TASK_MONITOR))
-#define PK_TASK_MONITOR_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_TASK_MONITOR, PkTaskMonitorClass))
-
-typedef struct PkTaskMonitorPrivate PkTaskMonitorPrivate;
-
-typedef struct
-{
- GObject parent;
- PkTaskMonitorPrivate *priv;
-} PkTaskMonitor;
-
-typedef struct
-{
- GObjectClass parent_class;
-} PkTaskMonitorClass;
-
-GType pk_task_monitor_get_type (void);
-PkTaskMonitor *pk_task_monitor_new (void);
-
-gboolean pk_task_monitor_set_tid (PkTaskMonitor *tmonitor,
- const gchar *tid);
-gchar *pk_task_monitor_get_tid (PkTaskMonitor *tmonitor);
-gboolean pk_task_monitor_get_status (PkTaskMonitor *tmonitor,
- PkStatusEnum *status);
-gboolean pk_task_monitor_get_role (PkTaskMonitor *tmonitor,
- PkRoleEnum *role,
- gchar **package_id);
-gboolean pk_task_monitor_get_percentage (PkTaskMonitor *tmonitor,
- guint *percentage);
-gboolean pk_task_monitor_get_sub_percentage (PkTaskMonitor *tmonitor,
- guint *percentage);
-gboolean pk_task_monitor_get_package (PkTaskMonitor *tmonitor,
- gchar **package_id);
-gboolean pk_task_monitor_cancel (PkTaskMonitor *tmonitor);
-
-G_END_DECLS
-
-#endif /* __PK_TASK_MONITOR_H */
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 8f3b563..9105172 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -183,7 +183,7 @@ pk_engine_transaction_status_changed_cb
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -206,7 +206,7 @@ pk_engine_percentage_changed_cb (PkBacke
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -227,7 +227,7 @@ pk_engine_sub_percentage_changed_cb (PkB
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -248,7 +248,7 @@ pk_engine_no_percentage_updates_cb (PkBa
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -269,7 +269,7 @@ pk_engine_package_cb (PkBackend *backend
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -293,7 +293,7 @@ pk_engine_update_detail_cb (PkBackend *b
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -317,7 +317,7 @@ pk_engine_error_code_cb (PkBackend *back
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -340,7 +340,7 @@ pk_engine_require_restart_cb (PkBackend
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -364,7 +364,7 @@ pk_engine_description_cb (PkBackend *bac
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -388,7 +388,7 @@ pk_engine_finished_cb (PkBackend *backen
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -420,7 +420,7 @@ pk_engine_allow_interrupt_cb (PkBackend
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
+ item = pk_transaction_list_get_from_backend (engine->priv->transaction_list, backend);
if (item == NULL) {
pk_warning ("could not find backend");
return;
@@ -478,7 +478,7 @@ pk_engine_new_backend (PkEngine *engine)
/* initialise some stuff */
pk_engine_reset_timer (engine);
- pk_transaction_list_add (engine->priv->transaction_list, backend);
+ pk_transaction_list_create (engine->priv->transaction_list);
/* we don't add to the array or do the transaction-list-changed yet
* as this transaction might fail */
@@ -542,9 +542,13 @@ gboolean
pk_engine_get_tid (PkEngine *engine, gchar **tid, GError **error)
{
PkTransactionItem *item;
- item = pk_transaction_list_add (engine->priv->transaction_list, NULL);
+
+ g_return_val_if_fail (engine != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+
+ item = pk_transaction_list_create (engine->priv->transaction_list);
*tid = g_strdup (item->tid);
- return FALSE;
+ return TRUE;
}
/**
@@ -619,7 +623,7 @@ pk_engine_refresh_cache (PkEngine *engin
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -659,7 +663,7 @@ pk_engine_get_updates (PkEngine *engine,
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -750,7 +754,7 @@ pk_engine_search_name (PkEngine *engine,
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -801,7 +805,7 @@ pk_engine_search_details (PkEngine *engi
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -852,7 +856,7 @@ pk_engine_search_group (PkEngine *engine
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -903,7 +907,7 @@ pk_engine_search_file (PkEngine *engine,
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -954,7 +958,7 @@ pk_engine_resolve (PkEngine *engine, con
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -993,7 +997,7 @@ pk_engine_get_depends (PkEngine *engine,
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -1040,7 +1044,7 @@ pk_engine_get_requires (PkEngine *engine
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -1087,7 +1091,7 @@ pk_engine_get_update_detail (PkEngine *e
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -1134,7 +1138,7 @@ pk_engine_get_description (PkEngine *eng
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"transaction_id '%s' not found", tid);
@@ -1174,7 +1178,7 @@ pk_engine_update_system (PkEngine *engin
g_return_if_fail (PK_IS_ENGINE (engine));
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"transaction_id '%s' not found", tid);
@@ -1232,7 +1236,7 @@ pk_engine_remove_package (PkEngine *engi
g_return_if_fail (PK_IS_ENGINE (engine));
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"transaction_id '%s' not found", tid);
@@ -1293,7 +1297,7 @@ pk_engine_install_package (PkEngine *eng
g_return_if_fail (PK_IS_ENGINE (engine));
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"transaction_id '%s' not found", tid);
@@ -1354,7 +1358,7 @@ pk_engine_install_file (PkEngine *engine
g_return_if_fail (PK_IS_ENGINE (engine));
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"transaction_id '%s' not found", tid);
@@ -1415,7 +1419,7 @@ pk_engine_update_package (PkEngine *engi
g_return_if_fail (PK_IS_ENGINE (engine));
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"transaction_id '%s' not found", tid);
@@ -1488,7 +1492,7 @@ pk_engine_get_status (PkEngine *engine,
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
"No tid:%s", tid);
@@ -1514,7 +1518,7 @@ pk_engine_get_role (PkEngine *engine, co
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
"No tid:%s", tid);
@@ -1539,7 +1543,7 @@ pk_engine_get_percentage (PkEngine *engi
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
"No tid:%s", tid);
@@ -1567,7 +1571,7 @@ pk_engine_get_sub_percentage (PkEngine *
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
"No tid:%s", tid);
@@ -1595,7 +1599,7 @@ pk_engine_get_package (PkEngine *engine,
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
"No tid:%s", tid);
@@ -1621,7 +1625,7 @@ pk_engine_get_old_transactions (PkEngine
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- item = pk_transaction_list_add (engine->priv->transaction_list, NULL);
+ item = pk_transaction_list_create (engine->priv->transaction_list);
engine->priv->sync_item = item;
pk_transaction_db_get_list (engine->priv->transaction_db, number);
// pk_engine_finished_cb ();
@@ -1648,7 +1652,7 @@ pk_engine_cancel (PkEngine *engine, cons
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ item = pk_transaction_list_get_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
"No tid:%s", tid);
diff --git a/src/pk-transaction-list.c b/src/pk-transaction-list.c
index 1fd32ad..fc271cf 100644
--- a/src/pk-transaction-list.c
+++ b/src/pk-transaction-list.c
@@ -89,10 +89,10 @@ pk_transaction_list_role_present (PkTran
}
/**
- * pk_transaction_list_add:
+ * pk_transaction_list_create:
**/
PkTransactionItem *
-pk_transaction_list_add (PkTransactionList *tlist, PkBackend *backend)
+pk_transaction_list_create (PkTransactionList *tlist)
{
PkTransactionItem *item;
@@ -103,7 +103,7 @@ pk_transaction_list_add (PkTransactionLi
item = g_new0 (PkTransactionItem, 1);
item->committed = FALSE;
item->running = FALSE;
- item->backend = backend;
+ item->backend = NULL;
item->tid = pk_transaction_id_generate ();
g_ptr_array_add (tlist->priv->array, item);
return item;
@@ -143,7 +143,7 @@ pk_transaction_list_backend_finished_cb
g_return_if_fail (tlist != NULL);
g_return_if_fail (PK_IS_TRANSACTION_LIST (tlist));
- item = pk_transaction_list_get_item_from_backend (tlist, backend);
+ item = pk_transaction_list_get_from_backend (tlist, backend);
if (item == NULL) {
pk_error ("moo!");
}
@@ -200,7 +200,7 @@ pk_transaction_list_commit (PkTransactio
g_return_val_if_fail (tlist != NULL, FALSE);
g_return_val_if_fail (PK_IS_TRANSACTION_LIST (tlist), FALSE);
- item = pk_transaction_list_get_item_from_backend (tlist, backend);
+ item = pk_transaction_list_get_from_backend (tlist, backend);
if (item == NULL) {
return FALSE;
}
@@ -290,10 +290,10 @@ pk_transaction_list_get_size (PkTransact
}
/**
- * pk_transaction_list_get_item_from_tid:
+ * pk_transaction_list_get_from_tid:
**/
PkTransactionItem *
-pk_transaction_list_get_item_from_tid (PkTransactionList *tlist, const gchar *tid)
+pk_transaction_list_get_from_tid (PkTransactionList *tlist, const gchar *tid)
{
guint i;
guint length;
@@ -314,10 +314,10 @@ pk_transaction_list_get_item_from_tid (P
}
/**
- * pk_transaction_list_get_item_from_backend:
+ * pk_transaction_list_get_from_backend:
**/
PkTransactionItem *
-pk_transaction_list_get_item_from_backend (PkTransactionList *tlist, PkBackend *backend)
+pk_transaction_list_get_from_backend (PkTransactionList *tlist, PkBackend *backend)
{
guint i;
guint length;
diff --git a/src/pk-transaction-list.h b/src/pk-transaction-list.h
index 3101927..34fe561 100644
--- a/src/pk-transaction-list.h
+++ b/src/pk-transaction-list.h
@@ -59,8 +59,7 @@ typedef struct {
GType pk_transaction_list_get_type (void);
PkTransactionList *pk_transaction_list_new (void);
-PkTransactionItem *pk_transaction_list_add (PkTransactionList *tlist,
- PkBackend *backend);
+PkTransactionItem *pk_transaction_list_create (PkTransactionList *tlist);
gboolean pk_transaction_list_remove (PkTransactionList *tlist,
PkTransactionItem *item);
gboolean pk_transaction_list_commit (PkTransactionList *tlist,
@@ -69,9 +68,9 @@ gboolean pk_transaction_list_role_prese
PkRoleEnum role);
gchar **pk_transaction_list_get_array (PkTransactionList *tlist);
guint pk_transaction_list_get_size (PkTransactionList *tlist);
-PkTransactionItem *pk_transaction_list_get_item_from_tid(PkTransactionList *tlist,
+PkTransactionItem *pk_transaction_list_get_from_tid (PkTransactionList *tlist,
const gchar *tid);
-PkTransactionItem *pk_transaction_list_get_item_from_backend(PkTransactionList *tlist,
+PkTransactionItem *pk_transaction_list_get_from_backend (PkTransactionList *tlist,
PkBackend *backend);
G_END_DECLS
diff --git a/tools/add-method.sh b/tools/add-method.sh
index 147b0ca..3b21d7b 100755
--- a/tools/add-method.sh
+++ b/tools/add-method.sh
@@ -1,4 +1,4 @@
#!/bin/sh
-$EDITOR docs/introduction.xml src/pk-interface.xml src/pk-engine.h src/pk-engine.c backends/yum/helpers/packagekit.py libpackagekit/pk-task-client.h libpackagekit/pk-task-client.c
+$EDITOR docs/introduction.xml src/pk-interface.xml src/pk-engine.h src/pk-engine.c backends/yum/helpers/packagekit.py libpackagekit/pk-client.h libpackagekit/pk-task-client.c
diff-tree dada6e2084b3cee197844c4cf6494f2e74febf79 (from 32676de08c947c041bb415c5ed399aa23fff1068)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 20:50:40 2007 +0100
oops
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
index 0c3e25f..cbf28ce 100644
--- a/libpackagekit/pk-client.c
+++ b/libpackagekit/pk-client.c
@@ -720,7 +720,7 @@ pk_client_allocate_transaction_id (PkCli
}
error = NULL;
- ret = dbus_g_proxy_call (client->priv->proxy, "NewTid", &error,
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetTid", &error,
G_TYPE_INVALID,
G_TYPE_STRING, &client->priv->tid,
G_TYPE_INVALID);
diff-tree 32676de08c947c041bb415c5ed399aa23fff1068 (from 26f01d14a975e3f1374b1e0fcd13b3bb662a547e)
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 20:47:58 2007 +0100
add the simple client library
diff --git a/libpackagekit/Makefile.am b/libpackagekit/Makefile.am
index 56b7437..18d8d47 100644
--- a/libpackagekit/Makefile.am
+++ b/libpackagekit/Makefile.am
@@ -6,7 +6,7 @@ INCLUDES = \
$(DBUS_CFLAGS) \
-I$(top_srcdir)/libpackagekit \
-I$(top_srcdir)/libgbus \
- -I$(top_srcdir)/libselftest \
+ -I$(top_srcdir)/libselftest \
-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
@@ -28,9 +28,10 @@ libpackagekit_include_HEADERS = \
pk-debug.h \
pk-connection.h \
pk-package-id.h \
- pk-enum-list.h \
+ pk-enum-list.h \
pk-enum.h \
pk-task-common.h \
+ pk-client.h \
pk-task-monitor.h \
pk-task-client.h \
pk-task-list.h \
@@ -47,12 +48,14 @@ libpackagekit_la_SOURCES = \
pk-connection.h \
pk-package-id.h \
pk-package-id.c \
- pk-enum-list.c \
- pk-enum-list.h \
+ pk-enum-list.c \
+ pk-enum-list.h \
pk-enum.h \
pk-enum.c \
pk-task-common.c \
pk-task-common.h \
+ pk-client.c \
+ pk-client.h \
pk-task-monitor.c \
pk-task-monitor.h \
pk-task-client.c \
diff --git a/libpackagekit/pk-client.c b/libpackagekit/pk-client.c
new file mode 100644
index 0000000..0c3e25f
--- /dev/null
+++ b/libpackagekit/pk-client.c
@@ -0,0 +1,1820 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <string.h>
+#include <sys/types.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h>
+#include <dbus/dbus-glib.h>
+
+#include "pk-client.h"
+#include "pk-connection.h"
+#include "pk-debug.h"
+#include "pk-marshal.h"
+#include "pk-polkit-client.h"
+#include "pk-task-common.h"
+
+static void pk_client_class_init (PkClientClass *klass);
+static void pk_client_init (PkClient *client);
+static void pk_client_finalize (GObject *object);
+
+#define PK_CLIENT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), PK_TYPE_CLIENT, PkClientPrivate))
+
+struct PkClientPrivate
+{
+ DBusGConnection *connection;
+ DBusGProxy *proxy;
+ gboolean assigned;
+ gboolean is_finished;
+ gboolean use_buffer;
+ gchar *tid;
+ GPtrArray *package_items;
+ PkConnection *pconnection;
+ PkPolkitClient *polkit;
+ PkRestartEnum require_restart;
+ PkStatusEnum last_status;
+};
+
+typedef enum {
+ PK_CLIENT_DESCRIPTION,
+ PK_CLIENT_ERROR_CODE,
+ PK_CLIENT_FINISHED,
+ PK_CLIENT_NO_PERCENTAGE_UPDATES,
+ PK_CLIENT_PACKAGE,
+ PK_CLIENT_PERCENTAGE_CHANGED,
+ PK_CLIENT_REQUIRE_RESTART,
+ PK_CLIENT_SUB_PERCENTAGE_CHANGED,
+ PK_CLIENT_TRANSACTION,
+ PK_CLIENT_TRANSACTION_STATUS_CHANGED,
+ PK_CLIENT_UPDATE_DETAIL,
+ PK_CLIENT_LAST_SIGNAL
+} PkSignals;
+
+static guint signals [PK_CLIENT_LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE (PkClient, pk_client, G_TYPE_OBJECT)
+
+/******************************************************************************
+ * LOCAL FUNCTIONS
+ ******************************************************************************/
+
+/**
+ * pk_client_set_tid:
+ **/
+gboolean
+pk_client_set_tid (PkClient *client, const gchar *tid)
+{
+ client->priv->tid = g_strdup (tid);
+ return TRUE;
+}
+
+/**
+ * pk_client_get_tid:
+ **/
+gchar *
+pk_client_get_tid (PkClient *client)
+{
+ return g_strdup (client->priv->tid);
+}
+
+/**
+ * pk_transaction_id_equal:
+ * TODO: only compare first two sections...
+ **/
+static gboolean
+pk_transaction_id_equal (const gchar *tid1, const gchar *tid2)
+{
+ if (tid1 == NULL || tid2 == NULL) {
+ pk_warning ("tid compare invalid '%s' and '%s'", tid1, tid2);
+ return FALSE;
+ }
+ return (strcmp (tid1, tid2) == 0);
+}
+
+/**
+ * pk_client_set_use_buffer:
+ **/
+gboolean
+pk_client_set_use_buffer (PkClient *client, gboolean use_buffer)
+{
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ client->priv->use_buffer = use_buffer;
+ return TRUE;
+}
+
+/**
+ * pk_client_get_use_buffer:
+ **/
+gboolean
+pk_client_get_use_buffer (PkClient *client)
+{
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ return client->priv->use_buffer;
+}
+
+/**
+ * pk_client_get_use_buffer:
+ **/
+PkRestartEnum
+pk_client_get_require_restart (PkClient *client)
+{
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ return client->priv->require_restart;
+}
+
+/**
+ * pk_client_get_package_buffer:
+ **/
+GPtrArray *
+pk_client_get_package_buffer (PkClient *client)
+{
+ if (client->priv->use_buffer == FALSE) {
+ return NULL;
+ }
+ return client->priv->package_items;
+}
+
+/**
+ * pk_client_remove_package_items:
+ **/
+static void
+pk_client_remove_package_items (PkClient *client)
+{
+ PkClientPackageItem *item;
+ while (client->priv->package_items->len > 0) {
+ item = g_ptr_array_index (client->priv->package_items, 0);
+ g_free (item->package_id);
+ g_free (item->summary);
+ g_free (item);
+ g_ptr_array_remove_index_fast (client->priv->package_items, 0);
+ }
+}
+
+/**
+ * pk_client_reset:
+ **/
+gboolean
+pk_client_reset (PkClient *client)
+{
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ if (client->priv->is_finished != TRUE) {
+ pk_warning ("not exit status, reset might be invalid");
+ }
+ client->priv->assigned = FALSE;
+ client->priv->use_buffer = FALSE;
+ client->priv->tid = NULL;
+ client->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
+ client->priv->is_finished = FALSE;
+ pk_client_remove_package_items (client);
+ return TRUE;
+}
+
+/**
+ * pk_client_get_error_name:
+ **/
+static const gchar *
+pk_client_get_error_name (GError *error)
+{
+ const gchar *name;
+ if (error->domain == DBUS_GERROR &&
+ error->code == DBUS_GERROR_REMOTE_EXCEPTION) {
+ name = dbus_g_error_get_name (error);
+ } else {
+ name = g_quark_to_string (error->domain);
+ }
+ return name;
+}
+
+/******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+
+/**
+ * pk_client_finished_cb:
+ */
+static void
+pk_client_finished_cb (DBusGProxy *proxy,
+ gchar *tid,
+ const gchar *exit_text,
+ guint runtime,
+ PkClient *client)
+{
+ PkExitEnum exit;
+
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (PK_IS_CLIENT (client));
+
+ if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
+ exit = pk_exit_enum_from_text (exit_text);
+ pk_debug ("emit finished %i, %i", exit, runtime);
+ g_signal_emit (client , signals [PK_CLIENT_FINISHED], 0, exit, runtime);
+ }
+ client->priv->is_finished = TRUE;
+}
+
+/**
+ * pk_client_percentage_changed_cb:
+ */
+static void
+pk_client_percentage_changed_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ guint percentage,
+ PkClient *client)
+{
+ 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 percentage-changed %i", percentage);
+ g_signal_emit (client , signals [PK_CLIENT_PERCENTAGE_CHANGED], 0, percentage);
+ }
+}
+
+/**
+ * pk_client_sub_percentage_changed_cb:
+ */
+static void
+pk_client_sub_percentage_changed_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ guint percentage,
+ PkClient *client)
+{
+ 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 sub-percentage-changed %i", percentage);
+ g_signal_emit (client, signals [PK_CLIENT_SUB_PERCENTAGE_CHANGED], 0, percentage);
+ }
+}
+
+/**
+ * pk_client_no_percentage_updates_cb:
+ */
+static void
+pk_client_no_percentage_updates_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ PkClient *client)
+{
+ 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 no-percentage-updates");
+ g_signal_emit (client , signals [PK_CLIENT_NO_PERCENTAGE_UPDATES], 0);
+ }
+}
+
+/**
+ * pk_client_transaction_status_changed_cb:
+ */
+static void
+pk_client_transaction_status_changed_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ const gchar *status_text,
+ PkClient *client)
+{
+ PkStatusEnum status;
+
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (PK_IS_CLIENT (client));
+
+ status = pk_status_enum_from_text (status_text);
+ if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
+ pk_debug ("emit transaction-status-changed %i", status);
+ g_signal_emit (client , signals [PK_CLIENT_TRANSACTION_STATUS_CHANGED], 0, status);
+ }
+ client->priv->last_status = status;
+}
+
+/**
+ * pk_client_package_cb:
+ */
+static void
+pk_client_package_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ guint value,
+ const gchar *package_id,
+ const gchar *summary,
+ PkClient *client)
+{
+ PkClientPackageItem *item;
+ 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);
+
+ /* cache */
+ if (client->priv->use_buffer == TRUE) {
+ pk_debug ("adding to cache array package %i, %s, %s", value, package_id, summary);
+ item = g_new0 (PkClientPackageItem, 1);
+ item->value = value;
+ item->package_id = g_strdup (package_id);
+ item->summary = g_strdup (summary);
+ g_ptr_array_add (client->priv->package_items, item);
+ }
+ }
+}
+
+/**
+ * pk_client_transaction_cb:
+ */
+static void
+pk_client_transaction_cb (DBusGProxy *proxy,
+ const gchar *tid, const gchar *old_tid, const gchar *timespec,
+ gboolean succeeded, const gchar *role, guint duration,
+ PkClient *client)
+{
+ 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 ("emitting transaction %s, %s, %i, %s, %i", old_tid, timespec, succeeded, role, duration);
+ g_signal_emit (client, signals [PK_CLIENT_TRANSACTION], 0, tid, timespec, succeeded, role, duration);
+ }
+}
+
+/**
+ * pk_client_update_detail_cb:
+ */
+static void
+pk_client_update_detail_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ const gchar *package_id,
+ const gchar *updates,
+ const gchar *obsoletes,
+ const gchar *url,
+ const gchar *restart,
+ const gchar *update_text,
+ PkClient *client)
+{
+ 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 update-detail %s, %s, %s, %s, %s, %s",
+ package_id, updates, obsoletes, url, restart, update_text);
+ g_signal_emit (client , signals [PK_CLIENT_UPDATE_DETAIL], 0,
+ package_id, updates, obsoletes, url, restart, update_text);
+ }
+}
+
+/**
+ * pk_client_description_cb:
+ */
+static void
+pk_client_description_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ const gchar *package_id,
+ const gchar *licence,
+ const gchar *group_text,
+ const gchar *description,
+ const gchar *url,
+ PkClient *client)
+{
+ PkGroupEnum group;
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (PK_IS_CLIENT (client));
+
+ if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
+ group = pk_group_enum_from_text (group_text);
+ pk_debug ("emit description %s, %s, %i, %s, %s", package_id, licence, group, description, url);
+ g_signal_emit (client , signals [PK_CLIENT_DESCRIPTION], 0, package_id, licence, group, description, url);
+ }
+}
+
+/**
+ * pk_client_error_code_cb:
+ */
+static void
+pk_client_error_code_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ const gchar *code_text,
+ const gchar *details,
+ PkClient *client)
+{
+ PkErrorCodeEnum code;
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (PK_IS_CLIENT (client));
+
+ if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
+ code = pk_error_enum_from_text (code_text);
+ pk_debug ("emit error-code %i, %s", code, details);
+ g_signal_emit (client , signals [PK_CLIENT_ERROR_CODE], 0, code, details);
+ }
+}
+
+/**
+ * pk_client_require_restart_cb:
+ */
+static void
+pk_client_require_restart_cb (DBusGProxy *proxy,
+ const gchar *tid,
+ const gchar *restart_text,
+ const gchar *details,
+ PkClient *client)
+{
+ PkRestartEnum restart;
+ g_return_if_fail (client != NULL);
+ g_return_if_fail (PK_IS_CLIENT (client));
+
+ if (pk_transaction_id_equal (tid, client->priv->tid) == TRUE) {
+ restart = pk_restart_enum_from_text (restart_text);
+ pk_debug ("emit require-restart %i, %s", restart, details);
+ g_signal_emit (client , signals [PK_CLIENT_REQUIRE_RESTART], 0, restart, details);
+ if (restart > client->priv->require_restart) {
+ client->priv->require_restart = restart;
+ pk_debug ("restart status now %s", pk_restart_enum_to_text (restart));
+ }
+ }
+}
+
+/******************************************************************************
+ * TRANSACTION ID USING METHODS
+ ******************************************************************************/
+
+/**
+ * pk_client_get_status:
+ **/
+gboolean
+pk_client_get_status (PkClient *client, PkStatusEnum *status)
+{
+ gboolean ret;
+ gchar *status_text;
+ GError *error;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (status != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (client->priv->tid != NULL, FALSE);
+
+ /* check to see if we have a valid transaction */
+ if (client->priv->tid == NULL) {
+ pk_warning ("Transaction ID not set");
+ return FALSE;
+ }
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetStatus", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &status_text,
+ G_TYPE_INVALID);
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetStatus failed!");
+ return FALSE;
+ }
+ *status = pk_status_enum_from_text (status_text);
+ return TRUE;
+}
+
+/**
+ * pk_client_get_package:
+ **/
+gboolean
+pk_client_get_package (PkClient *client, gchar **package)
+{
+ gboolean ret;
+ GError *error;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (package != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (client->priv->tid != NULL, FALSE);
+
+ /* check to see if we have a valid transaction */
+ if (client->priv->tid == NULL) {
+ pk_warning ("Transaction ID not set");
+ return FALSE;
+ }
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetPackage", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, package,
+ G_TYPE_INVALID);
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetPackage failed!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_get_percentage:
+ **/
+gboolean
+pk_client_get_percentage (PkClient *client, guint *percentage)
+{
+ gboolean ret;
+ GError *error;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (percentage != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (client->priv->tid != NULL, FALSE);
+
+ /* check to see if we have a valid transaction */
+ if (client->priv->tid == NULL) {
+ pk_warning ("Transaction ID not set");
+ return FALSE;
+ }
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetPercentage", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, percentage,
+ G_TYPE_INVALID);
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetPercentage failed!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_get_sub_percentage:
+ **/
+gboolean
+pk_client_get_sub_percentage (PkClient *client, guint *percentage)
+{
+ gboolean ret;
+ GError *error;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (percentage != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (client->priv->tid != NULL, FALSE);
+
+ /* check to see if we have a valid transaction */
+ if (client->priv->tid == NULL) {
+ pk_warning ("Transaction ID not set");
+ return FALSE;
+ }
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetSubPercentage", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_INVALID,
+ G_TYPE_UINT, percentage,
+ G_TYPE_INVALID);
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetSubPercentage failed!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_get_role:
+ **/
+gboolean
+pk_client_get_role (PkClient *client, PkRoleEnum *role, gchar **package_id)
+{
+ gboolean ret;
+ GError *error;
+ gchar *role_text;
+ gchar *package_id_temp;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (role != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+ g_return_val_if_fail (client->priv->tid != NULL, FALSE);
+
+ /* check to see if we have a valid transaction */
+ if (client->priv->tid == NULL) {
+ pk_warning ("Transaction ID not set");
+ return FALSE;
+ }
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetRole", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &role_text,
+ G_TYPE_STRING, &package_id_temp,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetRole failed :%s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ *role = pk_role_enum_from_text (role_text);
+ if (package_id != NULL) {
+ *package_id = g_strdup (package_id_temp);
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_cancel:
+ **/
+gboolean
+pk_client_cancel (PkClient *client)
+{
+ 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 have an action */
+ if (client->priv->assigned == FALSE) {
+ pk_warning ("Transaction ID not set");
+ return FALSE;
+ }
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "Cancel", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("Cancel failed :%s", error->message);
+ g_error_free (error);
+ }
+ return ret;
+}
+
+/******************************************************************************
+ * TRANSACTION ID CREATING METHODS
+ ******************************************************************************/
+
+/**
+ * pk_client_allocate_transaction_id:
+ **/
+static gboolean
+pk_client_allocate_transaction_id (PkClient *client)
+{
+ 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, "NewTid", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &client->priv->tid,
+ 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 ("NewTid failed!");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * pk_client_get_updates:
+ **/
+gboolean
+pk_client_get_updates (PkClient *client)
+{
+ 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, "GetUpdates", &error,
+ G_TYPE_STRING, client->priv->tid,
+ 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 ("GetUpdates failed!");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * pk_client_update_system_action:
+ **/
+gboolean
+pk_client_update_system_action (PkClient *client, 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, "UpdateSystem", error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("UpdateSystem failed!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_update_system:
+ **/
+gboolean
+pk_client_update_system (PkClient *client)
+{
+ 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_update_system_action (client, &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_update_system_action (client, &error);
+ }
+ }
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * pk_client_search_name:
+ **/
+gboolean
+pk_client_search_name (PkClient *client, const gchar *filter, const gchar *search)
+{
+ 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, "SearchName", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_STRING, filter,
+ G_TYPE_STRING, search,
+ 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 ("SearchName failed!");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * pk_client_search_details:
+ **/
+gboolean
+pk_client_search_details (PkClient *client, const gchar *filter, const gchar *search)
+{
+ 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, "SearchDetails", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_STRING, filter,
+ G_TYPE_STRING, search,
+ 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 ("SearchDetails failed!");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/**
+ * pk_client_search_group:
+ **/
+gboolean
+pk_client_search_group (PkClient *client, const gchar *filter, const gchar *search)
+{
+ 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, "SearchGroup", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_STRING, filter,
+ G_TYPE_STRING, search,
+ 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 ("SearchGroup failed!");
+ return FALSE;
+ }
+ /* only assign on success */
+
+ return TRUE;
+}
+
+/**
+ * pk_client_search_file:
+ **/
+gboolean
+pk_client_search_file (PkClient *client, const gchar *filter, const gchar *search)
+{
+ 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, "SearchFile", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_STRING, filter,
+ G_TYPE_STRING, search,
+ 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 ("SearchFile failed!");
+ return FALSE;
+ }
+ /* only assign on success */
+
+ return TRUE;
+}
+
+/**
+ * pk_client_get_depends:
+ **/
+gboolean
+pk_client_get_depends (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, "GetDepends", &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 ("GetDepends failed!");
+ return FALSE;
+ }
+ /* only assign on success */
+
+ return TRUE;
+}
+
+/**
+ * pk_client_get_requires:
+ **/
+gboolean
+pk_client_get_requires (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, "GetRequires", &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 ("GetRequires failed!");
+ return FALSE;
+ }
+ /* only assign on success */
+
+ return TRUE;
+}
+
+/**
+ * pk_client_get_update_detail:
+ **/
+gboolean
+pk_client_get_update_detail (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, "GetUpdateDetail", &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 ("GetUpdateDetail failed!");
+ return FALSE;
+ }
+ /* only assign on success */
+
+ return TRUE;
+}
+
+/**
+ * pk_client_get_description:
+ **/
+gboolean
+pk_client_get_description (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, "GetDescription", &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 ("GetDescription failed!");
+ return FALSE;
+ }
+ /* only assign on success */
+
+ return TRUE;
+}
+
+/**
+ * pk_client_remove_package_action:
+ **/
+gboolean
+pk_client_remove_package_action (PkClient *client, const gchar *package,
+ gboolean allow_deps, 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, "RemovePackage", error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_STRING, package,
+ G_TYPE_BOOLEAN, allow_deps,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("RemovePackage failed!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_remove_package:
+ **/
+gboolean
+pk_client_remove_package (PkClient *client, const gchar *package, gboolean allow_deps)
+{
+ 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_remove_package_action (client, package, allow_deps, &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_remove_package_action (client, package, allow_deps, &error);
+ }
+ }
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * pk_client_refresh_cache:
+ **/
+gboolean
+pk_client_refresh_cache (PkClient *client, gboolean force)
+{
+ 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, "RefreshCache", &error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_BOOLEAN, force,
+ 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 ("RefreshCache failed!");
+ return FALSE;
+ }
+ /* only assign on success */
+
+ return TRUE;
+}
+
+/**
+ * pk_client_install_package_action:
+ **/
+gboolean
+pk_client_install_package_action (PkClient *client, const gchar *package, 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, "InstallPackage", error,
+ G_TYPE_STRING, client->priv->tid,
+ G_TYPE_STRING, package,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("InstallPackage failed!");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_install_package:
+ **/
+gboolean
+pk_client_install_package (PkClient *client, const gchar *package_id)
+{
+ 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_package_action (client, package_id, &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_package_action (client, package_id, &error);
+ }
+ }
+ if (error != NULL) {
+ pk_debug ("ERROR: %s", error->message);
+ g_error_free (error);
+ }
+ }
+
+ /* only wait if the command succeeded. False is usually due to PolicyKit auth failure */
+ return ret;
+}
+
+/******************************************************************************
+ * NON-TRANSACTION ID METHODS
+ ******************************************************************************/
+
+/**
+ * pk_client_get_actions:
+ **/
+PkEnumList *
+pk_client_get_actions (PkClient *client)
+{
+ gboolean ret;
+ GError *error;
+ gchar *actions;
+ PkEnumList *elist;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_ROLE);
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetActions", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &actions,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetActions failed :%s", error->message);
+ g_error_free (error);
+ return elist;
+ }
+
+ /* convert to enumerated types */
+ pk_enum_list_from_string (elist, actions);
+ g_free (actions);
+ return elist;
+}
+
+/**
+ * pk_client_get_backend_detail:
+ **/
+gboolean
+pk_client_get_backend_detail (PkClient *client, gchar **name, gchar **author, gchar **version)
+{
+ gboolean ret;
+ GError *error;
+ gchar *tname;
+ gchar *tauthor;
+ gchar *tversion;
+
+ 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, "GetBackendDetail", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &tname,
+ G_TYPE_STRING, &tauthor,
+ G_TYPE_STRING, &tversion,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetBackendDetail failed :%s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+
+ /* copy needed bits */
+ if (name != NULL) {
+ *name = g_strdup (tname);
+ }
+ /* copy needed bits */
+ if (author != NULL) {
+ *author = g_strdup (tauthor);
+ }
+ /* copy needed bits */
+ if (version != NULL) {
+ *version = g_strdup (tversion);
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_get_groups:
+ **/
+PkEnumList *
+pk_client_get_groups (PkClient *client)
+{
+ gboolean ret;
+ GError *error;
+ gchar *groups;
+ PkEnumList *elist;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_GROUP);
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetGroups", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &groups,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetGroups failed :%s", error->message);
+ g_error_free (error);
+ return elist;
+ }
+
+ /* convert to enumerated types */
+ pk_enum_list_from_string (elist, groups);
+ g_free (groups);
+ return elist;
+}
+
+/**
+ * pk_client_get_old_transactions:
+ **/
+gboolean
+pk_client_get_old_transactions (PkClient *client, guint number)
+{
+ gboolean ret;
+ GError *error;
+
+ 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, "GetOldTransactions", &error,
+ G_TYPE_UINT, number,
+ G_TYPE_INVALID,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetOldTransactions failed :%s", error->message);
+ g_error_free (error);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+/**
+ * pk_client_get_filters:
+ **/
+PkEnumList *
+pk_client_get_filters (PkClient *client)
+{
+ gboolean ret;
+ GError *error;
+ gchar *filters;
+ PkEnumList *elist;
+
+ g_return_val_if_fail (client != NULL, FALSE);
+ g_return_val_if_fail (PK_IS_CLIENT (client), FALSE);
+
+ elist = pk_enum_list_new ();
+ pk_enum_list_set_type (elist, PK_ENUM_LIST_TYPE_FILTER);
+
+ error = NULL;
+ ret = dbus_g_proxy_call (client->priv->proxy, "GetFilters", &error,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &filters,
+ G_TYPE_INVALID);
+ if (ret == FALSE) {
+ /* abort as the DBUS method failed */
+ pk_warning ("GetFilters failed :%s", error->message);
+ g_error_free (error);
+ return elist;
+ }
+
+ /* convert to enumerated types */
+ pk_enum_list_from_string (elist, filters);
+ g_free (filters);
+ return elist;
+}
+
+/**
+ * pk_client_class_init:
+ **/
+static void
+pk_client_class_init (PkClientClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->finalize = pk_client_finalize;
+
+ signals [PK_CLIENT_TRANSACTION_STATUS_CHANGED] =
+ g_signal_new ("transaction-status-changed",
+ 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_PERCENTAGE_CHANGED] =
+ g_signal_new ("percentage-changed",
+ 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_SUB_PERCENTAGE_CHANGED] =
+ g_signal_new ("sub-percentage-changed",
+ 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_NO_PERCENTAGE_UPDATES] =
+ g_signal_new ("no-percentage-updates",
+ 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_PACKAGE] =
+ g_signal_new ("package",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, pk_marshal_VOID__UINT_STRING_STRING,
+ G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ 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_STRING_UINT,
+ G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_STRING, G_TYPE_UINT);
+ signals [PK_CLIENT_UPDATE_DETAIL] =
+ g_signal_new ("update-detail",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, 6, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
+ signals [PK_CLIENT_DESCRIPTION] =
+ g_signal_new ("description",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, pk_marshal_VOID__STRING_STRING_UINT_STRING_STRING,
+ G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
+ signals [PK_CLIENT_ERROR_CODE] =
+ g_signal_new ("error-code",
+ 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_CLIENT_REQUIRE_RESTART] =
+ g_signal_new ("require-restart",
+ 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_CLIENT_FINISHED] =
+ g_signal_new ("finished",
+ G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, pk_marshal_VOID__UINT_UINT,
+ G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_UINT);
+
+ g_type_class_add_private (klass, sizeof (PkClientPrivate));
+}
+
+/**
+ * pk_client_connect:
+ **/
+static void
+pk_client_connect (PkClient *client)
+{
+ pk_debug ("connect");
+}
+
+/**
+ * pk_connection_changed_cb:
+ **/
+static void
+pk_connection_changed_cb (PkConnection *pconnection, gboolean connected, PkClient *client)
+{
+ pk_debug ("connected=%i", connected);
+
+ /* TODO: if PK re-started mid-transaction then show a big fat warning */
+}
+
+/**
+ * pk_client_init:
+ **/
+static void
+pk_client_init (PkClient *client)
+{
+ GError *error = NULL;
+ DBusGProxy *proxy = NULL;
+
+ client->priv = PK_CLIENT_GET_PRIVATE (client);
+ client->priv->tid = NULL;
+ client->priv->assigned = FALSE;
+ client->priv->use_buffer = FALSE;
+ client->priv->last_status = PK_STATUS_ENUM_UNKNOWN;
+ client->priv->require_restart = PK_RESTART_ENUM_NONE;
+ client->priv->is_finished = FALSE;
+ client->priv->package_items = g_ptr_array_new ();
+
+ /* check dbus connections, exit if not valid */
+ client->priv->connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
+ if (error != NULL) {
+ pk_warning ("%s", error->message);
+ g_error_free (error);
+ g_error ("This program cannot start until you start the dbus system service.");
+ }
+
+ /* watch for PackageKit on the bus, and try to connect up at start */
+ client->priv->pconnection = pk_connection_new ();
+ g_signal_connect (client->priv->pconnection, "connection-changed",
+ G_CALLBACK (pk_connection_changed_cb), client);
+ if (pk_connection_valid (client->priv->pconnection)) {
+ pk_client_connect (client);
+ }
+
+ /* get a connection */
+ proxy = dbus_g_proxy_new_for_name (client->priv->connection,
+ PK_DBUS_SERVICE, PK_DBUS_PATH, PK_DBUS_INTERFACE);
+ if (proxy == NULL) {
+ g_error ("Cannot connect to PackageKit.");
+ }
+ client->priv->proxy = proxy;
+
+ /* get a connection */
+ proxy = dbus_g_proxy_new_for_name (client->priv->connection,
+ PK_DBUS_SERVICE, PK_DBUS_PATH, PK_DBUS_INTERFACE);
+ if (proxy == NULL) {
+ g_error ("Cannot connect to PackageKit.");
+ }
+ client->priv->proxy = proxy;
+
+ /* use PolicyKit */
+ client->priv->polkit = pk_polkit_client_new ();
+
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ /* Finished */
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_UINT,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_UINT_STRING_STRING,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_object_register_marshaller (pk_marshal_VOID__STRING_STRING_STRING_STRING_STRING_STRING_STRING,
+ 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,
+ G_TYPE_NONE, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN,
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+
+ dbus_g_proxy_add_signal (proxy, "Finished",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "Finished",
+ G_CALLBACK (pk_client_finished_cb), client, NULL);
+
+ dbus_g_proxy_add_signal (proxy, "PercentageChanged",
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "PercentageChanged",
+ G_CALLBACK (pk_client_percentage_changed_cb), client, NULL);
+
+ dbus_g_proxy_add_signal (proxy, "SubPercentageChanged",
+ G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "SubPercentageChanged",
+ G_CALLBACK (pk_client_sub_percentage_changed_cb), client, NULL);
+
+ dbus_g_proxy_add_signal (proxy, "NoPercentageUpdates",
+ G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "NoPercentageUpdates",
+ G_CALLBACK (pk_client_no_percentage_updates_cb), client, NULL);
+
+ dbus_g_proxy_add_signal (proxy, "TransactionStatusChanged",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "TransactionStatusChanged",
+ 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);
+ dbus_g_proxy_connect_signal (proxy, "Package",
+ G_CALLBACK (pk_client_package_cb), client, NULL);
+
+ 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);
+ dbus_g_proxy_connect_signal (proxy, "Transaction",
+ G_CALLBACK (pk_client_transaction_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);
+ dbus_g_proxy_connect_signal (proxy, "UpdateDetail",
+ G_CALLBACK (pk_client_update_detail_cb), client, NULL);
+
+ dbus_g_proxy_add_signal (proxy, "Description",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "Description",
+ G_CALLBACK (pk_client_description_cb), client, NULL);
+
+ dbus_g_proxy_add_signal (proxy, "ErrorCode",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "ErrorCode",
+ G_CALLBACK (pk_client_error_code_cb), client, NULL);
+
+ dbus_g_proxy_add_signal (proxy, "RequireRestart",
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
+ dbus_g_proxy_connect_signal (proxy, "RequireRestart",
+ G_CALLBACK (pk_client_require_restart_cb), client, NULL);
+}
+
+/**
+ * pk_client_finalize:
+ **/
+static void
+pk_client_finalize (GObject *object)
+{
+ PkClient *client;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (PK_IS_CLIENT (object));
+ client = PK_CLIENT (object);
+ g_return_if_fail (client->priv != NULL);
+
+ /* disconnect signal handlers */
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "Finished",
+ G_CALLBACK (pk_client_finished_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "PercentageChanged",
+ G_CALLBACK (pk_client_percentage_changed_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "SubPercentageChanged",
+ G_CALLBACK (pk_client_sub_percentage_changed_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "NoPercentageUpdates",
+ 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, "Package",
+ G_CALLBACK (pk_client_package_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "Transaction",
+ G_CALLBACK (pk_client_transaction_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "Description",
+ G_CALLBACK (pk_client_description_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "ErrorCode",
+ G_CALLBACK (pk_client_error_code_cb), client);
+ dbus_g_proxy_disconnect_signal (client->priv->proxy, "RequireRestart",
+ G_CALLBACK (pk_client_require_restart_cb), client);
+
+ /* free the proxy */
+ g_object_unref (G_OBJECT (client->priv->proxy));
+ g_object_unref (client->priv->pconnection);
+ g_object_unref (client->priv->polkit);
+
+ /* removed any cached packages */
+ pk_client_remove_package_items (client);
+ g_ptr_array_free (client->priv->package_items, TRUE);
+
+ G_OBJECT_CLASS (pk_client_parent_class)->finalize (object);
+}
+
+/**
+ * pk_client_new:
+ **/
+PkClient *
+pk_client_new (void)
+{
+ PkClient *client;
+ client = g_object_new (PK_TYPE_CLIENT, NULL);
+ return PK_CLIENT (client);
+}
+
diff --git a/libpackagekit/pk-client.h b/libpackagekit/pk-client.h
new file mode 100644
index 0000000..59b8644
--- /dev/null
+++ b/libpackagekit/pk-client.h
@@ -0,0 +1,136 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (C) 2007 Richard Hughes <richard at hughsie.com>
+ *
+ * Licensed under the GNU General Public License Version 2
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __PK_CLIENT_H
+#define __PK_CLIENT_H
+
+#include <glib-object.h>
+#include "pk-enum.h"
+#include "pk-enum-list.h"
+
+G_BEGIN_DECLS
+
+#define PK_TYPE_CLIENT (pk_client_get_type ())
+#define PK_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PK_TYPE_CLIENT, PkClient))
+#define PK_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PK_TYPE_CLIENT, PkClientClass))
+#define PK_IS_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PK_TYPE_CLIENT))
+#define PK_IS_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PK_TYPE_CLIENT))
+#define PK_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PK_TYPE_CLIENT, PkClientClass))
+
+typedef struct PkClientPrivate PkClientPrivate;
+
+typedef struct
+{
+ GObject parent;
+ PkClientPrivate *priv;
+} PkClient;
+
+typedef struct
+{
+ GObjectClass parent_class;
+} PkClientClass;
+
+/* used if we are collecting packages sync */
+typedef struct
+{
+ guint value;
+ gchar *package_id;
+ gchar *summary;
+} PkClientPackageItem;
+
+GType pk_client_get_type (void);
+PkClient *pk_client_new (void);
+
+gboolean pk_client_set_tid (PkClient *client,
+ const gchar *tid);
+gchar *pk_client_get_tid (PkClient *client);
+
+gboolean pk_client_set_use_buffer (PkClient *client,
+ gboolean use_buffer);
+gboolean pk_client_get_use_buffer (PkClient *client);
+
+/* general methods */
+gboolean pk_client_get_status (PkClient *client,
+ PkStatusEnum *status);
+gboolean pk_client_get_role (PkClient *client,
+ PkRoleEnum *role,
+ gchar **package_id);
+gboolean pk_client_get_percentage (PkClient *client,
+ guint *percentage);
+gboolean pk_client_get_sub_percentage (PkClient *client,
+ guint *percentage);
+gboolean pk_client_get_package (PkClient *client,
+ gchar **package_id);
+gboolean pk_client_cancel (PkClient *client);
+
+
+
+gboolean pk_client_get_updates (PkClient *client);
+gboolean pk_client_update_system (PkClient *client);
+gboolean pk_client_search_name (PkClient *client,
+ const gchar *filter,
+ const gchar *search);
+gboolean pk_client_search_details (PkClient *client,
+ const gchar *filter,
+ const gchar *search);
+gboolean pk_client_search_group (PkClient *client,
+ const gchar *filter,
+ const gchar *search);
+gboolean pk_client_search_file (PkClient *client,
+ const gchar *filter,
+ const gchar *search);
+gboolean pk_client_get_depends (PkClient *client,
+ const gchar *package_id);
+gboolean pk_client_get_update_detail (PkClient *client,
+ const gchar *package_id);
+gboolean pk_client_get_requires (PkClient *client,
+ const gchar *package_id);
+gboolean pk_client_get_description (PkClient *client,
+ const gchar *package_id);
+gboolean pk_client_remove_package (PkClient *client,
+ const gchar *package,
+ gboolean allow_deps);
+gboolean pk_client_refresh_cache (PkClient *client,
+ gboolean force);
+gboolean pk_client_install_package (PkClient *client,
+ const gchar *package_id);
+gboolean pk_client_cancel (PkClient *client);
+
+/* cached stuff */
+GPtrArray *pk_client_get_package_buffer (PkClient *client);
+PkRestartEnum pk_client_get_require_restart (PkClient *client);
+
+/* not job specific */
+PkEnumList *pk_client_get_actions (PkClient *client);
+PkEnumList *pk_client_get_filters (PkClient *client);
+PkEnumList *pk_client_get_groups (PkClient *client);
+gboolean pk_client_reset (PkClient *client);
+gboolean pk_client_get_old_transactions (PkClient *client,
+ guint number);
+gboolean pk_client_get_backend_detail (PkClient *client,
+ gchar **name,
+ gchar **author,
+ gchar **version);
+
+
+G_END_DECLS
+
+#endif /* __PK_CLIENT_H */
diff-tree 26f01d14a975e3f1374b1e0fcd13b3bb662a547e (from parents)
Merge: 83486a16dc4f376c81afd59b289bc9b26c0045b7 52228bc2040e551ac48bc567deff2729edef100b
Author: Richard Hughes <richard at hughsie.com>
Date: Mon Sep 24 18:48:25 2007 +0100
Merge branch 'master' into tid
diff-tree 83486a16dc4f376c81afd59b289bc9b26c0045b7 (from dec895aa77710f23601559977d91e7bb0e2cfd65)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 23 23:07:01 2007 +0100
better names
diff --git a/src/pk-engine.c b/src/pk-engine.c
index c9cadf9..8f3b563 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -486,10 +486,10 @@ pk_engine_new_backend (PkEngine *engine)
}
/**
- * pk_engine_add_backend:
+ * pk_engine_item_add:
**/
static gboolean
-pk_engine_add_backend (PkEngine *engine, PkTransactionItem *item)
+pk_engine_item_add (PkEngine *engine, PkTransactionItem *item)
{
PkRoleEnum role;
@@ -516,13 +516,13 @@ pk_engine_add_backend (PkEngine *engine,
}
/**
- * pk_engine_delete_backend:
+ * pk_engine_item_delete:
*
* Use this function when a function failed, and we just want to get rid
* of all references to it.
**/
gboolean
-pk_engine_delete_backend (PkEngine *engine, PkTransactionItem *item)
+pk_engine_item_delete (PkEngine *engine, PkTransactionItem *item)
{
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
@@ -638,11 +638,11 @@ pk_engine_refresh_cache (PkEngine *engin
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -678,10 +678,10 @@ pk_engine_get_updates (PkEngine *engine,
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -781,10 +781,10 @@ pk_engine_search_name (PkEngine *engine,
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -832,10 +832,10 @@ pk_engine_search_details (PkEngine *engi
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -883,10 +883,10 @@ pk_engine_search_group (PkEngine *engine
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -934,10 +934,10 @@ pk_engine_search_file (PkEngine *engine,
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -973,10 +973,10 @@ pk_engine_resolve (PkEngine *engine, con
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -1020,10 +1020,10 @@ pk_engine_get_depends (PkEngine *engine,
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -1067,10 +1067,10 @@ pk_engine_get_requires (PkEngine *engine
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -1114,10 +1114,10 @@ pk_engine_get_update_detail (PkEngine *e
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -1153,10 +1153,10 @@ pk_engine_get_description (PkEngine *eng
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
return TRUE;
}
@@ -1210,11 +1210,11 @@ pk_engine_update_system (PkEngine *engin
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
}
/**
@@ -1269,11 +1269,11 @@ pk_engine_remove_package (PkEngine *engi
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
}
/**
@@ -1330,11 +1330,11 @@ pk_engine_install_package (PkEngine *eng
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
}
/**
@@ -1391,11 +1391,11 @@ pk_engine_install_file (PkEngine *engine
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
}
/**
@@ -1452,11 +1452,11 @@ pk_engine_update_package (PkEngine *engi
if (ret == FALSE) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, item);
+ pk_engine_item_delete (engine, item);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, item);
+ pk_engine_item_add (engine, item);
}
/**
diff-tree dec895aa77710f23601559977d91e7bb0e2cfd65 (from 109306b02dc9a147bc5b323ef62f14fa96d9966b)
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 23 23:05:05 2007 +0100
always make the transaction id check first
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 5733244..c9cadf9 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -749,6 +749,14 @@ pk_engine_search_name (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
/* check the search term */
ret = pk_engine_search_check (search, error);
if (ret == FALSE) {
@@ -761,14 +769,6 @@ pk_engine_search_name (PkEngine *engine,
return FALSE;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -800,6 +800,14 @@ pk_engine_search_details (PkEngine *engi
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
/* check the search term */
ret = pk_engine_search_check (search, error);
if (ret == FALSE) {
@@ -812,14 +820,6 @@ pk_engine_search_details (PkEngine *engi
return FALSE;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -851,6 +851,14 @@ pk_engine_search_group (PkEngine *engine
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
/* check the search term */
ret = pk_engine_search_check (search, error);
if (ret == FALSE) {
@@ -863,14 +871,6 @@ pk_engine_search_group (PkEngine *engine
return FALSE;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -902,6 +902,14 @@ pk_engine_search_file (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
/* check the search term */
ret = pk_engine_search_check (search, error);
if (ret == FALSE) {
@@ -914,14 +922,6 @@ pk_engine_search_file (PkEngine *engine,
return FALSE;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -1039,14 +1039,6 @@ pk_engine_get_requires (PkEngine *engine
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* check package_id */
- ret = pk_package_id_check (package_id);
- if (ret == FALSE) {
- *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
- "The package id '%s' is not valid", package_id);
- return FALSE;
- }
-
/* find pre-requested transaction id */
item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
@@ -1055,6 +1047,14 @@ pk_engine_get_requires (PkEngine *engine
return FALSE;
}
+ /* check package_id */
+ ret = pk_package_id_check (package_id);
+ if (ret == FALSE) {
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
+ "The package id '%s' is not valid", package_id);
+ return FALSE;
+ }
+
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -1086,14 +1086,6 @@ pk_engine_get_update_detail (PkEngine *e
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* check package_id */
- ret = pk_package_id_check (package_id);
- if (ret == FALSE) {
- *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
- "The package id '%s' is not valid", package_id);
- return FALSE;
- }
-
/* find pre-requested transaction id */
item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
@@ -1102,6 +1094,14 @@ pk_engine_get_update_detail (PkEngine *e
return FALSE;
}
+ /* check package_id */
+ ret = pk_package_id_check (package_id);
+ if (ret == FALSE) {
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
+ "The package id '%s' is not valid", package_id);
+ return FALSE;
+ }
+
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -1173,6 +1173,15 @@ pk_engine_update_system (PkEngine *engin
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "transaction_id '%s' not found", tid);
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check with PolicyKit if the action is allowed from this client - if not, set an error */
ret = pk_engine_action_is_allowed (engine, context, "org.freedesktop.packagekit.update", &error);
if (ret == FALSE) {
@@ -1188,15 +1197,6 @@ pk_engine_update_system (PkEngine *engin
return;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "transaction_id '%s' not found", tid);
- dbus_g_method_return_error (context, error);
- return;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -1231,6 +1231,15 @@ pk_engine_remove_package (PkEngine *engi
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "transaction_id '%s' not found", tid);
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_id */
ret = pk_package_id_check (package_id);
if (ret == FALSE) {
@@ -1247,15 +1256,6 @@ pk_engine_remove_package (PkEngine *engi
return;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "transaction_id '%s' not found", tid);
- dbus_g_method_return_error (context, error);
- return;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -1292,6 +1292,15 @@ pk_engine_install_package (PkEngine *eng
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "transaction_id '%s' not found", tid);
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_id */
ret = pk_package_id_check (package_id);
if (ret == FALSE) {
@@ -1308,15 +1317,6 @@ pk_engine_install_package (PkEngine *eng
return;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "transaction_id '%s' not found", tid);
- dbus_g_method_return_error (context, error);
- return;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -1353,6 +1353,15 @@ pk_engine_install_file (PkEngine *engine
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "transaction_id '%s' not found", tid);
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check file exists */
ret = g_file_test (full_path, G_FILE_TEST_EXISTS);
if (ret == FALSE) {
@@ -1369,15 +1378,6 @@ pk_engine_install_file (PkEngine *engine
return;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "transaction_id '%s' not found", tid);
- dbus_g_method_return_error (context, error);
- return;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
@@ -1414,6 +1414,15 @@ pk_engine_update_package (PkEngine *engi
g_return_if_fail (engine != NULL);
g_return_if_fail (PK_IS_ENGINE (engine));
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "transaction_id '%s' not found", tid);
+ dbus_g_method_return_error (context, error);
+ return;
+ }
+
/* check package_id */
ret = pk_package_id_check (package_id);
if (ret == FALSE) {
@@ -1430,15 +1439,6 @@ pk_engine_update_package (PkEngine *engi
return;
}
- /* find pre-requested transaction id */
- item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
- if (item == NULL) {
- error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "transaction_id '%s' not found", tid);
- dbus_g_method_return_error (context, error);
- return;
- }
-
/* create a new backend */
item->backend = pk_engine_new_backend (engine);
if (item->backend == NULL) {
diff-tree 109306b02dc9a147bc5b323ef62f14fa96d9966b (from parents)
Merge: e732435f2ae91f38e2665a8b87c8340df81e8572 67e21e6fef087a473536684ee5871c9322422888
Author: Richard Hughes <richard at hughsie.com>
Date: Sun Sep 23 21:39:11 2007 +0100
Merge branch 'master' into tid
diff-tree e732435f2ae91f38e2665a8b87c8340df81e8572 (from 2a050a7dc2428d6ddbe8a437d1900690883f48e5)
Author: Richard Hughes <richard at hughsie.com>
Date: Sat Sep 22 01:11:07 2007 +0100
start of the two phase constructor
diff --git a/src/pk-engine.c b/src/pk-engine.c
index 7eee5cb..5733244 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -188,7 +188,7 @@ pk_engine_transaction_status_changed_cb
pk_warning ("could not find backend");
return;
}
- status_text = pk_status_enum_to_text (status);
+ status_text = pk_status_enum_to_text (status);
pk_debug ("emitting transaction-status-changed tid:%s, '%s'", item->tid, status_text);
g_signal_emit (engine, signals [PK_ENGINE_TRANSACTION_STATUS_CHANGED], 0, item->tid, status_text);
@@ -489,27 +489,18 @@ pk_engine_new_backend (PkEngine *engine)
* pk_engine_add_backend:
**/
static gboolean
-pk_engine_add_backend (PkEngine *engine, PkBackend *backend)
+pk_engine_add_backend (PkEngine *engine, PkTransactionItem *item)
{
PkRoleEnum role;
- PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
/* commit, so it appears in the JobList */
- pk_transaction_list_commit (engine->priv->transaction_list, backend);
-
- /* get all the data we know */
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
-
- /* we might not have a backend */
- if (backend == NULL) {
- return TRUE;
- }
+ pk_transaction_list_commit (engine->priv->transaction_list, item->backend);
/* only save into the database for useful stuff */
- pk_backend_get_role (backend, &role, NULL);
+ pk_backend_get_role (item->backend, &role, NULL);
if (role == PK_ROLE_ENUM_REFRESH_CACHE ||
role == PK_ROLE_ENUM_UPDATE_SYSTEM ||
role == PK_ROLE_ENUM_REMOVE_PACKAGE ||
@@ -531,18 +522,12 @@ pk_engine_add_backend (PkEngine *engine,
* of all references to it.
**/
gboolean
-pk_engine_delete_backend (PkEngine *engine, PkBackend *backend)
+pk_engine_delete_backend (PkEngine *engine, PkTransactionItem *item)
{
- PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* get item, and remove it */
- item = pk_transaction_list_get_item_from_backend(engine->priv->transaction_list, backend);
- if (item == NULL) {
- return FALSE;
- }
- pk_debug ("removing backend %p as it failed", backend);
+ pk_debug ("removing backend %p as it failed", item->backend);
pk_transaction_list_remove (engine->priv->transaction_list, item);
/* we don't do g_object_unref (backend) here as it is done in the
@@ -551,6 +536,18 @@ pk_engine_delete_backend (PkEngine *engi
}
/**
+ * pk_engine_get_tid:
+ **/
+gboolean
+pk_engine_get_tid (PkEngine *engine, gchar **tid, GError **error)
+{
+ PkTransactionItem *item;
+ item = pk_transaction_list_add (engine->priv->transaction_list, NULL);
+ *tid = g_strdup (item->tid);
+ return FALSE;
+}
+
+/**
* pk_engine_can_do_action:
**/
static PolKitResult
@@ -613,38 +610,39 @@ pk_engine_action_is_allowed (PkEngine *e
* pk_engine_refresh_cache:
**/
gboolean
-pk_engine_refresh_cache (PkEngine *engine, gboolean force, gchar **tid, GError **error)
+pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_refresh_cache (backend, force);
+ ret = pk_backend_refresh_cache (item->backend, force);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
- return FALSE;
- }
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- *tid = g_strdup (item->tid);
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -652,38 +650,38 @@ pk_engine_refresh_cache (PkEngine *engin
* pk_engine_get_updates:
**/
gboolean
-pk_engine_get_updates (PkEngine *engine, gchar **tid, GError **error)
+pk_engine_get_updates (PkEngine *engine, const gchar *tid, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_get_updates (backend);
+ ret = pk_backend_get_updates (item->backend);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
- return FALSE;
- }
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -743,11 +741,9 @@ pk_engine_filter_check (const gchar *fil
* pk_engine_search_name:
**/
gboolean
-pk_engine_search_name (PkEngine *engine, const gchar *filter, const gchar *search,
- gchar **tid, GError **error)
+pk_engine_search_name (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *search, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
@@ -765,29 +761,30 @@ pk_engine_search_name (PkEngine *engine,
return FALSE;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_search_name (backend, filter, search);
+ ret = pk_backend_search_name (item->backend, filter, search);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
- return FALSE;
- }
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -795,11 +792,9 @@ pk_engine_search_name (PkEngine *engine,
* pk_engine_search_details:
**/
gboolean
-pk_engine_search_details (PkEngine *engine, const gchar *filter, const gchar *search,
- gchar **tid, GError **error)
+pk_engine_search_details (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *search, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
@@ -817,29 +812,30 @@ pk_engine_search_details (PkEngine *engi
return FALSE;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_search_details (backend, filter, search);
+ ret = pk_backend_search_details (item->backend, filter, search);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
- return FALSE;
- }
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -847,11 +843,9 @@ pk_engine_search_details (PkEngine *engi
* pk_engine_search_group:
**/
gboolean
-pk_engine_search_group (PkEngine *engine, const gchar *filter, const gchar *search,
- gchar **tid, GError **error)
+pk_engine_search_group (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *search, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
@@ -869,29 +863,30 @@ pk_engine_search_group (PkEngine *engine
return FALSE;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_search_group (backend, filter, search);
+ ret = pk_backend_search_group (item->backend, filter, search);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
- return FALSE;
- }
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -899,11 +894,9 @@ pk_engine_search_group (PkEngine *engine
* pk_engine_search_file:
**/
gboolean
-pk_engine_search_file (PkEngine *engine, const gchar *filter, const gchar *search,
- gchar **tid, GError **error)
+pk_engine_search_file (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *search, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
@@ -921,29 +914,30 @@ pk_engine_search_file (PkEngine *engine,
return FALSE;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_search_file (backend, filter, search);
+ ret = pk_backend_search_file (item->backend, filter, search);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
- return FALSE;
- }
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -951,38 +945,38 @@ pk_engine_search_file (PkEngine *engine,
* pk_engine_resolve:
**/
gboolean
-pk_engine_resolve (PkEngine *engine, const gchar *package, gchar **tid, GError **error)
+pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *package, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_resolve (backend, package);
+ ret = pk_backend_resolve (item->backend, package);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
- return FALSE;
- }
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -990,16 +984,22 @@ pk_engine_resolve (PkEngine *engine, con
* pk_engine_get_depends:
**/
gboolean
-pk_engine_get_depends (PkEngine *engine, const gchar *package_id,
- gchar **tid, GError **error)
+pk_engine_get_depends (PkEngine *engine, const gchar *tid, const gchar *package_id, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
/* check package_id */
ret = pk_package_id_check (package_id);
if (ret == FALSE) {
@@ -1008,29 +1008,22 @@ pk_engine_get_depends (PkEngine *engine,
return FALSE;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_get_depends (backend, package_id);
+ ret = pk_backend_get_depends (item->backend, package_id);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
- return FALSE;
- }
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -1038,11 +1031,9 @@ pk_engine_get_depends (PkEngine *engine,
* pk_engine_get_requires:
**/
gboolean
-pk_engine_get_requires (PkEngine *engine, const gchar *package_id,
- gchar **tid, GError **error)
+pk_engine_get_requires (PkEngine *engine, const gchar *tid, const gchar *package_id, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
@@ -1056,29 +1047,30 @@ pk_engine_get_requires (PkEngine *engine
return FALSE;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_get_requires (backend, package_id);
+ ret = pk_backend_get_requires (item->backend, package_id);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
- return FALSE;
- }
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -1086,11 +1078,9 @@ pk_engine_get_requires (PkEngine *engine
* pk_engine_get_update_detail:
**/
gboolean
-pk_engine_get_update_detail (PkEngine *engine, const gchar *package_id,
- gchar **tid, GError **error)
+pk_engine_get_update_detail (PkEngine *engine, const gchar *tid, const gchar *package_id, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
@@ -1104,29 +1094,30 @@ pk_engine_get_update_detail (PkEngine *e
return FALSE;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_get_update_detail (backend, package_id);
+ ret = pk_backend_get_update_detail (item->backend, package_id);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
- return FALSE;
- }
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -1134,39 +1125,38 @@ pk_engine_get_update_detail (PkEngine *e
* pk_engine_get_description:
**/
gboolean
-pk_engine_get_description (PkEngine *engine, const gchar *package_id,
- gchar **tid, GError **error)
+pk_engine_get_description (PkEngine *engine, const gchar *tid, const gchar *package_id, GError **error)
{
gboolean ret;
- PkBackend *backend;
PkTransactionItem *item;
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
+ g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "transaction_id '%s' not found", tid);
+ return FALSE;
+ }
+
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
"Backend '%s' could not be initialized", engine->priv->backend);
return FALSE;
}
- ret = pk_backend_get_description (backend, package_id);
+ ret = pk_backend_get_description (item->backend, package_id);
if (ret == FALSE) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
- return FALSE;
- }
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ pk_engine_delete_backend (engine, item);
return FALSE;
}
- *tid = g_strdup (item->tid);
-
+ pk_engine_add_backend (engine, item);
return TRUE;
}
@@ -1174,12 +1164,10 @@ pk_engine_get_description (PkEngine *eng
* pk_engine_update_system:
**/
void
-pk_engine_update_system (PkEngine *engine,
- DBusGMethodInvocation *context, GError **dead_error)
+pk_engine_update_system (PkEngine *engine, const gchar *tid, DBusGMethodInvocation *context, GError **dead_error)
{
gboolean ret;
GError *error;
- PkBackend *backend;
PkTransactionItem *item;
g_return_if_fail (engine != NULL);
@@ -1200,43 +1188,44 @@ pk_engine_update_system (PkEngine *engin
return;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "Operation not yet supported by backend");
+ "transaction_id '%s' not found", tid);
dbus_g_method_return_error (context, error);
return;
}
- ret = pk_backend_update_system (backend);
- if (ret == FALSE) {
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ ret = pk_backend_update_system (item->backend);
+ if (ret == FALSE) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ pk_engine_delete_backend (engine, item);
+ dbus_g_method_return_error (context, error);
return;
}
- dbus_g_method_return (context, item->tid);
+ pk_engine_add_backend (engine, item);
}
/**
* pk_engine_remove_package:
**/
void
-pk_engine_remove_package (PkEngine *engine, const gchar *package_id, gboolean allow_deps,
+pk_engine_remove_package (PkEngine *engine, const gchar *tid, const gchar *package_id, gboolean allow_deps,
DBusGMethodInvocation *context, GError **dead_error)
{
PkTransactionItem *item;
gboolean ret;
- PkBackend *backend;
GError *error;
g_return_if_fail (engine != NULL);
@@ -1258,31 +1247,33 @@ pk_engine_remove_package (PkEngine *engi
return;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "Operation not yet supported by backend");
+ "transaction_id '%s' not found", tid);
dbus_g_method_return_error (context, error);
return;
}
- ret = pk_backend_remove_package (backend, package_id, allow_deps);
- if (ret == FALSE) {
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ ret = pk_backend_remove_package (item->backend, package_id, allow_deps);
+ if (ret == FALSE) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ pk_engine_delete_backend (engine, item);
+ dbus_g_method_return_error (context, error);
return;
}
- dbus_g_method_return (context, item->tid);
+ pk_engine_add_backend (engine, item);
}
/**
@@ -1291,12 +1282,11 @@ pk_engine_remove_package (PkEngine *engi
* This is async, so we have to treat it a bit carefully
**/
void
-pk_engine_install_package (PkEngine *engine, const gchar *package_id,
+pk_engine_install_package (PkEngine *engine, const gchar *tid, const gchar *package_id,
DBusGMethodInvocation *context, GError **dead_error)
{
gboolean ret;
PkTransactionItem *item;
- PkBackend *backend;
GError *error;
g_return_if_fail (engine != NULL);
@@ -1318,31 +1308,33 @@ pk_engine_install_package (PkEngine *eng
return;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "Operation not yet supported by backend");
+ "transaction_id '%s' not found", tid);
dbus_g_method_return_error (context, error);
return;
}
- ret = pk_backend_install_package (backend, package_id);
- if (ret == FALSE) {
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ ret = pk_backend_install_package (item->backend, package_id);
+ if (ret == FALSE) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ pk_engine_delete_backend (engine, item);
+ dbus_g_method_return_error (context, error);
return;
}
- dbus_g_method_return (context, item->tid);
+ pk_engine_add_backend (engine, item);
}
/**
@@ -1351,12 +1343,11 @@ pk_engine_install_package (PkEngine *eng
* This is async, so we have to treat it a bit carefully
**/
void
-pk_engine_install_file (PkEngine *engine, const gchar *full_path,
+pk_engine_install_file (PkEngine *engine, const gchar *tid, const gchar *full_path,
DBusGMethodInvocation *context, GError **dead_error)
{
gboolean ret;
PkTransactionItem *item;
- PkBackend *backend;
GError *error;
g_return_if_fail (engine != NULL);
@@ -1378,31 +1369,33 @@ pk_engine_install_file (PkEngine *engine
return;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "Operation not yet supported by backend");
+ "transaction_id '%s' not found", tid);
dbus_g_method_return_error (context, error);
return;
}
- ret = pk_backend_install_file (backend, full_path);
- if (ret == FALSE) {
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ ret = pk_backend_install_file (item->backend, full_path);
+ if (ret == FALSE) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ pk_engine_delete_backend (engine, item);
+ dbus_g_method_return_error (context, error);
return;
}
- dbus_g_method_return (context, item->tid);
+ pk_engine_add_backend (engine, item);
}
/**
@@ -1411,12 +1404,11 @@ pk_engine_install_file (PkEngine *engine
* This is async, so we have to treat it a bit carefully
**/
void
-pk_engine_update_package (PkEngine *engine, const gchar *package_id,
+pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *package_id,
DBusGMethodInvocation *context, GError **dead_error)
{
gboolean ret;
PkTransactionItem *item;
- PkBackend *backend;
GError *error;
g_return_if_fail (engine != NULL);
@@ -1438,31 +1430,33 @@ pk_engine_update_package (PkEngine *engi
return;
}
- /* create a new backend and start it */
- backend = pk_engine_new_backend (engine);
- if (backend == NULL) {
+ /* find pre-requested transaction id */
+ item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
+ if (item == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "Operation not yet supported by backend");
+ "transaction_id '%s' not found", tid);
dbus_g_method_return_error (context, error);
return;
}
- ret = pk_backend_update_package (backend, package_id);
- if (ret == FALSE) {
+ /* create a new backend */
+ item->backend = pk_engine_new_backend (engine);
+ if (item->backend == NULL) {
error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
"Operation not yet supported by backend");
- pk_engine_delete_backend (engine, backend);
dbus_g_method_return_error (context, error);
return;
}
- pk_engine_add_backend (engine, backend);
- item = pk_transaction_list_get_item_from_backend (engine->priv->transaction_list, backend);
- if (item == NULL) {
- pk_warning ("could not find backend");
+ ret = pk_backend_update_package (item->backend, package_id);
+ if (ret == FALSE) {
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ pk_engine_delete_backend (engine, item);
+ dbus_g_method_return_error (context, error);
return;
}
- dbus_g_method_return (context, item->tid);
+ pk_engine_add_backend (engine, item);
}
/**
@@ -1493,6 +1487,7 @@ pk_engine_get_status (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
@@ -1518,6 +1513,7 @@ pk_engine_get_role (PkEngine *engine, co
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
@@ -1542,6 +1538,7 @@ pk_engine_get_percentage (PkEngine *engi
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
@@ -1569,6 +1566,7 @@ pk_engine_get_sub_percentage (PkEngine *
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
@@ -1596,6 +1594,7 @@ pk_engine_get_package (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
@@ -1615,7 +1614,7 @@ pk_engine_get_package (PkEngine *engine,
* pk_engine_get_old_transactions:
**/
gboolean
-pk_engine_get_old_transactions (PkEngine *engine, guint number, gchar **tid, GError **error)
+pk_engine_get_old_transactions (PkEngine *engine, const gchar *tid, guint number, GError **error)
{
PkTransactionItem *item;
@@ -1625,7 +1624,6 @@ pk_engine_get_old_transactions (PkEngine
item = pk_transaction_list_add (engine->priv->transaction_list, NULL);
engine->priv->sync_item = item;
pk_transaction_db_get_list (engine->priv->transaction_db, number);
- *tid = g_strdup (item->tid);
// pk_engine_finished_cb ();
pk_debug ("emitting finished transaction:%s, '%s', %i", item->tid, "", 0);
@@ -1649,6 +1647,7 @@ pk_engine_cancel (PkEngine *engine, cons
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ /* find pre-requested transaction id */
item = pk_transaction_list_get_item_from_tid (engine->priv->transaction_list, tid);
if (item == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NO_SUCH_TRANSACTION,
@@ -1679,7 +1678,7 @@ pk_engine_get_actions (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* create a new backend and start it */
+ /* create a new backend */
backend = pk_engine_new_backend (engine);
if (backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
@@ -1708,7 +1707,7 @@ pk_engine_get_backend_detail (PkEngine *
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* create a new backend and start it */
+ /* create a new backend */
backend = pk_engine_new_backend (engine);
if (backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
@@ -1735,7 +1734,7 @@ pk_engine_get_groups (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* create a new backend and start it */
+ /* create a new backend */
backend = pk_engine_new_backend (engine);
if (backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
@@ -1764,7 +1763,7 @@ pk_engine_get_filters (PkEngine *engine,
g_return_val_if_fail (engine != NULL, FALSE);
g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
- /* create a new backend and start it */
+ /* create a new backend */
backend = pk_engine_new_backend (engine);
if (backend == NULL) {
g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
diff --git a/src/pk-engine.h b/src/pk-engine.h
index b6ea80b..a08567f 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -76,73 +76,86 @@ PkEngine *pk_engine_new (void);
gboolean pk_engine_use_backend (PkEngine *engine,
const gchar *backend);
-gboolean pk_engine_get_updates (PkEngine *engine,
+gboolean pk_engine_get_tid (PkEngine *engine,
gchar **tid,
GError **error);
+gboolean pk_engine_get_updates (PkEngine *engine,
+ const gchar *tid,
+ GError **error);
gboolean pk_engine_search_name (PkEngine *engine,
+ const gchar *tid,
const gchar *filter,
const gchar *search,
- gchar **tid,
GError **error);
gboolean pk_engine_search_details (PkEngine *engine,
+ const gchar *tid,
const gchar *filter,
const gchar *search,
- gchar **tid,
GError **error);
gboolean pk_engine_search_group (PkEngine *engine,
+ const gchar *tid,
const gchar *filter,
const gchar *search,
- gchar **tid,
GError **error);
gboolean pk_engine_search_file (PkEngine *engine,
+ const gchar *tid,
const gchar *filter,
const gchar *search,
- gchar **tid,
GError **error);
gboolean pk_engine_get_depends (PkEngine *engine,
+ const gchar *tid,
const gchar *package_id,
- gchar **tid,
GError **error);
gboolean pk_engine_get_update_detail (PkEngine *engine,
+ const gchar *tid,
const gchar *package_id,
- gchar **tid,
GError **error);
gboolean pk_engine_get_requires (PkEngine *engine,
+ const gchar *tid,
const gchar *package_id,
- gchar **tid,
GError **error);
gboolean pk_engine_get_description (PkEngine *engine,
+ const gchar *tid,
const gchar *package_id,
- gchar **tid,
GError **error);
gboolean pk_engine_resolve (PkEngine *engine,
+ const gchar *tid,
const gchar *package,
- gchar **tid,
GError **error);
gboolean pk_engine_refresh_cache (PkEngine *engine,
+ const gchar *tid,
gboolean force,
- gchar **tid,
+ GError **error);
+gboolean pk_engine_get_old_transactions (PkEngine *engine,
+ const gchar *tid,
+ guint number,
GError **error);
void pk_engine_update_system (PkEngine *engine,
+ const gchar *tid,
DBusGMethodInvocation *context,
GError **error);
void pk_engine_remove_package (PkEngine *engine,
+ const gchar *tid,
const gchar *package_id,
gboolean allow_deps,
DBusGMethodInvocation *context,
GError **error);
void pk_engine_install_package (PkEngine *engine,
+ const gchar *tid,
const gchar *package_id,
DBusGMethodInvocation *context,
GError **error);
void pk_engine_install_file (PkEngine *engine,
+ const gchar *tid,
const gchar *full_path,
DBusGMethodInvocation *context,
GError **error);
void pk_engine_update_package (PkEngine *engine,
+ const gchar *tid,
const gchar *package_id,
DBusGMethodInvocation *context,
GError **error);
+
gboolean pk_engine_get_transaction_list (PkEngine *engine,
gchar ***transaction_list,
GError **error);
@@ -186,10 +199,6 @@ gboolean pk_engine_get_package (PkEng
const gchar *tid,
gchar **package,
GError **error);
-gboolean pk_engine_get_old_transactions (PkEngine *engine,
- guint number,
- gchar **tid,
- GError **error);
G_END_DECLS
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index 24946ed..c490133 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -3,77 +3,80 @@
<interface name="org.freedesktop.PackageKit">
<!-- Schedule new transactions -->
- <method name="GetUpdates">
+ <method name="GetTid">
<arg type="s" name="tid" direction="out"/>
</method>
+ <method name="GetUpdates">
+ <arg type="s" name="tid" direction="in"/>
+ </method>
<method name="RefreshCache">
+ <arg type="s" name="tid" direction="in"/>
<arg type="b" name="force" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="UpdateSystem">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
- <arg type="s" name="tid" direction="out"/>
+ <arg type="s" name="tid" direction="in"/>
</method>
<method name="Resolve">
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="SearchName">
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="SearchDetails">
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="SearchGroup">
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="SearchFile">
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="GetDepends">
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="GetRequires">
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="GetUpdateDetail">
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="GetDescription"> <!-- orders Description signals for the package -->
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="RemovePackage">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
<arg type="b" name="allow_deps" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="InstallPackage">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="UpdatePackage">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<method name="InstallFile">
<annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
+ <arg type="s" name="tid" direction="in"/>
<arg type="s" name="full_path" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<!-- signals emitted from any transaction -->
@@ -177,8 +180,8 @@
<!-- Transaction methods -->
<method name="GetOldTransactions">
+ <arg type="s" name="tid" direction="in"/>
<arg type="u" name="number" direction="in"/>
- <arg type="s" name="tid" direction="out"/>
</method>
<signal name="Transaction">
<arg type="s" name="tid" direction="out"/>
More information about the PackageKit
mailing list