fort/src/ui/util/confutil.h

62 lines
1.7 KiB
C
Raw Normal View History

2017-08-29 08:40:23 +00:00
#ifndef CONFUTIL_H
#define CONFUTIL_H
#include <QObject>
#include <QByteArray>
#include <QList>
#include <QMap>
class AppGroup;
class FirewallConf;
class Ip4Range;
typedef QMap<QString, quint32> appperms_map_t;
typedef QVector<quint32> appperms_arr_t;
class ConfUtil : public QObject
{
Q_OBJECT
Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorMessageChanged)
public:
explicit ConfUtil(QObject *parent = nullptr);
QString errorMessage() const { return m_errorMessage; }
signals:
void errorMessageChanged();
public slots:
2017-08-31 03:05:45 +00:00
int write(const FirewallConf &conf, QByteArray &buf);
2017-08-31 03:20:17 +00:00
int writeFlags(const FirewallConf &conf, QByteArray &buf);
2017-08-29 08:40:23 +00:00
private:
void setErrorMessage(const QString &errorMessage);
// Convert app. groups to plain lists
bool parseAppGroups(const QList<AppGroup *> &appGroups,
QStringList &groupNames,
int &groupNamesLen,
QStringList &appPaths,
int &appPathsLen,
appperms_arr_t &appPerms);
bool parseApps(const QString &text, bool blocked,
appperms_map_t &appPermsMap, int groupOffset);
static QString parseAppPath(const QStringRef &line);
static void writeData(char *output, const FirewallConf &conf,
const Ip4Range &incRange, const Ip4Range &excRange,
const QStringList &groupNames, const QStringList &appPaths,
2017-08-30 08:34:37 +00:00
const appperms_arr_t &appPerms);
2017-08-29 08:40:23 +00:00
static void writeNumbers(char **data, const QVector<quint32> &array);
static void writeStrings(char **data, const QStringList &list);
private:
QString m_errorMessage;
};
#endif // CONFUTIL_H