This commit is contained in:
scullin%netscape.com 1998-09-22 00:08:27 +00:00
Родитель 7b3aceb98b
Коммит d875fa60bc
10 изменённых файлов: 2097 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,23 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH=..\..\..
IGNORE_MANIFEST=1
DIRS= win
include <$(DEPTH)\config\rules.mak>

Просмотреть файл

@ -0,0 +1,212 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <ole2.h>
#include <comcat.h>
#include <olectl.h>
#include <tchar.h>
#include "factory.h"
#pragma data_seg(".text")
#define INITGUID
#include <initguid.h>
#include <shlguid.h>
#include "Guid.h"
#pragma data_seg()
extern "C" BOOL WINAPI DllMain(HINSTANCE, DWORD, LPVOID);
BOOL RegisterServer(CLSID, LPTSTR, BOOL);
HINSTANCE g_hInst;
UINT g_DllRefCount;
extern "C" BOOL WINAPI DllMain( HINSTANCE hInstance,
DWORD dwReason,
LPVOID lpReserved)
{
switch(dwReason)
{
case DLL_PROCESS_ATTACH:
g_hInst = hInstance;
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
STDAPI DllCanUnloadNow(void)
{
return (g_DllRefCount ? S_FALSE : S_OK);
}
STDAPI DllGetClassObject( REFCLSID rclsid,
REFIID riid,
LPVOID *ppReturn)
{
*ppReturn = NULL;
//if we don't support this classid, return the proper error code
if(!IsEqualCLSID(rclsid, CLSID_NGLayoutPrefs))
return CLASS_E_CLASSNOTAVAILABLE;
//create a CClassFactory object and check it for validity
CClassFactory *pClassFactory = new CClassFactory(rclsid);
if(NULL == pClassFactory)
return E_OUTOFMEMORY;
//get the QueryInterface return for our return value
HRESULT hResult = pClassFactory->QueryInterface(riid, ppReturn);
//call Release to decement the ref count - creating the object set it to one
//and QueryInterface incremented it - since its being used externally (not by
//us), we only want the ref count to be 1
pClassFactory->Release();
//return the result from QueryInterface
return hResult;
}
STDAPI DllRegisterServer(void)
{
//Register the explorer bar object.
if(!RegisterServer(CLSID_NGLayoutPrefs, _T("NGLayoutPrefs"), TRUE))
return SELFREG_E_CLASS;
return S_OK;
}
STDAPI DllUnregisterServer(void)
{
//Unregister the explorer bar object.
if(!RegisterServer(CLSID_NGLayoutPrefs, _T("NGLayoutPrefs"), FALSE))
return SELFREG_E_CLASS;
return S_OK;
}
typedef struct{
HKEY hRootKey;
LPTSTR szSubKey;//TCHAR szSubKey[MAX_PATH];
LPTSTR lpszValueName;
LPTSTR szData;//TCHAR szData[MAX_PATH];
} DOREGSTRUCT, *LPDOREGSTRUCT;
BOOL RegisterServer(CLSID clsid, LPTSTR lpszTitle, BOOL bRegister)
{
int i;
LRESULT lResult;
DWORD dwDisp;
TCHAR szSubKey[MAX_PATH];
TCHAR szCLSID[MAX_PATH];
LPWSTR pwsz;
//get the CLSID in string form
StringFromIID(clsid, &pwsz);
if(pwsz)
{
#ifdef UNICODE
lstrcpy(szCLSID, pwsz);
#else
WideCharToMultiByte(CP_ACP,
0,
pwsz,
-1,
szCLSID,
MAX_PATH,
NULL,
NULL);
#endif
//free the string
LPMALLOC pMalloc;
CoGetMalloc(1, &pMalloc);
pMalloc->Free(pwsz);
pMalloc->Release();
}
if (bRegister)
{
HKEY hKey;
TCHAR szModule[MAX_PATH];
DOREGSTRUCT ClsidEntries[] = {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s"), NULL, lpszTitle,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), NULL, szModule,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), TEXT("ThreadingModel"), TEXT("Apartment"),
NULL, NULL, NULL, NULL};
//get this app's path and file name
GetModuleFileName(g_hInst, szModule, MAX_PATH);
//register the CLSID entries
for(i = 0; ClsidEntries[i].hRootKey; i++)
{
//create the sub key string - for this case, insert the file extension
wsprintf(szSubKey, ClsidEntries[i].szSubKey, szCLSID);
lResult = RegCreateKeyEx( ClsidEntries[i].hRootKey,
szSubKey,
0,
NULL,
REG_OPTION_NON_VOLATILE,
KEY_WRITE,
NULL,
&hKey,
&dwDisp);
if(NOERROR == lResult)
{
TCHAR szData[MAX_PATH];
//if necessary, create the value string
wsprintf(szData, ClsidEntries[i].szData, szModule);
lResult = RegSetValueEx( hKey,
ClsidEntries[i].lpszValueName,
0,
REG_SZ,
(LPBYTE)szData,
lstrlen(szData) + 1);
RegCloseKey(hKey);
}
else
return FALSE;
}
} else {
DOREGSTRUCT ClsidEntries[] = {HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\InprocServer32"), NULL, NULL,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s\\Implemented Categories"), NULL, NULL,
HKEY_CLASSES_ROOT, TEXT("CLSID\\%s"), NULL, NULL,
NULL, NULL, NULL, NULL};
//unregister the CLSID entries
for(i = 0; ClsidEntries[i].hRootKey; i++)
{
//create the sub key string - for this case, insert the file extension
wsprintf(szSubKey, ClsidEntries[i].szSubKey, szCLSID);
lResult = RegDeleteKey(ClsidEntries[i].hRootKey,
szSubKey);
if (lResult != NOERROR && lResult != ERROR_FILE_NOT_FOUND)
return FALSE;
}
}
return TRUE;
}

Просмотреть файл

@ -0,0 +1,202 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "factory.h"
#include "globals.h"
#include "ngprefs.h"
/**
* CNGLayoutPrefs
*/
class CNGLayoutPrefs: public INGLayoutPrefs {
private:
int m_ObjRefCount;
public:
CNGLayoutPrefs();
~CNGLayoutPrefs();
//IUnknown methods
STDMETHOD (QueryInterface)(REFIID, LPVOID*);
STDMETHOD_(DWORD, AddRef)();
STDMETHOD_(DWORD, Release)();
//INGLayoutPrefs
STDMETHOD (Show)(HWND hwnd);
};
CNGLayoutPrefs::CNGLayoutPrefs()
{
m_ObjRefCount = 1;
g_DllRefCount++;
}
CNGLayoutPrefs::~CNGLayoutPrefs()
{
g_DllRefCount--;
}
STDMETHODIMP CNGLayoutPrefs::QueryInterface(REFIID riid, LPVOID *ppReturn)
{
*ppReturn = NULL;
//IUnknown
if(IsEqualIID(riid, IID_IUnknown))
{
*ppReturn = this;
}
//INGLayoutPrefs
else if(IsEqualIID(riid, IID_INGLayoutPrefs))
{
*ppReturn = (INGLayoutPrefs*)this;
}
if(*ppReturn)
{
(*(LPUNKNOWN*)ppReturn)->AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(DWORD) CNGLayoutPrefs::AddRef()
{
return ++m_ObjRefCount;
}
STDMETHODIMP_(DWORD) CNGLayoutPrefs::Release()
{
if(--m_ObjRefCount == 0)
{
delete this;
return 0;
}
return m_ObjRefCount;
}
STDMETHODIMP CNGLayoutPrefs::Show(HWND hwnd)
{
DisplayPreferences(hwnd);
return S_OK;
}
/**
* CNGLayoutPrefs
*/
CClassFactory::CClassFactory(CLSID clsid)
{
m_clsidObject = clsid;
m_ObjRefCount = 1;
g_DllRefCount++;
}
CClassFactory::~CClassFactory()
{
g_DllRefCount--;
}
STDMETHODIMP CClassFactory::QueryInterface(REFIID riid, LPVOID *ppReturn)
{
*ppReturn = NULL;
if(IsEqualIID(riid, IID_IUnknown))
{
*ppReturn = this;
}
else if(IsEqualIID(riid, IID_IClassFactory))
{
*ppReturn = (IClassFactory*)this;
}
if(*ppReturn)
{
(*(LPUNKNOWN*)ppReturn)->AddRef();
return S_OK;
}
return E_NOINTERFACE;
}
STDMETHODIMP_(DWORD) CClassFactory::AddRef()
{
return ++m_ObjRefCount;
}
STDMETHODIMP_(DWORD) CClassFactory::Release()
{
if(--m_ObjRefCount == 0)
{
delete this;
return 0;
}
return m_ObjRefCount;
}
STDMETHODIMP CClassFactory::CreateInstance( LPUNKNOWN pUnknown,
REFIID riid,
LPVOID *ppObject)
{
HRESULT hResult = E_FAIL;
LPVOID pTemp = NULL;
*ppObject = NULL;
if(pUnknown != NULL)
return CLASS_E_NOAGGREGATION;
//create the proper object
if(IsEqualCLSID(m_clsidObject, CLSID_NGLayoutPrefs))
{
CNGLayoutPrefs *pPrefs = new CNGLayoutPrefs();
if(NULL == pPrefs)
return E_OUTOFMEMORY;
pTemp = pPrefs;
}
if(pTemp)
{
//get the QueryInterface return for our return value
hResult = ((LPUNKNOWN)pTemp)->QueryInterface(riid, ppObject);
//call Release to decement the ref count
((LPUNKNOWN)pTemp)->Release();
}
return hResult;
}
/**************************************************************************
CClassFactory::LockServer
**************************************************************************/
STDMETHODIMP CClassFactory::LockServer(BOOL)
{
return E_NOTIMPL;
}

Просмотреть файл

@ -0,0 +1,45 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef __FACTORY_H
#define __FACTORY_H
#include <windows.h>
#include <ole2.h>
#include "ngprefs.h"
class CClassFactory : public IClassFactory
{
private:
DWORD m_ObjRefCount;
CLSID m_clsidObject;
public:
CClassFactory(CLSID);
~CClassFactory();
//IUnknown methods
STDMETHOD (QueryInterface)(REFIID, LPVOID*);
STDMETHOD_(DWORD, AddRef)();
STDMETHOD_(DWORD, Release)();
//IClassFactory methods
STDMETHOD (CreateInstance)(LPUNKNOWN, REFIID, LPVOID*);
STDMETHOD (LockServer)(BOOL);
};
#endif // __FACTORY_H

Просмотреть файл

@ -0,0 +1,26 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef __GLOBALS_H
#define __GLOBALS_H
extern HINSTANCE g_hInst;
extern UINT g_DllRefCount;
#endif // __GLOBALS_H

Просмотреть файл

@ -0,0 +1,18 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/

Просмотреть файл

@ -0,0 +1,64 @@
#!nmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
IGNORE_MANIFEST=1
MAKE_OBJ_TYPE = DLL
DEPTH=..\..\..\..
LINCS = \
-I$(PUBLIC) \
-I$(DEPTH)\cmd\winfe \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\pref \
-I$(PUBLIC)\js \
$(NULL)
LLIBS = \
$(LIBNSPR) \
$(DIST)\lib\libplc21.lib \
$(DIST)\lib\xppref32.lib \
OLE32.lib \
UUID.lib \
$(NULL)
LIBNAME = .\$(OBJDIR)\ngprefs
DLL = $(LIBNAME).dll
DEFFILE=ngprefs.def
LCFLAGS = -D_IMPL_NS_COM -DUSE_NSREG -DWIN32_LEAN_AND_MEAN -UEDITOR
CPP_OBJS = \
.\$(OBJDIR)\dllmain.obj \
.\$(OBJDIR)\ngprefs.obj \
.\$(OBJDIR)\factory.obj \
$(NULL)
EXPORTS = \
ngprefs.h \
$(NULL)
MODULE = ngprefs
include <$(DEPTH)\config\rules.mak>
libs:: $(DLL)
$(MAKE_INSTALL) $(LIBNAME).$(DLL_SUFFIX) $(DIST)\bin
$(MAKE_INSTALL) $(LIBNAME).$(LIB_SUFFIX) $(DIST)\lib

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,9 @@
LIBRARY ngprefs.dll
DESCRIPTION "ngprefs"
EXPORTS
DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE

Просмотреть файл

@ -0,0 +1,39 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _PREFS_H
#define _PREFS_H
#include <ole2.h>
// {5F541370-4DAE-11d2-B70A-00805F8A2676}
DEFINE_GUID(CLSID_NGLayoutPrefs,
0x5f541370, 0x4dae, 0x11d2, 0xb7, 0xa, 0x0, 0x80, 0x5f, 0x8a, 0x26, 0x76);
// {4E97BE30-4DB1-11d2-B70A-00805F8A2676}
DEFINE_GUID(IID_INGLayoutPrefs,
0x4e97be30, 0x4db1, 0x11d2, 0xb7, 0xa, 0x0, 0x80, 0x5f, 0x8a, 0x26, 0x76);
interface INGLayoutPrefs: public IUnknown {
STDMETHOD(Show)(HWND hwnd) = 0;
};
extern "C" void
DisplayPreferences(HWND pFrame);
#endif