summaryrefslogtreecommitdiffstats
path: root/kmyfirewall/core/iptchain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kmyfirewall/core/iptchain.cpp')
-rw-r--r--kmyfirewall/core/iptchain.cpp178
1 files changed, 89 insertions, 89 deletions
diff --git a/kmyfirewall/core/iptchain.cpp b/kmyfirewall/core/iptchain.cpp
index 9a9d2b1..41fa9fb 100644
--- a/kmyfirewall/core/iptchain.cpp
+++ b/kmyfirewall/core/iptchain.cpp
@@ -13,9 +13,9 @@
* *
***************************************************************************/
-#include "qptrlist.h"
-#include "qstring.h"
-#include "qmessagebox.h"
+#include "tqptrlist.h"
+#include "tqstring.h"
+#include "tqmessagebox.h"
// kde includes
#include <kdebug.h>
@@ -31,8 +31,8 @@
namespace KMF {
-IPTChain::IPTChain( IPTable* table, const char* name, const QString& chainName, bool buildin ) : NetfilterObject( table, name ) {
- // kdDebug() << "IPTChain::IPTChain(const QString& name,IPTable* table,bool buildin)" << endl;
+IPTChain::IPTChain( IPTable* table, const char* name, const TQString& chainName, bool buildin ) : NetfilterObject( table, name ) {
+ // kdDebug() << "IPTChain::IPTChain(const TQString& name,IPTable* table,bool buildin)" << endl;
m_err = new KMFError();
// m_object_type = NetfilterObject::CHAIN;
@@ -80,8 +80,8 @@ void IPTChain::reset() {
changed();
}
-void IPTChain::setDefaultTarget( const QString& target ) {
- // kdDebug() << "void IPTChain::setDefaultTarget(const QString& target) " << endl;
+void IPTChain::setDefaultTarget( const TQString& target ) {
+ // kdDebug() << "void IPTChain::setDefaultTarget(const TQString& target) " << endl;
m_default_target = target;
has_default_target = true;
changed();
@@ -96,8 +96,8 @@ IPTable* IPTChain::table() const {
return m_table;
}
-QPtrList<IPTRule>& IPTChain::chainRuleset() const {
- QPtrList<IPTRule>* ret_list = new QPtrList<IPTRule>;
+TQPtrList<IPTRule>& IPTChain::chainRuleset() const {
+ TQPtrList<IPTRule>* ret_list = new TQPtrList<IPTRule>;
*ret_list = m_ruleset;
return *ret_list;
}
@@ -105,7 +105,7 @@ QPtrList<IPTRule>& IPTChain::chainRuleset() const {
void IPTChain::setBuildIn( bool build_in ) {
is_build_in_chain = build_in;
if ( is_build_in_chain ) {
- const QString target = "DROP";
+ const TQString target = "DROP";
setDefaultTarget( target );
hasCustomDefaultTarget( false );
}
@@ -126,21 +126,21 @@ void IPTChain::setUsed( bool valid ) {
int IPTChain::indexOf( const IPTRule& rule ) {
// kdDebug() << "int IPTChain::indexOf( IPTRule* " << rule.name() << " ) " << endl;
- return m_ruleset.find( &rule );
+ return m_ruleset.tqfind( &rule );
}
-IPTRule* IPTChain::addRule( const QString& rule_name, KMFError *err, int index ) {
- kdDebug() << "IPTRule* IPTChain::addRule(QString& " << rule_name << ", KMFError *err) " << endl;
+IPTRule* IPTChain::addRule( const TQString& rule_name, KMFError *err, int index ) {
+ kdDebug() << "IPTRule* IPTChain::addRule(TQString& " << rule_name << ", KMFError *err) " << endl;
- QString target = "DROP";
- const QString& new_name = rule_name;
- QString name = new_name;
+ TQString target = "DROP";
+ const TQString& new_name = rule_name;
+ TQString name = new_name;
for ( uint i = 0; i < m_ruleset.count(); i++ ) {
- QString tmp_name = m_ruleset.at( i ) ->name();
+ TQString tmp_name = m_ruleset.at( i ) ->name();
if ( tmp_name == name ) {
err->setErrType(KMFError::NORMAL);
- err->setErrMsg( i18n( "<qt><p>Unable to add rule: <b>%1</b> into chain: <b>%2</b>.<br>There is already a rule defined with that name. Please try again with another name (must be unique in that chain).</p></qt>" ).arg( tmp_name ).arg( NetfilterObject::name() ) );
+ err->setErrMsg( i18n( "<qt><p>Unable to add rule: <b>%1</b> into chain: <b>%2</b>.<br>There is already a rule defined with that name. Please try again with another name (must be unique in that chain).</p></qt>" ).tqarg( tmp_name ).tqarg( NetfilterObject::name() ) );
return 0;
}
}
@@ -158,7 +158,7 @@ IPTRule* IPTChain::addRule( const QString& rule_name, KMFError *err, int index )
} else {
if ( index < 0 || index > (int) chainRuleset().count() - -1 ) {
err->setErrType(KMFError::FATAL);
- err->setErrMsg( i18n("Cannot insert rule at %1 This is a bug ;-(").arg( index ) );
+ err->setErrMsg( i18n("Cannot insert rule at %1 This is a bug ;-(").tqarg( index ) );
return 0;
}
kdDebug() << "IPTChain::addRule: inserting rule at: " << index << endl;
@@ -175,14 +175,14 @@ KMFError* IPTChain::delRule( IPTRule* rule ) {
if ( m_ruleset.count() < 1 )
return false;
- QString name = rule->name();
- if ( m_ruleset.find( rule ) != -1 ) {
+ TQString name = rule->name();
+ if ( m_ruleset.tqfind( rule ) != -1 ) {
m_err->setErrType(KMFError::OK );
if ( ! m_ruleset.remove( rule ) ) {
rule->deleteLater();
rule = 0;
m_err->setErrType( KMFError::FATAL );
- const QString& msg = i18n( "Sorry, can't find Rule: %1 in the Ruleset of this chain." ).arg( rule->name() );
+ const TQString& msg = i18n( "Sorry, can't find Rule: %1 in the Ruleset of this chain." ).tqarg( rule->name() );
m_err->setErrMsg( msg );
return m_err;
}
@@ -192,7 +192,7 @@ KMFError* IPTChain::delRule( IPTRule* rule ) {
return m_err;
} else {
m_err->setErrType( KMFError::FATAL );
- const QString& msg = i18n( "Sorry, can't find Rule: %1 in the Ruleset of this chain." ).arg( rule->name() );
+ const TQString& msg = i18n( "Sorry, can't find Rule: %1 in the Ruleset of this chain." ).tqarg( rule->name() );
m_err->setErrMsg( msg );
return m_err;
}
@@ -202,7 +202,7 @@ KMFError* IPTChain::delRule( IPTRule* rule ) {
bool IPTChain::moveRule( IPTRule* rule, int how_much ) {
// kdDebug() << "void IPTChain::moveRule(IPTRule* rule,int how_much)" << endl;
- int num = m_ruleset.find( rule );
+ int num = m_ruleset.tqfind( rule );
int new_pos = num + how_much;
if ( new_pos < 0 || new_pos > ( int ) m_ruleset.count() - 1 ) {
// kdDebug() << "New Position is not Valid: " << new_pos << endl;
@@ -217,7 +217,7 @@ bool IPTChain::moveRule( IPTRule* rule, int how_much ) {
}
}
-void IPTChain::setDropLogging( bool enabled, QString& limit, QString& burst, QString& prefix ) {
+void IPTChain::setDropLogging( bool enabled, TQString& limit, TQString& burst, TQString& prefix ) {
enable_log = enabled;
if ( !limit.isEmpty() )
@@ -236,45 +236,45 @@ void IPTChain::setDropLogging( bool enabled, QString& limit, QString& burst, QSt
}
-QPtrList<IPTRule>& IPTChain::chainFwds() {
- // kdDebug() << "QPtrList<IPTRule> IPTChain::chainFwds()" << endl;
- QPtrList<IPTRule>* fwds = new QPtrList<IPTRule>;
- QPtrListIterator<IPTRule> it( m_ruleset );
+TQPtrList<IPTRule>& IPTChain::chainFwds() {
+ // kdDebug() << "TQPtrList<IPTRule> IPTChain::chainFwds()" << endl;
+ TQPtrList<IPTRule>* fwds = new TQPtrList<IPTRule>;
+ TQPtrListIterator<IPTRule> it( m_ruleset );
IPTRule* rule = 0;
while ( it.current() ) {
rule = it.current();
++it;
- QString target = rule->target();
+ TQString target = rule->target();
// FIXME: lots of targets missing !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if ( !target.isEmpty() && target != "ACCEPT" && target != "DROP" && target != "LOG"
&& target != "REJECT" && target != "RETURN" && target != "DNAT" && target != "SNAT"
- && target != "QUEUE" && target != "MIRROR" && target != "REDIRECT" && target != "MASQUERADE" ) {
+ && target != "TQUEUE" && target != "MIRROR" && target != "REDIRECT" && target != "MASTQUERADE" ) {
//kdDebug() << "Found Forward to chain: " << target << endl;
fwds->append( rule );
}
}
-// kdDebug() << "EXIT: QPtrList<IPTRule>& IPTChain::chainFwds()" << endl;
+// kdDebug() << "EXIT: TQPtrList<IPTRule>& IPTChain::chainFwds()" << endl;
return *fwds;
}
-QPtrList<IPTRule>& IPTChain::chainFeeds() {
-// kdDebug() << "QPtrList<IPTRule> IPTChain::chainFeeds()" << endl;
- QPtrList<IPTRule>* feeds = new QPtrList<IPTRule>;
+TQPtrList<IPTRule>& IPTChain::chainFeeds() {
+// kdDebug() << "TQPtrList<IPTRule> IPTChain::chainFeeds()" << endl;
+ TQPtrList<IPTRule>* feeds = new TQPtrList<IPTRule>;
IPTChain* tmp_chain;
- QPtrList<IPTChain> table_chains = table() ->chains();
- QPtrListIterator<IPTChain> it( table_chains );
+ TQPtrList<IPTChain> table_chains = table() ->chains();
+ TQPtrListIterator<IPTChain> it( table_chains );
while ( it.current() ) {
tmp_chain = it.current();
++it;
// kdDebug() << "Searching in chain: " << tmp_chain->name() << endl;
if ( !tmp_chain->chainRuleset().isEmpty() ) {
IPTRule * tmp_rule;
- QPtrList<IPTRule> rules = tmp_chain->chainRuleset();
- QPtrListIterator<IPTRule> it2( rules );
+ TQPtrList<IPTRule> rules = tmp_chain->chainRuleset();
+ TQPtrListIterator<IPTRule> it2( rules );
while ( it2.current() ) {
tmp_rule = it2.current();
++it2;
- QString target = tmp_rule->target();
+ TQString target = tmp_rule->target();
//kdDebug() << "Found Rule: " << tmp_rule->name() << " with target: " << target << endl;
if ( target == name() ) {
feeds->append( tmp_rule );
@@ -283,11 +283,11 @@ QPtrList<IPTRule>& IPTChain::chainFeeds() {
}
}
}
- // kdDebug() << "EXIT: QPtrList<IPTRule>& IPTChain::chainFeeds()" << endl;
+ // kdDebug() << "EXIT: TQPtrList<IPTRule>& IPTChain::chainFeeds()" << endl;
return *feeds;
}
-IPTRule* IPTChain::ruleForName( const QString& name ) {
+IPTRule* IPTChain::ruleForName( const TQString& name ) {
IPTRule * tmp_rule = 0;
for ( tmp_rule = m_ruleset.first();tmp_rule; tmp_rule = m_ruleset.next() ) {
if ( tmp_rule->name() == name ) {
@@ -297,7 +297,7 @@ IPTRule* IPTChain::ruleForName( const QString& name ) {
return 0;
}
-IPTRule* IPTChain::ruleForUuid( const QUuid& id ) {
+IPTRule* IPTChain::ruleForUuid( const TQUuid& id ) {
IPTRule * tmp_rule = 0;
for ( tmp_rule = m_ruleset.first();tmp_rule; tmp_rule = m_ruleset.next() ) {
if ( tmp_rule->uuid() == id ) {
@@ -308,8 +308,8 @@ IPTRule* IPTChain::ruleForUuid( const QUuid& id ) {
}
-QString IPTChain::createIPTablesChainDefinition() {
- QString chainDef = "";
+TQString IPTChain::createIPTablesChainDefinition() {
+ TQString chainDef = "";
if ( is_build_in_chain ) {
return chainDef;
} else {
@@ -321,7 +321,7 @@ QString IPTChain::createIPTablesChainDefinition() {
}
}
-QString IPTChain::createIPTablesChainDefaultTarget() {
+TQString IPTChain::createIPTablesChainDefaultTarget() {
// kdDebug() << "IPTChain::createIPTablesChainDefaultTarget()" << endl;
m_cmd_default_target = "$IPT -t ";
m_cmd_default_target.append( m_table->name() );
@@ -339,10 +339,10 @@ QString IPTChain::createIPTablesChainDefaultTarget() {
return m_cmd_default_target;
}
-const QDomDocument& IPTChain::getDOMTree() {
- // kdDebug() << "const QString& IPTChain::getIDOMree( )" << endl;
- QDomDocument doc;
- QDomElement root = doc.createElement( XML::Chain_Element );
+const TQDomDocument& IPTChain::getDOMTree() {
+ // kdDebug() << "const TQString& IPTChain::getIDOMree( )" << endl;
+ TQDomDocument doc;
+ TQDomElement root = doc.createElement( XML::Chain_Element );
NetfilterObject::saveUuid( root );
@@ -359,14 +359,14 @@ const QDomDocument& IPTChain::getDOMTree() {
}
if ( logging() ) {
- QDomElement logging = doc.createElement( XML::Logging_Element );
+ TQDomElement logging = doc.createElement( XML::Logging_Element );
root.appendChild( logging );
logging.setAttribute( XML::Prefix_Attribute, m_log_prefix );
logging.setAttribute( XML::Limit_Attribute, m_log_limit );
logging.setAttribute( XML::Burst_Attribute, m_log_burst );
}
- QPtrListIterator<IPTRule> it ( m_ruleset );
+ TQPtrListIterator<IPTRule> it ( m_ruleset );
IPTRule *rule = 0;
while ( ( rule = it.current() ) != 0 ) {
++it;
@@ -378,24 +378,24 @@ const QDomDocument& IPTChain::getDOMTree() {
}
}
doc.appendChild( root );
- return *( new QDomDocument( doc ) );
+ return *( new TQDomDocument( doc ) );
}
-void IPTChain::loadXML( const QDomDocument& doc, QStringList& errors ) {
- kdDebug() << "void IPTChain::loadXML( const QDomDocument& )" << endl;
- QDomElement root = doc.documentElement();
+void IPTChain::loadXML( const TQDomDocument& doc, TQStringList& errors ) {
+ kdDebug() << "void IPTChain::loadXML( const TQDomDocument& )" << endl;
+ TQDomElement root = doc.documentElement();
loadXML( root, errors );
}
-void IPTChain::loadXML( QDomNode root, QStringList& errors ) {
+void IPTChain::loadXML( TQDomNode root, TQStringList& errors ) {
/*
-void IPTChain::loadXML( const QDomDocument& doc ) {*/
- kdDebug() << "\nvoid IPTChain::loadXML( const QDomDocument& doc )" << endl;
+void IPTChain::loadXML( const TQDomDocument& doc ) {*/
+ kdDebug() << "\nvoid IPTChain::loadXML( const TQDomDocument& doc )" << endl;
NetfilterObject::loadUuid( root, errors );
- // QDomNode curr = root.toElement();
+ // TQDomNode curr = root.toElement();
- QString target = "";
- QString builtin = "";
- QString desc = "";
+ TQString target = "";
+ TQString builtin = "";
+ TQString desc = "";
kdDebug() << "Parsing node: " << root.nodeName() << endl;
builtin = root.toElement().attribute( XML::BuiltIn_Attribute );
if ( !builtin.isEmpty() && builtin == XML::Yes_Value ) {
@@ -408,29 +408,29 @@ void IPTChain::loadXML( const QDomDocument& doc ) {*/
if ( !target.isEmpty() ) {
if ( ! isBuildIn() )
hasCustomDefaultTarget( true );
- setDefaultTarget( *(new QString( target ) ) );
+ setDefaultTarget( *(new TQString( target ) ) );
}
desc = root.toElement().attribute( XML::Description_Attribute );
- setDescription( *(new QString( desc ) ) );
+ setDescription( *(new TQString( desc ) ) );
kdDebug() << "Loading chain description: " << desc << endl;
kdDebug() << "Loading Chain: " << name() << endl;
kdDebug() << "Is built in: " << builtin << endl;
kdDebug() << "Description chain description: " << desc << endl;
- QDomNode curr = root.firstChild();
- QPtrList<IPTRule> used_rules;
+ TQDomNode curr = root.firstChild();
+ TQPtrList<IPTRule> used_rules;
while ( !curr.isNull() ) {
kdDebug() << "Parsing Node: " << curr.nodeName() << endl;
if ( curr.isElement() && curr.nodeName() == XML::Rule_Element ) {
- QString name = curr.toElement().attribute( XML::Name_Attribute );
- QString id = curr.toElement().attribute( XML::Uuid_Attribute );
- QUuid rule_id( id );
+ TQString name = curr.toElement().attribute( XML::Name_Attribute );
+ TQString id = curr.toElement().attribute( XML::Uuid_Attribute );
+ TQUuid rule_id( id );
// kdDebug() << "IPTChain: Start Parsing Rule: " << name << endl;
- QDomDocument rule_xml;
+ TQDomDocument rule_xml;
rule_xml.appendChild( curr.cloneNode(true) );
IPTRule* rule = 0;
rule = ruleForUuid( rule_id );
@@ -450,9 +450,9 @@ void IPTChain::loadXML( const QDomDocument& doc ) {*/
used_rules.append( rule );
// kdDebug() << "IPTChain: Finished Parsing Rule: " << name << endl;
} else if( curr.isElement() && curr.nodeName() == XML::Logging_Element ) {
- QString log_limit = "";
- QString log_burst = "";
- QString log_prefix = "";
+ TQString log_limit = "";
+ TQString log_burst = "";
+ TQString log_prefix = "";
enable_log = true;
log_limit = curr.toElement().attribute( XML::Limit_Attribute );
@@ -471,11 +471,11 @@ void IPTChain::loadXML( const QDomDocument& doc ) {*/
}
- QPtrListIterator<IPTRule> it ( m_ruleset );
+ TQPtrListIterator<IPTRule> it ( m_ruleset );
while ( it.current() ) {
// kdDebug() << "IPTChain::xloadXML() cleanup loop." << endl;
IPTRule *rule = it.current();
- QPtrListIterator<IPTRule> it2 ( used_rules );
+ TQPtrListIterator<IPTRule> it2 ( used_rules );
bool found = false;
while ( it2.current() ) {
IPTRule *rule2 = it2.current();
@@ -494,21 +494,21 @@ void IPTChain::loadXML( const QDomDocument& doc ) {*/
changed();
}
-QPtrList<QStringList>& IPTChain::createIPTablesChainRules() {
- // kdDebug() << "QPtrList<QStringList>& IPTChain::createIPTablesChainRules()" << endl;
- QPtrList<QStringList>* all_rules = new QPtrList<QStringList>;
+TQPtrList<TQStringList>& IPTChain::createIPTablesChainRules() {
+ // kdDebug() << "TQPtrList<TQStringList>& IPTChain::createIPTablesChainRules()" << endl;
+ TQPtrList<TQStringList>* all_rules = new TQPtrList<TQStringList>;
if ( !m_ruleset.isEmpty() ) {
//kdDebug() << "------- Chain Rules --------"<< endl;
IPTRule * rule;
for ( rule = m_ruleset.first(); rule; rule = m_ruleset.next() ) {
- QString rule_name = rule->name();
- QString rule_cmd = rule->toString();
- QStringList* chainDefs = new QStringList();
+ TQString rule_name = rule->name();
+ TQString rule_cmd = rule->toString();
+ TQStringList* chainDefs = new TQStringList();
chainDefs->append( rule_name );
if ( rule->enabled() ) {
chainDefs->append( rule_cmd );
} else {
- QString warning = "if [ \"$verbose\" = \"1\" ]; then\n"
+ TQString warning = "if [ \"$verbose\" = \"1\" ]; then\n"
" echo \"Skipping Disabled Rule " + rule_name + "!!!\"\n"
"fi\n true";
chainDefs->append( warning );
@@ -518,7 +518,7 @@ QPtrList<QStringList>& IPTChain::createIPTablesChainRules() {
}
if ( enable_log ) {
//kdDebug() << "------- Chain Logging --------"<< endl;
- QString chain_log = "";
+ TQString chain_log = "";
chain_log.append( "$IPT -t " );
chain_log.append( m_table->name() );
chain_log.append( " -A " );
@@ -538,17 +538,17 @@ QPtrList<QStringList>& IPTChain::createIPTablesChainRules() {
chain_log.append( "\"" );
}
kdDebug() << chain_log << endl;
- QStringList* chainDefs = new QStringList();
- QString rule_name = i18n( "Chain: %1 Drop Logging" ).arg( name() );
+ TQStringList* chainDefs = new TQStringList();
+ TQString rule_name = i18n( "Chain: %1 Drop Logging" ).tqarg( name() );
chainDefs->append( rule_name );
chainDefs->append( chain_log );
all_rules->append( chainDefs );
}
//kdDebug() << "------- Chain Default Target --------"<< endl;
if ( has_default_target && !m_cmd_default_target.isEmpty() ) {
- QString deftg = createIPTablesChainDefaultTarget();
- QStringList* chainDefs = new QStringList();
- QString rule_name = i18n( "Chain: %1 Default Target" ).arg( name() );
+ TQString deftg = createIPTablesChainDefaultTarget();
+ TQStringList* chainDefs = new TQStringList();
+ TQString rule_name = i18n( "Chain: %1 Default Target" ).tqarg( name() );
chainDefs->append( rule_name );
chainDefs->append( deftg );
all_rules->append( chainDefs );