1999-01-28 18:56:14 +01:00
|
|
|
/***************************************************************************************
|
|
|
|
* BindCtx implementation
|
|
|
|
*
|
|
|
|
* Copyright 1999 Noomen Hamza
|
|
|
|
***************************************************************************************/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "wine/obj_moniker.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "heap.h"
|
|
|
|
|
1999-04-19 16:56:29 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(ole)
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* represent the first size table and it's increment block size */
|
|
|
|
#define BLOCK_TAB_SIZE 10
|
|
|
|
#define MAX_TAB_SIZE 0xFFFFFFFF
|
|
|
|
|
|
|
|
/* data structure of the BindCtx table elements */
|
|
|
|
typedef struct BindCtxObject{
|
|
|
|
|
|
|
|
IUnknown* pObj; /* point on a bound object */
|
|
|
|
|
|
|
|
LPOLESTR pkeyObj; /* key associated to this bound object */
|
|
|
|
|
|
|
|
BYTE regType; /* registration type: 1 if RegisterObjectParam and 0 if RegisterObjectBound */
|
|
|
|
|
|
|
|
} BindCtxObject;
|
|
|
|
|
|
|
|
/* BindCtx data strucrture */
|
1999-01-28 18:56:14 +01:00
|
|
|
typedef struct BindCtxImpl{
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
ICOM_VTABLE(IBindCtx)* lpvtbl; /* VTable relative to the IBindCtx interface.*/
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
ULONG ref; /* reference counter for this object */
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
BindCtxObject* bindCtxTable; /* this is a table in witch all bounded objects are stored*/
|
|
|
|
DWORD bindCtxTableLastIndex; /* first free index in the table */
|
|
|
|
DWORD bindCtxTableSize; /* size table */
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
BIND_OPTS2 bindOption2; /* a structure witch contains the bind options*/
|
1999-02-18 14:26:22 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
} BindCtxImpl;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* IBindCtx prototype functions : */
|
|
|
|
|
|
|
|
/* IUnknown functions*/
|
|
|
|
static HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject);
|
|
|
|
static ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface);
|
|
|
|
static ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface);
|
|
|
|
/* IBindCtx functions */
|
|
|
|
static HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown** punk);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** ppenum);
|
|
|
|
static HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR pszkey);
|
|
|
|
/* Local functions*/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This);
|
|
|
|
HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This);
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_GetObjectIndex(BindCtxImpl* This,IUnknown* punk,LPOLESTR pszkey,DWORD *index);
|
1999-02-18 14:26:22 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Virtual function table for the BindCtx class. */
|
1999-01-28 18:56:14 +01:00
|
|
|
static ICOM_VTABLE(IBindCtx) VT_BindCtxImpl =
|
|
|
|
{
|
1999-05-22 13:41:38 +02:00
|
|
|
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
|
1999-02-18 14:26:22 +01:00
|
|
|
BindCtxImpl_QueryInterface,
|
|
|
|
BindCtxImpl_AddRef,
|
|
|
|
BindCtxImpl_Release,
|
|
|
|
BindCtxImpl_RegisterObjectBound,
|
|
|
|
BindCtxImpl_RevokeObjectBound,
|
1999-03-23 14:48:56 +01:00
|
|
|
BindCtxImpl_ReleaseBoundObjects,
|
1999-02-18 14:26:22 +01:00
|
|
|
BindCtxImpl_SetBindOptions,
|
|
|
|
BindCtxImpl_GetBindOptions,
|
|
|
|
BindCtxImpl_GetRunningObjectTable,
|
|
|
|
BindCtxImpl_RegisterObjectParam,
|
|
|
|
BindCtxImpl_GetObjectParam,
|
|
|
|
BindCtxImpl_EnumObjectParam,
|
|
|
|
BindCtxImpl_RevokeObjectParam
|
1999-01-28 18:56:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* BindCtx_QueryInterface
|
|
|
|
*******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_QueryInterface(IBindCtx* iface,REFIID riid,void** ppvObject)
|
|
|
|
{
|
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-01-28 18:56:14 +01:00
|
|
|
TRACE(ole,"(%p,%p,%p)\n",This,riid,ppvObject);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* Perform a sanity check on the parameters.*/
|
|
|
|
if ( (This==0) || (ppvObject==0) )
|
|
|
|
return E_INVALIDARG;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Initialize the return parameter.*/
|
1999-01-28 18:56:14 +01:00
|
|
|
*ppvObject = 0;
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Compare the riid with the interface IDs implemented by this object.*/
|
|
|
|
if (IsEqualIID(&IID_IUnknown, riid))
|
1999-01-28 18:56:14 +01:00
|
|
|
*ppvObject = (IBindCtx*)This;
|
|
|
|
else
|
1999-03-23 14:48:56 +01:00
|
|
|
if (IsEqualIID(&IID_IBindCtx, riid))
|
1999-01-28 18:56:14 +01:00
|
|
|
*ppvObject = (IBindCtx*)This;
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Check that we obtained an interface.*/
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
return E_NOINTERFACE;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Query Interface always increases the reference count by one when it is successful */
|
1999-02-18 14:26:22 +01:00
|
|
|
BindCtxImpl_AddRef(iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* BindCtx_AddRef
|
1999-01-28 18:56:14 +01:00
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
ULONG WINAPI BindCtxImpl_AddRef(IBindCtx* iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-01-28 18:56:14 +01:00
|
|
|
TRACE(ole,"(%p)\n",This);
|
|
|
|
|
|
|
|
return ++(This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BindCtx_Release
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
ULONG WINAPI BindCtxImpl_Release(IBindCtx* iface)
|
|
|
|
{
|
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-01-28 18:56:14 +01:00
|
|
|
TRACE(ole,"(%p)\n",This);
|
|
|
|
|
|
|
|
This->ref--;
|
|
|
|
|
|
|
|
if (This->ref==0){
|
1999-03-23 14:48:56 +01:00
|
|
|
|
|
|
|
/* release all registred objects */
|
|
|
|
BindCtxImpl_ReleaseBoundObjects((IBindCtx*)This);
|
|
|
|
|
1999-02-18 14:26:22 +01:00
|
|
|
BindCtxImpl_Destroy(This);
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-01-28 18:56:14 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return This->ref;;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* BindCtx_Construct (local function)
|
1999-01-28 18:56:14 +01:00
|
|
|
*******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_Construct(BindCtxImpl* This)
|
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p)\n",This);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Initialize the virtual function table.*/
|
1999-01-28 18:56:14 +01:00
|
|
|
This->lpvtbl = &VT_BindCtxImpl;
|
1999-03-23 14:48:56 +01:00
|
|
|
This->ref = 0;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* Initialize the BIND_OPTS2 structure */
|
|
|
|
This->bindOption2.cbStruct = sizeof(BIND_OPTS2);
|
|
|
|
This->bindOption2.grfFlags = 0;
|
|
|
|
This->bindOption2.grfMode = STGM_READWRITE;
|
|
|
|
This->bindOption2.dwTickCountDeadline = 0;
|
|
|
|
|
|
|
|
This->bindOption2.dwTrackFlags = 0;
|
|
|
|
This->bindOption2.dwClassContext = CLSCTX_SERVER;
|
|
|
|
This->bindOption2.locale = 1033;
|
|
|
|
This->bindOption2.pServerInfo = 0;
|
|
|
|
|
|
|
|
/* Initialize the bindctx table */
|
|
|
|
This->bindCtxTableSize=BLOCK_TAB_SIZE;
|
|
|
|
This->bindCtxTableLastIndex=0;
|
|
|
|
This->bindCtxTable= HeapAlloc(GetProcessHeap(), 0,This->bindCtxTableSize*sizeof(BindCtxObject));
|
|
|
|
|
|
|
|
if (This->bindCtxTable==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* BindCtx_Destroy (local function)
|
1999-01-28 18:56:14 +01:00
|
|
|
*******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_Destroy(BindCtxImpl* This)
|
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p)\n",This);
|
|
|
|
|
|
|
|
/* free the table space memory */
|
|
|
|
HeapFree(GetProcessHeap(),0,This->bindCtxTable);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/* free the bindctx structure */
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BindCtx_RegisterObjectBound
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_RegisterObjectBound(IBindCtx* iface,IUnknown* punk)
|
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
|
1999-02-18 14:26:22 +01:00
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-03-23 14:48:56 +01:00
|
|
|
DWORD lastIndex=This->bindCtxTableLastIndex;
|
|
|
|
BindCtxObject cell;
|
|
|
|
|
|
|
|
TRACE(ole,"(%p,%p)\n",This,punk);
|
|
|
|
|
|
|
|
if (punk==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
IUnknown_AddRef(punk);
|
|
|
|
|
|
|
|
/* put the object in the first free element in the table */
|
|
|
|
This->bindCtxTable[lastIndex].pObj = punk;
|
|
|
|
This->bindCtxTable[lastIndex].pkeyObj = NULL;
|
|
|
|
This->bindCtxTable[lastIndex].regType = 0;
|
|
|
|
cell=This->bindCtxTable[lastIndex];
|
|
|
|
lastIndex= ++This->bindCtxTableLastIndex;
|
|
|
|
|
|
|
|
if (lastIndex == This->bindCtxTableSize){ /* the table is full so it must be resized */
|
|
|
|
|
|
|
|
if (This->bindCtxTableSize > (MAX_TAB_SIZE-BLOCK_TAB_SIZE)){
|
|
|
|
FIXME(ole,"This->bindCtxTableSize: %ld is out of data limite \n",This->bindCtxTableSize);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
This->bindCtxTableSize+=BLOCK_TAB_SIZE; /* new table size */
|
|
|
|
|
|
|
|
This->bindCtxTable = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,This->bindCtxTable,
|
|
|
|
This->bindCtxTableSize * sizeof(BindCtxObject));
|
|
|
|
if (!This->bindCtxTable)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BindCtx_RevokeObjectBound
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_RevokeObjectBound(IBindCtx* iface, IUnknown* punk)
|
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
DWORD index,j;
|
|
|
|
|
1999-02-18 14:26:22 +01:00
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p,%p)\n",This,punk);
|
|
|
|
|
|
|
|
/* check if the object was registred or not */
|
|
|
|
if (BindCtxImpl_GetObjectIndex(This,punk,NULL,&index)==S_FALSE)
|
|
|
|
|
|
|
|
return MK_E_NOTBOUND;
|
|
|
|
|
|
|
|
IUnknown_Release(This->bindCtxTable[index].pObj);
|
|
|
|
|
|
|
|
/* left-shift all elements in the rigth side of the curent revoked object */
|
|
|
|
for(j=index; j<This->bindCtxTableLastIndex-1; j++)
|
|
|
|
This->bindCtxTable[j]= This->bindCtxTable[j+1];
|
|
|
|
|
|
|
|
This->bindCtxTableLastIndex--;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* BindCtx_ReleaseBoundObjects
|
1999-01-28 18:56:14 +01:00
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_ReleaseBoundObjects(IBindCtx* iface)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
DWORD i;
|
|
|
|
|
1999-02-18 14:26:22 +01:00
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p)\n",This);
|
|
|
|
|
|
|
|
for(i=0;i<This->bindCtxTableLastIndex;i++)
|
|
|
|
IUnknown_Release(This->bindCtxTable[i].pObj);
|
|
|
|
|
|
|
|
This->bindCtxTableLastIndex = 0;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BindCtx_SetBindOptions
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_SetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
|
|
|
|
{
|
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p,%p)\n",This,pbindopts);
|
|
|
|
|
|
|
|
if (pbindopts==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
This->bindOption2=*pbindopts;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BindCtx_GetBindOptions
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_GetBindOptions(IBindCtx* iface,LPBIND_OPTS2 pbindopts)
|
|
|
|
{
|
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p,%p)\n",This,pbindopts);
|
|
|
|
|
|
|
|
if (pbindopts==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*pbindopts=This->bindOption2;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BindCtx_GetRunningObjectTable
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_GetRunningObjectTable(IBindCtx* iface,IRunningObjectTable** pprot)
|
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT res;
|
|
|
|
|
1999-02-18 14:26:22 +01:00
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p,%p)\n",This,pprot);
|
|
|
|
|
|
|
|
if (pprot==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
res=GetRunningObjectTable(0,(LPVOID*)pprot);
|
|
|
|
|
|
|
|
return res;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* BindCtx_RegisterObjectParam
|
|
|
|
******************************************************************************/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_RegisterObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown* punk)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p,%p,%p)\n",This,pszkey,punk);
|
|
|
|
|
|
|
|
if (punk==NULL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
IUnknown_AddRef(punk);
|
|
|
|
|
|
|
|
This->bindCtxTable[This->bindCtxTableLastIndex].pObj = punk;
|
|
|
|
This->bindCtxTable[This->bindCtxTableLastIndex].regType = 1;
|
|
|
|
|
|
|
|
if (pszkey==NULL)
|
|
|
|
|
|
|
|
This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj=NULL;
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj=
|
|
|
|
HeapAlloc(GetProcessHeap(),0,(sizeof(WCHAR)*(1+lstrlenW(pszkey))));
|
|
|
|
|
|
|
|
if (This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj==NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
lstrcpyW(This->bindCtxTable[This->bindCtxTableLastIndex].pkeyObj,pszkey);
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
This->bindCtxTableLastIndex++;
|
|
|
|
|
|
|
|
if (This->bindCtxTableLastIndex == This->bindCtxTableSize){ /* table is full ! must be resized */
|
|
|
|
|
|
|
|
This->bindCtxTableSize+=BLOCK_TAB_SIZE; /* new table size */
|
|
|
|
|
|
|
|
if (This->bindCtxTableSize > (MAX_TAB_SIZE-BLOCK_TAB_SIZE)){
|
|
|
|
FIXME(ole,"This->bindCtxTableSize: %ld is out of data limite \n",This->bindCtxTableSize);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
This->bindCtxTable = HeapReAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,This->bindCtxTable,
|
|
|
|
This->bindCtxTableSize * sizeof(BindCtxObject));
|
|
|
|
if (!This->bindCtxTable)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
1999-01-28 18:56:14 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* BindCtx_GetObjectParam
|
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_GetObjectParam(IBindCtx* iface,LPOLESTR pszkey, IUnknown** punk)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
DWORD index;
|
1999-02-18 14:26:22 +01:00
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p,%p,%p)\n",This,pszkey,punk);
|
|
|
|
|
|
|
|
if (punk==NULL)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
*punk=0;
|
|
|
|
|
|
|
|
if (BindCtxImpl_GetObjectIndex(This,NULL,pszkey,&index)==S_FALSE)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
IUnknown_AddRef(This->bindCtxTable[index].pObj);
|
|
|
|
|
|
|
|
*punk = This->bindCtxTable[index].pObj;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* BindCtx_RevokeObjectParam
|
1999-01-28 18:56:14 +01:00
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_RevokeObjectParam(IBindCtx* iface,LPOLESTR ppenum)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
DWORD index,j;
|
|
|
|
|
1999-02-18 14:26:22 +01:00
|
|
|
ICOM_THIS(BindCtxImpl,iface);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
TRACE(ole,"(%p,%p)\n",This,ppenum);
|
|
|
|
|
|
|
|
if (BindCtxImpl_GetObjectIndex(This,NULL,ppenum,&index)==S_FALSE)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
/* release the object if it's found */
|
|
|
|
IUnknown_Release(This->bindCtxTable[index].pObj);
|
|
|
|
|
|
|
|
/* remove the object from the table with a left-shifting of all objects in the right side */
|
|
|
|
for(j=index; j<This->bindCtxTableLastIndex-1; j++)
|
|
|
|
This->bindCtxTable[j]= This->bindCtxTable[j+1];
|
|
|
|
|
|
|
|
This->bindCtxTableLastIndex--;
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-28 18:56:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* BindCtx_EnumObjectParam
|
1999-01-28 18:56:14 +01:00
|
|
|
******************************************************************************/
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT WINAPI BindCtxImpl_EnumObjectParam(IBindCtx* iface,IEnumString** pszkey)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-03-23 14:48:56 +01:00
|
|
|
FIXME(ole,"(%p,%p),stub!\n",iface,pszkey);
|
1999-01-28 18:56:14 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
/********************************************************************************
|
|
|
|
* GetObjectIndex (local function)
|
|
|
|
********************************************************************************/
|
|
|
|
HRESULT WINAPI BindCtxImpl_GetObjectIndex(BindCtxImpl* This,
|
|
|
|
IUnknown* punk,
|
|
|
|
LPOLESTR pszkey,
|
|
|
|
DWORD *index)
|
|
|
|
{
|
|
|
|
|
|
|
|
DWORD i;
|
|
|
|
BYTE found=0;
|
|
|
|
|
|
|
|
TRACE(ole,"(%p,%p,%p,%p)\n",This,punk,pszkey,index);
|
|
|
|
|
|
|
|
if (punk==NULL)
|
|
|
|
/* search object identified by a register key */
|
|
|
|
for(i=0; ( (i<This->bindCtxTableLastIndex) && (!found));i++){
|
|
|
|
|
|
|
|
if(This->bindCtxTable[i].regType==1){
|
|
|
|
|
|
|
|
if ( ( (This->bindCtxTable[i].pkeyObj==NULL) && (pszkey==NULL) ) ||
|
|
|
|
( (This->bindCtxTable[i].pkeyObj!=NULL) &&
|
|
|
|
(pszkey!=NULL) &&
|
|
|
|
(lstrcmpW(This->bindCtxTable[i].pkeyObj,pszkey)==0)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
found=1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
/* search object identified by a moniker*/
|
|
|
|
for(i=0; ( (i<This->bindCtxTableLastIndex) && (!found));i++)
|
|
|
|
if(This->bindCtxTable[i].pObj==punk)
|
|
|
|
found=1;
|
|
|
|
|
|
|
|
if (index != NULL)
|
|
|
|
*index=i-1;
|
|
|
|
|
|
|
|
if (found)
|
|
|
|
return S_OK;
|
|
|
|
else
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
1999-01-28 18:56:14 +01:00
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* CreateBindCtx16
|
|
|
|
******************************************************************************/
|
1999-02-18 14:26:22 +01:00
|
|
|
HRESULT WINAPI CreateBindCtx16(DWORD reserved, LPBC * ppbc)
|
|
|
|
{
|
1999-01-28 18:56:14 +01:00
|
|
|
FIXME(ole,"(%ld,%p),stub!\n",reserved,ppbc);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
1999-03-23 14:48:56 +01:00
|
|
|
* CreateBindCtx
|
1999-01-28 18:56:14 +01:00
|
|
|
******************************************************************************/
|
1999-02-26 12:11:13 +01:00
|
|
|
HRESULT WINAPI CreateBindCtx(DWORD reserved, LPBC * ppbc)
|
1999-02-18 14:26:22 +01:00
|
|
|
{
|
1999-01-28 18:56:14 +01:00
|
|
|
BindCtxImpl* newBindCtx = 0;
|
1999-03-23 14:48:56 +01:00
|
|
|
HRESULT hr;
|
|
|
|
IID riid=IID_IBindCtx;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
|
|
|
TRACE(ole,"(%ld,%p)\n",reserved,ppbc);
|
|
|
|
|
|
|
|
newBindCtx = HeapAlloc(GetProcessHeap(), 0, sizeof(BindCtxImpl));
|
|
|
|
|
|
|
|
if (newBindCtx == 0)
|
1999-03-23 14:48:56 +01:00
|
|
|
return E_OUTOFMEMORY;
|
1999-01-28 18:56:14 +01:00
|
|
|
|
|
|
|
hr = BindCtxImpl_Construct(newBindCtx);
|
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
if (FAILED(hr)){
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),0,newBindCtx);
|
1999-01-28 18:56:14 +01:00
|
|
|
return hr;
|
1999-03-23 14:48:56 +01:00
|
|
|
}
|
1999-01-28 18:56:14 +01:00
|
|
|
|
1999-03-23 14:48:56 +01:00
|
|
|
hr = BindCtxImpl_QueryInterface((IBindCtx*)newBindCtx,&riid,(void**)ppbc);
|
1999-01-28 18:56:14 +01:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|