doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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