[CTFMON][MSCTFIME][MSCTF][MSUTB][CICERO] Fix TFUninitLib (#6504)

Supporting the Language bar...
JIRA issue: CORE-19363
- Delete TFInitLib and TFUninitLib
  calls from ctfmon.exe.
- Delete TFUninitLib from Cicero
  library.
- Implement InitDisplayAttrbuteLib
  in msctfime.ime.
- Improve CIC_LIBTHREAD structure.
This commit is contained in:
Katayama Hirofumi MZ 2024-02-20 14:36:24 +09:00 committed by GitHub
parent 6f91b6c0fe
commit 6bc40d36f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 87 additions and 25 deletions

View file

@ -194,9 +194,6 @@ InitApp(
g_bOnWow64 = cicIsWow64(); // Is the current process on WoW64?
cicGetOSInfo(&g_uACP, &g_dwOsInfo); // Get OS info
// Initialize Cicero
TFInitLib();
// Create a mutex for Cicero
g_hCicMutex = TF_CreateCicLoadMutex(&g_fWinLogon);
if (!g_hCicMutex)
@ -251,9 +248,6 @@ UninitApp(VOID)
// Close Tipbar Popup
ClosePopupTipbar();
// Release Cicero
TFUninitLib();
// Close the mutex
::CloseHandle(g_hCicMutex);
g_hCicMutex = NULL;

View file

@ -10,12 +10,15 @@
WINE_DEFAULT_DEBUG_CHANNEL(msctfime);
typedef CicArray<GUID> CDispAttrPropCache;
HINSTANCE g_hInst = NULL; /* The instance of this module */
BOOL g_bWinLogon = FALSE;
UINT g_uACP = CP_ACP;
DWORD g_dwOSInfo = 0;
BOOL gfTFInitLib = FALSE;
CRITICAL_SECTION g_csLock;
CDispAttrPropCache *g_pPropCache = NULL;
DEFINE_GUID(GUID_COMPARTMENT_CTFIME_DIMFLAGS, 0xA94C5FD2, 0xC471, 0x4031, 0x95, 0x46, 0x70, 0x9C, 0x17, 0x30, 0x0C, 0xB9);
DEFINE_GUID(GUID_COMPARTMENT_CTFIME_CICINPUTCONTEXT, 0x85A688F7, 0x6DC8, 0x4F17, 0xA8, 0x3A, 0xB1, 0x1C, 0x09, 0xCD, 0xD7, 0xBF);
@ -124,6 +127,33 @@ IsInteractiveUserLogon(VOID)
return bOK && IsMember;
}
/// @implemented
ITfCategoryMgr *GetUIMCat(PCIC_LIBTHREAD pLibThread)
{
if (!pLibThread)
return NULL;
if (pLibThread->m_pCategoryMgr)
return pLibThread->m_pCategoryMgr;
if (FAILED(cicCoCreateInstance(CLSID_TF_CategoryMgr, NULL, CLSCTX_INPROC_SERVER,
IID_ITfCategoryMgr, (void **)&pLibThread->m_pCategoryMgr)))
{
return NULL;
}
return pLibThread->m_pCategoryMgr;
}
/// @implemented
HRESULT LibEnumItemsInCategory(PCIC_LIBTHREAD pLibThread, REFGUID rguid, IEnumGUID **ppEnum)
{
ITfCategoryMgr *pCat = GetUIMCat(pLibThread);
if (!pCat)
return E_FAIL;
return pCat->EnumItemsInCategory(rguid, ppEnum);
}
/// @implemented
HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread)
{
if (!pLibThread)
@ -135,8 +165,37 @@ HRESULT InitDisplayAttrbuteLib(PCIC_LIBTHREAD pLibThread)
pLibThread->m_pDisplayAttrMgr = NULL;
}
//FIXME
return E_NOTIMPL;
if (FAILED(cicCoCreateInstance(CLSID_TF_DisplayAttributeMgr, NULL, CLSCTX_INPROC_SERVER,
IID_ITfDisplayAttributeMgr,
(void **)&pLibThread->m_pDisplayAttrMgr)))
{
return E_FAIL;
}
IEnumGUID *pEnumGuid;
LibEnumItemsInCategory(pLibThread, GUID_TFCAT_DISPLAYATTRIBUTEPROPERTY, &pEnumGuid);
HRESULT hr = E_OUTOFMEMORY;
::EnterCriticalSection(&g_csLock);
if (pEnumGuid && !g_pPropCache)
{
g_pPropCache = new(cicNoThrow) CDispAttrPropCache();
if (g_pPropCache)
{
g_pPropCache->Add(GUID_PROP_ATTRIBUTE);
GUID guid;
while (pEnumGuid->Next(1, &guid, NULL) == S_OK)
{
if (!IsEqualGUID(guid, GUID_PROP_ATTRIBUTE))
g_pPropCache->Add(guid);
}
hr = S_OK;
}
}
::LeaveCriticalSection(&g_csLock);
return hr;
}
HIMC GetActiveContext(VOID)
@ -3646,6 +3705,15 @@ VOID DetachIME(VOID)
UnregisterImeClass();
}
EXTERN_C VOID TFUninitLib(VOID)
{
if (g_pPropCache)
{
delete g_pPropCache;
g_pPropCache = NULL;
}
}
/// @implemented
BOOL ProcessAttach(HINSTANCE hinstDLL)
{
@ -3667,11 +3735,9 @@ BOOL ProcessAttach(HINSTANCE hinstDLL)
return AttachIME();
}
/// @unimplemented
/// @implemented
VOID ProcessDetach(HINSTANCE hinstDLL)
{
// FIXME
TF_DllDetachInOther();
if (gfTFInitLib)

View file

@ -519,6 +519,11 @@ VOID InitCUASFlag(VOID)
}
}
EXTERN_C VOID TFUninitLib(VOID)
{
// Do nothing
}
/**
* @unimplemented
*/

View file

@ -6207,6 +6207,11 @@ BEGIN_OBJECT_MAP(ObjectMap)
#endif
END_OBJECT_MAP()
EXTERN_C VOID TFUninitLib(VOID)
{
// Do nothing
}
/// @implemented
BOOL ProcessAttach(HINSTANCE hinstDLL)
{

View file

@ -254,13 +254,3 @@ TFInitLib(FN_CoCreateInstance fnCoCreateInstance)
_cicGetSetUserCoCreateInstance(fnCoCreateInstance);
return TRUE;
}
/**
* @unimplemented
*/
EXTERN_C
VOID
TFUninitLib(VOID)
{
//FIXME
}

View file

@ -17,10 +17,12 @@ DEFINE_GUID(IID_ITfLangBarMgr_P, 0xD72C0FA9, 0xADD5, 0x4AF0, 0x87,
DEFINE_GUID(IID_ITfLangBarEventSink_P, 0x7A460360, 0xDA21, 0x4B09, 0xA8, 0xA0, 0x8A, 0x69, 0xE7, 0x28, 0xD8, 0x93);
DEFINE_GUID(CLSID_MSUTBDeskBand, 0x540D8A8B, 0x1C3F, 0x4E32, 0x81, 0x32, 0x53, 0x0F, 0x6A, 0x50, 0x20, 0x90);
DEFINE_GUID(CATID_DeskBand, 0x00021492, 0x0000, 0x0000, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46);
DEFINE_GUID(
GUID_TFCAT_DISPLAYATTRIBUTEPROPERTY, 0xB95F181B, 0xEA4C, 0x4AF1, 0x80, 0x56, 0x7C, 0x32, 0x1A, 0xBB, 0xB0, 0x91);
typedef struct CIC_LIBTHREAD
{
IUnknown *m_pUnknown1;
ITfCategoryMgr *m_pCategoryMgr;
ITfDisplayAttributeMgr *m_pDisplayAttrMgr;
} CIC_LIBTHREAD, *PCIC_LIBTHREAD;
@ -44,10 +46,10 @@ inline void TFUninitLib_Thread(PCIC_LIBTHREAD pLibThread)
if (!pLibThread)
return;
if (pLibThread->m_pUnknown1)
if (pLibThread->m_pCategoryMgr)
{
pLibThread->m_pUnknown1->Release();
pLibThread->m_pUnknown1 = NULL;
pLibThread->m_pCategoryMgr->Release();
pLibThread->m_pCategoryMgr = NULL;
}
if (pLibThread->m_pDisplayAttrMgr)
{