2009-01-27 21:15:08 +01:00
|
|
|
/*
|
|
|
|
* MSCTF Server DLL
|
|
|
|
*
|
|
|
|
* 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 <stdarg.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "shlguid.h"
|
2009-01-27 21:15:30 +01:00
|
|
|
#include "comcat.h"
|
2016-05-04 19:40:47 +02:00
|
|
|
#include "olectl.h"
|
2010-12-08 12:08:29 +01:00
|
|
|
#include "rpcproxy.h"
|
2009-01-27 21:15:30 +01:00
|
|
|
#include "msctf.h"
|
2013-08-05 13:14:50 +02:00
|
|
|
#include "inputscope.h"
|
2009-01-27 21:15:30 +01:00
|
|
|
|
|
|
|
#include "msctf_internal.h"
|
2009-01-27 21:15:08 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(msctf);
|
|
|
|
|
2009-01-29 23:12:30 +01:00
|
|
|
static HINSTANCE MSCTF_hinstance;
|
2009-01-27 21:15:08 +01:00
|
|
|
|
2009-04-21 17:47:48 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
DWORD id;
|
|
|
|
DWORD magic;
|
|
|
|
LPVOID data;
|
|
|
|
} CookieInternal;
|
|
|
|
|
2009-05-07 21:27:29 +02:00
|
|
|
typedef struct {
|
|
|
|
TF_LANGUAGEPROFILE LanguageProfile;
|
|
|
|
ITfTextInputProcessor *pITfTextInputProcessor;
|
2015-11-27 20:39:30 +01:00
|
|
|
ITfThreadMgrEx *pITfThreadMgrEx;
|
2009-05-08 15:50:59 +02:00
|
|
|
ITfKeyEventSink *pITfKeyEventSink;
|
2009-05-07 21:27:29 +02:00
|
|
|
TfClientId tid;
|
|
|
|
} ActivatedTextService;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
ActivatedTextService *ats;
|
|
|
|
} AtsEntry;
|
|
|
|
|
2009-04-21 17:47:48 +02:00
|
|
|
static CookieInternal *cookies;
|
|
|
|
static UINT id_last;
|
|
|
|
static UINT array_size;
|
|
|
|
|
2009-05-07 21:27:29 +02:00
|
|
|
static struct list AtsList = LIST_INIT(AtsList);
|
2009-05-07 21:28:00 +02:00
|
|
|
static UINT activated = 0;
|
2009-05-07 21:27:29 +02:00
|
|
|
|
2009-02-02 17:24:47 +01:00
|
|
|
DWORD tlsIndex = 0;
|
2009-05-07 21:28:00 +02:00
|
|
|
TfClientId processId = 0;
|
2009-06-15 23:25:36 +02:00
|
|
|
ITfCompartmentMgr *globalCompartmentMgr = NULL;
|
2009-02-02 17:24:47 +01:00
|
|
|
|
2009-02-03 20:17:41 +01:00
|
|
|
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};
|
2009-06-26 10:03:30 +02:00
|
|
|
const WCHAR szwSystemCTFKey[] = {'S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t','\\','C','T','F',0};
|
2009-02-03 20:17:41 +01:00
|
|
|
|
2009-01-27 21:15:08 +01:00
|
|
|
typedef HRESULT (*LPFNCONSTRUCTOR)(IUnknown *pUnkOuter, IUnknown **ppvOut);
|
|
|
|
|
|
|
|
static const struct {
|
|
|
|
REFCLSID clsid;
|
|
|
|
LPFNCONSTRUCTOR ctor;
|
|
|
|
} ClassesTable[] = {
|
2009-01-27 21:15:30 +01:00
|
|
|
{&CLSID_TF_ThreadMgr, ThreadMgr_Constructor},
|
2009-02-03 20:17:04 +01:00
|
|
|
{&CLSID_TF_InputProcessorProfiles, InputProcessorProfiles_Constructor},
|
2009-02-03 20:18:02 +01:00
|
|
|
{&CLSID_TF_CategoryMgr, CategoryMgr_Constructor},
|
2010-02-17 03:31:05 +01:00
|
|
|
{&CLSID_TF_LangBarMgr, LangBarMgr_Constructor},
|
2010-03-18 16:39:00 +01:00
|
|
|
{&CLSID_TF_DisplayAttributeMgr, DisplayAttributeMgr_Constructor},
|
2009-01-27 21:15:08 +01:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct tagClassFactory
|
|
|
|
{
|
2010-12-08 22:59:39 +01:00
|
|
|
IClassFactory IClassFactory_iface;
|
2009-01-27 21:15:08 +01:00
|
|
|
LONG ref;
|
|
|
|
LPFNCONSTRUCTOR ctor;
|
|
|
|
} ClassFactory;
|
|
|
|
|
2010-12-08 22:59:39 +01:00
|
|
|
static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
|
|
|
|
}
|
|
|
|
|
2009-01-27 21:15:08 +01:00
|
|
|
static void ClassFactory_Destructor(ClassFactory *This)
|
|
|
|
{
|
|
|
|
TRACE("Destroying class factory %p\n", This);
|
|
|
|
HeapFree(GetProcessHeap(),0,This);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
*ppvOut = NULL;
|
|
|
|
if (IsEqualIID(riid, &IID_IClassFactory) || IsEqualIID(riid, &IID_IUnknown)) {
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
*ppvOut = iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Unknown interface %s\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
|
|
|
|
{
|
2010-12-08 22:59:39 +01:00
|
|
|
ClassFactory *This = impl_from_IClassFactory(iface);
|
2009-01-27 21:15:08 +01:00
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
|
|
|
|
{
|
2010-12-08 22:59:39 +01:00
|
|
|
ClassFactory *This = impl_from_IClassFactory(iface);
|
2009-01-27 21:15:08 +01:00
|
|
|
ULONG ret = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
if (ret == 0)
|
|
|
|
ClassFactory_Destructor(This);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *punkOuter, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
2010-12-08 22:59:39 +01:00
|
|
|
ClassFactory *This = impl_from_IClassFactory(iface);
|
2009-01-27 21:15:08 +01:00
|
|
|
HRESULT ret;
|
|
|
|
IUnknown *obj;
|
|
|
|
|
|
|
|
TRACE("(%p, %p, %s, %p)\n", iface, punkOuter, debugstr_guid(iid), ppvOut);
|
|
|
|
ret = This->ctor(punkOuter, &obj);
|
|
|
|
if (FAILED(ret))
|
|
|
|
return ret;
|
|
|
|
ret = IUnknown_QueryInterface(obj, iid, ppvOut);
|
|
|
|
IUnknown_Release(obj);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL fLock)
|
|
|
|
{
|
2010-12-08 22:59:39 +01:00
|
|
|
ClassFactory *This = impl_from_IClassFactory(iface);
|
2009-01-27 21:15:08 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x)\n", This, fLock);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IClassFactoryVtbl ClassFactoryVtbl = {
|
|
|
|
/* IUnknown */
|
|
|
|
ClassFactory_QueryInterface,
|
|
|
|
ClassFactory_AddRef,
|
|
|
|
ClassFactory_Release,
|
|
|
|
|
|
|
|
/* IClassFactory*/
|
|
|
|
ClassFactory_CreateInstance,
|
|
|
|
ClassFactory_LockServer
|
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT ClassFactory_Constructor(LPFNCONSTRUCTOR ctor, LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
ClassFactory *This = HeapAlloc(GetProcessHeap(),0,sizeof(ClassFactory));
|
2010-12-08 22:59:39 +01:00
|
|
|
This->IClassFactory_iface.lpVtbl = &ClassFactoryVtbl;
|
2009-01-27 21:15:08 +01:00
|
|
|
This->ref = 1;
|
|
|
|
This->ctor = ctor;
|
2017-02-05 15:20:35 +01:00
|
|
|
*ppvOut = &This->IClassFactory_iface;
|
2009-01-27 21:15:08 +01:00
|
|
|
TRACE("Created class factory %p\n", This);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-04-21 17:47:48 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* DWORD Cookie Management
|
|
|
|
*/
|
|
|
|
DWORD generate_Cookie(DWORD magic, LPVOID data)
|
|
|
|
{
|
2013-02-13 22:06:41 +01:00
|
|
|
UINT i;
|
2009-04-21 17:47:48 +02:00
|
|
|
|
|
|
|
/* 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;
|
|
|
|
}
|
|
|
|
|
2009-05-04 21:31:15 +02:00
|
|
|
DWORD enumerate_Cookie(DWORD magic, DWORD *index)
|
|
|
|
{
|
2013-02-13 22:06:41 +01:00
|
|
|
unsigned int i;
|
2009-05-04 21:31:15 +02:00
|
|
|
for (i = *index; i < id_last; i++)
|
|
|
|
if (cookies[i].id != 0 && cookies[i].magic == magic)
|
|
|
|
{
|
|
|
|
*index = (i+1);
|
|
|
|
return cookies[i].id;
|
|
|
|
}
|
|
|
|
return 0x0;
|
|
|
|
}
|
|
|
|
|
2016-05-04 19:40:47 +02:00
|
|
|
HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie)
|
|
|
|
{
|
|
|
|
Sink *sink;
|
|
|
|
|
|
|
|
sink = HeapAlloc(GetProcessHeap(), 0, sizeof(*sink));
|
|
|
|
if (!sink)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
if (FAILED(IUnknown_QueryInterface(unk, riid, (void**)&sink->interfaces.pIUnknown)))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, sink);
|
|
|
|
return CONNECT_E_CANNOTCONNECT;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_add_head(sink_list, &sink->entry);
|
|
|
|
*cookie = generate_Cookie(cookie_magic, sink);
|
|
|
|
TRACE("cookie %x\n", *cookie);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-05-04 19:40:59 +02:00
|
|
|
static void free_sink(Sink *sink)
|
|
|
|
{
|
|
|
|
list_remove(&sink->entry);
|
|
|
|
IUnknown_Release(sink->interfaces.pIUnknown);
|
|
|
|
HeapFree(GetProcessHeap(), 0, sink);
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT unadvise_sink(DWORD cookie)
|
|
|
|
{
|
|
|
|
Sink *sink;
|
|
|
|
|
|
|
|
sink = remove_Cookie(cookie);
|
|
|
|
if (!sink)
|
|
|
|
return CONNECT_E_NOCONNECTION;
|
|
|
|
|
|
|
|
free_sink(sink);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-05-04 19:41:13 +02:00
|
|
|
void free_sinks(struct list *sink_list)
|
|
|
|
{
|
|
|
|
while(!list_empty(sink_list))
|
|
|
|
{
|
|
|
|
Sink* sink = LIST_ENTRY(sink_list->next, Sink, entry);
|
|
|
|
free_sink(sink);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-07 21:27:29 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* Active Text Service Management
|
|
|
|
*****************************************************************************/
|
2015-11-27 20:39:30 +01:00
|
|
|
static HRESULT activate_given_ts(ActivatedTextService *actsvr, ITfThreadMgrEx *tm)
|
2009-05-07 21:27:29 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
/* Already Active? */
|
|
|
|
if (actsvr->pITfTextInputProcessor)
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
hr = CoCreateInstance (&actsvr->LanguageProfile.clsid, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_ITfTextInputProcessor, (void**)&actsvr->pITfTextInputProcessor);
|
|
|
|
if (FAILED(hr)) return hr;
|
|
|
|
|
2015-11-27 20:39:30 +01:00
|
|
|
hr = ITfTextInputProcessor_Activate(actsvr->pITfTextInputProcessor, (ITfThreadMgr *)tm, actsvr->tid);
|
2009-05-07 21:27:29 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ITfTextInputProcessor_Release(actsvr->pITfTextInputProcessor);
|
|
|
|
actsvr->pITfTextInputProcessor = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2015-11-27 20:39:30 +01:00
|
|
|
actsvr->pITfThreadMgrEx = tm;
|
|
|
|
ITfThreadMgrEx_AddRef(tm);
|
2009-05-07 21:27:29 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT deactivate_given_ts(ActivatedTextService *actsvr)
|
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
if (actsvr->pITfTextInputProcessor)
|
|
|
|
{
|
|
|
|
hr = ITfTextInputProcessor_Deactivate(actsvr->pITfTextInputProcessor);
|
|
|
|
ITfTextInputProcessor_Release(actsvr->pITfTextInputProcessor);
|
2015-11-27 20:39:30 +01:00
|
|
|
ITfThreadMgrEx_Release(actsvr->pITfThreadMgrEx);
|
2009-05-07 21:27:29 +02:00
|
|
|
actsvr->pITfTextInputProcessor = NULL;
|
2015-11-27 20:39:30 +01:00
|
|
|
actsvr->pITfThreadMgrEx = NULL;
|
2009-05-07 21:27:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void deactivate_remove_conflicting_ts(REFCLSID catid)
|
|
|
|
{
|
|
|
|
AtsEntry *ats, *cursor2;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(ats, cursor2, &AtsList, AtsEntry, entry)
|
|
|
|
{
|
|
|
|
if (IsEqualCLSID(catid,&ats->ats->LanguageProfile.catid))
|
|
|
|
{
|
|
|
|
deactivate_given_ts(ats->ats);
|
|
|
|
list_remove(&ats->entry);
|
|
|
|
HeapFree(GetProcessHeap(),0,ats->ats);
|
|
|
|
HeapFree(GetProcessHeap(),0,ats);
|
2016-06-11 13:53:21 +02:00
|
|
|
/* we are guaranteeing there is only 1 */
|
2009-05-07 21:27:29 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT add_active_textservice(TF_LANGUAGEPROFILE *lp)
|
|
|
|
{
|
|
|
|
ActivatedTextService *actsvr;
|
|
|
|
ITfCategoryMgr *catmgr;
|
|
|
|
AtsEntry *entry;
|
2015-11-27 20:39:30 +01:00
|
|
|
ITfThreadMgrEx *tm = TlsGetValue(tlsIndex);
|
2009-05-07 21:27:29 +02:00
|
|
|
ITfClientId *clientid;
|
|
|
|
|
|
|
|
if (!tm) return E_UNEXPECTED;
|
|
|
|
|
|
|
|
actsvr = HeapAlloc(GetProcessHeap(),0,sizeof(ActivatedTextService));
|
|
|
|
if (!actsvr) return E_OUTOFMEMORY;
|
|
|
|
|
2015-11-27 20:39:30 +01:00
|
|
|
ITfThreadMgrEx_QueryInterface(tm, &IID_ITfClientId, (void **)&clientid);
|
2009-05-07 21:27:29 +02:00
|
|
|
ITfClientId_GetClientId(clientid, &lp->clsid, &actsvr->tid);
|
|
|
|
ITfClientId_Release(clientid);
|
|
|
|
|
|
|
|
if (!actsvr->tid)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(),0,actsvr);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
actsvr->pITfTextInputProcessor = NULL;
|
|
|
|
actsvr->LanguageProfile = *lp;
|
2009-05-08 15:50:59 +02:00
|
|
|
actsvr->pITfKeyEventSink = NULL;
|
2009-05-07 21:27:29 +02:00
|
|
|
|
|
|
|
/* get TIP category */
|
|
|
|
if (SUCCEEDED(CategoryMgr_Constructor(NULL,(IUnknown**)&catmgr)))
|
|
|
|
{
|
|
|
|
static const GUID *list[3] = {&GUID_TFCAT_TIP_SPEECH, &GUID_TFCAT_TIP_KEYBOARD, &GUID_TFCAT_TIP_HANDWRITING};
|
|
|
|
|
|
|
|
ITfCategoryMgr_FindClosestCategory(catmgr,
|
|
|
|
&actsvr->LanguageProfile.clsid, &actsvr->LanguageProfile.catid,
|
|
|
|
list, 3);
|
|
|
|
|
|
|
|
ITfCategoryMgr_Release(catmgr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ERR("CategoryMgr construction failed\n");
|
|
|
|
actsvr->LanguageProfile.catid = GUID_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!IsEqualGUID(&actsvr->LanguageProfile.catid,&GUID_NULL))
|
|
|
|
deactivate_remove_conflicting_ts(&actsvr->LanguageProfile.catid);
|
|
|
|
|
2009-05-07 21:28:00 +02:00
|
|
|
if (activated > 0)
|
|
|
|
activate_given_ts(actsvr, tm);
|
|
|
|
|
2009-05-16 21:43:06 +02:00
|
|
|
entry = HeapAlloc(GetProcessHeap(),0,sizeof(AtsEntry));
|
|
|
|
|
|
|
|
if (!entry)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(),0,actsvr);
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2009-05-07 21:27:29 +02:00
|
|
|
entry->ats = actsvr;
|
|
|
|
list_add_head(&AtsList, &entry->entry);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL get_active_textservice(REFCLSID rclsid, TF_LANGUAGEPROFILE *profile)
|
|
|
|
{
|
|
|
|
AtsEntry *ats;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(ats, &AtsList, AtsEntry, entry)
|
|
|
|
{
|
|
|
|
if (IsEqualCLSID(rclsid,&ats->ats->LanguageProfile.clsid))
|
|
|
|
{
|
|
|
|
if (profile)
|
|
|
|
*profile = ats->ats->LanguageProfile;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-11-27 20:39:30 +01:00
|
|
|
HRESULT activate_textservices(ITfThreadMgrEx *tm)
|
2009-05-07 21:27:29 +02:00
|
|
|
{
|
|
|
|
HRESULT hr = S_OK;
|
|
|
|
AtsEntry *ats;
|
|
|
|
|
2009-05-07 21:28:00 +02:00
|
|
|
activated ++;
|
|
|
|
if (activated > 1)
|
|
|
|
return S_OK;
|
|
|
|
|
2009-05-07 21:27:29 +02:00
|
|
|
LIST_FOR_EACH_ENTRY(ats, &AtsList, AtsEntry, entry)
|
|
|
|
{
|
|
|
|
hr = activate_given_ts(ats->ats, tm);
|
|
|
|
if (FAILED(hr))
|
|
|
|
FIXME("Failed to activate text service\n");
|
|
|
|
}
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT deactivate_textservices(void)
|
|
|
|
{
|
|
|
|
AtsEntry *ats;
|
|
|
|
|
2009-05-07 21:28:00 +02:00
|
|
|
if (activated > 0)
|
|
|
|
activated --;
|
|
|
|
|
|
|
|
if (activated == 0)
|
|
|
|
LIST_FOR_EACH_ENTRY(ats, &AtsList, AtsEntry, entry)
|
|
|
|
deactivate_given_ts(ats->ats);
|
2009-05-07 21:27:29 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2009-05-08 15:50:59 +02:00
|
|
|
CLSID get_textservice_clsid(TfClientId tid)
|
|
|
|
{
|
|
|
|
AtsEntry *ats;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(ats, &AtsList, AtsEntry, entry)
|
|
|
|
if (ats->ats->tid == tid)
|
|
|
|
return ats->ats->LanguageProfile.clsid;
|
|
|
|
return GUID_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT get_textservice_sink(TfClientId tid, REFCLSID iid, IUnknown **sink)
|
|
|
|
{
|
|
|
|
AtsEntry *ats;
|
|
|
|
|
|
|
|
if (!IsEqualCLSID(iid,&IID_ITfKeyEventSink))
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(ats, &AtsList, AtsEntry, entry)
|
|
|
|
if (ats->ats->tid == tid)
|
|
|
|
{
|
|
|
|
*sink = (IUnknown*)ats->ats->pITfKeyEventSink;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT set_textservice_sink(TfClientId tid, REFCLSID iid, IUnknown* sink)
|
|
|
|
{
|
|
|
|
AtsEntry *ats;
|
|
|
|
|
|
|
|
if (!IsEqualCLSID(iid,&IID_ITfKeyEventSink))
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
LIST_FOR_EACH_ENTRY(ats, &AtsList, AtsEntry, entry)
|
|
|
|
if (ats->ats->tid == tid)
|
|
|
|
{
|
|
|
|
ats->ats->pITfKeyEventSink = (ITfKeyEventSink*)sink;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2009-01-27 21:15:08 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* MSCTF DllMain
|
|
|
|
*/
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD fdwReason, LPVOID fImpLoad)
|
|
|
|
{
|
|
|
|
TRACE("%p 0x%x %p\n", hinst, fdwReason, fImpLoad);
|
|
|
|
switch (fdwReason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
MSCTF_hinstance = hinst;
|
2009-02-02 17:24:47 +01:00
|
|
|
tlsIndex = TlsAlloc();
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
2013-05-16 12:51:53 +02:00
|
|
|
if (fImpLoad) break;
|
2009-02-02 17:24:47 +01:00
|
|
|
TlsFree(tlsIndex);
|
2009-01-27 21:15:08 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* DllCanUnloadNow (MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllCanUnloadNow(void)
|
|
|
|
{
|
2015-04-02 03:30:48 +02:00
|
|
|
return S_FALSE;
|
2009-01-27 21:15:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllGetClassObject (MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *ppvOut)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
*ppvOut = NULL;
|
|
|
|
if (!IsEqualIID(iid, &IID_IUnknown) && !IsEqualIID(iid, &IID_IClassFactory))
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
|
|
|
|
for (i = 0; ClassesTable[i].clsid != NULL; i++)
|
|
|
|
if (IsEqualCLSID(ClassesTable[i].clsid, clsid)) {
|
|
|
|
return ClassFactory_Constructor(ClassesTable[i].ctor, ppvOut);
|
|
|
|
}
|
|
|
|
FIXME("CLSID %s not supported\n", debugstr_guid(clsid));
|
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
}
|
2009-02-03 21:28:35 +01:00
|
|
|
|
2010-12-08 12:08:29 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* DllRegisterServer (MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllRegisterServer(void)
|
|
|
|
{
|
2011-08-02 15:51:55 +02:00
|
|
|
return __wine_register_resources( MSCTF_hinstance );
|
2010-12-08 12:08:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* DllUnregisterServer (MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI DllUnregisterServer(void)
|
|
|
|
{
|
2011-08-02 15:51:55 +02:00
|
|
|
return __wine_unregister_resources( MSCTF_hinstance );
|
2010-12-08 12:08:29 +01:00
|
|
|
}
|
|
|
|
|
2009-02-03 21:28:35 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* TF_CreateThreadMgr (MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI TF_CreateThreadMgr(ITfThreadMgr **pptim)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
return ThreadMgr_Constructor(NULL,(IUnknown**)pptim);
|
|
|
|
}
|
2009-02-03 21:28:41 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TF_GetThreadMgr (MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
2009-03-05 09:39:10 +01:00
|
|
|
*pptim = TlsGetValue(tlsIndex);
|
2009-02-03 21:28:41 +01:00
|
|
|
|
|
|
|
if (*pptim)
|
|
|
|
ITfThreadMgr_AddRef(*pptim);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-02-05 20:12:55 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetInputScope(MSCTF.@)
|
|
|
|
*/
|
2013-08-05 13:14:50 +02:00
|
|
|
HRESULT WINAPI SetInputScope(HWND hwnd, InputScope inputscope)
|
2009-02-05 20:12:55 +01:00
|
|
|
{
|
|
|
|
FIXME("STUB: %p %i\n",hwnd,inputscope);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-02-05 20:13:02 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetInputScopes(MSCTF.@)
|
|
|
|
*/
|
2013-08-05 13:14:50 +02:00
|
|
|
HRESULT WINAPI SetInputScopes(HWND hwnd, const InputScope *pInputScopes,
|
2009-02-05 20:13:02 +01:00
|
|
|
UINT cInputScopes, WCHAR **ppszPhraseList,
|
|
|
|
UINT cPhrases, WCHAR *pszRegExp, WCHAR *pszSRGS)
|
|
|
|
{
|
2013-02-13 22:06:41 +01:00
|
|
|
UINT i;
|
2009-02-05 20:13:02 +01:00
|
|
|
FIXME("STUB: %p ... %s %s\n",hwnd, debugstr_w(pszRegExp), debugstr_w(pszSRGS));
|
|
|
|
for (i = 0; i < cInputScopes; i++)
|
2013-02-13 22:06:41 +01:00
|
|
|
TRACE("\tScope[%u] = %i\n",i,pInputScopes[i]);
|
2009-02-05 20:13:02 +01:00
|
|
|
for (i = 0; i < cPhrases; i++)
|
2013-02-13 22:06:41 +01:00
|
|
|
TRACE("\tPhrase[%u] = %s\n",i,debugstr_w(ppszPhraseList[i]));
|
2009-02-05 20:13:02 +01:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-06-30 21:46:42 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TF_CreateInputProcessorProfiles(MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI TF_CreateInputProcessorProfiles(
|
|
|
|
ITfInputProcessorProfiles **ppipr)
|
|
|
|
{
|
|
|
|
return InputProcessorProfiles_Constructor(NULL,(IUnknown**)ppipr);
|
|
|
|
}
|
2009-09-08 17:29:56 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TF_InvalidAssemblyListCacheIfExist(MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI TF_InvalidAssemblyListCacheIfExist(void)
|
|
|
|
{
|
|
|
|
FIXME("Stub\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|
2010-02-17 03:31:05 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TF_CreateLangBarMgr (MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI TF_CreateLangBarMgr(ITfLangBarMgr **pppbm)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
return LangBarMgr_Constructor(NULL,(IUnknown**)pppbm);
|
|
|
|
}
|
2013-06-25 10:15:34 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI TF_CreateLangBarItemMgr(ITfLangBarItemMgr **pplbim)
|
|
|
|
{
|
|
|
|
FIXME("stub %p\n", pplbim);
|
|
|
|
*pplbim = NULL;
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2015-02-23 05:42:35 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* TF_InitMlngInfo (MSCTF.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI TF_InitMlngInfo(void)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return S_OK;
|
|
|
|
}
|