[Openvas-commits] r13279 - in trunk/gsd: . src

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Wed Apr 18 11:21:35 CEST 2012


Author: aheinecke
Date: 2012-04-18 11:21:35 +0200 (Wed, 18 Apr 2012)
New Revision: 13279

Added:
   trunk/gsd/src/dlg_newPortList.ui
Modified:
   trunk/gsd/ChangeLog
   trunk/gsd/src/CMakeLists.txt
   trunk/gsd/src/gsd_control.cpp
   trunk/gsd/src/gsd_dialogs.cpp
   trunk/gsd/src/gsd_dialogs.h
   trunk/gsd/src/gsd_dlg.cpp
   trunk/gsd/src/gsd_dlg.h
   trunk/gsd/src/gsd_mw.cpp
   trunk/gsd/src/gsd_mw.h
   trunk/gsd/src/omp_string_builder.cpp
Log:
Add support to create Port Lists


Modified: trunk/gsd/ChangeLog
===================================================================
--- trunk/gsd/ChangeLog	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/ChangeLog	2012-04-18 09:21:35 UTC (rev 13279)
@@ -1,7 +1,28 @@
 2012-04-18  Andre Heinecke <aheinecke at intevation.de>
 
+	Add support for Port List creation.
+
 	* src/omp_command.cpp: Add OMP_DEBUG Macro for protocol debugging
 
+	* src/dlg_newPortList.ui: New Ui for creating port lists
+
+	* src/gsd_dlg.h, gsd_dlg.cpp (gsd_dlg::new_port_list_dlg): New
+
+	* src/omp_string_builder.cpp (omp_string_builder::appendCreateParameter):
+	Add support for port_list create paramaters
+
+	* src/gsd_mw.cpp (gsd_mw::createConnections): Connect New_PortList action
+	(gsd_mw::new_port_list_dlg): New emit signal to create new port list
+
+	* src/gsd_control.cpp (gsd_control::start): Forward create_port_list
+	signal
+
+	* src/gsd_dialogs.h (dlg_new_port_list): New Class
+
+	* src/gsd_dialogs.cpp (dlg_new_port_list::create): New
+
+	* src/CMakeLists.txt: Compile dlg_newPortList.ui
+
 2011-04-17  Andre Heinecke <aheinecke at intevation.de>
 
 	Start implementing support for port lists

Modified: trunk/gsd/src/CMakeLists.txt
===================================================================
--- trunk/gsd/src/CMakeLists.txt	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/CMakeLists.txt	2012-04-18 09:21:35 UTC (rev 13279)
@@ -119,6 +119,7 @@
   dlg_new_note.ui
   dlg_new_override.ui
   dlg_new_slave.ui
+  dlg_newPortList.ui
   dlg_modify_config.ui
   dlg_modify_scan_pref.ui
   dlg_modify_family.ui

Added: trunk/gsd/src/dlg_newPortList.ui
===================================================================
--- trunk/gsd/src/dlg_newPortList.ui	                        (rev 0)
+++ trunk/gsd/src/dlg_newPortList.ui	2012-04-18 09:21:35 UTC (rev 13279)
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>newPortList</class>
+ <widget class="QDialog" name="newPortList">
+  <property name="windowModality">
+   <enum>Qt::WindowModal</enum>
+  </property>
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>390</width>
+    <height>160</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>New Port List</string>
+  </property>
+  <property name="windowIcon">
+   <iconset resource="img/images.qrc">
+    <normaloff>:/img/favicon.gif</normaloff>:/img/favicon.gif</iconset>
+  </property>
+  <layout class="QGridLayout" name="gridLayout">
+   <item row="0" column="0">
+    <widget class="QLabel" name="label">
+     <property name="text">
+      <string>Name</string>
+     </property>
+    </widget>
+   </item>
+   <item row="0" column="1" colspan="3">
+    <widget class="QLineEdit" name="le_name"/>
+   </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="label_2">
+     <property name="text">
+      <string>Comment (optional)</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1" colspan="3">
+    <widget class="QLineEdit" name="le_comment"/>
+   </item>
+   <item row="2" column="0">
+    <widget class="QLabel" name="label_3">
+     <property name="text">
+      <string>Port Range</string>
+     </property>
+    </widget>
+   </item>
+   <item row="2" column="1" colspan="3">
+    <widget class="QLineEdit" name="le_port_range">
+     <property name="text">
+      <string>T:1-5,7,9,U:1-3,5,7,9</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="2">
+    <widget class="QPushButton" name="pb_cancel">
+     <property name="text">
+      <string>Cancel</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="3">
+    <widget class="QPushButton" name="pb_create">
+     <property name="text">
+      <string>Create</string>
+     </property>
+    </widget>
+   </item>
+   <item row="3" column="1">
+    <spacer name="horizontalSpacer">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>40</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <tabstops>
+  <tabstop>le_name</tabstop>
+  <tabstop>le_comment</tabstop>
+  <tabstop>le_port_range</tabstop>
+  <tabstop>pb_create</tabstop>
+  <tabstop>pb_cancel</tabstop>
+ </tabstops>
+ <resources>
+  <include location="img/images.qrc"/>
+ </resources>
+ <connections>
+  <connection>
+   <sender>pb_cancel</sender>
+   <signal>released()</signal>
+   <receiver>newPortList</receiver>
+   <slot>close()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>247</x>
+     <y>188</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>194</x>
+     <y>108</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

Modified: trunk/gsd/src/gsd_control.cpp
===================================================================
--- trunk/gsd/src/gsd_control.cpp	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/gsd_control.cpp	2012-04-18 09:21:35 UTC (rev 13279)
@@ -359,6 +359,10 @@
            dialogs,
            SLOT (new_credential_dlg ()));
   connect (mainwindow,
+           SIGNAL (sig_create_port_list ()),
+           dialogs,
+           SLOT (new_port_list_dlg ()));
+  connect (mainwindow,
            SIGNAL (sig_create_agent ()),
            dialogs,
            SLOT (new_agent_dlg ()));

Modified: trunk/gsd/src/gsd_dialogs.cpp
===================================================================
--- trunk/gsd/src/gsd_dialogs.cpp	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/gsd_dialogs.cpp	2012-04-18 09:21:35 UTC (rev 13279)
@@ -836,7 +836,7 @@
 }
 
 /**
- * @brief Emits a signal to start task creation.
+ * @brief Emits a signal to start target creation.
  */
 void
 dlg_new_target::create ()
@@ -1095,7 +1095,32 @@
   return true;
 }
 
+/**
+ * @class dlg_new_port_list.
+ */
+/**
+ * @brief Emits a signal to start port_list creation.
+ */
+void
+dlg_new_port_list::create ()
+{
+  if (le_name->text ().length () == 0 ||
+      le_port_range->text ().length () == 0)
+    {
+      return;
+    }
 
+  QString type;
+
+  QMap<QString, QString> parameter;
+  parameter.insert ("name", le_name->text ());
+  parameter.insert ("comment", le_comment->text ());
+  parameter.insert ("port_range", le_port_range->text ());
+
+  emit sig_create (omp_utilities::PORT_LIST, parameter);
+  this->close ();
+}
+
 /**
  * @class dlg_new_credential.
  */

Modified: trunk/gsd/src/gsd_dialogs.h
===================================================================
--- trunk/gsd/src/gsd_dialogs.h	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/gsd_dialogs.h	2012-04-18 09:21:35 UTC (rev 13279)
@@ -42,6 +42,7 @@
 #include "ui_dlg_newCredential.h"
 #include "ui_dlg_newAgent.h"
 #include "ui_dlg_newConfig.h"
+#include "ui_dlg_newPortList.h"
 #include "ui_dlg_new_note.h"
 #include "ui_dlg_new_override.h"
 #include "ui_dlg_new_slave.h"
@@ -265,7 +266,28 @@
     void update ();
 };
 
+/**
+ * @brief Protos and data structures for new port list.
+ */
+class dlg_new_port_list : public create_dialog, private Ui::newPortList
+{
+  Q_OBJECT
 
+  public:
+    dlg_new_port_list ()
+      {
+        setupUi (this);
+        connect (pb_create,
+                 SIGNAL (released ()),
+                 this,
+                 SLOT (create ()));
+      };
+    ~dlg_new_port_list () {};
+
+  private slots:
+    void create ();
+};
+
 /**
  * @brief Protos and data structures for new task.
  */

Modified: trunk/gsd/src/gsd_dlg.cpp
===================================================================
--- trunk/gsd/src/gsd_dlg.cpp	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/gsd_dlg.cpp	2012-04-18 09:21:35 UTC (rev 13279)
@@ -49,6 +49,7 @@
   new_credential = new dlg_new_credential ();
   new_agent = new dlg_new_agent ();
   new_slave = new dlg_new_slave ();
+  new_port_list = new dlg_new_port_list ();
   modify_task = new dlg_modify_task ();
 
   connect (login,
@@ -107,6 +108,10 @@
            SIGNAL (sig_create (int, QMap<QString, QString>)),
            this,
            SLOT (create (int, QMap<QString, QString>)));
+  connect (new_port_list,
+           SIGNAL (sig_create (int, QMap<QString, QString>)),
+           this,
+           SLOT (create (int, QMap <QString, QString>)));
   connect (new_task,
            SIGNAL (sig_new_target ()),
            this,
@@ -131,6 +136,10 @@
            SIGNAL (sig_new_credential ()),
            this,
            SLOT (new_credential_dlg ()));
+  connect (new_target,
+           SIGNAL (sig_new_port_list ()),
+           this,
+           SLOT (new_port_list_dlg ()));
   connect (modify_task,
            SIGNAL (sig_modify (int, QMap<QString, QString>)),
            this,
@@ -161,6 +170,7 @@
   free (new_schedule);
   free (new_escalator);
   free (new_credential);
+  free (new_port_list);
   free (new_agent);
 }
 
@@ -222,6 +232,14 @@
   new_credential->show ();
 }
 
+/**
+ * @brief Shows the new port_list dialog.
+ */
+void
+gsd_dlg::new_port_list_dlg ()
+{
+  new_port_list->show ();
+}
 
 /**
  * @brief Shows the new escalator dialog.

Modified: trunk/gsd/src/gsd_dlg.h
===================================================================
--- trunk/gsd/src/gsd_dlg.h	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/gsd_dlg.h	2012-04-18 09:21:35 UTC (rev 13279)
@@ -81,6 +81,7 @@
     void new_target_dlg ();
     void new_task_dlg ();
     void new_slave_dlg ();
+    void new_port_list_dlg ();
     void modify_task_dlg (int pos);
 
     void request_failed (int, int, int);
@@ -100,6 +101,7 @@
     dlg_new_agent *new_agent;
     dlg_new_slave *new_slave;
     dlg_modify_task *modify_task;
+    dlg_new_port_list *new_port_list;
 
   public:
     gsd_dlg (gsd_control *ctl);

Modified: trunk/gsd/src/gsd_mw.cpp
===================================================================
--- trunk/gsd/src/gsd_mw.cpp	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/gsd_mw.cpp	2012-04-18 09:21:35 UTC (rev 13279)
@@ -920,6 +920,10 @@
            SIGNAL (triggered (bool)),
            this,
            SLOT (new_credential_dlg ()));
+  connect (actionNew_PortList,
+           SIGNAL (triggered (bool)),
+           this,
+           SLOT (new_port_list_dlg ()));
   connect (actionDelete_Credential,
            SIGNAL (triggered (bool)),
            this,
@@ -1186,6 +1190,7 @@
   actionNew_Agent->setDisabled (false);
   actionNew_Schedule->setDisabled (false);
   actionNew_Slave->setDisabled (false);
+  actionNew_PortList->setDisabled (false);
 }
 
 
@@ -1616,6 +1621,14 @@
   emit sig_create_credential ();
 }
 
+/**
+ * @brief Requests the new port_list dialog.
+ */
+void
+gsd_mw::new_port_list_dlg ()
+{
+  emit sig_create_port_list ();
+}
 
 /**
  * @brief Requests the new agent dialog.

Modified: trunk/gsd/src/gsd_mw.h
===================================================================
--- trunk/gsd/src/gsd_mw.h	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/gsd_mw.h	2012-04-18 09:21:35 UTC (rev 13279)
@@ -113,6 +113,8 @@
     void sig_delete_slave (int);
     void sig_create_slave ();
 
+    void sig_create_port_list ();
+
     void sig_details_config (int);
     void sig_details_credential (int);
     void sig_details_escalator (int);
@@ -172,6 +174,7 @@
     void new_credential_dlg ();
     void new_agent_dlg ();
     void new_slave_dlg ();
+    void new_port_list_dlg ();
     void modify_note_dlg ();
     void modify_override_dlg ();
     void modify_config_dlg ();

Modified: trunk/gsd/src/omp_string_builder.cpp
===================================================================
--- trunk/gsd/src/omp_string_builder.cpp	2012-04-18 09:10:43 UTC (rev 13278)
+++ trunk/gsd/src/omp_string_builder.cpp	2012-04-18 09:21:35 UTC (rev 13279)
@@ -789,6 +789,22 @@
           return com;
         }
     }
+  if (type == omp_utilities::PORT_LIST)
+    {
+      if (parameter["name"].compare ("") == 0 ||
+          parameter["port_range"].compare ("") == 0)
+        return QString ("");
+      else
+        {
+          com = QString ("<name>%1</name>"
+                         "<comment>%2</comment>"
+                         "<port_range>%3</port_range>"
+                         ).arg (parameter["name"])
+                          .arg (parameter["comment"])
+                          .arg (parameter["port_range"]);
+          return com;
+        }
+    }
   return QString ("");
 }
 



More information about the Openvas-commits mailing list