mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-03-20 10:17:16 +01: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:
parent
eca0a93cc7
commit
da2deee052
@ -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>
|
||||
|
||||
* IOSImporter.cpp (createTCPUDPNeqObject): see #2248 implemented
|
||||
|
||||
@ -425,10 +425,10 @@ void PIXImporter::commitNamedTCPUDPServiceObject()
|
||||
if (protocol == "tcp") obj = createTCPService();
|
||||
if (protocol == "udp") obj = createUDPService();
|
||||
|
||||
service_maker->promoteToNamedObject(obj,
|
||||
named_object_name.toUtf8().constData());
|
||||
current_named_object = commitObject(
|
||||
service_maker->promoteToNamedObject(
|
||||
obj, named_object_name.toUtf8().constData()));
|
||||
|
||||
current_named_object = commitObject(obj);
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
obj->setName(objName);
|
||||
obj->dispatch(&sig, (void*)(NULL));
|
||||
registerNamedObject(sig, obj);
|
||||
if (obj->getLibrary()->getId() == FWObjectDatabase::STANDARD_LIB_ID)
|
||||
{
|
||||
FWObject *new_obj = library->getRoot()->create(obj->getTypeName());
|
||||
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 &objName);
|
||||
|
||||
void promoteToNamedObject(libfwbuilder::FWObject *obj,
|
||||
const std::string &objName);
|
||||
libfwbuilder::FWObject* promoteToNamedObject(libfwbuilder::FWObject *obj,
|
||||
const std::string &objName);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -886,7 +886,7 @@ void FWWindow::importPolicy()
|
||||
if (!activeProject()->m_panel->om->isObjectAllowed(Firewall::TYPENAME))
|
||||
return;
|
||||
|
||||
ImportFirewallConfigurationWizard wiz(this);
|
||||
ImportFirewallConfigurationWizard wiz(this, db());
|
||||
wiz.exec();
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,8 +24,6 @@
|
||||
#include "global.h"
|
||||
#include "events.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "networkZoneManager.h"
|
||||
|
||||
#include "IC_NetworkZonesPage.h"
|
||||
@ -68,7 +66,8 @@ void IC_NetworkZonesPage::initializePage()
|
||||
m_dialog->iface_nz_list->setHorizontalHeaderLabels(labels);
|
||||
|
||||
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*>::iterator it;
|
||||
|
||||
@ -25,14 +25,12 @@
|
||||
#include "global.h"
|
||||
#include "events.h"
|
||||
#include "FWBSettings.h"
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
|
||||
#include "IC_ProgressPage.h"
|
||||
#include "ImporterThread.h"
|
||||
#include "ImportFirewallConfigurationWizard.h"
|
||||
|
||||
#include "fwbuilder/Policy.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QFileDialog>
|
||||
@ -151,8 +149,10 @@ void IC_ProgressPage::initializePage()
|
||||
getBufferPtr();
|
||||
QString fileName = field("fileName").toString();
|
||||
|
||||
Library *lib = dynamic_cast<ImportFirewallConfigurationWizard*>(
|
||||
wizard())->currentLib();
|
||||
importer = new ImporterThread(this,
|
||||
mw->getCurrentLib(),
|
||||
lib,
|
||||
*buffer, platform, firewallName, fileName,
|
||||
deduplicate);
|
||||
|
||||
@ -199,28 +199,6 @@ void IC_ProgressPage::importerFinished()
|
||||
QString fwName = field("firewallName").toString();
|
||||
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()
|
||||
|
||||
} else
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "global.h"
|
||||
#include "events.h"
|
||||
|
||||
#include "ImportFirewallConfigurationWizard.h"
|
||||
|
||||
@ -30,10 +31,15 @@
|
||||
#include "IC_PlatformWarningPage.h"
|
||||
#include "IC_ProgressPage.h"
|
||||
#include "IC_NetworkZonesPage.h"
|
||||
|
||||
#include "FWWindow.h"
|
||||
#include "ProjectPanel.h"
|
||||
#include "ObjConflictResolutionDialog.h"
|
||||
|
||||
#include "fwbuilder/FWObject.h"
|
||||
#include "fwbuilder/Library.h"
|
||||
#include "fwbuilder/Firewall.h"
|
||||
#include "fwbuilder/Policy.h"
|
||||
|
||||
#include <QDesktopWidget>
|
||||
#include <QtDebug>
|
||||
@ -42,10 +48,13 @@ using namespace std;
|
||||
using namespace libfwbuilder;
|
||||
|
||||
|
||||
ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(QWidget *parent) :
|
||||
QWizard(parent)
|
||||
ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(
|
||||
QWidget *parent, FWObjectDatabase *_db) : QWizard(parent)
|
||||
{
|
||||
fw = NULL;
|
||||
db_orig = _db;
|
||||
db_copy = new FWObjectDatabase(*_db);
|
||||
current_lib = Library::cast(db_copy->findInIndex(mw->getCurrentLib()->getId()));
|
||||
|
||||
QPixmap pm;
|
||||
pm.load(":/Images/fwbuilder3-72x72.png");
|
||||
@ -82,6 +91,11 @@ ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(QWidget *pa
|
||||
resize(desired_size);
|
||||
}
|
||||
|
||||
ImportFirewallConfigurationWizard::~ImportFirewallConfigurationWizard()
|
||||
{
|
||||
delete db_copy;
|
||||
}
|
||||
|
||||
void ImportFirewallConfigurationWizard::accept()
|
||||
{
|
||||
qDebug() << "ImportFirewallConfigurationWizard::accept()";
|
||||
@ -90,5 +104,33 @@ void ImportFirewallConfigurationWizard::accept()
|
||||
dynamic_cast<IC_NetworkZonesPage*>(
|
||||
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();
|
||||
}
|
||||
|
||||
@ -29,7 +29,9 @@
|
||||
|
||||
namespace libfwbuilder
|
||||
{
|
||||
class FWObjectDatabase;
|
||||
class Firewall;
|
||||
class Library;
|
||||
};
|
||||
|
||||
|
||||
@ -39,13 +41,17 @@ class ImportFirewallConfigurationWizard : public QWizard
|
||||
QString platform;
|
||||
QStringList buffer;
|
||||
libfwbuilder::Firewall *fw;
|
||||
libfwbuilder::FWObjectDatabase *db_orig;
|
||||
libfwbuilder::FWObjectDatabase *db_copy;
|
||||
libfwbuilder::Library *current_lib;
|
||||
|
||||
public:
|
||||
enum { Page_FileName, Page_Platform, Page_FirewallName,
|
||||
Page_Progess, Page_NetworkZones };
|
||||
|
||||
ImportFirewallConfigurationWizard(QWidget *parent);
|
||||
virtual ~ImportFirewallConfigurationWizard() {}
|
||||
ImportFirewallConfigurationWizard(QWidget *parent,
|
||||
libfwbuilder::FWObjectDatabase *db);
|
||||
virtual ~ImportFirewallConfigurationWizard();
|
||||
|
||||
QString getPlatform() { return platform; }
|
||||
void setPlatform(const QString &s) { platform = s; }
|
||||
@ -54,6 +60,9 @@ public:
|
||||
|
||||
libfwbuilder::Firewall* getFirewall() { return fw; }
|
||||
void setFirewall(libfwbuilder::Firewall* _fw) { fw = _fw; }
|
||||
|
||||
libfwbuilder::FWObjectDatabase* db() { return db_copy; }
|
||||
libfwbuilder::Library* currentLib() { return current_lib; }
|
||||
|
||||
public slots:
|
||||
virtual void accept();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user