This commit is contained in:
DavidXanatos 2023-04-08 16:50:04 +02:00
parent c19dff8f6f
commit e4ece1a16c
3 changed files with 28 additions and 16 deletions

View File

@ -60,10 +60,33 @@ void COptionsWindow::LoadINetAccess()
void COptionsWindow::SaveINetAccess()
{
int Mode = ui.cmbBlockINet->currentData().toInt();
if (Mode == 1) m_pBox->InsertText("AllowNetworkAccess", "!<InternetAccess>,n");
else m_pBox->DelValue("AllowNetworkAccess", "!<InternetAccess>,n");
if (Mode != 0) m_pBox->DelValue("AllowNetworkAccess", "y");
else if (m_WFPisBlocking) m_pBox->InsertText("AllowNetworkAccess", "y");
if (Mode == 1) {
if (!FindEntryInSettingList("AllowNetworkAccess", "!<InternetAccess>,n"))
m_pBox->InsertText("AllowNetworkAccess", "!<InternetAccess>,n");
}
else
m_pBox->DelValue("AllowNetworkAccess", "!<InternetAccess>,n");
if (Mode == 0) {
if (m_WFPisBlocking && !FindEntryInSettingList("AllowNetworkAccess", "y"))
m_pBox->InsertText("AllowNetworkAccess", "y");
}
else
m_pBox->DelValue("AllowNetworkAccess", "y");
QTreeWidgetItem* pBlockedNet = FindGroupByName("<BlockNetAccess>");
if (pBlockedNet && pBlockedNet->childCount() > 0) {
if (m_IsEnabledWFP && !FindEntryInSettingList("AllowNetworkAccess", "<BlockNetAccess>,n"))
m_pBox->InsertText("AllowNetworkAccess", "<BlockNetAccess>,n");
}
else
m_pBox->DelValue("AllowNetworkAccess", "<BlockNetAccess>,n");
QTreeWidgetItem* pBlockedDev = FindGroupByName("<BlockNetDevices>");
if (pBlockedDev && pBlockedDev->childCount() > 0)
SetAccessEntry(eFile, "<BlockNetDevices>", eClosed, "InternetAccessDevices");
else
DelAccessEntry(eFile, "<BlockNetDevices>", eClosed, "InternetAccessDevices");
WriteAdvancedCheck(ui.chkINetBlockPrompt, "PromptForInternetAccess", "y", "");
WriteAdvancedCheck(ui.chkINetBlockMsg, "NotifyInternetAccessDenied", "", "n");
@ -98,7 +121,7 @@ QString COptionsWindow::INetModeToGroup(int Mode)
void COptionsWindow::LoadBlockINet()
{
if (GetAccessEntry(eFile, "!<InternetAccess>", eClosed, "InternetAccessDevices") != NULL)
if (IsAccessEntrySet(eFile, "!<InternetAccess>", eClosed, "InternetAccessDevices"))
ui.cmbBlockINet->setCurrentIndex(ui.cmbBlockINet->findData(2));
else if (m_IsEnabledWFP && (FindEntryInSettingList("AllowNetworkAccess", "!<InternetAccess>,n")
|| (m_WFPisBlocking && !FindEntryInSettingList("AllowNetworkAccess", "y"))))
@ -336,14 +359,6 @@ bool COptionsWindow::FindEntryInSettingList(const QString& Name, const QString&
return false;
}
void COptionsWindow::CheckINetBlock()
{
SetAccessEntry(eFile, "<BlockNetDevices>", eClosed, "InternetAccessDevices");
if (m_IsEnabledWFP && !FindEntryInSettingList("AllowNetworkAccess", "<BlockNetAccess>,n"))
m_pBox->InsertText("AllowNetworkAccess", "<BlockNetAccess>,n");
}
void COptionsWindow::LoadNetFwRules()
{
ui.treeNetFw->clear();

View File

@ -1057,8 +1057,6 @@ void COptionsWindow::UpdateCurrentTab()
}
else if (m_pCurrentTab == ui.tabInternet || m_pCurrentTab == ui.tabINet)
{
CheckINetBlock();
LoadBlockINet();
}
else if (m_pCurrentTab == ui.tabCOM) {

View File

@ -387,7 +387,6 @@ protected:
QString GetINetModeStr(int Mode);
void CloseINetEdit(bool bSave = true);
void CloseINetEdit(QTreeWidgetItem* pItem, bool bSave = true);
void CheckINetBlock();
bool FindEntryInSettingList(const QString& Name, const QString& Value);
void LoadINetAccess();
void SaveINetAccess();