[Openvas-commits] r8510 - in trunk/gsa-desktop: . src
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Jul 19 18:54:03 CEST 2010
Author: raimund
Date: 2010-07-19 18:54:02 +0200 (Mon, 19 Jul 2010)
New Revision: 8510
Modified:
trunk/gsa-desktop/ChangeLog
trunk/gsa-desktop/src/gsa_desktop_control.cpp
trunk/gsa-desktop/src/gsa_desktop_control.h
trunk/gsa-desktop/src/gsa_desktop_ui.cpp
trunk/gsa-desktop/src/gsa_desktop_ui.h
trunk/gsa-desktop/src/omp_commands.cpp
trunk/gsa-desktop/src/omp_commands.h
trunk/gsa-desktop/src/omp_connector.cpp
trunk/gsa-desktop/src/omp_connector.h
Log:
* src/gsa_desktop_ui.cpp (createConnections): Signal/slot configuration for
delete target.
(eventFilter): Added target actions to event filter.
(modifyWidgets): Install eventifilter on target table, connect change
signal.
(target_delete, target_selectionchanged): New.
* src/gsa_desktop_control.cpp (createConnections): Signal/slot configuration
for delete target.
(target_delete): New.
* src/omp_connector.cpp (deleteTarget): New.
* src/omp_commands.cpp (target_delete): New.
* src/gsa_desktop_ui.h, gsa_desktop_control.h, omp_connector.h,
omp_commands.h: Updated prototypes.
Modified: trunk/gsa-desktop/ChangeLog
===================================================================
--- trunk/gsa-desktop/ChangeLog 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/ChangeLog 2010-07-19 16:54:02 UTC (rev 8510)
@@ -1,5 +1,25 @@
2010-07-19 Raimund Renkert <raimund.renkert at intevation.de>
+ * src/gsa_desktop_ui.cpp (createConnections): Signal/slot configuration for
+ delete target.
+ (eventFilter): Added target actions to event filter.
+ (modifyWidgets): Install eventifilter on target table, connect change
+ signal.
+ (target_delete, target_selectionchanged): New.
+
+ * src/gsa_desktop_control.cpp (createConnections): Signal/slot configuration
+ for delete target.
+ (target_delete): New.
+
+ * src/omp_connector.cpp (deleteTarget): New.
+
+ * src/omp_commands.cpp (target_delete): New.
+
+ * src/gsa_desktop_ui.h, gsa_desktop_control.h, omp_connector.h,
+ omp_commands.h: Updated prototypes.
+
+2010-07-19 Raimund Renkert <raimund.renkert at intevation.de>
+
Added new target dialog.
* src/gsa_desktop_ui.cpp (createToolBars): Enable new target button.
@@ -21,7 +41,6 @@
* src/src.pro: Added new files.
-
2010-07-19 Raimund Renkert <raimund.renkert at intevation.de>
* src/gsa_desktop_ui.cpp (createConnections): Signal/slot configuration for
Modified: trunk/gsa-desktop/src/gsa_desktop_control.cpp
===================================================================
--- trunk/gsa-desktop/src/gsa_desktop_control.cpp 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/src/gsa_desktop_control.cpp 2010-07-19 16:54:02 UTC (rev 8510)
@@ -123,6 +123,8 @@
connect (mainwin, SIGNAL (sig_create_target (QString, QString, QString,
QString)),
this, SLOT (target_create (QString, QString, QString, QString)));
+ connect (mainwin, SIGNAL (sig_delete_target (QString)), this,
+ SLOT (target_delete (QString)));
}
@@ -706,6 +708,24 @@
/**
+ * @brief SLOT that deletes a target.
+ *
+ * Deletes a target, identified by its id.
+ *
+ * @param id Target id
+ */
+void
+gsa_desktop_control::target_delete (QString id)
+{
+ if (this->connector->deleteTarget (id) != 0)
+ {
+ QMessageBox::information (NULL,tr ("Status Error"),
+ tr ("Could not delete target!"));
+ }
+}
+
+
+/**
* @brief SLOT to display login faults
*
* Displays errors that occured while trying to login.
Modified: trunk/gsa-desktop/src/gsa_desktop_control.h
===================================================================
--- trunk/gsa-desktop/src/gsa_desktop_control.h 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/src/gsa_desktop_control.h 2010-07-19 16:54:02 UTC (rev 8510)
@@ -97,6 +97,7 @@
void config_delete (QString id);
void target_create (QString name, QString comment, QString hosts,
QString lsc_id);
+ void target_delete (QString id);
void log (QString msg, int prio);
Modified: trunk/gsa-desktop/src/gsa_desktop_ui.cpp
===================================================================
--- trunk/gsa-desktop/src/gsa_desktop_ui.cpp 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/src/gsa_desktop_ui.cpp 2010-07-19 16:54:02 UTC (rev 8510)
@@ -196,7 +196,6 @@
targets->addActionToToolBar (actionDelete_Target);
targets->addSeparator ();
targets->addActionToToolBar (actionDetails_Target);
- actionDelete_Target->setEnabled (false);
actionDetails_Target->setEnabled (false);
escalators->addActionToToolBar (actionNew_Escalator);
@@ -481,6 +480,8 @@
SLOT (config_delete ()));
connect (actionNew_Target, SIGNAL (triggered (bool)), this,
SLOT (newTarget_dlg ()));
+ connect (actionDelete_Target, SIGNAL (triggered (bool)), this,
+ SLOT (target_delete ()));
}
@@ -655,6 +656,8 @@
tw_tasks->installEventFilter (this);
tw_configs->installEventFilter (this);
+ tw_targets->installEventFilter (this);
+
dw_tasks->raise ();
connect (tw_tasks->selectionModel (),
@@ -668,6 +671,10 @@
SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)),
this, SLOT (config_selectionchanged (const QModelIndex&,
const QModelIndex&)));
+ connect (tw_targets->selectionModel (),
+ SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)),
+ this, SLOT (target_selectionchanged (const QModelIndex &,
+ const QModelIndex &)));
}
@@ -1125,6 +1132,53 @@
/**
+ * @brief SLOT to delete currently selected target.
+ *
+ * Emits sig_delete_target (...) to delete the config
+ * Emits sig_req_targets (...) to refresh the configview
+ */
+void
+gsa_desktop_ui::target_delete ()
+{
+ QDomNode ent;
+ QModelIndexList selected = targets->getTable ()->selectionModel ()->selectedRows (0);
+ if (selected.size () != 0)
+ {
+ ent = targetModel->getEntity (selected.at (0).row ());
+ int ret = QMessageBox::warning (this, tr ("Delete?"),
+ QString (tr ("Do you really want delete"
+ " the target :<b>%1</b>"))
+ .arg (configModel->getValue
+ (ent.toElement (), "name")),
+ QMessageBox::Yes, QMessageBox::No);
+ switch (ret)
+ {
+ case QMessageBox::Yes:
+ {
+ targetModel->removeEntity (selected.at (0).row ());
+ emit sig_delete_target (targetModel->getAttr (ent.toElement (), "target id"));
+ emit sig_req_targets ();
+ return;
+ }
+ case QMessageBox::No:
+ {
+ return;
+ }
+ default:
+ {
+ return;
+ }
+ }
+ }
+ else
+ {
+ QMessageBox::information (NULL,tr ("Status Error"),
+ tr ("No target selected!"));
+ }
+}
+
+
+/**
* @brief SLOT that starts the update dockwidget
*/
void
@@ -1455,11 +1509,52 @@
gsa_desktop_ui::config_selectionchanged (const QModelIndex &newindex,
const QModelIndex &oldindex)
{
+
actionDelete_Config->setEnabled (true);
}
/**
+ * @brief SLOT to enable/disable action buttons in config widget.
+ *
+ * @param newindex: new selected index
+ * @param oldindex: previous selected index
+ */
+void
+gsa_desktop_ui::target_selectionchanged (const QModelIndex &newindex,
+ const QModelIndex &oldindex)
+{
+ int row = -1;
+ QModelIndexList selected = targets->getTable ()->selectionModel ()
+ ->selectedRows (0);
+ if (selected.empty ())
+ return;
+ if (newindex.row () >= 0 )
+ {
+ row = newindex.row ();
+ }
+ else if (newindex.row () < 0 && selected.at (0).row () > 0)
+ {
+ row = selected.at (0).row ();
+ }
+ else
+ {
+ row = 0;
+ }
+ QDomNode ent = targetModel->getEntity (row);
+ if (ent.isNull ())
+ {
+ return;
+ }
+ QString stat = targetModel->getValue (ent.toElement (), "in_use");
+ if (stat.compare ("0") == 0)
+ actionDelete_Target->setEnabled (true);
+ else
+ actionDelete_Target->setEnabled (false);
+}
+
+
+/**
* @brief SLOT to start runnig a task
*/
void
@@ -2018,6 +2113,9 @@
if (widget->objectName ().compare ("tw_configs") == 0)
config_selectionchanged (QModelIndex (), QModelIndex ());
+
+ if (widget->objectName ().compare ("tw_targets") == 0)
+ target_selectionchanged (QModelIndex (), QModelIndex ());
}
if (e->type () == QEvent::FocusOut)
{
@@ -2036,6 +2134,10 @@
{
actionDelete_Config->setEnabled (false);
}
+ if (widget->objectName ().compare ("tw_targets") != 0)
+ {
+ actionDelete_Target->setEnabled (false);
+ }
}
return false;
Modified: trunk/gsa-desktop/src/gsa_desktop_ui.h
===================================================================
--- trunk/gsa-desktop/src/gsa_desktop_ui.h 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/src/gsa_desktop_ui.h 2010-07-19 16:54:02 UTC (rev 8510)
@@ -168,6 +168,7 @@
void sig_create_config (QString, QString, QString);
void sig_delete_config (QString);
void sig_create_target (QString, QString, QString, QString);
+ void sig_delete_target (QString);
public:
gsa_desktop_ui ();
@@ -251,11 +252,13 @@
const QModelIndex &oldindex);
void config_selectionchanged (const QModelIndex &newindex,
const QModelIndex &oldindex);
-
+ void target_selectionchanged (const QModelIndex &newindex,
+ const QModelIndex &oldindex);
void config_create (QString name, QString comment, QString base);
void config_delete ();
void target_create (QString name, QString comment, QString hosts,
QString lsc_id);
+ void target_delete ();
private:
QLabel *la_update;
Modified: trunk/gsa-desktop/src/omp_commands.cpp
===================================================================
--- trunk/gsa-desktop/src/omp_commands.cpp 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/src/omp_commands.cpp 2010-07-19 16:54:02 UTC (rev 8510)
@@ -405,3 +405,40 @@
}
return -1;
}
+
+
+/**
+ * @brief Deletes a target by id
+ *
+ * Establishes a connection to the openvas-manager using the inherited
+ * functions openConnection () and closeConnection ().
+ *
+ * @param id Target id
+ *
+ * @return 0 on success, 1 if no connection could be established, -1 on error.
+ */
+int
+omp_commands::target_delete (QString id)
+{
+ if (openConnection () == 0)
+ {
+ gnutls_session_t session = getSession ();
+ if (id.isNull ())
+ return -1;
+
+ QString temp = tr ("<delete_target target_id=\"%1\"/>").arg (id);
+ int ret = openvas_server_sendf (&session, temp.toLatin1 ());
+
+ entity_t response = NULL;
+ if (read_entity (&session, &response)) return -1;
+
+ closeConnection ();
+
+ return ret;
+ }
+ else
+ {
+ return 1;
+ }
+}
+
Modified: trunk/gsa-desktop/src/omp_commands.h
===================================================================
--- trunk/gsa-desktop/src/omp_commands.h 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/src/omp_commands.h 2010-07-19 16:54:02 UTC (rev 8510)
@@ -59,6 +59,7 @@
int target_create (QString name, QString comment, QString hosts,
QString lsc_id);
+ int target_delete (QString id);
};
#endif
Modified: trunk/gsa-desktop/src/omp_connector.cpp
===================================================================
--- trunk/gsa-desktop/src/omp_connector.cpp 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/src/omp_connector.cpp 2010-07-19 16:54:02 UTC (rev 8510)
@@ -474,6 +474,20 @@
/**
+ * @brief Deletes a target.
+ *
+ * @param id Target id, Target to delete.
+ *
+ * @return 0 on success, 1 if no connection could be established, -1 on error
+ */
+int
+omp_connector::deleteTarget (QString id)
+{
+ return commands->target_delete (id);
+}
+
+
+/**
* @brief Stops updating Tasks.
*
* Emits sig_stopped_taskupdate ().
Modified: trunk/gsa-desktop/src/omp_connector.h
===================================================================
--- trunk/gsa-desktop/src/omp_connector.h 2010-07-19 16:47:23 UTC (rev 8509)
+++ trunk/gsa-desktop/src/omp_connector.h 2010-07-19 16:54:02 UTC (rev 8510)
@@ -119,6 +119,7 @@
int deleteConfig (QString id);
int createTarget (QString name, QString comment, QString hosts,
QString lsc_id);
+ int deleteTarget (QString id);
};
#endif
More information about the Openvas-commits
mailing list