Blob Blame Raw
From b6ed011ee153bb698d176019e9c2fbedeacad5fa Mon Sep 17 00:00:00 2001
From: Jakub Filak <jfilak@redhat.com>
Date: Thu, 19 Mar 2015 08:35:38 +0100
Subject: [PATCH] applet: get the list of problems through D-Bus service

The default dump location directory is not iterable for regular users.

I cherry-picked and merged these two commits:
57895ccd0c6289faada8e5f3327e276ffded46b5
3484123353de0d77745d348cd371c317e9a52483

Signed-off-by: Jakub Filak <jfilak@redhat.com>
---
 src/applet/applet.c | 47 +++--------------------------------------------
 1 file changed, 3 insertions(+), 44 deletions(-)

diff --git a/src/applet/applet.c b/src/applet/applet.c
index 644da60..3198ae5 100644
--- a/src/applet/applet.c
+++ b/src/applet/applet.c
@@ -70,7 +70,6 @@ enum
 static GDBusConnection *g_system_bus;
 static GtkStatusIcon *ap_status_icon;
 static GtkWidget *ap_menu;
-static char **s_dirs;
 static GList *g_deferred_crash_queue;
 static guint g_deferred_timeout;
 static int g_signal_pipe[2];
@@ -429,29 +428,6 @@ static char *build_message(problem_info_t *pi)
     return msg;
 }
 
-static GList *add_dirs_to_dirlist(GList *dirlist, const char *dirname)
-{
-    DIR *dir = opendir(dirname);
-    if (!dir)
-        return dirlist;
-
-    struct dirent *dent;
-    while ((dent = readdir(dir)) != NULL)
-    {
-        if (dot_or_dotdot(dent->d_name))
-            continue;
-        char *full_name = concat_path_file(dirname, dent->d_name);
-        struct stat statbuf;
-        if (lstat(full_name, &statbuf) == 0 && S_ISDIR(statbuf.st_mode))
-            dirlist = g_list_prepend(dirlist, full_name);
-        else
-            free(full_name);
-    }
-    closedir(dir);
-
-    return g_list_reverse(dirlist);
-}
-
 /* Compares the problem directories to list saved in
  * $XDG_CACHE_HOME/abrt/applet_dirlist and updates the applet_dirlist
  * with updated list.
@@ -461,13 +437,9 @@ static GList *add_dirs_to_dirlist(GList *dirlist, const char *dirname)
  */
 static void new_dir_exists(GList **new_dirs)
 {
-    GList *dirlist = NULL;
-    char **pp = s_dirs;
-    while (*pp)
-    {
-        dirlist = add_dirs_to_dirlist(dirlist, *pp);
-        pp++;
-    }
+    GList *dirlist = get_problems_over_dbus(/*don't authorize*/false);
+    if (dirlist == ERR_PTR)
+        return;
 
     const char *cachedir = g_get_user_cache_dir();
     char *dirlist_name = concat_path_file(cachedir, "abrt");
@@ -1660,19 +1632,6 @@ int main(int argc, char** argv)
     load_event_config_data();
     load_user_settings("abrt-applet");
 
-    const char *default_dirs[] = {
-        g_settings_dump_location,
-        NULL,
-        NULL,
-    };
-    argv += optind;
-    if (!argv[0])
-    {
-        default_dirs[1] = concat_path_file(g_get_user_cache_dir(), "abrt/spool");
-        argv = (char**)default_dirs;
-    }
-    s_dirs = argv;
-
     /* Initialize our (dbus_abrt) machinery: hook _system_ dbus to glib main loop.
      * (session bus is left to be handled by libnotify, see below) */
     DBusError err;
-- 
2.1.0