summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/kmfwidgets/kmfiptdocoptions.cpp
blob: 4aa52edb2e06d1250c304ee62934ac1e793d7704 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/***************************************************************************
 begin                : Wed Aug 21 2002
 copyright            : (C) 2002 by Christian Hubinger
 email                : chubinger@irrsinnig.org.orphi.iki
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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 "kmfiptdocoptions.h"


// qt includes
#include <tqcheckbox.h>

// kde includes
#include <kdebug.h>
#include <tdeapplication.h>
#include <tdemessagebox.h>
#include <tdelocale.h>

// project includes
#include "../core/kmfdoc.h"
#include "../core/kmfiptdoc.h"
#include "../core/kmfundoengine.h"
#include "../core/kmfnetwork.h"
#include "../core/kmftarget.h"
namespace KMF {
KMFIPTDocOptions::KMFIPTDocOptions( TQWidget *parent, const char *name ) : KMyFirewallIPTDocOptions( parent, name ) {}

KMFIPTDocOptions::~KMFIPTDocOptions() {}

void KMFIPTDocOptions::loadDoc( KMFIPTDoc* doc ) {
	kdDebug() << "void KMFIPTDocOptions::loadDoc(KMFIPTDoc* doc)" << endl;
	kmfdoc = doc;
	c_use_filter->setChecked( kmfdoc->useFilter() );
	c_use_nat->setChecked( kmfdoc->useNat() );
	c_use_mangle->setChecked( kmfdoc->useMangle() );
	c_use_ipfwd->setChecked( kmfdoc->useIPFwd() );
	c_use_rp_filter->setChecked( kmfdoc->useRPFilter() );
	c_use_martians->setChecked( kmfdoc->useMartians() );
	c_use_syn_cookies->setChecked( kmfdoc->useSynCookies() );
	c_use_modules->setChecked( kmfdoc->useModules() );
}
void KMFIPTDocOptions::accept() {
	if (  ! c_use_filter->isChecked() && ! c_use_nat->isChecked() && ! c_use_mangle->isChecked() ) {
		KMessageBox::sorry(this, i18n("<p>Sorry, you need to use at least one of the three tables -- <b> filter, nat</b> or <b>mangle</b>:<br>it does not make any sense to work on a ruleset where you cannot add any rules.</p>") );
		return;
	}
	
	
	KMFUndoEngine::instance()->startTransaction(
		kmfdoc,
		i18n( "Edit document settings for target: %1.").arg( kmfdoc->target()->guiName() )
	);
	kmfdoc->setUseFilter( c_use_filter->isChecked() );
	kmfdoc->setUseNat( c_use_nat->isChecked() );
	kmfdoc->setUseMangle( c_use_mangle->isChecked() );
	kmfdoc->setUseIPFwd( c_use_ipfwd->isChecked() );
	if ( c_use_rp_filter->isChecked() ) {
		kmfdoc->setUseRPFilter( true );
		kmfdoc->setUseMartians( c_use_martians->isChecked() );
	} else {
		kmfdoc->setUseRPFilter( false );
		kmfdoc->setUseMartians( false );
	}
	kmfdoc->setUseSynCookies( c_use_syn_cookies->isChecked() );
	kmfdoc->setUseModules( c_use_modules->isChecked() );
	//	kmfdoc->network()->changed();
	KMFUndoEngine::instance()->endTransaction();
	emit sigConfigChanged();
	TQDialog::accept();
}

void KMFIPTDocOptions::slotHelp() {
	kdDebug() << "void KMFIPTDocOptions::slotHelp() {" << endl;
	kapp->invokeHelp();
}

}
#include "kmfiptdocoptions.moc"