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

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