mirror of
https://github.com/fwbuilder/fwbuilder
synced 2026-09-15 09:29:36 +02:00
update 2426. rev 79 repair
This commit is contained in:
@@ -2459,7 +2459,9 @@ FWObject* ObjectManipulator::copyObj2Tree(const QString &objType, const QString
|
||||
return 0;
|
||||
if (!parent)
|
||||
parent=m_project->getStandardSlotForObject(lib, objType);
|
||||
|
||||
ids.clear();
|
||||
return copyObjWithDeep(copyFrom);
|
||||
/*
|
||||
|
||||
FWObject *nobj = pasteTo (parent, copyFrom, true, false, false);
|
||||
FWObject * nobj_ = nobj ;
|
||||
@@ -2479,7 +2481,10 @@ FWObject* ObjectManipulator::copyObj2Tree(const QString &objType, const QString
|
||||
{
|
||||
continue ;
|
||||
}
|
||||
FWObject *par = m_project->getStandardSlotForObject(lib, o->getTypeName().c_str());
|
||||
if (m_project->db()->getRoot()->getById(o->getId())==NULL)
|
||||
{
|
||||
FWObject * lib2 = idxToLibs[1];
|
||||
FWObject *par = m_project->getStandardSlotForObject(lib2, o->getTypeName().c_str());
|
||||
FWObject * newobj = nobj_->getById(o->getId());
|
||||
FWObject *no = pasteTo (par, o, true, false, false);
|
||||
//ref->setPointerId(no->getId());
|
||||
@@ -2491,6 +2496,7 @@ FWObject* ObjectManipulator::copyObj2Tree(const QString &objType, const QString
|
||||
// newobj->setId(no->getId());
|
||||
//}
|
||||
objByIds[no->getId()] = no;
|
||||
}
|
||||
|
||||
}
|
||||
if (nobj && Firewall::isA(nobj))
|
||||
@@ -2498,10 +2504,97 @@ FWObject* ObjectManipulator::copyObj2Tree(const QString &objType, const QString
|
||||
m_project->addFirewallToList(nobj);
|
||||
m_project->showFirewall(nobj);
|
||||
}
|
||||
|
||||
return nobj;
|
||||
*/
|
||||
// return nobj;
|
||||
}
|
||||
|
||||
libfwbuilder::FWObject * ObjectManipulator::copyObjWithDeep(libfwbuilder::FWObject *copyFrom)
|
||||
{
|
||||
|
||||
if (copyFrom==NULL)
|
||||
return NULL;
|
||||
FWObject *nobj= copyFrom;//m_project->db()->create(copyFrom->getTypeName());
|
||||
if (ids.contains(nobj->getId().c_str()))
|
||||
{
|
||||
|
||||
return nobj;
|
||||
}
|
||||
else
|
||||
{
|
||||
ids.insert(nobj->getId().c_str());
|
||||
}
|
||||
//nobj->duplicate(copyFrom,false);
|
||||
FWReference * ref = FWReference::cast(nobj);
|
||||
if (ref!=NULL)
|
||||
{
|
||||
FWObject * obj = copyObjWithDeep(ref->getPointer());
|
||||
return ref ;
|
||||
}
|
||||
|
||||
Group * group = Group::cast(nobj);
|
||||
if (group!=NULL)
|
||||
{
|
||||
for (list<FWObject*>::iterator i=nobj->begin() ; i!=nobj->end(); ++i)
|
||||
{
|
||||
copyObjWithDeep(*i);
|
||||
}
|
||||
return group;
|
||||
//return group;
|
||||
}
|
||||
Firewall * fw = Firewall::cast(nobj);
|
||||
if (fw!=NULL)
|
||||
{
|
||||
for (libfwbuilder::FWObject::iterator i=fw->begin(); i!=fw->end(); i++)
|
||||
{
|
||||
|
||||
RuleSet *rule = RuleSet::cast(*i);
|
||||
if (rule==NULL)
|
||||
continue;
|
||||
copyObjWithDeep(rule);
|
||||
//FWOptions *ropt = rule->getOptionsObject();
|
||||
//if (ropt)
|
||||
// extRefs.push_back(ropt);
|
||||
}
|
||||
}
|
||||
RuleSet * ruleset = RuleSet::cast(nobj);
|
||||
if (ruleset!=NULL)
|
||||
{
|
||||
|
||||
for (list<FWObject*>::iterator i=ruleset->begin() ; i!=ruleset->end(); ++i)
|
||||
{
|
||||
copyObjWithDeep(*i);
|
||||
}
|
||||
}
|
||||
|
||||
Rule * rule = Rule::cast(nobj);
|
||||
if (rule!=NULL)
|
||||
{
|
||||
for (int col =0; col < 5; col++)
|
||||
{
|
||||
RuleElement *re = m_project->getRE(rule, col);
|
||||
if (!re) continue;
|
||||
copyObjWithDeep(re);
|
||||
}
|
||||
return rule;
|
||||
}
|
||||
FWObject * lib = getCurrentLib();
|
||||
|
||||
if (lib->getRoot()->getById(nobj->getId(),true)==NULL)
|
||||
{
|
||||
FWObject *par = m_project->getStandardSlotForObject(lib, nobj->getTypeName().c_str());
|
||||
FWObject *no = pasteTo (par, nobj, true, false, false);
|
||||
if (no && Firewall::isA(no))
|
||||
{
|
||||
m_project->addFirewallToList(no);
|
||||
m_project->showFirewall(no);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
FWObject* ObjectManipulator::actuallyCreateObject(FWObject *parent,
|
||||
const QString &objType,
|
||||
const QString &objName,
|
||||
|
||||
@@ -83,7 +83,7 @@ class ObjectManipulator : public QWidget/*ObjectManipulator_q*/ {
|
||||
|
||||
std::vector<libfwbuilder::FWObject*> idxToLibs;
|
||||
std::vector<QTreeWidget*> idxToTrees;
|
||||
|
||||
QSet <QString> ids ;
|
||||
std::stack<HistoryItem> history;
|
||||
int cacheHits;
|
||||
|
||||
@@ -165,7 +165,10 @@ public slots:
|
||||
libfwbuilder::FWObject *copyFrom=NULL);
|
||||
libfwbuilder::FWObject * copyObj2Tree(const QString &objType, const QString &objName,
|
||||
libfwbuilder::FWObject *copyFrom, libfwbuilder::FWObject *parent=NULL, bool ask4Lib=true);
|
||||
|
||||
libfwbuilder::FWObject * copyObjWithDeep(libfwbuilder::FWObject *copyFrom);
|
||||
|
||||
|
||||
void newLibrary();
|
||||
void newObject();
|
||||
void newFirewall();
|
||||
|
||||
+64
-19
@@ -203,6 +203,8 @@ ProjectPanel::~ProjectPanel()
|
||||
|
||||
void ProjectPanel::info(libfwbuilder::FWObject *obj, bool forced)
|
||||
{
|
||||
if (obj==NULL)
|
||||
return ;
|
||||
if (st->getInfoStyle()!=0 && (shownInInfo!=obj || forced))
|
||||
{
|
||||
m_panel->oi->clear();
|
||||
@@ -276,7 +278,7 @@ void ProjectPanel::checkPolicy4ExtRefs(Firewall *fw, list<FWObject*> &extRefs)
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectPanel::check4Depends(FWObject *obj, list<FWObject*>& objList, FWObject *lib)
|
||||
void ProjectPanel::check4Depends(FWObject *obj, list<FWObject*>& objList,list<FWReference*> & refLinfs, FWObject *lib)
|
||||
//objList - это куда объекты для копирвания складывать
|
||||
{
|
||||
copySet.clear();
|
||||
@@ -285,14 +287,14 @@ void ProjectPanel::check4Depends(FWObject *obj, list<FWObject*>& objList, FWObje
|
||||
return;
|
||||
list<FWObject*> externalRefs;
|
||||
checkPolicy4ExtRefs(fw, externalRefs);//ищем ссылки правил фаервола на объекты, записываем в extRefs
|
||||
findIntersectRefs(lib, fw, objList, externalRefs);
|
||||
findIntersectRefs(lib, fw, objList, externalRefs,refLinfs);
|
||||
|
||||
}
|
||||
|
||||
void ProjectPanel::findIntersectRefs(FWObject *lib,
|
||||
FWObject *root,
|
||||
list<FWObject*> &extRefs,
|
||||
const list<FWObject*> &objList)
|
||||
const list<FWObject*> &objList, list<FWReference*> & refLinfs)
|
||||
{
|
||||
|
||||
FWReference *ref=FWReference::cast(root);
|
||||
@@ -303,19 +305,33 @@ void ProjectPanel::findIntersectRefs(FWObject *lib,
|
||||
plib->getId()!=DELETED_LIB &&
|
||||
plib!=lib )
|
||||
{
|
||||
|
||||
|
||||
for (list<FWObject*>::const_iterator i=objList.begin();i!=objList.end();i++)
|
||||
FWObject* ptr=ref->getPointer();
|
||||
|
||||
cout << string(0,' ') << "Pointer: " << ptr << endl;
|
||||
cout << string(0,' ') << "Name: " << ref->getName() << endl;
|
||||
if (ptr) {
|
||||
cout<< string(0,' ') << "Ptr.name: " << ptr->getName() <<endl;
|
||||
cout<< string(0,' ') << "Ptr.id: " << ptr->getId() <<endl;
|
||||
}
|
||||
//qDebug (ref->getTypeName().c_str());
|
||||
//qDebug (ref->getPointer()->getTypeName().c_str());
|
||||
//qDebug (QString().setNum(objList.size()).toAscii().data());
|
||||
int counter = 0 ;
|
||||
for (list<FWObject*>::const_iterator i=ptr->begin();i!=ptr->end();i++)
|
||||
{
|
||||
qDebug("push_back (%s, %s)", (*i)->getId().c_str(), ref->getId().c_str());
|
||||
FWObject * obj = *i;
|
||||
counter++;
|
||||
//qDebug("push_back (%s, %s)", (*i)->getId().c_str(), ref->getId().c_str());
|
||||
//FWObject * obj = *i;
|
||||
FWObject * obj = *i;//ptr;
|
||||
|
||||
QString name = obj->getName().c_str();
|
||||
if ((obj)->getId() != root->getId())
|
||||
{
|
||||
//FWObject *nobj= db()->create(obj->getTypeName());
|
||||
//nobj->ref();
|
||||
//nobj->duplicate(obj,true); //if renew_id == true creates new object ID
|
||||
//nobj->duplicate(obj,false); //if renew_id == true creates new object ID
|
||||
//obj->setReadOnly(false);
|
||||
//ref->setPointerId(nobj->getId());
|
||||
//if (!obj->isReadOnly())
|
||||
// obj->setId(nobj->getId());
|
||||
|
||||
@@ -323,16 +339,42 @@ void ProjectPanel::findIntersectRefs(FWObject *lib,
|
||||
if (!copySet.contains (name)){
|
||||
copySet.insert(name);
|
||||
extRefs.push_back(obj);
|
||||
refLinfs.push_back (ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (counter==0)
|
||||
{
|
||||
FWObject * obj = ptr;
|
||||
|
||||
QString name = obj->getName().c_str();
|
||||
if ((obj)->getId() != root->getId())
|
||||
{
|
||||
//FWObject *nobj= db()->create(obj->getTypeName());
|
||||
//nobj->ref();
|
||||
//nobj->duplicate(obj,false); //if renew_id == true creates new object ID
|
||||
//obj->setReadOnly(false);
|
||||
//ref->setPointerId(nobj->getId());
|
||||
//if (!obj->isReadOnly())
|
||||
// obj->setId(nobj->getId());
|
||||
|
||||
//qDebug("HERE");// !!!!!
|
||||
if (!copySet.contains (name)){
|
||||
copySet.insert(name);
|
||||
extRefs.push_back(obj);
|
||||
refLinfs.push_back (ref);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
qDebug (QString().setNum(counter).toAscii().data());
|
||||
}
|
||||
return;
|
||||
} else
|
||||
{
|
||||
//;
|
||||
for (FWObject::iterator i=root->begin(); i!=root->end(); i++)
|
||||
findIntersectRefs(lib, *i, extRefs, objList);
|
||||
findIntersectRefs(lib, *i, extRefs, objList,refLinfs);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3187,18 +3229,22 @@ void ProjectPanel::showEvent( QShowEvent *ev)
|
||||
if (w1 || w2)
|
||||
m_panel->objInfoSplitter->setSizes( sl );
|
||||
}
|
||||
/* if (rcs!=NULL)
|
||||
/* if (rcs!=NULL&&firstResize==false)
|
||||
{
|
||||
// QMdiArea * par = (QMdiArea *)mdiWindow->getParent();
|
||||
QString FileName = rcs->getFileName();
|
||||
int x = st->getInt("Window/"+FileName+"/x");
|
||||
int y = st->getInt("Window/"+FileName+"/y");
|
||||
int width = st->getInt("Window/"+FileName+"/width");
|
||||
int height = st->getInt("Window/"+FileName+"/height");
|
||||
|
||||
mdiWindow->resize(width,height);
|
||||
firstResize=true ;
|
||||
mdiWindow->showMinimized();
|
||||
mdiWindow->move(x,y);
|
||||
mdiWindow->showMaximized();
|
||||
// par->addSubWindow(mdiWindow);
|
||||
//this->;
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
|
||||
|
||||
QWidget::showEvent(ev);
|
||||
}
|
||||
@@ -3222,16 +3268,15 @@ void ProjectPanel::hideEvent( QHideEvent *ev)
|
||||
|
||||
|
||||
void ProjectPanel::closeEvent( QCloseEvent * ev)
|
||||
{
|
||||
/* if (rcs!=NULL)
|
||||
{
|
||||
/* if (rcs!=NULL)
|
||||
{
|
||||
QString FileName = rcs->getFileName();
|
||||
st->setInt("Window/"+FileName+"/x",mdiWindow->x());
|
||||
st->setInt("Window/"+FileName+"/y",mdiWindow->y());
|
||||
st->setInt("Window/"+FileName+"/width",mdiWindow->width ());
|
||||
st->setInt("Window/"+FileName+"/height",mdiWindow->height ());
|
||||
}
|
||||
*/
|
||||
}*/
|
||||
if (saveIfModified() && checkin(true))
|
||||
{
|
||||
if (rcs)
|
||||
|
||||
@@ -65,6 +65,7 @@ class ProjectPanel: public QWidget {
|
||||
bool editingStandardLib;
|
||||
bool editingTemplateLib;
|
||||
bool ruleSetRedrawPending;
|
||||
bool firstResize;
|
||||
QString startupFileName;
|
||||
|
||||
libfwbuilder::FWObjectDatabase *objdb;
|
||||
@@ -90,14 +91,13 @@ class ProjectPanel: public QWidget {
|
||||
|
||||
QString noFirewalls;
|
||||
|
||||
libfwbuilder::RuleElement* getRE(libfwbuilder::Rule* r, int col );
|
||||
void checkRERefs(libfwbuilder::RuleElement *re,
|
||||
std::list<libfwbuilder::FWObject*> &extRefs);
|
||||
void checkPolicy4ExtRefs(libfwbuilder::Firewall *fw,
|
||||
std::list<libfwbuilder::FWObject*> &extRefs);
|
||||
void findIntersectRefs(libfwbuilder::FWObject *lib, libfwbuilder::FWObject *root,
|
||||
std::list<libfwbuilder::FWObject*> &extRefs,
|
||||
const std::list<libfwbuilder::FWObject*> &objList);
|
||||
const std::list<libfwbuilder::FWObject*> &objList,std::list<libfwbuilder::FWReference*> & refLinfs);
|
||||
|
||||
void restorePolicyRefs(libfwbuilder::Policy *pol, libfwbuilder::Policy *pol_old,
|
||||
const std::map<const std::string, libfwbuilder::FWObject *> &objByIds);
|
||||
@@ -122,6 +122,8 @@ public:
|
||||
void clearObjects();
|
||||
libfwbuilder::FWObjectDatabase* db() { return objdb; }
|
||||
bool hasObject(libfwbuilder::FWObject* obj) { return objdb->findInIndex(obj->getId()); };
|
||||
libfwbuilder::RuleElement* getRE(libfwbuilder::Rule* r, int col );
|
||||
|
||||
//wrapers for some ObjectManipulator functions
|
||||
libfwbuilder::FWObject* getOpened();
|
||||
|
||||
@@ -264,7 +266,7 @@ public:
|
||||
QString chooseNewFileName(const QString &fname, bool checkPresence,const QString &title);
|
||||
void setFileName(const QString &fname);
|
||||
void check4Depends(libfwbuilder::FWObject *obj,
|
||||
std::list<libfwbuilder::FWObject*> & objList,
|
||||
std::list<libfwbuilder::FWObject*> & objList, std::list<libfwbuilder::FWReference*> & refLinfs,
|
||||
libfwbuilder::FWObject *lib);
|
||||
void restoreDepends(libfwbuilder::FWObject *obj_old, libfwbuilder::FWObject *nobj,
|
||||
const std::map<const std::string, libfwbuilder::FWObject *> &objByIds);
|
||||
|
||||
Reference in New Issue
Block a user