Blame SOURCES/0129-libabrt-add-new-function-fetching-full-problem-data-.patch

06486d
From 10bc280ed5fe1de3cca8dc9d61cd364de4a93807 Mon Sep 17 00:00:00 2001
06486d
From: Jakub Filak <jfilak@redhat.com>
06486d
Date: Tue, 24 Mar 2015 19:03:52 +0100
06486d
Subject: [PATCH] libabrt: add new function fetching full problem data over
06486d
 DBus
06486d
06486d
This function is required because users may not have direct file system
06486d
access to the problem data.
06486d
06486d
Related: #1224984
06486d
06486d
Signed-off-by: Jakub Filak <jfilak@redhat.com>
06486d
---
06486d
 src/include/libabrt.h      |  7 +++++++
06486d
 src/lib/problem_api_dbus.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
06486d
 2 files changed, 51 insertions(+)
06486d
06486d
diff --git a/src/include/libabrt.h b/src/include/libabrt.h
06486d
index 3749a31..6a51c80 100644
06486d
--- a/src/include/libabrt.h
06486d
+++ b/src/include/libabrt.h
06486d
@@ -156,6 +156,13 @@ int delete_problem_dirs_over_dbus(const GList *problem_dir_paths);
06486d
 problem_data_t *get_problem_data_dbus(const char *problem_dir_path);
06486d
 
06486d
 /**
06486d
+  @brief Fetches full problem data for specified problem id
06486d
+
06486d
+  @return problem_data_t or ERR_PTR on failure
06486d
+*/
06486d
+problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path);
06486d
+
06486d
+/**
06486d
   @brief Fetches all problems from problem database
06486d
 
06486d
   @param authorize If set to true will try to fetch even problems owned by other users (will require root authorization over policy kit)
06486d
diff --git a/src/lib/problem_api_dbus.c b/src/lib/problem_api_dbus.c
06486d
index 2d77898..549175c 100644
06486d
--- a/src/lib/problem_api_dbus.c
06486d
+++ b/src/lib/problem_api_dbus.c
06486d
@@ -183,3 +183,47 @@ GList *get_problems_over_dbus(bool authorize)
06486d
 
06486d
     return list;
06486d
 }
06486d
+
06486d
+problem_data_t *get_full_problem_data_over_dbus(const char *problem_dir_path)
06486d
+{
06486d
+    INITIALIZE_LIBABRT();
06486d
+
06486d
+    GDBusProxy *proxy = get_dbus_proxy();
06486d
+    if (!proxy)
06486d
+        return ERR_PTR;
06486d
+
06486d
+    GError *error = NULL;
06486d
+    GVariant *result = g_dbus_proxy_call_sync(proxy,
06486d
+                                    "GetProblemData",
06486d
+                                    g_variant_new("(s)", problem_dir_path),
06486d
+                                    G_DBUS_CALL_FLAGS_NONE,
06486d
+                                    -1,
06486d
+                                    NULL,
06486d
+                                    &error);
06486d
+
06486d
+    if (error)
06486d
+    {
06486d
+        error_msg(_("Can't get problem data from abrt-dbus: %s"), error->message);
06486d
+        g_error_free(error);
06486d
+        return ERR_PTR;
06486d
+    }
06486d
+
06486d
+    GVariantIter *iter = NULL;
06486d
+    g_variant_get(result, "(a{s(its)})", &iter);
06486d
+
06486d
+    gchar *name = NULL;
06486d
+    gint flags;
06486d
+    gulong size;
06486d
+    gchar *value = NULL;
06486d
+
06486d
+    problem_data_t *pd = problem_data_new();
06486d
+    while (g_variant_iter_loop(iter, "{&s(it&s)}", &name, &flags, &size, &value))
06486d
+        problem_data_add_ext(pd, name, value, flags, size);
06486d
+
06486d
+    problem_data_add(pd, CD_DUMPDIR, problem_dir_path,
06486d
+            CD_FLAG_TXT + CD_FLAG_ISNOTEDITABLE + CD_FLAG_LIST);
06486d
+
06486d
+    g_variant_unref(result);
06486d
+
06486d
+    return pd;
06486d
+}
06486d
-- 
06486d
2.4.3
06486d