#define INITOBJECTS                // define the descriptions for our objects

#include "IPServer.H"
#include "LocalSrv.H"

const static IID IID_ICatRegister = {0x0002E012,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};

//#include "LocalObj.H"
#include "CtrlObj.H"
//#include "olectl.H"
#include "Globals.H"
#include "Util.H"
#include "Resource.H"

#include "wsocxctl.h"
#include "WSocxPPG.H"
#include "cathelp.H"
#include <WSDappDev.h>


// Control Globals
//
//CRITICAL_SECTION drawCritSec;
//HBITMAP cardcacheMem[14*4+14];	// 4 suites * 14 cards + 14 card backs

const CATID CATID_SafeForScripting = {0x7dd95801,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};
const CATID CATID_SafeForInitializing = {0x7dd95802,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};

// needed for ASSERTs and FAIL
//
SZTHISFILE

//=--------------------------------------------------------------------------=
// our Libid.  This should be the LIBID from the Type library, or NULL if you
// don't have one.
//
const CLSID *g_pLibid = &LIBID_WSocxObjects;
//const CLSID *g_pLibid = &IID_IWSocx;


//=--------------------------------------------------------------------------=
// Localization Information
//
// We need the following two pieces of information:
//    a. whether or not this DLL uses satellite DLLs for localization.  if
//       not, then the lcidLocale is ignored, and we just always get resources
//       from the server module file.
//    b. the ambient LocaleID for this in-proc server.  Controls calling
//       GetResourceHandle() will set this up automatically, but anybody
//       else will need to be sure that it's set up properly.
//
const VARIANT_BOOL    g_fSatelliteLocalization =  FALSE;
LCID            g_lcidLocale = MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT);


//=--------------------------------------------------------------------------=
// your license key and where under HKEY_CLASSES_ROOT_LICENSES it's sitting
//
const WCHAR g_wszLicenseKey [] = L"";
const WCHAR g_wszLicenseLocation [] = L"";


WNDPROC g_ParkingWindowProc = NULL;

//=--------------------------------------------------------------------------=
// This Table describes all the automatible objects in your automation server.
// See AutomationObject.H for a description of what goes in this structure
// and what it's used for.
//
OBJECTINFO g_ObjectInfo[] = {
    CONTROLOBJECT(WSocx),
    PROPERTYPAGE(WSocxGeneral),
    EMPTYOBJECT
};

const char g_szLibName[] = "ActiveXSDKWSocx";

void WINAPI InitializeLibrary (void ){
dbprintf("InitializeLibrary %s:%d start\n",__FILE__,__LINE__);
//	InitializeCriticalSection( &drawCritSec );
dbprintf("InitializeLibrary %s:%d done\n",__FILE__,__LINE__);
}

void WINAPI UninitializeLibrary(void){
dbprintf("UninitializeLibrary %s:%d start\n",__FILE__,__LINE__);
//	DeleteCriticalSection( &drawCritSec );
//
//	for( int t = 0; t < sizeof(cardcacheMem)/sizeof(cardcacheMem[0]); t++ )
//		if( cardcacheMem[t] )
//			DeleteObject( cardcacheMem[t] );
dbprintf("UninitializeLibrary %s:%d done\n",__FILE__,__LINE__);
}

BOOL WINAPI CheckForLicense(void){
    return TRUE;
}

BOOL WINAPI RegisterData(void){
dbprintf("RegisterData %s:%d start\n",__FILE__,__LINE__);
	HRESULT hr;

	hr = CreateComponentCategory(CATID_SafeForScripting, L"Controls that are safely scriptable");
	hr = CreateComponentCategory(CATID_SafeForInitializing, L"Controls safely initializable from persistent data");
	hr = RegisterCLSIDInCategory(CLSID_WSocx, CATID_SafeForScripting);
	hr = RegisterCLSIDInCategory(CLSID_WSocx, CATID_SafeForInitializing);
dbprintf("RegisterData %s:%d done\n",__FILE__,__LINE__);
    return TRUE;
}

BOOL WINAPI UnregisterData(void){
dbprintf("UnregisterData %s:%d start\n",__FILE__,__LINE__);
	HRESULT hr;

	hr = UnRegisterCLSIDInCategory(CLSID_WSocx, CATID_SafeForScripting);
	hr = UnRegisterCLSIDInCategory(CLSID_WSocx, CATID_SafeForInitializing);
dbprintf("UnregisterData %s:%d done\n",__FILE__,__LINE__);
    return TRUE;
}

BOOL WINAPI      CheckLicenseKey(LPWSTR wszCheckme){
	return TRUE;
}

BSTR WINAPI      GetLicenseKey(void){
dbprintf("CheckLicenseKey %s:%d start/done\n",__FILE__,__LINE__);
	return NULL;
}
void WSGFwsIePluginInitialize(){
  WSGIappDev()->setMode(WS_MODE_NS_PLUGIN);
extern void dummyf();
  dummyf();
}
void dummyf(){
  if (1){
    return;
  }
extern void dummy_ipserver();
  dummy_ipserver();
extern void dummy_wsocxctl();
  dummy_wsocxctl();
}

