bugfix 2607

This commit is contained in:
2008-05-30 15:01:36 +00:00
parent d350924ca3
commit 2f9e82c5ba
3 changed files with 543 additions and 0 deletions
+178
View File
@@ -0,0 +1,178 @@
/*
Firewall Builder
Copyright (C) 2008 NetCitadel, LLC
Author: Vadim Kurland vadim@fwbuilder.org
$Id: RuleSetDialog.cpp,v 1.20 2007/04/14 00:18:43 vkurland Exp $
This program is free software which we release under the GNU General Public
License. You may redistribute and/or modify this program under the terms
of that license as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "fwbuilder_ph.h"
#include "config.h"
#include "global.h"
#include "utils.h"
#include "FWBTree.h"
#include "RuleSetDialog.h"
#include "ProjectPanel.h"
#include "fwbuilder/Library.h"
#include "fwbuilder/Host.h"
#include "fwbuilder/Interface.h"
#include "fwbuilder/Management.h"
#include "fwbuilder/FWException.h"
#include <qlineedit.h>
#include <qspinbox.h>
#include <qcheckbox.h>
#include <qtextedit.h>
#include <qcombobox.h>
#include <qmessagebox.h>
#include <qpushbutton.h>
#include "FWBSettings.h"
#include "FWWindow.h"
using namespace std;
using namespace libfwbuilder;
RuleSetDialog::RuleSetDialog(ProjectPanel *project, QWidget *parent) : QWidget(parent), m_project(project)
{
m_dialog = new Ui::RuleSetDialog_q;
m_dialog->setupUi(this);
setFont(st->getUiFont());
obj=NULL;
}
RuleSetDialog::~RuleSetDialog()
{
delete m_dialog;
}
void RuleSetDialog::loadFWObject(FWObject *o)
{
obj=o;
RuleSet *s = dynamic_cast<RuleSet*>(obj);
assert(s!=NULL);
init=true;
// fillLibraries(m_dialog->libs,obj);
// Management *mgmt=s->getManagementObject();
// assert(mgmt!=NULL);
// FWOptions *opt =s->getOptionsObject();
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
// snmpCommunity->setText( mgmt->getSNMPManagement()->getReadCommunity().c_str() );
// m_dialog->MACmatching->setChecked( opt->getBool("use_mac_addr_filter") );
m_dialog->comment->setText( QString::fromUtf8(s->getComment().c_str()) );
//apply->setEnabled( false );
// m_dialog->obj_name->setEnabled(!o->isReadOnly());
// setDisabledPalette(m_dialog->obj_name);
// m_dialog->libs->setEnabled(!o->isReadOnly());
// setDisabledPalette(m_dialog->libs);
// snmpCommunity->setEnabled(!o->isReadOnly());
// setDisabledPalette(snmpCommunity);
// m_dialog->MACmatching->setEnabled(!o->isReadOnly());
// setDisabledPalette(m_dialog->MACmatching);
// m_dialog->comment->setReadOnly(o->isReadOnly());
// setDisabledPalette(m_dialog->comment);
init=false;
}
void RuleSetDialog::changed()
{
//apply->setEnabled( true );
emit changed_sign();
}
void RuleSetDialog::validate(bool *res)
{
*res=true;
if (!isTreeReadWrite(this,obj)) { *res=false; return; }
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
}
void RuleSetDialog::isChanged(bool *res)
{
//*res=(!init && apply->isEnabled());
}
void RuleSetDialog::libChanged()
{
changed();
}
void RuleSetDialog::applyChanges()
{
RuleSet *s = dynamic_cast<RuleSet*>(obj);
assert(s!=NULL);
// Management *mgmt=s->getManagementObject();
// assert(mgmt!=NULL);
// FWOptions *opt =s->getOptionsObject();
string oldname=obj->getName();
obj->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );
obj->setComment( string(m_dialog->comment->toPlainText().toUtf8().constData()) );
mw->updateObjName(obj,QString::fromUtf8(oldname.c_str()));
init=true;
/* move to another lib if we have to */
// if (! m_project->isSystem(obj) &&
// m_dialog->libs->currentText() != QString(obj->getLibrary()->getName().c_str()))
// mw->moveObject(m_dialog->libs->currentText(), obj);
init=false;
//apply->setEnabled( false );
mw->updateLastModifiedTimestampForAllFirewalls(obj);
}
void RuleSetDialog::discardChanges()
{
loadFWObject(obj);
}
/* ObjectEditor class connects its slot to this signal and does all
* the verification for us, then accepts (or not) the event. So we do
* nothing here and defer all the processing to ObjectEditor
*/
void RuleSetDialog::closeEvent(QCloseEvent *e)
{
emit close_sign(e);
}
+71
View File
@@ -0,0 +1,71 @@
/*
Firewall Builder
Copyright (C) 2008 NetCitadel, LLC
Author: Vadim Kurland vadim@fwbuilder.org
$Id: RuleSetDialog.h,v 1.6 2006/05/13 06:53:05 vkurland Exp $
This program is free software which we release under the GNU General Public
License. You may redistribute and/or modify this program under the terms
of that license as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To get a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __RULESETDIALOG_H_
#define __RULESETDIALOG_H_
#include "config.h"
#include <ui_rulesetdialog_q.h>
#include <QWidget>
#include "fwbuilder/FWObject.h"
class ProjectPanel;
class RuleSetDialog : public QWidget
{
Q_OBJECT
libfwbuilder::FWObject *obj;
bool init;
Ui::RuleSetDialog_q *m_dialog;
ProjectPanel *m_project;
public:
RuleSetDialog(ProjectPanel *project, QWidget *parent);
~RuleSetDialog();
public slots:
virtual void changed();
virtual void libChanged();
virtual void applyChanges();
virtual void discardChanges();
virtual void loadFWObject(libfwbuilder::FWObject *obj);
virtual void validate(bool*);
virtual void isChanged(bool*);
virtual void closeEvent(QCloseEvent *e);
signals:
/**
* This signal is emitted from closeEvent, ObjectEditor connects
* to this signal to make checks before the object editor can be closed
* and to store its position on the screen
*/
void close_sign(QCloseEvent *e);
void changed_sign();
};
#endif // RULESETDIALOG_H
+294
View File
@@ -0,0 +1,294 @@
<ui version="4.0" >
<class>RuleSetDialog_q</class>
<widget class="QWidget" name="RuleSetDialog_q" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>563</width>
<height>146</height>
</rect>
</property>
<property name="windowTitle" >
<string>Ruleset</string>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>2</number>
</property>
<property name="topMargin" >
<number>2</number>
</property>
<property name="rightMargin" >
<number>2</number>
</property>
<property name="bottomMargin" >
<number>2</number>
</property>
<property name="horizontalSpacing" >
<number>0</number>
</property>
<property name="verticalSpacing" >
<number>0</number>
</property>
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>2</number>
</property>
<item>
<widget class="QFrame" name="frame3" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>16</width>
<height>20</height>
</size>
</property>
<property name="frameShape" >
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>2</number>
</property>
<property name="topMargin" >
<number>2</number>
</property>
<property name="rightMargin" >
<number>2</number>
</property>
<property name="bottomMargin" >
<number>2</number>
</property>
<property name="horizontalSpacing" >
<number>2</number>
</property>
<property name="verticalSpacing" >
<number>2</number>
</property>
<item row="0" column="1" >
<widget class="QLabel" name="editorTitle" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Rule set</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="pixmapLabel1" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="pixmap" >
<pixmap/>
</property>
<property name="scaledContents" >
<bool>true</bool>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame7" >
<property name="frameShape" >
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>2</number>
</property>
<property name="topMargin" >
<number>2</number>
</property>
<property name="rightMargin" >
<number>2</number>
</property>
<property name="bottomMargin" >
<number>2</number>
</property>
<property name="horizontalSpacing" >
<number>2</number>
</property>
<property name="verticalSpacing" >
<number>2</number>
</property>
<item row="1" column="0" >
<widget class="QFrame" name="frame27" >
<property name="frameShape" >
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Sunken</enum>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>2</number>
</property>
<property name="topMargin" >
<number>2</number>
</property>
<property name="rightMargin" >
<number>2</number>
</property>
<property name="bottomMargin" >
<number>2</number>
</property>
<property name="horizontalSpacing" >
<number>2</number>
</property>
<property name="verticalSpacing" >
<number>2</number>
</property>
<item row="3" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>5</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1" >
<property name="text" >
<string>Name:</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLineEdit" name="obj_name" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" >
<widget class="QTextEdit" name="comment" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>100</verstretch>
</sizepolicy>
</property>
<property name="minimumSize" >
<size>
<width>200</width>
<height>0</height>
</size>
</property>
<property name="tabChangesFocus" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QLabel" name="textLabel2" >
<property name="text" >
<string>Comment:</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="2" margin="2" />
<tabstops>
<tabstop>obj_name</tabstop>
<tabstop>comment</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>obj_name</sender>
<signal>textChanged(QString)</signal>
<receiver>RuleSetDialog_q</receiver>
<slot>changed()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
<connection>
<sender>comment</sender>
<signal>textChanged()</signal>
<receiver>RuleSetDialog_q</receiver>
<slot>changed()</slot>
<hints>
<hint type="sourcelabel" >
<x>20</x>
<y>20</y>
</hint>
<hint type="destinationlabel" >
<x>20</x>
<y>20</y>
</hint>
</hints>
</connection>
</connections>
</ui>