doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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