[Openvas-commits] r2725 - in trunk/openvas-client: . src/gui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Mar 10 15:44:46 CET 2009


Author: felix
Date: 2009-03-10 15:44:44 +0100 (Tue, 10 Mar 2009)
New Revision: 2725

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/src/gui/priofiltermngr_dlg.c
Log:
Allow deletion of overrides from the Priority Filter Manager GUI.
Prototypical implementation.

* src/gui/priofiltermngr_dlg.c: Added reference to extern 
global_filter_active flag.

* src/gui/priofiltermngr_dlg.c (priorityfiltermanager_dialog):
Respect the global_filter_active flag, allow deletion of overrides.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-03-10 14:39:50 UTC (rev 2724)
+++ trunk/openvas-client/ChangeLog	2009-03-10 14:44:44 UTC (rev 2725)
@@ -1,5 +1,16 @@
 2009-03-10  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	Allow deletion of overrides from the Priority Filter Manager GUI.
+	Prototypical implementation.
+
+	* src/gui/priofiltermngr_dlg.c: Added reference to extern 
+	global_filter_active flag.
+	
+	* src/gui/priofiltermngr_dlg.c (priorityfiltermanager_dialog):
+	Respect the global_filter_active flag, allow deletion of overrides.
+
+2009-03-10  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	Added function to remove an override from a priority_filter.
 
 	* src/util/priority_filter.c, src/util/priority_filter.h

Modified: trunk/openvas-client/src/gui/priofiltermngr_dlg.c
===================================================================
--- trunk/openvas-client/src/gui/priofiltermngr_dlg.c	2009-03-10 14:39:50 UTC (rev 2724)
+++ trunk/openvas-client/src/gui/priofiltermngr_dlg.c	2009-03-10 14:44:44 UTC (rev 2725)
@@ -54,6 +54,9 @@
 extern struct arglist* MainDialog;
 extern struct context* Context;
 
+/* temporary, should move to context, now global in priority_filter.c */
+extern gboolean global_filter_active;
+
 /**
  * @brief Add a page showing an override to a listnotebook.
  * 
@@ -94,7 +97,7 @@
   // If the global_filter is not initialized, try to load or initialize it.
   if (global_filter == NULL)
     {
-      char * filter_file = g_build_filename (prefs_get_nessushome(),
+      gchar * filter_file = g_build_filename (prefs_get_nessushome(),
                                             ".openvas", "priofilter.xml", NULL);
       global_filter = priority_filter_from_xml (filter_file);
 
@@ -109,19 +112,18 @@
 
   dialog = gtk_dialog_new_with_buttons (_("Priority Filter Manager"),
                                          window, GTK_DIALOG_DESTROY_WITH_PARENT,
-                                         GTK_STOCK_DELETE, GTK_RESPONSE_CANCEL,
+                                         GTK_STOCK_DELETE, 12,
                                          GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
                                          NULL);
 
   gtk_window_set_transient_for(GTK_WINDOW(dialog), window);
-  g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
 
   gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
 
   if (global_filter)
-    label = gtk_label_new(_("Priority Filter Manager is just a dummy-implementation yet (but Testfilter switched on!)"));
+    label = gtk_label_new(_("Priority Filter Manager is just a test-implementation yet (but Testfilter switched on!)"));
   else
-    label = gtk_label_new(_("Priority Filter Manager is just a dummy-implementation yet (but Testfilter switched off!)"));
+    label = gtk_label_new(_("Priority Filter Manager is just a test-implementation yet (but Testfilter switched off!)"));
 
   gtk_widget_show(label);
   gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0);
@@ -143,12 +145,32 @@
 
   response = gtk_dialog_run (GTK_DIALOG (dialog));
 
-#ifdef PRIO_FILTERMNG_DLG_DELET
   // Handle the response
-  if (response == GTK_RESPONSE_CANCEL)
-#endif
+  while (response == 12) // Click on "Delete"
+    {
+      char* selected_override_name = listnotebook_get_selected (overrides_notebook);
+      // Prototypical removal (@TODO Do not mess around with strings but manage list of overrides in the first place)
+      GSList* walk = global_filter->overrides;
+      while (walk)
+        {
+          priority_override_t* override = walk->data;
+          if (!strcmp(override->name, selected_override_name))
+            {
+              priority_filter_remove (global_filter, override);
+              listnotebook_remove_page (overrides_notebook, selected_override_name);
+            }
+          walk = g_slist_next (walk);
+        }
+      gchar * filter_file = g_build_filename (prefs_get_nessushome(),
+                                              ".openvas", "priofilter.xml", NULL);
+      priority_filter_to_xml (global_filter, filter_file);
+      g_free (filter_file);
+      printf ("BUGME: reponded\n");
+      response = gtk_dialog_run (GTK_DIALOG (dialog));
+    }
+    
+  gtk_widget_destroy (dialog);
 
-
   /* If currently a Report is selected in the GUI,
     Update the scopeview, as we want the values and icon change immediately
     according to the priority_filter.
@@ -156,7 +178,7 @@
     scopetreeview. That did not work in practice, however.
     @TODO make meachanism clean.
   */
-  if (Context->type == CONTEXT_REPORT)
+  if (Context->type == CONTEXT_REPORT && global_filter_active == TRUE)
     {
       // Flag the current context as being (un)filtered
       Context->is_priority_mapped = (Context->is_priority_mapped)?FALSE:TRUE;



More information about the Openvas-commits mailing list