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.

155 lines
3.5 KiB

  1. //
  2. // imtls.h
  3. //
  4. #ifndef IMTLS_H
  5. #define IMTLS_H
  6. #include "private.h"
  7. #include "ciccs.h"
  8. #include "imtls.h"
  9. extern DWORD g_dwTLSIndex;
  10. class CActiveIMM;
  11. struct ITfThreadMgr_P;
  12. struct IActiveIMMIME_Private;
  13. struct IAImeProfile;
  14. typedef struct _PENDINGFILTER
  15. {
  16. struct _PENDINGFILTER *pNext;
  17. UINT uSize;
  18. ATOM rgAtoms[1];
  19. } PENDINGFILTER;
  20. typedef struct _PENDINGFILTERGUIDMAP
  21. {
  22. struct _PENDINGFILTERGUIDMAP *pNext;
  23. UINT uSize;
  24. BOOL rgGuidMap[1];
  25. } PENDINGFILTERGUIDMAP;
  26. typedef struct _PENDINGFILTEREX
  27. {
  28. struct _PENDINGFILTEREX *pNext;
  29. HWND hWnd;
  30. BOOL fGuidMap;
  31. } PENDINGFILTEREX;
  32. typedef struct _PrivateUIWndMsg
  33. {
  34. HWND hWnd;
  35. UINT uMsgOnLayoutChange;
  36. UINT uMsgOnClearDocFeedBuffer;
  37. } PrivateUIWndMsg;
  38. typedef struct _IMTLS
  39. {
  40. // dimm
  41. CActiveIMM *pActiveIMM;
  42. PENDINGFILTER *pPendingFilterClientWindows; // IActiveIMMApp::FilterClientWindows
  43. PENDINGFILTERGUIDMAP *pPendingFilterClientWindowsGuidMap; // IActiveIMMAppEx::FilterClientWindows
  44. PENDINGFILTEREX *pPendingFilterClientWindowsEx; // IActiveIMMAppEx::FilterClientWindowsEx
  45. // win32
  46. // consider: perf: this is so lame. We could put almost all of this directly
  47. // into ImmIfIme, the per-thread object, rather using TLS everywhere.
  48. ITfThreadMgr_P *tim;
  49. HIMC hIMC;
  50. IActiveIMMIME_Private *pAImm; // consider: this could be merged with pActiveIMM
  51. IAImeProfile *pAImeProfile;
  52. PrivateUIWndMsg prvUIWndMsg; // consider: is this constant per-process?
  53. BOOL m_fMyPushPop : 1; // TRUE: This is AIMM1.2's Push/Pop call.
  54. } IMTLS;
  55. extern CCicCriticalSectionStatic g_cs;
  56. extern BOOL g_fInLegacyClsid;
  57. extern BOOL g_fTrident55;
  58. extern BOOL g_fAIMM12Trident;
  59. #ifdef DEBUG
  60. extern DWORD g_dwCacheThreadId;
  61. #endif
  62. inline IMTLS *IMTLS_GetOrAlloc()
  63. {
  64. IMTLS *ptls;
  65. ptls = (IMTLS *)TlsGetValue(g_dwTLSIndex);
  66. if (ptls == NULL)
  67. {
  68. if ((ptls = (IMTLS *)cicMemAllocClear(sizeof(IMTLS))) == NULL)
  69. return NULL;
  70. if (!TlsSetValue(g_dwTLSIndex, ptls))
  71. {
  72. cicMemFree(ptls);
  73. return NULL;
  74. }
  75. }
  76. return ptls;
  77. }
  78. inline void IMTLS_Free()
  79. {
  80. PENDINGFILTER *pPending;
  81. PENDINGFILTEREX *pPendingEx;
  82. IMTLS *ptls;
  83. ptls = (IMTLS *)TlsGetValue(g_dwTLSIndex);
  84. if (ptls == NULL)
  85. return;
  86. Assert(ptls->pActiveIMM == NULL);
  87. Assert(ptls->tim == NULL);
  88. Assert(ptls->pAImeProfile == NULL);
  89. while (ptls->pPendingFilterClientWindows != NULL)
  90. {
  91. pPending = ptls->pPendingFilterClientWindows->pNext;
  92. cicMemFree(ptls->pPendingFilterClientWindows);
  93. ptls->pPendingFilterClientWindows = pPending;
  94. }
  95. while (ptls->pPendingFilterClientWindowsEx != NULL)
  96. {
  97. pPendingEx = ptls->pPendingFilterClientWindowsEx->pNext;
  98. cicMemFree(ptls->pPendingFilterClientWindowsEx);
  99. ptls->pPendingFilterClientWindowsEx = pPendingEx;
  100. }
  101. cicMemFree(ptls);
  102. TlsSetValue(g_dwTLSIndex, NULL);
  103. }
  104. inline CActiveIMM *IMTLS_GetActiveIMM()
  105. {
  106. IMTLS *ptls = IMTLS_GetOrAlloc();
  107. if (ptls == NULL)
  108. {
  109. return NULL;
  110. }
  111. return ptls->pActiveIMM;
  112. }
  113. inline BOOL IMTLS_SetActiveIMM(CActiveIMM *pActiveIMM)
  114. {
  115. IMTLS *ptls = IMTLS_GetOrAlloc();
  116. if (ptls == NULL)
  117. return FALSE;
  118. ptls->pActiveIMM = pActiveIMM;
  119. return TRUE;
  120. }
  121. #endif // IMTLS_H