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

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