bugfix 2565

This commit is contained in:
2008-05-31 14:30:53 +00:00
parent 07975b55b5
commit 1b125e33d3
6 changed files with 644 additions and 1 deletions
+4
View File
@@ -43,6 +43,7 @@
#include "AddressTableDialog.h"
#include "NetworkDialog.h"
#include "NetworkDialogIPv6.h"
#include "UserDialog.h"
#include "CustomServiceDialog.h"
#include "ICMPServiceDialog.h"
#include "IPServiceDialog.h"
@@ -99,6 +100,7 @@
#include "fwbuilder/Rule.h"
#include "fwbuilder/Resources.h"
#include "fwbuilder/TagService.h"
#include "fwbuilder/UserService.h"
#include <iostream>
#include "ProjectPanel.h"
@@ -108,6 +110,8 @@ using namespace libfwbuilder;
QWidget *DialogFactory::createDialog(ProjectPanel *project, QWidget *parent,const QString &objType)
{
if (objType==UserService::TYPENAME) return new UserDialog(project, parent);
if (objType==Policy::TYPENAME) return new RuleSetDialog(project, parent);
if (objType==NAT::TYPENAME) return new RuleSetDialog(project, parent);
+5
View File
@@ -75,6 +75,7 @@
#include "fwbuilder/UDPService.h"
#include "fwbuilder/ServiceGroup.h"
#include "fwbuilder/TagService.h"
#include "fwbuilder/UserService.h"
#include "fwbuilder/Interval.h"
#include "fwbuilder/IntervalGroup.h"
@@ -105,6 +106,10 @@ ObjectEditor::ObjectEditor( QWidget *parent, ProjectPanel *project):
#endif
QWidget *w;
w= DialogFactory::createDialog(m_project, parent,UserService::TYPENAME);
stackIds[UserService::TYPENAME] = parentWidget->addWidget(w);
dialogs[stackIds[UserService::TYPENAME]] = w;
w= DialogFactory::createDialog(m_project, parent,Policy::TYPENAME);
stackIds[Policy::TYPENAME] = parentWidget->addWidget(w);
dialogs[stackIds[Policy::TYPENAME]] = w;
+161
View File
@@ -0,0 +1,161 @@
/*
Firewall Builder
Copyright (C) 2003 NetCitadel, LLC
Author: Vadim Kurland vadim@fwbuilder.org
$Id: UserDialog.cpp,v 1.22 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 "UserDialog.h"
#include "ProjectPanel.h"
#include "fwbuilder/Library.h"
#include "fwbuilder/UserService.h"
#include "fwbuilder/Interface.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;
UserDialog::UserDialog(ProjectPanel *project, QWidget *parent) : QWidget(parent), m_project(project)
{
m_dialog = new Ui::UserDialog_q;
m_dialog->setupUi(this);
setFont(st->getUiFont());
obj=NULL;
}
UserDialog::~UserDialog() { delete m_dialog; }
void UserDialog::loadFWObject(FWObject *o)
{
obj=o;
UserService *s = dynamic_cast<UserService*>(obj);
assert(s!=NULL);
init=true;
fillLibraries(m_dialog->libs,obj);
m_dialog->obj_name->setText( QString::fromUtf8(s->getName().c_str()) );
m_dialog->userid->setText( s->getUserId().c_str() );
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);
m_dialog->userid->setEnabled(!o->isReadOnly());
setDisabledPalette(m_dialog->userid);
m_dialog->comment->setReadOnly(o->isReadOnly());
setDisabledPalette(m_dialog->comment);
init=false;
}
void UserDialog::changed()
{
//apply->setEnabled( true );
emit changed_sign();
}
void UserDialog::validate(bool *res)
{
*res=true;
if (!isTreeReadWrite(this,obj)) { *res=false; return; }
if (!validateName(this,obj,m_dialog->obj_name->text())) { *res=false; return; }
UserService *s = dynamic_cast<UserService*>(obj);
assert(s!=NULL);
}
void UserDialog::isChanged(bool*)
{
//*res=(!init && apply->isEnabled());
}
void UserDialog::libChanged()
{
changed();
}
void UserDialog::applyChanges()
{
UserService *s = dynamic_cast<UserService*>(obj);
assert(s!=NULL);
s->dump(false,false);
string oldname=obj->getName();
obj->setName( string(m_dialog->obj_name->text().toUtf8().constData()) );
obj->setComment( string(m_dialog->comment->toPlainText().toUtf8().constData()) );
obj->setName( string(m_dialog->userid->text().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 UserDialog::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 UserDialog::closeEvent(QCloseEvent *e)
{
emit close_sign(e);
}
+72
View File
@@ -0,0 +1,72 @@
/*
Firewall Builder
Copyright (C) 2003 NetCitadel, LLC
Author: Vadim Kurland vadim@fwbuilder.org
$Id: UserDialog.h,v 1.7 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 __USERDIALOG_H_
#define __USERDIALOG_H_
#include "config.h"
#include <ui_userdialog_q.h>
#include <QWidget>
#include "fwbuilder/FWObject.h"
class ProjectPanel;
class UserDialog : public QWidget
{
Q_OBJECT
libfwbuilder::FWObject *obj;
Ui::UserDialog_q *m_dialog;
bool init;
ProjectPanel *m_project;
public:
UserDialog(ProjectPanel *project, QWidget *parent);
~UserDialog();
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 // UserDialog_H
+3
View File
@@ -68,6 +68,7 @@ HEADERS += ../../config.h \
PhysicalAddressDialog.h \
NetworkDialog.h \
NetworkDialogIPv6.h \
UserDialog.h \
RuleSetDialog.h \
LibraryDialog.h \
CustomServiceDialog.h \
@@ -179,6 +180,7 @@ SOURCES += ProjectPanel.cpp \
PhysicalAddressDialog.cpp \
NetworkDialog.cpp \
NetworkDialogIPv6.cpp \
UserDialog.cpp \
LibraryDialog.cpp \
CustomServiceDialog.cpp \
IPServiceDialog.cpp \
@@ -252,6 +254,7 @@ FORMS = FWBMainWindow_q.ui \
addresstabledialog_q.ui \
networkdialog_q.ui \
networkdialogipv6_q.ui \
userdialog_q.ui \
hostdialog_q.ui \
firewalldialog_q.ui \
interfacedialog_q.ui \
+398
View File
@@ -0,0 +1,398 @@
<ui version="4.0" >
<class>UserDialog_q</class>
<widget class="QWidget" name="UserDialog_q" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>562</width>
<height>166</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Minimum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle" >
<string>User</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>2</number>
</property>
<property name="verticalSpacing" >
<number>2</number>
</property>
<item row="0" column="0" >
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>2</number>
</property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</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="frameShape" >
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Plain</enum>
</property>
<property name="text" >
<string>User</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="sizePolicy" >
<sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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="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>
<item row="1" column="0" >
<widget class="QFrame" name="frame50" >
<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="4" 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="1" column="0" >
<widget class="QLabel" name="textLabel1_2" >
<property name="text" >
<string>Library:</string>
</property>
<property name="wordWrap" >
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="userid" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="textLabel2_2" >
<property name="text" >
<string>User id:</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>
<item row="1" column="1" >
<widget class="QComboBox" name="libs" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<layoutdefault spacing="2" margin="2" />
<tabstops>
<tabstop>obj_name</tabstop>
<tabstop>libs</tabstop>
<tabstop>userid</tabstop>
<tabstop>comment</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>obj_name</sender>
<signal>textChanged(QString)</signal>
<receiver>UserDialog_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>libs</sender>
<signal>activated(int)</signal>
<receiver>UserDialog_q</receiver>
<slot>libChanged()</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>userid</sender>
<signal>textChanged(QString)</signal>
<receiver>UserDialog_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>UserDialog_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>