[packagekit] packagekit: Branch 'master' - 3 commits
Richard Hughes
hughsient at kemper.freedesktop.org
Wed Nov 14 23:45:53 PST 2007
backends/Makefile.am | 4
backends/zypp/Makefile.am | 10
backends/zypp/pk-backend-zypp.cpp | 127 ++++++++
configure.ac | 6
src/pk-engine.c | 601 ++++++++++++++++++++------------------
src/pk-engine.h | 75 ++--
src/pk-interface.xml | 13
wscript | 95 +++++-
8 files changed, 599 insertions(+), 332 deletions(-)
New commits:
commit 37369a1a61eb880d143fd81c80a7e05771e1b9aa
Author: Daniel Svensson <dsvensson at gmail.com>
Date: Thu Nov 15 01:17:57 2007 +0100
Provide a coverage report when waf has run the tests.
diff --git a/policy/packagekit.policy b/policy/packagekit.policy
old mode 100644
new mode 100755
diff --git a/wscript b/wscript
index e544333..d002e26 100644
--- a/wscript
+++ b/wscript
@@ -146,6 +146,7 @@ def gcov_report():
rootdir = os.getcwd()
+ os.chdir(blddir)
#for test in ['test-libpackagekit', 'test-packagekitd']:
for test in ['test-libpackagekit']:
@@ -154,7 +155,7 @@ def gcov_report():
obj = Object.name_to_obj(test)
- testdir = os.path.join(blddir, obj.path.bldpath(env))
+ testdir = obj.path.bldpath(env)
if not os.path.isdir(testdir):
continue
@@ -180,19 +181,18 @@ def gcov_report():
suffix = '.' + suffix
tgt_name = lib_name + suffix
- tgt_path = os.path.join(rootdir, testdir, tgt_name)
+ tgt_path = os.path.join(rootdir, blddir, testdir, tgt_name)
src_path = os.path.join(rootdir, blddir, lib_path, lib_name)
if not os.path.exists(tgt_path):
os.symlink(src_path, tgt_path)
cleanup.append(tgt_path)
+ # Gather sources from objects
sources += obj.to_list(obj.source)
-
- #from http://code.nsnam.org/ns-3-dev/file/c21093326f8d/wscript
- #command = 'rm -f gcov.txt'
- #if subprocess.Popen(command, shell=True).wait():
- # raise SystemExit(1)
+ for x in obj.to_list(obj.add_objects):
+ o = Object.name_to_obj(x)
+ sources += o.to_list(o.source)
d = obj.path.bldpath(env)
@@ -200,12 +200,77 @@ def gcov_report():
if subprocess.Popen(command, shell=True).wait():
raise SystemExit(1)
- os.chdir(rootdir)
+ # Ignore these
+ ignore = """
+ pk-main.c
+ pk-marshal.c
+ pk-security-dummy.c
+ pk-backend-python.c
+ """.split()
- """
- report_tool = os.path.join(rootdir, 'tools', 'create-coverage-report.sh')
- command = report_tool + ' packagekit ../libpackagekit/*.c'
- print command, os.getcwd()
- if subprocess.Popen(command, shell=True).wait():
- raise SystemExit(1)
- """
+ sources = [x for x in sources if x not in ignore]
+
+ total_loc = 0
+ total_covered = 0
+ total_stmts = 0
+
+ print '================================================================================'
+ print ' Test coverage for module packagekit:'
+ print '================================================================================'
+
+ srcdir = obj.path.srcpath(env)
+
+ for src in sources:
+ srcpath = os.path.join(srcdir, src)
+
+ command = 'gcov -o %s %s > /dev/null' % (testdir, srcpath)
+ if subprocess.Popen(command, shell=True).wait():
+ raise SystemExit(1)
+
+ covpath = src + '.gcov'
+ if not os.path.exists(covpath):
+ continue
+
+ cleanup.append(covpath)
+
+ not_covered = 0
+ covered = 0
+ loc = 0
+
+ f = open(covpath, 'rb')
+ for line in f.readlines():
+ if line.startswith(' #####:'):
+ not_covered += 1
+ elif not line.startswith(' -:'):
+ covered += 1
+ loc += 1
+ f.close()
+
+ if (covered + not_covered) > 0:
+ percent = 100.0 * covered / (covered + not_covered)
+ else:
+ percent = 0
+
+ print '%30s: %7.2f%% (%d of %d)' % (covpath, percent, covered, not_covered+covered)
+
+ total_loc += loc
+ total_covered += covered
+ total_stmts += covered + not_covered
+
+ if (total_stmts) > 0:
+ percent = 100.0 * total_covered / (total_stmts)
+ else:
+ percent = 0
+
+ print '================================================================================'
+ print ' Source lines : %d' % total_loc
+ print ' Actual statements : %d' % total_stmts
+ print ' Executed statements : %d' % total_covered
+ print ' Test coverage : %3.2f%%' % percent
+ print '================================================================================'
+
+ for item in cleanup:
+ os.unlink(item)
+
+
+ os.chdir(rootdir)
commit 0c400f62c0722870de4c6d8881483ba22eff19f6
Author: Richard Hughes <richard at hughsie.com>
Date: Thu Nov 15 00:11:42 2007 +0000
convert all the active methods async. this lets us get the sender so we can watch to see if they fall off the bus or not
diff --git a/src/pk-engine.c b/src/pk-engine.c
index ac966a3..24c47ae 100644
--- a/src/pk-engine.c
+++ b/src/pk-engine.c
@@ -802,8 +802,7 @@ pk_engine_action_is_allowed (PkEngine *engine, const gchar *dbus_sender,
* pk_engine_refresh_cache:
**/
void
-pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force,
- DBusGMethodInvocation *context, GError **dead_error)
+pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
@@ -819,7 +818,7 @@ pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force,
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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
+ "transaction_id '%s' not found", tid);
dbus_g_method_return_error (context, error);
return;
}
@@ -864,31 +863,34 @@ pk_engine_refresh_cache (PkEngine *engine, const gchar *tid, gboolean force,
/**
* pk_engine_get_updates:
**/
-gboolean
-pk_engine_get_updates (PkEngine *engine, const gchar *tid, GError **error)
+void
+pk_engine_get_updates (PkEngine *engine, const gchar *tid, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("GetUpdates method called: %s", tid);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
/* try and reuse cache */
@@ -908,18 +910,19 @@ pk_engine_get_updates (PkEngine *engine, const gchar *tid, GError **error)
}
pk_engine_finished_cb (item->backend, PK_EXIT_ENUM_SUCCESS, engine);
pk_engine_item_delete (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
+ return;
}
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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
@@ -935,39 +938,39 @@ pk_engine_search_check (const gchar *search, GError **error)
size = strlen (search);
if (search == NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
- "Search is null. This isn't supposed to happen...");
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
+ "Search is null. This isn't supposed to happen...");
return FALSE;
}
if (size == 0) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
- "Search string zero length");
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
+ "Search string zero length");
return FALSE;
}
if (size < 2) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
- "The search string length is too small");
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
+ "The search string length is too small");
return FALSE;
}
if (size > 1024) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
- "The search string length is too large");
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
+ "The search string length is too large");
return FALSE;
}
if (strstr (search, "*") != NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
- "Invalid search containing '*'");
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
+ "Invalid search containing '*'");
return FALSE;
}
if (strstr (search, "?") != NULL) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
- "Invalid search containing '?'");
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_SEARCH_INVALID,
+ "Invalid search containing '?'");
return FALSE;
}
ret = pk_strvalidate (search);
if (ret == FALSE) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
- "Invalid search term");
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
+ "Invalid search term");
return FALSE;
}
return TRUE;
@@ -984,16 +987,16 @@ pk_engine_filter_check (const gchar *filter, GError **error)
/* check for invalid input */
ret = pk_strvalidate (filter);
if (ret == FALSE) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
- "Invalid filter term");
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
+ "Invalid filter term");
return FALSE;
}
/* check for invalid filter */
ret = pk_filter_check (filter);
if (ret == FALSE) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_FILTER_INVALID,
- "Filter '%s' is invalid", filter);
+ *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_FILTER_INVALID,
+ "Filter '%s' is invalid", filter);
return FALSE;
}
return TRUE;
@@ -1002,560 +1005,620 @@ pk_engine_filter_check (const gchar *filter, GError **error)
/**
* pk_engine_search_name:
**/
-gboolean
-pk_engine_search_name (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *search, GError **error)
+void
+pk_engine_search_name (PkEngine *engine, const gchar *tid, const gchar *filter,
+ const gchar *search, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("SearchName method called: %s, %s, %s", tid, filter, search);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 the search term */
- ret = pk_engine_search_check (search, error);
+ ret = pk_engine_search_check (search, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* check the filter */
- ret = pk_engine_filter_check (filter, error);
+ ret = pk_engine_filter_check (filter, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_search_details:
**/
-gboolean
-pk_engine_search_details (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *search, GError **error)
+void
+pk_engine_search_details (PkEngine *engine, const gchar *tid, const gchar *filter,
+ const gchar *search, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("SearchDetails method called: %s, %s, %s", tid, filter, search);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 the search term */
- ret = pk_engine_search_check (search, error);
+ ret = pk_engine_search_check (search, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* check the filter */
- ret = pk_engine_filter_check (filter, error);
+ ret = pk_engine_filter_check (filter, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_search_group:
**/
-gboolean
-pk_engine_search_group (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *search, GError **error)
+void
+pk_engine_search_group (PkEngine *engine, const gchar *tid, const gchar *filter,
+ const gchar *search, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("SearchGroup method called: %s, %s, %s", tid, filter, search);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 the search term */
- ret = pk_engine_search_check (search, error);
+ ret = pk_engine_search_check (search, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* check the filter */
- ret = pk_engine_filter_check (filter, error);
+ ret = pk_engine_filter_check (filter, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_search_file:
**/
-gboolean
-pk_engine_search_file (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *search, GError **error)
+void
+pk_engine_search_file (PkEngine *engine, const gchar *tid, const gchar *filter,
+ const gchar *search, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("SearchFile method called: %s, %s, %s", tid, filter, search);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 the search term */
- ret = pk_engine_search_check (search, error);
+ ret = pk_engine_search_check (search, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* check the filter */
- ret = pk_engine_filter_check (filter, error);
+ ret = pk_engine_filter_check (filter, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_resolve:
**/
-gboolean
-pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *filter, const gchar *package, GError **error)
+void
+pk_engine_resolve (PkEngine *engine, const gchar *tid, const gchar *filter,
+ const gchar *package, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("Resolve method called: %s, %s, %s", tid, filter, package);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 the filter */
- ret = pk_engine_filter_check (filter, error);
+ ret = pk_engine_filter_check (filter, &error);
if (ret == FALSE) {
- return FALSE;
+ dbus_g_method_return_error (context, error);
+ return;
}
/* check for sanity */
ret = pk_strvalidate (package);
if (ret == FALSE) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
- "Invalid input passed to daemon");
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
+ "Invalid input passed to daemon");
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
ret = pk_backend_resolve (item->backend, filter, package);
if (ret == FALSE) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "Operation not yet supported by backend");
- pk_engine_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_get_depends:
**/
-gboolean
-pk_engine_get_depends (PkEngine *engine, const gchar *tid, const gchar *package_id, gboolean recursive, GError **error)
+void
+pk_engine_get_depends (PkEngine *engine, const gchar *tid, const gchar *package_id,
+ gboolean recursive, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("GetDepends method called: %s, %s, %i", tid, package_id, recursive);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 for sanity */
ret = pk_strvalidate (package_id);
if (ret == FALSE) {
- *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
- "Invalid input passed to daemon");
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
+ "Invalid input passed to daemon");
+ dbus_g_method_return_error (context, error);
+ return;
}
/* 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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
+ "The package id '%s' is not valid", package_id);
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
ret = pk_backend_get_depends (item->backend, package_id, recursive);
if (ret == FALSE) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "Operation not yet supported by backend");
- pk_engine_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_get_requires:
**/
-gboolean
-pk_engine_get_requires (PkEngine *engine, const gchar *tid, const gchar *package_id, gboolean recursive, GError **error)
+void
+pk_engine_get_requires (PkEngine *engine, const gchar *tid, const gchar *package_id,
+ gboolean recursive, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("GetRequires method called: %s, %s, %i", tid, package_id, recursive);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 for sanity */
ret = pk_strvalidate (package_id);
if (ret == FALSE) {
- *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
- "Invalid input passed to daemon");
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
+ "Invalid input passed to daemon");
+ dbus_g_method_return_error (context, error);
+ return;
}
/* 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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
+ "The package id '%s' is not valid", package_id);
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
ret = pk_backend_get_requires (item->backend, package_id, recursive);
if (ret == FALSE) {
- g_set_error (error, PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
- "Operation not yet supported by backend");
- pk_engine_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_get_update_detail:
**/
-gboolean
-pk_engine_get_update_detail (PkEngine *engine, const gchar *tid, const gchar *package_id, GError **error)
+void
+pk_engine_get_update_detail (PkEngine *engine, const gchar *tid, const gchar *package_id,
+ DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("GetUpdateDetail method called: %s, %s", tid, package_id);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 for sanity */
ret = pk_strvalidate (package_id);
if (ret == FALSE) {
- *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
- "Invalid input passed to daemon");
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
+ "Invalid input passed to daemon");
+ dbus_g_method_return_error (context, error);
+ return;
}
/* 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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
+ "The package id '%s' is not valid", package_id);
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_get_description:
**/
-gboolean
-pk_engine_get_description (PkEngine *engine, const gchar *tid, const gchar *package_id, GError **error)
+void
+pk_engine_get_description (PkEngine *engine, const gchar *tid, const gchar *package_id,
+ DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("GetDescription method called: %s, %s", tid, package_id);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 for sanity */
ret = pk_strvalidate (package_id);
if (ret == FALSE) {
- *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
- "Invalid input passed to daemon");
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
+ "Invalid input passed to daemon");
+ dbus_g_method_return_error (context, error);
+ return;
}
/* 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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
+ "The package id '%s' is not valid", package_id);
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_get_files:
**/
-gboolean
-pk_engine_get_files (PkEngine *engine, const gchar *tid, const gchar *package_id, GError **error)
+void
+pk_engine_get_files (PkEngine *engine, const gchar *tid, const gchar *package_id,
+ DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("GetFiles method called: %s, %s", tid, package_id);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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 for sanity */
ret = pk_strvalidate (package_id);
if (ret == FALSE) {
- *error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
- "Invalid input passed to daemon");
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INPUT_INVALID,
+ "Invalid input passed to daemon");
+ dbus_g_method_return_error (context, error);
+ return;
}
/* 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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_PACKAGE_ID_INVALID,
+ "The package id '%s' is not valid", package_id);
+ dbus_g_method_return_error (context, error);
+ return;
}
/* create a new backend */
item->backend = pk_engine_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
ret = pk_backend_get_files (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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_update_system:
**/
void
-pk_engine_update_system (PkEngine *engine, const gchar *tid, DBusGMethodInvocation *context, GError **dead_error)
+pk_engine_update_system (PkEngine *engine, const gchar *tid, DBusGMethodInvocation *context)
{
gboolean ret;
GError *error;
@@ -1619,7 +1682,7 @@ pk_engine_update_system (PkEngine *engine, const gchar *tid, DBusGMethodInvocati
**/
void
pk_engine_remove_package (PkEngine *engine, const gchar *tid, const gchar *package_id, gboolean allow_deps,
- DBusGMethodInvocation *context, GError **dead_error)
+ DBusGMethodInvocation *context)
{
PkTransactionItem *item;
gboolean ret;
@@ -1690,12 +1753,10 @@ pk_engine_remove_package (PkEngine *engine, const gchar *tid, const gchar *packa
/**
* pk_engine_install_package:
- *
- * This is async, so we have to treat it a bit carefully
**/
void
pk_engine_install_package (PkEngine *engine, const gchar *tid, const gchar *package_id,
- DBusGMethodInvocation *context, GError **dead_error)
+ DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
@@ -1766,12 +1827,10 @@ pk_engine_install_package (PkEngine *engine, const gchar *tid, const gchar *pack
/**
* pk_engine_install_file:
- *
- * This is async, so we have to treat it a bit carefully
**/
void
pk_engine_install_file (PkEngine *engine, const gchar *tid, const gchar *full_path,
- DBusGMethodInvocation *context, GError **dead_error)
+ DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
@@ -1833,12 +1892,10 @@ pk_engine_install_file (PkEngine *engine, const gchar *tid, const gchar *full_pa
/**
* pk_engine_rollback:
- *
- * This is async, so we have to treat it a bit carefully
**/
void
pk_engine_rollback (PkEngine *engine, const gchar *tid, const gchar *transaction_id,
- DBusGMethodInvocation *context, GError **dead_error)
+ DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
@@ -1900,12 +1957,9 @@ pk_engine_rollback (PkEngine *engine, const gchar *tid, const gchar *transaction
/**
* pk_engine_update_package:
- *
- * This is async, so we have to treat it a bit carefully
**/
void
-pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *package_id,
- DBusGMethodInvocation *context, GError **dead_error)
+pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *package_id, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
@@ -1977,52 +2031,53 @@ pk_engine_update_package (PkEngine *engine, const gchar *tid, const gchar *packa
/**
* pk_engine_get_repo_list:
**/
-gboolean
-pk_engine_get_repo_list (PkEngine *engine, const gchar *tid, GError **error)
+void
+pk_engine_get_repo_list (PkEngine *engine, const gchar *tid, DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
+ GError *error;
- g_return_val_if_fail (engine != NULL, FALSE);
- g_return_val_if_fail (PK_IS_ENGINE (engine), FALSE);
+ g_return_if_fail (engine != NULL);
+ g_return_if_fail (PK_IS_ENGINE (engine));
pk_debug ("GetRepoList method called: %s", tid);
/* 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_INITIALIZE_FAILED,
- "transaction_id '%s' not found", tid);
- return FALSE;
+ 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_backend_new (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;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_INITIALIZE_FAILED,
+ "Backend '%s' could not be initialized", engine->priv->backend);
+ dbus_g_method_return_error (context, error);
+ return;
}
ret = pk_backend_get_repo_list (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_item_delete (engine, item);
- return FALSE;
+ error = g_error_new (PK_ENGINE_ERROR, PK_ENGINE_ERROR_NOT_SUPPORTED,
+ "Operation not yet supported by backend");
+ dbus_g_method_return_error (context, error);
+ return;
}
pk_engine_item_add (engine, item);
- return TRUE;
+ dbus_g_method_return (context);
}
/**
* pk_engine_repo_enable:
- *
- * This is async, so we have to treat it a bit carefully
**/
void
pk_engine_repo_enable (PkEngine *engine, const gchar *tid, const gchar *repo_id, gboolean enabled,
- DBusGMethodInvocation *context, GError **dead_error)
+ DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
@@ -2084,13 +2139,11 @@ pk_engine_repo_enable (PkEngine *engine, const gchar *tid, const gchar *repo_id,
/**
* pk_engine_repo_set_data:
- *
- * This is async, so we have to treat it a bit carefully
**/
void
pk_engine_repo_set_data (PkEngine *engine, const gchar *tid, const gchar *repo_id,
const gchar *parameter, const gchar *value,
- DBusGMethodInvocation *context, GError **dead_error)
+ DBusGMethodInvocation *context)
{
gboolean ret;
PkTransactionItem *item;
diff --git a/src/pk-engine.h b/src/pk-engine.h
index 2ef3aaa..29b96e4 100644
--- a/src/pk-engine.h
+++ b/src/pk-engine.h
@@ -80,95 +80,88 @@ gboolean pk_engine_use_backend (PkEngine *engine,
gboolean pk_engine_get_tid (PkEngine *engine,
gchar **tid,
GError **error);
-gboolean pk_engine_get_updates (PkEngine *engine,
+void pk_engine_get_updates (PkEngine *engine,
const gchar *tid,
- GError **error);
-gboolean pk_engine_search_name (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_search_name (PkEngine *engine,
const gchar *tid,
const gchar *filter,
const gchar *search,
- GError **error);
-gboolean pk_engine_search_details (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_search_details (PkEngine *engine,
const gchar *tid,
const gchar *filter,
const gchar *search,
- GError **error);
-gboolean pk_engine_search_group (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_search_group (PkEngine *engine,
const gchar *tid,
const gchar *filter,
const gchar *search,
- GError **error);
-gboolean pk_engine_search_file (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_search_file (PkEngine *engine,
const gchar *tid,
const gchar *filter,
const gchar *search,
- GError **error);
-gboolean pk_engine_get_depends (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_get_depends (PkEngine *engine,
const gchar *tid,
const gchar *package_id,
gboolean recursive,
- GError **error);
-gboolean pk_engine_get_update_detail (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_get_update_detail (PkEngine *engine,
const gchar *tid,
const gchar *package_id,
- GError **error);
-gboolean pk_engine_get_requires (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_get_requires (PkEngine *engine,
const gchar *tid,
const gchar *package_id,
gboolean recursive,
- GError **error);
-gboolean pk_engine_get_description (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_get_description (PkEngine *engine,
const gchar *tid,
const gchar *package_id,
- GError **error);
-gboolean pk_engine_get_files (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_get_files (PkEngine *engine,
const gchar *tid,
const gchar *package_id,
- GError **error);
-gboolean pk_engine_resolve (PkEngine *engine,
+ DBusGMethodInvocation *context);
+void pk_engine_resolve (PkEngine *engine,
const gchar *tid,
const gchar *filter,
const gchar *package,
- GError **error);
+ DBusGMethodInvocation *context);
void pk_engine_rollback (PkEngine *engine,
const gchar *tid,
const gchar *transaction_id,
- DBusGMethodInvocation *context,
- GError **error);
+ DBusGMethodInvocation *context);
void pk_engine_refresh_cache (PkEngine *engine,
const gchar *tid,
gboolean force,
- DBusGMethodInvocation *context,
- GError **error);
+ DBusGMethodInvocation *context);
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);
+ DBusGMethodInvocation *context);
void pk_engine_remove_package (PkEngine *engine,
const gchar *tid,
const gchar *package_id,
gboolean allow_deps,
- DBusGMethodInvocation *context,
- GError **error);
+ DBusGMethodInvocation *context);
void pk_engine_install_package (PkEngine *engine,
const gchar *tid,
const gchar *package_id,
- DBusGMethodInvocation *context,
- GError **error);
+ DBusGMethodInvocation *context);
void pk_engine_install_file (PkEngine *engine,
const gchar *tid,
const gchar *full_path,
- DBusGMethodInvocation *context,
- GError **error);
+ DBusGMethodInvocation *context);
void pk_engine_update_package (PkEngine *engine,
const gchar *tid,
const gchar *package_id,
- DBusGMethodInvocation *context,
- GError **error);
+ DBusGMethodInvocation *context);
gboolean pk_engine_get_transaction_list (PkEngine *engine,
gchar ***transaction_list,
@@ -217,22 +210,20 @@ gboolean pk_engine_get_package (PkEngine *engine,
GError **error);
/* repo stuff */
-gboolean pk_engine_get_repo_list (PkEngine *engine,
+void pk_engine_get_repo_list (PkEngine *engine,
const gchar *tid,
- GError **error);
+ DBusGMethodInvocation *context);
void pk_engine_repo_enable (PkEngine *engine,
const gchar *tid,
const gchar *repo_id,
gboolean enabled,
- DBusGMethodInvocation *context,
- GError **error);
+ DBusGMethodInvocation *context);
void pk_engine_repo_set_data (PkEngine *engine,
const gchar *tid,
const gchar *repo_id,
const gchar *parameter,
const gchar *value,
- DBusGMethodInvocation *context,
- GError **error);
+ DBusGMethodInvocation *context);
G_END_DECLS
diff --git a/src/pk-interface.xml b/src/pk-interface.xml
index c4a90cd..c94142b 100644
--- a/src/pk-interface.xml
+++ b/src/pk-interface.xml
@@ -7,6 +7,7 @@
<arg type="s" name="tid" direction="out"/>
</method>
<method name="GetUpdates">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
</method>
<method name="RefreshCache">
@@ -19,53 +20,64 @@
<arg type="s" name="tid" direction="in"/>
</method>
<method name="Resolve">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="package" direction="in"/>
</method>
<method name="Rollback">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="transaction_id" direction="in"/>
</method>
<method name="SearchName">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
</method>
<method name="SearchDetails">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
</method>
<method name="SearchGroup">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
</method>
<method name="SearchFile">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="filter" direction="in"/>
<arg type="s" name="search" direction="in"/>
</method>
<method name="GetDepends">
+ <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="recursive" direction="in"/>
</method>
<method name="GetRequires">
+ <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="recursive" direction="in"/>
</method>
<method name="GetUpdateDetail">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
</method>
<method name="GetDescription"> <!-- orders Description signals for the package -->
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
</method>
<method name="GetFiles">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
<arg type="s" name="package_id" direction="in"/>
</method>
@@ -172,6 +184,7 @@
<!-- Repository stuff -->
<method name="GetRepoList">
+ <annotation name="org.freedesktop.DBus.GLib.Async" value=""/>
<arg type="s" name="tid" direction="in"/>
</method>
<method name="RepoEnable">
commit 00af22502dad0c3faf21e34b50c4b7c6e7e8203c
Author: Boyd Timothy <btimothy at gmail.com>
Date: Wed Nov 14 16:57:51 2007 -0700
Initial checkin of the zypp backend.
diff --git a/backends/Makefile.am b/backends/Makefile.am
index e04d333..63df794 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -28,6 +28,10 @@ if BACKEND_TYPE_PISI
SUBDIRS += pisi
endif
+if BACKEND_TYPE_ZYPP
+SUBDIRS += zypp
+endif
+
clean-local :
rm -f *~
diff --git a/backends/zypp/Makefile.am b/backends/zypp/Makefile.am
new file mode 100644
index 0000000..c5c3407
--- /dev/null
+++ b/backends/zypp/Makefile.am
@@ -0,0 +1,10 @@
+#SUBDIRS = helpers
+plugindir = @PK_PLUGIN_DIR@
+plugin_LTLIBRARIES = libpk_backend_zypp.la
+libpk_backend_zypp_la_SOURCES = pk-backend-zypp.cpp
+libpk_backend_zypp_la_LIBADD = @PK_PLUGIN_LIBS@
+# FIXME: Do the pkg-config stuff in $top_srcdir/configure.ac
+libpk_backend_zypp_la_LDFLAGS = -module -avoid-version `pkg-config --libs libzypp`
+libpk_backend_zypp_la_CFLAGS = @PK_PLUGIN_CFLAGS@ `pkg-config --cflags libzypp`
+libpk_backend_zypp_la_CPPFLAGS = @PK_PLUGIN_CFLAGS@ `pkg-config --cflags libzypp`
+
diff --git a/backends/zypp/pk-backend-zypp.cpp b/backends/zypp/pk-backend-zypp.cpp
new file mode 100644
index 0000000..7a123a4
--- /dev/null
+++ b/backends/zypp/pk-backend-zypp.cpp
@@ -0,0 +1,127 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
+ *
+ * Copyright (c) 2007 Novell, Inc.
+ *
+ * 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 <gmodule.h>
+#include <glib.h>
+#include <string.h>
+#include <pk-backend.h>
+
+#include <zypp/ZYppFactory.h>
+#include <zypp/ResObject.h>
+#include <zypp/ResPoolProxy.h>
+#include <zypp/ui/Selectable.h>
+#include <zypp/Patch.h>
+#include <zypp/Selection.h>
+#include <zypp/Package.h>
+#include <zypp/Pattern.h>
+#include <zypp/Language.h>
+#include <zypp/Product.h>
+#include <zypp/Repository.h>
+#include <zypp/RepoManager.h>
+
+/**
+ * backend_get_groups:
+ */
+/*
+static void
+backend_get_groups (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_GROUP_ENUM_ACCESSORIES,
+ PK_GROUP_ENUM_GAMES,
+ PK_GROUP_ENUM_GRAPHICS,
+ PK_GROUP_ENUM_INTERNET,
+ PK_GROUP_ENUM_OFFICE,
+ PK_GROUP_ENUM_OTHER,
+ PK_GROUP_ENUM_PROGRAMMING,
+ PK_GROUP_ENUM_MULTIMEDIA,
+ PK_GROUP_ENUM_SYSTEM,
+ -1);
+}
+*/
+
+/**
+ * backend_get_filters:
+ */
+/*
+static void
+backend_get_filters (PkBackend *backend, PkEnumList *elist)
+{
+ g_return_if_fail (backend != NULL);
+ pk_enum_list_append_multiple (elist,
+ PK_FILTER_ENUM_GUI,
+ PK_FILTER_ENUM_INSTALLED,
+ PK_FILTER_ENUM_DEVELOPMENT,
+ -1);
+}
+*/
+
+/**
+ * backend_get_repo_list:
+ */
+static void
+backend_get_repo_list (PkBackend *backend)
+{
+ g_return_if_fail (backend != NULL);
+
+ zypp::RepoManager manager;
+ std::list <zypp::RepoInfo> repos = manager.knownRepositories();
+ for (std::list <zypp::RepoInfo>::iterator it = repos.begin(); it != repos.end(); it++) {
+ pk_backend_repo_detail (backend,
+ it->name().c_str(),
+ it->alias().c_str(),
+ it->enabled());
+ }
+
+ pk_backend_finished (backend);
+}
+
+extern "C" PK_BACKEND_OPTIONS (
+ "Zypp", /* description */
+ "Boyd Timothy <btimothy at gmail.com>, Scott Reeves <sreeves at novell.com>", /* author */
+ NULL, /* initalize */
+ NULL, /* destroy */
+ NULL, /* get_groups */
+ NULL, /* get_filters */
+ NULL, /* cancel */
+ NULL, /* get_depends */
+ NULL, /* get_description */
+ NULL, /* get_files */
+ NULL, /* get_requires */
+ NULL, /* get_update_detail */
+ NULL, /* get_updates */
+ NULL, /* install_package */
+ NULL, /* install_file */
+ NULL, /* refresh_cache */
+ NULL, /* remove_package */
+ NULL, /* resolve */
+ NULL, /* rollback */
+ NULL, /* search_details */
+ NULL, /* search_file */
+ NULL, /* search_group */
+ NULL, /* search_name */
+ NULL, /* update_package */
+ NULL, /* update_system */
+ backend_get_repo_list, /* get_repo_list */
+ NULL, /* repo_enable */
+ NULL /* repo_set_data */
+);
diff --git a/configure.ac b/configure.ac
index 75c2e85..7eb61fb 100755
--- a/configure.ac
+++ b/configure.ac
@@ -262,7 +262,7 @@ dnl - Compile time default choice of backend
dnl ---------------------------------------------------------------------------
AC_ARG_WITH([default_backend],
AS_HELP_STRING([--with-default-backend=<option>],
- [Default backend to use alpm,apt,box,conary,dummy,smart,yum,pisi (dummy)]))
+ [Default backend to use alpm,apt,box,conary,dummy,smart,yum,pisi,zypp (dummy)]))
# default to a sane option for the installed tool
if test x$with_default_backend = x; then
if test -f /usr/bin/yum ; then
@@ -279,6 +279,8 @@ if test x$with_default_backend = x; then
with_default_backend=smart
elif test -f /usr/bin/pisi ; then
with_default_backend=pisi
+ elif test -f /usr/bin/zypp ; then
+ with_default_backend=zypp
else
with_default_backend=dummy
fi
@@ -439,6 +441,7 @@ AM_CONDITIONAL(BACKEND_TYPE_BOX, [test x$with_default_backend = xbox], [using BO
AM_CONDITIONAL(BACKEND_TYPE_ALPM, [test x$with_default_backend = xalpm], [using ALPM backend])
AM_CONDITIONAL(BACKEND_TYPE_SMART, [test x$with_default_backend = xsmart], [using SMART backend])
AM_CONDITIONAL(BACKEND_TYPE_PISI, [test x$with_default_backend = xpisi], [using PiSi backend])
+AM_CONDITIONAL(BACKEND_TYPE_ZYPP, [test x$with_default_backend = xzypp], [using Zypp backend])
dnl ---------------------------------------------------------------------------
@@ -469,6 +472,7 @@ backends/yum/Makefile
backends/yum/helpers/Makefile
backends/pisi/Makefile
backends/pisi/helpers/Makefile
+backends/zypp/Makefile
data/Makefile
data/tests/Makefile
libselftest/Makefile
More information about the PackageKit
mailing list