Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Internet Explorer AdBlock

, 17 Jan 2008 GPL3
Internet Explorer AdBlock Add-on
ieadblock_src.zip
IE AdBlockPS
IE AdBlockps.def
IE AdBlock
AdBlockBand.rgs
AdBlockBHO.rgs
bin
XListCtrlSSDU.lib
XListCtrlSSRU.lib
IE AdBlock.def
IE AdBlock.rgs
res
bmpToolbar.bmp
checkboxes.bmp
icoSettings.ico
XListCtrl
checkboxes.bmp
// Redefinition protection
#ifndef ADLIST_H
#define ADLIST_H

//*********************************************************************
// INCLUDES
//*********************************************************************

#include "MarkUp.h"
#include <vector>
using namespace std;

//*********************************************************************
// Constants
//*********************************************************************

const CString LISTTYPE_PATTERN				= _T("pattern");
const CString LISTTYPE_REGULAREXPRESSION	= _T("regexp");
const CString LISTTYPE_CACHE				= _T("cache");

const int CACHE_SIZE = 500;

struct CacheObject
{
	// Variables
	CString sURL;
	CString sElementType;
	bool	bListed;
	int		iRequestCount;

	// Constructor
	CacheObject()
	{
		// Set default values
		iRequestCount = 0;
	}
};

//*********************************************************************
// CAdList
//*********************************************************************

class CAdList  
{
public:
	// Constructor & destructor
	CAdList();
	~CAdList();

	// Functions
	static	CAdList * Instance();
	bool	Load(CMarkup & xml, bool bResetCurrentList = true);
	bool	Store(CMarkup & xml);
	bool	Matches(CString sURL, CString sElementType);
	void	ClearCache();
	void	SortCache();
	int		GetCachedItemsCount();
	void	DeleteAllItems();
	void	DeleteAllPatterns();
	void	DeleteAllRegularExpressions();
	void	AddPattern(CString sPattern);
	void	ModifyPattern(int index, CString sPattern);
	void	RemovePattern(int index);
	void	AddRegularExpression(CString sRegularExpression);
	void	ModifyRegularExpression(int index, CString sRegularExpression);
	void	RemoveRegularExpression(int index);
	int		GetPatternCount();
	CString	GetPattern(int index);
	int		GetRegularExpressionCount();
	CString	GetRegularExpression(int index);
	void	SortListAlphabetically();
	bool	GetKeepSorted();
	void	SetKeepSorted(bool bEnable);

private:
	// Functions
	bool	StoreList(CMarkup & xml, CStringArray * pStringArray, CString sType);
	bool	MatchesList(CStringArray * pStringArray, CMapStringToString * pMap,
				CString sURL, CString sElementType);
	void	AddItemToCache(CString sURL, CString sElementType, bool bListed, int iRequestCount);
	void	IncreaseCacheUsage(int iExistingCacheLocation);
	void	AddItem(CStringArray * pStringArray, CMapStringToString * pMap, CString sContent);
	void	ModifyItem(CStringArray * pStringArray, CMapStringToString * pMap, int index, CString sContent);
	void	RemoveItem(CStringArray * pStringArray, CMapStringToString * pMap, int index);
	CString GetItem(CStringArray * pStringArray, int index);
	void	SortListAlphabeticallyInternal(CStringArray * pStringArray,
				CMapStringToString * pMap);
	bool	CompareElements(CString sElement, CString sElementWithMask);
	CString CleanPattern(CString sPattern);

	// Variables
	CMapStringToString	m_mapPatterns;
	CMapStringToString	m_mapRegularExpressions;
	CMapStringToString	m_mapCache;
	CStringArray		m_arrPatterns;
	CStringArray		m_arrRegularExpressions;
	vector<CacheObject>	m_arrCache;
	bool				m_bKeepSorted;
};

// End of redefinition protection
#endif // SETTINGS_H

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Share

About the Author

Geert van Horrik
Software Developer CatenaLogic
Netherlands Netherlands
I am Geert van Horrik, and I have studied Computer Science in the Netherlands.
 
I love to write software using .NET (especially the combination of WPF and C#). I am also the lead developer of Catel, an open-source application development framework for WPF, Silverlight, WP7 and WinRT with the focus on MVVM.
 
I have my own company since January 1st 2007, called CatenaLogic. This company develops commercial and non-commercial software.
 
To download (or buy) applications I have written, visit my website: http://www.catenalogic.com
Follow on   Twitter

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141216.1 | Last Updated 17 Jan 2008
Article Copyright 2008 by Geert van Horrik
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid