Blob Blame History Raw
From 6ba08b9f28343da5c6102833d1a5062475f09468 Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Tue, 24 Mar 2015 19:03:52 +0100
Subject: [PATCH] libabrt: add new function fetching full problem data over
 DBus

This function is required because users may not have direct file system
access to the problem data.

Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
 src/include/libabrt.h      |  7 +++++++
 src/lib/problem_api_dbus.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+)

diff --git a/src/include/libabrt.h b/src/include/libabrt.h
index 37704dd..5a019fb 100644
--- a/src/include/libabrt.h
+++ b/src/include/libabrt.h
@@ -169,6 +169,13 @@ int delete_problem_dirs_over_dbus(const GList *problem_dir_paths);
 problem_data_t *get_problem_data_dbus(const char *problem_dir_path);
 
 /**
+  @brief Fetches full problem data for specified problem id
+
+  @return problem_data_t or ERR_PTR on failure
+*/
+problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path);
+
+/**
   @brief Fetches all problems from problem database
 
   @param authorize If set to true will try to fetch even problems owned by other users (will require root authorization over policy kit)
diff --git a/src/lib/problem_api_dbus.c b/src/lib/problem_api_dbus.c
index 2d77898..549175c 100644
--- a/src/lib/problem_api_dbus.c
+++ b/src/lib/problem_api_dbus.c
@@ -183,3 +183,47 @@ GList *get_problems_over_dbus(bool authorize)
 
     return list;
 }
+
+problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path)
+{
+    INITIALIZE_LIBABRT();
+
+    GDBusProxy *proxy = get_dbus_proxy();
+    if (!proxy)
+        return ERR_PTR;
+
+    GError *error = NULL;
+    GVariant *result = g_dbus_proxy_call_sync(proxy,
+                                    "GetProblemData",
+                                    g_variant_new("(s)", problem_dir_path),
+                                    G_DBUS_CALL_FLAGS_NONE,
+                                    -1,
+                                    NULL,
+                                    &error);
+
+    if (error)
+    {
+        error_msg(_("Can't get problem data from abrt-dbus: %s"), error->message);
+        g_error_free(error);
+        return ERR_PTR;
+    }
+
+    GVariantIter *iter = NULL;
+    g_variant_get(result, "(a{s(its)})", &iter);
+
+    gchar *name = NULL;
+    gint flags;
+    gulong size;
+    gchar *value = NULL;
+
+    problem_data_t *pd = problem_data_new();
+    while (g_variant_iter_loop(iter, "{&s(it&s)}", &name, &flags, &size, &value))
+        problem_data_add_ext(pd, name, value, flags, size);
+
+    problem_data_add(pd, CD_DUMPDIR, problem_dir_path,
+            CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE + CD_FLAG_LIST);
+
+    g_variant_unref(result);
+
+    return pd;
+}
-- 
2.1.0