bugfix 2647,2636

This commit is contained in:
2008-06-10 16:37:05 +00:00
parent c0fd400bdd
commit ad3e9d0cc0
+55 -43
View File
@@ -1708,39 +1708,39 @@ void ObjectManipulator::cutObj()
void ObjectManipulator::pasteObj() void ObjectManipulator::pasteObj()
{ {
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators(); FWObject *nobj=NULL;
for (int i = 0 ; i < oms.size(); i++)
{
ObjectManipulator* pom = oms[i] ;
if (pom->getCurrentObjectTree()->getNumSelected()==0) return; if (getCurrentObjectTree()->getNumSelected()==0) return;
FWObject *obj=pom->getCurrentObjectTree()->getSelectedObjects().front(); FWObject *obj=getCurrentObjectTree()->getSelectedObjects().front();
if (obj==NULL) return; if (obj==NULL) return;
vector<int>::iterator i; vector<int>::iterator i;
int idx = 0; int idx = 0;
for (i= FWObjectClipboard::obj_clipboard->begin(); for (i= FWObjectClipboard::obj_clipboard->begin();
i!=FWObjectClipboard::obj_clipboard->end(); ++i) i!=FWObjectClipboard::obj_clipboard->end(); ++i)
{ {
FWObject *co = FWObject *co = FWObjectClipboard::obj_clipboard->getObjectByIdx(idx);
FWObjectClipboard::obj_clipboard->getObjectByIdx(idx); if (Interface::isA(co) && Firewall::isA(obj))
if (Interface::isA(co) && Firewall::isA(obj)) {
{ pasteTo (obj, co, false, false, true);
pasteTo (obj, co, false, false, true); continue ;
continue ;
}
pom->copyObjWithDeep(co);
} }
if (nobj==NULL)
{
nobj=co->getRoot()->create(co->getTypeName());
nobj->duplicate(co,true);
nobj->setId(FWObjectDatabase::generateUniqueId());
nobj->setRoot(co->getRoot());
}
copyObjWithDeep(nobj);
} }
} }
FWObject* ObjectManipulator::pasteTo(FWObject *target, FWObject *obj, FWObject* ObjectManipulator::pasteTo(FWObject *target, FWObject *obj,
bool openobj, bool validateOnly, bool openobj, bool validateOnly,
bool renew_id) bool renew_id)
{ {
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators(); FWObject *ret = NULL;
for (int i = 0 ; i < oms.size(); i++)
{
ObjectManipulator* pom = oms[i] ;
FWObject *ta=target; FWObject *ta=target;
if (IPv4::isA(ta) || IPv6::isA(ta)) ta=ta->getParent(); if (IPv4::isA(ta) || IPv6::isA(ta)) ta=ta->getParent();
@@ -1752,9 +1752,9 @@ FWObject* ObjectManipulator::pasteTo(FWObject *target, FWObject *obj,
Host *hst = Host::cast(ta); // works for firewall, too Host *hst = Host::cast(ta); // works for firewall, too
Interface *intf = Interface::cast(ta); Interface *intf = Interface::cast(ta);
if (pom->m_project->isSystem(ta)) if (m_project->isSystem(ta))
{ {
if (!pom->m_project->validateForInsertion(ta,obj)) if (!m_project->validateForInsertion(ta,obj))
{ {
if (validateOnly) return NULL; if (validateOnly) return NULL;
@@ -1771,27 +1771,29 @@ FWObject* ObjectManipulator::pasteTo(FWObject *target, FWObject *obj,
} }
} }
if ( pom->m_project->isSystem(ta) || if ( m_project->isSystem(ta) ||
(hst!=NULL && hst->validateChild(obj)) || (hst!=NULL && hst->validateChild(obj)) ||
(intf!=NULL && intf->validateChild(obj)) (intf!=NULL && intf->validateChild(obj))
) )
{ {
if (validateOnly) return obj; if (validateOnly) return obj;
/* add a copy of the object to system group */ /* add a copy of the object to system group */
FWObject *nobj= m_project->db()->create(obj->getTypeName());
FWObject *nobj=
pom->m_project->db()->create(obj->getTypeName());
assert (nobj!=NULL); assert (nobj!=NULL);
nobj->ref(); nobj->ref();
nobj->duplicate(obj,renew_id); //if renew_id == true creates new object ID nobj->duplicate(obj,renew_id); //if renew_id == true creates new object ID
pom->makeNameUnique(ta,nobj); makeNameUnique(ta,nobj);
ta->add( nobj ); ta->add( nobj );
pom->insertSubtree( pom->allItems[ta], nobj); QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
if (openobj) pom->openObject(nobj);
for (int i = 0 ; i < oms.size(); i++)
{
ObjectManipulator* pom = oms[i] ;
pom->insertSubtree( pom->allItems[ta], nobj);
if (openobj) pom->openObject(nobj);
}
return nobj; return nobj;
} }
@@ -1815,7 +1817,7 @@ FWObject* ObjectManipulator::pasteTo(FWObject *target, FWObject *obj,
} }
grp->addRef(obj); grp->addRef(obj);
if (openobj) pom->openObject(grp); if (openobj) openObject(grp);
} }
} }
catch(FWException &ex) catch(FWException &ex)
@@ -1831,8 +1833,8 @@ FWObject* ObjectManipulator::pasteTo(FWObject *target, FWObject *obj,
if (validateOnly) return NULL; if (validateOnly) return NULL;
return obj; return obj;
}
return NULL; //return ret;
} }
@@ -2696,7 +2698,11 @@ FWObject* ObjectManipulator::copyObj2Tree(
FWObject *no = pasteTo (parent,copyFrom , false, false, true); FWObject *no = pasteTo (parent,copyFrom , false, false, true);
return no; return no;
} }
return copyObjWithDeep(copyFrom); FWObject *nobj=copyFrom->getRoot()->create(copyFrom->getTypeName());
nobj->duplicate(copyFrom,true);
nobj->setId(FWObjectDatabase::generateUniqueId());
nobj->setRoot(copyFrom->getRoot());
return copyObjWithDeep(nobj);
} }
FWObject * ObjectManipulator::copyObjWithDeep(FWObject *copyFrom) FWObject * ObjectManipulator::copyObjWithDeep(FWObject *copyFrom)
@@ -2720,7 +2726,7 @@ FWObject * ObjectManipulator::copyObjWithDeep(FWObject *copyFrom)
FWReference * ref = FWReference::cast(nobj); FWReference * ref = FWReference::cast(nobj);
if (ref!=NULL) if (ref!=NULL)
{ {
copyObjWithDeep(ref->getPointer()); FWObject * o = copyObjWithDeep(ref->getPointer());
return ref ; return ref ;
} }
@@ -2778,13 +2784,19 @@ FWObject * ObjectManipulator::copyObjWithDeep(FWObject *copyFrom)
if (lib->getRoot()->getById(nobj->getId(),true)==NULL) if (lib->getRoot()->getById(nobj->getId(),true)==NULL)
{ {
FWObject *par = m_project->getFWTree()->getStandardSlotForObject(lib, nobj->getTypeName().c_str()); FWObject *par = m_project->getFWTree()->getStandardSlotForObject(lib, nobj->getTypeName().c_str());
QVector <ObjectManipulator*> oms = getAllMdiObjectManipulators();
// for (int i = 0 ; i < oms.size(); i++)
// {
// ObjectManipulator* pom = oms[i] ;
FWObject *no = pasteTo (par, nobj, false, false, false); FWObject *no = pasteTo (par, nobj, false, false, false);
if (no && Firewall::isA(no)) // }
/* if (no && Firewall::isA(no))
{ {
m_project->addFirewallToList(no); m_project->addFirewallToList(no);
m_project->showFirewall(no); m_project->showFirewall(no);
} }
*/
} }
return nobj; return nobj;