- Sync itss and msctf with Wine 1.1.20

svn path=/trunk/; revision=40814
This commit is contained in:
Dmitry Chapyshev 2009-05-06 08:47:39 +00:00
parent 6c47ffb60d
commit 64c34901d8
9 changed files with 327 additions and 11 deletions

View file

@ -1,5 +1,5 @@
<group>
<module name="itss" type="win32dll" baseaddress="${BASEADDRESS_ITSS}" installbase="system32" installname="itss.dll" crt="msvcrt">
<module name="itss" type="win32dll" baseaddress="${BASEADDRESS_ITSS}" installbase="system32" installname="itss.dll" crt="msvcrt" allowwarnings="true">
<autoregister infsection="OleControlDlls" type="DllRegisterServer" />
<importlibrary definition="itss.spec" />
<include base="itss">.</include>

View file

@ -137,7 +137,7 @@ static HRESULT report_result(IInternetProtocolSink *sink, HRESULT hres)
static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
IInternetProtocolSink *pOIProtSink, IInternetBindInfo *pOIBindInfo,
DWORD grfPI, DWORD dwReserved)
DWORD grfPI, HANDLE_PTR dwReserved)
{
ITSProtocol *This = PROTOCOL_THIS(iface);
BINDINFO bindinfo;
@ -151,7 +151,7 @@ static HRESULT WINAPI ITSProtocol_Start(IInternetProtocol *iface, LPCWSTR szUrl,
static const WCHAR separator[] = {':',':',0};
TRACE("(%p)->(%s %p %p %08x %d)\n", This, debugstr_w(szUrl), pOIProtSink,
TRACE("(%p)->(%s %p %p %08x %lx)\n", This, debugstr_w(szUrl), pOIProtSink,
pOIBindInfo, grfPI, dwReserved);
ptr = skip_schema(szUrl);

View file

@ -382,7 +382,7 @@ static WINAPI HRESULT ContextSource_AdviseSink(ITfSource *iface,
return CONNECT_E_CANNOTCONNECT;
}
list_add_head(&This->pTextEditSink ,&es->entry);
*pdwCookie = (DWORD)es;
*pdwCookie = generate_Cookie(COOKIE_MAGIC_CONTEXTSINK, es);
}
else
{
@ -396,10 +396,18 @@ static WINAPI HRESULT ContextSource_AdviseSink(ITfSource *iface,
static WINAPI HRESULT ContextSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
{
ContextSink *sink = (ContextSink*)pdwCookie;
ContextSink *sink;
Context *This = impl_from_ITfSourceVtbl(iface);
TRACE("(%p) %x\n",This,pdwCookie);
if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_CONTEXTSINK)
return E_INVALIDARG;
sink = (ContextSink*)remove_Cookie(pdwCookie);
if (!sink)
return CONNECT_E_NOCONNECTION;
list_remove(&sink->entry);
free_sink(sink);

View file

@ -167,7 +167,7 @@ static HRESULT WINAPI DocumentMgr_Pop(ITfDocumentMgr *iface, DWORD dwFlags)
if (dwFlags)
return E_INVALIDARG;
if (This->contextStack[0] == NULL) /* Cannot pop last context */
if (This->contextStack[1] == NULL) /* Cannot pop last context */
return E_FAIL;
ITfThreadMgrEventSink_OnPopContext(This->ThreadMgrSink,This->contextStack[0]);
@ -199,14 +199,21 @@ static HRESULT WINAPI DocumentMgr_GetTop(ITfDocumentMgr *iface, ITfContext **ppi
static HRESULT WINAPI DocumentMgr_GetBase(ITfDocumentMgr *iface, ITfContext **ppic)
{
DocumentMgr *This = (DocumentMgr *)iface;
ITfContext *tgt;
TRACE("(%p)\n",This);
if (!ppic)
return E_INVALIDARG;
if (This->contextStack[1])
ITfContext_AddRef(This->contextStack[1]);
tgt = This->contextStack[1];
else
tgt = This->contextStack[0];
*ppic = This->contextStack[1];
if (tgt)
ITfContext_AddRef(tgt);
*ppic = tgt;
return S_OK;
}

View file

@ -43,6 +43,17 @@ static LONG MSCTF_refCount;
static HINSTANCE MSCTF_hinstance;
typedef struct
{
DWORD id;
DWORD magic;
LPVOID data;
} CookieInternal;
static CookieInternal *cookies;
static UINT id_last;
static UINT array_size;
DWORD tlsIndex = 0;
const WCHAR szwSystemTIPKey[] = {'S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t','\\','C','T','F','\\','T','I','P',0};
@ -154,6 +165,93 @@ static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
return S_OK;
}
/*************************************************************************
* DWORD Cookie Management
*/
DWORD generate_Cookie(DWORD magic, LPVOID data)
{
int i;
/* try to reuse IDs if possible */
for (i = 0; i < id_last; i++)
if (cookies[i].id == 0) break;
if (i == array_size)
{
if (!array_size)
{
cookies = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(CookieInternal) * 10);
if (!cookies)
{
ERR("Out of memory, Unable to alloc cookies array\n");
return 0;
}
array_size = 10;
}
else
{
CookieInternal *new_cookies = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, cookies,
sizeof(CookieInternal) * (array_size * 2));
if (!new_cookies)
{
ERR("Out of memory, Unable to realloc cookies array\n");
return 0;
}
cookies = new_cookies;
array_size *= 2;
}
}
cookies[i].id = i + 1; /* a return of 0 is used for failure */
cookies[i].magic = magic;
cookies[i].data = data;
if (i == id_last)
id_last++;
return cookies[i].id;
}
DWORD get_Cookie_magic(DWORD id)
{
UINT index = id - 1;
if (index >= id_last)
return 0;
if (cookies[index].id == 0)
return 0;
return cookies[index].magic;
}
LPVOID get_Cookie_data(DWORD id)
{
UINT index = id - 1;
if (index >= id_last)
return NULL;
if (cookies[index].id == 0)
return NULL;
return cookies[index].data;
}
LPVOID remove_Cookie(DWORD id)
{
UINT index = id - 1;
if (index >= id_last)
return NULL;
if (cookies[index].id == 0)
return NULL;
cookies[index].id = 0;
return cookies[index].data;
}
/*************************************************************************
* MSCTF DllMain
*/

View file

@ -1,3 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
<group>
<module name="msctf" type="win32dll" baseaddress="${BASEADDRESS_MSCTF}" installbase="system32" installname="msctf.dll" allowwarnings="true">
<autoregister infsection="OleControlDlls" type="DllRegisterServer" />
<importlibrary definition="msctf.spec" />
@ -21,3 +24,7 @@
<library>kernel32</library>
<library>ntdll</library>
</module>
<module name="msctf_local_interface" type="idlinterface">
<file>msctf_local.idl</file>
</module>
</group>

View file

@ -20,6 +20,10 @@
#ifndef __WINE_MSCTF_I_H
#define __WINE_MSCTF_I_H
#define COOKIE_MAGIC_TMSINK 0x0010
#define COOKIE_MAGIC_CONTEXTSINK 0x0020
extern DWORD tlsIndex;
extern HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut);
@ -28,5 +32,11 @@ extern HRESULT Context_Constructor(TfClientId tidOwner, IUnknown *punk, ITfConte
extern HRESULT InputProcessorProfiles_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut);
extern HRESULT CategoryMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut);
/* cookie function */
extern DWORD generate_Cookie(DWORD magic, LPVOID data);
extern DWORD get_Cookie_magic(DWORD id);
extern LPVOID get_Cookie_data(DWORD id);
extern LPVOID remove_Cookie(DWORD id);
extern const WCHAR szwSystemTIPKey[];
#endif /* __WINE_MSCTF_I_H */

View file

@ -0,0 +1,2 @@
#include "msctf.idl"

View file

@ -59,6 +59,7 @@ typedef struct tagThreadMgrSink {
typedef struct tagACLMulti {
const ITfThreadMgrVtbl *ThreadMgrVtbl;
const ITfSourceVtbl *SourceVtbl;
const ITfKeystrokeMgrVtbl *KeystrokeMgrVtbl;
LONG refCount;
const ITfThreadMgrEventSinkVtbl *ThreadMgrEventSinkVtbl; /* internal */
@ -79,6 +80,11 @@ static inline ThreadMgr *impl_from_ITfSourceVtbl(ITfSource *iface)
return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,SourceVtbl));
}
static inline ThreadMgr *impl_from_ITfKeystrokeMgrVtbl(ITfKeystrokeMgr *iface)
{
return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,KeystrokeMgrVtbl));
}
static inline ThreadMgr *impl_from_ITfThreadMgrEventSink(ITfThreadMgrEventSink *iface)
{
return (ThreadMgr *)((char *)iface - FIELD_OFFSET(ThreadMgr,ThreadMgrEventSinkVtbl));
@ -153,6 +159,10 @@ static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid,
{
*ppvOut = &This->SourceVtbl;
}
else if (IsEqualIID(iid, &IID_ITfKeystrokeMgr))
{
*ppvOut = &This->KeystrokeMgrVtbl;
}
if (*ppvOut)
{
@ -196,6 +206,14 @@ static HRESULT WINAPI ThreadMgr_fnDeactivate( ITfThreadMgr* iface)
{
ThreadMgr *This = (ThreadMgr *)iface;
FIXME("STUB:(%p)\n",This);
if (This->focus)
{
ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, 0, This->focus);
ITfDocumentMgr_Release(This->focus);
This->focus = 0;
}
return E_NOTIMPL;
}
@ -246,7 +264,7 @@ static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *p
if (!pdimFocus || FAILED(IUnknown_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check)))
return E_INVALIDARG;
ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, This->focus, check);
ITfThreadMgrEventSink_OnSetFocus((ITfThreadMgrEventSink*)&This->ThreadMgrEventSinkVtbl, check, This->focus);
if (This->focus)
ITfDocumentMgr_Release(This->focus);
@ -357,7 +375,7 @@ static WINAPI HRESULT ThreadMgrSource_AdviseSink(ITfSource *iface,
return CONNECT_E_CANNOTCONNECT;
}
list_add_head(&This->ThreadMgrEventSink,&tms->entry);
*pdwCookie = (DWORD)tms;
*pdwCookie = generate_Cookie(COOKIE_MAGIC_TMSINK, tms);
}
else
{
@ -372,10 +390,18 @@ static WINAPI HRESULT ThreadMgrSource_AdviseSink(ITfSource *iface,
static WINAPI HRESULT ThreadMgrSource_UnadviseSink(ITfSource *iface, DWORD pdwCookie)
{
ThreadMgrSink *sink = (ThreadMgrSink*)pdwCookie;
ThreadMgrSink *sink;
ThreadMgr *This = impl_from_ITfSourceVtbl(iface);
TRACE("(%p) %x\n",This,pdwCookie);
if (get_Cookie_magic(pdwCookie)!=COOKIE_MAGIC_TMSINK)
return E_INVALIDARG;
sink = (ThreadMgrSink*)remove_Cookie(pdwCookie);
if (!sink)
return CONNECT_E_NOCONNECTION;
list_remove(&sink->entry);
free_sink(sink);
@ -392,6 +418,163 @@ static const ITfSourceVtbl ThreadMgr_SourceVtbl =
ThreadMgrSource_UnadviseSink,
};
/*****************************************************
* ITfKeystrokeMgr functions
*****************************************************/
static HRESULT WINAPI KeystrokeMgr_QueryInterface(ITfKeystrokeMgr *iface, REFIID iid, LPVOID *ppvOut)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
return ThreadMgr_QueryInterface((ITfThreadMgr *)This, iid, *ppvOut);
}
static ULONG WINAPI KeystrokeMgr_AddRef(ITfKeystrokeMgr *iface)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
return ThreadMgr_AddRef((ITfThreadMgr*)This);
}
static ULONG WINAPI KeystrokeMgr_Release(ITfKeystrokeMgr *iface)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
return ThreadMgr_Release((ITfThreadMgr *)This);
}
static HRESULT WINAPI KeystrokeMgr_AdviseKeyEventSink(ITfKeystrokeMgr *iface,
TfClientId tid, ITfKeyEventSink *pSink, BOOL fForeground)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_UnadviseKeyEventSink(ITfKeystrokeMgr *iface,
TfClientId tid)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_GetForeground(ITfKeystrokeMgr *iface,
CLSID *pclsid)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_TestKeyDown(ITfKeystrokeMgr *iface,
WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_TestKeyUp(ITfKeystrokeMgr *iface,
WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_KeyDown(ITfKeystrokeMgr *iface,
WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_KeyUp(ITfKeystrokeMgr *iface,
WPARAM wParam, LPARAM lParam, BOOL *pfEaten)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_GetPreservedKey(ITfKeystrokeMgr *iface,
ITfContext *pic, const TF_PRESERVEDKEY *pprekey, GUID *pguid)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_IsPreservedKey(ITfKeystrokeMgr *iface,
REFGUID rguid, const TF_PRESERVEDKEY *pprekey, BOOL *pfRegistered)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_PreserveKey(ITfKeystrokeMgr *iface,
TfClientId tid, REFGUID rguid, const TF_PRESERVEDKEY *prekey,
const WCHAR *pchDesc, ULONG cchDesc)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_UnpreserveKey(ITfKeystrokeMgr *iface,
REFGUID rguid, const TF_PRESERVEDKEY *pprekey)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_SetPreservedKeyDescription(ITfKeystrokeMgr *iface,
REFGUID rguid, const WCHAR *pchDesc, ULONG cchDesc)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_GetPreservedKeyDescription(ITfKeystrokeMgr *iface,
REFGUID rguid, BSTR *pbstrDesc)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static HRESULT WINAPI KeystrokeMgr_SimulatePreservedKey(ITfKeystrokeMgr *iface,
ITfContext *pic, REFGUID rguid, BOOL *pfEaten)
{
ThreadMgr *This = impl_from_ITfKeystrokeMgrVtbl(iface);
FIXME("STUB:(%p)\n",This);
return E_NOTIMPL;
}
static const ITfKeystrokeMgrVtbl ThreadMgr_KeystrokeMgrVtbl =
{
KeystrokeMgr_QueryInterface,
KeystrokeMgr_AddRef,
KeystrokeMgr_Release,
KeystrokeMgr_AdviseKeyEventSink,
KeystrokeMgr_UnadviseKeyEventSink,
KeystrokeMgr_GetForeground,
KeystrokeMgr_TestKeyDown,
KeystrokeMgr_TestKeyUp,
KeystrokeMgr_KeyDown,
KeystrokeMgr_KeyUp,
KeystrokeMgr_GetPreservedKey,
KeystrokeMgr_IsPreservedKey,
KeystrokeMgr_PreserveKey,
KeystrokeMgr_UnpreserveKey,
KeystrokeMgr_SetPreservedKeyDescription,
KeystrokeMgr_GetPreservedKeyDescription,
KeystrokeMgr_SimulatePreservedKey
};
/*****************************************************
* ITfThreadMgrEventSink functions (internal)
*****************************************************/
@ -534,6 +717,7 @@ HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl;
This->SourceVtbl = &ThreadMgr_SourceVtbl;
This->KeystrokeMgrVtbl= &ThreadMgr_KeystrokeMgrVtbl;
This->ThreadMgrEventSinkVtbl = &ThreadMgr_ThreadMgrEventSinkVtbl;
This->refCount = 1;
TlsSetValue(tlsIndex,This);