mirror of https://github.com/roytam1/kmeleon.git
9 changed files with 1817 additions and 0 deletions
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -0,0 +1,106 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup Label="ProjectConfigurations"> |
||||
<ProjectConfiguration Include="Debug|Win32"> |
||||
<Configuration>Debug</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
<ProjectConfiguration Include="Release|Win32"> |
||||
<Configuration>Release</Configuration> |
||||
<Platform>Win32</Platform> |
||||
</ProjectConfiguration> |
||||
</ItemGroup> |
||||
<PropertyGroup Label="Globals"> |
||||
<ProjectGuid>{977A0098-4BEA-4D21-9352-C751486556EE}</ProjectGuid> |
||||
<RootNamespace>adblock</RootNamespace> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> |
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> |
||||
<ConfigurationType>DynamicLibrary</ConfigurationType> |
||||
<UseDebugLibraries>true</UseDebugLibraries> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
<PlatformToolset>v120_xp</PlatformToolset> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> |
||||
<ConfigurationType>DynamicLibrary</ConfigurationType> |
||||
<UseDebugLibraries>false</UseDebugLibraries> |
||||
<WholeProgramOptimization>true</WholeProgramOptimization> |
||||
<CharacterSet>Unicode</CharacterSet> |
||||
<PlatformToolset>v120_xp</PlatformToolset> |
||||
</PropertyGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> |
||||
<ImportGroup Label="ExtensionSettings"> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
</ImportGroup> |
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> |
||||
</ImportGroup> |
||||
<PropertyGroup Label="UserMacros" /> |
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||
<OutDir>$(SolutionDir)..\$(Configuration)\kplugins\</OutDir> |
||||
<IntDir>$(SolutionDir)..\_$(Configuration)\kmeleon\kplugins\$(ProjectName)\</IntDir> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||
<OutDir>$(SolutionDir)..\$(Configuration)\kplugins\</OutDir> |
||||
<IntDir>$(SolutionDir)..\_$(Configuration)\kmeleon\kplugins\$(ProjectName)\</IntDir> |
||||
</PropertyGroup> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> |
||||
<ClCompile> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>Disabled</Optimization> |
||||
<AdditionalIncludeDirectories>..\..\..\xulrunner-sdk\include\nspr;..\..\..\xulrunner-sdk\include;..\..\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
||||
<PreprocessorDefinitions>MOZ_FOLD_LIBS ;XP_WIN;XP_WIN32;WIN32;_DEBUG;_WINDOWS;_USRDLL;JSBRIDGE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<MinimalRebuild>true</MinimalRebuild> |
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> |
||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> |
||||
</ClCompile> |
||||
<Link> |
||||
<GenerateDebugInformation>true</GenerateDebugInformation> |
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> |
||||
<AdditionalLibraryDirectories>..\..\..\xulrunner-sdk\lib_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
||||
<AdditionalDependencies>ws2_32.lib;nss3.lib;xul.lib;mozalloc.lib;mozjs.lib;xpcomglue_s.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> |
||||
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> |
||||
<ClCompile> |
||||
<WarningLevel>Level3</WarningLevel> |
||||
<Optimization>MaxSpeed</Optimization> |
||||
<FunctionLevelLinking>true</FunctionLevelLinking> |
||||
<IntrinsicFunctions>true</IntrinsicFunctions> |
||||
<AdditionalIncludeDirectories>..\..\..\xulrunner-sdk\include\nspr;..\..\..\xulrunner-sdk\include;..\..\shared;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> |
||||
<PreprocessorDefinitions>XP_WIN;XP_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions)</PreprocessorDefinitions> |
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> |
||||
<OmitFramePointers /> |
||||
<EnableFiberSafeOptimizations /> |
||||
<StringPooling>true</StringPooling> |
||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet> |
||||
</ClCompile> |
||||
<Link> |
||||
<GenerateDebugInformation>true</GenerateDebugInformation> |
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding> |
||||
<OptimizeReferences>true</OptimizeReferences> |
||||
<AdditionalDependencies>ws2_32.lib;nss3.lib;xul.lib;mozalloc.lib;mozjs.lib;xpcomglue_s.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> |
||||
<AdditionalLibraryDirectories>..\..\..\xulrunner-sdk\lib_$(Configuration);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> |
||||
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> |
||||
<Profile>true</Profile> |
||||
</Link> |
||||
</ItemDefinitionGroup> |
||||
<ItemGroup> |
||||
<ClCompile Include="adblock.cpp" /> |
||||
<ClCompile Include="nsGenericFactory.cpp" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClInclude Include="adcomp.h" /> |
||||
<ClInclude Include="nsGenericFactory.h" /> |
||||
<ClInclude Include="resource.h" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ResourceCompile Include="adblock.rc" /> |
||||
</ItemGroup> |
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
||||
<ImportGroup Label="ExtensionTargets"> |
||||
</ImportGroup> |
||||
</Project> |
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
||||
<Filter Include="Fichiers sources"> |
||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> |
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> |
||||
</Filter> |
||||
<Filter Include="Fichiers d%27en-tête"> |
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> |
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> |
||||
</Filter> |
||||
<Filter Include="Fichiers de ressources"> |
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> |
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> |
||||
</Filter> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClCompile Include="adblock.cpp"> |
||||
<Filter>Fichiers sources</Filter> |
||||
</ClCompile> |
||||
<ClCompile Include="nsGenericFactory.cpp"> |
||||
<Filter>Fichiers sources</Filter> |
||||
</ClCompile> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ClInclude Include="adcomp.h"> |
||||
<Filter>Fichiers d%27en-tête</Filter> |
||||
</ClInclude> |
||||
<ClInclude Include="nsGenericFactory.h"> |
||||
<Filter>Fichiers d%27en-tête</Filter> |
||||
</ClInclude> |
||||
<ClInclude Include="resource.h"> |
||||
<Filter>Fichiers d%27en-tête</Filter> |
||||
</ClInclude> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ResourceCompile Include="adblock.rc"> |
||||
<Filter>Fichiers de ressources</Filter> |
||||
</ResourceCompile> |
||||
</ItemGroup> |
||||
</Project> |
@ -0,0 +1,60 @@
|
||||
|
||||
#include <vector> |
||||
#include "nsIContentPolicy.h" |
||||
#include "nsIWebProgressListener.h" |
||||
#include "nsIWebBrowserPersist.h" |
||||
#include "nsIObserver.h" |
||||
#include "nsEmbedString.h" |
||||
#include "nsIDOMWindow.h" |
||||
|
||||
class nsIEffectiveTLDService; |
||||
|
||||
|
||||
#define POLICY_CID { 0x842170b0, 0x5220, 0x12db, { 0xb0, 0xde, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66}} |
||||
static NS_DEFINE_CID(kPolicyCID, POLICY_CID); |
||||
|
||||
class Policy:public nsIContentPolicy, public nsIObserver { |
||||
protected: |
||||
nsCOMPtr<nsIEffectiveTLDService> tld; |
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICONTENTPOLICY |
||||
NS_DECL_NSIOBSERVER |
||||
|
||||
Policy(); |
||||
virtual ~Policy() { |
||||
nsCOMPtr<nsIObserverService> observerService = do_GetService("@mozilla.org/observer-service;1"); |
||||
if (!observerService) return; |
||||
//observerService->RemoveObserver(this, "content-document-global-created");
|
||||
//observerService->RemoveObserver(this, "http-on-opening-request");
|
||||
}; |
||||
|
||||
bool IsInWhiteList(nsIURI* aUri); |
||||
bool Process(nsIDOMWindow* wnd, nsIDOMNode* node, nsIURI* location, unsigned int contentType); |
||||
}; |
||||
|
||||
|
||||
|
||||
class Subscriptions : nsIWebProgressListener |
||||
{ |
||||
protected: |
||||
std::vector<std::string> subscriptionList; |
||||
std::vector<std::string>::iterator dwnIt; |
||||
nsCOMPtr<nsIWebBrowserPersist> persist; |
||||
nsEmbedCString mContentDisposition; |
||||
bool _Download(); |
||||
std::wstring tmpFile; |
||||
std::wstring adFile; |
||||
std::wstring cacheFile; |
||||
public: |
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIWEBPROGRESSLISTENER; |
||||
|
||||
Subscriptions(); |
||||
virtual ~Subscriptions() {}; |
||||
|
||||
bool RulesExists(); |
||||
bool Parse(); |
||||
bool Download(); |
||||
bool Add(const char* url); |
||||
}; |
@ -0,0 +1,208 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
||||
* |
||||
* The contents of this file are subject to the Mozilla Public License Version |
||||
* 1.1 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* http://www.mozilla.org/MPL/
|
||||
* |
||||
* Software distributed under the License is distributed on an "AS IS" basis, |
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
||||
* for the specific language governing rights and limitations under the |
||||
* License. |
||||
* |
||||
* The Original Code is mozilla.org code. |
||||
* |
||||
* The Initial Developer of the Original Code is |
||||
* Netscape Communications Corporation. |
||||
* Portions created by the Initial Developer are Copyright (C) 1998 |
||||
* the Initial Developer. All Rights Reserved. |
||||
* |
||||
* Contributor(s): |
||||
* Pierre Phaneuf <pp@ludusdesign.com> |
||||
* |
||||
* Alternatively, the contents of this file may be used under the terms of |
||||
* either of the GNU General Public License Version 2 or later (the "GPL"), |
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
||||
* in which case the provisions of the GPL or the LGPL are applicable instead |
||||
* of those above. If you wish to allow use of your version of this file only |
||||
* under the terms of either the GPL or the LGPL, and not to allow others to |
||||
* use your version of this file under the terms of the MPL, indicate your |
||||
* decision by deleting the provisions above and replace them with the notice |
||||
* and other provisions required by the GPL or the LGPL. If you do not delete |
||||
* the provisions above, a recipient may use your version of this file under |
||||
* the terms of any one of the MPL, the GPL or the LGPL. |
||||
* |
||||
* ***** END LICENSE BLOCK ***** */ |
||||
|
||||
|
||||
|
||||
// I need this file only when build with XPCOM_GLUE
|
||||
// When builded with it the components should be in a
|
||||
// external dll file like the original mfcembed do.
|
||||
// But we don't really need it to have them in a dll.
|
||||
//#ifdef XPCOM_GLUE
|
||||
|
||||
// DO NOT COPY THIS CODE INTO YOUR SOURCE! USE NS_IMPL_NSGETMODULE()
|
||||
|
||||
#include "nsMemory.h" |
||||
#include "nsCOMPtr.h" |
||||
#include "nsIComponentManager.h" |
||||
#include "nsIComponentRegistrar.h" |
||||
#include "nsGenericFactory.h" |
||||
#include "nsIProgrammingLanguage.h" |
||||
|
||||
|
||||
nsGenericFactory::nsGenericFactory(const nsModuleComponentInfo *info) |
||||
: mInfo(info) |
||||
{ |
||||
|
||||
} |
||||
|
||||
nsGenericFactory::~nsGenericFactory() |
||||
{ |
||||
|
||||
} |
||||
|
||||
NS_IMPL_ISUPPORTS(nsGenericFactory, |
||||
nsIGenericFactory, |
||||
nsIFactory, |
||||
nsIClassInfo) |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::CreateInstance(nsISupports *aOuter, |
||||
REFNSIID aIID, void **aResult) |
||||
{ |
||||
if (mInfo->mConstructor) { |
||||
return mInfo->mConstructor(aOuter, aIID, aResult); |
||||
} |
||||
|
||||
return NS_ERROR_FACTORY_NOT_REGISTERED; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::LockFactory(bool aLock) |
||||
{ |
||||
// XXX do we care if (mInfo->mFlags & THREADSAFE)?
|
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetInterfaces(PRUint32 *countp, |
||||
nsIID* **array) |
||||
{ |
||||
*countp = 0; |
||||
*array = nullptr; |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetHelperForLanguage(PRUint32 language, |
||||
nsISupports **helper) |
||||
{ |
||||
*helper = nullptr; |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetContractID(char **aContractID) |
||||
{ |
||||
if (mInfo->mContractID) { |
||||
*aContractID = (char *)nsMemory::Alloc(strlen(mInfo->mContractID) + 1); |
||||
if (!*aContractID) |
||||
return NS_ERROR_OUT_OF_MEMORY; |
||||
strcpy(*aContractID, mInfo->mContractID); |
||||
} else { |
||||
*aContractID = nullptr; |
||||
} |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetClassDescription(char * *aClassDescription) |
||||
{ |
||||
if (mInfo->mDescription) { |
||||
*aClassDescription = (char *) |
||||
nsMemory::Alloc(strlen(mInfo->mDescription) + 1); |
||||
if (!*aClassDescription) |
||||
return NS_ERROR_OUT_OF_MEMORY; |
||||
strcpy(*aClassDescription, mInfo->mDescription); |
||||
} else { |
||||
*aClassDescription = nullptr; |
||||
} |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetClassID(nsCID * *aClassID) |
||||
{ |
||||
*aClassID = |
||||
reinterpret_cast<nsCID*> |
||||
(nsMemory::Clone(&mInfo->mCID, sizeof mInfo->mCID)); |
||||
if (! *aClassID) |
||||
return NS_ERROR_OUT_OF_MEMORY; |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetClassIDNoAlloc(nsCID *aClassID) |
||||
{ |
||||
*aClassID = mInfo->mCID; |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetImplementationLanguage(PRUint32 *langp) |
||||
{ |
||||
*langp = nsIProgrammingLanguage::CPLUSPLUS; |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetFlags(PRUint32 *flagsp) |
||||
{ |
||||
return NS_OK; |
||||
} |
||||
|
||||
// nsIGenericFactory: component-info accessors
|
||||
NS_IMETHODIMP nsGenericFactory::SetComponentInfo(const nsModuleComponentInfo *info) |
||||
{ |
||||
mInfo = info; |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_IMETHODIMP nsGenericFactory::GetComponentInfo(const nsModuleComponentInfo **infop) |
||||
{ |
||||
*infop = mInfo; |
||||
return NS_OK; |
||||
} |
||||
|
||||
NS_METHOD nsGenericFactory::Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr) |
||||
{ |
||||
// sorry, aggregation not spoken here.
|
||||
nsresult res = NS_ERROR_NO_AGGREGATION; |
||||
if (outer == NULL) { |
||||
nsGenericFactory* factory = new nsGenericFactory; |
||||
if (factory != NULL) { |
||||
res = factory->QueryInterface(aIID, aInstancePtr); |
||||
if (res != NS_OK) |
||||
delete factory; |
||||
} else { |
||||
res = NS_ERROR_OUT_OF_MEMORY; |
||||
} |
||||
} |
||||
return res; |
||||
} |
||||
|
||||
|
||||
nsresult |
||||
NS_NewGenericFactory(nsIGenericFactory* *result, |
||||
const nsModuleComponentInfo *info) |
||||
{ |
||||
nsresult rv; |
||||
nsIGenericFactory* fact; |
||||
rv = nsGenericFactory::Create(NULL, NS_GET_IID(nsIFactory), (void**)&fact); |
||||
if (NS_FAILED(rv)) return rv; |
||||
rv = fact->SetComponentInfo(info); |
||||
if (NS_FAILED(rv)) goto error; |
||||
*result = fact; |
||||
return rv; |
||||
|
||||
error: |
||||
NS_RELEASE(fact); |
||||
return rv; |
||||
} |
||||
|
||||
|
||||
//#endif //XPCOM_GLUE
|
@ -0,0 +1,150 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
||||
* |
||||
* The contents of this file are subject to the Mozilla Public License Version |
||||
* 1.1 (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* http://www.mozilla.org/MPL/
|
||||
* |
||||
* Software distributed under the License is distributed on an "AS IS" basis, |
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
||||
* for the specific language governing rights and limitations under the |
||||
* License. |
||||
* |
||||
* The Original Code is mozilla.org code. |
||||
* |
||||
* The Initial Developer of the Original Code is |
||||
* Netscape Communications Corporation. |
||||
* Portions created by the Initial Developer are Copyright (C) 1998 |
||||
* the Initial Developer. All Rights Reserved. |
||||
* |
||||
* Contributor(s): |
||||
* |
||||
* Alternatively, the contents of this file may be used under the terms of |
||||
* either of the GNU General Public License Version 2 or later (the "GPL"), |
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
||||
* in which case the provisions of the GPL or the LGPL are applicable instead |
||||
* of those above. If you wish to allow use of your version of this file only |
||||
* under the terms of either the GPL or the LGPL, and not to allow others to |
||||
* use your version of this file under the terms of the MPL, indicate your |
||||
* decision by deleting the provisions above and replace them with the notice |
||||
* and other provisions required by the GPL or the LGPL. If you do not delete |
||||
* the provisions above, a recipient may use your version of this file under |
||||
* the terms of any one of the MPL, the GPL or the LGPL. |
||||
* |
||||
* ***** END LICENSE BLOCK ***** */ |
||||
|
||||
|
||||
|
||||
#include "nsCOMPtr.h" |
||||
#include "nsIFactory.h" |
||||
#include "nsIClassInfo.h" |
||||
#include "mozilla/ModuleUtils.h" |
||||
|
||||
struct nsModuleComponentInfo { |
||||
const char* mDescription; |
||||
nsCID mCID; |
||||
const char* mContractID; |
||||
mozilla::Module::ConstructorProcPtr mConstructor;
|
||||
}; |
||||
|
||||
// {3bc97f01-ccdf-11d2-bab8-b548654461fc}
|
||||
#define NS_GENERICFACTORY_CID \ |
||||
{ 0x3bc97f01, 0xccdf, 0x11d2, \
|
||||
{ 0xba, 0xb8, 0xb5, 0x48, 0x65, 0x44, 0x61, 0xfc } } |
||||
|
||||
// {3bc97f00-ccdf-11d2-bab8-b548654461fc}
|
||||
#define NS_IGENERICFACTORY_IID \ |
||||
{ 0x3bc97f00, 0xccdf, 0x11d2, \
|
||||
{ 0xba, 0xb8, 0xb5, 0x48, 0x65, 0x44, 0x61, 0xfc } } |
||||
|
||||
class nsIGenericFactory : public nsIFactory { |
||||
public: |
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IGENERICFACTORY_IID) |
||||
|
||||
NS_IMETHOD SetComponentInfo(const nsModuleComponentInfo *info) = 0; |
||||
NS_IMETHOD GetComponentInfo(const nsModuleComponentInfo **infop) = 0; |
||||
}; |
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsIGenericFactory, NS_IGENERICFACTORY_IID); |
||||
|
||||
/**
|
||||
* Most factories follow this simple pattern, so why not just use a function |
||||
* pointer for most creation operations? |
||||
*/ |
||||
class nsGenericFactory : public nsIGenericFactory, public nsIClassInfo { |
||||
public: |
||||
NS_DEFINE_STATIC_CID_ACCESSOR(NS_GENERICFACTORY_CID) |
||||
|
||||
nsGenericFactory(const nsModuleComponentInfo *info = NULL); |
||||
|
||||
NS_DECL_ISUPPORTS |
||||
NS_DECL_NSICLASSINFO |
||||
|
||||
/* nsIGenericFactory methods */ |
||||
NS_IMETHOD SetComponentInfo(const nsModuleComponentInfo *info); |
||||
NS_IMETHOD GetComponentInfo(const nsModuleComponentInfo **infop); |
||||
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter, REFNSIID aIID, void **aResult); |
||||
|
||||
NS_IMETHOD LockFactory(bool aLock); |
||||
|
||||
static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr); |
||||
private: |
||||
~nsGenericFactory(); |
||||
|
||||
const nsModuleComponentInfo *mInfo; |
||||
}; |
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "nsIModule.h" |
||||
#include "plhash.h" |
||||
|
||||
class nsGenericModule : public nsIModule |
||||
{ |
||||
public: |
||||
nsGenericModule(const char* moduleName,
|
||||
PRUint32 componentCount, |
||||
const nsModuleComponentInfo* components, |
||||
mozilla::Module::ConstructorProcPtr ctor); |
||||
|
||||
private: |
||||
~nsGenericModule(); |
||||
|
||||
public: |
||||
NS_DECL_ISUPPORTS |
||||
|
||||
NS_DECL_NSIMODULE |
||||
|
||||
struct FactoryNode |
||||
{ |
||||
FactoryNode(nsIFactory* fact, FactoryNode* next)
|
||||
{
|
||||
mFactory = fact;
|
||||
mNext = next; |
||||
} |
||||
~FactoryNode(){} |
||||
|
||||
nsCOMPtr<nsIFactory> mFactory; |
||||
FactoryNode* mNext; |
||||
}; |
||||
|
||||
|
||||
|
||||
|
||||
protected: |
||||
nsresult Initialize(nsIComponentManager* compMgr); |
||||
|
||||
void Shutdown(); |
||||
nsresult AddFactoryNode(nsIFactory* fact); |
||||
|
||||
PRBool mInitialized; |
||||
const char* mModuleName; |
||||
PRUint32 mComponentCount; |
||||
const nsModuleComponentInfo* mComponents; |
||||
FactoryNode* mFactoriesNotToBeRegistered; |
||||
mozilla::Module::ConstructorProcPtr mCtor; |
||||
//nsModuleDestructorProc mDtor;
|
||||
}; |
@ -0,0 +1,14 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by adblock.rc
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED |
||||
#ifndef APSTUDIO_READONLY_SYMBOLS |
||||
#define _APS_NEXT_RESOURCE_VALUE 101 |
||||
#define _APS_NEXT_COMMAND_VALUE 40001 |
||||
#define _APS_NEXT_CONTROL_VALUE 1001 |
||||
#define _APS_NEXT_SYMED_VALUE 101 |
||||
#endif |
||||
#endif |
Loading…
Reference in new issue