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

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