summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/core/netfilterobject.h
blob: 1449b2605befad94d19ca6da408f4f7c74f6dad3 (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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/***************************************************************************
   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.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef NETFILTEROBJECT_H
#define NETFILTEROBJECT_H

// TQt includes
#include <tqobject.h>
#include <tqstring.h>
#include <tqdom.h>
#include <tqptrlist.h>
#include <tqintdict.h>
#include <tqmap.h>
#include <tquuid.h>
#include <tqstringlist.h>
#include <tqguardedptr.h>
#include <kdemacros.h>

// KDE includes

// Project includes

namespace KMF {
class KMFDoc;
class KMFUndoEngine;

/** NetfilterObject ist the base class for (allmost)  all data classes
	used within KMF. It defines the needed prperties and methods to 
	allow things undo/redo, unique object id's etc. */ 

class TDE_EXPORT NetfilterObject : public TQObject {

// friend class KMFNetwork;
friend class KMFUndoEngine;
friend class KMFTransaction;
friend class KMFProtocolCategory;

	//############# Beginn static stuff ##############

public:
	static NetfilterObject* findObject( const TQUuid& uuid );
	static int objectCount( int type );
private:	
	static TQMap<TQUuid, NetfilterObject*>* getUuidObjectDict() {
		return m_uuid_dict;
	};

// DATA
private:
	static TQMap<TQUuid, NetfilterObject*>* m_uuid_dict;
	
	//############# End static stuff ##############

public:
	NetfilterObject( NetfilterObject*,  const char* name );
	virtual ~NetfilterObject();
	
private:
	NetfilterObject();
	NetfilterObject( TQObject* );
	
public: 
	/** Known object types */ 
	enum { 
		TABLE = 0, 
		CHAIN = 1, 
		RULE = 2, 
		RULEOPTION = 3, 
		PROTOCOL = 4, 
		NETZONE = 5, 
		NETHOST = 6, 
		KMFTARGET = 7, 
		KMFTARGETCONFIG = 8, 
		PROTOCOLUSAGE = 9, 
		IPTABLES_RULESET = 10, 
		GENERIC_RULESET = 11, 
		KMFNETWORK = 12,
		PROTOCOLCATEGORY = 13 
	};
	
	/** Get All living objects of the given Type */
	// const TQValueList<NetfilterObject*>& getAllOfType( int type );
	
	/** Sets the Neame of the Object */
	virtual void setName( const TQString& );

	/** return the object uuid */
	const TQUuid& uuid() const {
		return m_uuid;
	};	

	/** Retrun the Object's name */
	virtual const TQString& name();


	/** reset type */
	virtual void clear() = 0;
	
	/** return the object type */
	virtual int type() = 0;
	
	/** Return the Object's nesting level within the NetfilterObject Tree */
	int getLevel();

	/** Return the Object's Description */
	virtual const TQString& description();

	/** Set Description for this Object */
	virtual void setDescription( const TQString& );

	/** Return DomDocument of this Object */
	virtual const TQDomDocument& getDOMTree() = 0;

	/** Return String representation of the DomDocument generated 
		by const TQDomDocument& getDOMTree() */
	virtual const TQString& getXMLSniplet();

	/** Load configuration from the given TQDdomDocument */
	virtual void loadXML( const TQDomDocument&, TQStringList& errors ) = 0;

	/** Load configuration from the given TQDdomDocument */
	virtual void loadXML( TQDomNode, TQStringList& errors ) = 0;
	
	/** Set the parent object */
	void setParent( NetfilterObject* );
	
	/** check if the object is a (indirect) child of the object 
		with the given id */
	bool isChildOf( const TQUuid& uuid );
	
	/** set the changed flag, and calling changed( int id ) in the parent 
		object with it's own id */
	void changed();
	
	/** Get the Parent object */
	NetfilterObject* parentObj() const {
		return m_parent;
	}
	
protected:
	/** read the uuid from the dom node if needed */
	void loadUuid( TQDomNode&, TQStringList& errors );
	
	/** write the uuid to the dom node */
	void saveUuid( TQDomNode& );
	
private:
	/** Return the Object's nesting level within the NetfilterObject Tree walking the tree up */
	void getLevel( int& currlevel );
	
	/** Sets the UUID of the Object */
	void setUuid( const TQUuid& );
	
private:
	TQGuardedPtr<NetfilterObject> m_parent;
	TQString m_name;
	TQString m_desc;
	TQUuid m_uuid;
};
}
#endif