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.

168 lines
4.0 KiB

  1. //
  2. // api.c
  3. //
  4. #include "private.h"
  5. #include "tim.h"
  6. #include "dim.h"
  7. #include "dam.h"
  8. #include "imelist.h"
  9. #include "nuimgr.h"
  10. #include "globals.h"
  11. #include "assembly.h"
  12. #include "timlist.h"
  13. #include "catmgr.h"
  14. extern "C" HRESULT WINAPI TF_GetThreadMgr(ITfThreadMgr **pptim)
  15. {
  16. SYSTHREAD *psfn = GetSYSTHREAD();
  17. if (!psfn)
  18. return E_FAIL;
  19. if (pptim)
  20. {
  21. *pptim = psfn->ptim;
  22. if (*pptim)
  23. (*pptim)->AddRef();
  24. }
  25. return S_OK;
  26. }
  27. extern "C" HRESULT WINAPI TF_CreateThreadMgr(ITfThreadMgr **pptim)
  28. {
  29. return CThreadInputMgr::CreateInstance(NULL, IID_ITfThreadMgr, (void **)pptim);
  30. }
  31. extern "C" HRESULT WINAPI TF_CreateDisplayAttributeMgr(ITfDisplayAttributeMgr **ppdam)
  32. {
  33. return CDisplayAttributeMgr::CreateInstance(NULL, IID_ITfDisplayAttributeMgr, (void **)ppdam);
  34. }
  35. extern "C" HRESULT WINAPI TF_CreateLangBarMgr(ITfLangBarMgr **pplbm)
  36. {
  37. return CLangBarMgr::CreateInstance(NULL, IID_ITfLangBarMgr, (void **)pplbm);
  38. }
  39. extern "C" HRESULT WINAPI TF_CreateInputProcessorProfiles(ITfInputProcessorProfiles **ppipp)
  40. {
  41. return CInputProcessorProfiles::CreateInstance(NULL, IID_ITfInputProcessorProfiles, (void **)ppipp);
  42. }
  43. extern "C" HRESULT WINAPI TF_CreateLangBarItemMgr(ITfLangBarItemMgr **pplbim)
  44. {
  45. return CLangBarItemMgr::CreateInstance(NULL, IID_ITfLangBarItemMgr, (void **)pplbim);
  46. }
  47. extern "C" HRESULT WINAPI TF_InvalidAssemblyListCache()
  48. {
  49. if (!CAssemblyList::InvalidCache())
  50. return E_FAIL;
  51. SYSTHREAD *psfn = GetSYSTHREAD();
  52. if (!psfn)
  53. return E_FAIL;
  54. EnsureAssemblyList(psfn, TRUE);
  55. return S_OK;
  56. }
  57. extern "C" HRESULT WINAPI TF_InvalidAssemblyListCacheIfExist()
  58. {
  59. // the only diff from TF_InvalidAssemblyListCache() is
  60. // that we don't care if cache really exist
  61. //
  62. CAssemblyList::InvalidCache();
  63. SYSTHREAD *psfn = GetSYSTHREAD();
  64. if (!psfn)
  65. return E_FAIL;
  66. EnsureAssemblyList(psfn, TRUE);
  67. return S_OK;
  68. }
  69. extern "C" HRESULT WINAPI TF_PostAllThreadMsg(WPARAM wParam, DWORD dwFlags)
  70. {
  71. ULONG ulNum;
  72. SYSTHREAD *psfn = GetSYSTHREAD();
  73. if (!psfn)
  74. return E_FAIL;
  75. EnsureTIMList(psfn);
  76. ulNum = g_timlist.GetNum();
  77. if (ulNum)
  78. {
  79. DWORD *pdw = new DWORD[ulNum + 1];
  80. if (pdw)
  81. {
  82. if (g_timlist.GetList(pdw,
  83. ulNum+1,
  84. &ulNum,
  85. dwFlags,
  86. TLFlagFromTFPriv(wParam),
  87. TRUE))
  88. {
  89. ULONG ul;
  90. for (ul = 0; ul < ulNum; ul++)
  91. {
  92. if (pdw[ul])
  93. PostThreadMessage(pdw[ul], g_msgPrivate, wParam, 0);
  94. }
  95. }
  96. delete pdw;
  97. }
  98. }
  99. return S_OK;
  100. }
  101. extern "C" HRESULT WINAPI TF_CreateCategoryMgr(ITfCategoryMgr **ppCategoryMgr)
  102. {
  103. return CCategoryMgr::CreateInstance(NULL, IID_ITfCategoryMgr, (void **)ppCategoryMgr);
  104. }
  105. extern "C" BOOL WINAPI TF_IsFullScreenWindowAcitvated()
  106. {
  107. return GetSharedMemory()->fInFullScreen ? TRUE : FALSE;
  108. }
  109. extern "C" HRESULT WINAPI TF_GetGlobalCompartment(ITfCompartmentMgr **ppCompMgr)
  110. {
  111. if (!ppCompMgr)
  112. return E_INVALIDARG;
  113. *ppCompMgr = NULL;
  114. SYSTHREAD *psfn = GetSYSTHREAD();
  115. EnsureGlobalCompartment(psfn);
  116. if (!psfn->_pGlobalCompMgr)
  117. return E_OUTOFMEMORY;
  118. if (EnsureTIMList(psfn))
  119. g_timlist.SetFlags(psfn->dwThreadId, TLF_GCOMPACTIVE);
  120. *ppCompMgr = psfn->_pGlobalCompMgr;
  121. psfn->_pGlobalCompMgr->AddRef();
  122. return S_OK;
  123. }
  124. extern "C" HRESULT WINAPI TF_CUASAppFix(LPCSTR lpCmdLine)
  125. {
  126. if (!lpCmdLine)
  127. return E_INVALIDARG;
  128. if (!lstrcmpi(lpCmdLine, "DelayFirstActivateKeyboardLayout"))
  129. {
  130. g_dwAppCompatibility |= CIC_COMPAT_DELAYFIRSTACTIVATEKBDLAYOUT;
  131. return S_OK;
  132. }
  133. return E_INVALIDARG;
  134. }