mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-14 09:00:01 +02:00
* ImportFirewallConfigurationWizard.cpp (accept): see #2253
"importer should not creates objects while still in the middle of the wizard". Importer wizard creates new objects in the object tree only when user clicks Finish and abandons results if they click Cancel.
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
2011-03-20 vadim <vadim@netcitadel.com>
|
||||||
|
|
||||||
|
* ImportFirewallConfigurationWizard.cpp (accept): see #2253
|
||||||
|
"importer should not creates objects while still in the middle of
|
||||||
|
the wizard". Importer wizard creates new objects in the object
|
||||||
|
tree only when user clicks Finish and abandons results if they
|
||||||
|
click Cancel.
|
||||||
|
|
||||||
2011-03-19 vadim <vadim@netcitadel.com>
|
2011-03-19 vadim <vadim@netcitadel.com>
|
||||||
|
|
||||||
* IOSImporter.cpp (createTCPUDPNeqObject): see #2248 implemented
|
* IOSImporter.cpp (createTCPUDPNeqObject): see #2248 implemented
|
||||||
|
|||||||
@@ -425,10 +425,10 @@ void PIXImporter::commitNamedTCPUDPServiceObject()
|
|||||||
if (protocol == "tcp") obj = createTCPService();
|
if (protocol == "tcp") obj = createTCPService();
|
||||||
if (protocol == "udp") obj = createUDPService();
|
if (protocol == "udp") obj = createUDPService();
|
||||||
|
|
||||||
service_maker->promoteToNamedObject(obj,
|
current_named_object = commitObject(
|
||||||
named_object_name.toUtf8().constData());
|
service_maker->promoteToNamedObject(
|
||||||
|
obj, named_object_name.toUtf8().constData()));
|
||||||
|
|
||||||
current_named_object = commitObject(obj);
|
|
||||||
named_objects_registry[named_object_name] = current_named_object;
|
named_objects_registry[named_object_name] = current_named_object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -719,12 +719,36 @@ void ObjectMaker::registerAnonymousObject(const ObjectSignature &sig, FWObject*
|
|||||||
anon_object_registry[anon_sig.toString()] = (obj!=NULL) ? obj->getId() : -1;
|
anon_object_registry[anon_sig.toString()] = (obj!=NULL) ? obj->getId() : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObjectMaker::promoteToNamedObject(FWObject *obj, const std::string &objName)
|
/*
|
||||||
|
* take anonymous object @obj and make named object from it.
|
||||||
|
*
|
||||||
|
* - assignin @objName
|
||||||
|
* - check if this object is in standard objects library and if it is, create
|
||||||
|
* a copy since we cant rename objects there
|
||||||
|
*
|
||||||
|
* Note that this means that returned pointer may point to a new object
|
||||||
|
* rather than @obj
|
||||||
|
*/
|
||||||
|
FWObject* ObjectMaker::promoteToNamedObject(FWObject *obj,
|
||||||
|
const std::string &objName)
|
||||||
{
|
{
|
||||||
ObjectSignature sig;
|
if (obj->getLibrary()->getId() == FWObjectDatabase::STANDARD_LIB_ID)
|
||||||
obj->setName(objName);
|
{
|
||||||
obj->dispatch(&sig, (void*)(NULL));
|
FWObject *new_obj = library->getRoot()->create(obj->getTypeName());
|
||||||
registerNamedObject(sig, obj);
|
new_obj->duplicate(obj);
|
||||||
|
new_obj->setName(objName);
|
||||||
|
ObjectSignature sig;
|
||||||
|
new_obj->dispatch(&sig, (void*)(NULL));
|
||||||
|
registerNamedObject(sig, new_obj);
|
||||||
|
return new_obj;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
obj->setName(objName);
|
||||||
|
ObjectSignature sig;
|
||||||
|
obj->dispatch(&sig, (void*)(NULL));
|
||||||
|
registerNamedObject(sig, obj);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//****************************************************************
|
//****************************************************************
|
||||||
|
|||||||
@@ -209,8 +209,8 @@ public:
|
|||||||
const std::string &objType,
|
const std::string &objType,
|
||||||
const std::string &objName);
|
const std::string &objName);
|
||||||
|
|
||||||
void promoteToNamedObject(libfwbuilder::FWObject *obj,
|
libfwbuilder::FWObject* promoteToNamedObject(libfwbuilder::FWObject *obj,
|
||||||
const std::string &objName);
|
const std::string &objName);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -886,7 +886,7 @@ void FWWindow::importPolicy()
|
|||||||
if (!activeProject()->m_panel->om->isObjectAllowed(Firewall::TYPENAME))
|
if (!activeProject()->m_panel->om->isObjectAllowed(Firewall::TYPENAME))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ImportFirewallConfigurationWizard wiz(this);
|
ImportFirewallConfigurationWizard wiz(this, db());
|
||||||
wiz.exec();
|
wiz.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
#include "FWBSettings.h"
|
#include "FWBSettings.h"
|
||||||
#include "FWWindow.h"
|
|
||||||
#include "ProjectPanel.h"
|
|
||||||
#include "networkZoneManager.h"
|
#include "networkZoneManager.h"
|
||||||
|
|
||||||
#include "IC_NetworkZonesPage.h"
|
#include "IC_NetworkZonesPage.h"
|
||||||
@@ -68,7 +66,8 @@ void IC_NetworkZonesPage::initializePage()
|
|||||||
m_dialog->iface_nz_list->setHorizontalHeaderLabels(labels);
|
m_dialog->iface_nz_list->setHorizontalHeaderLabels(labels);
|
||||||
|
|
||||||
NetworkZoneManager netzone_manager;
|
NetworkZoneManager netzone_manager;
|
||||||
netzone_manager.load(mw->activeProject()->db());
|
netzone_manager.load(
|
||||||
|
dynamic_cast<ImportFirewallConfigurationWizard*>(wizard())->db());
|
||||||
|
|
||||||
list<FWObject*> all_interfaces = fw->getByTypeDeep(Interface::TYPENAME);
|
list<FWObject*> all_interfaces = fw->getByTypeDeep(Interface::TYPENAME);
|
||||||
list<FWObject*>::iterator it;
|
list<FWObject*>::iterator it;
|
||||||
|
|||||||
@@ -25,14 +25,12 @@
|
|||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "events.h"
|
#include "events.h"
|
||||||
#include "FWBSettings.h"
|
#include "FWBSettings.h"
|
||||||
#include "FWWindow.h"
|
|
||||||
#include "ProjectPanel.h"
|
|
||||||
|
|
||||||
#include "IC_ProgressPage.h"
|
#include "IC_ProgressPage.h"
|
||||||
#include "ImporterThread.h"
|
#include "ImporterThread.h"
|
||||||
#include "ImportFirewallConfigurationWizard.h"
|
#include "ImportFirewallConfigurationWizard.h"
|
||||||
|
|
||||||
#include "fwbuilder/Policy.h"
|
#include "fwbuilder/Library.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
@@ -151,8 +149,10 @@ void IC_ProgressPage::initializePage()
|
|||||||
getBufferPtr();
|
getBufferPtr();
|
||||||
QString fileName = field("fileName").toString();
|
QString fileName = field("fileName").toString();
|
||||||
|
|
||||||
|
Library *lib = dynamic_cast<ImportFirewallConfigurationWizard*>(
|
||||||
|
wizard())->currentLib();
|
||||||
importer = new ImporterThread(this,
|
importer = new ImporterThread(this,
|
||||||
mw->getCurrentLib(),
|
lib,
|
||||||
*buffer, platform, firewallName, fileName,
|
*buffer, platform, firewallName, fileName,
|
||||||
deduplicate);
|
deduplicate);
|
||||||
|
|
||||||
@@ -199,28 +199,6 @@ void IC_ProgressPage::importerFinished()
|
|||||||
QString fwName = field("firewallName").toString();
|
QString fwName = field("firewallName").toString();
|
||||||
fw->setName(fwName.toUtf8().constData());
|
fw->setName(fwName.toUtf8().constData());
|
||||||
|
|
||||||
ProjectPanel *pp = mw->activeProject();
|
|
||||||
QString filename = pp->getFileName();
|
|
||||||
|
|
||||||
QCoreApplication::postEvent(
|
|
||||||
mw, new reloadObjectTreeImmediatelyEvent(filename));
|
|
||||||
|
|
||||||
QCoreApplication::postEvent(
|
|
||||||
pp, new showObjectInTreeEvent(filename, fw->getId()));
|
|
||||||
|
|
||||||
QCoreApplication::postEvent(
|
|
||||||
pp, new expandObjectInTreeEvent(
|
|
||||||
mw->activeProject()->getFileName(), fw->getId()));
|
|
||||||
|
|
||||||
QCoreApplication::postEvent(
|
|
||||||
mw, new openObjectInEditorEvent(filename, fw->getId()));
|
|
||||||
|
|
||||||
// Open first created Policy ruleset object
|
|
||||||
FWObject *first_policy = fw->getFirstByType(Policy::TYPENAME);
|
|
||||||
if (first_policy)
|
|
||||||
QCoreApplication::postEvent(
|
|
||||||
pp, new openRulesetEvent(filename, first_policy->getId()));
|
|
||||||
|
|
||||||
setFinalPage(false); // this triggers call to nextId()
|
setFinalPage(false); // this triggers call to nextId()
|
||||||
|
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
#include "events.h"
|
||||||
|
|
||||||
#include "ImportFirewallConfigurationWizard.h"
|
#include "ImportFirewallConfigurationWizard.h"
|
||||||
|
|
||||||
@@ -30,10 +31,15 @@
|
|||||||
#include "IC_PlatformWarningPage.h"
|
#include "IC_PlatformWarningPage.h"
|
||||||
#include "IC_ProgressPage.h"
|
#include "IC_ProgressPage.h"
|
||||||
#include "IC_NetworkZonesPage.h"
|
#include "IC_NetworkZonesPage.h"
|
||||||
|
|
||||||
#include "FWWindow.h"
|
#include "FWWindow.h"
|
||||||
|
#include "ProjectPanel.h"
|
||||||
|
#include "ObjConflictResolutionDialog.h"
|
||||||
|
|
||||||
#include "fwbuilder/FWObject.h"
|
#include "fwbuilder/FWObject.h"
|
||||||
|
#include "fwbuilder/Library.h"
|
||||||
#include "fwbuilder/Firewall.h"
|
#include "fwbuilder/Firewall.h"
|
||||||
|
#include "fwbuilder/Policy.h"
|
||||||
|
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
@@ -42,10 +48,13 @@ using namespace std;
|
|||||||
using namespace libfwbuilder;
|
using namespace libfwbuilder;
|
||||||
|
|
||||||
|
|
||||||
ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(QWidget *parent) :
|
ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(
|
||||||
QWizard(parent)
|
QWidget *parent, FWObjectDatabase *_db) : QWizard(parent)
|
||||||
{
|
{
|
||||||
fw = NULL;
|
fw = NULL;
|
||||||
|
db_orig = _db;
|
||||||
|
db_copy = new FWObjectDatabase(*_db);
|
||||||
|
current_lib = Library::cast(db_copy->findInIndex(mw->getCurrentLib()->getId()));
|
||||||
|
|
||||||
QPixmap pm;
|
QPixmap pm;
|
||||||
pm.load(":/Images/fwbuilder3-72x72.png");
|
pm.load(":/Images/fwbuilder3-72x72.png");
|
||||||
@@ -82,6 +91,11 @@ ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(QWidget *pa
|
|||||||
resize(desired_size);
|
resize(desired_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImportFirewallConfigurationWizard::~ImportFirewallConfigurationWizard()
|
||||||
|
{
|
||||||
|
delete db_copy;
|
||||||
|
}
|
||||||
|
|
||||||
void ImportFirewallConfigurationWizard::accept()
|
void ImportFirewallConfigurationWizard::accept()
|
||||||
{
|
{
|
||||||
qDebug() << "ImportFirewallConfigurationWizard::accept()";
|
qDebug() << "ImportFirewallConfigurationWizard::accept()";
|
||||||
@@ -90,5 +104,33 @@ void ImportFirewallConfigurationWizard::accept()
|
|||||||
dynamic_cast<IC_NetworkZonesPage*>(
|
dynamic_cast<IC_NetworkZonesPage*>(
|
||||||
page(Page_NetworkZones))->setNetworkZones();
|
page(Page_NetworkZones))->setNetworkZones();
|
||||||
|
|
||||||
|
// merge dbcopy into db
|
||||||
|
|
||||||
|
CompareObjectsDialog cod(this);
|
||||||
|
db_orig->merge(db_copy, &cod);
|
||||||
|
|
||||||
|
ProjectPanel *pp = mw->activeProject();
|
||||||
|
QString filename = pp->getFileName();
|
||||||
|
|
||||||
|
QCoreApplication::postEvent(
|
||||||
|
mw, new reloadObjectTreeImmediatelyEvent(filename));
|
||||||
|
|
||||||
|
QCoreApplication::postEvent(
|
||||||
|
pp, new showObjectInTreeEvent(filename, fw->getId()));
|
||||||
|
|
||||||
|
QCoreApplication::postEvent(
|
||||||
|
pp, new expandObjectInTreeEvent(
|
||||||
|
mw->activeProject()->getFileName(), fw->getId()));
|
||||||
|
|
||||||
|
QCoreApplication::postEvent(
|
||||||
|
mw, new openObjectInEditorEvent(filename, fw->getId()));
|
||||||
|
|
||||||
|
// Open first created Policy ruleset object
|
||||||
|
FWObject *first_policy = fw->getFirstByType(Policy::TYPENAME);
|
||||||
|
if (first_policy)
|
||||||
|
QCoreApplication::postEvent(
|
||||||
|
pp, new openRulesetEvent(filename, first_policy->getId()));
|
||||||
|
|
||||||
|
|
||||||
QWizard::accept();
|
QWizard::accept();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,9 @@
|
|||||||
|
|
||||||
namespace libfwbuilder
|
namespace libfwbuilder
|
||||||
{
|
{
|
||||||
|
class FWObjectDatabase;
|
||||||
class Firewall;
|
class Firewall;
|
||||||
|
class Library;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -39,13 +41,17 @@ class ImportFirewallConfigurationWizard : public QWizard
|
|||||||
QString platform;
|
QString platform;
|
||||||
QStringList buffer;
|
QStringList buffer;
|
||||||
libfwbuilder::Firewall *fw;
|
libfwbuilder::Firewall *fw;
|
||||||
|
libfwbuilder::FWObjectDatabase *db_orig;
|
||||||
|
libfwbuilder::FWObjectDatabase *db_copy;
|
||||||
|
libfwbuilder::Library *current_lib;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { Page_FileName, Page_Platform, Page_FirewallName,
|
enum { Page_FileName, Page_Platform, Page_FirewallName,
|
||||||
Page_Progess, Page_NetworkZones };
|
Page_Progess, Page_NetworkZones };
|
||||||
|
|
||||||
ImportFirewallConfigurationWizard(QWidget *parent);
|
ImportFirewallConfigurationWizard(QWidget *parent,
|
||||||
virtual ~ImportFirewallConfigurationWizard() {}
|
libfwbuilder::FWObjectDatabase *db);
|
||||||
|
virtual ~ImportFirewallConfigurationWizard();
|
||||||
|
|
||||||
QString getPlatform() { return platform; }
|
QString getPlatform() { return platform; }
|
||||||
void setPlatform(const QString &s) { platform = s; }
|
void setPlatform(const QString &s) { platform = s; }
|
||||||
@@ -54,6 +60,9 @@ public:
|
|||||||
|
|
||||||
libfwbuilder::Firewall* getFirewall() { return fw; }
|
libfwbuilder::Firewall* getFirewall() { return fw; }
|
||||||
void setFirewall(libfwbuilder::Firewall* _fw) { fw = _fw; }
|
void setFirewall(libfwbuilder::Firewall* _fw) { fw = _fw; }
|
||||||
|
|
||||||
|
libfwbuilder::FWObjectDatabase* db() { return db_copy; }
|
||||||
|
libfwbuilder::Library* currentLib() { return current_lib; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void accept();
|
virtual void accept();
|
||||||
|
|||||||
Reference in New Issue
Block a user