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

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