Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
6.1 KiB

  1. /*++
  2. Copyright (c) 2001, Microsoft Corporation
  3. Module Name:
  4. cic.h
  5. Abstract:
  6. This file defines the CicBridge Interface Class.
  7. Author:
  8. Revision History:
  9. Notes:
  10. --*/
  11. #ifndef _CIC_H_
  12. #define _CIC_H_
  13. #include "tls.h"
  14. #include "template.h"
  15. #include "imc.h"
  16. #include "context.h"
  17. #include "tmgrevcb.h"
  18. class CicBridge : public ITfSysHookSink
  19. {
  20. public:
  21. CicBridge()
  22. {
  23. m_pkm_P = NULL;
  24. m_dimEmpty = NULL;
  25. m_pDIMCallback = NULL;
  26. m_tfClientId = TF_CLIENTID_NULL;
  27. m_ref = 1;
  28. }
  29. virtual ~CicBridge()
  30. {
  31. TLS* ptls = TLS::ReferenceTLS(); // Should not allocate TLS. ie. TLS::GetTLS
  32. // DllMain -> TLS::InternalDestroy -> CicBridge::Release
  33. if (ptls != NULL)
  34. {
  35. ITfThreadMgr_P* ptim_P = ptls->GetTIM();
  36. if (ptim_P != NULL)
  37. {
  38. HRESULT hr = DeactivateIMMX(ptls, ptim_P);
  39. if (SUCCEEDED(hr))
  40. {
  41. UnInitIMMX(ptls);
  42. }
  43. }
  44. }
  45. }
  46. //
  47. // IUnknown methods
  48. //
  49. public:
  50. STDMETHODIMP QueryInterface(REFIID riid, void **ppvObj);
  51. STDMETHODIMP_(ULONG) AddRef(void);
  52. STDMETHODIMP_(ULONG) Release(void);
  53. //
  54. // ITfSysHookSink methods
  55. //
  56. STDMETHODIMP OnPreFocusDIM(HWND hWnd);
  57. STDMETHODIMP OnSysKeyboardProc(WPARAM wParam, LPARAM lParam);
  58. STDMETHODIMP OnSysShellProc(int nCode, WPARAM wParam, LPARAM lParam);
  59. public:
  60. HRESULT InitIMMX(TLS* ptls);
  61. BOOL UnInitIMMX(TLS* ptls);
  62. HRESULT ActivateIMMX(TLS *ptls, ITfThreadMgr_P* ptim_P);
  63. HRESULT DeactivateIMMX(TLS *ptls, ITfThreadMgr_P* ptim_P);
  64. HRESULT CreateInputContext(TLS* ptls, HIMC hImc);
  65. HRESULT DestroyInputContext(TLS* ptls, HIMC hImc);
  66. HRESULT SelectEx(TLS* ptls, ITfThreadMgr_P* ptim_P, HIMC hImc, BOOL fSelect, HKL hKL);
  67. HRESULT SetActiveContextAlways(TLS* ptls, HIMC hImc, BOOL fOn, HWND hWnd, HKL hKL);
  68. BOOL ProcessKey(TLS* ptls, ITfThreadMgr_P* ptim_P, HIMC hIMC, UINT uVirtKey, LPARAM lParam, CONST LPBYTE lpbKeyState);
  69. HRESULT ToAsciiEx(TLS* ptls, ITfThreadMgr_P* ptim_P, UINT uVirtKey, UINT uScanCode, CONST LPBYTE lpbKeyState, LPTRANSMSGLIST lpTransBuf, UINT fuState, HIMC hIMC, UINT *uNum);
  70. BOOL ProcessCicHotkey(TLS* ptls, ITfThreadMgr_P* ptim_P, HIMC hIMC, UINT uVirtKey, LPARAM lParam);
  71. HRESULT Notify(TLS* ptls, ITfThreadMgr_P* ptls_P, HIMC hIMC, DWORD dwAction, DWORD dwIndex, DWORD dwValue);
  72. HRESULT ConfigureGeneral(TLS* ptls, ITfThreadMgr_P* ptim_P, HKL hKL, HWND hAppWnd);
  73. HRESULT ConfigureRegisterWord(TLS* ptls, ITfThreadMgr_P* ptim_P, HKL hKL, HWND hAppWnd, REGISTERWORDW* pRegisterWord);
  74. LRESULT EscapeKorean(TLS* ptls, HIMC hImc, UINT uSubFunc, LPVOID lpData);
  75. BOOL SetCompositionString(TLS* ptls, ITfThreadMgr_P* ptim_P, HIMC hImc, DWORD dwIndex, void* pComp, DWORD dwCompLen, void* pRead, DWORD dwReadLen);
  76. HRESULT GetGuidAtom(TLS* ptls, HIMC hImc, BYTE bAttr, TfGuidAtom* atom);
  77. HRESULT GetDisplayAttributeInfo(TfGuidAtom atom, TF_DISPLAYATTRIBUTE* da);
  78. private:
  79. TfClientId _GetClientId()
  80. {
  81. return m_tfClientId;
  82. }
  83. LIBTHREAD* _GetLibTLS()
  84. {
  85. return &_libTLS;
  86. }
  87. Interface_Attach<ITfContext> GetInputContext(IMCCLock<CTFIMECONTEXT>& imc_ctfime) const
  88. {
  89. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  90. if (!_pCicContext)
  91. return NULL;
  92. Interface_Attach<ITfContext> ic(_pCicContext->GetInputContext());
  93. return ic;
  94. }
  95. Interface_Attach<ITfDocumentMgr> GetDocumentManager(IMCCLock<CTFIMECONTEXT>& imc_ctfime) const
  96. {
  97. CicInputContext* _pCicContext = imc_ctfime->m_pCicContext;
  98. if (!_pCicContext)
  99. return NULL;
  100. Interface_Attach<ITfDocumentMgr> dim(_pCicContext->GetDocumentManager());
  101. return dim;
  102. }
  103. public:
  104. Interface_Attach<ITfDocumentMgr> GetEmptyDIM() const
  105. {
  106. Interface_Attach<ITfDocumentMgr> dim(m_dimEmpty);
  107. return dim;
  108. }
  109. static BOOL IsOwnDim(ITfDocumentMgr *pdim);
  110. static BOOL CTFDetection(TLS* ptls, ITfDocumentMgr* dim);
  111. private:
  112. struct ENUMIMC
  113. {
  114. TLS *ptls;
  115. CicBridge *_this;
  116. };
  117. static BOOL EnumCreateInputContextCallback(HIMC hIMC, LPARAM lParam);
  118. static BOOL EnumDestroyInputContextCallback(HIMC hIMC, LPARAM lParam);
  119. BOOL IsDefaultIMCDim(ITfDocumentMgr *pdim);
  120. VOID SetAssociate(TLS* ptls, HWND hWnd, ITfThreadMgr_P* ptim_P, ITfDocumentMgr* pdim);
  121. HRESULT OnSetOpenStatus(ITfThreadMgr_P* ptim_P, IMCLock& imc, CicInputContext& CicContext);
  122. HRESULT OnSetConversionSentenceMode(ITfThreadMgr_P* ptim_P, IMCLock& imc, CicInputContext& CicContext, DWORD dwValue, LANGID langid);
  123. HRESULT OnSetKorImxConversionMode(ITfThreadMgr_P* ptim_P, IMCLock& imc, CicInputContext& CicContext);
  124. LRESULT EscHanjaMode(TLS* ptls, HIMC hImc, LPWSTR lpwStr);
  125. LRESULT DoOpenCandidateHanja(ITfThreadMgr_P* ptim_P, IMCLock& imc, CicInputContext& CicContext);
  126. BOOL DefaultKeyHandling(TLS* ptls, IMCLock& imc, CicInputContext* CicContext, UINT uVirtKey, LPARAM lParam);
  127. VOID PostTransMsg(HWND hwnd, INT iNum, LPTRANSMSG lpTransMsg);
  128. //
  129. // ref count.
  130. //
  131. private:
  132. long m_ref;
  133. private:
  134. CBoolean m_fCicInit;
  135. CBoolean m_fOnSetAssociate;
  136. CBoolean m_fInDeactivate;
  137. LONG m_lCicActive;
  138. ITfKeystrokeMgr_P *m_pkm_P;
  139. ITfDocumentMgr *m_dimEmpty; // empty dim for NULL hIMC.
  140. CThreadMgrEventSink_DIMCallBack *m_pDIMCallback; // Thread manager event sink callback for DIM
  141. TfClientId m_tfClientId;
  142. LIBTHREAD _libTLS; // tls for the helper library. Since this object is apt threaded,
  143. // all members are accessed in a single thread
  144. // also, cicero will only create a single instance of this obj per thread
  145. };
  146. #endif // _CIC_H_