UI: Programs: Edit Wildcard paths

This commit is contained in:
Nodir Temirkhodjaev 2023-12-04 18:31:01 +03:00
parent 08d12672e2
commit 78c7a26d19
4 changed files with 29 additions and 12 deletions

View File

@ -168,11 +168,11 @@ const char *const sqlDeleteApp = "DELETE FROM app WHERE app_id = ?1 RETURNING pa
const char *const sqlDeleteAppAlert = "DELETE FROM app_alert WHERE app_id = ?1;";
const char *const sqlUpdateApp = "UPDATE app"
" SET app_group_id = ?2, origin_path = ?3, name = ?4,"
" is_wildcard = ?5, use_group_perm = ?6,"
" apply_child = ?7, lan_only = ?8,"
" log_blocked = ?9, log_conn = ?10,"
" blocked = ?11, kill_process = ?12, end_time = ?13"
" SET app_group_id = ?2, origin_path = ?3, path = ?4,"
" name = ?5, is_wildcard = ?6, use_group_perm = ?7,"
" apply_child = ?8, lan_only = ?9,"
" log_blocked = ?10, log_conn = ?11,"
" blocked = ?12, kill_process = ?13, end_time = ?14"
" WHERE app_id = ?1;";
const char *const sqlUpdateAppName = "UPDATE app SET name = ?2 WHERE app_id = ?1;";
@ -974,9 +974,10 @@ bool ConfManager::updateApp(const App &app)
sqliteDb()->beginTransaction();
const auto vars = QVariantList()
<< app.appId << appGroup->id() << app.appOriginPath << app.appName << app.isWildcard
<< app.useGroupPerm << app.applyChild << app.lanOnly << app.logBlocked << app.logConn
<< app.blocked << app.killProcess << (!app.endTime.isNull() ? app.endTime : QVariant());
<< app.appId << appGroup->id() << app.appOriginPath << app.appPath << app.appName
<< app.isWildcard << app.useGroupPerm << app.applyChild << app.lanOnly << app.logBlocked
<< app.logConn << app.blocked << app.killProcess
<< (!app.endTime.isNull() ? app.endTime : QVariant());
sqliteDb()->executeEx(sqlUpdateApp, vars, 0, &ok);

View File

@ -26,8 +26,12 @@ bool ConfManagerRpc::addApp(const App &app)
void ConfManagerRpc::deleteApps(const QVector<qint64> &appIdList)
{
IoC<RpcManager>()->doOnServer(
Control::Rpc_ConfManager_deleteApps, { VariantUtil::vectorToList(appIdList) });
const QVariantList appIdVarList = VariantUtil::vectorToList(appIdList);
QVariantList args;
VariantUtil::addToList(args, appIdVarList);
IoC<RpcManager>()->doOnServer(Control::Rpc_ConfManager_deleteApps, args);
}
bool ConfManagerRpc::purgeApps()
@ -46,8 +50,13 @@ bool ConfManagerRpc::updateApp(const App &app)
void ConfManagerRpc::updateAppsBlocked(
const QVector<qint64> &appIdList, bool blocked, bool killProcess)
{
IoC<RpcManager>()->doOnServer(Control::Rpc_ConfManager_updateAppsBlocked,
{ VariantUtil::vectorToList(appIdList), blocked, killProcess });
const QVariantList appIdVarList = VariantUtil::vectorToList(appIdList);
QVariantList args;
VariantUtil::addToList(args, appIdVarList);
args << blocked << killProcess;
IoC<RpcManager>()->doOnServer(Control::Rpc_ConfManager_updateAppsBlocked, args);
}
bool ConfManagerRpc::updateAppName(qint64 appId, const QString &appName)

View File

@ -23,3 +23,8 @@ QVector<qint64> VariantUtil::listToVector(const QVariantList &list)
return array;
}
void VariantUtil::addToList(QVariantList &list, const QVariant &v)
{
list.push_back(v); // append() merges the list, does not insert
}

View File

@ -11,6 +11,8 @@ public:
static QVariantList vectorToList(const QVector<qint64> &array);
static QVector<qint64> listToVector(const QVariantList &list);
static void addToList(QVariantList &list, const QVariant &v);
};
#endif // VARIANTUTIL_H