Blame SOURCES/0186-report-gtk-offer-users-to-create-private-ticket.patch

28bab8
From 056aea2ac07d86d7cbade4814570f03c2e6cbec7 Mon Sep 17 00:00:00 2001
28bab8
From: Matej Habrnal <mhabrnal@redhat.com>
28bab8
Date: Tue, 22 Mar 2016 14:39:59 +0100
28bab8
Subject: [PATCH] report-gtk: offer users to create private ticket
28bab8
28bab8
Make the feature public and offer it only in the cases where it make
28bab8
sense (i.e. do not offer users to crate private ticket for
28bab8
'report_Uploader').
28bab8
28bab8
Related to rhbz#1279453
28bab8
28bab8
Signed-off-by: Jakub Filak <jfilak@redhat.com>
28bab8
Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
28bab8
---
28bab8
 src/gui-wizard-gtk/wizard.c     | 109 ++++++++++++++++++++++++++++++++---
28bab8
 src/gui-wizard-gtk/wizard.glade | 123 ----------------------------------------
28bab8
 2 files changed, 102 insertions(+), 130 deletions(-)
28bab8
28bab8
diff --git a/src/gui-wizard-gtk/wizard.c b/src/gui-wizard-gtk/wizard.c
28bab8
index 3a7db9c..17257ec 100644
28bab8
--- a/src/gui-wizard-gtk/wizard.c
28bab8
+++ b/src/gui-wizard-gtk/wizard.c
28bab8
@@ -124,6 +124,21 @@ static void add_workflow_buttons(GtkBox *box, GHashTable *workflows, GCallback f
28bab8
 static void set_auto_event_chain(GtkButton *button, gpointer user_data);
28bab8
 static void start_event_run(const char *event_name);
28bab8
 
28bab8
+static GtkWidget *g_sens_ticket;
28bab8
+static GtkToggleButton *g_sens_ticket_cb;
28bab8
+
28bab8
+enum {
28bab8
+    PRIV_WARN_SHOW_BTN      = 0x01,
28bab8
+    PRIV_WARN_HIDE_BTN      = 0x02,
28bab8
+    PRIV_WARN_SHOW_MSG      = 0x04,
28bab8
+    PRIV_WARN_HIDE_MSG      = 0x08,
28bab8
+    PRIV_WARN_BTN_CHECKED   = 0x10,
28bab8
+    PRIV_WARN_BTN_UNCHECKED = 0x20,
28bab8
+};
28bab8
+
28bab8
+static void private_ticket_creation_warning(int flags);
28bab8
+static void update_private_ticket_creation_warning_for_selected_event(void);
28bab8
+
28bab8
 enum
28bab8
 {
28bab8
     /* Note: need to update types in
28bab8
@@ -202,11 +217,13 @@ static const gchar *const page_names[] =
28bab8
 #define PRIVATE_TICKET_CB "private_ticket_cb"
28bab8
 
28bab8
 #define SENSITIVE_DATA_WARN "sensitive_data_warning"
28bab8
+#define SENSITIVE_DATA_WARN_MSG "sensitive_data_warning_message"
28bab8
 #define SENSITIVE_LIST "ls_sensitive_words"
28bab8
 static const gchar *misc_widgets[] =
28bab8
 {
28bab8
     SENSITIVE_DATA_WARN,
28bab8
     SENSITIVE_LIST,
28bab8
+    PRIVATE_TICKET_CB,
28bab8
     NULL
28bab8
 };
28bab8
 
28bab8
@@ -956,6 +973,7 @@ static int check_event_config(const char *event_name)
28bab8
     {
28bab8
         g_hash_table_unref(errors);
28bab8
         show_event_opt_error_dialog(event_name);
28bab8
+        update_private_ticket_creation_warning_for_selected_event();
28bab8
         return 1;
28bab8
     }
28bab8
     return 0;
28bab8
@@ -2160,17 +2178,52 @@ static void on_sensitive_ticket_clicked_cb(GtkWidget *button, gpointer user_data
28bab8
     }
28bab8
 }
28bab8
 
28bab8
-static void add_sensitive_data_warning(void)
28bab8
+static void on_privacy_info_btn(GtkWidget *button, gpointer user_data)
28bab8
+{
28bab8
+    if (g_event_selected == NULL)
28bab8
+        return;
28bab8
+
28bab8
+    show_event_config_dialog(g_event_selected, GTK_WINDOW(g_top_most_window));
28bab8
+}
28bab8
+
28bab8
+static void private_ticket_creation_warning(int flags)
28bab8
 {
28bab8
-    GtkBuilder *builder = make_builder();
28bab8
+    if (flags & PRIV_WARN_HIDE_BTN)
28bab8
+    {
28bab8
+        gtk_widget_hide(GTK_WIDGET(g_sens_ticket));
28bab8
+    }
28bab8
+
28bab8
+    if (flags & PRIV_WARN_SHOW_BTN)
28bab8
+    {
28bab8
+        gtk_widget_show_all(GTK_WIDGET(g_sens_ticket));
28bab8
+        gtk_widget_show(GTK_WIDGET(g_sens_ticket));
28bab8
+    }
28bab8
+
28bab8
+    if (flags & PRIV_WARN_BTN_UNCHECKED)
28bab8
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_sens_ticket_cb), FALSE);
28bab8
+
28bab8
+    if (flags & PRIV_WARN_BTN_CHECKED)
28bab8
+        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(g_sens_ticket_cb), TRUE);
28bab8
+
28bab8
+    if (flags & PRIV_WARN_HIDE_MSG)
28bab8
+        clear_warnings();
28bab8
+
28bab8
+    if (flags & PRIV_WARN_SHOW_MSG)
28bab8
+    {
28bab8
+       add_warning(_("Possible sensitive data detected, feel free to edit the report and remove them."));
28bab8
+       show_warnings();
28bab8
+    }
28bab8
+}
28bab8
 
28bab8
-    GtkWidget *sens_data_warn = GTK_WIDGET(gtk_builder_get_object(builder, SENSITIVE_DATA_WARN));
28bab8
-    GtkButton *sens_ticket_cb = GTK_BUTTON(gtk_builder_get_object(builder, PRIVATE_TICKET_CB));
28bab8
+static void add_sensitive_data_warning(void)
28bab8
+{
28bab8
+    int flags = PRIV_WARN_SHOW_MSG;
28bab8
 
28bab8
-    g_signal_connect(sens_ticket_cb, "toggled", G_CALLBACK(on_sensitive_ticket_clicked_cb), NULL);
28bab8
-    add_widget_to_warning_area(GTK_WIDGET(sens_data_warn));
28bab8
+    event_config_t *cfg = get_event_config(g_event_selected);
28bab8
+    if (cfg != NULL && cfg->ec_supports_restricted_access)
28bab8
+        flags |= PRIV_WARN_SHOW_BTN | PRIV_WARN_BTN_CHECKED;
28bab8
 
28bab8
-    g_object_unref(builder);
28bab8
+    private_ticket_creation_warning(flags);
28bab8
 }
28bab8
 
28bab8
 static void show_warnings(void)
28bab8
@@ -2627,6 +2680,19 @@ static char *get_next_processed_event(GList **events_list)
28bab8
     return event_name;
28bab8
 }
28bab8
 
28bab8
+static void update_private_ticket_creation_warning_for_selected_event(void)
28bab8
+{
28bab8
+    event_config_t *cfg = get_event_config(g_event_selected);
28bab8
+    if (cfg == NULL || !cfg->ec_supports_restricted_access)
28bab8
+        return;
28bab8
+
28bab8
+    int flags = PRIV_WARN_SHOW_BTN | PRIV_WARN_HIDE_MSG;
28bab8
+    if (ec_restricted_access_enabled(cfg))
28bab8
+        flags |= PRIV_WARN_BTN_CHECKED;
28bab8
+
28bab8
+    private_ticket_creation_warning(flags);
28bab8
+}
28bab8
+
28bab8
 static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer user_data)
28bab8
 {
28bab8
     //int page_no = gtk_assistant_get_current_page(g_assistant);
28bab8
@@ -2669,6 +2735,11 @@ static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer us
28bab8
 
28bab8
     if (pages[PAGENO_SUMMARY].page_widget == page)
28bab8
     {
28bab8
+        if (get_global_create_private_ticket())
28bab8
+            private_ticket_creation_warning(  PRIV_WARN_SHOW_BTN
28bab8
+                                            | PRIV_WARN_BTN_CHECKED
28bab8
+                                            | PRIV_WARN_HIDE_MSG);
28bab8
+
28bab8
         if (!g_expert_mode)
28bab8
         {
28bab8
             /* Skip intro screen */
28bab8
@@ -2718,6 +2789,8 @@ static void on_page_prepare(GtkNotebook *assistant, GtkWidget *page, gpointer us
28bab8
 
28bab8
     if (pages[PAGENO_EDIT_COMMENT].page_widget == page)
28bab8
     {
28bab8
+        update_private_ticket_creation_warning_for_selected_event();
28bab8
+
28bab8
         gtk_widget_set_sensitive(g_btn_next, false);
28bab8
         on_comment_changed(gtk_text_view_get_buffer(g_tv_comment), NULL);
28bab8
     }
28bab8
@@ -3527,6 +3600,28 @@ void create_assistant(GtkApplication *app, bool expert_mode)
28bab8
     gtk_box_pack_start(g_box_assistant, GTK_WIDGET(g_assistant), true, true, 0);
28bab8
 
28bab8
     gtk_box_pack_start(g_box_assistant, GTK_WIDGET(g_widget_warnings_area), false, false, 0);
28bab8
+
28bab8
+    /* Private ticket warning */
28bab8
+    {
28bab8
+        g_sens_ticket = GTK_WIDGET(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0));
28bab8
+        gtk_widget_set_no_show_all(GTK_WIDGET(g_sens_ticket), TRUE);
28bab8
+        gtk_widget_hide(GTK_WIDGET(g_sens_ticket));
28bab8
+
28bab8
+        g_sens_ticket_cb = GTK_TOGGLE_BUTTON(gtk_check_button_new_with_label(_("Restrict access to the report")));
28bab8
+        gtk_widget_set_margin_start(GTK_WIDGET(g_sens_ticket_cb), 5);
28bab8
+        gtk_widget_show(GTK_WIDGET(g_sens_ticket_cb));
28bab8
+        g_signal_connect(g_sens_ticket_cb, "toggled", G_CALLBACK(on_sensitive_ticket_clicked_cb), NULL);
28bab8
+
28bab8
+        GtkLinkButton *privacy_info_btn = GTK_LINK_BUTTON(gtk_link_button_new_with_label("", _("Learn more about restricted access in the configuration")));
28bab8
+        gtk_widget_show(GTK_WIDGET(privacy_info_btn));
28bab8
+        g_signal_connect(privacy_info_btn, "clicked", G_CALLBACK(on_privacy_info_btn), NULL);
28bab8
+
28bab8
+        gtk_box_pack_start(GTK_BOX(g_sens_ticket), GTK_WIDGET(g_sens_ticket_cb), false, false, 5);
28bab8
+        gtk_box_pack_start(GTK_BOX(g_sens_ticket), GTK_WIDGET(privacy_info_btn), false, false, 5);
28bab8
+
28bab8
+        gtk_box_pack_start(g_box_assistant, GTK_WIDGET(g_sens_ticket), false, true, 5);
28bab8
+    }
28bab8
+
28bab8
     gtk_box_pack_start(g_box_assistant, GTK_WIDGET(g_box_buttons), false, false, 5);
28bab8
 
28bab8
     gtk_widget_show_all(GTK_WIDGET(g_box_buttons));
28bab8
diff --git a/src/gui-wizard-gtk/wizard.glade b/src/gui-wizard-gtk/wizard.glade
28bab8
index 9296bca..441b2fc 100644
28bab8
--- a/src/gui-wizard-gtk/wizard.glade
28bab8
+++ b/src/gui-wizard-gtk/wizard.glade
28bab8
@@ -16,129 +16,6 @@
28bab8
       <column type="gpointer"/>
28bab8
     </columns>
28bab8
   </object>
28bab8
-  <object class="GtkWindow" id="sensitiveDataWarning_w">
28bab8
-    <property name="can_focus">False</property>
28bab8
-    <child>
28bab8
-      <object class="GtkBox" id="sensitive_data_warning">
28bab8
-        <property name="visible">True</property>
28bab8
-        <property name="can_focus">False</property>
28bab8
-        <property name="orientation">vertical</property>
28bab8
-        <child>
28bab8
-          <object class="GtkBox" id="box5">
28bab8
-            <property name="visible">True</property>
28bab8
-            <property name="can_focus">False</property>
28bab8
-            <child>
28bab8
-              <object class="GtkImage" id="image2">
28bab8
-                <property name="visible">True</property>
28bab8
-                <property name="can_focus">False</property>
28bab8
-                <property name="margin_left">4</property>
28bab8
-                <property name="stock">gtk-media-record</property>
28bab8
-                <property name="icon-size">1</property>
28bab8
-              </object>
28bab8
-              <packing>
28bab8
-                <property name="expand">False</property>
28bab8
-                <property name="fill">True</property>
28bab8
-                <property name="position">0</property>
28bab8
-              </packing>
28bab8
-            </child>
28bab8
-            <child>
28bab8
-              <object class="GtkLabel" id="label10">
28bab8
-                <property name="visible">True</property>
28bab8
-                <property name="can_focus">False</property>
28bab8
-                <property name="margin_left">6</property>
28bab8
-                <property name="margin_top">3</property>
28bab8
-                <property name="margin_bottom">3</property>
28bab8
-                <property name="label" translatable="yes">Possible sensitive data detected, feel free to edit the report and remove them.</property>
28bab8
-                <attributes>
28bab8
-                  <attribute name="weight" value="bold"/>
28bab8
-                </attributes>
28bab8
-              </object>
28bab8
-              <packing>
28bab8
-                <property name="expand">False</property>
28bab8
-                <property name="fill">True</property>
28bab8
-                <property name="position">1</property>
28bab8
-              </packing>
28bab8
-            </child>
28bab8
-          </object>
28bab8
-          <packing>
28bab8
-            <property name="expand">False</property>
28bab8
-            <property name="fill">True</property>
28bab8
-            <property name="position">0</property>
28bab8
-          </packing>
28bab8
-        </child>
28bab8
-        <child>
28bab8
-          <object class="GtkBox" id="box6">
28bab8
-            <property name="visible">True</property>
28bab8
-            <property name="can_focus">False</property>
28bab8
-            <child>
28bab8
-              <object class="GtkBox" id="box4">
28bab8
-                <property name="visible">True</property>
28bab8
-                <property name="can_focus">False</property>
28bab8
-                <property name="orientation">vertical</property>
28bab8
-                <child>
28bab8
-                  <object class="GtkCheckButton" id="private_ticket_cb">
28bab8
-                    <property name="label" translatable="yes">Restrict access to the report</property>
28bab8
-                    <property name="visible">True</property>
28bab8
-                    <property name="can_focus">True</property>
28bab8
-                    <property name="receives_default">False</property>
28bab8
-                    <property name="xalign">0</property>
28bab8
-                    <property name="draw_indicator">True</property>
28bab8
-                  </object>
28bab8
-                  <packing>
28bab8
-                    <property name="expand">False</property>
28bab8
-                    <property name="fill">True</property>
28bab8
-                    <property name="position">0</property>
28bab8
-                  </packing>
28bab8
-                </child>
28bab8
-                <child>
28bab8
-                  <object class="GtkLabel" id="label11">
28bab8
-                    <property name="visible">True</property>
28bab8
-                    <property name="can_focus">False</property>
28bab8
-                    <property name="margin_top">13</property>
28bab8
-                    <property name="label" translatable="yes">No one except Red Hat employees will be allowed to see the report with restricted access (not even you)</property>
28bab8
-                    <attributes>
28bab8
-                      <attribute name="style" value="italic"/>
28bab8
-                    </attributes>
28bab8
-                  </object>
28bab8
-                  <packing>
28bab8
-                    <property name="expand">False</property>
28bab8
-                    <property name="fill">True</property>
28bab8
-                    <property name="position">1</property>
28bab8
-                  </packing>
28bab8
-                </child>
28bab8
-                <child>
28bab8
-                  <object class="GtkLinkButton" id="linkbutton1">
28bab8
-                    <property name="label" translatable="yes">Read more about reports with restricted access</property>
28bab8
-                    <property name="visible">True</property>
28bab8
-                    <property name="can_focus">True</property>
28bab8
-                    <property name="receives_default">True</property>
28bab8
-                    <property name="has_tooltip">True</property>
28bab8
-                    <property name="relief">none</property>
28bab8
-                    <property name="uri">https://github.com/abrt/abrt/wiki/FAQ#reports-with-restricted-access</property>
28bab8
-                  </object>
28bab8
-                  <packing>
28bab8
-                    <property name="expand">False</property>
28bab8
-                    <property name="fill">True</property>
28bab8
-                    <property name="position">2</property>
28bab8
-                  </packing>
28bab8
-                </child>
28bab8
-              </object>
28bab8
-              <packing>
28bab8
-                <property name="expand">False</property>
28bab8
-                <property name="fill">True</property>
28bab8
-                <property name="position">0</property>
28bab8
-              </packing>
28bab8
-            </child>
28bab8
-          </object>
28bab8
-          <packing>
28bab8
-            <property name="expand">False</property>
28bab8
-            <property name="fill">True</property>
28bab8
-            <property name="position">1</property>
28bab8
-          </packing>
28bab8
-        </child>
28bab8
-      </object>
28bab8
-    </child>
28bab8
-  </object>
28bab8
   <object class="GtkWindow" id="window0">
28bab8
     <property name="can_focus">False</property>
28bab8
     <child>
28bab8
-- 
28bab8
1.8.3.1
28bab8