diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 01:04:17 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-02-17 01:04:17 +0000 |
commit | c3b707c026782768bd8c0e6ae6b574fe8a36802d (patch) | |
tree | 5ca6782031b1546c788290cc0b95524369ff01ea /kmyfirewall/genericinterface | |
download | kmyfirewall-c3b707c026782768bd8c0e6ae6b574fe8a36802d.tar.gz kmyfirewall-c3b707c026782768bd8c0e6ae6b574fe8a36802d.zip |
Added old abandoned KDE3 version of kmyfirewall
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kmyfirewall@1091559 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kmyfirewall/genericinterface')
21 files changed, 3982 insertions, 0 deletions
diff --git a/kmyfirewall/genericinterface/Makefile.am b/kmyfirewall/genericinterface/Makefile.am new file mode 100644 index 0000000..df0dc7e --- /dev/null +++ b/kmyfirewall/genericinterface/Makefile.am @@ -0,0 +1,22 @@ +INCLUDES = $(all_includes) -I../core -I../ipteditor -I../kmfwidgets +METASOURCES = AUTO +kde_module_LTLIBRARIES = libkmfgenericinterfacepart.la + +partrcdir = $(kde_datadir)/kmfgenericinterfacepart +partrc_DATA = kmfgenericinterfacepartui.rc + +libkmfgenericinterfacepart_la_LDFLAGS = -module -no-undefined $(all_libraries) \ + $(KDE_PLUGIN) +libkmfgenericinterfacepart_la_LIBADD = \ + $(LIB_KPARTS) ../kmfwidgets/libkmfwidgets.la ../core/libkmfcore.la + +libkmfgenericinterfacepart_la_SOURCES = kmfgenericinterface.cpp \ + kmfgenericinterface_part.cpp kmfgenericinterfaceprotocol.cpp kmfgenericinterfacenat.cpp \ + kmfgenericinterfacehost.cpp kmfgenericinterfacelogging.cpp kmyfirewallgenericinterfacelogging.ui \ + kmfgenericinterfaceicmp.cpp kmyfirewallgenericinterfaceicmp.ui \ + kmyfirewallgenericinterfacehostwidget.ui kmyfirewallgenericinterfacenatwidget.ui \ + kmyfirewallgenericinterfaceprotocolwidget.ui + +noinst_HEADERS = kmfgenericinterface.h kmfgenericinterface_part.h \ + kmfgenericinterfaceprotocol.h kmfgenericinterfacenat.h kmfgenericinterfacehost.h \ + kmfgenericinterfacelogging.h kmfgenericinterfaceicmp.h diff --git a/kmyfirewall/genericinterface/kmfgenericinterface.cpp b/kmyfirewall/genericinterface/kmfgenericinterface.cpp new file mode 100644 index 0000000..1be07d7 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterface.cpp @@ -0,0 +1,237 @@ +// +// +// C++ Implementation: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include "kmfgenericinterface.h" + +// qt includes +#include <qstring.h> +#include <qlayout.h> +#include <qtabwidget.h> + +// kde includes +#include <klocale.h> +#include <kdebug.h> +#include <kglobal.h> +#include <kiconloader.h> + + +// project includes +#include "../core/kmfnetwork.h" +#include "../core/kmfgenericdoc.h" + +#include "../kmfwidgets/kmfmynetworkwidget.h" +#include "kmfgenericinterfaceprotocol.h" +//#include "kmfgenericinterfaceeditprotocol.h" +#include "kmfgenericinterfacenat.h" +#include "kmfgenericinterfacehost.h" +#include "kmfgenericinterfacelogging.h" +#include "kmfgenericinterfaceicmp.h" + +namespace KMF { + +KMFGenericInterface::KMFGenericInterface( QWidget *parent, const char *name ) : KJanusWidget( parent, name, KJanusWidget::IconList ) { + connect( this,SIGNAL( aboutToShowPage( QWidget* ) ), + this,SLOT( slotPageChanged( QWidget* ) ) ); + loadIcons(); + + //###################### My Network Widget ################################### + myNetworkFrame = addPage(i18n("My Network"), i18n("Define and configure the firewall host you like to configure"), icon_zone_page ); + m_myNetworkWidget = new KMFMyNetworkWidget( myNetworkFrame, "m_myNetworkWidget" ); + connect( this, SIGNAL( sigUpdateView() ), + m_myNetworkWidget, SLOT( slotUpdateView() ) ); + connect( this, SIGNAL( sigUpdateView( NetfilterObject* ) ), + m_myNetworkWidget, SLOT( slotUpdateView( NetfilterObject* ) ) ); + + connect( m_myNetworkWidget, SIGNAL( sigActiveTargetChanged() ), this, SIGNAL( sigTargetChanged() ) ); + + QGridLayout *myNetworkLayout = new QGridLayout( myNetworkFrame, 1, 1, 2, 2 ); + myNetworkLayout->addWidget( m_myNetworkWidget,0,0 ); + + //###################### Access Control PAGE ################################# + protocolFrame = addPage(i18n("Access Control"), i18n("Access configuration for incoming and outgoing connections"), icon_protocol_page ); + + m_protocolPageZones = new KMFGenericInterfaceProtocol( protocolFrame, "m_protocolPageIncoming"); + connect( this, SIGNAL( sigUpdateView() ), + m_protocolPageZones, SLOT( slotUpdateView() ) ); + connect( this, SIGNAL( sigUpdateView( NetfilterObject* ) ), + m_protocolPageZones, SLOT( slotUpdateView( NetfilterObject* ) ) ); + + QGridLayout *protocoLayout = new QGridLayout( protocolFrame, 1, 1, 2, 2 ); + protocoLayout->addWidget( m_protocolPageZones,0,0 ); + + //###################### HOSTS PAGE ################################### + hostFrame = addPage(i18n("Special Hosts"), i18n("Define Hosts that should be treated specially."), icon_host_page ); + m_hostPage = new KMFGenericInterfaceHost(hostFrame,"m_hostPageTrusted"); + connect( this, SIGNAL( sigUpdateView() ), + m_hostPage, SLOT( slotUpdateView() ) ); + connect( this, SIGNAL( sigUpdateView( NetfilterObject* ) ), + m_hostPage, SLOT( slotUpdateView( NetfilterObject* ) ) ); + + QGridLayout *hostLayout = new QGridLayout( hostFrame, 1, 1, 2, 2 ); + hostLayout->addWidget( m_hostPage,0,0 ); + + //###################### ICMP PAGE ################################# + icmpFrame = addPage(i18n("ICMP Options"), i18n("Define how ICMP packets should be handled."), icon_icmp_page ); + QGridLayout *icmpLayout = new QGridLayout( icmpFrame, 1, 1, 2, 2 ); + m_icmpPage = new KMFGenericInterfaceIcmp(icmpFrame,"m_icmpPage"); + connect( this, SIGNAL( sigUpdateView() ), + m_icmpPage, SLOT( slotUpdateView() ) ); + connect( this, SIGNAL( sigUpdateView( NetfilterObject* ) ), + m_icmpPage, SLOT( slotUpdateView( NetfilterObject* ) ) ); + + icmpLayout->addWidget( m_icmpPage,0,0 ); + + + //###################### NAT PAGE ################################### + natFrame = addPage(i18n("NAT Configuration"), i18n("Configure NAT (Network Address Translation) here."), icon_nat_page ); + QGridLayout *natLayout = new QGridLayout( natFrame, 1, 1, 2, 2 ); + m_natPage = new KMFGenericInterfaceNat(natFrame,"m_natPage"); + connect( this, SIGNAL( sigUpdateView() ), + m_natPage, SLOT( slotUpdateView() ) ); + connect( this, SIGNAL( sigUpdateView( NetfilterObject* ) ), + m_natPage, SLOT( slotUpdateView( NetfilterObject* ) ) ); + + natLayout->addWidget( m_natPage,0,0 ); + + //###################### LOGGING PAGE ################################### + logFrame = addPage(i18n("Logging"), i18n("Configure your firewall's logging behavior here."), icon_logging_page ); + QGridLayout *logLayout = new QGridLayout( logFrame, 1, 1, 2, 2 ); + m_loggingPage = new KMFGenericInterfaceLogging(logFrame,"m_loggingPage"); + connect( this, SIGNAL( sigUpdateView() ), + m_loggingPage, SLOT( slotUpdateView() ) ); + connect( this, SIGNAL( sigUpdateView( NetfilterObject* ) ), + m_loggingPage, SLOT( slotUpdateView( NetfilterObject* ) ) ); + + logLayout->addWidget( m_loggingPage,0,0 ); + + setEnabled( false ); +} + +KMFGenericInterface::~KMFGenericInterface() {} + +void KMFGenericInterface::loadDoc( KMFNetwork* doc ) { + kdDebug() << "void KMFGenericInterface::loadDoc( KMFGenericDoc* )" << endl; + if ( ! doc ) { + setEnabled( false ); + return; + } + setEnabled( true ); + m_network = doc; + + m_myNetworkWidget->setNetwork( m_network ); + m_myNetworkWidget->slotUpdateView(); + m_myNetworkWidget->parent(); + + m_protocolPageZones->loadDoc( m_network ); + m_protocolPageZones->slotUpdateView(); + + m_hostPage->loadDoc( m_network ); + m_hostPage->slotUpdateView(); + +// m_protocolPageEditProtocol->loadDoc( m_network ); +// m_protocolPageEditProtocol->slotUpdateView(); + + m_icmpPage->loadDoc( m_network ); + m_icmpPage->slotUpdateView(); + + m_natPage->loadDoc( m_network ); + m_natPage->slotUpdateView(); + + m_loggingPage->loadDoc( m_network ); + m_loggingPage->slotUpdateView(); +} + +/* +void KMFGenericInterface::slotUpdateView( NetfilterObject* obj ) { + kdDebug() << "KMFGenericInterface::slotUpdateView( NetfilterObject* )" << endl; + if ( ! m_network ) { + setEnabled( false ); + return; + } + m_myNetworkWidget->slotUpdateView( obj ); + + m_protocolPageZones->slotUpdateView( obj ); + + m_hostPage->slotUpdateView( obj ); + + m_icmpPage->slotUpdateView( obj ); + + m_natPage->slotUpdateView( obj ); + + m_loggingPage->slotUpdateView( obj ); +} + +void KMFGenericInterface::slotUpdateView() { + if ( ! m_network ) { + setEnabled( false ); + return; + } + m_myNetworkWidget->slotUpdateView(); + + m_protocolPageZones->slotUpdateView(); + + m_hostPage->slotUpdateView(); + + m_icmpPage->slotUpdateView(); + + m_natPage->slotUpdateView(); + + m_loggingPage->slotUpdateView(); +} +*/ + +void KMFGenericInterface::slotPageChanged( QWidget* /*wid*/ ){ + kdDebug() << "KMFGenericInterface::slotPageChanged( QWidget* )" << endl; + emit sigUpdateView(); + // slotUpdateView(); +} + +void KMFGenericInterface::loadIcons() { + kdDebug() << "void KMFGenericInterface::loadIcons()" << endl; + KIconLoader *loader = KGlobal:: iconLoader(); + QString icon_name; + + icon_name = "network"; + icon_zone_page = loader->loadIcon( icon_name, KIcon::Desktop ); + + icon_name = "services"; + icon_protocol_page = loader->loadIcon( icon_name, KIcon::Desktop ); + + icon_name = "nfs_unmount"; + icon_edit_protocol_page = loader->loadIcon( icon_name, KIcon::Desktop ); + + icon_name = "pipe"; + icon_icmp_page = loader->loadIcon( icon_name, KIcon::Desktop ); + + icon_name = "log"; + icon_logging_page = loader->loadIcon( icon_name, KIcon::Desktop ); + + icon_name = "network_local"; + icon_host_page = loader->loadIcon( icon_name, KIcon::Desktop ); + + icon_name = "filesaveas"; + icon_nat_page = loader->loadIcon( icon_name, KIcon::Desktop ); +} + +} + +#include "kmfgenericinterface.moc" diff --git a/kmyfirewall/genericinterface/kmfgenericinterface.h b/kmyfirewall/genericinterface/kmfgenericinterface.h new file mode 100644 index 0000000..9853a35 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterface.h @@ -0,0 +1,100 @@ +// +// +// C++ Interface: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef KMFGENERICINTERFACE_H +#define KMFGENERICINTERFACE_H + +#include <kjanuswidget.h> + +/** +@author Christian Hubinger +*/ + +// QT includes +#include <qpixmap.h> +#include <qguardedptr.h> + +class QFrame; +class QVBox; +class QTabWidget; + +// KDE includes + + + +// Project includes +namespace KMF { +class KMFGenericInterfaceProtocol; +class KMFGenericInterfaceNat; +class KMFGenericInterfaceHost; +class KMFGenericInterfaceLogging; +class KMFGenericInterfaceEditProtocol; +class KMFGenericInterfaceIcmp; +class KMFGenericDoc; +class KMFNetwork; +class KMFMyNetworkWidget; +class NetfilterObject; + +class KMFGenericInterface : public KJanusWidget { + Q_OBJECT +public: + + KMFGenericInterface( QWidget *parent = 0, const char *name = 0 ); + ~KMFGenericInterface(); + + void loadDoc( KMFNetwork* ); + + +private slots: + void slotPageChanged( QWidget* ); +// void slotUpdateView(); +// void slotUpdateView( NetfilterObject* ); + +private: + void loadIcons(); + +signals: + void sigUpdateView(); + void sigUpdateView( NetfilterObject* ); + void sigTargetChanged(); + +private: + KMFMyNetworkWidget *m_myNetworkWidget; + KMFGenericInterfaceProtocol *m_protocolPageZones; + KMFGenericInterfaceEditProtocol *m_protocolPageEditProtocol; + KMFGenericInterfaceNat *m_natPage; + KMFGenericInterfaceHost *m_hostPage; + KMFGenericInterfaceLogging *m_loggingPage; + KMFGenericInterfaceIcmp *m_icmpPage; + + QGuardedPtr<KMFNetwork> m_network; + + QFrame *myNetworkFrame, *zoneFrame, *protocolFrame, *editProtocolFrame,*icmpFrame, *hostFrame,*natFrame, *logFrame; + + QPixmap icon_zone_page, icon_protocol_page, + icon_edit_protocol_page, icon_icmp_page, + icon_logging_page, icon_host_page, icon_nat_page; + + +}; +} +#endif diff --git a/kmyfirewall/genericinterface/kmfgenericinterface_part.cpp b/kmyfirewall/genericinterface/kmfgenericinterface_part.cpp new file mode 100644 index 0000000..1da06a9 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterface_part.cpp @@ -0,0 +1,258 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/* +Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2001 +*/ + + +#include "kmfgenericinterface_part.h" + + +// QT includes +#include <qlabel.h> + +// KDE includes +#include <kinstance.h> +#include <kaction.h> +#include <kstdaction.h> +#include <klocale.h> +#include <kaboutdata.h> +#include <kmessagebox.h> +#include <kiconloader.h> +#include <kparts/genericfactory.h> + +// Project includes +#include "kmfgenericinterface.h" + +#include "../core/kmfnetwork.h" + +#include "../kmfwidgets/kmfmainwindow.h" +namespace KMF { +KMFGenericInterfacePart::KMFGenericInterfacePart( QWidget *parentWidget, const char * widgetName , + QObject *parent, const char *name, + const QStringList & /*args*/ ) + : KParts::ReadWritePart( parent, name ) { + setInstance( KMFGenericInterfacePartFactory::instance() ); + + m_genericinterface = new KMFGenericInterface( parentWidget, widgetName ); + + + m_app = dynamic_cast<KMFMainWindow*>( parent ); + if ( ! m_app ) { + KMessageBox::error(0,"Oops wrong parent class found for kmfinstallerplugin!!!"); + } + + m_genericinterface->loadDoc( m_app->network() ); + connect( m_genericinterface, SIGNAL( sigTargetChanged() ), + this, SLOT( slotTargetChanged() ) ); + + connect( m_app, SIGNAL( sigUpdateView() ), + m_genericinterface, SIGNAL( sigUpdateView() ) ); + + connect( m_app, SIGNAL( sigUpdateView( NetfilterObject* ) ), + m_genericinterface, SIGNAL( sigUpdateView( NetfilterObject* ) ) ); + + connect( m_app, SIGNAL( sigEnableActions( bool ) ), + this, SLOT( slotEnableActions( bool ) ) ); + + + m_actionGoMyNetwork = new KAction( i18n( "&My Network" ), QIconSet( BarIcon( "network", KMFGenericInterfacePartFactory::instance() ) ), + 0 , this, SLOT( slotGoMyNetwork() ), actionCollection(), "my_network" ); + + m_actionGoAccessControl = new KAction( i18n( "&Access Control" ), QIconSet( BarIcon( "services", KMFGenericInterfacePartFactory::instance() ) ), + 0 , this, SLOT( slotGoAccessControl() ), actionCollection(), "access_control" ); + + + m_actionGoSpecialHosts = new KAction( i18n( "&Special Hosts Control" ), QIconSet( BarIcon( "network_local", KMFGenericInterfacePartFactory::instance() ) ), + 0 , this, SLOT( slotGoSpecialHosts() ), actionCollection(), "special_hosts" ); + + + m_actionGoICMPOptions = new KAction( i18n( "&ICMP Options" ), QIconSet( BarIcon( "pipe", KMFGenericInterfacePartFactory::instance() ) ), + 0 , this, SLOT( slotGoICMPOptions() ), actionCollection(), "icmp_options" ); + + + m_actionGoNATConfiguration = new KAction( i18n( "&NAT Configuration" ), QIconSet( BarIcon( "filesaveas", KMFGenericInterfacePartFactory::instance() ) ), + 0 , this, SLOT( slotGoNATConfiguration() ), actionCollection(), "nat_configuration" ); + + m_actionGoLogging = new KAction( i18n( "&Logging" ), QIconSet( BarIcon( "log", KMFGenericInterfacePartFactory::instance() ) ), + 0 , this, SLOT( slotGoLogging() ), actionCollection(), "logging_options" ); + + + setWidget( m_genericinterface ); + setXMLFile( "kmfgenericinterfacepartui.rc" ); + + // we are read-write by default + setReadWrite( true ); + + // we are not modified since we haven't done anything yet + setModified( false ); + +} + +KMFGenericInterfacePart::~KMFGenericInterfacePart() { + closeURL(); +} + +void KMFGenericInterfacePart::slotTargetChanged() { + m_app->updateCaption(); +} + +void KMFGenericInterfacePart::setReadWrite( bool rw ) { + ReadWritePart::setReadWrite( rw ); +} + +void KMFGenericInterfacePart::slotGoMyNetwork() { + kdDebug() << "slotGoMyNetwork()" << endl; + m_genericinterface->showPage( 0 ); +} + +void KMFGenericInterfacePart::slotGoAccessControl() { + kdDebug() << "slotGoAccessControl()" << endl; + m_genericinterface->showPage( 1 ); +} + +void KMFGenericInterfacePart::slotGoSpecialHosts() { + kdDebug() << "slotGoSpecialHosts()" << endl; + m_genericinterface->showPage( 2 ); +} + +void KMFGenericInterfacePart::slotGoICMPOptions() { + kdDebug() << "slotGoICMPOptions()" << endl; + m_genericinterface->showPage( 3 ); +} + +void KMFGenericInterfacePart::slotGoNATConfiguration() { + kdDebug() << "slotGoNATConfiguration()" << endl; + m_genericinterface->showPage( 4 ); +} + +void KMFGenericInterfacePart::slotGoLogging() { + kdDebug() << "slotGoLogging()" << endl; + m_genericinterface->showPage( 5 ); +} + + +void KMFGenericInterfacePart::setModified( bool modified ) { + // get a handle on our Save action and make sure it is valid +// KAction * save = actionCollection() ->action( KStdAction::stdName( KStdAction::Save ) ); +// if ( !save ) +// return ; +// +// // if so, we either enable or disable it based on the current +// // state +// if ( modified ) +// save->setEnabled( true ); +// else +// save->setEnabled( false ); + + // in any event, we want our parent to do it's thing + ReadWritePart::setModified( modified ); +} + +bool KMFGenericInterfacePart::openFile() { + // m_file is always local so we can use QFile on it + // QFile file(m_file); + // if (file.open(IO_ReadOnly) == false) + // return false; + // + // // our example widget is text-based, so we use QTextStream instead + // // of a raw QDataStream + // QTextStream stream(&file); + // QString str; + // while (!stream.eof()) + // str += stream.readLine() + "\n"; + // + // file.close(); + // + // // now that we have the entire file, display it + // // m_widget->setText(str); + // + // // just for fun, set the status bar + // emit setStatusBarText( m_url.prettyURL() ); + + return true; +} + +bool KMFGenericInterfacePart::saveFile() { + // if we aren't read-write, return immediately + /* if (isReadWrite() == false) + return false; + + // m_file is always local, so we use QFile + QFile file(m_file); + if (file.open(IO_WriteOnly) == false) + return false; + + // use QTextStream to dump the text to the file + QTextStream stream(&file); + stream << m_widget->text(); + + file.close(); + */ + return true; +} + +void KMFGenericInterfacePart::slotEnableActions( bool ) { + kdDebug() << "void KMFGenericInterfacePart::slotEnableActions( bool )" << endl; +} + +// bool KMFGenericInterfacePart::closeURL() +// { +// return true; +// } + +// It's usually safe to leave the factory code alone.. with the +// notable exception of the KAboutData data +#include <kaboutdata.h> +#include <klocale.h> + +KInstance* KMFGenericInterfacePartFactory::s_instance = 0L; +KAboutData* KMFGenericInterfacePartFactory::s_about = 0L; + +KMFGenericInterfacePartFactory::KMFGenericInterfacePartFactory() + : KParts::Factory() {} + +KMFGenericInterfacePartFactory::~KMFGenericInterfacePartFactory() { + delete s_instance; + delete s_about; + + s_instance = 0L; +} + +KParts::Part* KMFGenericInterfacePartFactory::createPartObject( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const char *classname, const QStringList& args) { + // Create an instance of our Part + KMFGenericInterfacePart * obj = new KMFGenericInterfacePart( parentWidget, widgetName, parent, name ,args ); + + // See if we are to be read-write or not + if ( QCString( classname ) == "KParts::ReadOnlyPart" ) + obj->setReadWrite( false ); + + return obj; +} + +KInstance* KMFGenericInterfacePartFactory::instance() { + if ( !s_instance ) { + s_about = new KAboutData( "kmfgenericinterfacepart", I18N_NOOP( "kmfgenericinterfacepartPart" ), "0.1" ); + s_about->addAuthor( "Christian Hubinger", 0, "chubinger@irrsinnig.org" ); + s_instance = new KInstance( s_about ); + } + return s_instance; +} + +extern "C" { + void* init_libkmfgenericinterfacepart() { + return new KMFGenericInterfacePartFactory; + } +} + +} + +#include "kmfgenericinterface_part.moc" diff --git a/kmyfirewall/genericinterface/kmfgenericinterface_part.h b/kmyfirewall/genericinterface/kmfgenericinterface_part.h new file mode 100644 index 0000000..d86c120 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterface_part.h @@ -0,0 +1,111 @@ +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/* +Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2001 +*/ + + +#ifndef __kmfgenericinterface_part_h__ +#define __kmfgenericinterface_part_h__ + +#include <klibloader.h> +#include <kparts/part.h> +#include <kparts/factory.h> + +class KInstance; +class KAboutData; +class QLabel; +class KAction; +class KActionMenu; + +namespace KMF { +class KMFMainWindow; +class KMFGenericInterface; + +class KMFGenericInterfacePart: public KParts::ReadWritePart { + Q_OBJECT +public: + KMFGenericInterfacePart( QWidget *parent, const char *name, QObject *parentObject, const + char *nameOb, + const QStringList & /*args*/ ); + virtual ~KMFGenericInterfacePart(); + static KAboutData *createAboutData(); + + /** + * This is a virtual function inherited from KParts::ReadWritePart. + * A shell will use this to inform this Part if it should act + * read-only + */ + virtual void setReadWrite( bool rw ); + + /** + * Reimplemented to disable and enable Save action + */ + virtual void setModified( bool modified ); +public slots: + void slotEnableActions( bool ); + void slotGoAccessControl(); + void slotGoMyNetwork(); + void slotGoSpecialHosts(); + void slotGoICMPOptions(); + void slotGoNATConfiguration(); + void slotGoLogging(); + + void slotTargetChanged(); + + + + +protected: + /** + * This must be implemented by each part + */ + virtual bool openFile(); + + /** + * This must be implemented by each read-write part + */ + virtual bool saveFile(); + +private: + KMFMainWindow *m_app; + + KMFGenericInterface *m_genericinterface; + KAction* m_actionGoMyNetwork; + KAction* m_actionGoAccessControl; + KAction* m_actionGoSpecialHosts; + KAction* m_actionGoICMPOptions; + KAction* m_actionGoNATConfiguration; + KAction* m_actionGoLogging; + +/*signals: + void sigUpdateView();*/ +}; + + + +class KMFGenericInterfacePartFactory : public KParts::Factory +{ + Q_OBJECT +public: + KMFGenericInterfacePartFactory(); + virtual ~KMFGenericInterfacePartFactory(); + virtual KParts::Part* createPartObject( QWidget *parentWidget, const char *widgetName, + QObject *parent, const char *name, + const char *classname, const QStringList &args ); + static KInstance* instance(); + +private: + static KInstance* s_instance; + static KAboutData* s_about; +}; +} +#endif + + diff --git a/kmyfirewall/genericinterface/kmfgenericinterfacehost.cpp b/kmyfirewall/genericinterface/kmfgenericinterfacehost.cpp new file mode 100644 index 0000000..aa72c4c --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfacehost.cpp @@ -0,0 +1,519 @@ +// +// +// C++ Implementation: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include "kmfgenericinterfacehost.h" + +// QT includes +#include <qstring.h> +#include <qcheckbox.h> +#include <qtextedit.h> +#include <qlabel.h> +#include <qtimer.h> + +// KDE includes +#include <klocale.h> +#include <kdebug.h> +#include <klistview.h> +#include <kpopupmenu.h> +#include <kpushbutton.h> +#include <kiconloader.h> +#include <knuminput.h> +#include <kmessagebox.h> +#include <kstdguiitem.h> + +// Project includes +#include "../core/kmfnetwork.h" +#include "../core/kmfgenericdoc.h" +#include "../core/kmfnetzone.h" +#include "../core/kmfnethost.h" + +#include "../kmfwidgets/kmflistviewitem.h" + +namespace KMF { +KMFGenericInterfaceHost::KMFGenericInterfaceHost( QWidget *parent, const char *name, WFlags f ) + : KMyFirewallGenericInterfaceHostWidget( parent, name, f ) { + m_lv_zones->setFullWidth( true ); + m_contextMenu = new KPopupMenu( this, "Popup" ); + m_contextMenu->hide(); + loadIcons(); + connect( m_lv_zones, SIGNAL( pressed( QListViewItem* ) ) , + this, SLOT( slotNewItemSelected( QListViewItem* ) ) ); + connect( m_lv_zones, SIGNAL( contextMenuRequested ( QListViewItem*, const QPoint&, int ) ), + this, SLOT( slotZoneRBM( QListViewItem*, const QPoint&, int ) ) ); + connect( m_lv_zones, SIGNAL( itemRenamed ( QListViewItem *, int, const QString & ) ) , + this, SLOT( slotHostRenamed( QListViewItem*, int , const QString & ) ) ); + + connect( m_sb_host_1, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); + connect( m_sb_host_2, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); + connect( m_sb_host_3, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); + connect( m_sb_host_4, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); + + connect( m_host_desc, SIGNAL( textChanged() ), + this, SLOT( slotHostDescChanged() ) ); + + connect( c_log_in, SIGNAL( toggled( bool ) ), + this, SLOT( slotLoggingChanged( bool ) ) ); + connect( c_log_out, SIGNAL( toggled( bool ) ), + this, SLOT( slotLoggingChanged( bool ) ) ); + + b_newHost->setIconSet( icon_new ); + b_delHost->setIconSet( icon_del ); + + connect( b_newHost, SIGNAL( clicked() ), + this, SLOT( slotNewHost() ) ); + + connect( b_delHost, SIGNAL( clicked() ), + this, SLOT( slotDelHost() ) ); +} + + +KMFGenericInterfaceHost::~KMFGenericInterfaceHost() {} + +// void KMFGenericInterfaceHost::slotDisable() { +// } + +void KMFGenericInterfaceHost::slotUpdateView( NetfilterObject* ) { + kdDebug() << "KMFGenericInterfaceHost::slotUpdateView( NetfilterObject* )" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + slotUpdateView(); +} + +void KMFGenericInterfaceHost::slotUpdateView() { + kdDebug() << "KMFGenericInterfaceHost::slotUpdateView()" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + + m_lv_zones->clear(); + itemTrustedHosts = new KMFListViewItem( m_lv_zones, 0, m_doc->currentDocAsGenericDoc()-> trustedHostsZone() ); + itemMaliciousHosts = new KMFListViewItem( m_lv_zones, 0, m_doc->currentDocAsGenericDoc()->maliciousHostsZone() ); + itemBadServers = new KMFListViewItem( m_lv_zones, 0, m_doc->currentDocAsGenericDoc()->badServersHostsZone() ); + itemBadClients = new KMFListViewItem( m_lv_zones, 0, m_doc->currentDocAsGenericDoc()->badClientsHostsZone() ); + + itemTrustedHosts->deleteChildren(); + itemTrustedHosts->setupZoneView(); + + itemMaliciousHosts->deleteChildren(); + itemMaliciousHosts->setupZoneView(); + + itemBadServers->deleteChildren(); + itemBadServers->setupZoneView(); + + itemBadClients->deleteChildren(); + itemBadClients->setupZoneView(); + + KMFListViewItem* it = 0; + if ( m_host ) { + it = findKMFItem( m_host->uuid() ); + } else if ( m_zone ) { + it = findKMFItem( m_zone->uuid() ); + } + if ( it ) { + m_lv_zones->setSelected( it, true ); + slotNewItemSelected( it ); + } +} + +/*! + \fn KMFGenericInterfaceHost::loadDoc( KMFGenericDoc* ) + */ +void KMFGenericInterfaceHost::loadDoc( KMFNetwork* doc ) { + kdDebug() << "void KMFGenericInterfaceHost::loadDoc( KMFGenericDoc* )" << endl; + m_doc = doc; + slotUpdateView(); +} + +/*! + \fn KMFGenericInterfaceHost::slotAddHost() + */ +void KMFGenericInterfaceHost::slotNewHost() { + kdDebug() << "void KMFGenericInterfaceHost::slotNewHost()" << endl; + if ( m_zone ) { + + KMFUndoEngine::instance()->startTransaction( + m_zone, + i18n( "Add new host to zone: %1." ).arg( m_zone->guiName() ) + ); + KMFNetHost * host = m_zone->addNetHost( i18n("New Host"), *(new QDomDocument() ) ); + if ( host ) { + host->setGuiName( i18n("New Host") ); + KMFListViewItem* it = findKMFItem( i18n("New Host"), host->uuid() ); + if ( it ) { + it->setRenameEnabled( 0, true ); + it->startRename( 0 ); + } + m_host = host; + m_zone = host->zone(); + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); + } else { + KMFUndoEngine::instance()->abortTransaction(); + } + } +} + +/*! + \fn KMFGenericInterfaceHost::slotDelHost() + */ +void KMFGenericInterfaceHost::slotDelHost() { + kdDebug() << "void KMFGenericInterfaceHost::slotDelHost()" << endl; + if ( ! m_host || ! m_zone ) + return; + if ( KMessageBox::questionYesNo(this, i18n("<qt>Are you sure that you want to delete host " + "<b>%1</b> from <b>%2</b>?</qt>").arg(m_host->guiName() ).arg( m_zone->guiName() ), + i18n("Are you sure?"), KStdGuiItem::yes(), KStdGuiItem::cancel(), + "genericgui_hostpage_hostdelete") == KMessageBox::Yes ) { + KMFUndoEngine::instance()->startTransaction( + m_zone, + i18n( "Delete host: %1 from zone: %2." ).arg( m_host->guiName() ).arg( m_zone->guiName() ) + ); + m_zone->delHost( m_host ); + m_host = 0; + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); + } +} + +/*! + \fn KMFGenericInterfaceHost::slotNewItemSelected( QListViewItem* ) + */ +void KMFGenericInterfaceHost::slotNewItemSelected( QListViewItem* item ){ + kdDebug() << "void KMFGenericInterfaceHost::slotNewItemSelected( QListViewItem* )" << endl; + if ( ! item ) + return ; + KMFListViewItem* kmfitem = dynamic_cast<KMFListViewItem*> ( item ); + if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETZONE ) { + m_host = 0; + m_zone = kmfitem->zone(); + m_sb_host_1->setEnabled(false); + m_sb_host_2->setEnabled(false); + m_sb_host_3->setEnabled(false); + m_sb_host_4->setEnabled(false); + m_host_desc->setReadOnly( true ); + c_log_in->setEnabled(false); + c_log_out->setEnabled(false); + c_log_in->setChecked( false ); + c_log_out->setChecked( false ); + m_host_desc->clear(); + } else if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETHOST ) { + m_host = kmfitem->host(); + m_zone = kmfitem->host()->zone(); + m_sb_host_1->setEnabled(true); + m_sb_host_2->setEnabled(true); + m_sb_host_3->setEnabled(true); + m_sb_host_4->setEnabled(true); + m_sb_host_1->blockSignals(true); + m_sb_host_2->blockSignals(true); + m_sb_host_3->blockSignals(true); + m_sb_host_4->blockSignals(true); + m_sb_host_1->setValue( m_host->address()->getDigit( 0 ) ); + m_sb_host_2->setValue( m_host->address()->getDigit( 1 ) ); + m_sb_host_3->setValue( m_host->address()->getDigit( 2 ) ); + m_sb_host_4->setValue( m_host->address()->getDigit( 3 ) ); + m_sb_host_1->blockSignals(false); + m_sb_host_2->blockSignals(false); + m_sb_host_3->blockSignals(false); + m_sb_host_4->blockSignals(false); + m_host_desc->setText( m_host->description() ); + m_host_desc->setReadOnly( false ); + c_log_in->setEnabled(true); + c_log_out->setEnabled(true); + c_log_in->setChecked( m_host->logIncoming() ); + c_log_out->setChecked( m_host->logOutgoing() ); + l_currHost->setText( i18n( "Host: %1").arg( m_host->guiName() ) ); + + } else { + kdDebug() << "KMFGenericInterfaceHost::slotNewItemSelected( QListViewItem* item ): WARNING unknown ListView Type!!!" << endl; + } + +} + +/*! + \fn KMFGenericInterfaceHost::slotRenameHost() + */ +void KMFGenericInterfaceHost::slotRenameHost() { + kdDebug() << "void KMFGenericInterfaceHost::slotRenameHost()" << endl; + if ( m_host ) { + KMFListViewItem* it = findKMFItem( m_host->guiName(), m_host->uuid() ); + if ( it ) { + it->setRenameEnabled( 0, true ); + it->startRename( 0 ); + } + } +} + +void KMFGenericInterfaceHost::slotHostRenamed( QListViewItem* item, int , const QString& text ) { + kdDebug() << "void KMFGenericInterfaceHost::slotHostRenamed( QListViewItem* item, int , const QString& text )" << endl; + + if ( ! item || text.isNull() ) + return ; + + QString newName = text.simplifyWhiteSpace(); + + KMFListViewItem* kmfitem = dynamic_cast<KMFListViewItem*> ( item ); + if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETHOST ) { + m_host = kmfitem->host(); + m_zone = kmfitem->host()->zone(); + if ( newName == m_host->guiName() ) { + return; + } + KMFUndoEngine::instance()->startTransaction( + m_host, + i18n( "Rename host: %1 to %2." ).arg( m_host->guiName() ).arg( newName ) + ); + m_host->setGuiName( newName ); + KMFUndoEngine::instance()->endTransaction(); + kdDebug() << "Setting GuiName: " << m_host->guiName() << "\ninternal Name: " << m_host->name() << endl; + slotUpdateView(); + } + +} +void KMFGenericInterfaceHost::slotAddressChanged( const QString& ) { + kdDebug() << "void KMFGenericInterfaceProtocol::slotAddressChanged( const QString& )" << endl; + if ( ! m_host ) + return; + + QString address = "[" + m_sb_host_1->text() + "." + + m_sb_host_2->text() + "." + + m_sb_host_3->text() + "." + + m_sb_host_4->text() + "]"; + + if ( address == m_host->address()->toString() ) { + return; + } + KMFUndoEngine::instance()->startTransaction( + m_host, + i18n( "Change address of host: %1." ).arg( m_host->guiName() ) + ); + m_host->address()->setAddress( m_sb_host_1->text() +"."+ + m_sb_host_2->text()+"."+ + m_sb_host_3->text()+"."+ + m_sb_host_4->text() ); + KMFUndoEngine::instance()->endTransaction(); + + KMFListViewItem *it = findKMFItem( m_host->guiName(), m_host->uuid() ); + if ( it ) { + it->setText( 1 , "[" + address +"]" ); + } +} + +void KMFGenericInterfaceHost::slotHostDescChanged() { + kdDebug() << "void KMFGenericInterfaceHost::slotHostDescChanged()" << endl; + if ( ! m_host ) { + return; + } + if ( m_host_desc->text().simplifyWhiteSpace() == m_host->description() ) { + return; + } + KMFUndoEngine::instance()->startTransaction( + m_host, + i18n( "Edit documentation of host: %1" ).arg( m_host->guiName() ) + ); + m_host->setDescription( m_host_desc->text().simplifyWhiteSpace() ); + KMFUndoEngine::instance()->endTransaction(); + +} + +void KMFGenericInterfaceHost::slotLoggingChanged( bool ) { + kdDebug() << "void KMFGenericInterfaceHost::slotLoggingChanged( bool )" << endl; + if ( ! m_host ) { + return; + } + if ( c_log_in->isChecked() != m_host->logIncoming() ) { + KMFUndoEngine::instance()->startTransaction( + m_host, + i18n( "Edit logging option of host: %1" ).arg( m_host->guiName() ) + ); + m_host->setLogIncoming( c_log_in->isChecked() ); + KMFUndoEngine::instance()->endTransaction(); + } + if ( m_host->logOutgoing() != c_log_out->isChecked() ) { + KMFUndoEngine::instance()->startTransaction( + m_host, + i18n( "Edit logging option of host: %1" ).arg( m_host->guiName() ) + ); + m_host->setLogOutgoing( c_log_out->isChecked() ); + KMFUndoEngine::instance()->endTransaction(); + } + +} + +/*! + \fn KMFGenericInterfaceHost::slotRBM( QListViewItem*, const QPoint&, int ) + */ +void KMFGenericInterfaceHost::slotZoneRBM( QListViewItem* item, const QPoint& point, int ){ + kdDebug() << "void KMFGenericInterfaceHost::slotRBM( QListViewItem*, const QPoint&, int )" << endl; + if ( ! item ) + return ; + KMFListViewItem* kmfitem = dynamic_cast<KMFListViewItem*> ( item ); + if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETZONE ) { + kdDebug() << "Setting up Zone RBM:" << endl; + m_host = 0; + m_zone = 0; + m_zone = kmfitem->zone(); + if ( m_zone ) { + m_contextMenu->clear(); + QString name = m_zone->name(); + QString lab_str = i18n("Special Host Type: %1").arg( m_zone->guiName() ); + m_contextMenu->insertTitle( icon_chain, lab_str ); + m_contextMenu->insertItem( icon_new, i18n( "New Host..." ), this, SLOT( slotNewHost() ) ); + m_contextMenu->popup( point ); + } + } else if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETHOST ) { + m_host = 0; + m_zone = 0; + m_host = kmfitem->host(); + m_zone = kmfitem->host()->zone(); + if ( m_host ) { + m_contextMenu->clear(); + QString name = m_zone->name(); + QString lab_str = i18n("Special Host: %1").arg( m_host->guiName() ); + m_contextMenu->insertTitle( icon_chain, lab_str ); + m_contextMenu->insertItem( icon_new, i18n( "New Host..." ), this, SLOT( slotNewHost() ) ); + m_contextMenu->insertItem( icon_rename, i18n( "Rename Host..." ), this, SLOT( slotRenameHost() ) ); + m_contextMenu->insertSeparator(); + m_contextMenu->insertItem( icon_del, i18n( "Delete Host" ), this, SLOT( slotDelHost() ) ); + + m_contextMenu->popup( point ); + + } + } +} + +KMFListViewItem* KMFGenericInterfaceHost::findKMFItem( const QString& text, const QUuid& obj_id ) { + if ( obj_id.isNull() ) + return 0; + QListViewItemIterator it( m_lv_zones ); + while ( it.current() ) { + QListViewItem * qitem = it.current(); + ++it; + KMFListViewItem * item = 0; + item = dynamic_cast<KMFListViewItem*> ( qitem ); + if ( item ) { + if ( item->text( 0 ) == text && item->uuid() == obj_id ) + return item; + } else { + kdDebug() << "CAST ERROR: Item not of type KMFListViewItem" << endl; + } + } +// kdDebug() << "Couldn't find Item " << text << " column: " << column << ", int obj_id: " << obj_id << endl; + return 0; +} +KMFListViewItem* KMFGenericInterfaceHost::findKMFItem( const QUuid& obj_id ) { + if ( obj_id.isNull() ) + return 0; + QListViewItemIterator it( m_lv_zones ); + while ( it.current() ) { + QListViewItem * qitem = it.current(); + ++it; + KMFListViewItem * item = 0; + item = dynamic_cast<KMFListViewItem*> ( qitem ); + if ( item ) { + if ( item->uuid() == obj_id ) + return item; + } else { + kdDebug() << "CAST ERROR: Item not of type KMFListViewItem" << endl; + } + } +// kdDebug() << "Couldn't find Item " << text << " column: " << column << ", int obj_id: " << obj_id << endl; + return 0; +} + +void KMFGenericInterfaceHost::loadIcons() { + kdDebug() << "void KMFGenericInterfa::loadIcons()" << endl; + KIconLoader *loader = KGlobal:: iconLoader(); + QString icon_name; + + icon_name = "up"; + icon_up = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "down"; + icon_down = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "editdelete"; + icon_del = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "filenew"; + icon_new = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "edit"; + icon_edit = loader->loadIcon( icon_name, KIcon::Small ); + + + icon_name = "filter"; + icon_filter = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "text"; + icon_rename = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "rule-22"; + icon_rule = loader->loadIcon( icon_name, KIcon::User ); + + icon_name = "view_tree"; + icon_chain = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "reject"; + icon_reject = loader->loadIcon( icon_name, KIcon::User ); + + icon_name = "target"; + icon_target = loader->loadIcon( icon_name, KIcon::User ); + + icon_name = "stop"; + icon_drop = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "button_ok"; + icon_accept = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "filesaveas"; + icon_log = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "undo"; + icon_return = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "editclear"; + icon_cmd = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "filter"; + icon_filter = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "pipe"; + icon_queue = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "editcopy"; + icon_copy = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "forward"; + icon_move = loader->loadIcon( icon_name, KIcon::Small ); + +} + +} + +#include "kmfgenericinterfacehost.moc" diff --git a/kmyfirewall/genericinterface/kmfgenericinterfacehost.h b/kmyfirewall/genericinterface/kmfgenericinterfacehost.h new file mode 100644 index 0000000..84f28cc --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfacehost.h @@ -0,0 +1,103 @@ +// +// +// C++ Interface: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef KMFGENERICINTERFACEHOST_H +#define KMFGENERICINTERFACEHOST_H + +#include "kmyfirewallgenericinterfacehostwidget.h" + +/** +@author Christian Hubinger +*/ + +// QT includes + +#include <qstring.h> +#include <qguardedptr.h> +#include <qpixmap.h> +#include <quuid.h> + +class QListViewItem; + +// KDE includes + +class KPopupMenu; + +namespace KMF { +// Project Includes +class KMFNetwork; +class KMFGenericDoc; +class KMFNetZone; +class KMFNetHost; +class KMFListViewItem; +class NetfilterObject; + +class KMFGenericInterfaceHost : public KMyFirewallGenericInterfaceHostWidget { + Q_OBJECT +public: + KMFGenericInterfaceHost( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + + ~KMFGenericInterfaceHost(); + +public: + void loadDoc( KMFNetwork* ); + +public slots: + void slotUpdateView(); + void slotUpdateView( NetfilterObject* ); + +private slots: + void slotZoneRBM( QListViewItem*, const QPoint&, int ); + void slotNewHost(); + void slotDelHost(); + void slotNewItemSelected( QListViewItem* ); + void slotRenameHost(); + void slotHostRenamed( QListViewItem*, int , const QString & ); + void slotAddressChanged( const QString& ); + void slotHostDescChanged(); + void slotLoggingChanged( bool ); + // void slotDisable(); + +private: + void loadIcons(); + KMFListViewItem* findKMFItem( const QString& text, const QUuid& obj_id ); + KMFListViewItem* findKMFItem( const QUuid& obj_id ); + + QGuardedPtr<KMFNetZone> m_zone; + QGuardedPtr<KMFNetHost> m_host; + QGuardedPtr<KMFNetwork> m_doc; + KPopupMenu* m_contextMenu; + + KMFListViewItem *itemTrustedHosts; + KMFListViewItem *itemMaliciousHosts; + KMFListViewItem *itemBadServers; + KMFListViewItem *itemBadClients; + + + + QPixmap icon_up, icon_down, icon_del, icon_edit, icon_rule, icon_filter, icon_rename, + icon_chain, icon_log, icon_accept, icon_drop, icon_cmd, icon_reject, icon_return, + icon_target, icon_queue, icon_new, icon_copy, icon_move; + +}; +} +#endif diff --git a/kmyfirewall/genericinterface/kmfgenericinterfaceicmp.cpp b/kmyfirewall/genericinterface/kmfgenericinterfaceicmp.cpp new file mode 100644 index 0000000..a867715 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfaceicmp.cpp @@ -0,0 +1,110 @@ +// +// +// C++ Implementation: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include "kmfgenericinterfaceicmp.h" + +// QT includes +#include <qstring.h> +#include <qcheckbox.h> + +// KDE includes +#include <klocale.h> +#include <kdebug.h> + +// Project includes +#include "../core/kmfnetwork.h" +#include "../core/kmfgenericdoc.h" + +namespace KMF { +KMFGenericInterfaceIcmp::KMFGenericInterfaceIcmp( QWidget *parent, const char *name, WFlags f ) + : KMyFirewallGenericInterfaceIcmp( parent, name, f ) { +connect( c_allow_ping, SIGNAL( toggled( bool ) ), + this, SLOT( slotEnablePingReplyToggled( bool ) ) ); +connect( c_limit_ping, SIGNAL( toggled( bool ) ), + this, SLOT( slotEnablePingReplyLimitToggled( bool ) ) ); +} + + +KMFGenericInterfaceIcmp::~KMFGenericInterfaceIcmp() {} + +void KMFGenericInterfaceIcmp::slotUpdateView( NetfilterObject* ) { + kdDebug() << "KMFGenericInterfaceIcmp::slotUpdateView( NetfilterObject* )" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + slotUpdateView(); +} + +void KMFGenericInterfaceIcmp::slotUpdateView() { + kdDebug() << "KMFGenericInterfaceIcmp::slotUpdateView()" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + c_allow_ping->setChecked( m_doc->currentDocAsGenericDoc()->allowPingReply() ); + c_limit_ping->setChecked( m_doc->currentDocAsGenericDoc()->limitPingReply() ); + +} +void KMFGenericInterfaceIcmp::loadDoc( KMFNetwork* doc ) { + kdDebug() << "void KMFGenericInterfaceIcmp::loadDoc( KMFGenericDoc* )" << endl; + m_doc = doc; + slotUpdateView(); +} + +void KMFGenericInterfaceIcmp::slotEnablePingReplyToggled( bool onoff ) { + kdDebug() << "KMFGenericInterfaceIcmp::slotEnablePingReplyToggled( bool onoff )" << endl; + if ( m_doc->currentDocAsGenericDoc()->allowPingReply() == onoff ) { + return; + } + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "%1 ping reply." ).arg( onoff ? i18n( "Allow" ) : i18n( "Supress" ) ) + ); + if ( onoff ) { + m_doc->currentDocAsGenericDoc()->setAllowPingReply( onoff ); + if ( c_limit_ping->isChecked() ) { + m_doc->currentDocAsGenericDoc()->setLimitPingReply( onoff ); + } + } else { + m_doc->currentDocAsGenericDoc()->setAllowPingReply( onoff ); + } + KMFUndoEngine::instance()->endTransaction(); +} + +void KMFGenericInterfaceIcmp::slotEnablePingReplyLimitToggled( bool onoff ) { + kdDebug() << "KMFGenericInterfaceIcmp::slotEnablePingReplyLimitToggled( bool onoff )" << endl; + if ( m_doc->currentDocAsGenericDoc()->limitPingReply() == onoff ) { + return; + } + + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "%1 limit ping reply." ).arg( onoff ? i18n( "Enable") : i18n( "Disable" ) ) + ); + m_doc->currentDocAsGenericDoc()->setLimitPingReply( onoff ); + KMFUndoEngine::instance()->endTransaction(); +} + +} + +#include "kmfgenericinterfaceicmp.moc" diff --git a/kmyfirewall/genericinterface/kmfgenericinterfaceicmp.h b/kmyfirewall/genericinterface/kmfgenericinterfaceicmp.h new file mode 100644 index 0000000..62841d3 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfaceicmp.h @@ -0,0 +1,60 @@ +// +// +// C++ Interface: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef KMFGENERICINTERFACEICMP_H +#define KMFGENERICINTERFACEICMP_H + +#include <kmyfirewallgenericinterfaceicmp.h> + +// QT Includes +#include <qguardedptr.h> + +/** +@author Christian Hubinger +*/ +namespace KMF { +class KMFGenericDoc; +class KMFNetwork; +class NetfilterObject; + +class KMFGenericInterfaceIcmp : public KMyFirewallGenericInterfaceIcmp { + Q_OBJECT +public: + KMFGenericInterfaceIcmp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + + ~KMFGenericInterfaceIcmp(); + +void loadDoc( KMFNetwork* doc ); + +public slots: + void slotUpdateView(); + void slotUpdateView( NetfilterObject* ); + +private slots: + void slotEnablePingReplyToggled( bool ); + void slotEnablePingReplyLimitToggled( bool ); + +private: + QGuardedPtr<KMFNetwork> m_doc; +}; +} +#endif diff --git a/kmyfirewall/genericinterface/kmfgenericinterfacelogging.cpp b/kmyfirewall/genericinterface/kmfgenericinterfacelogging.cpp new file mode 100644 index 0000000..9b065a9 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfacelogging.cpp @@ -0,0 +1,125 @@ +// +// +// C++ Implementation: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include "kmfgenericinterfacelogging.h" + +// QT includes +#include <qstring.h> +#include <qcheckbox.h> +#include <qtimer.h> + +// KDE includes +#include <klocale.h> +#include <kdebug.h> +#include <krestrictedline.h> + +// Project includes +#include "../core/kmfnetwork.h" +#include "../core/kmfgenericdoc.h" +namespace KMF { +KMFGenericInterfaceLogging::KMFGenericInterfaceLogging( QWidget *parent, const char *name, WFlags f ) + : KMyFirewallGenericInterfaceLogging( parent, name, f ) { + connect( m_c_log, SIGNAL( toggled( bool ) ), + this,SLOT( slotLoggingChanged( bool ) ) ); + + connect( m_c_limitLog, SIGNAL( toggled( bool ) ), + this,SLOT( slotLimitChanged( bool ) ) ); + + connect( m_le_logPrefix, SIGNAL( textChanged( const QString & ) ), + this,SLOT ( slotLogPrefixChanged( const QString & ) ) ); +} + + +KMFGenericInterfaceLogging::~KMFGenericInterfaceLogging() {} + +void KMFGenericInterfaceLogging::slotUpdateView( NetfilterObject* ) { + kdDebug() << "KMFGenericInterfaceLogging::slotUpdateView( NetfilterObject* )" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + slotUpdateView(); +} + +void KMFGenericInterfaceLogging::slotUpdateView() { + kdDebug() << "KMFGenericInterfaceLogging::slotUpdateView()" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + m_c_log->setChecked( m_doc->currentDocAsGenericDoc()-> logDropped() ); + m_c_limitLog->setChecked( m_doc->currentDocAsGenericDoc()->limitLog() ); + + if ( m_doc->currentDocAsGenericDoc()->logPrefix() != m_le_logPrefix->text().simplifyWhiteSpace() ) { + m_le_logPrefix->setText( m_doc->currentDocAsGenericDoc()->logPrefix() ); + } +} + +/*! + \fn KMFGenericInterfaceLogging::loadDoc( KMFGenricDoc* ) + */ +void KMFGenericInterfaceLogging::loadDoc( KMFNetwork* doc ) { + kdDebug() << "void KMFGenericInterfaceLogging::loadDoc( KMFGenericDoc* )" << endl; + m_doc = doc; + slotUpdateView(); +} + +void KMFGenericInterfaceLogging::slotLoggingChanged( bool onoff ) { + if ( m_doc->currentDocAsGenericDoc()->logDropped() == onoff ) { + return; + } + + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "%1 logging of dropped packets." ).arg( onoff ? i18n( "Enable" ) : i18n( "Disable" ) ) + ); + m_doc->currentDocAsGenericDoc()->setLogDropped( onoff ); + KMFUndoEngine::instance()->endTransaction(); +} + +void KMFGenericInterfaceLogging::slotLimitChanged( bool onoff ) { + if ( m_doc->currentDocAsGenericDoc()->limitLog() == onoff ) { + return; + } + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "%1 logging limit." ).arg( onoff ? i18n( "Enable" ) : i18n( "Disable" ) ) + ); + m_doc->currentDocAsGenericDoc()->setLimitLog( onoff ); + KMFUndoEngine::instance()->endTransaction(); +} + +void KMFGenericInterfaceLogging::slotLogPrefixChanged( const QString & ) { + if ( m_doc->currentDocAsGenericDoc()->logPrefix() == m_le_logPrefix->text().simplifyWhiteSpace() ) { + return; + } + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "Change logging prefix to %1." ).arg( m_le_logPrefix->text().simplifyWhiteSpace() ) + ); + m_doc->currentDocAsGenericDoc()->setLogPrefix( m_le_logPrefix->text().simplifyWhiteSpace() ); + KMFUndoEngine::instance()->endTransaction(); + +} + +} +#include "kmfgenericinterfacelogging.moc" diff --git a/kmyfirewall/genericinterface/kmfgenericinterfacelogging.h b/kmyfirewall/genericinterface/kmfgenericinterfacelogging.h new file mode 100644 index 0000000..8fa62d1 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfacelogging.h @@ -0,0 +1,67 @@ +// +// +// C++ Interface: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef KMFGENERICINTERFACELOGGING_H +#define KMFGENERICINTERFACELOGGING_H + +#include <kmyfirewallgenericinterfacelogging.h> + +/** +@author Christian Hubinger +*/ + +// QT includes +#include <qstring.h> +#include <qguardedptr.h> + +class QTimer; + +namespace KMF { +class KMFNetwork; +class KMFGenericDoc; +class NetfilterObject; + +class KMFGenericInterfaceLogging : public KMyFirewallGenericInterfaceLogging { + Q_OBJECT +public: + KMFGenericInterfaceLogging( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + + ~KMFGenericInterfaceLogging(); + + +public slots: + void slotUpdateView(); + void slotUpdateView( NetfilterObject* ); + +public: + void loadDoc( KMFNetwork* ); + +private slots: + void slotLoggingChanged( bool ); + void slotLimitChanged( bool ); + void slotLogPrefixChanged( const QString & ); + +private: + QGuardedPtr<KMFNetwork> m_doc; +}; +} +#endif diff --git a/kmyfirewall/genericinterface/kmfgenericinterfacenat.cpp b/kmyfirewall/genericinterface/kmfgenericinterfacenat.cpp new file mode 100644 index 0000000..7393d8f --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfacenat.cpp @@ -0,0 +1,200 @@ +// +// +// C++ Implementation: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include "kmfgenericinterfacenat.h" + + +// QT includes +#include <qstring.h> +#include <qstringlist.h> +#include <qcheckbox.h> +#include <qlistview.h> + +// KDE includes +#include <kdebug.h> +#include <klocale.h> +#include <kcombobox.h> +#include <knuminput.h> +#include <klistview.h> + +// Project includes +#include "../core/kmfnetwork.h" +#include "../core/kmftarget.h" +#include "../core/kmftargetconfig.h" +#include "../core/kmfgenericdoc.h" +#include "../core/kmfconfig.h" +namespace KMF { +KMFGenericInterfaceNat::KMFGenericInterfaceNat( QWidget *parent, const char *name, WFlags f ) + : KMyFirewallGenericInterfaceNATWidget( parent, name, f ) { + +connect( m_c_enable_nat, SIGNAL( toggled( bool ) ), + this, SLOT( slotNatEnabled( bool ) ) ); +connect( m_c_use_masquerade, SIGNAL( toggled( bool ) ), + this, SLOT( slotMasqueradeEnabled( bool ) ) ); + + +connect( m_sb_addr_1, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); +connect( m_sb_addr_2, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); +connect( m_sb_addr_3, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); +connect( m_sb_addr_4, SIGNAL( valueChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); + +connect( m_cb_external_interface, SIGNAL( activated( const QString& ) ), + this, SLOT( slotExternalInterfaceChanged( const QString& ) ) ); +} + + +KMFGenericInterfaceNat::~KMFGenericInterfaceNat() {} + +void KMFGenericInterfaceNat::slotUpdateView( NetfilterObject* ) { + kdDebug() << "KMFGenericInterfaceNat::slotUpdateView( NetfilterObject* )" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + slotUpdateView(); +} +void KMFGenericInterfaceNat::slotUpdateView() { + kdDebug() << "void KMFGenericInterfaceNat::slotUpdateView()" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + m_c_enable_nat->setChecked( m_doc->currentDocAsGenericDoc()->useNat() ); + m_c_use_masquerade->setChecked( m_doc->currentDocAsGenericDoc()->useMasquerade() ); +// m_c_restrict_nat->setChecked( m_doc->restrictNat() ); + m_sb_addr_1->blockSignals( true ); + m_sb_addr_2->blockSignals( true ); + m_sb_addr_3->blockSignals( true ); + m_sb_addr_4->blockSignals( true ); + m_sb_addr_1->setValue( m_doc->currentDocAsGenericDoc()->natAddress()->getDigit( 0 ) ); + m_sb_addr_2->setValue( m_doc->currentDocAsGenericDoc()->natAddress()->getDigit( 1 ) ); + m_sb_addr_3->setValue( m_doc->currentDocAsGenericDoc()->natAddress()->getDigit( 2 ) ); + m_sb_addr_4->setValue( m_doc->currentDocAsGenericDoc()->natAddress()->getDigit( 3 ) ); + kdDebug() << "Setting Address Fields to: " << m_doc->currentDocAsGenericDoc()->natAddress()->getDigit( 0 ) << "." << + m_doc->currentDocAsGenericDoc()->natAddress()->getDigit( 1 ) << "." << m_doc->currentDocAsGenericDoc()->natAddress()->getDigit( 2 ) << "." << + m_doc->currentDocAsGenericDoc()->natAddress()->getDigit( 3 ) << endl; + m_sb_addr_1->blockSignals( false ); + m_sb_addr_2->blockSignals( false ); + m_sb_addr_3->blockSignals( false ); + m_sb_addr_4->blockSignals( false ); + + QStringList interfaces = m_doc->currentTarget()->config()->interfaces(); + m_cb_external_interface->clear(); + m_cb_external_interface->insertStringList( interfaces ); + + QString interf = m_doc->currentDocAsGenericDoc()->outgoingInterface(); + + interf = m_doc->currentDocAsGenericDoc()->outgoingInterface(); + bool found = false; + int i = 0; + for ( QStringList::Iterator it = interfaces.begin(); it != interfaces.end() && ! found; ++it ) { + if ( *it == interf ) { + m_cb_external_interface->setCurrentItem( i ); + } + i++; + } + +} + +/*! + \fn KMFGenericInterfaceNat::loadDoc( KMFGenericDoc* ) + */ +void KMFGenericInterfaceNat::loadDoc( KMFNetwork* doc ) { + kdDebug() << "void KMFGenericInterfaceNat::loadDoc( KMFGenericDoc* )" << endl; + m_doc = doc; + slotUpdateView(); +} + + +/*! + \fn KMFGenericInterfaceNat::slotNatEnabled( bool ) + */ +void KMFGenericInterfaceNat::slotNatEnabled( bool onoff ) { + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "%1 NAT." ).arg( onoff ? i18n( "Enable" ) : i18n( "Disable" ) ) + ); + + m_doc->currentDocAsGenericDoc()->setUseNat( onoff ); + m_doc->currentDocAsGenericDoc()->setOutgoingInterface( m_cb_external_interface->currentText () ); + KMFUndoEngine::instance()->endTransaction(); +} + +/*! + \fn KMFGenericInterfaceNat::slotMasqueradeEnabled( bool ) + */ +void KMFGenericInterfaceNat::slotMasqueradeEnabled( bool onoff ) { + if ( m_doc->currentDocAsGenericDoc()->useMasquerade() == onoff ) { + return; + } + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "%1 MASQUERADE target for NAT." ).arg( onoff ? i18n( "Enable" ) : i18n( "Disable" ) ) + ); + m_doc->currentDocAsGenericDoc()->setUseMasquerade( onoff ); + KMFUndoEngine::instance()->endTransaction(); +} + + +/*! + \fn KMFGenericInterfaceNat::slotAddressChanged( const QString& ) + */ +void KMFGenericInterfaceNat::slotAddressChanged( const QString& ) { + QString address = "" + m_sb_addr_1->text() + "." + m_sb_addr_2->text() + "." + m_sb_addr_3->text() + "." + m_sb_addr_4->text(); + if ( address == m_doc->currentDocAsGenericDoc()->natAddress()->toString() ) { + return; + } + + kdDebug() << "Updating NAT external address to: " << address << endl; + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "Set NAT adddress to %1." ).arg( address ) + ); + m_doc->currentDocAsGenericDoc()->natAddress()->setAddress( m_sb_addr_1->value(), + m_sb_addr_2->value(), + m_sb_addr_3->value(), + m_sb_addr_4->value() ); + KMFUndoEngine::instance()->endTransaction(); +} +/*! + \fn KMFGenericInterfaceNat::slotOutgoingInterfaceChanged( const QString& ) + */ +void KMFGenericInterfaceNat::slotExternalInterfaceChanged( const QString& str ) { + if ( m_doc->currentDocAsGenericDoc()->outgoingInterface() == str ) { + return; + } + + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc(), + i18n( "Change NAT outgoing interface to %1." ).arg( str ) + ); + m_doc->currentDocAsGenericDoc()->setOutgoingInterface( str ); + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); +} + +} +#include "kmfgenericinterfacenat.moc" diff --git a/kmyfirewall/genericinterface/kmfgenericinterfacenat.h b/kmyfirewall/genericinterface/kmfgenericinterfacenat.h new file mode 100644 index 0000000..efd1a6e --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfacenat.h @@ -0,0 +1,66 @@ +// +// +// C++ Interface: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef KMFGENERICINTERFACENAT_H +#define KMFGENERICINTERFACENAT_H + +#include <kmyfirewallgenericinterfacenatwidget.h> + +// QT Includes +#include <qguardedptr.h> + +/** +@author Christian Hubinger +*/ + +namespace KMF { +class KMFNetwork; +class KMFGenericDoc; +class NetfilterObject; + +class KMFGenericInterfaceNat : public KMyFirewallGenericInterfaceNATWidget { + Q_OBJECT +public: + KMFGenericInterfaceNat( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + + ~KMFGenericInterfaceNat(); +signals: + + +public slots: + void slotUpdateView(); + void slotUpdateView( NetfilterObject* ); + +public: + void loadDoc( KMFNetwork* ); + + +private: + QGuardedPtr<KMFNetwork> m_doc; + + private slots: void slotAddressChanged( const QString& ); + private slots: void slotMasqueradeEnabled( bool ); + private slots: void slotNatEnabled( bool ); + private slots: void slotExternalInterfaceChanged( const QString& ); +}; +} +#endif diff --git a/kmyfirewall/genericinterface/kmfgenericinterfacepartui.rc b/kmyfirewall/genericinterface/kmfgenericinterfacepartui.rc new file mode 100644 index 0000000..14db18f --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfacepartui.rc @@ -0,0 +1,16 @@ +<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> +<kpartgui name="kmfgenericinterfacepart" version="1"> + <MenuBar> + <Menu name="go"><text>&Go</text> + <Action name="my_network"/> + <Action name="access_control"/> + <Action name="special_hosts"/> + <Action name="icmp_options"/> + <Action name="nat_configuration"/> + <Action name="logging_options"/> + </Menu> +</MenuBar> +</kpartgui> + +<!-- libraryname="libkmfgenericinterfacepart" --> + diff --git a/kmyfirewall/genericinterface/kmfgenericinterfaceprotocol.cpp b/kmyfirewall/genericinterface/kmfgenericinterfaceprotocol.cpp new file mode 100644 index 0000000..ea688ed --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfaceprotocol.cpp @@ -0,0 +1,681 @@ +// +// +// C++ Implementation: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#include "kmfgenericinterfaceprotocol.h" + +// QT includes +#include <qlistview.h> +#include <qcheckbox.h> +#include <qspinbox.h> +#include <qcombobox.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qgroupbox.h> +#include <qwidgetstack.h> +#include <qtextedit.h> +#include <qtimer.h> + + +// KDE includes +#include <kdebug.h> +#include <klocale.h> +#include <klistview.h> +#include <kcombobox.h> +#include <kpopupmenu.h> +#include <kiconloader.h> +#include <kinputdialog.h> +#include <knuminput.h> + +// Project includes +#include "../core/kmfnetwork.h" +#include "../core/kmfgenericdoc.h" +#include "../core/kmfprotocol.h" +#include "../core/kmfprotocolusage.h" +#include "../core/kmfnetzone.h" +#include "../core/kmfnethost.h" +#include "../core/kmferror.h" + +#include "../kmfwidgets/kmflistviewitem.h" +#include "../kmfwidgets/kmfchecklistitem.h" +#include "../kmfwidgets/kmfnetworkwidget.h" +#include "../kmfwidgets/kmfnethostpropertieswidget.h" +#include "../kmfwidgets/kmfprotocolpropertieswidget.h" +#include "../kmfwidgets/kmfprotocollistview.h" + +namespace KMF { +KMFGenericInterfaceProtocol::KMFGenericInterfaceProtocol( QWidget *parent, const char *name, WFlags f ) : KMyFirewallGenericInterfaceProtocolWidget( parent, name, f ) { + loadIcons(); + m_contextMenu = new KPopupMenu( this, "m_contextMenu" ); +// m_lv_protocols->setFullWidth( true ); + + // Network Widget + m_network_widget = new KMFNetworkWidget( m_widgetStack, "m_network_widget" ); + m_widgetStack->addWidget( m_network_widget ); + connect( m_network_widget,SIGNAL( sigZoneChanged( KMFNetZone* ) ), + this,SLOT( slotZoneChanged( KMFNetZone* ) ) ); + + // Host widget + m_nethostProperties_widget = new KMFNetHostPropertiesWidget( m_widgetStack, "m_nethostProperties_widget" ); + m_widgetStack->addWidget( m_nethostProperties_widget ); + + connect( m_nethostProperties_widget, SIGNAL( sigHostAddressChanged( const QString& ) ), + this, SLOT( slotAddressChanged( const QString& ) ) ); + + // Protocol Widget + m_protocolProperties_widget = new KMFProtocolPropertiesWidget( m_widgetStack, "m_protocolProperties_widget" ); + m_widgetStack->addWidget( m_protocolProperties_widget ); + + + // Protociol List View + m_protocolLIstView = new KMFProtocolListView( m_protocolsFrame, "m_protocolLIstView" ); + + QGridLayout *grid = new QGridLayout( m_protocolsFrame, 1, 1 ); + grid->addWidget( m_protocolLIstView, 0, 0 ); + + connect( m_protocolLIstView,SIGNAL( sigProtocolClicked( KMFProtocolUsage*, bool ) ), + this, SLOT( slotProtocolClicked( KMFProtocolUsage*, bool ) ) ); + + connect( m_protocolLIstView,SIGNAL( sigProtocolCategoryClicked( KMFProtocolCategory* ) ), + this, SLOT ( slotProtocolCategoryClicked( KMFProtocolCategory* ) ) ); + + // Zone view + connect( m_lv_zones, SIGNAL( pressed( QListViewItem* ) ) , + this, SLOT( slotNewItemSelected( QListViewItem* ) ) ); + + connect( m_lv_zones, SIGNAL( contextMenuRequested ( QListViewItem*, const QPoint&, int ) ), + this, SLOT( slotZoneRBM( QListViewItem*, const QPoint&, int ) ) ); + + connect( m_lv_zones, SIGNAL( itemRenamed ( QListViewItem *, int, const QString & ) ) , + this, SLOT( slotRenameItem( QListViewItem *, int, const QString & ) ) ); + + // Main win + connect( m_c_restrictOutgoing, SIGNAL( clicked() ), + this, SLOT( slotRestrictionChanged() ) ); + + connect( m_c_allowIncoming, SIGNAL( clicked() ), + this, SLOT( slotRestrictionChanged() ) ); + + connect( m_zoneSelect, SIGNAL( activated( const QString& ) ), + this, SLOT( slotCurrentZoneChanged( const QString& ) ) ); + + m_zone = 0; + m_type = -1; + m_protocolUsage = 0; +} + + +KMFGenericInterfaceProtocol::~KMFGenericInterfaceProtocol() {} + +void KMFGenericInterfaceProtocol::loadDoc( KMFNetwork *net ) { + kdDebug() << "void KMFGenericInterfaceProtocol::loadDoc( KMFGenericDoc* doc )" << endl; + m_doc = net; + m_doc->currentDocAsGenericDoc()->incomingZone(); + m_zoneSelect->clear(); + m_zoneSelect->insertItem( i18n("Incoming Zone") ); + m_zoneSelect->insertItem( i18n("Outgoing Zone") ); + slotUpdateView(); +} + +void KMFGenericInterfaceProtocol::slotUpdateView( NetfilterObject* ) { + kdDebug() << "KMFGenericInterfaceProtocol::slotUpdateView( NetfilterObject* )" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + slotUpdateView(); +} + +void KMFGenericInterfaceProtocol::slotUpdateView() { + kdDebug() << "void KMFGenericInterfaceProtocol::slotUpdateView()" << endl; + if ( ! m_doc ) { + kdDebug() << "WRINING: m_doc == 0" << endl; + return; + } + m_lv_zones->clear(); + m_protocolLIstView->loadProtocols(); + m_protocolLIstView->setEnabled( false ); + + m_c_allowIncoming->blockSignals( true ); + m_c_restrictOutgoing->blockSignals( true ); + m_c_allowIncoming->setChecked( m_doc->currentDocAsGenericDoc()->allowIncomingConnections() ); + m_c_restrictOutgoing->setChecked( m_doc->currentDocAsGenericDoc()->restrictOutgoingConnections() ); + m_c_allowIncoming->blockSignals( false ); + m_c_restrictOutgoing->blockSignals( false ); + + QString zone = m_zoneSelect->currentText(); + if ( zone == i18n("Incoming Zone") ) { + kdDebug() << "Showing Incoming Zone" << endl; + KMFListViewItem *item = new KMFListViewItem( m_lv_zones, 0, m_doc->currentDocAsGenericDoc()->incomingZone() ); + item->setupZoneView(); + } else if ( zone == i18n("Outgoing Zone") ) { + kdDebug() << "Showing Outgoing Zone" << endl; + KMFListViewItem *item2 = new KMFListViewItem( m_lv_zones, 0, m_doc->currentDocAsGenericDoc()->outgoingZone() ); + item2->setupZoneView(); + } + + if ( ! m_doc->currentDocAsGenericDoc()->allowIncomingConnections() && ! m_doc->currentDocAsGenericDoc()->restrictOutgoingConnections() ) { + m_lv_zones->setEnabled( false ); + m_protocolLIstView->setEnabled( false ); + m_widgetStack->setEnabled( false ); + return; + } + + m_lv_zones->setEnabled( true ); + // m_protocolLIstView->setEnabled( true ); + m_widgetStack->setEnabled( true ); + + if ( m_host ) { + if ( KMFListViewItem *item = findItem( m_host->uuid() ) ) { + m_lv_zones->setSelected( item, true ); + } + } else if ( m_zone ) { + if ( KMFListViewItem *item = findItem( m_zone->uuid() ) ) { + m_lv_zones->setSelected( item, true ); + } + } + m_lv_zones->setSorting( 0 , false ); +} + +void KMFGenericInterfaceProtocol::slotRestrictionChanged() { + m_doc->currentDocAsGenericDoc()->setRestrictOutgoingConnections( m_c_restrictOutgoing->isChecked() ); + m_doc->currentDocAsGenericDoc()->setAllowIncomingConnections( m_c_allowIncoming->isChecked() ); + slotUpdateView(); +} + +void KMFGenericInterfaceProtocol::slotCurrentZoneChanged( const QString& ) { + slotUpdateView(); +} + +void KMFGenericInterfaceProtocol::slotNewItemSelected( QListViewItem* item ) { + kdDebug() << "void KMFGenericInterfaceProtocol::slotNewItemSelected( QListViewItem* item )" << endl; + if ( ! item ) { + m_protocolLIstView->setEnabled( false ); + return ; + } + m_protocolUsage = 0; + m_zone = 0; + m_host = 0; + + KMFListViewItem* kmfitem = dynamic_cast<KMFListViewItem*> ( item ); + if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETZONE ) { + kdDebug() << "Selected NETZONE" << endl; + m_widgetStack->raiseWidget( m_network_widget ); + m_zone = kmfitem->zone(); + if ( m_zone ) { + kdDebug() << "kmfitem->zone() pointer is valid" << endl; + kmfitem->setText( 0,m_zone->guiName() ); + kmfitem->setText( 1, "[" + m_zone->address()->toString() + i18n("/%1]").arg( m_zone->maskLength() ) ); + m_protocolLIstView->setZone( m_zone ); + m_protocolLIstView->setEnabled( true ); + m_network_widget->loadZone( m_zone ); + + if ( m_zone->name() == "incoming_world" || m_zone->name() == "outgoing_world" || m_zone->readOnly() ) { + m_network_widget->allowEdit( false ); + } else { + m_network_widget->allowEdit( true ); + } + + } + } else if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETHOST ) { + kdDebug() << "Selected NETHOST" << endl; + m_widgetStack->raiseWidget( m_nethostProperties_widget ); + m_host = kmfitem->host(); + m_zone = m_host->zone(); + if ( m_host ) { + kdDebug() << "kmfitem->host() pointer is valid" << endl; + m_nethostProperties_widget->loadHost( m_host ); + m_protocolLIstView->setEnabled( true ); + m_protocolLIstView->setHost( m_host ); + } + } else { + m_protocolLIstView->setEnabled( false ); + } + kdDebug() << "Laving slotNewItemSelected()" << endl; +} + +void KMFGenericInterfaceProtocol::slotZoneRBM( QListViewItem* item, const QPoint& point, int ) { + if ( ! item ) + return ; + KMFListViewItem* kmfitem = dynamic_cast<KMFListViewItem*> ( item ); + if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETZONE ) { + kdDebug() << "Setting up Zone RBM:" << endl; + m_host = 0; + m_zone = 0; + m_zone = kmfitem->zone(); + if ( m_zone ) { + m_contextMenu->clear(); + QString name = m_zone->name(); + QString lab_str = i18n("Zone: %1").arg( m_zone->guiName() ); + m_contextMenu->insertTitle( icon_chain, lab_str ); + m_contextMenu->insertItem( icon_new, i18n( "Add Host..." ), this, SLOT( slotAddHost() ) ); + + + m_contextMenu->insertSeparator(); + m_contextMenu->insertItem( icon_new, i18n( "Add Zone..." ), this, SLOT( slotAddZone() ) ); + if ( m_zone->name() != "incoming_world" && m_zone->name() != "outgoing_world" ) { + m_contextMenu->insertItem( icon_rename, i18n( "Rename Zone..." ), this, SLOT( slotRenameZone() ) ); + m_contextMenu->insertSeparator(); + m_contextMenu->insertItem( icon_del, i18n( "Delete Zone" ), this, SLOT( slotDelZone() ) ); + } + + m_contextMenu->popup( point ); + } + } else if ( kmfitem != 0 && kmfitem->type() == NetfilterObject::NETHOST ) { + kdDebug() << "Setting up Host RBM:" << endl; + m_host = 0; + m_host = kmfitem->host(); + if ( m_host ) { + m_contextMenu->clear(); + QString name = m_host->name(); + QString lab_str = i18n("Host: %1").arg( m_host->guiName() ); + m_contextMenu->insertTitle( icon_chain, lab_str ); + m_contextMenu->insertItem( icon_rename, i18n( "Rename Host..." ), this, SLOT( slotRenameHost() ) ); + m_contextMenu->insertItem( icon_rename, i18n( "Delete Host..." ), this, SLOT( slotDelHost() ) ); + m_contextMenu->popup( point ); + } + } +} + +void KMFGenericInterfaceProtocol::slotProtocolClicked( KMFProtocolUsage* protUsage, bool onOff ) { + kdDebug() << " KMFGenericInterfaceProtocol::slotProtocolClicked( KMFProtocolUsage* protUsage, bool onOff )" << endl; + if ( ! protUsage || ! m_zone ) { + kdDebug() << "WARNING: no protUsage selected" << endl; + return ; + } + m_widgetStack->raiseWidget( m_protocolProperties_widget ); + if ( m_zone && ! m_host ) { + if ( onOff ) { + m_protocolUsage = 0; + if ( KMFProtocolUsage* pro = m_zone->findProtocolUsageByProtocolUuid( protUsage->protocol()->uuid() ) ) { + m_protocolUsage = pro; + } else { + KMFUndoEngine::instance()->startTransaction( + m_zone, + i18n("Add protocol %1 to zone %2.").arg( protUsage->protocol()->name() ).arg( m_zone->guiName() ) + ); + KMFProtocolUsage * pro = m_zone->addProtocolUsage( protUsage->protocol()->uuid(), protUsage->protocol()->getDOMTree() ); + + if ( pro ) { + kdDebug() << "Added Protocol to zone: " << m_zone-> name() << endl; + m_protocolUsage = pro; + KMFUndoEngine::instance()->endTransaction(); + } else { + KMFUndoEngine::instance()->abortTransaction(); + } + } + + if ( m_protocolUsage ) { + m_protocolProperties_widget->loadProtocolUsage( m_protocolUsage ); + } + } else { + m_protocolProperties_widget->loadProtocol( protUsage->protocol() ); + if ( m_zone->findProtocolUsageByProtocolUuid( protUsage->protocol()->uuid() ) ) { + KMFUndoEngine::instance()->startTransaction( + m_zone, + i18n("Delete protocol %1 from zone %2.").arg( protUsage->protocol()->name() ).arg( m_zone->guiName() ) + ); + m_zone->delProtocolUsage( protUsage ); + KMFUndoEngine::instance()->endTransaction(); + } + } + + } else if ( m_host ) { + if ( onOff ) { + m_protocolUsage = 0; + + if ( KMFProtocolUsage* pro = m_host->findProtocolUsageByProtocolUuid( protUsage->protocol()->uuid() ) ) { + m_protocolUsage = pro; + } else { + KMFUndoEngine::instance()->startTransaction( + m_host, + i18n("Add protocol %1 to host %2.").arg( protUsage->protocol()->name() ).arg( m_host->guiName() ) + ); + KMFProtocolUsage * pro = m_host->addProtocolUsage( protUsage->protocol()->uuid(), protUsage->protocol() ->getDOMTree() ); + + if ( pro ) { + kdDebug() << "Added Protocol to host: " << m_host-> name() << endl; + m_protocolUsage = pro; + KMFUndoEngine::instance()->endTransaction(); + } else { + KMFUndoEngine::instance()->abortTransaction(); + } + } + if ( m_protocolUsage ) { + m_protocolProperties_widget->loadProtocolUsage( m_protocolUsage ); + } + } else { + m_protocolProperties_widget->loadProtocol( protUsage->protocol() ); + if ( m_host->findProtocolUsageByProtocolUuid( protUsage->protocol()->uuid() ) ) { + KMFUndoEngine::instance()->startTransaction( + m_host, + i18n("Delete protocol %1 from host %2.").arg( protUsage->protocol()->name() ).arg( m_host->guiName() ) + ); + m_host->delProtocolUsage( protUsage ); + KMFUndoEngine::instance()->endTransaction(); + } + } + } +} + +void KMFGenericInterfaceProtocol::slotProtocolCategoryClicked( KMFProtocolCategory* protCat ) { + kdDebug() << " KMFGenericInterfaceProtocol::slotProtocolCategoryClicked( KMFProtocolUsage* protUsage, bool onOff )" << endl; + if ( ! protCat ) { + return; + } + + m_widgetStack->raiseWidget( m_protocolProperties_widget ); + m_protocolProperties_widget->loadProtocolCategory( protCat ); +} + + + + +void KMFGenericInterfaceProtocol::slotAddZone() { + kdDebug() << "void KMFGenericInterfaceProtocol::slotAddZone()" << endl; + bool ok; + QString name = KInputDialog::getText(i18n("New Zone"), i18n("Zone Name"),i18n("NewZone"), &ok, this ); + if ( !ok ) + return; + + + if ( m_zoneSelect->currentText() == i18n("Incoming Zone") ) { + QString s = ""; + s = s.setNum( m_doc->currentDocAsGenericDoc()->incomingZone()->zones().count() ); + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc()->incomingZone(), + i18n("Add Zone %1 to Incoming Zone").arg( name ) + ); + KMFNetZone * zone = m_doc->currentDocAsGenericDoc()->incomingZone()->addZone( "" + m_doc->currentDocAsGenericDoc()->incomingZone()->name() + "_z_" + s, new KMFError() ); + if ( zone ) { + zone->setGuiName( name ); + m_doc->currentDocAsGenericDoc()->incomingZone()->refreshNetworkTree(); + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); + } else { + KMFUndoEngine::instance()->abortTransaction(); + } + + } else if ( m_zoneSelect->currentText() == i18n("Outgoing Zone") ) { + QString s = ""; + s = s.setNum( m_doc->currentDocAsGenericDoc()->outgoingZone()->zones().count() ); + KMFUndoEngine::instance()->startTransaction( + m_doc->currentDocAsGenericDoc()->outgoingZone(), + i18n("Add Zone %1 to Outgoing Zone.").arg( name ) + ); + + KMFNetZone * zone = m_doc->currentDocAsGenericDoc()->outgoingZone()->addZone( "" + m_doc->currentDocAsGenericDoc()->outgoingZone()->name() + "_z_" + s, new KMFError() ); + if ( zone ) { + zone->setGuiName( name ); + m_doc->currentDocAsGenericDoc()->outgoingZone()->refreshNetworkTree(); + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); + } else { + KMFUndoEngine::instance()->abortTransaction(); + } + } + + +} + +void KMFGenericInterfaceProtocol::slotDelZone() { + kdDebug() << "void KMFGenericInterfaceProtocol::slotDelZone()" << endl; + if ( ! m_zone ) + return; + if ( m_zone->name() != "incoming_world" || m_zone->name() != "outgoing_world" ) { + KMFUndoEngine::instance()->startTransaction( + m_zone->zone(), + i18n("Delete zone %1 from zone %2.").arg( m_zone->guiName() ).arg( m_zone->zone()->guiName() ) + ); + m_zone->zone()->delZone( m_zone ); + m_zone = 0; + m_doc->currentDocAsGenericDoc()->incomingZone()->refreshNetworkTree(); + m_doc->currentDocAsGenericDoc()->outgoingZone()->refreshNetworkTree(); + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); + } +} + +void KMFGenericInterfaceProtocol::slotAddHost() { + kdDebug() << "void KMFGenericInterfaceProtocol::slotAddHost()" << endl; + bool ok; + QString name = KInputDialog::getText( i18n("New Host"), i18n("Host Name"),i18n("New Host"), &ok, this ); + if ( !ok ) + return; + + if ( m_zone ) { + QString s = ""; + s = s.setNum( m_zone->hosts().count() ); + KMFUndoEngine::instance()->startTransaction( + m_zone, + i18n("Add Host %1 to Zone: %2").arg( name ).arg( m_zone->guiName() ) + ); + KMFNetHost * host = m_zone->addNetHost( "" + m_zone->name() + "_h_" + s, * (new QDomDocument() ) ); + if ( host ) { + host->setGuiName( name ); + KMFUndoEngine::instance()->endTransaction(); m_doc->currentDocAsGenericDoc()->incomingZone()->refreshNetworkTree(); + m_doc->currentDocAsGenericDoc()->outgoingZone()->refreshNetworkTree(); + slotUpdateView(); + } else { + KMFUndoEngine::instance()->abortTransaction(); + } + } +} + +void KMFGenericInterfaceProtocol::slotDelHost() { + kdDebug() << "void KMFGenericInterfaceProtocol::slotDelHost()" << endl; + if ( ! m_zone || ! m_host ) + return; + KMFUndoEngine::instance()->startTransaction( + m_zone, + i18n("Delete host %1 from zone: %2").arg( m_host->guiName() ).arg( m_zone->guiName() ) + ); + m_zone->delHost( m_host ); + m_host = 0; + m_doc->currentDocAsGenericDoc()->incomingZone()->refreshNetworkTree(); + m_doc->currentDocAsGenericDoc()->outgoingZone()->refreshNetworkTree(); + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); +} + +KMFListViewItem* KMFGenericInterfaceProtocol::findItem( const QUuid& obj_id ) { + kdDebug() << "KMFListViewItem* KMFGenericInterfaceProtocol::findItem( int obj_id )" << endl; + QListViewItem* root = m_lv_zones->firstChild(); + if ( ! root ) + return 0; + QListViewItem* item = root->firstChild(); + while ( item ) { +// item->setText( 0, item->text(0) +"_searched" ); + if ( KMFListViewItem* kmfitem = dynamic_cast<KMFListViewItem*> ( item ) ) { + kdDebug() << "kmfitem->uuid(): " << kmfitem->uuid() << + " obj_id: " << obj_id << endl; + + if ( kmfitem->uuid() == obj_id ) { + kdDebug() << "MATCHED" << endl; + return kmfitem; + } + } + item = item->itemBelow(); + } + return 0; +} + +// void KMFGenericInterfaceProtocol::slotAddressChanged( int, int, int, int ) { +// +// +// +// } + +void KMFGenericInterfaceProtocol::slotAddressChanged( const QString& ) { + kdDebug() << "void KMFGenericInterfaceProtocol::slotAddressChanged( const QString& )" << endl; + if ( ! m_host ) { + return; + } + slotUpdateView(); + if ( KMFListViewItem *item = findItem( m_host->uuid() ) ) { + item->setText( 1, "[" + m_host->address()->toString() + "]" ); + } +} + +void KMFGenericInterfaceProtocol::slotZoneChanged( KMFNetZone* z ) { + kdDebug() << "void KMFGenericInterfaceProtocol::slotZoneChanged( KMFNetZone* z )" << endl; + if ( KMFListViewItem *item = findItem( z->uuid() ) ) { + kdDebug() << "Updating item" << endl; + item->setText( 1, "[" + z->address()->toString() + i18n("/%1]").arg( z->maskLength() ) ); + } + m_doc->currentDocAsGenericDoc()->incomingZone()->refreshNetworkTree(); + m_doc->currentDocAsGenericDoc()->outgoingZone()->refreshNetworkTree(); + slotUpdateView(); + +} + + +void KMFGenericInterfaceProtocol::slotRenameZone() { + kdDebug() << "void KMFGenericInterfaceProtocol::slotRenameZone()" << endl; + if ( ! m_zone ) + return; + if ( KMFListViewItem* item = findItem( m_zone->uuid() ) ) { + item->setRenameEnabled( 0 ,true ); + item->startRename(0); + } +} + +void KMFGenericInterfaceProtocol::slotRenameHost() { + kdDebug() << "void KMFGenericInterfaceProtocol::slotRenameHost()" << endl; + if ( ! m_host ) + return; + if ( KMFListViewItem* item = findItem( m_host->uuid() ) ) { + item->setRenameEnabled( 0 ,true ); + item->startRename(0); + } +} + +void KMFGenericInterfaceProtocol::slotRenameItem( QListViewItem* item, int, const QString& name ) { + kdDebug() << "void KMFGenericInterfaceProtocol::slotRenameItem( QListViewItem* item, int, const QString& name )" << endl; + if ( ! item ) + return; + + if ( name.isEmpty() ) { + slotUpdateView(); + return; + } + + if ( KMFListViewItem *kmfitem = dynamic_cast<KMFListViewItem*> (item) ) { + if ( kmfitem->type() == NetfilterObject::NETZONE ) { + KMFUndoEngine::instance()->startTransaction( + kmfitem->zone(), + i18n("Rename zone %1 to %2.").arg( kmfitem->zone()->guiName() ).arg( name ) + ); + + kmfitem->zone()->setGuiName( name ); + kdDebug() << "Renaming Zone: " << kmfitem->zone()->name() << endl; + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); + return; + } + } + + if ( KMFListViewItem *kmfitem = dynamic_cast<KMFListViewItem*> (item) ) { + if ( kmfitem->type() == NetfilterObject::NETHOST ) { + KMFUndoEngine::instance()->startTransaction( + kmfitem->host(), + i18n("Rename host %1 to %2.").arg( kmfitem->host()->guiName() ).arg( name ) + ); + kmfitem->host()->setGuiName( name ); + kdDebug() << "Renaming Host: " << kmfitem->host()->name() << endl; + KMFUndoEngine::instance()->endTransaction(); + slotUpdateView(); + return; + } + } + +} + +void KMFGenericInterfaceProtocol::loadIcons() { + kdDebug() << "void KMFGenericInterfa::loadIcons()" << endl; + KIconLoader *loader = KGlobal:: iconLoader(); + QString icon_name; + + icon_name = "up"; + icon_up = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "down"; + icon_down = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "editdelete"; + icon_del = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "filenew"; + icon_new = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "edit"; + icon_edit = loader->loadIcon( icon_name, KIcon::Small ); + + + icon_name = "filter"; + icon_filter = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "text"; + icon_rename = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "rule-22"; + icon_rule = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "view_tree"; + icon_chain = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "reject"; + icon_reject = loader->loadIcon( icon_name, KIcon::User ); + + icon_name = "target"; + icon_target = loader->loadIcon( icon_name, KIcon::User ); + + icon_name = "stop"; + icon_drop = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "button_ok"; + icon_accept = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "filesaveas"; + icon_log = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "undo"; + icon_return = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "editclear"; + icon_cmd = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "filter"; + icon_filter = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "pipe"; + icon_queue = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "editcopy"; + icon_copy = loader->loadIcon( icon_name, KIcon::Small ); + + icon_name = "forward"; + icon_move = loader->loadIcon( icon_name, KIcon::Small ); + +} + +} +#include "kmfgenericinterfaceprotocol.moc" diff --git a/kmyfirewall/genericinterface/kmfgenericinterfaceprotocol.h b/kmyfirewall/genericinterface/kmfgenericinterfaceprotocol.h new file mode 100644 index 0000000..9f4d277 --- /dev/null +++ b/kmyfirewall/genericinterface/kmfgenericinterfaceprotocol.h @@ -0,0 +1,121 @@ +// +// +// C++ Interface: $MODULE$ +// +// Description: +// +// +// Author: Christian Hubinger <chubinger@irrsinnig.org>, (C) 2003 +// +// Copyright: See COPYING file that comes with this distribution +// +// +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + + +#ifndef KMFGENERICINTERFACEPROTOCOL_H +#define KMFGENERICINTERFACEPROTOCOL_H + +#include <kmyfirewallgenericinterfaceprotocolwidget.h> + +// QT includes +class QListViewItem; + + +#include <qptrlist.h> +#include <qstring.h> +#include <qguardedptr.h> +#include <qpixmap.h> +#include <quuid.h> + +// KDE includes +class KPopupMenu; + +// Project includes +#include "../core/kmfprotocol.h" +#include "../core/kmfprotocolusage.h" +#include "../core/kmfprotocolcategory.h" + + +class QCheckBox; +class QTextEdit; + +/*class KMFErrorHandler;*/ + +namespace KMF { +class KMFNetwork; +class KMFGenericDoc; +class KMFNetZone; +class KMFListViewItem; +class KMFNetHost; +class KMFNetworkWidget; +class KMFNetHostPropertiesWidget; +class KMFProtocolPropertiesWidget; +class KMFProtocolListView; + +class KMFGenericInterfaceProtocol : public KMyFirewallGenericInterfaceProtocolWidget { + Q_OBJECT +public: + KMFGenericInterfaceProtocol( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); + + ~KMFGenericInterfaceProtocol(); + void loadDoc( KMFNetwork* ); + +// void setType( int ); +// enum { INCOMING, OUTGOING }; + +public slots: + void slotUpdateView(); + void slotUpdateView( NetfilterObject* ); + +private slots: +// void slotNewProtocolSelected( QListViewItem* ); + void slotNewItemSelected( QListViewItem* ); + void slotZoneRBM( QListViewItem*, const QPoint&, int ); + void slotAddZone(); + void slotDelZone(); + void slotAddHost(); + void slotDelHost(); + void slotAddressChanged( const QString& ); + void slotZoneChanged( KMFNetZone* ); + void slotCurrentZoneChanged( const QString& ); + void slotRenameZone(); + void slotRenameHost(); + void slotRenameItem( QListViewItem* item, int, const QString& name ); + void slotRestrictionChanged(); + void slotProtocolClicked( KMFProtocolUsage*, bool ); + void slotProtocolCategoryClicked( KMFProtocolCategory* ); +private: + void loadIcons(); + KMFListViewItem* findItem( const QUuid& obj_id ); + +private: + QGuardedPtr<KMFNetwork> m_doc; + + KPopupMenu* m_contextMenu; + + KMFNetworkWidget *m_network_widget; + KMFNetHostPropertiesWidget *m_nethostProperties_widget; + KMFProtocolPropertiesWidget *m_protocolProperties_widget; + KMFProtocolListView *m_protocolLIstView; + + QPtrList<KMFNetZone> m_zones; + QGuardedPtr<KMFProtocolUsage> m_protocolUsage; + QGuardedPtr<KMFNetZone> m_zone; + QGuardedPtr<KMFNetHost> m_host; + + int m_type; + QPixmap icon_up, icon_down, icon_del, icon_edit, icon_rule, icon_filter, icon_rename, + icon_chain, icon_log, icon_accept, icon_drop, icon_cmd, icon_reject, icon_return, + icon_target, icon_queue, icon_new, icon_copy, icon_move; + +}; +} +#endif diff --git a/kmyfirewall/genericinterface/kmyfirewallgenericinterfacehostwidget.ui b/kmyfirewall/genericinterface/kmyfirewallgenericinterfacehostwidget.ui new file mode 100644 index 0000000..4a42f27 --- /dev/null +++ b/kmyfirewall/genericinterface/kmyfirewallgenericinterfacehostwidget.ui @@ -0,0 +1,306 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>KMyFirewallGenericInterfaceHostWidget</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KMyFirewallGenericInterfaceHostWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>668</width> + <height>401</height> + </rect> + </property> + <property name="caption"> + <string>Hosts</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>2</number> + </property> + <property name="spacing"> + <number>2</number> + </property> + <widget class="QLayoutWidget" row="0" column="1"> + <property name="name"> + <cstring>layout2</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QGroupBox" row="1" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>groupBox6_5</cstring> + </property> + <property name="title"> + <string>Host Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="4" column="0"> + <property name="name"> + <cstring>c_log_out</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Log outgoing packets</string> + </property> + </widget> + <widget class="QCheckBox" row="3" column="0"> + <property name="name"> + <cstring>c_log_in</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="text"> + <string>Log incoming packets</string> + </property> + </widget> + <widget class="QTextEdit" row="2" column="0"> + <property name="name"> + <cstring>m_host_desc</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="wordWrap"> + <enum>NoWrap</enum> + </property> + <property name="readOnly"> + <bool>true</bool> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel1_2_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Notes:</string> + </property> + </widget> + <widget class="QLayoutWidget" row="0" column="0"> + <property name="name"> + <cstring>layout19</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3_3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>IP:</string> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>m_sb_host_1</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>255</number> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4_5</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>.</string> + </property> + <property name="alignment"> + <set>AlignBottom</set> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>m_sb_host_2</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>255</number> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4_4_3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>.</string> + </property> + <property name="alignment"> + <set>AlignBottom</set> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>m_sb_host_3</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>255</number> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4_3_3</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>.</string> + </property> + <property name="alignment"> + <set>AlignBottom</set> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>m_sb_host_4</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>255</number> + </property> + </widget> + </hbox> + </widget> + </grid> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>l_currHost</cstring> + </property> + <property name="text"> + <string>Host:</string> + </property> + </widget> + <widget class="KPushButton" row="0" column="2"> + <property name="name"> + <cstring>b_delHost</cstring> + </property> + <property name="text"> + <string>&Delete</string> + </property> + </widget> + <widget class="KPushButton" row="0" column="1"> + <property name="name"> + <cstring>b_newHost</cstring> + </property> + <property name="text"> + <string>&New</string> + </property> + </widget> + </grid> + </widget> + <widget class="KListView" row="0" column="0"> + <column> + <property name="text"> + <string>Host</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>IP</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>m_lv_zones</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>12</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </grid> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>kpushbutton.h</includehint> + <includehint>klistview.h</includehint> +</includehints> +</UI> diff --git a/kmyfirewall/genericinterface/kmyfirewallgenericinterfaceicmp.ui b/kmyfirewall/genericinterface/kmyfirewallgenericinterfaceicmp.ui new file mode 100644 index 0000000..a0c5db0 --- /dev/null +++ b/kmyfirewall/genericinterface/kmyfirewallgenericinterfaceicmp.ui @@ -0,0 +1,178 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>KMyFirewallGenericInterfaceIcmp</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KMyFirewallGenericInterfaceIcmp</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>564</width> + <height>366</height> + </rect> + </property> + <property name="caption"> + <string>ICMP</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>2</number> + </property> + <property name="spacing"> + <number>2</number> + </property> + <spacer row="1" column="0"> + <property name="name"> + <cstring>spacer3</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>80</height> + </size> + </property> + </spacer> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>GroupBox2_2</cstring> + </property> + <property name="title"> + <string>ICMP Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <spacer row="3" column="0"> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>401</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>TextLabel3_2_2_2</cstring> + </property> + <property name="text"> + <string><p><b>By limiting the ping requests you allow past your firewall, you can avoid DoS (Denial of Service) attacks.</b><br> +Those attacks are based on the fact that every computer can only handle a limited number of open connections. +A DoS attack is mostly performed by a lot of hosts connecting to the victim host until it gives up.</p></string> + </property> + <property name="alignment"> + <set>WordBreak|AlignVCenter|AlignLeft</set> + </property> + <property name="wordwrap" stdset="0"> + </property> + </widget> + <widget class="QCheckBox" row="3" column="1"> + <property name="name"> + <cstring>c_limit_ping</cstring> + </property> + <property name="text"> + <string>Limit replies </string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QCheckBox" row="1" column="1"> + <property name="name"> + <cstring>c_allow_ping</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Reply to echo-requests</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <spacer row="1" column="0"> + <property name="name"> + <cstring>spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>381</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>TextLabel2_3_2_2</cstring> + </property> + <property name="text"> + <string><p>The so-called <b>Ping</b> is an ICMP packet that is sent to a host to check if it's running or not.<br> +If you disable "Reply to echo-request", your computer will be invisible for most of the common programs used to hack/crack hosts on the Internet.<br> +However, there are a lot of network programs that use ping requests to find and check the connections to their client/server host.</p></string> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + <property name="alignment"> + <set>WordBreak|AlignVCenter|AlignLeft</set> + </property> + <property name="wordwrap" stdset="0"> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>c_allow_ping</sender> + <signal>toggled(bool)</signal> + <receiver>c_limit_ping</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>c_allow_ping</sender> + <signal>toggled(bool)</signal> + <receiver>TextLabel3_2_2_2</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/kmyfirewall/genericinterface/kmyfirewallgenericinterfacelogging.ui b/kmyfirewall/genericinterface/kmyfirewallgenericinterfacelogging.ui new file mode 100644 index 0000000..395950d --- /dev/null +++ b/kmyfirewall/genericinterface/kmyfirewallgenericinterfacelogging.ui @@ -0,0 +1,194 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>KMyFirewallGenericInterfaceLogging</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KMyFirewallGenericInterfaceLogging</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>682</width> + <height>366</height> + </rect> + </property> + <property name="caption"> + <string>Logging</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>2</number> + </property> + <property name="spacing"> + <number>2</number> + </property> + <spacer row="1" column="0"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>81</height> + </size> + </property> + </spacer> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>GroupBox3_2</cstring> + </property> + <property name="title"> + <string>Logging</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>11</number> + </property> + <property name="spacing"> + <number>6</number> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>TextLabel1_3</cstring> + </property> + <property name="text"> + <string><p>Logging dropped packets will allow you to have a look at the +packets (source/destination IP/port, etc.) that tried to pass your +firewall unsuccessfully.<br> +This is very useful if any damage has been caused by an attack +and you want to find the person responsible.<br> +The entries are written to the system's main log file +(usually /var/log/messages).<p></string> + </property> + <property name="textFormat"> + <enum>RichText</enum> + </property> + <property name="alignment"> + <set>WordBreak|AlignVCenter</set> + </property> + </widget> + <spacer row="1" column="0"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>381</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QCheckBox" row="1" column="1"> + <property name="name"> + <cstring>m_c_log</cstring> + </property> + <property name="text"> + <string>Log dropped packets</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>TextLabel5_2_2_2</cstring> + </property> + <property name="text"> + <string><p>The logprefix is a string that is prepended to the lines written to your log file to help you find the lines you need.</p></string> + </property> + <property name="alignment"> + <set>WordBreak|AlignTop|AlignLeft</set> + </property> + <property name="vAlign" stdset="0"> + </property> + <property name="wordwrap" stdset="0"> + </property> + </widget> + <widget class="KRestrictedLine" row="2" column="1"> + <property name="name"> + <cstring>m_le_logPrefix</cstring> + </property> + <property name="maxLength"> + <number>18</number> + </property> + <property name="validChars"> + <string>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ: </string> + </property> + </widget> + <widget class="QCheckBox" row="3" column="1"> + <property name="name"> + <cstring>m_c_limitLog</cstring> + </property> + <property name="text"> + <string>Limit logged packets</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>TextLabel3_3_2_2_2</cstring> + </property> + <property name="text"> + <string><p>Avoid "Denial of Service" attacks by limiting logging.</p></string> + </property> + <property name="alignment"> + <set>WordBreak|AlignVCenter|AlignLeft</set> + </property> + <property name="wordwrap" stdset="0"> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>m_c_log</sender> + <signal>toggled(bool)</signal> + <receiver>m_c_limitLog</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>m_c_log</sender> + <signal>toggled(bool)</signal> + <receiver>TextLabel3_3_2_2_2</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>m_c_log</sender> + <signal>toggled(bool)</signal> + <receiver>m_le_logPrefix</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>m_c_log</sender> + <signal>toggled(bool)</signal> + <receiver>TextLabel5_2_2_2</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>krestrictedline.h</includehint> +</includehints> +</UI> diff --git a/kmyfirewall/genericinterface/kmyfirewallgenericinterfacenatwidget.ui b/kmyfirewall/genericinterface/kmyfirewallgenericinterfacenatwidget.ui new file mode 100644 index 0000000..9fa259f --- /dev/null +++ b/kmyfirewall/genericinterface/kmyfirewallgenericinterfacenatwidget.ui @@ -0,0 +1,293 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>KMyFirewallGenericInterfaceNATWidget</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KMyFirewallGenericInterfaceNATWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>690</width> + <height>762</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel7</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string><p>You can make your firewall act as a NAT router here.<br> +By enabling NAT you can provide your Internet connection to other hosts that +are using your computer a their default gateway.</p></string> + </property> + <property name="alignment"> + <set>WordBreak|AlignTop</set> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>m_c_enable_nat</cstring> + </property> + <property name="text"> + <string>&Enable NAT (Network Address Translation)</string> + </property> + </widget> + <widget class="QGroupBox" row="2" column="0"> + <property name="name"> + <cstring>groupBox4</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="title"> + <string>NAT options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel8</cstring> + </property> + <property name="text"> + <string><p>By using the MASQUERADE target you are able to setup NAT without needing to have a static IP address. This is normaly the case for cheap DSL, Cable or Modem internet connections.</p></string> + </property> + </widget> + <widget class="QGroupBox" row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>m_gb_nat_ip</cstring> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="lineWidth"> + <number>1</number> + </property> + <property name="title"> + <string></string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>5</number> + </property> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel3</cstring> + </property> + <property name="text"> + <string>Public IP:</string> + </property> + </widget> + <widget class="QLayoutWidget"> + <property name="name"> + <cstring>layout19</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>m_sb_addr_1</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>255</number> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>.</string> + </property> + <property name="alignment"> + <set>AlignBottom</set> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>m_sb_addr_2</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>255</number> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4_4_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>.</string> + </property> + <property name="alignment"> + <set>AlignBottom</set> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>m_sb_addr_3</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>255</number> + </property> + </widget> + <widget class="QLabel"> + <property name="name"> + <cstring>textLabel4_3_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>.</string> + </property> + <property name="alignment"> + <set>AlignBottom</set> + </property> + </widget> + <widget class="KIntSpinBox"> + <property name="name"> + <cstring>m_sb_addr_4</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maxValue"> + <number>255</number> + </property> + </widget> + </hbox> + </widget> + </hbox> + </widget> + <widget class="QCheckBox" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>m_c_use_masquerade</cstring> + </property> + <property name="text"> + <string>Use the &MASQUERADE target for NAT</string> + </property> + <property name="toolTip" stdset="0"> + <string><p>Enable this if you don't have a static IP address.<br>Normaly this is the case for dial-in connections using a modem of ISDN line<p></string> + </property> + </widget> + <widget class="KComboBox" row="1" column="1"> + <property name="name"> + <cstring>m_cb_external_interface</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>textLabel3_2</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>5</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Network interface connected to the Internet:</string> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<connections> + <connection> + <sender>m_c_enable_nat</sender> + <signal>toggled(bool)</signal> + <receiver>groupBox4</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>m_c_use_masquerade</sender> + <signal>toggled(bool)</signal> + <receiver>m_gb_nat_ip</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>m_c_use_masquerade</sender> + <signal>toggled(bool)</signal> + <receiver>m_sb_addr_1</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>m_c_use_masquerade</sender> + <signal>toggled(bool)</signal> + <receiver>m_sb_addr_2</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>m_c_use_masquerade</sender> + <signal>toggled(bool)</signal> + <receiver>m_sb_addr_3</receiver> + <slot>setDisabled(bool)</slot> + </connection> + <connection> + <sender>m_c_use_masquerade</sender> + <signal>toggled(bool)</signal> + <receiver>m_sb_addr_4</receiver> + <slot>setDisabled(bool)</slot> + </connection> +</connections> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>kcombobox.h</includehint> +</includehints> +</UI> diff --git a/kmyfirewall/genericinterface/kmyfirewallgenericinterfaceprotocolwidget.ui b/kmyfirewall/genericinterface/kmyfirewallgenericinterfaceprotocolwidget.ui new file mode 100644 index 0000000..05f3ce6 --- /dev/null +++ b/kmyfirewall/genericinterface/kmyfirewallgenericinterfaceprotocolwidget.ui @@ -0,0 +1,215 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>KMyFirewallGenericInterfaceProtocolWidget</class> +<widget class="QWidget"> + <property name="name"> + <cstring>KMyFirewallGenericInterfaceProtocolWidget</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>511</width> + <height>449</height> + </rect> + </property> + <property name="caption"> + <string>Protocols</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>2</number> + </property> + <widget class="QGroupBox" row="0" column="0"> + <property name="name"> + <cstring>groupBox25</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>8</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Access Control Configuration</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string>Edit zone:</string> + </property> + </widget> + <widget class="QWidgetStack" row="3" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>m_widgetStack</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <widget class="QWidget"> + <property name="name"> + <cstring>qt_dead_widget_m_protocolOptions</cstring> + </property> + <attribute name="id"> + <number>0</number> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>qt_dead_widget_m_zoneOptions</cstring> + </property> + <attribute name="id"> + <number>1</number> + </attribute> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + </grid> + </widget> + <widget class="QWidget"> + <property name="name"> + <cstring>qt_dead_widget_m_hostOptions</cstring> + </property> + <attribute name="id"> + <number>2</number> + </attribute> + </widget> + </widget> + <widget class="QSplitter" row="2" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>splitter5</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>7</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <widget class="KListView"> + <column> + <property name="text"> + <string>Object</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Atributes</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Description</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>m_lv_zones</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>7</vsizetype> + <horstretch>12</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="fullWidth"> + <bool>true</bool> + </property> + </widget> + <widget class="QFrame"> + <property name="name"> + <cstring>m_protocolsFrame</cstring> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + </widget> + </widget> + <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>m_c_allowIncoming</cstring> + </property> + <property name="text"> + <string>Allow Incoming Connections</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="2"> + <property name="name"> + <cstring>m_c_restrictOutgoing</cstring> + </property> + <property name="text"> + <string>Restrict Outgoing Connections</string> + </property> + </widget> + <widget class="QComboBox" row="0" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>m_zoneSelect</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </grid> + </widget> + </grid> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + <includehint>klistview.h</includehint> +</includehints> +</UI> |