summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/core/iptruleoption.h
blob: b6503f36199cfc24d06aadf6b1a3a9d9dfe75234 (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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
begin                : Mon Feb 4 2002
copyright            : (C) 2002 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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef IPTRULEOPTION_H
#define IPTRULEOPTION_H

#include "netfilterobject.h"

// QT
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqdict.h>

#include <tqdom.h>

#include <kdemacros.h>

#define MAXOPTNUM 10
namespace KMF {
class KMFIPTDoc;
class IPTRule;

/**
  * class IPTRuleOption
  *
  */

class KDE_EXPORT IPTRuleOption : public NetfilterObject {
	//########## BEGIN STATIC ##############

public:
	/** Contains the option commands for each option type. */
	static TQDict<TQStringList>* getOptionStringDict();
	
	/** Returns a Stringlist containing the user visible strings for the opition */
	static TQDict<TQStringList>* getGUIStringDict();
	
	/** Return a list of all currently available option types */
	static TQPtrList<TQString>* getAvailableOptionTypes();
	
	static void readRuleOptionDefinition( const TQDomDocument& );
private:
	/** Reads a XML OptionDefinitionNode */
	static void readRuleOptionDefinitionNode( const TQDomNode& curr, TQStringList* vals, TQStringList* gui ) ;

private:  // DATA
	static TQDict<TQStringList>* m_dict_option_strings;
	static TQDict<TQStringList>* m_dict_gui_strings;
	static TQDict<TQString>* m_dict_option_names;
	
	static TQPtrList<TQString>* m_known_types;
	static bool m_created_dict;
	//########## END STATIC ################

	/** Public methods: */
public:
	IPTRuleOption( IPTRule* rule, const char* name );
	~IPTRuleOption();

	virtual int type();
	virtual void clear();
	
	/** restore the opotion config from an xml sniplet */
	virtual void loadXML( const TQDomDocument&, TQStringList& errors );

	/** restore the opotion config from an xml sniplet */
	virtual void loadXML( TQDomNode, TQStringList& errors );

	/** Makes the option empty. */
	void reset();

	/** Returns true if no option values are set */
	bool isEmpty();

	/** Return DomDocument representing this rule() */
	const TQDomDocument& getDOMTree( );

	/** Returns a TQString containing the option. */
	const TQString& toString( );

	/** Set Option Type */
	void setOptionType( const TQString& );
	
	/** Return the type of the option. */
	const TQString& getOptionType() const {
		return m_option_type;
	};
	
	/** Return the type of the option. */
	const TQString& guiName() const ;

	/** Returns true if this is a target option otherwise false*/
	bool isTargetOption() const {
		return m_target_option;
	};

	/** Returns a pointer to the rule to which this options belongs */
	IPTRule* rule() const {
		return m_rule;
	};

	/** Make this option a target option.
		Target options are appended at the very
		end of the rule */
	void setTargetOption( bool );

	/** Load the provided option values in the TQStringList. */
	void loadValues( TQStringList );

	/** Returns a TQStringList containing the option values. */
	const TQStringList& getValues();

private:
	IPTRule *m_rule;
	TQString m_option_type;
	bool m_target_option;
	TQString m_values[ MAXOPTNUM ];
};
}

#endif // IPTRULEOPTION_H