From cafb9545c0e251b8ece493a341e7b209bde00a11 Mon Sep 17 00:00:00 2001
From: Martin Milata <mmilata@redhat.com>
Date: Mon, 20 Jan 2014 15:24:31 +0100
Subject: [ABRT PATCH 13/13] applet: do not say the report is anonymous when
 ureport auth is enabled

Depends on https://github.com/abrt/libreport/pull/232

Related to rhbz#1053042, rhbz#1055619.

Signed-off-by: Martin Milata <mmilata@redhat.com>
---
 configure.ac           |  2 ++
 src/applet/Makefile.am |  1 +
 src/applet/applet.c    | 43 +++++++++++++++++++++++++++++++++++++++----
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index a5f7a79..479289c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -139,6 +139,7 @@ EVENTS_DIR='${datadir}/libreport/events'
 EVENTS_CONF_DIR='${sysconfdir}/libreport/events.d'
 ENABLE_SOCKET_OR_DBUS='-DENABLE_DBUS=1'
 DEFAULT_DUMP_DIR_MODE=$($PKG_CONFIG --variable=dd_mode libreport)
+LIBREPORT_PLUGINS_CONF_DIR=$($PKG_CONFIG --variable=plugins_conf_dir libreport)
 PROBLEMS_CONFIG_INTERFACES_DIR=${dbusinterfacedir}
 
 AC_ARG_WITH([defaultdumplocation],
@@ -226,6 +227,7 @@ AC_SUBST(EVENTS_CONF_DIR)
 AC_SUBST(EVENTS_DIR)
 AC_SUBST(DEFAULT_DUMP_LOCATION)
 AC_SUBST(DEFAULT_DUMP_DIR_MODE)
+AC_SUBST(LIBREPORT_PLUGINS_CONF_DIR)
 AC_SUBST(PROBLEMS_CONFIG_INTERFACES_DIR)
 
 AC_ARG_WITH(bodhi,
diff --git a/src/applet/Makefile.am b/src/applet/Makefile.am
index ec50fcd..fe7ec98 100644
--- a/src/applet/Makefile.am
+++ b/src/applet/Makefile.am
@@ -9,6 +9,7 @@ abrt_applet_CPPFLAGS = \
     -DBIN_DIR=\"$(bindir)\" \
     -DLIBEXEC_DIR=\"$(libexecdir)\" \
     -DICON_DIR=\"${datadir}/abrt/icons/hicolor/48x48/status\" \
+    -DLIBREPORT_PLUGINS_CONF_DIR=\"$(LIBREPORT_PLUGINS_CONF_DIR)\" \
     $(XICE_CFLAGS) \
     $(XSMP_CFLAGS) \
     $(GTK_CFLAGS) \
diff --git a/src/applet/applet.c b/src/applet/applet.c
index 9971e04..131d2ab 100644
--- a/src/applet/applet.c
+++ b/src/applet/applet.c
@@ -90,6 +90,27 @@ static bool is_autoreporting_enabled(void)
     return get_configured_bool_or_default("AutoreportingEnabled", g_settings_autoreporting);
 }
 
+static bool is_ureport_auth_enabled(void)
+{
+    bool success, auth_enabled;
+    map_string_t *settings = new_map_string();
+    char *ureport_conf_path = concat_path_file(LIBREPORT_PLUGINS_CONF_DIR, "ureport.conf");
+
+    success = load_conf_file(ureport_conf_path, settings, /*skipKeysWithoutValue*/false);
+    if (success)
+    {
+        const char *value = get_map_string_item_or_NULL(settings, "SSLClientAuth");
+        auth_enabled = (value && value[0] != '\0');
+    }
+    else
+        auth_enabled = true; /* assume it is, do not claim the reporting is anonymous */
+
+    free(ureport_conf_path);
+    free_map_string(settings);
+
+    return auth_enabled;
+}
+
 static const char *get_autoreport_event_name(void)
 {
     load_user_settings("abrt-applet");
@@ -99,14 +120,28 @@ static const char *get_autoreport_event_name(void)
 
 static void ask_start_autoreporting()
 {
+    struct strbuf *question = strbuf_new();
+    question = strbuf_append_str(question,
+         _("The report which will be sent does not contain any security sensitive data. "
+           "Therefore it is not necessary to bother you next time and require any further action by you. \n"));
+
+    if (is_ureport_auth_enabled())
+    {
+        question = strbuf_append_str(question,
+            _("Do you want to enable automatically submitted crash reports?"));
+    }
+    else
+    {
+        question = strbuf_append_str(question,
+            _("Do you want to enable automatically submitted anonymous crash reports?"));
+    }
+
     /* The "Yes" response will be saved even if user don't check the
      * "Don't ask me again" box.
      */
-    const int ret = run_ask_yes_no_save_result_dialog("AutoreportingEnabled",
-     _("The report which will be sent does not contain any security sensitive data. "
-       "Therefore it is not necessary to bother you next time and require any further action by you. "
-       "\nDo you want to enable automatically submitted anonymous crash reports?"),
+    const int ret = run_ask_yes_no_save_result_dialog("AutoreportingEnabled", question->buf,
        /*parent wnd */ NULL);
+    strbuf_free(question);
 
     load_user_settings("abrt-applet");
 
-- 
1.8.3.1

