| OLD | NEW |
| 1 #include "PluginStdAfx.h" | 1 #include "PluginStdAfx.h" |
| 2 | 2 |
| 3 #include <Wbemidl.h> | 3 #include <Wbemidl.h> |
| 4 #include <time.h> | 4 #include <time.h> |
| 5 #include "PluginIniFileW.h" | 5 #include "PluginIniFileW.h" |
| 6 #include "PluginIniFile.h" | 6 #include "PluginIniFile.h" |
| 7 #include "PluginSettings.h" | 7 #include "PluginSettings.h" |
| 8 #include "PluginDictionary.h" | 8 #include "PluginDictionary.h" |
| 9 #include "PluginClient.h" | 9 #include "PluginClient.h" |
| 10 #include "PluginChecksum.h" | 10 #include "PluginChecksum.h" |
| 11 #include "PluginSystem.h" | 11 #include "PluginSystem.h" |
| 12 #ifdef SUPPORT_FILTER | 12 #ifdef SUPPORT_FILTER |
| 13 #include "PluginFilter.h" | 13 #include "PluginFilter.h" |
| 14 #endif | 14 #endif |
| 15 #include "PluginMutex.h" | 15 #include "PluginMutex.h" |
| 16 #include "PluginHttpRequest.h" | 16 #include "PluginHttpRequest.h" |
| 17 #include <memory> |
| 18 |
| 17 | 19 |
| 18 // IE functions | 20 // IE functions |
| 19 #pragma comment(lib, "iepmapi.lib") | 21 #pragma comment(lib, "iepmapi.lib") |
| 20 | 22 |
| 21 #include <knownfolders.h> | 23 #include <knownfolders.h> |
| 22 | 24 |
| 23 class TSettings | 25 class TSettings |
| 24 { | 26 { |
| 25 DWORD processorId; | 27 DWORD processorId; |
| 26 | 28 |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 IncrementTabVersion(SETTING_TAB_SETTINGS_VERSION); | 811 IncrementTabVersion(SETTING_TAB_SETTINGS_VERSION); |
| 810 } | 812 } |
| 811 else | 813 else |
| 812 { | 814 { |
| 813 isWritten = false; | 815 isWritten = false; |
| 814 } | 816 } |
| 815 | 817 |
| 816 return isWritten; | 818 return isWritten; |
| 817 } | 819 } |
| 818 | 820 |
| 819 #ifdef SUPPORT_WHITELIST | |
| 820 | |
| 821 void CPluginSettings::AddDomainToHistory(const CString& domain) | |
| 822 { | |
| 823 if (!CPluginClient::IsValidDomain(domain)) | |
| 824 { | |
| 825 return; | |
| 826 } | |
| 827 | |
| 828 // Delete domain | |
| 829 s_criticalSectionDomainHistory.Lock(); | |
| 830 { | |
| 831 for (TDomainHistory::iterator it = m_domainHistory.begin(); it != m_domainHi
story.end(); ++it) | |
| 832 { | |
| 833 if (it->first == domain) | |
| 834 { | |
| 835 m_domainHistory.erase(it); | |
| 836 break; | |
| 837 } | |
| 838 } | |
| 839 | |
| 840 // Get whitelist reason | |
| 841 int reason = 0; | |
| 842 | |
| 843 s_criticalSectionLocal.Lock(); | |
| 844 { | |
| 845 TDomainList::iterator it = m_whitelist.find(domain); | |
| 846 if (it != m_whitelist.end()) | |
| 847 { | |
| 848 reason = it->second; | |
| 849 } | |
| 850 else | |
| 851 { | |
| 852 reason = 3; | |
| 853 } | |
| 854 } | |
| 855 s_criticalSectionLocal.Unlock(); | |
| 856 | |
| 857 // Delete domain, if history is too long | |
| 858 if (m_domainHistory.size() >= DOMAIN_HISTORY_MAX_COUNT) | |
| 859 { | |
| 860 m_domainHistory.erase(m_domainHistory.begin()); | |
| 861 } | |
| 862 | |
| 863 m_domainHistory.push_back(std::make_pair(domain, reason)); | |
| 864 } | |
| 865 s_criticalSectionDomainHistory.Unlock(); | |
| 866 } | |
| 867 | |
| 868 | |
| 869 TDomainHistory CPluginSettings::GetDomainHistory() const | |
| 870 { | |
| 871 TDomainHistory domainHistory; | |
| 872 | |
| 873 s_criticalSectionDomainHistory.Lock(); | |
| 874 { | |
| 875 domainHistory = m_domainHistory; | |
| 876 } | |
| 877 s_criticalSectionDomainHistory.Unlock(); | |
| 878 | |
| 879 return domainHistory; | |
| 880 } | |
| 881 | |
| 882 #endif // SUPPORT_WHITELIST | |
| 883 | |
| 884 | 821 |
| 885 bool CPluginSettings::IsPluginUpdateAvailable() const | 822 bool CPluginSettings::IsPluginUpdateAvailable() const |
| 886 { | 823 { |
| 887 bool isAvailable = Has(SETTING_PLUGIN_UPDATE_VERSION); | 824 bool isAvailable = Has(SETTING_PLUGIN_UPDATE_VERSION); |
| 888 if (isAvailable) | 825 if (isAvailable) |
| 889 { | 826 { |
| 890 CString newVersion = GetString(SETTING_PLUGIN_UPDATE_VERSION); | 827 CString newVersion = GetString(SETTING_PLUGIN_UPDATE_VERSION); |
| 891 CString curVersion = IEPLUGIN_VERSION; | 828 CString curVersion = IEPLUGIN_VERSION; |
| 892 | 829 |
| 893 isAvailable = newVersion != curVersion; | 830 isAvailable = newVersion != curVersion; |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 // ============================================================================ | 1498 // ============================================================================ |
| 1562 // Whitelist settings | 1499 // Whitelist settings |
| 1563 // ============================================================================ | 1500 // ============================================================================ |
| 1564 | 1501 |
| 1565 #ifdef SUPPORT_WHITELIST | 1502 #ifdef SUPPORT_WHITELIST |
| 1566 | 1503 |
| 1567 void CPluginSettings::ClearWhitelist() | 1504 void CPluginSettings::ClearWhitelist() |
| 1568 { | 1505 { |
| 1569 s_criticalSectionLocal.Lock(); | 1506 s_criticalSectionLocal.Lock(); |
| 1570 { | 1507 { |
| 1571 m_whitelist.clear(); | 1508 m_whitelistedDomains.clear(); |
| 1572 m_whitelistToGo.clear(); | |
| 1573 } | 1509 } |
| 1574 s_criticalSectionLocal.Unlock(); | 1510 s_criticalSectionLocal.Unlock(); |
| 1575 } | 1511 } |
| 1576 | 1512 |
| 1577 | 1513 |
| 1578 bool CPluginSettings::ReadWhitelist(bool isDebug) | 1514 bool CPluginSettings::ReadWhitelist(bool isDebug) |
| 1579 { | 1515 { |
| 1580 bool isRead = true; | 1516 bool isRead = true; |
| 1581 | 1517 |
| 1582 DEBUG_SETTINGS("SettingsWhitelist::Read") | 1518 DEBUG_SETTINGS("SettingsWhitelist::Read") |
| 1583 | 1519 |
| 1584 if (isDebug) | 1520 if (isDebug) |
| 1585 { | 1521 { |
| 1586 DEBUG_GENERAL("*** Loading whitelist settings:" + m_settingsFileWhitelist-
>GetFilePath()); | 1522 DEBUG_GENERAL("*** Loading whitelist settings"); |
| 1587 } | 1523 } |
| 1588 | 1524 |
| 1589 CPluginSettingsWhitelistLock lock; | 1525 CPluginSettingsWhitelistLock lock; |
| 1590 if (lock.IsLocked()) | 1526 if (lock.IsLocked()) |
| 1591 { | 1527 { |
| 1592 isRead = m_settingsFileWhitelist->Read(); | 1528 ClearWhitelist(); |
| 1593 if (isRead) | 1529 |
| 1530 s_criticalSectionLocal.Lock(); |
| 1531 std::vector<AdblockPlus::FilterPtr> filters = CPluginClient::GetInstance()
->GetFilterEngine()->GetListedFilters(); |
| 1532 for (int i = 0; i < filters.size(); i ++) |
| 1594 { | 1533 { |
| 1595 if (m_settingsFileWhitelist->IsValidChecksum()) | 1534 if (filters[i]->GetProperty("type", AdblockPlus::Filter::Type::TYPE_INVA
LID) == AdblockPlus::Filter::Type::TYPE_EXCEPTION) |
| 1596 { | 1535 { |
| 1597 ClearWhitelist(); | 1536 std::string text = filters[i]->GetProperty("text", ""); |
| 1598 | 1537 //@@||example.com^$document |
| 1599 s_criticalSectionLocal.Lock(); | 1538 size_t endPos = text.rfind("^$document"); |
| 1539 if (endPos != std::string::npos) |
| 1600 { | 1540 { |
| 1601 // Unpack white list | 1541 size_t startPos = text.find("@@||") + 4; |
| 1602 CPluginIniFileW::TSectionData whitelist = m_settingsFileWhitelist->G
etSectionData("Whitelist"); | 1542 if (startPos != std::string::npos) |
| 1603 int domainCount = 0; | |
| 1604 bool bContinue = true; | |
| 1605 | |
| 1606 do | |
| 1607 { | 1543 { |
| 1608 CString domainCountStr; | 1544 m_whitelistedDomains.push_back(text.substr(startPos, endPos - star
tPos)); |
| 1609 domainCountStr.Format(L"%d", ++domainCount); | 1545 } |
| 1610 | |
| 1611 CPluginIniFileW::TSectionData::iterator domainIt = whitelist.find(
L"domain" + domainCountStr); | |
| 1612 CPluginIniFileW::TSectionData::iterator reasonIt = whitelist.find(
L"domain" + domainCountStr + L"r"); | |
| 1613 | |
| 1614 if (bContinue = (domainIt != whitelist.end() && reasonIt != whitel
ist.end())) | |
| 1615 { | |
| 1616 m_whitelist[domainIt->second] = _wtoi(reasonIt->second); | |
| 1617 } | |
| 1618 | |
| 1619 } while (bContinue); | |
| 1620 | |
| 1621 // Unpack white list | |
| 1622 whitelist = m_settingsFileWhitelist->GetSectionData("Whitelist togo"
); | |
| 1623 domainCount = 0; | |
| 1624 bContinue = true; | |
| 1625 | |
| 1626 do | |
| 1627 { | |
| 1628 CString domainCountStr; | |
| 1629 domainCountStr.Format(L"%d", ++domainCount); | |
| 1630 | |
| 1631 CPluginIniFileW::TSectionData::iterator domainIt = whitelist.find(
L"domain" + domainCountStr); | |
| 1632 CPluginIniFileW::TSectionData::iterator reasonIt = whitelist.find(
L"domain" + domainCountStr + L"r"); | |
| 1633 | |
| 1634 if (bContinue = (domainIt != whitelist.end() && reasonIt != whitel
ist.end())) | |
| 1635 { | |
| 1636 m_whitelistToGo[domainIt->second] = _wtoi(reasonIt->second); | |
| 1637 } | |
| 1638 | |
| 1639 } while (bContinue); | |
| 1640 } | 1546 } |
| 1641 s_criticalSectionLocal.Unlock(); | |
| 1642 } | |
| 1643 else | |
| 1644 { | |
| 1645 DEBUG_SETTINGS("SettingsWhitelist:Invalid checksum - Deleting file") | |
| 1646 | |
| 1647 DEBUG_ERROR_LOG(m_settingsFileWhitelist->GetLastError(), PLUGIN_ERRO
R_SETTINGS_WHITELIST, PLUGIN_ERROR_SETTINGS_FILE_READ_CHECKSUM, "SettingsWhiteli
st::Read - Checksum") | |
| 1648 isRead = false; | |
| 1649 m_isDirtyWhitelist = true; | |
| 1650 } | 1547 } |
| 1651 } | 1548 } |
| 1652 else if (m_settingsFileWhitelist->GetLastError() == ERROR_FILE_NOT_FOUND) | 1549 s_criticalSectionLocal.Unlock(); |
| 1653 { | |
| 1654 m_isDirtyWhitelist = true; | |
| 1655 } | |
| 1656 else | |
| 1657 { | |
| 1658 DEBUG_ERROR_LOG(m_settingsFileWhitelist->GetLastError(), PLUGIN_ERROR_SE
TTINGS_WHITELIST, PLUGIN_ERROR_SETTINGS_FILE_READ, "SettingsWhitelist::Read") | |
| 1659 } | |
| 1660 } | 1550 } |
| 1661 else | 1551 else |
| 1662 { | 1552 { |
| 1663 isRead = false; | 1553 isRead = false; |
| 1664 } | 1554 } |
| 1665 | 1555 |
| 1666 // Write file in case it is dirty | |
| 1667 WriteWhitelist(isDebug); | |
| 1668 | |
| 1669 return isRead; | 1556 return isRead; |
| 1670 } | 1557 } |
| 1671 | 1558 |
| 1672 | 1559 |
| 1673 bool CPluginSettings::WriteWhitelist(bool isDebug) | 1560 void CPluginSettings::AddWhiteListedDomain(const CString& domain) |
| 1674 { | |
| 1675 bool isWritten = true; | |
| 1676 | |
| 1677 if (!m_isDirtyWhitelist) | |
| 1678 { | |
| 1679 return isWritten; | |
| 1680 } | |
| 1681 | |
| 1682 if (isDebug) | |
| 1683 { | |
| 1684 DEBUG_GENERAL("*** Writing changed whitelist settings") | |
| 1685 } | |
| 1686 | |
| 1687 CPluginSettingsWhitelistLock lock; | |
| 1688 if (lock.IsLocked()) | |
| 1689 { | |
| 1690 m_settingsFileWhitelist->Clear(); | |
| 1691 | |
| 1692 s_criticalSectionLocal.Lock(); | |
| 1693 { | |
| 1694 // White list | |
| 1695 int whitelistCount = 0; | |
| 1696 CPluginIniFileW::TSectionData whitelist; | |
| 1697 | |
| 1698 for (TDomainList::iterator it = m_whitelist.begin(); it != m_whitelist.end
(); ++it) | |
| 1699 { | |
| 1700 CString whitelistCountStr; | |
| 1701 whitelistCountStr.Format(L"%d", ++whitelistCount); | |
| 1702 | |
| 1703 CString reason; | |
| 1704 reason.Format(L"%d", it->second); | |
| 1705 | |
| 1706 whitelist[L"domain" + whitelistCountStr] = it->first; | |
| 1707 whitelist[L"domain" + whitelistCountStr + L"r"] = reason; | |
| 1708 } | |
| 1709 | |
| 1710 m_settingsFileWhitelist->UpdateSection("Whitelist", whitelist); | |
| 1711 | |
| 1712 // White list (not yet committed) | |
| 1713 whitelistCount = 0; | |
| 1714 whitelist.clear(); | |
| 1715 | |
| 1716 for (TDomainList::iterator it = m_whitelistToGo.begin(); it != m_whitelist
ToGo.end(); ++it) | |
| 1717 { | |
| 1718 CString whitelistCountStr; | |
| 1719 whitelistCountStr.Format(L"%d", ++whitelistCount); | |
| 1720 | |
| 1721 CString reason; | |
| 1722 reason.Format(L"%d", it->second); | |
| 1723 | |
| 1724 whitelist[L"domain" + whitelistCountStr] = it->first; | |
| 1725 whitelist[L"domain" + whitelistCountStr + L"r"] = reason; | |
| 1726 } | |
| 1727 | |
| 1728 m_settingsFileWhitelist->UpdateSection("Whitelist togo", whitelist); | |
| 1729 } | |
| 1730 s_criticalSectionLocal.Unlock(); | |
| 1731 | |
| 1732 // Write file | |
| 1733 isWritten = m_settingsFileWhitelist->Write(); | |
| 1734 if (!isWritten) | |
| 1735 { | |
| 1736 DEBUG_ERROR_LOG(m_settingsFileWhitelist->GetLastError(), PLUGIN_ERROR_SETT
INGS_WHITELIST, PLUGIN_ERROR_SETTINGS_FILE_WRITE, "SettingsWhitelist::Write") | |
| 1737 } | |
| 1738 | |
| 1739 m_isDirty = false; | |
| 1740 } | |
| 1741 else | |
| 1742 { | |
| 1743 isWritten = false; | |
| 1744 } | |
| 1745 | |
| 1746 if (isWritten) | |
| 1747 { | |
| 1748 DEBUG_WHITELIST("Whitelist::Icrement version") | |
| 1749 | |
| 1750 IncrementTabVersion(SETTING_TAB_WHITELIST_VERSION); | |
| 1751 } | |
| 1752 | |
| 1753 return isWritten; | |
| 1754 } | |
| 1755 | |
| 1756 | |
| 1757 void CPluginSettings::AddWhiteListedDomain(const CString& domain, int reason, bo
ol isToGo) | |
| 1758 { | 1561 { |
| 1759 DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain) | 1562 DEBUG_SETTINGS("SettingsWhitelist::AddWhiteListedDomain domain:" + domain) |
| 1760 | 1563 |
| 1761 bool isNewVersion = false; | 1564 bool isNewVersion = false; |
| 1762 bool isForcingUpdateOnStart = false; | 1565 bool isForcingUpdateOnStart = false; |
| 1763 | 1566 |
| 1764 CPluginSettingsWhitelistLock lock; | 1567 CPluginSettingsWhitelistLock lock; |
| 1765 if (lock.IsLocked()) | 1568 if (lock.IsLocked()) |
| 1766 { | 1569 { |
| 1767 ReadWhitelist(false); | 1570 ReadWhitelist(false); |
| 1768 | 1571 |
| 1572 std::string newDomain = CW2A(domain, CP_UTF8); |
| 1573 |
| 1574 //Domain already present? |
| 1575 if (std::find(m_whitelistedDomains.begin(), m_whitelistedDomains.end(), newD
omain) != m_whitelistedDomains.end()) |
| 1576 { |
| 1577 return; |
| 1578 } |
| 1769 s_criticalSectionLocal.Lock(); | 1579 s_criticalSectionLocal.Lock(); |
| 1770 { | 1580 { |
| 1771 bool isToGoMatcingReason = false; | 1581 AdblockPlus::FilterPtr whitelistFilter = CPluginClient::GetInstance()->Get
FilterEngine()->GetFilter(std::string("@@||").append(CW2A(domain)).append("^$doc
ument")); |
| 1772 bool isToGoMatcingDomain = false; | 1582 whitelistFilter->AddToList(); |
| 1773 | |
| 1774 TDomainList::iterator itToGo = m_whitelistToGo.find(domain); | |
| 1775 TDomainList::iterator it = m_whitelist.find(domain); | |
| 1776 if (isToGo) | |
| 1777 { | |
| 1778 if (itToGo != m_whitelistToGo.end()) | |
| 1779 { | |
| 1780 isToGoMatcingDomain = true; | |
| 1781 isToGoMatcingReason = itToGo->second == reason; | |
| 1782 | |
| 1783 if (reason == 3) | |
| 1784 { | |
| 1785 m_whitelistToGo.erase(itToGo); | |
| 1786 m_isDirtyWhitelist = true; | |
| 1787 } | |
| 1788 else if (!isToGoMatcingReason) | |
| 1789 { | |
| 1790 itToGo->second = reason; | |
| 1791 m_isDirtyWhitelist = true; | |
| 1792 } | |
| 1793 } | |
| 1794 else | |
| 1795 { | |
| 1796 m_whitelistToGo[domain] = reason; | |
| 1797 m_isDirtyWhitelist = true; | |
| 1798 | |
| 1799 // Delete new togo item from saved white list | |
| 1800 if (it != m_whitelist.end()) | |
| 1801 { | |
| 1802 m_whitelist.erase(it); | |
| 1803 } | |
| 1804 } | |
| 1805 } | |
| 1806 else | |
| 1807 { | |
| 1808 if (isToGoMatcingDomain) | |
| 1809 { | |
| 1810 m_whitelistToGo.erase(itToGo); | |
| 1811 m_isDirtyWhitelist = true; | |
| 1812 } | |
| 1813 | |
| 1814 if (it != m_whitelist.end()) | |
| 1815 { | |
| 1816 if (it->second != reason) | |
| 1817 { | |
| 1818 it->second = reason; | |
| 1819 m_isDirtyWhitelist = true; | |
| 1820 } | |
| 1821 } | |
| 1822 else | |
| 1823 { | |
| 1824 m_whitelist[domain] = reason; | |
| 1825 m_isDirtyWhitelist = true; | |
| 1826 } | |
| 1827 } | |
| 1828 | |
| 1829 isForcingUpdateOnStart = m_whitelistToGo.size() > 0; | |
| 1830 } | 1583 } |
| 1831 s_criticalSectionLocal.Unlock(); | 1584 s_criticalSectionLocal.Unlock(); |
| 1832 | 1585 |
| 1833 WriteWhitelist(false); | |
| 1834 } | 1586 } |
| 1835 | 1587 |
| 1836 if (isForcingUpdateOnStart) | 1588 if (isForcingUpdateOnStart) |
| 1837 { | 1589 { |
| 1838 ForceConfigurationUpdateOnStart(); | 1590 ForceConfigurationUpdateOnStart(); |
| 1839 } | 1591 } |
| 1840 } | 1592 } |
| 1841 | 1593 |
| 1842 | 1594 |
| 1843 bool CPluginSettings::IsWhiteListedDomain(const CString& domain) const | 1595 bool CPluginSettings::IsWhiteListedDomain(const CString& domain) const |
| 1844 { | 1596 { |
| 1845 bool bIsWhiteListed; | 1597 bool bIsWhiteListed; |
| 1846 | 1598 |
| 1847 s_criticalSectionLocal.Lock(); | 1599 s_criticalSectionLocal.Lock(); |
| 1848 { | 1600 { |
| 1849 bIsWhiteListed = m_whitelist.find(domain) != m_whitelist.end(); | 1601 bIsWhiteListed = std::find(m_whitelistedDomains.begin(), m_whitelistedDomain
s.end(), std::string(CW2A(domain, CP_UTF8))) != m_whitelistedDomains.end(); |
| 1850 if (!bIsWhiteListed) | |
| 1851 { | |
| 1852 TDomainList::const_iterator it = m_whitelistToGo.find(domain); | |
| 1853 bIsWhiteListed = it != m_whitelistToGo.end() && it->second != 3; | |
| 1854 } | |
| 1855 } | 1602 } |
| 1856 s_criticalSectionLocal.Unlock(); | 1603 s_criticalSectionLocal.Unlock(); |
| 1857 | 1604 |
| 1858 return bIsWhiteListed; | 1605 return bIsWhiteListed; |
| 1859 } | 1606 } |
| 1860 | 1607 |
| 1861 int CPluginSettings::GetWhiteListedDomainCount() const | 1608 int CPluginSettings::GetWhiteListedDomainCount() const |
| 1862 { | 1609 { |
| 1863 int count = 0; | 1610 int count = 0; |
| 1864 | 1611 |
| 1865 s_criticalSectionLocal.Lock(); | 1612 s_criticalSectionLocal.Lock(); |
| 1866 { | 1613 { |
| 1867 count = (int)m_whitelist.size(); | 1614 count = (int)m_whitelistedDomains.size(); |
| 1868 } | 1615 } |
| 1869 s_criticalSectionLocal.Unlock(); | 1616 s_criticalSectionLocal.Unlock(); |
| 1870 | 1617 |
| 1871 return count; | 1618 return count; |
| 1872 } | 1619 } |
| 1873 | 1620 |
| 1874 | 1621 |
| 1875 TDomainList CPluginSettings::GetWhiteListedDomainList(bool isToGo) const | 1622 std::vector<std::string> CPluginSettings::GetWhiteListedDomainList(bool isToGo) |
| 1876 { | 1623 { |
| 1877 TDomainList domainList; | 1624 bool r = ReadWhitelist(false); |
| 1878 | 1625 return m_whitelistedDomains; |
| 1879 s_criticalSectionLocal.Lock(); | |
| 1880 { | |
| 1881 if (isToGo) | |
| 1882 { | |
| 1883 domainList = m_whitelistToGo; | |
| 1884 } | |
| 1885 else | |
| 1886 { | |
| 1887 domainList = m_whitelist; | |
| 1888 } | |
| 1889 } | |
| 1890 s_criticalSectionLocal.Unlock(); | |
| 1891 | |
| 1892 return domainList; | |
| 1893 } | 1626 } |
| 1894 | 1627 |
| 1895 | 1628 |
| 1896 void CPluginSettings::ReplaceWhiteListedDomains(const TDomainList& domains) | |
| 1897 { | |
| 1898 CPluginSettingsWhitelistLock lock; | |
| 1899 if (lock.IsLocked()) | |
| 1900 { | |
| 1901 ReadWhitelist(false); | |
| 1902 | |
| 1903 s_criticalSectionLocal.Lock(); | |
| 1904 { | |
| 1905 if (m_whitelist != domains) | |
| 1906 { | |
| 1907 m_whitelist = domains; | |
| 1908 m_isDirtyWhitelist = true; | |
| 1909 } | |
| 1910 | |
| 1911 // Delete entries in togo list | |
| 1912 bool isDeleted = true; | |
| 1913 | |
| 1914 while (isDeleted) | |
| 1915 { | |
| 1916 isDeleted = false; | |
| 1917 | |
| 1918 for (TDomainList::iterator it = m_whitelistToGo.begin(); it != m_whiteli
stToGo.end(); ++it) | |
| 1919 { | |
| 1920 if (m_whitelist.find(it->first) != m_whitelist.end() || it->second ==
3) | |
| 1921 { | |
| 1922 m_whitelistToGo.erase(it); | |
| 1923 | |
| 1924 // Force another round... | |
| 1925 isDeleted = true; | |
| 1926 break; | |
| 1927 } | |
| 1928 } | |
| 1929 } | |
| 1930 } | |
| 1931 s_criticalSectionLocal.Unlock(); | |
| 1932 | |
| 1933 WriteWhitelist(false); | |
| 1934 } | |
| 1935 } | |
| 1936 | |
| 1937 | |
| 1938 void CPluginSettings::RemoveWhiteListedDomainsToGo(const TDomainList& domains) | |
| 1939 { | |
| 1940 CPluginSettingsWhitelistLock lock; | |
| 1941 if (lock.IsLocked()) | |
| 1942 { | |
| 1943 ReadWhitelist(false); | |
| 1944 | |
| 1945 s_criticalSectionLocal.Lock(); | |
| 1946 { | |
| 1947 for (TDomainList::const_iterator it = domains.begin(); it != domains.end()
; ++it) | |
| 1948 { | |
| 1949 for (TDomainList::iterator itToGo = m_whitelistToGo.begin(); itToGo != m
_whitelistToGo.end(); ++ itToGo) | |
| 1950 { | |
| 1951 if (it->first == itToGo->first) | |
| 1952 { | |
| 1953 m_whitelistToGo.erase(itToGo); | |
| 1954 m_isDirtyWhitelist = true; | |
| 1955 break; | |
| 1956 } | |
| 1957 } | |
| 1958 } | |
| 1959 } | |
| 1960 s_criticalSectionLocal.Unlock(); | |
| 1961 | |
| 1962 WriteWhitelist(false); | |
| 1963 } | |
| 1964 } | |
| 1965 | |
| 1966 | |
| 1967 bool CPluginSettings::RefreshWhitelist() | 1629 bool CPluginSettings::RefreshWhitelist() |
| 1968 { | 1630 { |
| 1969 CPluginSettingsWhitelistLock lock; | 1631 CPluginSettingsWhitelistLock lock; |
| 1970 if (lock.IsLocked()) | 1632 if (lock.IsLocked()) |
| 1971 { | 1633 { |
| 1972 ReadWhitelist(true); | 1634 ReadWhitelist(true); |
| 1973 } | 1635 } |
| 1974 | 1636 |
| 1975 return true; | 1637 return true; |
| 1976 } | 1638 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1997 | 1659 |
| 1998 void CPluginSettings::SetSubscription(BSTR url) | 1660 void CPluginSettings::SetSubscription(BSTR url) |
| 1999 { | 1661 { |
| 2000 std::string urlConverted = CT2A(url); | 1662 std::string urlConverted = CT2A(url); |
| 2001 SetSubscription(urlConverted); | 1663 SetSubscription(urlConverted); |
| 2002 } | 1664 } |
| 2003 | 1665 |
| 2004 void CPluginSettings::SetSubscription(std::string url) | 1666 void CPluginSettings::SetSubscription(std::string url) |
| 2005 { | 1667 { |
| 2006 FilterEngine* filterEngine= CPluginClient::GetInstance()->GetFilterEngine(); | 1668 FilterEngine* filterEngine= CPluginClient::GetInstance()->GetFilterEngine(); |
| 2007 AdblockPlus::Subscription subscription = filterEngine->GetSubscription(url); | 1669 AdblockPlus::SubscriptionPtr subscription = filterEngine->GetSubscription(url)
; |
| 2008 subscription.AddToList(); | 1670 subscription->AddToList(); |
| 2009 } | 1671 } |
| 2010 | 1672 |
| 2011 CString CPluginSettings::GetSubscription() | 1673 CString CPluginSettings::GetSubscription() |
| 2012 { | 1674 { |
| 2013 FilterEngine* filterEngine= CPluginClient::GetInstance()->GetFilterEngine(); | 1675 FilterEngine* filterEngine= CPluginClient::GetInstance()->GetFilterEngine(); |
| 2014 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = filterEngine->GetLis
tedSubscriptions(); | 1676 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = filterEngine->GetLis
tedSubscriptions(); |
| 2015 for (int i = 0; i < subscriptions.size(); i ++) | 1677 for (int i = 0; i < subscriptions.size(); i ++) |
| 2016 { | 1678 { |
| 2017 if (subscriptions[i]->IsListed()) | 1679 if (subscriptions[i]->IsListed()) |
| 2018 { | 1680 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2030 for (int i = 0; i < subscriptions.size(); i ++) | 1692 for (int i = 0; i < subscriptions.size(); i ++) |
| 2031 { | 1693 { |
| 2032 if (subscriptions[i]->IsListed()) | 1694 if (subscriptions[i]->IsListed()) |
| 2033 { | 1695 { |
| 2034 subscriptions[i]->UpdateFilters(); | 1696 subscriptions[i]->UpdateFilters(); |
| 2035 } | 1697 } |
| 2036 } | 1698 } |
| 2037 } | 1699 } |
| 2038 | 1700 |
| 2039 #endif // SUPPORT_WHITELIST | 1701 #endif // SUPPORT_WHITELIST |
| OLD | NEW |