UI: Refactor models.

This commit is contained in:
Nodir Temirkhodjaev 2021-05-30 15:14:19 +03:00
parent 8269330a6d
commit 6be568c174
17 changed files with 206 additions and 177 deletions

View File

@ -100,6 +100,17 @@ const char *const sqlUpdateTask = "UPDATE task"
" last_run = ?5, last_success = ?6, data = ?7"
" WHERE task_id = ?1;";
const char *const sqlSelectAppPaths = "SELECT app_id, path FROM app;";
const char *const sqlSelectAppById = "SELECT"
" g.order_index as group_index,"
" t.path,"
" t.use_group_perm,"
" t.blocked"
" FROM app t"
" JOIN app_group g ON g.app_group_id = t.app_group_id"
" WHERE app_id = ?1;";
const char *const sqlSelectApps = "SELECT"
" g.order_index as group_index,"
" t.path,"
@ -114,8 +125,7 @@ const char *const sqlSelectEndAppsCount = "SELECT COUNT(*) FROM app"
" WHERE end_time IS NOT NULL AND end_time != 0"
" AND blocked = 0;";
const char *const sqlSelectEndedApps = "SELECT t.app_id, t.app_group_id,"
" g.order_index as group_index,"
const char *const sqlSelectEndedApps = "SELECT t.app_id, g.order_index as group_index,"
" t.path, t.name, t.use_group_perm"
" FROM app t"
" JOIN app_group g ON g.app_group_id = t.app_group_id"
@ -134,7 +144,7 @@ const char *const sqlUpsertApp =
const char *const sqlInsertAppAlert = "INSERT INTO app_alert(app_id) VALUES(?1);";
const char *const sqlDeleteApp = "DELETE FROM app WHERE app_id = ?1;";
const char *const sqlDeleteApp = "DELETE FROM app WHERE app_id = ?1 RETURNING path;";
const char *const sqlDeleteAppAlert = "DELETE FROM app_alert WHERE app_id = ?1;";
@ -145,6 +155,8 @@ const char *const sqlUpdateApp = "UPDATE app"
const char *const sqlUpdateAppName = "UPDATE app SET name = ?2 WHERE app_id = ?1;";
const char *const sqlUpdateAppBlocked = "UPDATE app SET blocked = ?2 WHERE app_id = ?1;";
const char *const sqlUpdateAppResetGroup = "UPDATE app"
" SET app_group_id = ?2"
" WHERE app_group_id = ?1;";
@ -749,18 +761,15 @@ bool ConfManager::addApp(const QString &appPath, const QString &appName, const Q
return ok;
}
bool ConfManager::deleteApp(qint64 appId, const QString &appPath)
bool ConfManager::deleteApp(qint64 appId)
{
if (!updateDriverDeleteApp(appPath))
return false;
bool ok = false;
sqliteDb()->beginTransaction();
const auto vars = QVariantList() << appId;
sqliteDb()->executeEx(sqlDeleteApp, vars, 0, &ok);
const QString appPath = sqliteDb()->executeEx(sqlDeleteApp, vars, 1, &ok).toString();
if (ok) {
sqliteDb()->executeEx(sqlDeleteAppAlert, vars, 0, &ok);
}
@ -768,15 +777,49 @@ bool ConfManager::deleteApp(qint64 appId, const QString &appPath)
checkResult(ok, true);
if (ok) {
updateDriverDeleteApp(appPath);
emitAppChanged();
}
return ok;
}
bool ConfManager::updateApp(qint64 appId, const QString &appPath, const QString &appName,
const QDateTime &endTime, qint64 groupId, int groupIndex, bool useGroupPerm, bool blocked)
bool ConfManager::purgeApps()
{
QVector<qint64> appIdList;
// Collect non-existent apps
{
SqliteStmt stmt;
if (!sqliteDb()->prepare(stmt, sqlSelectAppPaths))
return false;
while (stmt.step() == SqliteStmt::StepRow) {
const QString appPath = stmt.columnText(1);
if (!FileUtil::fileExists(appPath) && !FileUtil::isSystemApp(appPath)) {
const qint64 appId = stmt.columnInt64(0);
appIdList.append(appId);
}
}
}
// Delete apps
for (const qint64 appId : appIdList) {
deleteApp(appId);
}
return true;
}
bool ConfManager::updateApp(qint64 appId, const QString &appPath, const QString &appName,
const QDateTime &endTime, int groupIndex, bool useGroupPerm, bool blocked)
{
const AppGroup *appGroup = conf()->appGroupAt(groupIndex);
if (appGroup->isNull())
return false;
if (!updateDriverUpdateApp(appPath, groupIndex, useGroupPerm, blocked))
return false;
@ -784,8 +827,8 @@ bool ConfManager::updateApp(qint64 appId, const QString &appPath, const QString
sqliteDb()->beginTransaction();
const auto vars = QVariantList() << appId << groupId << appName << useGroupPerm << blocked
<< (!endTime.isNull() ? endTime : QVariant());
const auto vars = QVariantList() << appId << appGroup->id() << appName << useGroupPerm
<< blocked << (!endTime.isNull() ? endTime : QVariant());
sqliteDb()->executeEx(sqlUpdateApp, vars, 0, &ok);
if (ok) {
@ -799,7 +842,35 @@ bool ConfManager::updateApp(qint64 appId, const QString &appPath, const QString
m_appEndTimer.start();
}
emit appUpdated();
emitAppUpdated();
}
return ok;
}
bool ConfManager::updateAppBlocked(qint64 appId, bool blocked)
{
bool changed = false;
if (!updateDriverUpdateAppBlocked(appId, blocked, changed))
return false;
bool ok = true;
sqliteDb()->beginTransaction();
const auto vars = QVariantList() << appId << blocked;
if (changed) {
sqliteDb()->executeEx(sqlUpdateAppBlocked, vars, 0, &ok);
}
if (ok) {
sqliteDb()->executeEx(sqlDeleteAppAlert, { appId }, 0, &ok);
}
checkResult(ok, true);
if (ok) {
emitAppUpdated();
}
return ok;
@ -816,7 +887,7 @@ bool ConfManager::updateAppName(qint64 appId, const QString &appName)
checkResult(ok);
if (ok) {
emit appUpdated();
emitAppUpdated();
}
return ok;
@ -855,24 +926,14 @@ void ConfManager::updateAppEndTimes()
stmt.bindDateTime(1, QDateTime::currentDateTime());
bool isAppEndTimesUpdated = false;
while (stmt.step() == SqliteStmt::StepRow) {
const qint64 appId = stmt.columnInt64(0);
const qint64 groupId = stmt.columnInt64(1);
const int groupIndex = stmt.columnInt(2);
const QString appPath = stmt.columnText(3);
const QString appName = stmt.columnText(4);
const bool useGroupPerm = stmt.columnBool(5);
if (updateApp(appId, appPath, appName, QDateTime(), groupId, groupIndex, useGroupPerm,
true)) {
isAppEndTimesUpdated = true;
}
}
if (isAppEndTimesUpdated) {
emitAppUpdated();
updateApp(appId, appPath, appName, QDateTime(), groupIndex, useGroupPerm, true);
}
}
@ -1087,6 +1148,31 @@ bool ConfManager::updateDriverUpdateApp(
return true;
}
bool ConfManager::updateDriverUpdateAppBlocked(qint64 appId, bool blocked, bool &changed)
{
SqliteStmt stmt;
if (!sqliteDb()->prepare(stmt, sqlSelectAppById))
return false;
stmt.bindInt64(1, appId);
if (stmt.step() != SqliteStmt::StepRow)
return false;
const int groupIndex = stmt.columnInt(0);
const QString appPath = stmt.columnText(1);
const bool useGroupPerm = stmt.columnBool(2);
const bool wasBlocked = stmt.columnBool(3);
if (blocked != wasBlocked) {
if (!updateDriverUpdateApp(appPath, groupIndex, useGroupPerm, blocked))
return false;
changed = true;
}
return true;
}
void ConfManager::updateDriverZones(quint32 zonesMask, quint32 enabledMask, quint32 dataSize,
const QList<QByteArray> &zonesData)
{

View File

@ -73,10 +73,11 @@ public:
qint64 appIdByPath(const QString &appPath);
virtual bool addApp(const QString &appPath, const QString &appName, const QDateTime &endTime,
int groupIndex, bool useGroupPerm, bool blocked, bool alerted = false);
virtual bool deleteApp(qint64 appId, const QString &appPath);
virtual bool deleteApp(qint64 appId);
virtual bool purgeApps();
virtual bool updateApp(qint64 appId, const QString &appPath, const QString &appName,
const QDateTime &endTime, qint64 groupId, int groupIndex, bool useGroupPerm,
bool blocked);
const QDateTime &endTime, int groupIndex, bool useGroupPerm, bool blocked);
virtual bool updateAppBlocked(qint64 appId, bool blocked);
virtual bool updateAppName(qint64 appId, const QString &appName);
bool walkApps(const std::function<walkAppsCallback> &func) override;
@ -134,6 +135,7 @@ private:
bool updateDriverDeleteApp(const QString &appPath);
bool updateDriverUpdateApp(const QString &appPath, int groupIndex, bool useGroupPerm,
bool blocked, bool remove = false);
bool updateDriverUpdateAppBlocked(qint64 appId, bool blocked, bool &changed);
bool updateDriverZoneFlag(int zoneId, bool enabled);
bool loadFromDb(FirewallConf &conf, bool &isNew);

View File

@ -23,7 +23,9 @@ const char *const commandString(Command cmd)
CASE_STRING(Rpc_ConfManager_save)
CASE_STRING(Rpc_ConfManager_addApp)
CASE_STRING(Rpc_ConfManager_deleteApp)
CASE_STRING(Rpc_ConfManager_purgeApps)
CASE_STRING(Rpc_ConfManager_updateApp)
CASE_STRING(Rpc_ConfManager_updateAppBlocked)
CASE_STRING(Rpc_ConfManager_updateAppName)
CASE_STRING(Rpc_ConfManager_addZone)
CASE_STRING(Rpc_ConfManager_deleteZone)
@ -90,7 +92,9 @@ RpcManager managerByCommand(Command cmd)
case Rpc_ConfManager_save:
case Rpc_ConfManager_addApp:
case Rpc_ConfManager_deleteApp:
case Rpc_ConfManager_purgeApps:
case Rpc_ConfManager_updateApp:
case Rpc_ConfManager_updateAppBlocked:
case Rpc_ConfManager_updateAppName:
case Rpc_ConfManager_addZone:
case Rpc_ConfManager_deleteZone:
@ -146,7 +150,9 @@ bool commandRequiresValidation(Command cmd)
case Rpc_ConfManager_save:
case Rpc_ConfManager_addApp:
case Rpc_ConfManager_deleteApp:
case Rpc_ConfManager_purgeApps:
case Rpc_ConfManager_updateApp:
case Rpc_ConfManager_updateAppBlocked:
case Rpc_ConfManager_updateAppName:
case Rpc_ConfManager_addZone:
case Rpc_ConfManager_deleteZone:

View File

@ -22,7 +22,9 @@ enum Command : qint8 {
Rpc_ConfManager_save,
Rpc_ConfManager_addApp,
Rpc_ConfManager_deleteApp,
Rpc_ConfManager_purgeApps,
Rpc_ConfManager_updateApp,
Rpc_ConfManager_updateAppBlocked,
Rpc_ConfManager_updateAppName,
Rpc_ConfManager_addZone,
Rpc_ConfManager_deleteZone,

View File

@ -378,7 +378,7 @@ bool ProgramEditDialog::save()
// Add new app or edit non-selected app
if (appIdsCount == 0) {
return appListModel()->addApp(appPath, appName, endTime, groupIndex, useGroupPerm, blocked);
return confManager()->addApp(appPath, appName, endTime, groupIndex, useGroupPerm, blocked);
}
// Edit selected app
@ -398,14 +398,14 @@ bool ProgramEditDialog::saveApp(const QString &appPath, const QString &appName,
|| endTime != m_appRow.endTime);
if (appEdited) {
return appListModel()->updateApp(
return confManager()->updateApp(
m_appRow.appId, appPath, appName, endTime, groupIndex, useGroupPerm, blocked);
}
if (appName == m_appRow.appName)
return true;
return appListModel()->updateAppName(m_appRow.appId, appName);
return confManager()->updateAppName(m_appRow.appId, appName);
}
bool ProgramEditDialog::saveMulti(
@ -414,7 +414,7 @@ bool ProgramEditDialog::saveMulti(
for (qint64 appId : m_appIdList) {
const auto appRow = appListModel()->appRowById(appId);
if (!appListModel()->updateApp(appId, appRow.appPath, appRow.appName, endTime, groupIndex,
if (!confManager()->updateApp(appId, appRow.appPath, appRow.appName, endTime, groupIndex,
useGroupPerm, blocked))
return false;
}

View File

@ -213,7 +213,7 @@ QLayout *ProgramsWindow::setupHeader()
connect(m_actPurgeApps, &QAction::triggered, this, [&] {
if (fortManager()->showQuestionBox(
tr("Are you sure to remove all non-existent programs?"))) {
appListModel()->purgeApps();
confManager()->purgeApps();
}
});
@ -364,24 +364,13 @@ void ProgramsWindow::addNewProgram()
void ProgramsWindow::editSelectedPrograms()
{
const auto rows = m_appListView->selectedRows();
if (rows.isEmpty())
const QVector<qint64> appIdList = selectedAppIdList();
if (appIdList.isEmpty())
return;
bool isFirstAppRow = true;
AppRow firstAppRow;
QVector<qint64> appIdList;
const auto appRow = appListCurrentRow();
for (int row : rows) {
const auto appRow = appListModel()->appRowAt(row);
if (isFirstAppRow) {
isFirstAppRow = false;
firstAppRow = appRow;
}
appIdList.append(appRow.appId);
}
openAppEditForm(firstAppRow, appIdList);
openAppEditForm(appRow, appIdList);
}
void ProgramsWindow::openAppEditForm(const AppRow &appRow, const QVector<qint64> &appIdList)
@ -392,32 +381,25 @@ void ProgramsWindow::openAppEditForm(const AppRow &appRow, const QVector<qint64>
m_formAppEdit->activate();
}
void ProgramsWindow::updateApp(int row, bool blocked)
{
const auto appRow = appListModel()->appRowAt(row);
appListModel()->updateApp(appRow.appId, appRow.appPath, appRow.appName, QDateTime(),
appRow.groupIndex, appRow.useGroupPerm, blocked);
}
void ProgramsWindow::deleteApp(int row)
{
const auto appRow = appListModel()->appRowAt(row);
appListModel()->deleteApp(appRow.appId, appRow.appPath);
confManager()->deleteApp(appRow.appId);
}
void ProgramsWindow::updateSelectedApps(bool blocked)
{
const auto rows = m_appListView->selectedRows();
for (int i = rows.size(); --i >= 0;) {
updateApp(rows.at(i), blocked);
const QVector<qint64> appIdList = selectedAppIdList();
for (const qint64 appId : appIdList) {
confManager()->updateAppBlocked(appId, blocked);
}
}
void ProgramsWindow::deleteSelectedApps()
{
const auto rows = m_appListView->selectedRows();
for (int i = rows.size(); --i >= 0;) {
deleteApp(rows.at(i));
const QVector<qint64> appIdList = selectedAppIdList();
for (const qint64 appId : appIdList) {
confManager()->deleteApp(appId);
}
}
@ -426,8 +408,26 @@ int ProgramsWindow::appListCurrentIndex() const
return m_appListView->currentRow();
}
AppRow ProgramsWindow::appListCurrentRow() const
{
return appListModel()->appRowAt(appListCurrentIndex());
}
QString ProgramsWindow::appListCurrentPath() const
{
const auto appRow = appListModel()->appRowAt(appListCurrentIndex());
const auto appRow = appListCurrentRow();
return appRow.isNull() ? QString() : appRow.appPath;
}
QVector<qint64> ProgramsWindow::selectedAppIdList() const
{
QVector<qint64> list;
const auto rows = m_appListView->selectedRows();
for (int row : rows) {
const auto appRow = appListModel()->appRowAt(row);
list.append(appRow.appId);
}
return list;
}

View File

@ -65,15 +65,17 @@ private:
void editSelectedPrograms();
void openAppEditForm(const AppRow &appRow, const QVector<qint64> &appIdList = {});
void updateApp(int row, bool blocked);
void deleteApp(int row);
void updateSelectedApps(bool blocked);
void deleteSelectedApps();
int appListCurrentIndex() const;
AppRow appListCurrentRow() const;
QString appListCurrentPath() const;
QVector<qint64> selectedAppIdList() const;
private:
ProgramsController *m_ctrl = nullptr;
WidgetWindowStateWatcher *m_stateWatcher = nullptr;

View File

@ -431,7 +431,7 @@ bool ZonesWindow::saveZoneEditForm()
// Add new zone
if (m_formZoneIsNew) {
int zoneId;
if (zoneListModel()->addZone(
if (confManager()->addZone(
zoneName, sourceCode, url, formData, enabled, customUrl, zoneId)) {
m_zoneListView->selectCell(zoneId - 1);
return true;
@ -450,12 +450,12 @@ bool ZonesWindow::saveZoneEditForm()
if (!zoneEdited) {
if (zoneNameEdited) {
return zoneListModel()->updateZoneName(zoneRow.zoneId, zoneName);
return confManager()->updateZoneName(zoneRow.zoneId, zoneName);
}
return true;
}
return zoneListModel()->updateZone(
return confManager()->updateZone(
zoneRow.zoneId, zoneName, sourceCode, url, formData, enabled, customUrl);
}
@ -463,14 +463,14 @@ void ZonesWindow::updateZone(int row, bool enabled)
{
const auto zoneRow = zoneListModel()->zoneRowAt(row);
zoneListModel()->updateZone(zoneRow.zoneId, zoneRow.zoneName, zoneRow.sourceCode, zoneRow.url,
confManager()->updateZone(zoneRow.zoneId, zoneRow.zoneName, zoneRow.sourceCode, zoneRow.url,
zoneRow.formData, enabled, zoneRow.customUrl);
}
void ZonesWindow::deleteZone(int row)
{
const auto zoneRow = zoneListModel()->zoneRowAt(row);
zoneListModel()->deleteZone(zoneRow.zoneId, row);
confManager()->deleteZone(zoneRow.zoneId);
}
void ZonesWindow::updateSelectedZone(bool enabled)

View File

@ -298,45 +298,6 @@ AppRow AppListModel::appRowByPath(const QString &appPath) const
return appRow;
}
bool AppListModel::addApp(const QString &appPath, const QString &appName, const QDateTime &endTime,
int groupIndex, bool useGroupPerm, bool blocked)
{
return confManager()->addApp(appPath, appName, endTime, groupIndex, useGroupPerm, blocked);
}
bool AppListModel::updateApp(qint64 appId, const QString &appPath, const QString &appName,
const QDateTime &endTime, int groupIndex, bool useGroupPerm, bool blocked)
{
const auto groupId = conf()->appGroupAt(groupIndex)->id();
return confManager()->updateApp(
appId, appPath, appName, endTime, groupId, groupIndex, useGroupPerm, blocked);
}
bool AppListModel::updateAppName(qint64 appId, const QString &appName)
{
return confManager()->updateAppName(appId, appName);
}
void AppListModel::deleteApp(qint64 appId, const QString &appPath)
{
confManager()->deleteApp(appId, appPath);
}
void AppListModel::purgeApps()
{
for (int row = rowCount(); --row >= 0;) {
const auto appRow = appRowAt(row);
const auto appPath = appRow.appPath;
if (!FileUtil::fileExists(appPath)) {
AppInfo appInfo;
if (!AppInfoUtil::getInfo(appPath, appInfo)) {
deleteApp(appRow.appId, appPath);
}
}
}
}
bool AppListModel::updateTableRow(int row) const
{
return updateAppRow(sql(), { row }, m_appRow);

View File

@ -52,14 +52,6 @@ public:
AppRow appRowById(qint64 appId) const;
AppRow appRowByPath(const QString &appPath) const;
bool addApp(const QString &appPath, const QString &appName, const QDateTime &endTime,
int groupIndex, bool useGroupPerm, bool blocked);
bool updateApp(qint64 appId, const QString &appPath, const QString &appName,
const QDateTime &endTime, int groupIndex, bool useGroupPerm, bool blocked);
bool updateAppName(qint64 appId, const QString &appName);
void deleteApp(qint64 appId, const QString &appPath);
void purgeApps();
protected:
bool updateTableRow(int row) const override;
TableRow &tableRow() const override { return m_appRow; }

View File

@ -121,7 +121,7 @@ bool ZoneListModel::setData(const QModelIndex &index, const QVariant &value, int
switch (role) {
case Qt::CheckStateRole:
const auto zoneRow = zoneRowAt(index.row());
return updateZoneEnabled(zoneRow.zoneId, !zoneRow.enabled);
return confManager()->updateZoneEnabled(zoneRow.zoneId, !zoneRow.enabled);
}
return false;
@ -145,42 +145,6 @@ const ZoneRow &ZoneListModel::zoneRowAt(int row) const
return m_zoneRow;
}
bool ZoneListModel::addZone(const QString &zoneName, const QString &sourceCode, const QString &url,
const QString &formData, bool enabled, bool customUrl, int &zoneId)
{
return confManager()->addZone(zoneName, sourceCode, url, formData, enabled, customUrl, zoneId);
}
bool ZoneListModel::updateZone(int zoneId, const QString &zoneName, const QString &sourceCode,
const QString &url, const QString &formData, bool enabled, bool customUrl)
{
return confManager()->updateZone(
zoneId, zoneName, sourceCode, url, formData, enabled, customUrl);
}
bool ZoneListModel::updateZoneName(int zoneId, const QString &zoneName)
{
return confManager()->updateZoneName(zoneId, zoneName);
}
bool ZoneListModel::updateZoneEnabled(int zoneId, bool enabled)
{
return confManager()->updateZoneEnabled(zoneId, enabled);
}
bool ZoneListModel::updateZoneResult(int zoneId, int addressCount, const QString &textChecksum,
const QString &binChecksum, const QDateTime &sourceModTime, const QDateTime &lastRun,
const QDateTime &lastSuccess)
{
return confManager()->updateZoneResult(
zoneId, addressCount, textChecksum, binChecksum, sourceModTime, lastRun, lastSuccess);
}
void ZoneListModel::deleteZone(int zoneId, int row)
{
confManager()->deleteZone(zoneId);
}
QString ZoneListModel::zoneNameById(int zoneId)
{
static const char *const sql = "SELECT name FROM zone WHERE zone_id = ?1;";

View File

@ -55,17 +55,6 @@ public:
const ZoneRow &zoneRowAt(int row) const;
bool addZone(const QString &zoneName, const QString &sourceCode, const QString &url,
const QString &formData, bool enabled, bool customUrl, int &zoneId);
bool updateZone(int zoneId, const QString &zoneName, const QString &sourceCode,
const QString &url, const QString &formData, bool enabled, bool customUrl);
bool updateZoneName(int zoneId, const QString &zoneName);
bool updateZoneEnabled(int zoneId, bool enabled);
bool updateZoneResult(int zoneId, int addressCount, const QString &textChecksum,
const QString &binChecksum, const QDateTime &sourceModTime, const QDateTime &lastRun,
const QDateTime &lastSuccess);
void deleteZone(int zoneId, int row);
QString zoneNameById(int zoneId);
QVariant zoneTypeByCode(const QString &typeCode) const;

View File

@ -32,16 +32,26 @@ bool ConfManagerRpc::addApp(const QString &appPath, const QString &appName,
{ appPath, appName, endTime, groupIndex, useGroupPerm, blocked });
}
bool ConfManagerRpc::deleteApp(qint64 appId, const QString &appPath)
bool ConfManagerRpc::deleteApp(qint64 appId)
{
return rpcManager()->doOnServer(Control::Rpc_ConfManager_deleteApp, { appId, appPath });
return rpcManager()->doOnServer(Control::Rpc_ConfManager_deleteApp, { appId });
}
bool ConfManagerRpc::purgeApps()
{
return rpcManager()->doOnServer(Control::Rpc_ConfManager_purgeApps);
}
bool ConfManagerRpc::updateApp(qint64 appId, const QString &appPath, const QString &appName,
const QDateTime &endTime, qint64 groupId, int groupIndex, bool useGroupPerm, bool blocked)
const QDateTime &endTime, int groupIndex, bool useGroupPerm, bool blocked)
{
return rpcManager()->doOnServer(Control::Rpc_ConfManager_updateApp,
{ appId, appPath, appName, endTime, groupId, groupIndex, useGroupPerm, blocked });
{ appId, appPath, appName, endTime, groupIndex, useGroupPerm, blocked });
}
bool ConfManagerRpc::updateAppBlocked(qint64 appId, bool blocked)
{
return rpcManager()->doOnServer(Control::Rpc_ConfManager_updateAppBlocked, { appId, blocked });
}
bool ConfManagerRpc::updateAppName(qint64 appId, const QString &appName)

View File

@ -19,10 +19,11 @@ public:
bool addApp(const QString &appPath, const QString &appName, const QDateTime &endTime,
int groupIndex, bool useGroupPerm, bool blocked, bool alerted = false) override;
bool deleteApp(qint64 appId, const QString &appPath) override;
bool deleteApp(qint64 appId) override;
bool purgeApps() override;
bool updateApp(qint64 appId, const QString &appPath, const QString &appName,
const QDateTime &endTime, qint64 groupId, int groupIndex, bool useGroupPerm,
bool blocked) override;
const QDateTime &endTime, int groupIndex, bool useGroupPerm, bool blocked) override;
bool updateAppBlocked(qint64 appId, bool blocked) override;
bool updateAppName(qint64 appId, const QString &appName) override;
bool addZone(const QString &zoneName, const QString &sourceCode, const QString &url,

View File

@ -333,15 +333,21 @@ bool RpcManager::processConfManagerRpc(
args.value(5).toBool()));
return true;
case Control::Rpc_ConfManager_deleteApp:
sendResult(
w, confManager()->deleteApp(args.value(0).toLongLong(), args.value(1).toString()));
sendResult(w, confManager()->deleteApp(args.value(0).toLongLong()));
return true;
case Control::Rpc_ConfManager_purgeApps:
sendResult(w, confManager()->purgeApps());
return true;
case Control::Rpc_ConfManager_updateApp:
sendResult(w,
confManager()->updateApp(args.value(0).toLongLong(), args.value(1).toString(),
args.value(2).toString(), args.value(3).toDateTime(),
args.value(4).toLongLong(), args.value(5).toInt(), args.value(6).toBool(),
args.value(7).toBool()));
args.value(2).toString(), args.value(3).toDateTime(), args.value(4).toInt(),
args.value(5).toBool(), args.value(6).toBool()));
return true;
case Control::Rpc_ConfManager_updateAppBlocked:
sendResult(w,
confManager()->updateAppBlocked(
args.value(0).toLongLong(), args.value(1).toBool()));
return true;
case Control::Rpc_ConfManager_updateAppName:
sendResult(w,

View File

@ -2,6 +2,7 @@
#include <QDir>
#include "../conf/confmanager.h"
#include "../fortmanager.h"
#include "../fortsettings.h"
#include "../model/zonelistmodel.h"
@ -20,6 +21,11 @@ TaskZoneDownloader *TaskInfoZoneDownloader::zoneDownloader() const
return static_cast<TaskZoneDownloader *>(taskWorker());
}
ConfManager *TaskInfoZoneDownloader::confManager() const
{
return fortManager()->confManager();
}
ZoneListModel *TaskInfoZoneDownloader::zoneListModel() const
{
return fortManager()->zoneListModel();
@ -148,7 +154,7 @@ void TaskInfoZoneDownloader::processSubResult(bool success)
const auto now = QDateTime::currentDateTime();
const auto lastSuccess = success ? now : worker->lastSuccess();
zoneListModel()->updateZoneResult(
confManager()->updateZoneResult(
zoneId, addressCount, textChecksum, binChecksum, sourceModTime, now, lastSuccess);
addSubResult(worker, success);

View File

@ -5,6 +5,7 @@
#include "taskinfo.h"
class ConfManager;
class TaskZoneDownloader;
class ZoneListModel;
@ -16,6 +17,7 @@ public:
explicit TaskInfoZoneDownloader(TaskManager &taskManager);
TaskZoneDownloader *zoneDownloader() const;
ConfManager *confManager() const;
ZoneListModel *zoneListModel() const;
signals: