2009-01-27 20:15:30 +00:00
|
|
|
/*
|
|
|
|
* ITfThreadMgr implementation
|
|
|
|
*
|
|
|
|
* Copyright 2008 Aric Stewart, CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#include "msctf.h"
|
|
|
|
#include "msctf_internal.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msctf);
|
|
|
|
|
|
|
|
typedef struct tagACLMulti {
|
|
|
|
const ITfThreadMgrVtbl *ThreadMgrVtbl;
|
|
|
|
LONG refCount;
|
2009-02-02 16:24:41 +00:00
|
|
|
|
|
|
|
ITfDocumentMgr *focus;
|
2009-01-27 20:15:30 +00:00
|
|
|
} ThreadMgr;
|
|
|
|
|
|
|
|
static void ThreadMgr_Destructor(ThreadMgr *This)
|
|
|
|
{
|
2009-02-02 16:24:47 +00:00
|
|
|
TlsSetValue(tlsIndex,NULL);
|
2009-01-27 20:15:30 +00:00
|
|
|
TRACE("destroying %p\n", This);
|
2009-02-02 16:24:41 +00:00
|
|
|
if (This->focus)
|
|
|
|
ITfDocumentMgr_Release(This->focus);
|
2009-01-27 20:15:30 +00:00
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_QueryInterface(ITfThreadMgr *iface, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
*ppvOut = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(iid, &IID_IUnknown) || IsEqualIID(iid, &IID_ITfThreadMgr))
|
|
|
|
{
|
|
|
|
*ppvOut = This;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*ppvOut)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef(iface);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("unsupported interface: %s\n", debugstr_guid(iid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgr_AddRef(ITfThreadMgr *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
return InterlockedIncrement(&This->refCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ThreadMgr_Release(ITfThreadMgr *iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
ULONG ret;
|
|
|
|
|
|
|
|
ret = InterlockedDecrement(&This->refCount);
|
|
|
|
if (ret == 0)
|
|
|
|
ThreadMgr_Destructor(This);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************
|
|
|
|
* ITfThreadMgr functions
|
|
|
|
*****************************************************/
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_fnActivate( ITfThreadMgr* iface, TfClientId *ptid)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_fnDeactivate( ITfThreadMgr* iface)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_CreateDocumentMgr( ITfThreadMgr* iface, ITfDocumentMgr
|
|
|
|
**ppdim)
|
|
|
|
{
|
2009-01-30 20:27:06 +00:00
|
|
|
TRACE("(%p)\n",iface);
|
|
|
|
return DocumentMgr_Constructor(ppdim);
|
2009-01-27 20:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_EnumDocumentMgrs( ITfThreadMgr* iface, IEnumTfDocumentMgrs
|
|
|
|
**ppEnum)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_GetFocus( ITfThreadMgr* iface, ITfDocumentMgr
|
|
|
|
**ppdimFocus)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
2009-02-02 16:24:41 +00:00
|
|
|
TRACE("(%p)\n",This);
|
|
|
|
|
|
|
|
if (!ppdimFocus)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
*ppdimFocus = This->focus;
|
|
|
|
|
|
|
|
TRACE("->%p\n",This->focus);
|
|
|
|
|
|
|
|
if (This->focus == NULL)
|
|
|
|
return S_FALSE;
|
|
|
|
|
|
|
|
ITfDocumentMgr_AddRef(This->focus);
|
|
|
|
|
|
|
|
return S_OK;
|
2009-01-27 20:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_SetFocus( ITfThreadMgr* iface, ITfDocumentMgr *pdimFocus)
|
|
|
|
{
|
2009-02-02 16:24:41 +00:00
|
|
|
ITfDocumentMgr *check;
|
2009-01-27 20:15:30 +00:00
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
2009-02-02 16:24:41 +00:00
|
|
|
|
|
|
|
TRACE("(%p) %p\n",This,pdimFocus);
|
|
|
|
|
|
|
|
if (!pdimFocus || FAILED(IUnknown_QueryInterface(pdimFocus,&IID_ITfDocumentMgr,(LPVOID*) &check)))
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (This->focus)
|
|
|
|
ITfDocumentMgr_Release(This->focus);
|
|
|
|
|
|
|
|
This->focus = check;
|
|
|
|
return S_OK;
|
2009-01-27 20:15:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_AssociateFocus( ITfThreadMgr* iface, HWND hwnd,
|
|
|
|
ITfDocumentMgr *pdimNew, ITfDocumentMgr **ppdimPrev)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_IsThreadFocus( ITfThreadMgr* iface, BOOL *pfThreadFocus)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_GetFunctionProvider( ITfThreadMgr* iface, REFCLSID clsid,
|
|
|
|
ITfFunctionProvider **ppFuncProv)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_EnumFunctionProviders( ITfThreadMgr* iface,
|
|
|
|
IEnumTfFunctionProviders **ppEnum)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ThreadMgr_GetGlobalCompartment( ITfThreadMgr* iface,
|
|
|
|
ITfCompartmentMgr **ppCompMgr)
|
|
|
|
{
|
|
|
|
ThreadMgr *This = (ThreadMgr *)iface;
|
|
|
|
FIXME("STUB:(%p)\n",This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const ITfThreadMgrVtbl ThreadMgr_ThreadMgrVtbl =
|
|
|
|
{
|
|
|
|
ThreadMgr_QueryInterface,
|
|
|
|
ThreadMgr_AddRef,
|
|
|
|
ThreadMgr_Release,
|
|
|
|
|
|
|
|
ThreadMgr_fnActivate,
|
|
|
|
ThreadMgr_fnDeactivate,
|
|
|
|
ThreadMgr_CreateDocumentMgr,
|
|
|
|
ThreadMgr_EnumDocumentMgrs,
|
|
|
|
ThreadMgr_GetFocus,
|
|
|
|
ThreadMgr_SetFocus,
|
|
|
|
ThreadMgr_AssociateFocus,
|
|
|
|
ThreadMgr_IsThreadFocus,
|
|
|
|
ThreadMgr_GetFunctionProvider,
|
|
|
|
ThreadMgr_EnumFunctionProviders,
|
|
|
|
ThreadMgr_GetGlobalCompartment
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT ThreadMgr_Constructor(IUnknown *pUnkOuter, IUnknown **ppOut)
|
|
|
|
{
|
|
|
|
ThreadMgr *This;
|
|
|
|
if (pUnkOuter)
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2009-02-02 16:24:47 +00:00
|
|
|
/* Only 1 ThreadMgr is created per thread */
|
|
|
|
This = TlsGetValue(tlsIndex);
|
|
|
|
if (This)
|
|
|
|
{
|
|
|
|
ThreadMgr_AddRef((ITfThreadMgr*)This);
|
|
|
|
*ppOut = (IUnknown*)This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-01-27 20:15:30 +00:00
|
|
|
This = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(ThreadMgr));
|
|
|
|
if (This == NULL)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->ThreadMgrVtbl= &ThreadMgr_ThreadMgrVtbl;
|
|
|
|
This->refCount = 1;
|
2009-02-02 16:24:47 +00:00
|
|
|
TlsSetValue(tlsIndex,This);
|
2009-01-27 20:15:30 +00:00
|
|
|
|
|
|
|
TRACE("returning %p\n", This);
|
|
|
|
*ppOut = (IUnknown *)This;
|
|
|
|
return S_OK;
|
|
|
|
}
|