msctf: Beginning of TfEditCookie definition and usage.

This commit is contained in:
Aric Stewart 2009-05-20 14:46:44 -05:00 committed by Alexandre Julliard
parent d82df8f9b0
commit a5006e7eb4
2 changed files with 30 additions and 4 deletions

View File

@ -69,6 +69,7 @@ typedef struct tagContext {
BOOL connected;
TfClientId tidOwner;
TfEditCookie defaultCookie;
ITextStoreACP *pITextStoreACP;
ITfContextOwnerCompositionSink *pITfContextOwnerCompositionSink;
@ -85,6 +86,10 @@ typedef struct tagContext {
} Context;
typedef struct tagEditCookie {
DWORD lockType;
Context *pOwningContext;
} EditCookie;
typedef struct tagTextStoreACPSink {
const ITextStoreACPSinkVtbl *TextStoreACPSinkVtbl;
@ -111,6 +116,7 @@ static void free_sink(ContextSink *sink)
static void Context_Destructor(Context *This)
{
struct list *cursor, *cursor2;
EditCookie *cookie;
TRACE("destroying %p\n", This);
if (This->pITextStoreACPSink)
@ -125,6 +131,13 @@ static void Context_Destructor(Context *This)
if (This->pITfContextOwnerCompositionSink)
ITextStoreACPSink_Release(This->pITfContextOwnerCompositionSink);
if (This->defaultCookie)
{
cookie = remove_Cookie(This->defaultCookie);
HeapFree(GetProcessHeap(),0,cookie);
This->defaultCookie = 0;
}
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->pContextKeyEventSink)
{
ContextSink* sink = LIST_ENTRY(cursor,ContextSink,entry);
@ -481,11 +494,19 @@ static const ITfSourceVtbl Context_SourceVtbl =
HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **ppOut, TfEditCookie *pecTextStore)
{
Context *This;
EditCookie *cookie;
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Context));
if (This == NULL)
return E_OUTOFMEMORY;
cookie = HeapAlloc(GetProcessHeap(),0,sizeof(EditCookie));
if (cookie == NULL)
{
HeapFree(GetProcessHeap(),0,This);
return E_OUTOFMEMORY;
}
TRACE("(%p) %x %p %p %p\n",This, tidOwner, punk, ppOut, pecTextStore);
This->ContextVtbl= &Context_ContextVtbl;
@ -494,6 +515,9 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp
This->tidOwner = tidOwner;
This->connected = FALSE;
cookie->lockType = TF_ES_READ;
cookie->pOwningContext = This;
if (punk)
{
IUnknown_QueryInterface(punk, &IID_ITextStoreACP,
@ -506,10 +530,8 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp
FIXME("Unhandled pUnk\n");
}
TRACE("returning %p\n", This);
*ppOut = (ITfContext*)This;
/* FIXME */
*pecTextStore = 0xdeaddead;
This->defaultCookie = generate_Cookie(COOKIE_MAGIC_EDITCOOKIE,cookie);
*pecTextStore = This->defaultCookie;
list_init(&This->pContextKeyEventSink);
list_init(&This->pEditTransactionSink);
@ -517,6 +539,9 @@ HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfContext **pp
list_init(&This->pTextEditSink);
list_init(&This->pTextLayoutSink);
*ppOut = (ITfContext*)This;
TRACE("returning %p\n", This);
return S_OK;
}

View File

@ -25,6 +25,7 @@
#define COOKIE_MAGIC_CONTEXTSINK 0x0020
#define COOKIE_MAGIC_GUIDATOM 0x0030
#define COOKIE_MAGIC_IPPSINK 0x0040
#define COOKIE_MAGIC_EDITCOOKIE 0x0050
extern DWORD tlsIndex;
extern TfClientId processId;