summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/genericinterface/kmfgenericinterfaceicmp.cpp
blob: aa6341bf47e18b1f87fa4428c240227f79c257d0 (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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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 <tqstring.h>
#include <tqcheckbox.h>

// KDE includes
#include <tdelocale.h>
#include <kdebug.h>

// Project includes
#include "../core/kmfnetwork.h"
#include "../core/kmfgenericdoc.h"

namespace KMF {
KMFGenericInterfaceIcmp::KMFGenericInterfaceIcmp( TQWidget *parent, const char *name, WFlags f )
		: KMyFirewallGenericInterfaceIcmp( parent, name, f ) {
connect( c_allow_ping, TQT_SIGNAL( toggled( bool ) ),
	this, TQT_SLOT( slotEnablePingReplyToggled( bool ) ) );
connect( c_limit_ping, TQT_SIGNAL( toggled( bool ) ),
	this, TQT_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"