1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-01-13 22:42:37 +01:00

fix: Add support for Qt6

This commit is contained in:
Sirius Bakke 2023-07-22 20:06:11 +02:00
parent b6648fd18a
commit f76af1915d
184 changed files with 907 additions and 982 deletions

View File

@ -299,7 +299,11 @@ protected:
{
#ifdef ANTLR_CXX_SUPPORTS_UNCAUGHT_EXCEPTION
// Only give trace if there's no uncaught exception..
if(!ANTLR_USE_NAMESPACE(std)uncaught_exception())
#if __cplusplus > 201402
if(!ANTLR_USE_NAMESPACE(std)uncaught_exceptions())
#else
if(!ANTLR_USE_NAMESPACE(std)uncaught_exception())
#endif
#endif
parser->traceOut(text);
}

View File

@ -30,7 +30,7 @@
#include "fwbuilder/Resources.h"
#include "fwbuilder/Constants.h"
#include <QRegExp>
#include <QRegularExpression>
#include <QTextStream>
#include <QDir>
#include <QFile>
@ -170,8 +170,7 @@ QString Configlet::expand()
{
// Need non-greedy matching so that if_re matches only one {{?var}} ... {{?}}
// clause
QRegExp var_re("\\{\\{\\$([^}]*)\\}\\}", Qt::CaseSensitive, QRegExp::RegExp2);
var_re.setMinimal(true);
QRegularExpression var_re("\\{\\{\\$([^}]*)\\}\\}", QRegularExpression::InvertedGreedinessOption);
// remove comments before processing {{$var}} and {{if var}} so we can
// use these in comments
@ -194,10 +193,11 @@ QString Configlet::expand()
"Check configlet syntax. %1").arg(file_path);
int counter = 0;
int pos = 0;
while ((pos = var_re.indexIn(all_code, pos)) != -1 && counter < 1000)
qsizetype from = 0;
QRegularExpressionMatch match;
while ((from = all_code.indexOf(var_re, from, &match)) != -1 && counter < 1000)
{
QString var = var_re.cap(1);
QString var = match.captured(1);
if (vars.count(var) > 0)
{
@ -243,21 +243,21 @@ QString Configlet::expand()
*/
bool Configlet::processIf(QString &stream, int pos)
{
QRegExp if_re("\\{\\{if {1,}([^}]{1,})\\}\\}", Qt::CaseSensitive, QRegExp::RegExp2);
QRegExp endif_re("\\{\\{endif\\}\\}", Qt::CaseSensitive, QRegExp::RegExp2);
if_re.setMinimal(true);
endif_re.setMinimal(true);
int current_if_pos = if_re.indexIn(stream, pos);
QRegularExpression if_re("\\{\\{if {1,}([^}]{1,})\\}\\}", QRegularExpression::InvertedGreedinessOption);
QRegularExpression endif_re("\\{\\{endif\\}\\}", QRegularExpression::InvertedGreedinessOption);
QRegularExpressionMatch if_re_match;
QRegularExpressionMatch endif_re_match;
qsizetype current_if_pos = stream.indexOf(if_re, pos, &if_re_match);
if (current_if_pos == -1) return false;
int current_if_length = if_re.cap(0).length();
QString current_if_var = if_re.cap(1);
qsizetype current_if_length = if_re_match.capturedLength();
QString current_if_var = if_re_match.captured(1);
// look what is next, another opening if or closing endif
int next_if_pos = if_re.indexIn(
stream, current_if_pos + current_if_length);
int next_endif_pos = endif_re.indexIn(
stream, current_if_pos + current_if_length);
qsizetype next_if_pos = stream.indexOf(if_re, current_if_pos + current_if_length);
qsizetype next_endif_pos = stream.indexOf(endif_re, current_if_pos + current_if_length, &endif_re_match);
if (next_if_pos != -1 && next_if_pos < next_endif_pos)
{
@ -269,10 +269,10 @@ bool Configlet::processIf(QString &stream, int pos)
if (next_endif_pos != -1)
{
int next_endif_length = endif_re.cap(0).length();
qsizetype next_endif_length = endif_re_match.capturedLength();
// current if statement starts at current_if_pos
// and ends at next_endif_pos + next_endif_length
int current_if_clause_length =
qsizetype current_if_clause_length =
next_endif_pos + next_endif_length - current_if_pos;
QString body = stream.mid(
current_if_pos + current_if_length,

View File

@ -41,7 +41,7 @@
#include <QDebug>
#include <QObject>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
@ -71,8 +71,8 @@ bool interfaceProperties::looksLikeVlanInterface(const QString &int_name)
*/
bool interfaceProperties::looksLikeInterface(const QString &name)
{
QRegExp basic_interface_name_pattern("^[a-zA-Z]+\\d{1,}(\\.\\d{1,})?(:\\d{1,})?$");
return (basic_interface_name_pattern.indexIn(name) != -1);
QRegularExpression basic_interface_name_pattern("^[a-zA-Z]+\\d{1,}(\\.\\d{1,})?(:\\d{1,})?$");
return (name.indexOf(basic_interface_name_pattern) != -1);
}
// simple name validation: does not allow space and "-"

View File

@ -29,7 +29,7 @@
#include <QDebug>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
using namespace libfwbuilder;
@ -37,11 +37,12 @@ using namespace libfwbuilder;
bool iosInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
return false;

View File

@ -29,7 +29,7 @@
#include <QDebug>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
using namespace libfwbuilder;
@ -37,11 +37,12 @@ using namespace libfwbuilder;
bool junosInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern("unit (\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("unit (\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = QString("unit");
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(1).toInt();
if (vlan_id!=nullptr) *vlan_id = match.captured(1).toInt();
return true;
}
return false;

View File

@ -31,7 +31,7 @@
#include <iostream>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
@ -40,15 +40,16 @@ using namespace libfwbuilder;
bool linux24Interfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QList<QRegExp> vlan_name_patterns;
vlan_name_patterns.append(QRegExp("([a-zA-Z0-9-]+\\d{1,})\\.(\\d{1,})"));
vlan_name_patterns.append(QRegExp("(vlan)(\\d{1,})"));
QList<QRegularExpression> vlan_name_patterns;
vlan_name_patterns.append(QRegularExpression("([a-zA-Z0-9-]+\\d{1,})\\.(\\d{1,})"));
vlan_name_patterns.append(QRegularExpression("(vlan)(\\d{1,})"));
QRegularExpressionMatch match;
for (int idx=0; idx < vlan_name_patterns.size(); ++idx)
{
if (vlan_name_patterns[idx].indexIn(name) != -1)
if (name.indexOf(vlan_name_patterns[idx], 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_patterns[idx].cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_patterns[idx].cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
}

View File

@ -29,7 +29,7 @@
#include <QDebug>
#include <QObject>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;
using namespace libfwbuilder;
@ -37,11 +37,12 @@ using namespace libfwbuilder;
bool nxosInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("([a-zA-Z-]+\\d{1,}/\\d{1,})\\.(\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
return false;

View File

@ -25,18 +25,19 @@
#include "fwbuilder/Interface.h"
#include <QRegExp>
#include <QRegularExpression>
using namespace libfwbuilder;
bool openbsdInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern(QRegExp("(vlan)(\\d{1,})"));
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern(QRegularExpression("(vlan)(\\d{1,})"));
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
return false;

View File

@ -25,7 +25,7 @@
#include "pixInterfaces.h"
#include <QRegExp>
#include <QRegularExpression>
/*
* http://www.cisco.com/en/US/docs/security/asa/asa70/command/reference/gl.html#wp1644971
@ -41,11 +41,12 @@
bool pixInterfaces::parseVlan(const QString &name, QString *base_name, int *vlan_id)
{
QRegExp vlan_name_pattern("([a-zA-Z-]+\\d{1,}(/\\d{1,})*)\\.(\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("([a-zA-Z-]+\\d{1,}(/\\d{1,})*)\\.(\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(3).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(3).toInt();
return true;
}
return false;

View File

@ -27,7 +27,7 @@
#include "fwbuilder/Interface.h"
#include <QRegExp>
#include <QRegularExpression>
#include <QObject>
using namespace std;
@ -66,11 +66,12 @@ bool procurveInterfaces::parseVlan(
}
// Procurve SNMP reports vlan interface names without space
QRegExp vlan_name_pattern("(vlan|Vlan|VLAN) *(\\d{1,})");
if (vlan_name_pattern.indexIn(name) != -1)
QRegularExpression vlan_name_pattern("(vlan|Vlan|VLAN) *(\\d{1,})");
QRegularExpressionMatch match;
if (name.indexOf(vlan_name_pattern, 0, &match) != -1)
{
if (base_name!=nullptr) *base_name = vlan_name_pattern.cap(1);
if (vlan_id!=nullptr) *vlan_id = vlan_name_pattern.cap(2).toInt();
if (base_name!=nullptr) *base_name = match.captured(1);
if (vlan_id!=nullptr) *vlan_id = match.captured(2).toInt();
return true;
}
return false;

View File

@ -35,7 +35,6 @@
#include <QtWidgets/QApplication>
#include <QTimer>
#include <QPixmapCache>
#include <QTextCodec>
#include <QLocale>
#include <QDir>
#include <QTranslator>
@ -246,17 +245,21 @@ int main( int argc, char *argv[] )
QString local = QLocale::system().name();//"en_US";//
QTranslator translator(0);
translator.load(QLatin1String("fwbuilder_") +
QString(local), Constants::getLocaleDirectory().c_str());
Q_UNUSED(translator.load(QLatin1String("fwbuilder_") +
QString(local), Constants::getLocaleDirectory().c_str()));
app->installTranslator (&translator);
QString qt_resource_dir =
QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QLibraryInfo::location(QLibraryInfo::TranslationsPath);
#else
QLibraryInfo::path(QLibraryInfo::TranslationsPath);
#endif
QTranslator qt_translator(0);
qt_translator.load(QLatin1String("qt_") + QLocale::system().name(),
qt_resource_dir);
Q_UNUSED(qt_translator.load(QLatin1String("qt_") + QLocale::system().name(),
qt_resource_dir));
app->installTranslator (&qt_translator);
mw = new FWWindow();

View File

@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
#include <ios>
@ -83,8 +83,9 @@ void IPTImporter::run()
string normalized_input_buffer;
normalized_input_buffer.reserve(input_size);
QRegExp old_negation_short("(-[^- ])\\s!");
QRegExp old_negation_long("(--[^- ]+)\\s!");
QRegularExpression old_negation_short("(-[^- ])\\s!");
QRegularExpression old_negation_long("(--[^- ]+)\\s!");
QRegularExpressionMatch match;
input.seekg (0, ios::beg);
char buf[8192];
@ -103,25 +104,25 @@ void IPTImporter::run()
// negation: "-s ! something" format is deprecated and is replaced with
// "! -s something", but our parser understands only old format.
int pos = 0;
qsizetype pos = 0;
while (true)
{
QString option;
int match_length = 0;
int old_pos = 0;
qsizetype match_length = 0;
qsizetype old_pos = 0;
old_pos = old_negation_short.indexIn(str, pos);
old_pos = str.indexOf(old_negation_short, pos, &match);
if (old_pos != -1)
{
option = old_negation_short.cap(1);
match_length = old_negation_short.matchedLength();
option = match.captured(1);
match_length = match.capturedLength();
} else
{
old_pos = old_negation_long.indexIn(str, pos);
old_pos = str.indexOf(old_negation_long, pos, &match);
if (old_pos != -1)
{
option = old_negation_long.cap(1);
match_length = old_negation_long.matchedLength();
option = match.captured(1);
match_length = match.capturedLength();
}
}

View File

@ -58,7 +58,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
@ -358,9 +358,10 @@ void Importer::setInterfaceParametes(const std::string &phys_intf_or_label,
// "nameif ethernet0 outside security0"
Interface *intf = all_interfaces[phys_intf_or_label];
intf->setLabel(label);
QRegExp pix6_sec_level("security(\\d+)");
if (pix6_sec_level.indexIn(sec_level.c_str()) > -1)
intf->setSecurityLevel(pix6_sec_level.cap(1).toInt());
QRegularExpression pix6_sec_level("security(\\d+)");
QRegularExpressionMatch match;
if (QString::fromStdString(sec_level).indexOf(pix6_sec_level, 0, &match) > -1)
intf->setSecurityLevel(match.captured(1).toInt());
} else
{
// since first arg is not physical interface name, it must be a label

View File

@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
#include <ios>
@ -78,12 +78,13 @@ void PFImporter::run()
}
QString whole_input = whole_input_tmp.join("\n") + "\n";
QRegExp line_continuation("\\\\\\s*\n");
QRegularExpression line_continuation("\\\\\\s*\n");
whole_input.replace(line_continuation, "");
QRegExp inline_comment("#.*$");
QRegExp macro_definition("^\\s*(\\S+)\\s*=\\s*(.*)$");
QRegExp list_of_items("^\\{\\s*((\\S+,?\\s*)+)\\s*\\}$");
QRegularExpression inline_comment("#.*$");
QRegularExpression macro_definition("^\\s*(\\S+)\\s*=\\s*(.*)$");
QRegularExpression list_of_items("^\\{\\s*((\\S+,?\\s*)+)\\s*\\}$");
QRegularExpressionMatch match;
QMap<QString, QString> macros;
QMap<QString, QString> macros_source_lines;
@ -94,15 +95,15 @@ void PFImporter::run()
work_str.replace(inline_comment, "");
work_str = work_str.trimmed();
if (macro_definition.indexIn(work_str) != -1)
if (work_str.indexOf(macro_definition, 0, &match) != -1)
{
QString macro_name = macro_definition.cap(1);
QString value = macro_definition.cap(2);
QString macro_name = match.captured(1);
QString value = match.captured(2);
value.replace('\"', "");
value = value.simplified();
macros[macro_name] = value;
macros_source_lines[macro_name] = macro_definition.cap(0);
macros_source_lines[macro_name] = match.captured(0);
}
}
@ -134,7 +135,7 @@ void PFImporter::run()
* RegExp list_of_items assumes the string has been
* stripped of any quotes and trimmed.
*/
if (list_of_items.indexIn(value) != -1)
if (value.indexOf(list_of_items, 0, &match) != -1)
{
qDebug() << "This macro defines a list";
@ -146,13 +147,9 @@ void PFImporter::run()
* because pf does not allow mixed address/service
* lists anywhere.
*/
QString list_str = list_of_items.cap(1);
QString list_str = match.captured(1);
list_str.replace(",", "");
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList items = list_str.split(QRegExp("\\s"), Qt::SkipEmptyParts);
#else
QStringList items = list_str.split(QRegExp("\\s"), QString::SkipEmptyParts);
#endif
QStringList items = list_str.split(QRegularExpression("\\s"), Qt::SkipEmptyParts);
qDebug() << items;
bool has_address = false;
@ -261,7 +258,8 @@ void PFImporter::substituteMacros(const QMap<QString,QString> &macros,
QString &buffer)
{
// make several passes: sometimes macros can use other macros
QRegExp any_macro_instance("\\$(\\w+)\\W");
QRegularExpression any_macro_instance("\\$(\\w+)\\W");
QRegularExpressionMatch match;
QSet<QString> undefined_macros;
for (;;)
{
@ -271,16 +269,16 @@ void PFImporter::substituteMacros(const QMap<QString,QString> &macros,
it.next();
QString macro_name = it.key();
QString macro_value = it.value();
QRegExp macro_instance(QString("\\$%1(?=\\W)").arg(macro_name));
QRegularExpression macro_instance(QString("\\$%1(?=\\W)").arg(macro_name));
buffer.replace(macro_instance, macro_value);
}
bool has_known_macros = false;
int idx = 0;
while ((idx = buffer.indexOf(any_macro_instance, idx)) != -1)
qsizetype idx = 0;
while ((idx = buffer.indexOf(any_macro_instance, idx, &match)) != -1)
{
QString macro_name = any_macro_instance.cap(1);
QString macro_name = match.captured(1);
if (macros.contains(macro_name)) has_known_macros = true;
else undefined_macros.insert(macro_name);
idx++;

View File

@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
#include <ios>
@ -96,7 +96,7 @@ void PIXImporter::run()
for (it=named_addresses.begin(); it!=named_addresses.end(); ++it)
{
QString re("\\b%1\\b");
str.replace(QRegExp(re.arg(it.key())), it.value());
str.replace(QRegularExpression(re.arg(it.key())), it.value());
}
}

View File

@ -23,7 +23,7 @@
#include "PreImport.h"
#include <QRegExp>
#include <QRegularExpression>
#include <functional>
@ -60,90 +60,90 @@ public:
void PreImport::scan()
{
QList<QRegExp> pix_re;
pix_re << QRegExp("^ASA Version")
<< QRegExp("^PIX Version")
<< QRegExp("^FWSM Version")
<< QRegExp("^nat \\(\\S+,\\S+\\)")
<< QRegExp("^static \\(\\S+,\\S+\\)")
<< QRegExp("^global \\(")
<< QRegExp("^nameif \\S+")
<< QRegExp("^fixup \\S+");
QList<QRegularExpression> pix_re;
pix_re << QRegularExpression("^ASA Version")
<< QRegularExpression("^PIX Version")
<< QRegularExpression("^FWSM Version")
<< QRegularExpression("^nat \\(\\S+,\\S+\\)")
<< QRegularExpression("^static \\(\\S+,\\S+\\)")
<< QRegularExpression("^global \\(")
<< QRegularExpression("^nameif \\S+")
<< QRegularExpression("^fixup \\S+");
QList<QRegExp> fwsm_re;
fwsm_re << QRegExp("^FWSM Version");
QList<QRegularExpression> fwsm_re;
fwsm_re << QRegularExpression("^FWSM Version");
QList<QRegExp> ios_re;
ios_re << QRegExp("IOS Version")
<< QRegExp("^[vV]ersion 1[012]\\..*");
QList<QRegularExpression> ios_re;
ios_re << QRegularExpression("IOS Version")
<< QRegularExpression("^[vV]ersion 1[012]\\..*");
QList<QRegExp> iptables_re;
iptables_re << QRegExp("# Generated by iptables-save")
<< QRegExp("^:INPUT ")
<< QRegExp("^:OUTPUT ")
<< QRegExp("^:FORWARD ")
<< QRegExp("^-A INPUT ")
<< QRegExp("^-A OUTPUT ")
<< QRegExp("^-A FORWARD ");
QList<QRegularExpression> iptables_re;
iptables_re << QRegularExpression("# Generated by iptables-save")
<< QRegularExpression("^:INPUT ")
<< QRegularExpression("^:OUTPUT ")
<< QRegularExpression("^:FORWARD ")
<< QRegularExpression("^-A INPUT ")
<< QRegularExpression("^-A OUTPUT ")
<< QRegularExpression("^-A FORWARD ");
QList<QRegExp> iptables_with_counters_re;
iptables_with_counters_re << QRegExp("^\\[\\d+:\\d+\\] -A INPUT ")
<< QRegExp("^\\[\\d+:\\d+\\] -A OUTPUT ")
<< QRegExp("^\\[\\d+:\\d+\\] -A FORWARD ");
QList<QRegularExpression> iptables_with_counters_re;
iptables_with_counters_re << QRegularExpression("^\\[\\d+:\\d+\\] -A INPUT ")
<< QRegularExpression("^\\[\\d+:\\d+\\] -A OUTPUT ")
<< QRegularExpression("^\\[\\d+:\\d+\\] -A FORWARD ");
QList<QRegExp> pf_conf_re;
pf_conf_re << QRegExp("^scrub\\s+\\S+")
<< QRegExp("^set\\s+timeout\\s+\\S+")
<< QRegExp("^pass\\s+")
<< QRegExp("^block\\s+")
<< QRegExp("^nat\\s+(?!\\()")
<< QRegExp("^rdr\\s+(?!\\()")
<< QRegExp("^table\\s+<\\S+>\\s+");
QList<QRegularExpression> pf_conf_re;
pf_conf_re << QRegularExpression("^scrub\\s+\\S+")
<< QRegularExpression("^set\\s+timeout\\s+\\S+")
<< QRegularExpression("^pass\\s+")
<< QRegularExpression("^block\\s+")
<< QRegularExpression("^nat\\s+(?!\\()")
<< QRegularExpression("^rdr\\s+(?!\\()")
<< QRegularExpression("^table\\s+<\\S+>\\s+");
foreach (QString line, *buffer)
{
if (platform == UNKNOWN)
{
foreach (QRegExp re, pix_re)
foreach (QRegularExpression re, pix_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = PIX;
break;
}
}
foreach (QRegExp re, fwsm_re)
foreach (QRegularExpression re, fwsm_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = FWSM;
break;
}
}
foreach (QRegExp re, ios_re)
foreach (QRegularExpression re, ios_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = IOSACL;
break;
}
}
foreach (QRegExp re, iptables_re)
foreach (QRegularExpression re, iptables_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = IPTABLES;
break;
}
}
foreach (QRegExp re, pf_conf_re)
foreach (QRegularExpression re, pf_conf_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = PF;
break;
@ -153,9 +153,9 @@ void PreImport::scan()
if (platform == IPTABLES)
{
foreach (QRegExp re, iptables_with_counters_re)
foreach (QRegularExpression re, iptables_with_counters_re)
{
if (re.indexIn(line) > -1)
if (line.indexOf(re) > -1)
{
platform = IPTABLES_WITH_COUNTERS;
break;
@ -208,15 +208,15 @@ bool PreImport::isReversePFConfigurationStyle(matchPFDirection &dir_op)
bool has_block_no_quick = false;
bool has_command_with_quick_after_block = false;
bool has_command_with_no_quick_after_block = false;
QRegExp cont("\\\\\\s*\n");
QRegularExpression cont("\\\\\\s*\n");
QString line;
QStringListIterator it(*buffer);
while (it.hasNext())
{
// first, unfold lines ending with "\"
line = it.next();
int cont_idx;
while ( (cont_idx = cont.indexIn(line)) > -1 && it.hasNext())
qsizetype cont_idx = 0;
while ( (cont_idx = line.indexOf(cont, cont_idx)) > -1 && it.hasNext())
{
line.insert(cont_idx, it.next());
}

View File

@ -57,7 +57,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -91,9 +93,10 @@ int main(int argc, char **argv)
{
QCoreApplication app(argc, argv, false);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
// compilers always write file names into manifest in Utf8
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();
if (args.size()<=1)

View File

@ -64,7 +64,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -101,7 +103,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -62,7 +62,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -97,7 +99,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -42,7 +42,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include <QTime>
#include <QElapsedTimer>
@ -83,7 +85,9 @@ int main(int argc, char **argv)
total_time_timer.start();
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -56,7 +56,6 @@
#include <QString>
#include <QRegExp>
#include <QtDebug>
#include <algorithm>

View File

@ -59,7 +59,7 @@
#include <QString>
#include <QtDebug>
#include <QRegExp>
#include <QRegularExpression>
#include <QStringList>
@ -284,7 +284,7 @@ void OSConfigurator_linux24::addVirtualAddressForNAT(const Address *addr)
string OSConfigurator_linux24::normalizeSetName(const string &txt)
{
QString table_name = txt.c_str();
table_name.replace(QRegExp("[ +*!#|]"), "_");
table_name.replace(QRegularExpression("[ +*!#|]"), "_");
return table_name.toStdString();
}
@ -479,15 +479,12 @@ QString OSConfigurator_linux24::addressTableWrapper(FWObject *rule,
bool ipv6)
{
QString combined_command = command;
QRegExp address_table_re("\\$at_(\\S+)");
int pos = address_table_re.indexIn(command);
if (pos > -1)
QRegularExpression address_table_re("\\$at_(\\S+)");
QRegularExpressionMatch match;
if (command.indexOf(address_table_re, 0, &match) > -1)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList command_lines = QString(command).split("\n", Qt::SkipEmptyParts);
#else
QStringList command_lines = QString(command).split("\n", QString::SkipEmptyParts);
#endif
if (command_lines.size() > 1)
{
command_lines.push_front("{");
@ -500,7 +497,7 @@ QString OSConfigurator_linux24::addressTableWrapper(FWObject *rule,
command_wrappers->collapseEmptyStrings(true);
command_wrappers->setVariable("ipv6", ipv6);
QString at_var = address_table_re.cap(1);
QString at_var = match.captured(1);
QString at_file = rule->getStr("address_table_file").c_str();
command_wrappers->setVariable("address_table_file", at_file);
@ -545,15 +542,16 @@ string OSConfigurator_linux24::printRunTimeWrappers(FWObject *rule,
command_wrappers->setVariable("address_table", false);
QRegExp intf_re("\\$i_([^ :]+)");
QRegularExpression intf_re("\\$i_([^ :]+)");
QRegularExpressionMatch match;
QStringList iface_names;
QStringList iface_vars;
int pos = -1;
while ((pos = intf_re.indexIn(combined_command, pos + 1)) > -1)
qsizetype pos = -1;
while ((pos = combined_command.indexOf(intf_re, pos + 1, &match)) > -1)
{
QString name = intf_re.cap(1);
int match_len = intf_re.matchedLength();
QString name = match.captured(1);
int match_len = match.capturedLength();
iface_names.push_back(name);
iface_vars.push_back("$i_" + name);
if (name.contains("*"))
@ -574,11 +572,7 @@ string OSConfigurator_linux24::printRunTimeWrappers(FWObject *rule,
if (!no_wrapper)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList command_lines = QString(combined_command).split("\n", Qt::SkipEmptyParts);
#else
QStringList command_lines = QString(combined_command).split("\n", QString::SkipEmptyParts);
#endif
if (command_lines.size() > 1)
{
command_lines.push_front("{");

View File

@ -30,9 +30,8 @@
#include "fwcompiler/OSConfigurator.h"
#include "OSData_ipt.h"
class QString;
class QStringList;
#include <QStringList>
namespace libfwbuilder {
class FWObject;

View File

@ -63,7 +63,7 @@
#include <QString>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
@ -654,10 +654,10 @@ bool OSConfigurator_linux24::validateInterfaces()
iface->getOptionsObject()->getStr("type") == "bonding")
{
QString subint_name = subinterface->getName().c_str();
QRegExp vlan1("[a-zA-Z-]+\\d{1,}\\.\\d{1,}");
QRegExp vlan2("vlan\\d{1,}");
if (vlan1.indexIn(subint_name) != -1 ||
vlan1.indexIn(subint_name) != -1)
QRegularExpression vlan1("[a-zA-Z-]+\\d{1,}\\.\\d{1,}");
QRegularExpression vlan2("vlan\\d{1,}");
// Note: this checked for vlan1 twice. Must have been a typo.
if (subint_name.indexOf(vlan1) != -1 || subint_name.indexOf(vlan2) != -1)
{
QString err(
"Vlan subinterfaces as slaves of bonding interfaces "

View File

@ -57,7 +57,6 @@
#include "Configlet.h"
#include <QStringList>
#include <QRegExp>
#include <QtDebug>
#include <iostream>

View File

@ -69,8 +69,6 @@
#include <climits>
#include <QString>
#include <QRegExp>
using namespace libfwbuilder;
using namespace fwcompiler;

View File

@ -21,6 +21,8 @@
*/
#include <list>
#include "ipt_utils.h"
#include "fwbuilder/FWObjectDatabase.h"
@ -35,7 +37,7 @@
#include "combinedAddress.h"
#include <QRegExp>
#include <QRegularExpression>
using namespace libfwbuilder;
@ -86,7 +88,7 @@ void build_interface_groups(
*/
QString iname = QString(iface->getName().c_str());
iname.replace(QRegExp("[0-9]{1,}$"), "+");
iname.replace(QRegularExpression("[0-9]{1,}$"), "+");
iname.replace("*", "+");
if (regular_interfaces.count(iname) == 0)

View File

@ -57,7 +57,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -92,7 +94,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -55,7 +55,7 @@
#include <qapplication.h>
#include <QStackedWidget>
#include <qcursor.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <QtDebug>
#include <iostream>
@ -119,9 +119,7 @@ void ActionsDialog::validate(bool *res)
{
*res=false;
QMessageBox::critical(this, "Firewall Builder",
tr("'Change inbound interface', 'Continue packet inspection' and 'Make a copy' options are mutually exclusive"),
tr("&Continue"), 0, 0,
0 );
tr("'Change inbound interface', 'Continue packet inspection' and 'Make a copy' options are mutually exclusive"));
}
}
}
@ -140,13 +138,11 @@ void ActionsDialog::applyChanges()
/* rule name for accounting may contain only alphanumeric characters
* and no white spaces or spec. characters
*/
if (rn.contains(QRegExp("[^a-zA-Z0-9_]"))!=0)
if (rn.contains(QRegularExpression("[^a-zA-Z0-9_]"))!=0)
{
QMessageBox::information(
this,"Firewall Builder",
tr("Rule name for accounting is converted to the iptables\nchain name and therefore may not contain white space\nand special characters."),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("Rule name for accounting is converted to the iptables\nchain name and therefore may not contain white space\nand special characters."));
return;
}

View File

@ -128,8 +128,7 @@ void AddressRangeDialog::validate(bool *res)
QMessageBox::critical(
this, "Firewall Builder",
QString::fromUtf8(ex.toString().c_str()),
tr("&Continue"), nullptr, nullptr,
0 );
QMessageBox::Ok);
blockSignals(false);
}
}

View File

@ -41,7 +41,7 @@ BackgroundCompileInfoWidget::BackgroundCompileInfoWidget(QWidget *parent, instDi
m_progressBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
QHBoxLayout *hboxlayout = new QHBoxLayout();
hboxlayout->setSpacing(0);
hboxlayout->setMargin(0);
hboxlayout->setContentsMargins(0, 0, 0, 0);
hboxlayout->addWidget(m_label);
hboxlayout->addWidget(m_progressBar);
setLayout(hboxlayout);

View File

@ -568,7 +568,7 @@ set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
IF (UseQt6)
qt_wrap_cpp(libgui_hdrs_moc ${libgui_hdrs})
qt_wrap_ui(libgui_ui_h ${libgui_ui})
qt_wrap_ui(libgui_ui_h ${libgui_ui} OPTIONS -c string)
qt_add_resources(libgui_resources_rcc ${libgui_resources})
ELSE()
qt5_wrap_cpp(libgui_hdrs_moc ${libgui_hdrs})

View File

@ -107,15 +107,15 @@ void ClusterDialog::updateTimeStamps()
time_t t;
t = obj->getInt("lastModified");
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
m_dialog->last_modified->setText((t)? dt.toString():"-");
t = obj->getInt("lastCompiled");
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
m_dialog->last_compiled->setText((t)? dt.toString():"-");
t = obj->getInt("lastInstalled");
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
m_dialog->last_installed->setText((t)? dt.toString():"-");
}
@ -197,8 +197,7 @@ void ClusterDialog::validate(bool *res)
QMessageBox::critical(
this,"Firewall Builder",
tr("Character \"/\" is not allowed in cluster object name"),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
blockSignals(false);
}
return;
@ -229,8 +228,7 @@ void ClusterDialog::applyChanges()
blockSignals(true);
autorename_chidren = (QMessageBox::warning(
this,"Firewall Builder", dialog_txt,
tr("&Yes"), tr("&No"), QString(),
0, 1 )==0 );
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes );
blockSignals(false);
}

View File

@ -337,7 +337,7 @@ void ClusterGroupDialog::openClusterConfDialog()
QMessageBox::critical(
this, "Firewall Builder",
tr("FWBuilder API error: %1").arg(ex.toString().c_str()),
tr("&Continue"), QString(), QString(), 0, 1);
QMessageBox::Ok);
return;
}
}

View File

@ -231,8 +231,7 @@ bool ClusterInterfaceWidget::isValid()
{
QMessageBox::warning(this,"Firewall Builder",
tr("Some of the cluster interfaces do not have any "
"member firewall interface selected"),
"&Continue", QString(), QString(), 0, 1 );
"member firewall interface selected"));
return false;
}
if (roots.values().contains(items.first()))
@ -241,8 +240,7 @@ bool ClusterInterfaceWidget::isValid()
QMessageBox::warning(this,"Firewall Builder",
tr("Please select interface of the member firewall "
"rather than the firewall object to be used "
"with cluster interface"),
"&Continue", QString(), QString(), 0, 1 );
"with cluster interface"));
return false;
}
if (!interfaceSelectable(ifacelist.list->selectedItems().first()->data(0, Qt::UserRole).value<Interface*>()))
@ -250,8 +248,7 @@ bool ClusterInterfaceWidget::isValid()
// selected interface item can not be used in this cluster
QMessageBox::warning(this,"Firewall Builder",
tr("%1 can not be used as cluster interface.")
.arg(ifacelist.list->selectedItems().first()->text(0)),
"&Continue", QString(), QString(), 0, 1 );
.arg(ifacelist.list->selectedItems().first()->text(0)));
return false;
}
}

View File

@ -173,8 +173,7 @@ bool ClusterInterfacesSelectorWidget::isValid()
{
QMessageBox::warning(this,"Firewall Builder",
tr("Interface %1 of firewall %2 is used in more than one cluster interface.")
.arg(iface1.second->getName().c_str()).arg(iface1.first->getName().c_str()),
"&Continue", QString(), QString(), 0, 1 );
.arg(iface1.second->getName().c_str()).arg(iface1.first->getName().c_str()));
return false;
}
}

View File

@ -84,14 +84,14 @@ void CompilerOutputPanel::loadFWObject(FWObject *obj)
BaseCompiler::errorRegExp(&err_re);
foreach(string re, err_re)
{
error_re.push_back(QRegExp(re.c_str()));
error_re.push_back(QRegularExpression(re.c_str()));
}
list<string> warn_re;
BaseCompiler::warningRegExp(&warn_re);
foreach(string re, warn_re)
{
warning_re.push_back(QRegExp(re.c_str()));
warning_re.push_back(QRegularExpression(re.c_str()));
}
QApplication::setOverrideCursor( QCursor( Qt::WaitCursor) );
@ -177,10 +177,10 @@ void CompilerOutputPanel::loadFWObject(FWObject *obj)
{
format = normal_format;
list<QRegExp>::const_iterator it;
list<QRegularExpression>::const_iterator it;
for (it=error_re.begin(); it!=error_re.end(); ++it)
{
if ((*it).indexIn(line) != -1)
if (line.indexOf(*it) != -1)
{
format = error_format;
break;
@ -189,7 +189,7 @@ void CompilerOutputPanel::loadFWObject(FWObject *obj)
for (it=warning_re.begin(); it!=warning_re.end(); ++it)
{
if ((*it).indexIn(line) != -1)
if (line.indexOf(*it) != -1)
{
format = warning_format;
break;

View File

@ -33,7 +33,7 @@
#include "fwbuilder/Rule.h"
#include "fwbuilder/Firewall.h"
#include <QRegExp>
#include <QRegularExpression>
#include <list>
@ -46,8 +46,8 @@ class CompilerOutputPanel : public BaseObjectDialog
libfwbuilder::RoutingRule *rule;
Ui::CompilerOutputPanel_q *m_widget;
std::list<QRegExp> error_re;
std::list<QRegExp> warning_re;
std::list<QRegularExpression> error_re;
std::list<QRegularExpression> warning_re;
public:

View File

@ -130,7 +130,7 @@ void DialogData::loadToWidget( DialogOption &dopt , bool override)
if (fwbdebug)
{
qDebug("loadToWidget -- QComboBox dopt.mapping.count()=%d",dopt.mapping.count());
qDebug() << QString("loadToWidget -- QComboBox dopt.mapping.count()=%1").arg(dopt.mapping.count());
qDebug("loadToWidget -- QComboBox s=%s",s.toLatin1().constData());
}

View File

@ -43,9 +43,8 @@
#include <QDir>
#include <QMainWindow>
#include <QDesktopWidget>
#include <QScreen>
#include <QUuid>
#include <QRegExp>
#include <QtDebug>
#include <QCryptographicHash>
#include <QTime>
@ -325,7 +324,7 @@ void FWBSettings::init(bool force_first_time_run)
if (app != nullptr)
{
QMessageBox::critical( 0,"Firewall Builder", err,
"&Continue", 0, 0, 0 );
QMessageBox::Ok);
} else
{
qDebug() << err;
@ -650,9 +649,8 @@ QPoint FWBSettings::getScreenPosition(const QString &wname)
int width = 150; // won't get closer to the screen edge than this
int height = 150;
QDesktopWidget *d = QApplication::desktop();
// get geometry of the screen that contains mw
QRect sg = d->screenGeometry(mw);
QRect sg = mw->screen()->availableGeometry();
if (x+width > sg.width()) x=sg.width()-width;
if (y+height > sg.height()) y=sg.height()-height;
@ -702,9 +700,9 @@ void FWBSettings::restoreGeometry(QWidget *w)
int width = val.section(',',2,2).toInt();
int height = val.section(',',3,3).toInt();
QDesktopWidget *d = QApplication::desktop();
// get geometry of the screen that contains mw
QRect sg = d->screenGeometry(mw);
QRect sg = mw->screen()->availableGeometry();
if (width > sg.width() || height > sg.height())
{
@ -738,9 +736,8 @@ void FWBSettings::restoreGeometry(QWidget *w, const QRect &dg)
int width = val.section(',',2,2).toInt();
int height = val.section(',',3,3).toInt();
QDesktopWidget *d = QApplication::desktop();
// get geometry of the screen that contains mw
QRect sg = d->screenGeometry(mw);
QRect sg = mw->screen()->availableGeometry();
if (width > sg.width() || height > sg.height())
{

View File

@ -31,7 +31,7 @@
#include <qobject.h>
#include <qtextstream.h>
#include <qdatetime.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <QtDebug>
#include "FWObjectPropertiesFactory.h"
@ -89,7 +89,11 @@ using namespace libfwbuilder;
QString FWObjectPropertiesFactory::getObjectPropertiesBrief(FWObject *obj)
{
QString res;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextStream str(&res, QIODevice::WriteOnly);
#else
QTextStream str(&res, QIODeviceBase::WriteOnly);
#endif
FWObject *parent_obj = obj->getParent();
try
@ -288,7 +292,11 @@ QString FWObjectPropertiesFactory::getObjectPropertiesBrief(FWObject *obj)
QString FWObjectPropertiesFactory::getObjectProperties(FWObject *obj)
{
QString res;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextStream str(&res, QIODevice::WriteOnly);
#else
QTextStream str(&res, QIODeviceBase::WriteOnly);
#endif
FWObject *parent_obj = obj->getParent();
try
@ -336,13 +344,13 @@ QString FWObjectPropertiesFactory::getObjectProperties(FWObject *obj)
QDateTime dt;
time_t t;
t = obj->getInt("lastModified");dt.setTime_t(t);
t = obj->getInt("lastModified");dt.setSecsSinceEpoch(t);
QString t_modified = (t)? dt.toString():"-";
t = obj->getInt("lastCompiled");dt.setTime_t(t);
t = obj->getInt("lastCompiled");dt.setSecsSinceEpoch(t);
QString t_compiled = (t)? dt.toString():"-";
t = obj->getInt("lastInstalled");dt.setTime_t(t);
t = obj->getInt("lastInstalled");dt.setSecsSinceEpoch(t);
QString t_installed = (t)? dt.toString():"-";
str << platform << "(" << readableVersion << ") / " << hostOS;
@ -480,9 +488,9 @@ QString FWObjectPropertiesFactory::stripHTML(const QString &str)
// note that str may contain multiple lines
// separated by <br> and/or '\n'
QRegExp htmltag1 = QRegExp("<[^>]+>");
QRegExp htmltag2 = QRegExp("</[^>]+>");
QRegExp htmltd = QRegExp("</td><td>");
QRegularExpression htmltag1 = QRegularExpression("<[^>]+>");
QRegularExpression htmltag2 = QRegularExpression("</[^>]+>");
QRegularExpression htmltd = QRegularExpression("</td><td>");
QString res = str;
res = res.replace(htmltd,": ");
@ -752,15 +760,15 @@ QString FWObjectPropertiesFactory::getObjectPropertiesDetailed(FWObject *obj,
time_t lc=obj->getInt("lastCompiled");
time_t li=obj->getInt("lastInstalled");
dt.setTime_t(lm);
dt.setSecsSinceEpoch(lm);
QString t_modified = (lm)? dt.toString():"-";
if (lm>lc && lm>li) t_modified=QString("<b>")+t_modified+"</b>";
dt.setTime_t(lc);
dt.setSecsSinceEpoch(lc);
QString t_compiled = (lc)? dt.toString():"-";
if (lc>lm && lc>li) t_compiled=QString("<b>")+t_compiled+"</b>";
dt.setTime_t(li);
dt.setSecsSinceEpoch(li);
QString t_installed = (li)? dt.toString():"-";
if (li>lc && li>lm) t_installed=QString("<b>")+t_installed+"</b>";

View File

@ -138,6 +138,7 @@
#include <QUndoStack>
#include <QUrl>
#include <qaction.h>
#include <QActionGroup>
#include <qapplication.h>
#include <qapplication.h>
#include <qcheckbox.h>
@ -766,8 +767,8 @@ void FWWindow::fileClose()
//updateGlobalToolbar();
}
if (fwbdebug) qDebug("subWindowList().size()=%d",
m_mainWindow->m_space->subWindowList().size());
if (fwbdebug) qDebug() << QString("subWindowList().size()=%1").arg(
m_mainWindow->m_space->subWindowList().size());
}
void FWWindow::fileExit()

View File

@ -155,7 +155,7 @@ void FWWindow::filePrint()
pdialog.setWindowTitle(tr("Print configuration of %1")
.arg(firewall_to_print->getName().c_str()));
#ifndef Q_OS_MACX
pdialog.addEnabledOption(QAbstractPrintDialog::PrintPageRange);
pdialog.setOption(QAbstractPrintDialog::PrintPageRange);
pdialog.setMinMax(1,9999);
pdialog.setPrintRange(QAbstractPrintDialog::AllPages);
#endif
@ -214,8 +214,7 @@ void FWWindow::filePrint()
QMessageBox::information(
this,"Firewall Builder",
tr("Printing aborted"),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
} else
showStatusBarMessage(tr("Printing completed"));

View File

@ -57,7 +57,7 @@
#include <qapplication.h>
#include <qstackedwidget.h>
#include <qcursor.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qtablewidget.h>
#include <qmessagebox.h>
@ -254,7 +254,7 @@ void FilterDialog::load()
void FilterDialog::update()
{
QRegExp r;
QRegularExpression r;
Filter newflt;
newflt.setMatchAny(m_dialog->combo->currentIndex());
@ -313,7 +313,7 @@ void FilterDialog::update()
bool FilterDialog::validate()
{
bool res=true;
QRegExp r;
QRegularExpression r;
int n=m_dialog->table->rowCount();
for(int i=0; i<n;i++)
@ -330,23 +330,22 @@ bool FilterDialog::validate()
return res;
}
QRegExp FilterDialog::constructRegExp(int p)
QRegularExpression FilterDialog::constructRegExp(int p)
{
QRegExp r;
QRegularExpression r;
QString buf;
r.setCaseSensitivity((m_dialog->case_sensitive->isChecked())?
Qt::CaseSensitive:Qt::CaseInsensitive);
r.setPatternOptions((m_dialog->case_sensitive->isChecked())?
QRegularExpression::NoPatternOption:QRegularExpression::CaseInsensitiveOption);
switch(((QComboBox*)m_dialog->table->cellWidget(p,1))->currentIndex())
{
case FWF_CONTAINS:
{
r.setPatternSyntax(QRegExp::Wildcard);
buf=m_dialog->table->item(p,2)->text().toLatin1().constData();
break;
}
{
buf=QRegularExpression::wildcardToRegularExpression(
m_dialog->table->item(p,2)->text().toLatin1().constData());
break;
}
case FWF_IS_EQUAL_TO:
{
r.setPatternSyntax(QRegExp::RegExp);
buf="^";
buf+=m_dialog->table->item(p,2)->text().toLatin1().constData();
buf+="$";
@ -354,27 +353,24 @@ QRegExp FilterDialog::constructRegExp(int p)
}
case FWF_STARTS_WITH:
{
r.setPatternSyntax(QRegExp::RegExp);
buf="^";
buf+=m_dialog->table->item(p,2)->text().toLatin1().constData();
break;
}
case FWF_ENDS_WITH:
{
r.setPatternSyntax(QRegExp::RegExp);
buf=m_dialog->table->item(p,2)->text().toLatin1().constData();
buf+="$";
break;
}
case FWF_MATCHES_WILDCARD:
{
r.setPatternSyntax(QRegExp::Wildcard);
buf=m_dialog->table->item(p,2)->text().toLatin1().constData();
buf=QRegularExpression::wildcardToRegularExpression(
m_dialog->table->item(p,2)->text().toLatin1().constData());
break;
}
case FWF_MATCHES_REGEXP:
{
r.setPatternSyntax(QRegExp::RegExp);
buf=m_dialog->table->item(p,2)->text().toLatin1().constData();
break;
}
@ -444,11 +440,11 @@ bool Filter::isCaseSens()
{
return CaseSensitive;
}
void Filter::addNameRegExp(const QRegExp &r)
void Filter::addNameRegExp(const QRegularExpression &r)
{
name_patterns.push_back(r);
}
void Filter::addAddrRegExp(const QRegExp &r)
void Filter::addAddrRegExp(const QRegularExpression &r)
{
addr_patterns.push_back(r);
}
@ -471,15 +467,6 @@ int Filter::getAddrPatternsNumber()
return addr_patterns.size();
}
bool Filter::isNameWildcard(int p)
{
return name_patterns[p].patternSyntax() == QRegExp::Wildcard;
}
bool Filter::isAddrWildcard(int p)
{
return addr_patterns[p].patternSyntax() == QRegExp::Wildcard;
}
Filter & Filter::operator=(const Filter& f)
{
addr_patterns=f.addr_patterns;
@ -508,11 +495,11 @@ Filter::~Filter()
}
void Filter::addNamePattern(const QString &s,bool wc)
{
name_patterns.push_back(QRegExp(s,Qt::CaseSensitive,wc?QRegExp::Wildcard:QRegExp::RegExp));
name_patterns.push_back(QRegularExpression(wc ? QRegularExpression::wildcardToRegularExpression(s) : s));
}
void Filter::addAddrPattern(const QString &s,bool wc)
{
addr_patterns.push_back(QRegExp(s,Qt::CaseSensitive,wc?QRegExp::Wildcard:QRegExp::RegExp));
addr_patterns.push_back(QRegularExpression(wc ? QRegularExpression::wildcardToRegularExpression(s) : s));
}
void Filter::clear()
{
@ -533,15 +520,15 @@ bool Filter::isMatchAny ()
}
bool Filter::testName(const QString &s)
{
int cmp;
qsizetype cmp;
if (name_patterns.isEmpty())
{
return addr_patterns.isEmpty() || !MatchAny;
}
for (int i=0;i<name_patterns.size();i++)
{
name_patterns[i].setCaseSensitivity(Qt::CaseSensitive);
cmp=name_patterns[i].indexIn(s);
name_patterns[i].setPatternOptions(addr_patterns[i].patternOptions() & ~QRegularExpression::CaseInsensitiveOption);
cmp=s.indexOf(name_patterns[i]);
if (MatchAny)
{
if(cmp>=0) return true;
@ -555,7 +542,7 @@ bool Filter::testName(const QString &s)
}
bool Filter::testAddr(const QString &s)
{
int cmp;
qsizetype cmp;
if (addr_patterns.isEmpty())
{
return (name_patterns.isEmpty() || !MatchAny);
@ -563,8 +550,8 @@ bool Filter::testAddr(const QString &s)
for (int i=0;i<addr_patterns.size();i++)
{
addr_patterns[i].setCaseSensitivity(Qt::CaseSensitive);
cmp=addr_patterns[i].indexIn(s);
addr_patterns[i].setPatternOptions(addr_patterns[i].patternOptions() & ~QRegularExpression::CaseInsensitiveOption);
cmp=s.indexOf(addr_patterns[i]);
if (MatchAny)
{
if(cmp>=0) return true;

View File

@ -34,7 +34,7 @@
#include <qvector.h>
#include <QDialog>
class QRegExp;
class QRegularExpression;
class ObjectDescriptor;
enum {FWF_ANY = 0, FWF_ALL = 1};
@ -52,8 +52,8 @@ class Filter
bool CaseSensitive;
bool MatchAny;
QVector<QRegExp> addr_patterns;
QVector<QRegExp> name_patterns;
QVector<QRegularExpression> addr_patterns;
QVector<QRegularExpression> name_patterns;
public:
@ -62,9 +62,9 @@ public:
~Filter();
void addNamePattern(const QString &s,bool wc);
void addNameRegExp(const QRegExp &r);
void addNameRegExp(const QRegularExpression &r);
void addAddrPattern(const QString &s,bool wc);
void addAddrRegExp(const QRegExp &r);
void addAddrRegExp(const QRegularExpression &r);
void setCaseSens(bool b);
bool isCaseSens ();
@ -84,8 +84,6 @@ public:
QString getNamePatternString(int p);
QString getAddrPatternString(int p);
bool isNameWildcard(int p);
bool isAddrWildcard(int p);
Filter& operator=(const Filter& f);
};
@ -101,7 +99,7 @@ class FilterDialog : public QDialog
bool validate();
void update();
QString LastFile;
QRegExp constructRegExp(int p);
QRegularExpression constructRegExp(int p);
public:
FilterDialog(QWidget *parent);
~FilterDialog();

View File

@ -61,7 +61,7 @@
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qcursor.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qapplication.h>
#include <qmessagebox.h>
#include <qpushbutton.h>
@ -245,8 +245,8 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
if (m_widget->useRegexp->isChecked())
{
res = (name.indexOf( QRegExp(s) )!=-1 ||
(!label.isEmpty() && label.indexOf( QRegExp(s) )!=-1));
res = (name.indexOf( QRegularExpression(s) )!=-1 ||
(!label.isEmpty() && label.indexOf( QRegularExpression(s) )!=-1));
} else
{
res = (name == s || (!label.isEmpty() && label == s));
@ -292,7 +292,7 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
QString addr = inet_addr->toString().c_str();
if (m_widget->useRegexp->isChecked())
res = ( addr.indexOf( QRegExp(s) )!=-1 );
res = ( addr.indexOf( QRegularExpression(s) )!=-1 );
else
res= ( addr == s );
}
@ -308,13 +308,13 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
{
QString port;
port.setNum(TCPUDPService::cast(obj)->getSrcRangeStart());
res |= ( port.indexOf( QRegExp(s) )!=-1 );
res |= ( port.indexOf( QRegularExpression(s) )!=-1 );
port.setNum(TCPUDPService::cast(obj)->getSrcRangeEnd());
res |= ( port.indexOf( QRegExp(s) )!=-1 );
res |= ( port.indexOf( QRegularExpression(s) )!=-1 );
port.setNum(TCPUDPService::cast(obj)->getDstRangeStart());
res |= ( port.indexOf( QRegExp(s) )!=-1 );
res |= ( port.indexOf( QRegularExpression(s) )!=-1 );
port.setNum(TCPUDPService::cast(obj)->getDstRangeEnd());
res |= ( port.indexOf( QRegExp(s) )!=-1 );
res |= ( port.indexOf( QRegularExpression(s) )!=-1 );
} else
{
bool conversion_status = false;
@ -339,7 +339,7 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
{
QString proto;
proto.setNum(obj->getInt("protocol_num"));
res |= ( proto.indexOf( QRegExp(s) )!=-1 );
res |= ( proto.indexOf( QRegularExpression(s) )!=-1 );
} else
{
bool conversion_status = false;
@ -357,7 +357,7 @@ bool FindObjectWidget::matchAttr(FWObject *obj)
{
QString icmptype;
icmptype.setNum(obj->getInt("type"));
res |= ( icmptype.indexOf( QRegExp(s) )!=-1 );
res |= ( icmptype.indexOf( QRegularExpression(s) )!=-1 );
} else
{
bool conversion_status = false;
@ -464,21 +464,30 @@ loop:
reset();
if (m_widget->srScope->currentIndex()==3) // scope ==selected firewalls
{
if ( QMessageBox::warning(
this,"Firewall Builder",
tr("Search hit the end of the policy rules."),
tr("&Continue at top"), tr("&Stop"), QString(), 0, 1 )==0 )
goto loop;
QMessageBox msgBox;
msgBox.setWindowTitle("Firewall Builder");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Search hit the end of the policy rules."));
QPushButton *continueButton = msgBox.addButton(tr("&Continue at top"), QMessageBox::AcceptRole);
msgBox.addButton(tr("&Strop"), QMessageBox::RejectRole);
msgBox.exec();
if (msgBox.clickedButton() == continueButton) goto loop;
}
else
{
if (fwbdebug) qDebug("widget that has focus: %p",mw->focusWidget());
bool r= ( QMessageBox::warning(
this,"Firewall Builder",
tr("Search hit the end of the object tree."),
tr("&Continue at top"), tr("&Stop"), QString(), 0, 1 )==0);
QMessageBox msgBox;
msgBox.setWindowTitle("Firewall Builder");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Search hit the end of the object tree."));
QPushButton *continueButton = msgBox.addButton(tr("&Continue at top"), QMessageBox::AcceptRole);
msgBox.addButton(tr("&Strop"), QMessageBox::RejectRole);
msgBox.exec();
QAbstractButton * const response = msgBox.clickedButton();
if (fwbdebug) qDebug("widget that has focus: %p",mw->focusWidget());
if (r) goto loop;
if (response == continueButton) goto loop;
}
return;
}

View File

@ -62,7 +62,6 @@
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qcursor.h>
#include <qregexp.h>
#include <qapplication.h>
#include <qmessagebox.h>
#include <qpushbutton.h>

View File

@ -156,15 +156,15 @@ void FirewallDialog::updateTimeStamps()
time_t t;
t = obj->getInt("lastModified");
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
m_dialog->last_modified->setText((t)? dt.toString():"-");
t = obj->getInt("lastCompiled");
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
m_dialog->last_compiled->setText((t)? dt.toString():"-");
t = obj->getInt("lastInstalled");
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
m_dialog->last_installed->setText((t)? dt.toString():"-");
}
@ -246,9 +246,7 @@ void FirewallDialog::validate(bool *res)
blockSignals(true);
QMessageBox::critical(
this,"Firewall Builder",
tr("Character \"/\" is not allowed in firewall object name"),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("Character \"/\" is not allowed in firewall object name"));
blockSignals(false);
}
return;
@ -294,8 +292,7 @@ void FirewallDialog::applyChanges()
blockSignals(true);
autorename_chidren = (QMessageBox::warning(
this,"Firewall Builder", dialog_txt,
tr("&Yes"), tr("&No"), QString(),
0, 1 )==0 );
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes );
blockSignals(false);
}
@ -367,9 +364,7 @@ void FirewallDialog::applyChanges()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("Platform setting can not be empty"),
tr("&Continue"), nullptr, nullptr,
0 );
tr("Platform setting can not be empty"));
return;
}
@ -377,9 +372,7 @@ void FirewallDialog::applyChanges()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("Host OS setting can not be empty"),
tr("&Continue"), nullptr, nullptr,
0 );
tr("Host OS setting can not be empty"));
return;
}
@ -418,9 +411,7 @@ void FirewallDialog::openFWDialog()
{
QMessageBox::critical(
this,"Firewall Builder",
tr("FWBuilder API error: %1").arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("FWBuilder API error: %1").arg(ex.toString().c_str()));
return;
}
}
@ -441,9 +432,7 @@ void FirewallDialog::openOSDialog()
{
QMessageBox::critical(
this,"Firewall Builder",
tr("FWBuilder API error: %1").arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("FWBuilder API error: %1").arg(ex.toString().c_str()));
return;
}
}

View File

@ -47,7 +47,6 @@
#include <QFileInfo>
#include <QMessageBox>
#include <QString>
#include <QTextCodec>
#include <QTextStream>
#include <QTimer>
#include <QtDebug>
@ -296,8 +295,7 @@ bool FirewallInstaller::readManifest(const QString &script,
{
QMessageBox::critical(
inst_dlg, "Firewall Builder",
tr("Generated script file %1 not found.").arg(script),
tr("&Continue") );
tr("Generated script file %1 not found.").arg(script));
return false;
}
}

View File

@ -122,9 +122,7 @@ bool FirewallInstallerCisco::packInstallJobsList(Firewall*)
{
QMessageBox::critical(
inst_dlg, "Firewall Builder",
tr("Can not read generated script %1").arg(ff),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("Can not read generated script %1").arg(ff));
return false;
}

View File

@ -120,9 +120,7 @@ bool FirewallInstallerJuniper::packInstallJobsList(Firewall*)
{
QMessageBox::critical(
inst_dlg, "Firewall Builder",
tr("Can not read generated script %1").arg(ff),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("Can not read generated script %1").arg(ff));
return false;
}

View File

@ -101,9 +101,7 @@ bool FirewallInstallerProcurve::packInstallJobsList(Firewall*)
{
QMessageBox::critical(
inst_dlg, "Firewall Builder",
tr("Can not read generated script %1").arg(ff),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("Can not read generated script %1").arg(ff));
return false;
}

View File

@ -50,8 +50,9 @@
#include <errno.h>
#include <iostream>
#include <fcntl.h>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include <QTextStream>
#include <QTimer>
#include <QMessageBox>
@ -104,7 +105,9 @@ bool FirewallInstallerUnx::packInstallJobsList(Firewall* fw)
* other files are located there as well.
*/
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
//key: local_file_name val: remote_file_name
QMap<QString,QString> all_files;
@ -135,9 +138,7 @@ bool FirewallInstallerUnx::packInstallJobsList(Firewall* fw)
inst_dlg, "Firewall Builder",
tr("Incorrect manifest format in generated script. "
"Line with \"*\" is missing, can not find any files "
"to copy to the firewall.\n%1").arg(cnf->script),
tr("&Continue"), QString(),QString(),
0, 1 );
"to copy to the firewall.\n%1").arg(cnf->script));
return false;
}

View File

@ -133,8 +133,7 @@ bool FirewallSelectorWidget::isValid()
QMessageBox::critical(
this, "Firewall Builder",
tr("You should select at least one firewall to use "
"with the cluster"),
"&Continue", QString(), QString(), 0, 1);
"with the cluster"));
return false;
}
for ( int i = 0; i < fws.count(); i++)
@ -144,8 +143,7 @@ bool FirewallSelectorWidget::isValid()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("Host operation systems of chosen firewalls are different"),
"&Continue", QString(), QString(), 0, 1);
tr("Host operation systems of chosen firewalls are different"));
return false;
}
if (platform.isEmpty()) platform = fws.at(i).first->getStr("platform").c_str();
@ -153,8 +151,7 @@ bool FirewallSelectorWidget::isValid()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("Platforms of chosen firewalls are different"),
"&Continue", QString(), QString(), 0, 1);
tr("Platforms of chosen firewalls are different"));
return false;
}
#ifdef COMPARE_MEMBER_VERSIONS_FOR_CLUSTER
@ -221,8 +218,7 @@ bool FirewallSelectorWidget::isValid()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("Cluster firewalls should have at least one common inteface"),
"&Continue", QString(), QString(), 0, 1);
tr("Cluster firewalls should have at least one common inteface"));
}
return ok;
}

View File

@ -137,8 +137,7 @@ void HostDialog::applyChanges()
blockSignals(true);
autorename_chidren = (QMessageBox::warning(
this,"Firewall Builder", dialog_txt,
tr("&Yes"), tr("&No"), QString(),
0, 1 )==0 );
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes );
blockSignals(false);
}

View File

@ -152,9 +152,7 @@ void IPv4Dialog::validate(bool *result)
blockSignals(true);
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
tr("Illegal IP address '%1'").arg(m_dialog->address->text()));
blockSignals(false);
}
}
@ -174,9 +172,7 @@ void IPv4Dialog::validate(bool *result)
// Do not allow netmask with zeroes inside.
QMessageBox::critical(
this, "Firewall Builder",
tr("Netmasks with zeroes in the middle are not supported"),
tr("&Continue"), 0, 0,
0 );
tr("Netmasks with zeroes in the middle are not supported"));
blockSignals(false);
}
return;
@ -190,9 +186,7 @@ void IPv4Dialog::validate(bool *result)
blockSignals(true);
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(m_dialog->netmask->text()),
tr("&Continue"), 0, 0,
0 );
tr("Illegal netmask '%1'").arg(m_dialog->netmask->text()));
blockSignals(false);
}
}
@ -281,15 +275,13 @@ void IPv4Dialog::DNSlookup()
QMessageBox::warning(
this,"Firewall Builder",
tr("DNS lookup failed for both names of the address object '%1' and the name of the host '%2'.")
.arg(m_dialog->obj_name->text()).arg(name),
"&Continue", QString(),QString(), 0, 1 );
.arg(m_dialog->obj_name->text()).arg(name));
return;
}
QMessageBox::warning(
this,"Firewall Builder",
tr("DNS lookup failed for name of the address object '%1'.")
.arg(name),
"&Continue", QString(),QString(), 0, 1 );
.arg(name));
return;
}
}

View File

@ -154,9 +154,7 @@ void IPv6Dialog::validate(bool *res)
{
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
tr("Illegal IP address '%1'").arg(m_dialog->address->text()));
blockSignals(false);
}
}
@ -175,9 +173,7 @@ void IPv6Dialog::validate(bool *res)
{
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(m_dialog->netmask->text()),
tr("&Continue"), 0, 0,
0 );
tr("Illegal netmask '%1'").arg(m_dialog->netmask->text()));
blockSignals(false);
}
}
@ -278,15 +274,13 @@ void IPv6Dialog::DNSlookup()
QMessageBox::warning(
this,"Firewall Builder",
tr("DNS lookup failed for both names of the address object '%1' and the name of the host '%2'.")
.arg(m_dialog->obj_name->text()).arg(name),
"&Continue", QString(),QString(), 0, 1 );
.arg(m_dialog->obj_name->text()).arg(name));
return;
}
QMessageBox::warning(
this,"Firewall Builder",
tr("DNS lookup failed for name of the address object '%1'.")
.arg(name),
"&Continue", QString(),QString(), 0, 1 );
.arg(name));
return;
}
}

View File

@ -351,8 +351,7 @@ void InterfaceDialog::validate(bool *res)
QMessageBox::critical(
this,"Firewall Builder",
err,
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
blockSignals(false);
}
return;
@ -385,8 +384,7 @@ void InterfaceDialog::validate(bool *res)
QMessageBox::critical(
this,"Firewall Builder",
err,
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
blockSignals(false);
}
}
@ -425,8 +423,7 @@ void InterfaceDialog::applyChanges()
blockSignals(true);
autorename_children = (QMessageBox::warning(
this, "Firewall Builder", dialog_txt,
tr("&Yes"), tr("&No"), QString(),
0, 1 )==0 );
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes );
blockSignals(false);
}
@ -537,8 +534,7 @@ void InterfaceDialog::openIfaceDialog()
QMessageBox::critical(
this,"Firewall Builder",
tr("FWBuilder API error: %1").arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
return;
}
}

View File

@ -521,6 +521,5 @@ void InterfaceEditorWidget::setError(const QString &title,
void InterfaceEditorWidget::showError()
{
QMessageBox::warning(this, errorTitle, errorText, "&Continue",
QString(), QString(), 0, 1);
QMessageBox::warning(this, errorTitle, errorText);
}

View File

@ -136,8 +136,7 @@ bool KeywordsDialog::validateKeyword(QWidget *parent, const QString &keyword)
if (keyword.isEmpty()) return false;
if (keyword.contains(',')) {
QMessageBox::warning(parent, "Firewall Builder",
tr("Keyword cannot contain a comma"), "&OK",
QString(), QString(), 0, 1);
tr("Keyword cannot contain a comma"));
return false;
}

View File

@ -144,8 +144,7 @@ void NetworkDialog::validate(bool *result)
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal IP address '%1'").arg(m_dialog->address->text()),
tr("&Continue"), 0, 0,
0 );
QMessageBox::Ok);
blockSignals(false);
}
return;
@ -173,8 +172,7 @@ void NetworkDialog::validate(bool *result)
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal netmask '%1'").arg( m_dialog->netmask->text() ),
tr("&Continue"), 0, 0,
0 );
QMessageBox::Ok);
return;
}
}
@ -195,8 +193,7 @@ void NetworkDialog::validate(bool *result)
QMessageBox::critical(
this, "Firewall Builder",
tr("Network object should not have netmask '0.0.0.0'"),
tr("&Continue"), 0, 0,
0 );
QMessageBox::Ok);
blockSignals(false);
}
return;
@ -213,8 +210,7 @@ void NetworkDialog::validate(bool *result)
QMessageBox::critical(
this, "Firewall Builder",
tr("Netmasks with zeroes in the middle are not supported"),
tr("&Continue"), 0, 0,
0 );
QMessageBox::Ok);
blockSignals(false);
}
return;
@ -230,8 +226,7 @@ void NetworkDialog::validate(bool *result)
QMessageBox::critical(
this, "Firewall Builder",
tr("Illegal netmask '%1'").arg( m_dialog->netmask->text() ),
tr("&Continue"), 0, 0,
0 );
QMessageBox::Ok);
blockSignals(false);
}
}

View File

@ -126,9 +126,7 @@ void NetworkDialogIPv6::validate(bool *res)
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal IPv6 address '%1'").arg(
m_dialog->address->text()),
tr("&Continue"), nullptr, nullptr,
0 );
m_dialog->address->text()));
blockSignals(false);
}
}
@ -148,9 +146,7 @@ void NetworkDialogIPv6::validate(bool *res)
blockSignals(true);
QMessageBox::critical(this, "Firewall Builder",
tr("Illegal netmask '%1'").arg(
m_dialog->netmask->text() ),
tr("&Continue"), nullptr, nullptr,
0 );
m_dialog->netmask->text()));
blockSignals(false);
}
}

View File

@ -47,6 +47,7 @@
#include <qpushbutton.h>
#include <qmap.h>
#include <QtDebug>
#include <QStyle>
#include <iostream>
#include <sstream>
@ -64,7 +65,7 @@ ObjConflictResolutionDialog::ObjConflictResolutionDialog(QWidget *parent): QDial
alwaysCurrent=false;
alwaysNew =false;
m_dialog->dlgIcon->setPixmap( QMessageBox::standardIcon( QMessageBox::Warning ) );
m_dialog->dlgIcon->setPixmap( this->style()->standardPixmap(QStyle::SP_MessageBoxWarning));
defaultLeftButtonText = tr("Keep current object");
defaultRightButtonText = tr("Replace with this object");

View File

@ -91,6 +91,7 @@
#include <QUndoStack>
#include <QMenu>
#include <QAction>
#include <QRegularExpression>
#include <memory>
#include <algorithm>
@ -311,11 +312,13 @@ QString ObjectManipulator::makeNameUnique(FWObject* parent,
if (obj_type == Interface::TYPENAME)
{
QRegExp rx("([a-zA-Z-]+)(\\d{1,})");
if (rx.indexIn(obj_name) != -1)
QRegularExpression rx("([a-zA-Z-]+)(\\d{1,})");
QRegularExpressionMatch match;
if (obj_name.indexOf(rx, 0, &match) != -1)
{
basename = rx.cap(1);
suffix = rx.cap(2).toInt();
basename = match.captured(1);
suffix = match.captured(2).toInt();
}
}
@ -1203,7 +1206,7 @@ void ObjectManipulator::filterFirewallsFromSelection(vector<FWObject*> &so,
QMessageBox::warning(this, "Firewall Builder",
QObject::tr("No firewalls assigned to cluster '%1'").
arg(cl->getName().c_str()),
"&Continue", QString(), QString(), 0, 1 );
QMessageBox::Ok);
continue;
}
fo.insert(cl);
@ -1253,8 +1256,7 @@ FWObject* ObjectManipulator::prepareForInsertion(FWObject *target, FWObject *obj
QMessageBox::critical(
this,"Firewall Builder",
err,
"&Continue", QString(), QString(),
0, 1 );
QMessageBox::Ok);
return nullptr;
}

View File

@ -340,8 +340,7 @@ FWObject* ObjectManipulator::createObject(const QString &objType,
"corresponding branch is missing in the object tree.\n"
"Please repair the tree using command 'fwbedit checktree -f file.fwb'.")
.arg(objType),
"&Continue", QString(), QString(),
0, 1 );
QMessageBox::Ok);
return nullptr;
}
@ -640,7 +639,7 @@ FWObject* ObjectManipulator::newStateSyncClusterGroup(QUndoCommand* macro)
QMessageBox::warning(
this,"Firewall Builder",
tr("Cluster host OS %1 does not support state synchronization").arg(host_os),
"&Continue", QString(), QString(), 0, 1 );
QMessageBox::Ok);
return nullptr;
}

View File

@ -415,8 +415,7 @@ FWObject* ObjectManipulator::actuallyPasteTo(FWObject *target,
QMessageBox::warning(
this,"Firewall Builder",
ex.toString().c_str(),
"&Continue", QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
return nullptr;
@ -592,8 +591,7 @@ void ObjectManipulator::deleteObject(FWObject *obj, QUndoCommand* macro)
QMessageBox::warning(
this,"Firewall Builder",
ex.toString().c_str(),
"&Continue", QString(),QString(),
0, 1 );
QMessageBox::Ok);
throw(ex);
}
@ -765,8 +763,8 @@ void ObjectManipulator::addSubfolderSlot()
if (folder.isEmpty()) return;
if (folder.contains(',')) {
QMessageBox::warning(this, "Firewall Builder",
tr("Subfolder cannot contain a comma"), "&OK",
QString(), QString(), 0, 1);
tr("Subfolder cannot contain a comma"),
QMessageBox::Ok);
return;
}
@ -870,8 +868,8 @@ void ObjectManipulator::renameUserFolder()
if (newFolderName.isEmpty()) return;
if (newFolderName.contains(',')) {
QMessageBox::warning(this, "Firewall Builder",
tr("Subfolder cannot contain a comma"), "&OK",
QString(), QString(), 0, 1);
tr("Subfolder cannot contain a comma"),
QMessageBox::Ok);
return;
}

View File

@ -335,8 +335,7 @@ void ObjectManipulator::delObj(QUndoCommand* macro)
"disappear from the tree and all groups and rules that reference them.\n"
"Do you still want to delete library %1?")
.arg(QString::fromUtf8(obj->getName().c_str())),
tr("&Yes"), tr("&No"), QString(),
0, 1 )!=0 ) continue;
QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes ) continue;
}
if (mw->isEditorVisible() && mw->getOpenedEditor()==obj)

View File

@ -83,7 +83,6 @@
#include <QPixmap>
#include <QMdiSubWindow>
#include <QMdiArea>
#include <QRegExp>
#include <QUndoStack>
#include <QScrollBar>

View File

@ -69,6 +69,7 @@
#include <QtDebug>
#include <qpainter.h>
#include <qpixmapcache.h>
#include <QRegularExpression>
#include <iostream>
#include <algorithm>
@ -535,7 +536,11 @@ void ObjectTreeView::dragMoveEvent(QDragMoveEvent *ev)
list<FWObject*> objs;
if (ev->source() != this || !FWObjectDrag::decode(ev, objs) ||
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
!isValidDropTarget(itemAt(ev->pos()), objs)) {
#else
!isValidDropTarget(itemAt(ev->position().toPoint()), objs)) {
#endif
ev->setAccepted(false);
return;
}
@ -551,7 +556,11 @@ void ObjectTreeView::dropEvent(QDropEvent *ev)
if (ev->source() == nullptr) return;
ObjectTreeViewItem *dest =
dynamic_cast<ObjectTreeViewItem *>(itemAt(ev->pos()));
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
dynamic_cast<ObjectTreeViewItem *>(itemAt(ev->pos()));
#else
dynamic_cast<ObjectTreeViewItem *>(itemAt(ev->position().toPoint()));
#endif
if (dest == nullptr) {
notWanted:
ev->setAccepted(false);
@ -881,23 +890,24 @@ static bool filterMatchesPortRange(const QStringList &args,
TCPUDPService *service = dynamic_cast<TCPUDPService*>(obj);
if (!service) return false;
QRegExp rx("\\s*([><]?)\\s*(\\d*)(?:-(\\d*))?");
QRegularExpression rx = QRegularExpression(QRegularExpression::anchoredPattern("\\s*([><]?)\\s*(\\d*)(?:-(\\d*))?"));
QRegularExpressionMatch match;
foreach (const QString &arg, args) {
if (!rx.exactMatch(arg)) continue;
if (!rx.match(arg).hasMatch()) continue;
int lowerBound = rx.cap(2).toInt(), upperBound = lowerBound;
int lowerBound = match.captured(2).toInt(), upperBound = lowerBound;
if (rx.pos(3) != -1) {
upperBound = rx.cap(3).toInt();
if (match.capturedStart(3) != -1) {
upperBound = match.captured(3).toInt();
}
if (rx.pos(1) != -1) {
if (rx.pos(3) != -1) // [><] cannot be combined with range
if (match.capturedStart(1) != -1) {
if (match.capturedStart(3) != -1) // [><] cannot be combined with range
continue;
if (rx.cap(1) == ">") {
if (match.captured(1) == ">") {
upperBound = 65535;
++lowerBound; // Adjust for using >= below
} else {// "<"
@ -936,22 +946,23 @@ static bool filterMatchesIpAddress(const QStringList &args,
Address *addr = dynamic_cast<Address*>(obj);
if (!addr) return false;
QRegExp rx("\\s*([.:0-9a-fA-F]+)(?:/([.:0-9a-fA-F]+))?");
QRegularExpression rx = QRegularExpression(QRegularExpression::anchoredPattern("\\s*([.:0-9a-fA-F]+)(?:/([.:0-9a-fA-F]+))?"));
QRegularExpressionMatch match;
InetAddrMask searchAddrAndMask;
foreach (const QString &arg, args) {
if (!rx.exactMatch(arg)) continue;
if (!rx.match(arg).hasMatch()) continue;
try {
std::string netmask = rx.cap(2).isEmpty() ? "32" : rx.cap(2).toStdString();
InetAddr ipv4addr(rx.cap(1).toStdString());
std::string netmask = match.captured(2).isEmpty() ? "32" : match.captured(2).toStdString();
InetAddr ipv4addr(match.captured(1).toStdString());
InetAddr ipv4mask(netmask);
searchAddrAndMask = InetAddrMask(ipv4addr, ipv4mask);
} catch (const FWException &) { // Could not create IPv4 object. Trying IPv6.
try {
int netmask = rx.cap(2).isEmpty() ? 128 : rx.cap(2).toInt();
InetAddr ipv6addr(AF_INET6, rx.cap(1).toStdString());
int netmask = match.captured(2).isEmpty() ? 128 : match.captured(2).toInt();
InetAddr ipv6addr(AF_INET6, match.captured(1).toStdString());
InetAddr ipv6mask(AF_INET6, netmask);
searchAddrAndMask = InetAddrMask(ipv6addr, ipv6mask);
} catch (const FWException &) { // Could not create IPv6 object.
@ -993,16 +1004,14 @@ static bool filterMatchesIpAddress(const QStringList &args,
static bool filterMatchesCommand(const QString &text,
ObjectTreeViewItem *item)
{
QRegExp rx("(?:(port)|(ip)):(.*)", Qt::CaseInsensitive);
if (!rx.exactMatch(text)) return false;
QRegularExpression rx = QRegularExpression(QRegularExpression::anchoredPattern("(?:(port)|(ip)):(.*)"), QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList args = rx.cap(3).split(",", Qt::SkipEmptyParts);
#else
QStringList args = rx.cap(3).split(",", QString::SkipEmptyParts);
#endif
if (!rx.match(text).hasMatch()) return false;
if (rx.pos(1) != -1)
QStringList args = match.captured(3).split(",", Qt::SkipEmptyParts);
if (match.capturedStart(1) != -1)
return (filterMatchesPortRange(args, item->getFWObject()));
else
return (filterMatchesIpAddress(args, item->getFWObject()));

View File

@ -40,9 +40,7 @@
#include <vector>
#include <set>
namespace libfwbuilder {
class FWObject;
};
#include <libfwbuilder/src/fwbuilder/FWObject.h>
class ProjectPanel;
class ObjectTreeViewItem;

View File

@ -95,31 +95,31 @@ bool ProjectPanel::saveIfModified(bool include_discard_button)
{
switch (QMessageBox::information(this, "Firewall Builder",
message,
tr("&Save"), tr("&Discard"), tr("&Cancel"),
0, // Enter = button 0
2 ) ) // Escape == button 2
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel))
{
case 0:
case QMessageBox::Save:
save();
break;
case 1: // discard
case QMessageBox::Discard:
db()->setDirty(false);
break;
case 2: // cancel
case QMessageBox::Cancel:
return false;
default:
return false;
}
} else
{
switch (QMessageBox::information(this, "Firewall Builder",
message,
tr("&Save"),tr("&Cancel"),
nullptr, // Enter = button 0
1 ) ) // Escape == button 1
QMessageBox::Save | QMessageBox::Cancel))
{
case 0:
case QMessageBox::Save:
save();
break;
case 1: // cancel
case QMessageBox::Cancel:
return false;
default:
return false;
}
}
@ -364,9 +364,8 @@ void ProjectPanel::fileDiscard()
"copy of its head revision from RCS."
"\n"
"All changes will be lost if you do this.\n"),
tr("&Discard changes"),
tr("&Cancel"), QString(),
1 )==0 )
QMessageBox::Discard | QMessageBox::Cancel,
QMessageBox::Cancel) == QMessageBox::Discard )
{
/* need to close the file without asking and saving, then
* reopen it again
@ -414,8 +413,7 @@ void ProjectPanel::fileAddToRCS()
QMessageBox::information(
this,"Firewall Builder",
tr("File %1 has been added to RCS.").arg(rcs->getFileName()),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
}
catch (FWException &ex)
@ -423,8 +421,7 @@ void ProjectPanel::fileAddToRCS()
QMessageBox::critical(
this,"Firewall Builder",
tr("Error adding file to RCS:\n%1").arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
QCoreApplication::postEvent(mw, new updateSubWindowTitlesEvent());
@ -500,8 +497,7 @@ void ProjectPanel::fileCompare()
this,"Firewall Builder",
tr("Error loading file %1:\n%2").
arg(fname1).arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
return;
}
@ -519,8 +515,7 @@ void ProjectPanel::fileCompare()
this,"Firewall Builder",
tr("Error loading file %1:\n%2").
arg(fname2).arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
return;
}
@ -574,8 +569,7 @@ void ProjectPanel::fileCompare()
QMessageBox::critical(
this,"Firewall Builder",
tr("Can not open report file for writing. File '%1'").arg(fn),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
}
@ -586,8 +580,7 @@ void ProjectPanel::fileCompare()
this,"Firewall Builder",
tr("Unexpected error comparing files %1 and %2:\n%3").
arg(fname1).arg(fname2).arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
}
@ -615,8 +608,7 @@ void ProjectPanel::fileExport()
QMessageBox::critical(
this,"Firewall Builder",
tr("Please select a library you want to export."),
"&Continue", QString(),QString(),
0, 1 );
QMessageBox::Ok);
return;
}
@ -640,8 +632,8 @@ void ProjectPanel::fileExport()
this,"Firewall Builder",
tr("The file %1 already exists.\nDo you want to overwrite it ?")
.arg(fname),
tr("&Yes"), tr("&No"), QString(),
0, 1 )==1 ) return;
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No) == QMessageBox::No ) return;
st->setOpenFileDir(path);
exportLibraryTo(fname,selectedLibs,ed.m_dialog->exportRO->isChecked());
@ -808,8 +800,7 @@ void ProjectPanel::exportLibraryTo(QString fname,list<FWObject*> &selectedLibs,
this,"Firewall Builder",
QObject::tr("Error saving file %1: %2")
.arg(fname).arg(err),
"&Continue", QString(), QString(),
0, 1 );
QMessageBox::Ok);
}
}
@ -914,8 +905,7 @@ FWObject* ProjectPanel::loadLibrary(const string &libfpath)
tr("The program encountered error trying to load file %1.\n"
"The file has not been loaded. Error:\n%2").
arg(libfpath.c_str()).arg(error_txt),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
return last_new_lib;
}
@ -1005,8 +995,7 @@ void ProjectPanel::loadStandardObjects()
QMessageBox::critical(
this,"Firewall Builder",
tr("Error loading file:\n%1").arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
}
@ -1197,8 +1186,7 @@ bool ProjectPanel::loadFromRCS(RCS *_rcs)
"but file '%3' already exists.\n"
"Choose a different name for the new file.")
.arg(fn).arg(newFileName).arg(newFileName),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
newFileName = chooseNewFileName(
fn, tr("Choose name and location for the new file"));
@ -1213,8 +1201,7 @@ bool ProjectPanel::loadFromRCS(RCS *_rcs)
this,"Firewall Builder",
tr("Load operation cancelled and data file reverted"
"to original version."),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
loadStandardObjects();
return false;
@ -1230,8 +1217,7 @@ bool ProjectPanel::loadFromRCS(RCS *_rcs)
tr("Firewall Builder uses file extension '.fwb'. Your data"
"file '%1' \nhas been renamed '%2'")
.arg(fn).arg(newFileName),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
fn = newFileName;
@ -1273,8 +1259,7 @@ bool ProjectPanel::loadFromRCS(RCS *_rcs)
this,"Firewall Builder",
tr("The program encountered error trying to load data file.\n"
"The file has not been loaded. Error:\n%1").arg(msg),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
} else
{
// this was not XML error, perhaps permissions or other
@ -1292,8 +1277,7 @@ bool ProjectPanel::loadFromRCS(RCS *_rcs)
tr("The program encountered error trying to load data file.\n"
"The file has not been loaded. Error:\n%1").arg(
error_txt),
tr("&Continue"), QString(),QString(),
0, 1 );
QMessageBox::Ok);
}
// load standard objects so the window does not remain empty
loadStandardObjects();
@ -1382,8 +1366,7 @@ bool ProjectPanel::checkin(bool unlock)
this,"Firewall Builder",
tr("Error checking in file %1:\n%2")
.arg(rcs->getFileName()).arg(ex.toString().c_str()),
tr("&Continue"), QString(), QString(),
0, 1 );
QMessageBox::Ok);
}
/***********************************************************************/
return true;
@ -1507,8 +1490,7 @@ void ProjectPanel::save()
this,"Firewall Builder",
tr("Error saving file %1: %2")
.arg(rcs->getFileName()).arg(err),
tr("&Continue"), QString(), QString(),
0, 1 );
QMessageBox::Ok);
}
}
}

View File

@ -33,12 +33,12 @@
//#include "FWWindow.h"
#include <qdir.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qeventloop.h>
#include <qtextcodec.h>
#include <QtDebug>
#include <QPushButton>
#include <stdlib.h>
@ -344,13 +344,15 @@ RCS::RCS(const QString &file)
* not have env. var LANG so it always runs in english
*/
QString rl = rlog();
QStringList split_log = rl.split(QRegExp("------|======"));
QStringList split_log = rl.split(QRegularExpression("------|======"));
QString head_section = split_log[0];
QRegExp head_rx("head:\\s+([0-9\\.]+)\\s*\\n");
int pos = head_rx.indexIn( head_section );
if (pos>-1) head = head_rx.cap(1);
QRegularExpression head_rx("head:\\s+([0-9\\.]+)\\s*\\n");
QRegularExpressionMatch match;
qsizetype pos = head_section.indexOf(head_rx, 0, &match);
if (pos>-1) head = match.captured(1);
QStringList::iterator i;
for (i=split_log.begin(),++i; i!=split_log.end(); ++i)
@ -358,56 +360,47 @@ RCS::RCS(const QString &file)
QString section = *i;
if (section.length()==0) continue;
int match = -1;
Revision r(filename);
r.rev = "";
r.log = "";
QRegExp rev_rx("revision\\s+([0-9\\.]+)");
match = rev_rx.indexIn( section );
if (match>-1)
QRegularExpression rev_rx("revision\\s+([0-9\\.]+)");
if (section.indexOf(rev_rx, 0, &match) > -1)
{
r.rev = rev_rx.cap(1);
r.rev = match.captured(1);
}
QRegExp lock_rx("revision\\s+([0-9\\.]+)\\s+locked by:\\s+(\\S+);");
lock_rx.setMinimal(true);
match = lock_rx.indexIn( section );
if (match>-1)
QRegularExpression lock_rx("revision\\s+([0-9\\.]+)\\s+locked by:\\s+(\\S+);", QRegularExpression::InvertedGreedinessOption);
if (section.indexOf(lock_rx, 0, &match) > -1)
{
r.locked_by = lock_rx.cap(2);
r.locked_by = match.captured(2);
locked = true;
locked_by = lock_rx.cap(2);
locked_by = match.captured(2);
locked_rev = r.rev;
}
// older implementation copied revision and "locked by" to r.log
// we'll do the same here to maintain compatibility
QRegExp rev2_rx("(revision.+)\\n");
rev2_rx.setMinimal(true);
match = rev2_rx.indexIn( section );
if (match>-1)
QRegularExpression rev2_rx("(revision.+)\\n", QRegularExpression::InvertedGreedinessOption);
if (section.indexOf(rev2_rx, 0, &match) > -1)
{
r.log += rev2_rx.cap(1) + "\n";
r.log += match.captured(1) + "\n";
}
QRegExp date_rx("date:\\s+([^;]+);\\s+author:\\s+(\\S+);");
date_rx.setMinimal(true);
match = date_rx.indexIn( section );
if (match>-1)
QRegularExpression date_rx("date:\\s+([^;]+);\\s+author:\\s+(\\S+);", QRegularExpression::InvertedGreedinessOption);
if (section.indexOf(date_rx, 0, &match) > -1)
{
r.date = date_rx.cap(1);
r.author = date_rx.cap(2);
r.date = match.captured(1);
r.author = match.captured(2);
}
QRegExp log_rx("date:.*\\n(.*)$");
log_rx.setMinimal(true);
match = log_rx.indexIn( section );
if (match>-1)
r.log += log_rx.cap(1);
QRegularExpression log_rx("date:.*\\n(.*)$", QRegularExpression::InvertedGreedinessOption);
if (section.indexOf(log_rx, 0, &match) > -1)
{
r.log += match.captured(1);
}
r.log.replace('\r',"");
@ -524,7 +517,7 @@ void RCS::abandon()
checked_out=false;
QString err = tr("Error checking file out: %1").arg(stderrBuffer);
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err, tr("&Continue") );
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err);
throw(FWException(err.toLatin1().constData()));
}
@ -726,7 +719,7 @@ bool RCS::co(const QString &rev,bool force)
if (fd<0)
{
QString err = tr("Error creating temporary file ")+tname+QString(" :\n")+strerror(errno);
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err, tr("&Continue") );
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err);
throw(FWException(err.toLatin1().constData()));
}
#ifdef _WIN32
@ -739,7 +732,7 @@ bool RCS::co(const QString &rev,bool force)
close(fd);
#endif
QString err = tr("Error writing to temporary file ")+tname+QString(" :\n")+strerror(errno);
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err, tr("&Continue") );
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err);
throw(FWException(err.toLatin1().constData()));
}
close(fd);
@ -756,7 +749,7 @@ bool RCS::co(const QString &rev,bool force)
selectedRev = head;
QString err = tr("Error checking file out: %1").arg(stderrBuffer);
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err, tr("&Continue") );
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err);
throw(FWException(err.toLatin1().constData()));
} else
@ -773,31 +766,39 @@ bool RCS::co(const QString &rev,bool force)
app->activeWindow(),"Firewall Builder",
tr("File is opened and locked by %1.\nYou can only open it read-only.")
.arg(locked_by),
"Open &read-only", "&Cancel", QString(),
0, 1 ) )
QMessageBox::Open | QMessageBox::Cancel))
{
case 0: ro=true; return false;
case 1: throw(FWException("cancel opening file")); break;
case QMessageBox::Open: ro=true; return false;
case QMessageBox::Cancel: throw(FWException("cancel opening file")); break;
default: throw(FWException("cancel opening file")); break;
}
}
if (force) goto checkout;
switch ( QMessageBox::warning(app->activeWindow(), "Firewall Builder",
tr("Revision %1 of this file has been checked out and locked by you earlier.\n\
The file may be opened in another copy of Firewall Builder or was left opened\n\
after the program crashed.").arg(locked_rev),
tr("Open &read-only"), tr("&Open and continue editing"), tr("&Cancel"),
0, 2 ) )
{
case 0: ro=true; return false;
case 1:
/* continue working with the file */
QMessageBox msgBox;
msgBox.setWindowTitle("Firewall Builder");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setText(tr("Revision %1 of this file has been checked out and locked by you earlier.\n\
The file may be opened in another copy of Firewall Builder or was left opened\n\
after the program crashed.").arg(locked_rev));
QPushButton *openRoButton = msgBox.addButton(tr("Open &read-only"), QMessageBox::AcceptRole);
QPushButton *openEditButton = msgBox.addButton(tr("&Open and continue editing"), QMessageBox::AcceptRole);
msgBox.addButton(QMessageBox::Cancel);
msgBox.exec();
QAbstractButton * const clickedButton = msgBox.clickedButton();
if (clickedButton == openRoButton) {
ro=true; return false;
} else if (clickedButton == openEditButton) {
/* continue working with the file */
checked_out = true;
locked = true;
selectedRev = locked_rev;
return true;
case 2: throw(FWException("cancel opening file")); break;
} else {
throw(FWException("cancel opening file"));
}
}
@ -848,7 +849,7 @@ after the program crashed.").arg(locked_rev),
selectedRev = head;
QString err = tr("Error checking file out: %1").arg(stderrBuffer);
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err, tr("&Continue") );
QMessageBox::critical(app->activeWindow(), "Firewall Builder", err);
throw(FWException(err.toLatin1().constData()));
}
@ -867,8 +868,8 @@ bool RCS::ci( const QString &_lm,
if (logmsg.isEmpty()) logmsg="_"; // otherwise ci adds "*** empty log message ***"
if (fwbdebug)
qDebug("RCS::ci log message (%d characters): '%s'",
logmsg.length(), logmsg.toLatin1().constData());
qDebug() << QString("RCS::ci log message (%1 characters): '%2'")
.arg(logmsg.length()).arg(logmsg.toLatin1().constData());
QStringList arglist;

View File

@ -33,7 +33,7 @@
#include "fwbuilder/XMLTools.h"
#include <QTreeWidget>
#include <qregexp.h>
#include <QRegularExpression>
#include <qpushbutton.h>
// #include <qtextbrowser.h>
@ -173,13 +173,13 @@ bool RCSFilePreview::showFileRLog( const QString &filename )
} else
{
// tree style
if ((*i).rev.indexOf(QRegExp("^[0-9]+\\.[0-9]+$"))!=-1)
if ((*i).rev.indexOf(QRegularExpression("^[0-9]+\\.[0-9]+$"))!=-1)
{
itm = addRevision(*i, rootItm);
itemList.push_back(itm);
}
if ((*i).rev.indexOf(QRegExp("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"))!=-1)
if ((*i).rev.indexOf(QRegularExpression("^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+"))!=-1)
{
QString branch_root = (*i).rev.section(".",0,1);
for (ili=itemList.begin(); ili!=itemList.end(); ++ili)

View File

@ -50,7 +50,6 @@
#include <qstackedwidget.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
#include <qregexp.h>
#include <qlabel.h>
#include <QSpinBox>

View File

@ -52,6 +52,7 @@
#include <qpushbutton.h>
#include <QUndoStack>
#include <QApplication>
#include <QRegularExpression>
using namespace std;
using namespace libfwbuilder;
@ -176,9 +177,9 @@ void RuleSetDialog::validate(bool *res)
if (platform == "pf")
pattern = "([a-zA-Z0-9_-+=@%^]+)(/\\*)?";
QRegExp rx(pattern);
QRegularExpression rx = QRegularExpression(QRegularExpression::anchoredPattern(pattern));
if (!rx.exactMatch(m_dialog->obj_name->text()))
if (!rx.match(m_dialog->obj_name->text()).hasMatch())
{
*res = false ;
if (QApplication::focusWidget() != nullptr)
@ -187,9 +188,7 @@ void RuleSetDialog::validate(bool *res)
QMessageBox::critical(
this,
"Firewall Builder",
tr("Rule set name '%1' is invalid. Only '[a-z][A-Z][0-9]_-+=@%^' characters are allowed.").arg( m_dialog->obj_name->text() ),
tr("&Continue"), 0, 0,
0 );
tr("Rule set name '%1' is invalid. Only '[a-z][A-Z][0-9]_-+=@%^' characters are allowed.").arg( m_dialog->obj_name->text()));
blockSignals(false);
}
return ;

View File

@ -33,7 +33,7 @@
#include <QtDebug>
#include <QHash>
#include <QRegExp>
#include <QRegularExpression>
#include <QMessageBox>
#include <QTime>
#include <QElapsedTimer>
@ -913,7 +913,7 @@ QString RuleSetModel::findUniqueNameForGroup(const QString &groupName)
bool exactNameExists = false;
QRegExp rx("^(.*)-(\\d+)$");
QRegularExpression rx = QRegularExpression(QRegularExpression::anchoredPattern("^(.*)-(\\d+)$"));
foreach (RuleNode *node, root->children)
{
@ -923,10 +923,11 @@ QString RuleSetModel::findUniqueNameForGroup(const QString &groupName)
exactNameExists = exactNameExists || (name == groupName);
if (rx.exactMatch(name))
QRegularExpressionMatch match = rx.match(name);
if (match.hasMatch())
{
QString nameSection = rx.capturedTexts().at(1);
QString countSection = rx.capturedTexts().at(2);
QString nameSection = match.capturedTexts().at(1);
QString countSection = match.capturedTexts().at(2);
int curCnt = countSection.toInt();
@ -1146,8 +1147,7 @@ bool RuleSetModel::insertObject(QModelIndex &index, FWObject *obj)
nullptr , "Firewall Builder",
QObject::tr(
"A single interface belonging to "
"this firewall is expected in this field."),
QString(),QString());
"this firewall is expected in this field."));
}
else if (RuleElementRGtw::cast(re))
{
@ -1157,8 +1157,7 @@ bool RuleSetModel::insertObject(QModelIndex &index, FWObject *obj)
"A single ip address is expected "
"here. You may also insert a host "
"or a network adapter leading to "
"a single ip adress."),
QString(),QString());
"a single ip adress."));
}
return false;
}

View File

@ -213,12 +213,12 @@ void RuleSetView::initActions()
// Move rule up
moveRuleUpAction = createAction(tr("Move Rule Up"), SLOT( moveRuleUp()),
QKeySequence(Qt::CTRL + Qt::Key_PageUp));
QKeySequence(Qt::CTRL | Qt::Key_PageUp));
addAction(moveRuleUpAction );
// Move rule down
moveRuleDownAction = createAction(tr("Move Rule Down"), SLOT( moveRuleDown()),
QKeySequence(Qt::CTRL + Qt::Key_PageDown));
QKeySequence(Qt::CTRL | Qt::Key_PageDown));
addAction(moveRuleDownAction );
// Remove rules from group
@ -814,8 +814,7 @@ void RuleSetView::addColumnRelatedMenu(QMenu *menu, const QModelIndex &index,
} catch (FWException &ex)
{
QMessageBox::critical( nullptr , "Firewall Builder",
ex.toString().c_str(),
QString(),QString());
ex.toString().c_str());
}
negID->setEnabled(supports_neg && !re->isAny());
fndID->setEnabled(!re->isAny());
@ -2195,8 +2194,11 @@ void RuleSetView::dropEvent(QDropEvent *ev)
RuleSetModel* md = ((RuleSetModel*)model());
if (!canChange(md)) return;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QModelIndex index = indexAt (ev->pos());
#else
QModelIndex index = indexAt (ev->position().toPoint());
#endif
if (!index.isValid()) return;
list<FWObject*> dragol;
@ -2225,8 +2227,11 @@ void RuleSetView::dropEvent(QDropEvent *ev)
// one rule to another.
clearSelection();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (ev->keyboardModifiers() & Qt::ControlModifier)
#else
if (ev->modifiers() & Qt::ControlModifier)
#endif
{
insertObject(
index, dragobj,
@ -2398,8 +2403,7 @@ bool RuleSetView::validateForInsertion(RuleElement *re, FWObject *obj, bool quie
nullptr , "Firewall Builder",
QObject::tr(
"A single interface belonging to this firewall is "
"expected in this field."),
QString(),QString());
"expected in this field."));
}
else if (RuleElementRGtw::cast(re))
{
@ -2408,8 +2412,7 @@ bool RuleSetView::validateForInsertion(RuleElement *re, FWObject *obj, bool quie
QObject::tr(
"A single ip adress is expected here. You may also "
"insert a host or a network adapter leading to a single "
"ip adress."),
QString(),QString());
"ip adress."));
}
}
return false;
@ -2484,12 +2487,19 @@ void RuleSetView::dragMoveEvent( QDragMoveEvent *ev)
{
if (ev->mimeData()->hasFormat(FWObjectDrag::FWB_MIME_TYPE) && !md->getRuleSet()->isReadOnly())
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (ev->keyboardModifiers() & Qt::ControlModifier)
#else
if (ev->modifiers() & Qt::ControlModifier)
#endif
ev->setDropAction(Qt::CopyAction);
else
ev->setDropAction(Qt::MoveAction);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QModelIndex index = indexAt (ev->pos());
#else
QModelIndex index = indexAt (ev->position().toPoint());
#endif
ColDesc colDesc = index.data(Qt::UserRole).value<ColDesc>();
if (index.column()<0 || ( colDesc.type != ColDesc::Object && colDesc.type != ColDesc::Time) )

View File

@ -32,7 +32,7 @@
#include <qobject.h>
#include <qtimer.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qeventloop.h>
@ -191,8 +191,8 @@ void SSHCisco::stateMachine()
{
case NONE:
{
if ( cmpPrompt(stdoutBuffer,QRegExp(pwd_prompt_1)) ||
cmpPrompt(stdoutBuffer,QRegExp(pwd_prompt_2)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(pwd_prompt_1)) ||
cmpPrompt(stdoutBuffer, QRegularExpression(pwd_prompt_2)) )
{
stdoutBuffer="";
proc->write( (pwd + "\n").toLatin1() );
@ -202,7 +202,7 @@ void SSHCisco::stateMachine()
/* we may get to LOGGEDIN state directly from NONE, for example when
* password is supplied on command line to plink.exe
*/
if (cmpPrompt(stdoutBuffer, QRegExp(normal_prompt)) )
if (cmpPrompt(stdoutBuffer, QRegularExpression(normal_prompt)) )
{
stdoutBuffer="";
state=LOGGEDIN;
@ -216,7 +216,7 @@ void SSHCisco::stateMachine()
/* we may even get straight to the enable prompt, e.g. if
* user account is configured with "privilege 15"
*/
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
state=WAITING_FOR_ENABLE;
stateMachine();
@ -242,9 +242,7 @@ void SSHCisco::stateMachine()
stopHeartBeat();
int res = QMessageBox::warning( parent, tr("New RSA key"), msg,
tr("Yes"), tr("No"), 0,
0, -1 );
QMessageBox::Yes | QMessageBox::No);
if (fwbdebug)
qDebug("User said: res=%d", res);
@ -268,7 +266,7 @@ void SSHCisco::stateMachine()
break;
case LOGGEDIN:
if ( cmpPrompt(stdoutBuffer,QRegExp(epwd_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(epwd_prompt)) )
{
stdoutBuffer="";
if (!epwd.isEmpty()) proc->write( (epwd + "\n").toLatin1() );
@ -278,7 +276,7 @@ void SSHCisco::stateMachine()
break;
case WAITING_FOR_ENABLE:
if ( cmpPrompt(stdoutBuffer,QRegExp(epwd_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(epwd_prompt)) )
{
stdoutBuffer="";
if (!epwd.isEmpty()) proc->write( (epwd + "\n").toLatin1() );
@ -286,7 +284,7 @@ void SSHCisco::stateMachine()
state=WAITING_FOR_ENABLE;
break;
}
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
emit printStdout_sign( tr("In enable mode."));
emit printStdout_sign( "\n");
@ -302,7 +300,7 @@ void SSHCisco::stateMachine()
}
/* FALLTHRU */
case ENABLE:
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
if (pre_config_commands.size()>0)
{
@ -341,26 +339,26 @@ void SSHCisco::stateMachine()
case SCHEDULE_RELOAD_DIALOG:
if ( cmpPrompt(stdoutBuffer,
QRegExp("System config.* modified\\. Save?")) )
QRegularExpression("System config.* modified\\. Save?")) )
{
stdoutBuffer="";
proc->write( "n" ); // no \n needed
break;
}
if ( cmpPrompt(stdoutBuffer, QRegExp("Proceed with reload?")) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression("Proceed with reload?")) )
{
stdoutBuffer="";
proc->write( "y" ); // no \n needed
break;
}
if ( cmpPrompt(stdoutBuffer, QRegExp("SHUTDOWN")) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression("SHUTDOWN")) )
{
stdoutBuffer="";
proc->write( "\n" );
state = ENABLE;
break;
}
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
// reload did not ask for confirmation
stdoutBuffer="";
@ -371,7 +369,7 @@ void SSHCisco::stateMachine()
break;
case EXECUTING_COMMAND:
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
//QCoreApplication::exit();
state = COMMAND_DONE;
@ -382,7 +380,7 @@ void SSHCisco::stateMachine()
break;
case WAITING_FOR_CONFIG_PROMPT:
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
/* install full policy */
state = PUSHING_CONFIG; // and drop to PUSHING_CONFIG case
@ -396,7 +394,7 @@ void SSHCisco::stateMachine()
break;
case PUSHING_CONFIG:
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt))) // config_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt))) // config_prompt)) )
{
// see SF bug 2973136 , fwbuilder bug #1347
// looks like if user hits Cancel to cancel install at just right
@ -443,7 +441,7 @@ void SSHCisco::stateMachine()
break;
case EXIT_FROM_CONFIG:
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
/*
* Execute post_config_commands

View File

@ -92,13 +92,13 @@ void SSHIOS::stateMachine()
case SCHEDULE_RELOAD_DIALOG:
if ( cmpPrompt(stdoutBuffer,
QRegExp("System config.* modified\\. Save?")) )
QRegularExpression("System config.* modified\\. Save?")) )
{
stdoutBuffer="";
proc->write( "no\n" );
break;
}
if ( cmpPrompt(stdoutBuffer,QRegExp("Proceed with reload?")) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression("Proceed with reload?")) )
{
stdoutBuffer="";
proc->write( "y\n" );
@ -108,7 +108,7 @@ void SSHIOS::stateMachine()
break;
case PUSHING_CONFIG:
if ( cmpPrompt(stdoutBuffer, QRegExp("Destination filename [.*]?")) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression("Destination filename [.*]?")) )
{
stdoutBuffer="";
proc->write("\n"); // accept default file name

View File

@ -32,7 +32,7 @@
#include <QObject>
#include <QTimer>
#include <QRegExp>
#include <QRegularExpression>
#include <QMessageBox>
#include <QApplication>
#include <QEventLoop>
@ -206,8 +206,8 @@ void SSHJunos::stateMachine()
{
case NONE:
{
if ( cmpPrompt(stdoutBuffer, QRegExp(pwd_prompt_1)) ||
cmpPrompt(stdoutBuffer, QRegExp(pwd_prompt_2)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(pwd_prompt_1)) ||
cmpPrompt(stdoutBuffer, QRegularExpression(pwd_prompt_2)) )
{
stdoutBuffer="";
proc->write( (pwd + "\n").toLatin1() );
@ -218,7 +218,7 @@ void SSHJunos::stateMachine()
* password is supplied on command line to plink.exe.
* This only happens with the root user
*/
if (cmpPrompt(stdoutBuffer, QRegExp(normal_prompt)))
if (cmpPrompt(stdoutBuffer, QRegularExpression(normal_prompt)))
{
stdoutBuffer="";
state=LOGGEDIN;
@ -231,7 +231,7 @@ void SSHJunos::stateMachine()
/* we get straight to operational prompt as a normal user
*/
if (cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)))
if (cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)))
{
state = WAITING_FOR_ENABLE;
stateMachine();
@ -257,8 +257,7 @@ void SSHJunos::stateMachine()
stopHeartBeat();
int res = QMessageBox::warning(parent, tr("New RSA key"), msg,
tr("Yes"), tr("No"), 0,
0, -1);
QMessageBox::Yes | QMessageBox::No);
if (fwbdebug)
qDebug("User said: red=%d", res);
@ -289,7 +288,7 @@ void SSHJunos::stateMachine()
break;
case LOGGEDIN:
if (cmpPrompt(stdoutBuffer, QRegExp(normal_prompt)))
if (cmpPrompt(stdoutBuffer, QRegularExpression(normal_prompt)))
{
stdoutBuffer="";
proc->write("cli\n");
@ -299,7 +298,7 @@ void SSHJunos::stateMachine()
}
/* FALLTHRU */
case WAITING_FOR_ENABLE:
if (cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)))
if (cmpPrompt(stdoutBuffer,QRegularExpression(enable_prompt)))
{
emit printStdout_sign( tr("In operational prompt."));
emit printStdout_sign("\n");
@ -309,7 +308,7 @@ void SSHJunos::stateMachine()
}
/* FALLTHRU */
case ENABLE:
if (cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)))
if (cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)))
{
if (pre_config_commands.size() > 0)
{
@ -332,7 +331,7 @@ void SSHJunos::stateMachine()
break;
case WAITING_FOR_CONFIG_PROMPT:
if (cmpPrompt(stdoutBuffer, QRegExp(config_prompt)))
if (cmpPrompt(stdoutBuffer, QRegularExpression(config_prompt)))
{
/* install full policy */
state = PUSHING_CONFIG;
@ -346,7 +345,7 @@ void SSHJunos::stateMachine()
break;
case PUSHING_CONFIG:
if (cmpPrompt(stdoutBuffer, QRegExp(config_prompt)))
if (cmpPrompt(stdoutBuffer, QRegularExpression(config_prompt)))
{
// see SF bug 2973136 , fwbuilder bug #1347
// looks like if user hits Cancel to cancel install at just right
@ -390,7 +389,7 @@ void SSHJunos::stateMachine()
break;
case EXIT_FROM_CONFIG:
if (cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)))
if (cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)))
{
/*
* Execute post_config_commands
@ -411,8 +410,8 @@ void SSHJunos::stateMachine()
break;
case EXIT:
if (cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) ||
cmpPrompt(stdoutBuffer, QRegExp(normal_prompt)) )
if (cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) ||
cmpPrompt(stdoutBuffer, QRegularExpression(normal_prompt)) )
{
stdoutBuffer="";
proc->write("exit\n");

View File

@ -89,7 +89,7 @@ void SSHNXOS::stateMachine()
// We need too delete files when doing scp with session
if ( cmpPrompt(stdoutBuffer,
QRegExp("Do you want to delete .* \\(yes/no/abort\\) \\[y\\] ")) )
QRegularExpression("Do you want to delete .* \\(yes/no/abort\\) \\[y\\] ")) )
{
stdoutBuffer="";
proc->write( "yes\n" );
@ -100,13 +100,13 @@ void SSHNXOS::stateMachine()
case SCHEDULE_RELOAD_DIALOG:
if ( cmpPrompt(stdoutBuffer,
QRegExp("System config.* modified\\. Save?")) )
QRegularExpression("System config.* modified\\. Save?")) )
{
stdoutBuffer="";
proc->write( "no\n" );
break;
}
if ( cmpPrompt(stdoutBuffer,QRegExp("Proceed with reload?")) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression("Proceed with reload?")) )
{
stdoutBuffer="";
proc->write( "y\n" );
@ -116,7 +116,7 @@ void SSHNXOS::stateMachine()
break;
case PUSHING_CONFIG:
if ( cmpPrompt(stdoutBuffer, QRegExp("Destination filename [.*]?")) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression("Destination filename [.*]?")) )
{
stdoutBuffer="";
proc->write("\n"); // accept default file name

View File

@ -32,7 +32,7 @@
#include <qobject.h>
#include <qtimer.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qeventloop.h>
@ -69,7 +69,7 @@ void SSHPIX::stateMachine()
switch (state)
{
case ENABLE:
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
if (pre_config_commands.size()>0)
{
@ -106,7 +106,7 @@ void SSHPIX::stateMachine()
break;
case EXECUTING_COMMAND:
if ( cmpPrompt(stdoutBuffer, QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
//QCoreApplication::exit();
state = COMMAND_DONE;
@ -117,14 +117,14 @@ void SSHPIX::stateMachine()
break;
case GET_ACLS:
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
QTimer::singleShot( 0, this, SLOT(getACLs()) );
}
break;
case GET_OG:
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
QTimer::singleShot( 0, this, SLOT(getObjectGroups()) );
}
@ -132,14 +132,14 @@ void SSHPIX::stateMachine()
case CLEAR_ACLS:
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
QTimer::singleShot( 0, this, SLOT(clearACLs()) );
}
break;
case CLEAR_OG:
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
QTimer::singleShot( 0, this, SLOT(clearObjectGroups()) );
}

View File

@ -91,7 +91,7 @@ void SSHProcurve::stateMachine()
* and provides prompt "Press any key to continue". Press "any key" to
* proceed.
*/
if (cmpPrompt(stdoutBuffer, QRegExp(hp_greeting_prompt)))
if (cmpPrompt(stdoutBuffer, QRegularExpression(hp_greeting_prompt)))
{
stdoutBuffer="";
proc->write("\n");
@ -103,7 +103,7 @@ void SSHProcurve::stateMachine()
case SCHEDULE_RELOAD_DIALOG:
if ( cmpPrompt(stdoutBuffer,
QRegExp("Do you want to save current configuration [y/n]?")) )
QRegularExpression("Do you want to save current configuration [y/n]?")) )
{
stdoutBuffer="";
proc->write( "no\n" );
@ -111,7 +111,7 @@ void SSHProcurve::stateMachine()
}
if ( cmpPrompt(
stdoutBuffer,
QRegExp("System will be rebooted at the scheduled time .*Do you want to continue [y/n]? ")) )
QRegularExpression("System will be rebooted at the scheduled time .*Do you want to continue [y/n]? ")) )
{
stdoutBuffer="";
proc->write( "y\n" );
@ -121,7 +121,7 @@ void SSHProcurve::stateMachine()
break;
case PUSHING_CONFIG:
if ( cmpPrompt(stdoutBuffer, QRegExp("Destination filename [.*]?")) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression("Destination filename [.*]?")) )
{
stdoutBuffer="";
proc->write("\n"); // accept default file name
@ -130,7 +130,7 @@ void SSHProcurve::stateMachine()
break;
case EXIT_FROM_CONFIG:
if ( cmpPrompt(stdoutBuffer,QRegExp(enable_prompt)) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression(enable_prompt)) )
{
/*
* Execute post_config_commands
@ -153,7 +153,7 @@ void SSHProcurve::stateMachine()
break;
case EXIT:
if ( cmpPrompt(stdoutBuffer,QRegExp("Do you want to log out [y/n]?")) )
if ( cmpPrompt(stdoutBuffer, QRegularExpression("Do you want to log out [y/n]?")) )
{
stdoutBuffer="";
proc->write("y\n"); // accept default file name

View File

@ -33,11 +33,13 @@
#include <qobject.h>
#include <qtimer.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qeventloop.h>
#include <qtextcodec.h>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <qtextcodec.h>
#endif
#include <qapplication.h>
#include <qdatetime.h>
#include <QtDebug>
@ -545,9 +547,9 @@ void SSHSession::readFromStdout()
* Matches ESC [ n ; m H (move cursor to position), ESC ? 25 l and ESC ? 25 h
* (hide and show cursor) and a few others
*/
QRegExp suppress_ansi_codes(
QRegularExpression suppress_ansi_codes(
"\x1B\\[((\\d*A)|(\\d*B)|(\\d*C)|(\\d*D)|(\\d*G)|(\\?\\d+l)|(\\d*J)|(2K)|(\\d*;\\d*[fHmr])|(\\?25h)|(\\?25l))");
QRegExp cursor_next_line("\x1B\\d*E");
QRegularExpression cursor_next_line("\x1B\\d*E");
while (buf.indexOf(suppress_ansi_codes) != -1)
buf.replace(suppress_ansi_codes, "");
@ -562,11 +564,7 @@ void SSHSession::readFromStdout()
QString lastLine = "";
// split on LF
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QStringList bufLines = buf.split("\n", Qt::KeepEmptyParts);
#else
QStringList bufLines = buf.split("\n", QString::KeepEmptyParts);
#endif
// if buf ends with a LF character, the last element in the list is
// an empty string
@ -733,11 +731,11 @@ bool SSHSession::cmpPrompt(const QString &str, const QString &prompt)
return res;
}
bool SSHSession::cmpPrompt(const QString &str,const QRegExp &prompt)
bool SSHSession::cmpPrompt(const QString &str,const QRegularExpression &prompt)
{
#if STATE_MACHINE_DEBUG
if (fwbdebug)
qDebug("SSHSession::cmpPrompt: str='%s' prompt='%s' (regexp)",
qDebug("SSHSession::cmpPrompt: str='%s' prompt='%s' (QRegularExpression)",
str.toLatin1().constData(),prompt.pattern().toLatin1().constData());
#endif

View File

@ -31,7 +31,7 @@
#include <qstring.h>
#include <qstringlist.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qprocess.h>
#include <qobject.h>
@ -152,7 +152,7 @@ class SSHSession : public QObject {
bool cmpPrompt(const QString &str,const QString &prompt);
bool cmpPrompt(const QString &str,const QRegExp &prompt);
bool cmpPrompt(const QString &str,const QRegularExpression &prompt);
void startHeartBeat();
void stopHeartBeat();

View File

@ -32,7 +32,7 @@
#include <qobject.h>
#include <qtimer.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qeventloop.h>
@ -129,7 +129,7 @@ bool SSHUnx::checkForErrors(QStringList *errptr)
foreach (QString err, *errptr)
{
if (stdoutBuffer.lastIndexOf(QRegExp(err), -1) != -1)
if (stdoutBuffer.lastIndexOf(QRegularExpression(err), -1) != -1)
{
if (fwbdebug)
qDebug("SSHUnx::stateMachine: MATCH. Error detected.");
@ -242,9 +242,8 @@ void SSHUnx::stateMachine()
stopHeartBeat();
int res =QMessageBox::warning( parent, tr("New RSA key"), msg,
tr("Yes"), tr("No"), 0,
0, -1 );
int res = QMessageBox::warning( parent, tr("New RSA key"), msg,
QMessageBox::Yes | QMessageBox::No);
if (fwbdebug)
qDebug("User said: res=%d", res);

View File

@ -71,7 +71,7 @@ void SimpleTextEditor::loadFromFile()
if (QMessageBox::warning(this, tr("Firewall Builder"),
tr("Warning: loading from file discards "
"current contents of the script."),
"&Load", "&Cancel", QString(), 0, 1 ) != 0)
QMessageBox::Open | QMessageBox::Cancel) != QMessageBox::Open)
{
return;
}
@ -88,7 +88,7 @@ void SimpleTextEditor::loadFromFile()
QMessageBox::warning(
this,"Firewall Builder",
tr("Could not open file %1").arg(filename),
"&Continue", QString(), QString(), 0, 1 );
QMessageBox::Ok);
return;
}

View File

@ -95,7 +95,7 @@ StartTipDialog::StartTipDialog(QWidget *parent): QDialog(parent)
delete h;
current_tip = tips.size() - 1;
if (fwbdebug) qDebug("Have %d tips", tips.size());
if (fwbdebug) qDebug() << QString("Have %1 tips").arg(tips.size());
first_run = st->getBool("UI/FirstRun");
}

View File

@ -63,7 +63,7 @@ bool TextFileEditor::load()
this, "Firewall Builder",
tr("The file %1 does not exist but it will be created "
"when you save your changes.").arg(file_name),
tr("&Open the file"), tr("&Cancel"), QString(), 0, 1 ) == 1)
QMessageBox::Open | QMessageBox::Cancel) == QMessageBox::Cancel)
return false;
return true;
@ -76,9 +76,9 @@ bool TextFileEditor::load()
QMessageBox::critical(
this, "Firewall Builder",
tr("The file is read-only, you can't save the changes."),
tr("&View the file"), tr("&Cancel"), QString(), 0, 1 ))
QMessageBox::Open | QMessageBox::Cancel))
{
case 0: // open read-only
case QMessageBox::Open: // open read-only
m_dialog->editor->setReadOnly(true);
m_dialog->ok_button->hide();
m_dialog->cancel_button->setText(tr("Close"));
@ -122,8 +122,7 @@ void TextFileEditor::save()
QMessageBox::critical(
this,"Firewall Builder",
tr("Error saving data to file '%1': %2")
.arg(file_name).arg(owf.errorString()),
"&Continue", QString(), QString(), 0, 1 );
.arg(file_name).arg(owf.errorString()));
return;
}
@ -143,15 +142,13 @@ void TextFileEditor::save()
QMessageBox::critical(
this,"Firewall Builder",
tr("Can not rename file %1 to %2: %3")
.arg(tmp_file_name).arg(file_name).arg(wf.errorString()),
"&Continue", QString(), QString(), 0, 1 );
.arg(tmp_file_name).arg(file_name).arg(wf.errorString()));
} else
QMessageBox::critical(
this,"Firewall Builder",
tr("Error saving data to a temporary file '%1': %2")
.arg(tmp_file_name).arg(wf.errorString()),
"&Continue", QString(), QString(), 0, 1 );
.arg(tmp_file_name).arg(wf.errorString()));
}
void TextFileEditor::closeEvent(QCloseEvent* ev)
@ -162,20 +159,21 @@ void TextFileEditor::closeEvent(QCloseEvent* ev)
QMessageBox::critical(
this, "Firewall Builder",
tr("Dialog contains modified data. Do you want to save it?"),
tr("&Save"), tr("&Discard"), tr("&Cancel"),
0, // enter: button 0
2 )) // escape: button 2
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel))
{
case 0:
case QMessageBox::Save:
save();
QDialog::closeEvent(ev);
break;
case 1:
case QMessageBox::Discard:
QDialog::closeEvent(ev);
break;
case 2:
case QMessageBox::Cancel:
ev->ignore();
return;
default:
ev->ignore();
return;
}

View File

@ -124,9 +124,7 @@ bool conntrackOptionsDialog::validate()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("Invalid IP address '%1'").arg(m_dialog->conntrack_address->text()),
tr("&Continue"), nullptr, nullptr,
0 );
tr("Invalid IP address '%1'").arg(m_dialog->conntrack_address->text()));
return false;
}
}

View File

@ -34,7 +34,9 @@
#include "FWWindow.h"
#include <qtextbrowser.h>
#include <qtextcodec.h>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <qtextcodec.h>
#endif
#include <qglobal.h>
#include <qpixmapcache.h>
#include <qlocale.h>

View File

@ -132,7 +132,7 @@ void filePropDialog::printRevHistory()
QPrintDialog printDialog(printer, this);
printDialog.addEnabledOption(QAbstractPrintDialog::PrintPageRange);
printDialog.setOption(QAbstractPrintDialog::PrintPageRange);
printDialog.setPrintRange(QAbstractPrintDialog::AllPages);
printDialog.setMinMax(1,9999);

View File

@ -48,7 +48,7 @@
#include <qcheckbox.h>
#include <qapplication.h>
#include <qcursor.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qmessagebox.h>
@ -138,7 +138,7 @@ bool findDialog::matchName(const QString &name)
bool res=false;
if (m_dialog->useRegexp->isChecked()) res= ( name.indexOf( QRegExp(s) )!=-1 );
if (m_dialog->useRegexp->isChecked()) res= ( name.indexOf( QRegularExpression(s) )!=-1 );
else res= ( name == s );
return res;
@ -159,7 +159,7 @@ bool findDialog::matchAttr(libfwbuilder::FWObject *obj)
if (a!=nullptr)
{
QString addr = a->getAddressPtr()->toString().c_str();
if (m_dialog->useRegexp->isChecked()) res= ( addr.indexOf( QRegExp(s) )!=-1 );
if (m_dialog->useRegexp->isChecked()) res= ( addr.indexOf( QRegularExpression(s) )!=-1 );
else res= ( addr == s );
}
break;
@ -171,13 +171,13 @@ bool findDialog::matchAttr(libfwbuilder::FWObject *obj)
{
QString port;
port.setNum(TCPUDPService::cast(obj)->getSrcRangeStart());
res |= ( port.indexOf( QRegExp(s) )!=-1 );
res |= ( port.indexOf( QRegularExpression(s) )!=-1 );
port.setNum(TCPUDPService::cast(obj)->getSrcRangeEnd());
res |= ( port.indexOf( QRegExp(s) )!=-1 );
res |= ( port.indexOf( QRegularExpression(s) )!=-1 );
port.setNum(TCPUDPService::cast(obj)->getDstRangeStart());
res |= ( port.indexOf( QRegExp(s) )!=-1 );
res |= ( port.indexOf( QRegularExpression(s) )!=-1 );
port.setNum(TCPUDPService::cast(obj)->getDstRangeEnd());
res |= ( port.indexOf( QRegExp(s) )!=-1 );
res |= ( port.indexOf( QRegularExpression(s) )!=-1 );
} else
{
int port = s.toInt();
@ -196,7 +196,7 @@ bool findDialog::matchAttr(libfwbuilder::FWObject *obj)
{
QString proto;
proto.setNum(obj->getInt("protocol_num"));
res |= ( proto.indexOf( QRegExp(s) )!=-1 );
res |= ( proto.indexOf( QRegularExpression(s) )!=-1 );
} else
{
int proto = s.toInt();
@ -212,7 +212,7 @@ bool findDialog::matchAttr(libfwbuilder::FWObject *obj)
{
QString icmptype;
icmptype.setNum(obj->getInt("type"));
res |= ( icmptype.indexOf( QRegExp(s) )!=-1 );
res |= ( icmptype.indexOf( QRegularExpression(s) )!=-1 );
} else
{
int icmptype = s.toInt();
@ -269,10 +269,17 @@ loop:
{
reset();
if ( QMessageBox::warning(
this,"Firewall Builder",
tr("Search hit the end of the object tree."),
tr("&Continue at top"), tr("&Stop"), QString(), 0, 1 )==0 ) goto loop;
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Warning);
msgBox.setWindowTitle("Firewall Builder");
msgBox.setText("Search hit the end of the object tree.");
QPushButton *continueButton = msgBox.addButton(tr("&Continue at top"), QMessageBox::ActionRole);
msgBox.addButton(tr("&Stop"), QMessageBox::RejectRole);
msgBox.exec();
if (msgBox.clickedButton() == continueButton) goto loop;
return;
}

View File

@ -39,7 +39,6 @@
#include <qcombobox.h>
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qregexp.h>
#include "FWWindow.h"

View File

@ -125,9 +125,7 @@ bool heartbeatOptionsDialog::validate()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("Invalid IP address '%1'").arg(m_dialog->heartbeat_address->text()),
tr("&Continue"), nullptr, nullptr,
0 );
tr("Invalid IP address '%1'").arg(m_dialog->heartbeat_address->text()));
return false;
}
}

View File

@ -72,8 +72,7 @@ void ChooseObjectsPage::initializePage()
} catch (FWException &ex)
{
QMessageBox::critical( nullptr , "Firewall Builder",
ex.toString().c_str(),
QString(),QString());
ex.toString().c_str());
}
}

View File

@ -67,16 +67,14 @@ bool FileNamePage::validatePage()
if ( ! f.exists())
{
QMessageBox::critical( nullptr , "Firewall Builder",
tr("File %1 does not exist").arg(file_name),
QString(),QString());
tr("File %1 does not exist").arg(file_name));
return false;
}
if ( ! f.isReadable())
{
QMessageBox::critical( nullptr , "Firewall Builder",
tr("Can not read file %1").arg(file_name),
QString(),QString());
tr("Can not read file %1").arg(file_name));
return false;
}

View File

@ -25,7 +25,7 @@
#include "HostsFile.h"
#include <QFile>
#include <QRegExp>
#include <QRegularExpression>
#include <QtDebug>
extern int fwbdebug;
@ -42,8 +42,9 @@ void HostsFile::parse()
data.clear();
QRegExp comment("^\\s*#");
QRegExp hosts_line("^\\s*(\\S+)\\s+(\\S*)");
QRegularExpression comment("^\\s*#");
QRegularExpression hosts_line("^\\s*(\\S+)\\s+(\\S*)");
QRegularExpressionMatch match;
while ( ! file.atEnd())
{
@ -51,15 +52,15 @@ void HostsFile::parse()
if (fwbdebug) qDebug() << "Line: " << line;
if (comment.indexIn(line) > -1) continue;
if (hosts_line.indexIn(line) > -1)
if (line.indexOf(comment) > -1) continue;
if (hosts_line.match(line).hasMatch())
{
QString addr_s = hosts_line.cap(1);
QStringList names = hosts_line.cap(2).split(",");
QString addr_s = match.captured(1);
QStringList names = match.captured(2).split(",");
if (fwbdebug)
qDebug() << "cap(1)=" << hosts_line.cap(1)
<< "cap(2)=" << hosts_line.cap(2);
qDebug() << "cap(1)=" << match.captured(1)
<< "cap(2)=" << match.captured(2);
try
{

View File

@ -64,16 +64,14 @@ bool IC_FileNamePage::validatePage()
if ( ! f.exists())
{
QMessageBox::critical( nullptr , "Firewall Builder",
tr("File %1 does not exist").arg(file_name),
QString(),QString());
tr("File %1 does not exist").arg(file_name));
return false;
}
if ( ! f.isReadable())
{
QMessageBox::critical( nullptr , "Firewall Builder",
tr("Can not read file %1").arg(file_name),
QString(),QString());
tr("Can not read file %1").arg(file_name));
return false;
}

View File

@ -30,7 +30,7 @@
#include <QString>
#include <QFile>
#include <QRegExp>
#include <QRegularExpression>
#include <QTextStream>
#include <QtDebug>
@ -58,13 +58,14 @@ void IC_FirewallNamePage::initializePage()
if (platform == "pix" || platform == "fwsm" || platform == "iosacl")
{
QRegExp cisco_re("^hostname\\s+(\\S+)");
QRegularExpression cisco_re("^hostname\\s+(\\S+)");
QRegularExpressionMatch match;
foreach(QString line, *buf)
{
if (cisco_re.indexIn(line) > -1)
if (cisco_re.match(line).hasMatch())
{
QString name = cisco_re.cap(1).replace("\"", "").replace("'", "");
QString name = match.captured(1).replace("\"", "").replace("'", "");
m_dialog->firewallName->setText(name);
break;
}

View File

@ -33,7 +33,6 @@
#include <QString>
#include <QFile>
#include <QRegExp>
#include <QTextStream>
#include <QDesktopServices>

View File

@ -303,8 +303,8 @@ void IC_ProgressPage::saveLog()
{
if (fwbdebug)
{
qDebug("Saving crawler log to file: %d chars",
m_dialog->importLog->toPlainText().length());
qDebug() << QString("Saving crawler log to file: %1 chars")
.arg(m_dialog->importLog->toPlainText().length());
qDebug("--------------------------------");
}
QTextStream strm(&f);

View File

@ -43,8 +43,8 @@
#include "fwbuilder/TCPService.h"
#include "fwbuilder/ServiceGroup.h"
#include <QDesktopWidget>
#include <QtDebug>
#include <QScreen>
using namespace std;
using namespace libfwbuilder;
@ -77,7 +77,7 @@ ImportFirewallConfigurationWizard::ImportFirewallConfigurationWizard(
// always show cancel button
setOption(QWizard::NoCancelButton, false);
QRect sg = QApplication::desktop()->screenGeometry(mw);
QRect sg = mw->screen()->availableGeometry();
QSize screen_size = sg.size();
#if defined(Q_OS_MACX)

View File

@ -37,7 +37,6 @@
#include <iostream>
#include <qobject.h>
#include <qregexp.h>
#include <qsettings.h>
#include <QtDebug>

View File

@ -62,7 +62,9 @@
#include <qgroupbox.h>
#include <qcolor.h>
#include <qtablewidget.h>
#include <qtextcodec.h>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <qtextcodec.h>
#endif
#include <qfileinfo.h>
#include <qtextstream.h>
#include <QDateTime>
@ -121,14 +123,14 @@ instDialog::instDialog(QWidget *p) : QDialog(p)
err_re.push_back("(fwb_[^:]*: \\S*\\.cpp:\\d{1,}: .*: Assertion .* failed.)");
foreach(string re, err_re)
{
error_re.push_back(QRegExp(re.c_str(), Qt::CaseInsensitive));
error_re.push_back(QRegularExpression(re.c_str(), QRegularExpression::CaseInsensitiveOption));
}
list<string> warn_re;
BaseCompiler::warningRegExp(&warn_re);
foreach(string re, warn_re)
{
warning_re.push_back(QRegExp(re.c_str()));
warning_re.push_back(QRegularExpression(re.c_str()));
}
@ -679,8 +681,7 @@ bool instDialog::checkSSHPathConfiguration(Firewall *fw)
QMessageBox::critical(this, "Firewall Builder",
tr("Policy installer uses Secure Shell to communicate with the firewall.\n"
"Please configure directory path to the secure shell utility \n"
"installed on your machine using Preferences dialog"),
tr("&Continue") );
"installed on your machine using Preferences dialog"));
addToLog("Please configure directory path to the secure \n "
"shell utility installed on your machine using \n"
@ -769,7 +770,9 @@ void instDialog::setUpProcessToInstall()
bool instDialog::executeCommand(const QString &path, QStringList &args)
{
// set codecs so that command line parameters can be encoded
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
enableStopButton();
QElapsedTimer start_time;
start_time.start();

View File

@ -37,10 +37,9 @@
#include "FirewallInstaller.h"
#include "ProjectPanel.h"
#include <qstring.h>
#include <qstringlist.h>
#include <QStringList>
#include <qprocess.h>
#include <QRegExp>
#include <QRegularExpression>
#include <fstream>
#include <set>
@ -59,7 +58,6 @@ class QListViewItem;
class QCheckListItem;
class QPushButton;
class QProgressBar;
class QStringList;
class QTreeWidgetItem;
class QTextCharFormat;
//class QCheckTableItem;
@ -111,8 +109,8 @@ class instDialog : public QDialog, public FakeWizard
std::list<libfwbuilder::Firewall*>::size_type install_list_initial_size;
std::map<int,QTreeWidgetItem*> opListMapping;
std::list<QRegExp> error_re;
std::list<QRegExp> warning_re;
std::list<QRegularExpression> error_re;
std::list<QRegularExpression> warning_re;
std::map<libfwbuilder::Firewall*, fwcompiler::BaseCompiler::termination_status>
compile_status;

View File

@ -50,8 +50,9 @@
#include <errno.h>
#include <iostream>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include <QTimer>
#include <QMessageBox>
#include <QFile>
@ -103,7 +104,9 @@ bool instDialog::runCompiler(Firewall *fw)
addToLog( args.join(" ") + "\n" );
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
// Launch compiler in the background
QString path = args.at(0);
@ -168,9 +171,7 @@ QStringList instDialog::prepareArgForCompiler(Firewall *fw)
QMessageBox::warning(
this,"Firewall Builder",
tr("Firewall platform is not specified in this object.\n\
Can't compile firewall policy."),
tr("&Continue"), QString(),QString(),
0, 1 );
Can't compile firewall policy."));
return args; // still empty list
}

View File

@ -49,7 +49,6 @@
#include <errno.h>
#include <iostream>
#include <QTextCodec>
#include <QTimer>
#include <QMessageBox>
#include <QtDebug>

View File

@ -60,7 +60,6 @@
#include <qgroupbox.h>
#include <qcolor.h>
#include <qtablewidget.h>
#include <qtextcodec.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <qpixmapcache.h>
@ -297,13 +296,13 @@ void instDialog::setFlags(QTreeWidgetItem* item)
}
}
dt.setTime_t(lm);
dt.setSecsSinceEpoch(lm);
item->setText(LAST_MODIFIED_COLUMN, (lm)?dt.toString():QString("Never"));
dt.setTime_t(lc);
dt.setSecsSinceEpoch(lc);
item->setText(LAST_COMPILED_COLUMN, (lc)?dt.toString():QString("Never"));
dt.setTime_t(li);
dt.setSecsSinceEpoch(li);
item->setText(LAST_INSTALLED_COLUMN, (li)?dt.toString():QString("Never"));
}
@ -781,10 +780,10 @@ void instDialog::addToLog(const QString &buf)
{
QTextCharFormat format = normal_format;
list<QRegExp>::const_iterator it;
list<QRegularExpression>::const_iterator it;
for (it=error_re.begin(); it!=error_re.end(); ++it)
{
if ((*it).indexIn(line) != -1)
if (line.indexOf(*it) != -1)
{
format = error_format;
break;
@ -793,7 +792,7 @@ void instDialog::addToLog(const QString &buf)
for (it=warning_re.begin(); it!=warning_re.end(); ++it)
{
if ((*it).indexIn(line) != -1)
if (line.indexOf(*it) != -1)
{
format = warning_format;
break;
@ -1384,8 +1383,7 @@ bool instDialog::verifyManagementAddress()
"must be marked as management interface.\n")
.arg(QString::fromUtf8(cnf.fwobj->getName().c_str()));
QMessageBox::critical(this, "Firewall Builder", err,
tr("&Continue") );
QMessageBox::critical(this, "Firewall Builder", err);
addToLog(err);
return false;
}
@ -1401,8 +1399,7 @@ bool instDialog::verifyManagementAddress()
"interface in the Editor panel")
.arg(QString::fromUtf8(cnf.fwobj->getName().c_str()));
QMessageBox::critical(this, "Firewall Builder", err,
tr("&Continue") );
QMessageBox::critical(this, "Firewall Builder", err);
addToLog(err);
return false;
}
@ -1414,8 +1411,7 @@ bool instDialog::verifyManagementAddress()
"Management interface does not have IP address, "
"can not communicate with the firewall.\n");
QMessageBox::critical(this, "Firewall Builder", err,
tr("&Continue") );
QMessageBox::critical(this, "Firewall Builder", err);
addToLog(err);
return false;
}

View File

@ -43,8 +43,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
using namespace std;
using namespace libfwbuilder;

View File

@ -49,7 +49,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
#include <qtabwidget.h>
#include <qlistwidget.h>

View File

@ -43,7 +43,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
using namespace std;

View File

@ -41,7 +41,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include "FWWindow.h"
#include "Help.h"

View File

@ -43,7 +43,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <QUndoStack>

View File

@ -43,7 +43,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <QUndoStack>

View File

@ -43,7 +43,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
#include <QUndoStack>

View File

@ -43,8 +43,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
using namespace std;
using namespace libfwbuilder;

View File

@ -49,7 +49,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
#include <qtabwidget.h>
#include <qlistwidget.h>

View File

@ -41,7 +41,6 @@
#include <qcombobox.h>
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qregexp.h>
#include <qtabwidget.h>
using namespace std;

View File

@ -41,7 +41,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <QUndoStack>
#include "FWWindow.h"

View File

@ -201,8 +201,7 @@ bool linux24IfaceOptsDialog::validate()
if (!valid)
{
QMessageBox::warning(this, "Firewall Builder",
tr("Input not valid: %1").arg(message), "&Continue",
QString(), QString(), 0, 1);
tr("Input not valid: %1").arg(message));
focus->setFocus();
}
return valid;

View File

@ -33,6 +33,7 @@
#include <qpixmap.h>
#include <qmessagebox.h>
#include <qlabel.h>
#include <QStyle>
#include <iostream>
@ -55,7 +56,7 @@ longTextDialog::longTextDialog(QWidget *p,
m_dialog->dlgText->setText(txt);
m_dialog->icn->setPixmap( QMessageBox::standardIcon(QMessageBox::Critical) );
m_dialog->icn->setPixmap( style()->standardPixmap(QStyle::SP_MessageBoxCritical) );
m_dialog->dlgLongText->setText(ltxt);
}

View File

@ -40,8 +40,6 @@
#include <qcombobox.h>
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qregexp.h>
using namespace std;
using namespace libfwbuilder;

View File

@ -329,8 +329,7 @@ void newClusterDialog::nextClicked()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("You should select at least one firewall to create a cluster"),
"&Continue", QString(), QString(), 0, 1);
tr("You should select at least one firewall to create a cluster"));
return;
}
}

View File

@ -33,7 +33,6 @@
#include "FWBTree.h"
#include "events.h"
#include "FWBApplication.h"
#include "QDesktopWidget"
#include "networkZoneManager.h"
#include "ObjConflictResolutionDialog.h"
@ -69,6 +68,7 @@
#include <QFileDialog>
#include <QDir>
#include <QtDebug>
#include <QScreen>
#include <algorithm>
#include <iostream>
@ -186,7 +186,7 @@ newFirewallDialog::newFirewallDialog(QWidget *parentw, FWObject *_p) :
);
this->resize(this->width(), this->minimumHeight());
int maxheight = (int)(app->desktop()->height()*0.9);
int maxheight = (int)(this->screen()->availableGeometry().height()*0.9);
if (this->height() > maxheight)
this->resize(this->width(), maxheight);
@ -320,8 +320,7 @@ void newFirewallDialog::getIPAddressOfFirewallByName()
QMessageBox::warning(
this,"Firewall Builder",
tr("Address of %1 could not be obtained via DNS")
.arg(m_dialog->obj_name->text()),
"&Continue", QString(), QString(), 0, 1 );
.arg(m_dialog->obj_name->text()));
}
getInterfacesBusy = false;
@ -441,8 +440,7 @@ void newFirewallDialog::getInterfacesViaSNMP()
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Missing SNMP community string."),
"&Continue", QString(), QString(), 0, 1 );
tr("Missing SNMP community string."));
return ;
}
@ -468,8 +466,7 @@ void newFirewallDialog::getInterfacesViaSNMP()
QMessageBox::warning(
this,"Firewall Builder",
tr("Address of %1 could not be obtained via DNS")
.arg(m_dialog->snmpIP->text()),
"&Continue", QString(), QString(), 0, 1 );
.arg(m_dialog->snmpIP->text()));
getInterfacesBusy = false;
return ;
}
@ -531,9 +528,7 @@ void newFirewallDialog::nextClicked()
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Please select template"),
tr("&Continue"), QString(),QString(),
0, 1 );
tr("Please select template"));
showPage(CHOOSE_FW_TEMPLATE);
return;
}
@ -665,9 +660,7 @@ void newFirewallDialog::showPage(const int page)
QMessageBox::critical(
this,"Firewall Builder",
tr("Error loading template library:\n%1")
.arg(ex.toString().c_str()),
tr("&Continue"), QString(),QString(),
0, 1 );
.arg(ex.toString().c_str()));
}
}
@ -805,8 +798,7 @@ void newFirewallDialog::getInterfaceDataFromInterfaceEditor(
catch (FWException &ex)
{
QMessageBox::warning(
this,"Firewall Builder", ex.toString().c_str(),
"&Continue", QString(), QString(), 0, 1 );
this,"Firewall Builder", ex.toString().c_str());
showPage( CONFIGURE_INTERFACES_MANUALLY );
return;
}
@ -1027,8 +1019,7 @@ bool newFirewallDialog::validateAddressAndMask(const QString &addr,
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Invalid address '%1/%2'").arg(addr).arg(netm),
"&Continue", QString(), QString(), 0, 1 );
tr("Invalid address '%1/%2'").arg(addr).arg(netm));
return false;
}
try
@ -1041,8 +1032,7 @@ bool newFirewallDialog::validateAddressAndMask(const QString &addr,
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Invalid address '%1/%2'").arg(addr).arg(netm),
"&Continue", QString(), QString(), 0, 1 );
tr("Invalid address '%1/%2'").arg(addr).arg(netm));
return false;
}
}
@ -1056,8 +1046,7 @@ bool newFirewallDialog::validateAddressAndMask(const QString &addr,
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Invalid address '%1/%2'").arg(addr).arg(netm),
"&Continue", QString(), QString(), 0, 1 );
tr("Invalid address '%1/%2'").arg(addr).arg(netm));
return false;
}
return true;

View File

@ -130,8 +130,7 @@ void newFirewallDialog::changedAddressesInNewFirewall()
QMessageBox::critical(
this, "Firewall Builder",
tr("Can not find interface %1 in the interface editor data")
.arg(intf->getName().c_str()),
"&Continue", QString(), QString(), 0, 1 );
.arg(intf->getName().c_str()));
} else
{
EditedInterfaceData new_data = new_configuration[intf];
@ -153,8 +152,8 @@ void newFirewallDialog::changedAddressesInNewFirewall()
* If user created more addresses than there used to
* be, extra addresses are not added to rules.
*/
QMap<libfwbuilder::Address*, AddressInfo >::iterator addrit;
for (addrit=new_data.addresses.begin(); addrit!=new_data.addresses.end(); ++addrit)
QMultiMap<libfwbuilder::Address*, AddressInfo >::iterator addrit;
for (addrit = new_data.addresses.begin(); addrit != new_data.addresses.end(); ++addrit)
{
Address *old_addr_obj = addrit.key();
InetAddrMask old_net;

View File

@ -54,7 +54,7 @@
#include <qtextbrowser.h>
#include <qmessagebox.h>
#include <qtimer.h>
#include <qregexp.h>
#include <QRegularExpression>
#include <qapplication.h>
#include <qcursor.h>
#include <qpixmapcache.h>
@ -279,8 +279,7 @@ void newHostDialog::getInterfacesViaSNMP()
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Missing SNMP community string."),
"&Continue", QString(), QString(), 0, 1 );
tr("Missing SNMP community string."));
return ;
}
@ -301,8 +300,7 @@ void newHostDialog::getInterfacesViaSNMP()
QMessageBox::warning(
this,"Firewall Builder",
tr("Address of %1 could not be obtained via DNS")
.arg(m_dialog->obj_name->text()),
"&Continue", QString(), QString(), 0, 1 );
.arg(m_dialog->obj_name->text()));
getInterfacesBusy = false;
return ;
}
@ -456,8 +454,8 @@ void newHostDialog::templateSelected(QListWidgetItem *itm)
QString lbl = intf->getLabel().c_str();
if (lbl=="outside" ||
nam.indexOf(QRegExp(".*0$"))!=-1 ||
nam.indexOf(QRegExp(".*0/0$"))!=-1 )
nam.indexOf(QRegularExpression(".*0$"))!=-1 ||
nam.indexOf(QRegularExpression(".*0/0$"))!=-1 )
{
haveOutside=true;
m_dialog->intfOutsideLine->show();
@ -465,8 +463,8 @@ void newHostDialog::templateSelected(QListWidgetItem *itm)
fillInterfaceData(intf,m_dialog->intfOutsideText);
}
if (lbl=="inside" ||
nam.indexOf(QRegExp(".*1$"))!=-1 ||
nam.indexOf(QRegExp(".*0/1$"))!=-1 )
nam.indexOf(QRegularExpression(".*1$"))!=-1 ||
nam.indexOf(QRegularExpression(".*0/1$"))!=-1 )
{
haveInside=true;
m_dialog->intfInsideLine->show();
@ -525,8 +523,7 @@ bool newHostDialog::validateAddressAndMask(const QString &addr,
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Illegal address '%1/%2'").arg(addr).arg(netm),
"&Continue", QString(), QString(), 0, 1 );
tr("Illegal address '%1/%2'").arg(addr).arg(netm));
return false;
}
try
@ -539,8 +536,7 @@ bool newHostDialog::validateAddressAndMask(const QString &addr,
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Illegal address '%1/%2'").arg(addr).arg(netm),
"&Continue", QString(), QString(), 0, 1 );
tr("Illegal address '%1/%2'").arg(addr).arg(netm));
return false;
}
}
@ -554,8 +550,7 @@ bool newHostDialog::validateAddressAndMask(const QString &addr,
{
QMessageBox::warning(
this,"Firewall Builder",
tr("Illegal address '%1/%2'").arg(addr).arg(netm),
"&Continue", QString(), QString(), 0, 1 );
tr("Illegal address '%1/%2'").arg(addr).arg(netm));
return false;
}
return true;

View File

@ -43,8 +43,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
using namespace std;
using namespace libfwbuilder;

View File

@ -49,7 +49,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
#include <qtabwidget.h>
#include <qlistwidget.h>

View File

@ -122,9 +122,7 @@ bool openaisOptionsDialog::validate()
{
QMessageBox::critical(
this, "Firewall Builder",
tr("Invalid IP address '%1'").arg(m_dialog->openais_address->text()),
tr("&Continue"), nullptr, nullptr,
0 );
tr("Invalid IP address '%1'").arg(m_dialog->openais_address->text()));
return false;
}
}

View File

@ -41,7 +41,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <QUndoStack>

View File

@ -47,7 +47,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
#include <QUndoStack>
#include <QFileInfo>

View File

@ -52,7 +52,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
#include <qtabwidget.h>
#include <qlistwidget.h>

View File

@ -104,8 +104,7 @@ bool pixFailoverOptionsDialog::validate()
if (!valid)
{
QMessageBox::warning(this, "Firewall Builder",
tr("Input not valid: %1").arg(message), "&Continue",
QString(), QString(), 0, 1);
tr("Input not valid: %1").arg(message));
focus->setFocus();
}
return valid;

View File

@ -43,8 +43,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
using namespace std;
using namespace libfwbuilder;

View File

@ -169,8 +169,7 @@ bool pixosIfaceOptsDialog::validate()
if (!valid)
{
QMessageBox::warning(this, "Firewall Builder",
tr("Input not valid: %1").arg(message), "&Continue",
QString(), QString(), 0, 1);
tr("Input not valid: %1").arg(message));
focus->setFocus();
}
return valid;

View File

@ -34,6 +34,7 @@
#include <QStringList>
#include <QComboBox>
#include <QtDebug>
#include <QRegularExpression>
#include "fwbuilder/Cluster.h"
#include "fwbuilder/Firewall.h"
@ -1143,13 +1144,14 @@ void guessInterfaceLabel(InterfaceData *idata)
QString qs_name = idata->name.c_str();
QString qs_label;
QRegExp pat1("Adaptive Security Appliance '(.*)' interface");
QRegExp pat2("Cisco PIX Security Appliance '(.*)' interface");
QRegExp pat3("PIX Firewall '(.*)' interface");
QRegularExpression pat1("Adaptive Security Appliance '(.*)' interface");
QRegularExpression pat2("Cisco PIX Security Appliance '(.*)' interface");
QRegularExpression pat3("PIX Firewall '(.*)' interface");
QRegularExpressionMatch match;
if (pat1.indexIn(qs_name) > -1) qs_label = pat1.cap(1);
if (pat2.indexIn(qs_name) > -1) qs_label = pat2.cap(1);
if (pat3.indexIn(qs_name) > -1) qs_label = pat3.cap(1);
if (qs_name.indexOf(pat1, 0, &match) > -1) qs_label = match.captured(1);
if (qs_name.indexOf(pat2, 0, &match) > -1) qs_label = match.captured(1);
if (qs_name.indexOf(pat3, 0, &match) > -1) qs_label = match.captured(1);
idata->label = qs_label.toStdString();
@ -1217,13 +1219,13 @@ void guessSecurityLevel(const string&, InterfaceData *idata)
void guessOSAndPlatformFromSysDescr(
const QString &sysDescr, QString &platform, QString &hostOS, QString &version)
{
QList<QRegExp> pix_re;
pix_re << QRegExp("Cisco PIX Firewall Version ([0-9\\.]+)")
<< QRegExp("Cisco PIX Security Appliance Version ([0-9\\.]+)")
<< QRegExp("Cisco Adaptive Security Appliance Version ([0-9\\.]+)");
QList<QRegularExpression> pix_re;
pix_re << QRegularExpression("Cisco PIX Firewall Version ([0-9\\.]+)")
<< QRegularExpression("Cisco PIX Security Appliance Version ([0-9\\.]+)")
<< QRegularExpression("Cisco Adaptive Security Appliance Version ([0-9\\.]+)");
QList<QRegExp> ios_re;
ios_re << QRegExp("Cisco Internetwork Operating System Software .* Version ([0-9\\.]+)");
QList<QRegularExpression> ios_re;
ios_re << QRegularExpression("Cisco Internetwork Operating System Software .* Version ([0-9\\.]+)");
platform = "";
hostOS = "";
@ -1235,25 +1237,26 @@ void guessOSAndPlatformFromSysDescr(
list<QStringPair> allowed_versions;
QString version_from_sysdescr;
QRegularExpressionMatch match;
foreach (QRegExp re, pix_re)
foreach (QRegularExpression re, pix_re)
{
if (re.indexIn(sysDescr) > -1)
if (sysDescr.indexOf(re, 0, &match) > -1)
{
platform = "pix";
hostOS = "pix_os";
version_from_sysdescr = re.cap(1);
version_from_sysdescr = match.captured(1);
}
}
foreach (QRegExp re, ios_re)
foreach (QRegularExpression re, ios_re)
{
if (re.indexIn(sysDescr) > -1)
if (sysDescr.indexOf(re, 0, &match) > -1)
{
platform = "iosacl";
hostOS = "ios";
version_from_sysdescr = re.cap(1);
version_from_sysdescr = match.captured(1);
}
}

View File

@ -49,7 +49,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
#include <qtabwidget.h>
#include <qlistwidget.h>

View File

@ -35,7 +35,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
#include <qtextedit.h>
#include <QUndoStack>

View File

@ -321,7 +321,7 @@ void secuwallosAdvancedDialog::buttonOpenURLClicked()
{
QMessageBox::warning
(this, "Firewall Builder",
message, "&Continue", QString(), QString(), 0, 1);
message);
}
}
@ -416,8 +416,7 @@ bool secuwallosAdvancedDialog::validate()
focus->setPalette(palette);
// display errror message
QMessageBox::warning(this, "Firewall Builder",
tr("Input not valid: %1").arg(message), "&Continue",
QString(), QString(), 0, 1);
tr("Input not valid: %1").arg(message));
}
return valid;
}

View File

@ -238,9 +238,7 @@ void ND_CreateObjectsPage::initializePage()
"and vlan interfaces to be the same. It is especially "
"important to review and fix generated objects if you "
"use MAC address spoofing."
),
tr("&Continue"), nullptr, nullptr,
0 );
));
}

View File

@ -389,8 +389,8 @@ void ND_ProgressPage::saveLog()
{
if (fwbdebug)
{
qDebug("Saving crawler log to file: %d chars",
m_dialog->discoveryLog->toPlainText().length());
qDebug() << QString("Saving crawler log to file: %1 chars")
.arg(m_dialog->discoveryLog->toPlainText().length());
qDebug("--------------------------------");
}
QTextStream strm(&f);

View File

@ -32,6 +32,7 @@
#include <QHostInfo>
#include <QtDebug>
#include <QRegularExpression>
using namespace std;
@ -98,12 +99,13 @@ bool ND_SetupPage::isSeedHostOK(const QString &hostName)
{
if (hostName.isEmpty()) return false;
QRegExp r = QRegExp("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",
Qt::CaseInsensitive); //non wildcard
QRegularExpression r = QRegularExpression(
QRegularExpression::anchoredPattern("^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$"),
QRegularExpression::CaseInsensitiveOption); //non wildcard
last_error = "";
if (r.exactMatch(hostName))
if (r.match(hostName).hasMatch())
{
try
{
@ -124,8 +126,10 @@ bool ND_SetupPage::isSeedHostOK(const QString &hostName)
bool ND_SetupPage::looksLikeIpAddress(const QString &s)
{
QRegExp r=QRegExp("^(\\d|\\.)+$",Qt::CaseInsensitive); //non wildcard
return r.exactMatch(s);
QRegularExpression r = QRegularExpression(
QRegularExpression::anchoredPattern("^(\\d|\\.)+$") ,
QRegularExpression::CaseInsensitiveOption); //non wildcard
return r.match(s).hasMatch();
}
void ND_SetupPage::displayStatusError(const QString &err)

View File

@ -36,7 +36,7 @@
#include "ND_SNMPParametersPage.h"
#include "FWWindow.h"
#include <QDesktopWidget>
#include <QScreen>
#include <QtDebug>
using namespace std;
@ -61,7 +61,7 @@ SNMPNetworkDiscoveryWizard::SNMPNetworkDiscoveryWizard(QWidget *parent) : QWizar
addPage(new ND_SelectLibraryPage(this));
addPage(new ND_CreateObjectsPage(this));
QRect sg = QApplication::desktop()->screenGeometry(mw);
QRect sg = mw->screen()->availableGeometry();
QSize screen_size = sg.size();
#if defined(Q_OS_MACX)

View File

@ -41,8 +41,6 @@
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qstackedwidget.h>
#include <qregexp.h>
using namespace std;
using namespace libfwbuilder;

View File

@ -31,6 +31,7 @@
#include "qmessagebox.h"
#include "qobject.h"
#include <QPushButton>
class MessageBoxUpgradePredicate: public libfwbuilder::XMLTools::UpgradePredicate
{
@ -40,20 +41,24 @@ class MessageBoxUpgradePredicate: public libfwbuilder::XMLTools::UpgradePredicat
virtual bool operator()(const std::string&) const
{
return QMessageBox::information( parent , "Firewall Builder",
QObject::tr(
"The data file you are trying to open has been \
saved with an older version of Firewall Builder. \
Opening it in this version will cause it to be \
upgraded, which may prevent older versions of \
the program from reading it. Backup copy of your \
file in the old format will be made in the same \
directory with extension '.bak'.\n\
Are you sure you want to open it?"),
QObject::tr("&Upgrade"),
QObject::tr("&Do not load the file"),
QString(),
0, 1 )==0;
QMessageBox msgBox;
msgBox.setWindowTitle("Firewall Builder");
msgBox.setText(QObject::tr("The data file you are trying to open has been \
saved with an older version of Firewall Builder. \
Opening it in this version will cause it to be \
upgraded, which may prevent older versions of \
the program from reading it. Backup copy of your \
file in the old format will be made in the same \
directory with extension '.bak'.\n\
Are you sure you want to open it?"));
msgBox.setIcon(QMessageBox::Information);
QPushButton *upgradeButton = msgBox.addButton(QObject::tr("&Upgrade"), QMessageBox::ActionRole);
QPushButton *cancelButton = msgBox.addButton(QObject::tr("&Do not load the file"), QMessageBox::RejectRole);
msgBox.setEscapeButton(cancelButton);
msgBox.exec();
return msgBox.clickedButton() == upgradeButton;
}
};

View File

@ -40,7 +40,7 @@
#include <QList>
#include <QStringList>
#include <QRegExp>
#include <QRegularExpression>
#include <QPixmap>
#include <QApplication>
#include <QFileInfo>
@ -212,9 +212,7 @@ bool isTreeReadWrite(QWidget *parent, FWObject *obj)
parent, "Firewall Builder",
QObject::tr("Impossible to apply changes because object is "
"located in read-only\npart of the tree or data "
"file was opened read-only"),
QObject::tr("&Continue"), 0, 0,
0, 2 );
"file was opened read-only"));
return false;
}
@ -235,8 +233,7 @@ bool validateName(QWidget *parent, FWObject *obj, const QString &newname)
QMessageBox::warning(
parent, "Firewall Builder",
QObject::tr("Object name should not be blank"),
QObject::tr("&Continue"), nullptr, nullptr, 0, 2 );
QObject::tr("Object name should not be blank"));
parent->blockSignals(false);
}
@ -277,8 +274,7 @@ bool validateName(QWidget *parent, FWObject *obj, const QString &newname)
parent, "Firewall Builder",
QObject::tr("Object with name '%1' already exists, "
"please choose different name.").
arg(o1->getName().c_str()),
QObject::tr("&Continue"), nullptr, nullptr, 0, 2 );
arg(o1->getName().c_str()));
parent->blockSignals(false);
}
@ -413,20 +409,20 @@ QString wordWrap(const QString& s, int maxchinline)
{
if (linestart<lastwdpos)
{
res.append(s.midRef(linestart,lastwdpos-linestart));
res.append(QStringView(s).mid(linestart,lastwdpos-linestart));
linestart=lastwdpos;
pos=lastwdpos;
}else
{
res.append(s.midRef(linestart,pos-linestart));
res.append(QStringView(s).mid(linestart,pos-linestart));
linestart=pos;
lastwdpos=pos;
}
}
else
{
res.append(s.midRef(linestart,pos-linestart));
res.append(QStringView(s).mid(linestart,pos-linestart));
while (++pos< s.length() && s.at(pos).isSpace()) ;
if (pos<s.length())
{
@ -442,7 +438,7 @@ QString wordWrap(const QString& s, int maxchinline)
chcount=0;
}
}
res.append(s.midRef(linestart,pos-linestart));
res.append(QStringView(s).mid(linestart,pos-linestart));
return res;
}
@ -585,7 +581,7 @@ QString _parseTokens(QStringList &args, const QChar closing_quote='\0')
*/
void parseCommandLine(const QString &cmd, QStringList &argv)
{
int first_arg = cmd.indexOf(QRegExp(" *-"));
int first_arg = cmd.indexOf(QRegularExpression(" *-"));
if (first_arg == -1)
{
// no arguments
@ -595,7 +591,7 @@ void parseCommandLine(const QString &cmd, QStringList &argv)
QString program = cmd.mid(0, first_arg).trimmed();
if (!program.isEmpty()) argv.append(program);
QStringList args = cmd.mid(first_arg).split(QRegExp("\\s+"));
QStringList args = cmd.mid(first_arg).split(QRegularExpression("\\s+"));
// QString::SkipEmptyParts);
// splits like this:
// ["", "-arg1", "val1", "-arg2", "\"value", "2", "\""]

View File

@ -169,8 +169,7 @@ bool vlanOnlyIfaceOptsDialog::validate()
if (!valid)
{
QMessageBox::warning(this, "Firewall Builder",
tr("Input not valid: %1").arg(message), "&Continue",
QString(), QString(), 0, 1);
tr("Input not valid: %1").arg(message));
focus->setFocus();
}
return valid;

View File

@ -113,8 +113,7 @@ bool vrrpOptionsDialog::validate()
if (!valid)
{
QMessageBox::warning(this, "Firewall Builder",
tr("Input not valid: %1").arg(message), "&Continue",
QString(), QString(), 0, 1);
tr("Input not valid: %1").arg(message));
focus->setFocus();
}
return valid;

View File

@ -57,7 +57,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -92,7 +94,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -44,7 +44,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -77,7 +79,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -104,7 +104,11 @@ string OSConfigurator_bsd::printFunctions()
* get addresses of dynamic interfaces
*/
QString script_buffer;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextStream ostr(&script_buffer, QIODevice::WriteOnly);
#else
QTextStream ostr(&script_buffer, QIODeviceBase::WriteOnly);
#endif
FWObjectTypedChildIterator j=fw->findByType(Interface::TYPENAME);
for ( ; j!=j.end(); ++j )
{

View File

@ -57,7 +57,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -95,7 +97,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -57,7 +57,9 @@
#include <QCoreApplication>
#include <QStringList>
#include <QTextCodec>
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif
#include "../common/init.cpp"
@ -92,7 +94,9 @@ int main(int argc, char **argv)
QCoreApplication app(argc, argv, false);
// compilers always write file names into manifest in Utf8
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QTextCodec::setCodecForLocale(QTextCodec::codecForName("Utf8"));
#endif
QStringList args = app.arguments();

View File

@ -34,7 +34,6 @@
#include <iostream>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
#include <QToolButton>

View File

@ -34,7 +34,6 @@
#include <iostream>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
#include <QToolButton>

View File

@ -34,7 +34,6 @@
#include <iostream>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
#include <QToolButton>
@ -223,7 +222,7 @@ void FirewallDialogTest::testDialog()
firewall->setInt("lastModified", 123456789);
t = 123456789;
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
dialog->changed();
QVERIFY(last_modified->text() == dt.toString());
@ -234,7 +233,7 @@ void FirewallDialogTest::testDialog()
firewall->setInt("lastCompiled", 123456789);
t = 123456789;
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
dialog->changed();
QVERIFY(last_compiled->text() == dt.toString());
@ -245,7 +244,7 @@ void FirewallDialogTest::testDialog()
firewall->setInt("lastInstalled", 123456789);
t = 123456789;
dt.setTime_t(t);
dt.setSecsSinceEpoch(t);
dialog->changed();
QVERIFY(last_installed->text() == dt.toString());
}

View File

@ -34,7 +34,6 @@
#include <iostream>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
#include <QToolButton>

View File

@ -34,7 +34,6 @@
#include <iostream>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
#include <QToolButton>

View File

@ -34,7 +34,6 @@
#include <iostream>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
#include <QToolButton>

View File

@ -34,7 +34,6 @@
#include <iostream>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
#include <QToolButton>

View File

@ -34,7 +34,6 @@
#include <iostream>
#include <QProcess>
#include <QRegExp>
#include <QDebug>
#include <QToolButton>

View File

@ -49,7 +49,7 @@
#include <QFile>
#include <QStringList>
#include <QString>
#include <QRegExp>
#include <QRegularExpression>
using namespace std;