summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/kmfwidgets/kmfobjectinfo.cpp
blob: 1c76d49c1fc81e260bb3ded3dfcec9d0ea72319c (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
/***************************************************************************
    begin                : Thu Apr 24 2003
    copyright            : (C) 2003 by Christian Hubinger
    email                : chubinger@irrsinnig.org
 ***************************************************************************/

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

// KDE Includes
#include <kdebug.h>
#include <kapplication.h>
#include <klocale.h>

// QT includes
#include <tqstring.h>
#include <tqlabel.h>
#include <tqpushbutton.h>
#include <tqtextedit.h>

// Project includes
#include "../core/iptrule.h"
#include "../core/iptchain.h"
#include "../core/iptable.h"
#include "../core/kmfdoc.h"
#include "../core/kmfiptdoc.h"
#include "../core/kmfnetwork.h"
#include "../core/kmfundoengine.h"
namespace KMF {
KMFObjectInfo::KMFObjectInfo(TQWidget *parent, const char *name, bool modal ) : KMyFirewallObjectInfo(parent, name, modal) {
}

KMFObjectInfo::~KMFObjectInfo(){
}

void KMFObjectInfo::loadNetfilterObject( NetfilterObject* obj ) {
	if ( ! obj )
		return;
	m_netfilter_object = obj;
	m_doc = 0;
	switch( m_netfilter_object->type() ) {
		case NetfilterObject::RULE:
			m_header->setText( i18n("Rule Documentation") );
			break;
		case NetfilterObject::CHAIN:
			m_header->setText( i18n("Chain Documentation") );
			break;
		default:
			m_header->setText( i18n("Object Documentation") );
			break;
	}
	te_desc->setText( m_netfilter_object->description() );
}

void KMFObjectInfo::loadKMFDoc( KMFDoc* obj ){
	if ( ! obj )
		return;
	m_doc = obj;
	m_netfilter_object = 0;
	m_header->setText( i18n("Firewall Documentation") );
	te_desc->setText( m_doc->description() );
}

void KMFObjectInfo::accept() {
	if ( m_netfilter_object ) {
		if ( m_netfilter_object->description() != te_desc->text() ) {
			KMFUndoEngine::instance()->startTransaction(
				m_netfilter_object,
				i18n("Edit Documentaion for: %1").tqarg( m_netfilter_object->name() ) 
			);
			m_netfilter_object->setDescription( te_desc->text() );
			kdDebug()  << "Description Changed: " << te_desc->text() <<  endl;
			KMFUndoEngine::instance()->endTransaction();
		}
	} else if ( m_doc ) {
		if ( m_doc->description() != te_desc->text() ) {
			KMFUndoEngine::instance()->startTransaction(
				m_doc, 
				i18n("Edit Documentaion for: %1").tqarg( m_netfilter_object->name() ) 
			);
			m_doc->setDescription( te_desc->text() );
			KMFUndoEngine::instance()->endTransaction();
			kdDebug()  << "Description Changed: " << te_desc->text() <<  endl;
		}
	}
	
	emit sigDocumentChanged();
	emit sigHideMe();
}

void KMFObjectInfo::reject() {
	emit sigHideMe();
}

void KMFObjectInfo::slotHelp() {
	kapp->invokeHelp( "rule_documentation" );
}

}

#include "kmfobjectinfo.moc"