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.

241 lines
6.0 KiB

  1. //
  2. // assembly.h
  3. //
  4. #ifndef ASSEMBLY_H
  5. #define ASSEMBLY_H
  6. #include "strary.h"
  7. #include "ptrary.h"
  8. class CAssemblyList;
  9. #define MAX_LANGPROFILENAME 256
  10. typedef struct tag_ASSEMBLYITEM
  11. {
  12. CLSID clsid;
  13. GUID catid;
  14. GUID guidProfile;
  15. CAlignWinHKL hkl;
  16. CAlignWinHKL hklSubstitute;
  17. BOOL fActive : 1;
  18. BOOL fActiveNoCic : 1;
  19. BOOL fEnabled : 1;
  20. BOOL fInitIconIndex : 1;
  21. BOOL fSkipToActivate : 1;
  22. BOOL fSkipToNotify : 1;
  23. BOOL fDisabledOnTransitory : 1;
  24. ULONG uIconIndex;
  25. WCHAR szProfile[MAX_LANGPROFILENAME];
  26. void InitIconIndex()
  27. {
  28. uIconIndex = (ULONG)(-1);
  29. fInitIconIndex = FALSE;
  30. }
  31. BOOL IsEqual(tag_ASSEMBLYITEM *pItem)
  32. {
  33. return IsEqual(pItem->hkl, pItem->clsid, pItem->guidProfile);
  34. }
  35. BOOL IsEqual(HKL hklIn, REFCLSID rclsidIn, REFGUID rguidProfileIn)
  36. {
  37. if ((hkl == hklIn) &&
  38. IsEqualGUID(clsid, rclsidIn) &&
  39. IsEqualGUID(guidProfile, rguidProfileIn))
  40. return TRUE;
  41. return FALSE;
  42. }
  43. static size_t GetAlignSize() { return Align(sizeof(struct tag_ASSEMBLYITEM)); }
  44. } ASSEMBLYITEM;
  45. //////////////////////////////////////////////////////////////////////////////
  46. //
  47. // CAssembly
  48. //
  49. //////////////////////////////////////////////////////////////////////////////
  50. class CAssembly
  51. {
  52. public:
  53. CAssembly(const TCHAR *pszName);
  54. CAssembly(LANGID langid);
  55. ~CAssembly();
  56. BOOL IsEnabled(SYSTHREAD *psfn);
  57. BOOL IsNonCiceroItem();
  58. BOOL IsEnabledKeyboardItem(SYSTHREAD *psfn);
  59. WCHAR *GetLangName() {return _szLangName;}
  60. LANGID GetLangId() {return _langid;}
  61. int Count() {return _rgAsmItem.Count();}
  62. ASSEMBLYITEM *GetItem(int nId)
  63. {
  64. return _rgAsmItem.GetPtr(nId);
  65. }
  66. BOOL IsFEIMEActive();
  67. void RebuildSubstitutedHKLList();
  68. BOOL IsSubstitutedHKL(HKL hkl);
  69. void ClearSubstitutedHKLList()
  70. {
  71. _rghklSubstituted.Clear();
  72. }
  73. ASSEMBLYITEM *GetSubstituteItem(HKL hKL);
  74. ASSEMBLYITEM *FindActiveKeyboardItem();
  75. ASSEMBLYITEM *FindKeyboardLayoutItem(HKL hkl);
  76. #ifdef CHECKFEIMESELECTED
  77. BOOL _fUnknownFEIMESelected;
  78. #endif
  79. private:
  80. friend CAssemblyList;
  81. ASSEMBLYITEM *FindItemByCategory(REFGUID catid);
  82. ASSEMBLYITEM *FindPureKbdTipItem();
  83. BOOL IsEnabledItemByCategory(REFGUID catid);
  84. BOOL IsEnabledItem();
  85. int Find(ASSEMBLYITEM *pItem)
  86. {
  87. ASSEMBLYITEM *pItemTmp;
  88. int nCnt = _rgAsmItem.Count();
  89. int i;
  90. for (i = 0; i < nCnt; i++)
  91. {
  92. pItemTmp = _rgAsmItem.GetPtr(i);
  93. if (pItemTmp->IsEqual(pItem))
  94. return i;
  95. }
  96. return -1;
  97. }
  98. void Add(ASSEMBLYITEM *pItem)
  99. {
  100. ASSEMBLYITEM *pItemTmp;
  101. if (Find(pItem) >= 0)
  102. return;
  103. pItemTmp = _rgAsmItem.Append(1);
  104. if (pItemTmp)
  105. *pItemTmp = *pItem;
  106. }
  107. void Remove(ASSEMBLYITEM *pItem)
  108. {
  109. int nId = Find(pItem);
  110. if (nId >= 0)
  111. {
  112. _rgAsmItem.Remove(nId, 1);
  113. }
  114. }
  115. LANGID _langid;
  116. WCHAR _szLangName[64];
  117. CStructArray<ASSEMBLYITEM> _rgAsmItem;
  118. CStructArray<HKL> _rghklSubstituted;
  119. };
  120. //////////////////////////////////////////////////////////////////////////////
  121. //
  122. // CAssemblyList
  123. //
  124. //////////////////////////////////////////////////////////////////////////////
  125. class CAssemblyList
  126. {
  127. public:
  128. CAssemblyList();
  129. ~CAssemblyList();
  130. void ClearAsms();
  131. HRESULT Load();
  132. CAssembly *GetDefaultAssembly();
  133. void AttachOriginalAssembly(CPtrArray<CAssembly> *prgAsmOrg);
  134. int Count() {return _rgAsm.Count();}
  135. CAssembly *GetAssembly(int nId)
  136. {
  137. return _rgAsm.Get(nId);
  138. }
  139. CAssembly *FindAssemblyByLangId(LANGID langid)
  140. {
  141. return FindAssemblyByLangIdInArray(&_rgAsm, langid);
  142. }
  143. static CAssembly *FindAssemblyByLangIdInArray(CPtrArray<CAssembly> *rgAsm, LANGID langid)
  144. {
  145. int nCnt = rgAsm->Count();
  146. int i;
  147. for (i = 0; i < nCnt; i++)
  148. {
  149. CAssembly *pAsm = rgAsm->Get(i);
  150. if (pAsm->_langid == langid)
  151. return pAsm;
  152. }
  153. return NULL;
  154. }
  155. BOOL LoadFromCache();
  156. BOOL SetDefaultTIPInAssemblyInternal(CAssembly *pAsm, ASSEMBLYITEM *pItem, BOOL fChangeDefault);
  157. static BOOL SetDefaultTIPInAssemblyForCache(LANGID langid, REFGUID catid, REFCLSID clsid, HKL hKL, REFGUID guidProfile);
  158. static BOOL InvalidCache();
  159. #ifdef PROFILE_UPDATE_REGISTRY // old code for tip setup.
  160. static BOOL IsUpdated();
  161. static BOOL ClearUpdatedFlag();
  162. #endif
  163. static BOOL GetDefaultTIPInAssembly(LANGID langid, REFGUID catid, CLSID *pclsid, HKL* phKL, GUID *pguidProfile);
  164. static BOOL SetDefaultTIPInAssembly(LANGID langid, REFGUID catid, REFCLSID clsid, HKL hKL, REFGUID guidProfile);
  165. static BOOL IsFEDummyKL(HKL hkl);
  166. static HKL GetProperHKL(LANGID langid, HKL *lphkl, BOOL *pfLoaded);
  167. static BOOL CheckLangSupport(REFCLSID rclsid, LANGID langid);
  168. private:
  169. BOOL CreateCache();
  170. static BOOL GetTIPCategory(REFCLSID clsid, GUID *pcatid, IEnumGUID *pEnumCat);
  171. CPtrArray<CAssembly> _rgAsm;
  172. static CAssembly *FindAndCreateNewAssembly(CPtrArray<CAssembly> *prgAsm, CPtrArray<CAssembly> *prgNutralAsm, LANGID langid);
  173. };
  174. inline BOOL IsIMEHKL(HKL hkl)
  175. {
  176. return ((((DWORD)(LONG_PTR)hkl) & 0xf0000000) == 0xe0000000) ? TRUE : FALSE;
  177. }
  178. inline BOOL IsFELangId(LANGID langid)
  179. {
  180. if ((langid == 0x411) ||
  181. (langid == 0x404) ||
  182. (langid == 0x412) ||
  183. (langid == 0x804))
  184. {
  185. return TRUE;
  186. }
  187. return FALSE;
  188. }
  189. inline BOOL IsPureIMEHKL(HKL hkl)
  190. {
  191. if (!IsIMEHKL(hkl))
  192. return FALSE;
  193. return CAssemblyList::IsFEDummyKL(hkl) ? FALSE : TRUE;
  194. }
  195. BOOL EnsureAsmCacheFileMap();
  196. BOOL UninitAsmCacheFileMap();
  197. BOOL IsAsmCache();
  198. #endif // ASSEMBLY_H