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.

139 lines
3.3 KiB

  1. /****************************************************************************
  2. IMCSUB.CPP
  3. Owner: cslim
  4. Copyright (c) 1997-1999 Microsoft Corporation
  5. Subroutines related to HIMC
  6. !!! NEED FULL REVIEW ALL FUNCTIONS NEED TO USE AND WORKS CORRECTLY !!!
  7. History:
  8. 21-JUL-1999 cslim Created(Borrowed almost part from KKIME)
  9. *****************************************************************************/
  10. #include "precomp.h"
  11. #include "imc.h"
  12. #include "imcsub.h"
  13. #include "debug.h"
  14. CIMECtx* GetIMECtx(HIMC hIMC)
  15. {
  16. CIMECtx* pImeCtx;
  17. CIMCPriv ImcPriv;
  18. if (hIMC == (HIMC)0)
  19. return NULL;
  20. if (ImcPriv.LockIMC(hIMC) == fFalse)
  21. {
  22. return NULL;
  23. }
  24. if (ImcPriv->hIMC != hIMC)
  25. {
  26. AST(ImcPriv->hIMC == hIMC);
  27. return NULL;
  28. }
  29. pImeCtx = ImcPriv->pImeCtx;
  30. if (pImeCtx == NULL)
  31. {
  32. AST(pImeCtx != NULL);
  33. return NULL;
  34. }
  35. if (pImeCtx->GetHIMC() != hIMC)
  36. {
  37. AST(pImeCtx->GetHIMC() == hIMC);
  38. return NULL;
  39. }
  40. if (ImcPriv->pIPoint == NULL)
  41. {
  42. AST(ImcPriv->pIPoint != NULL);
  43. return NULL;
  44. }
  45. return pImeCtx;
  46. }
  47. //IImePadInternal* GetImePad( HIMC hIMC )
  48. //{
  49. //
  50. // new : because, IMEPad is per process object
  51. //
  52. //Toshiak
  53. // return GetIImePadInThread();
  54. // hIMC; //no ref;
  55. //}
  56. BOOL CloseInputContext(HIMC hIMC)
  57. {
  58. Dbg(DBGID_API, "CloseInputContext::hiMC == %x .\r\n", hIMC);
  59. if (hIMC)
  60. {
  61. // Because ImeSelect has not been called from IMM on WIN95,
  62. // clean up hIMC private buffer here.
  63. CIMCPriv ImcPriv(hIMC);
  64. IMCPRIVATE* pImcPriv;
  65. pImcPriv = ImcPriv;
  66. if (pImcPriv)
  67. {
  68. Dbg(DBGID_API, "CloseInputContext::ImeSelect has not called yet.\r\n");
  69. // REVIEW:
  70. if (pImcPriv->pIPoint)
  71. {
  72. Dbg(DBGID_API, "CloseInputContext::IPoint Release\r\n");
  73. pImcPriv->pIPoint->Release();
  74. pImcPriv->pIPoint = NULL;
  75. }
  76. pImcPriv->hIMC = (HIMC)0;
  77. }
  78. ImcPriv.ResetPrivateBuffer();
  79. return fFalse;
  80. }
  81. return fTrue;
  82. }
  83. VOID SetPrivateBuffer(HIMC hIMC, VOID* pv, DWORD dwSize)
  84. {
  85. VOID* pvPriv;
  86. DWORD dwCurrentSize;
  87. LPINPUTCONTEXT pCtx;
  88. if (hIMC == NULL)
  89. return;
  90. pCtx = (INPUTCONTEXT*)OurImmLockIMC(hIMC);
  91. if (pCtx == NULL || pCtx->hPrivate == NULL)
  92. return;
  93. dwCurrentSize = OurImmGetIMCCSize(pCtx->hPrivate);
  94. // Check if need to re-allocate
  95. if (dwCurrentSize < dwSize)
  96. {
  97. OurImmUnlockIMCC( pCtx->hPrivate );
  98. pCtx->hPrivate = OurImmReSizeIMCC(pCtx->hPrivate, dwSize);
  99. AST_EX(pCtx->hPrivate != (HIMCC)0);
  100. if (pCtx->hPrivate == (HIMCC)0)
  101. return;
  102. pvPriv = (VOID*)OurImmLockIMCC(pCtx->hPrivate);
  103. }
  104. else
  105. {
  106. // already sized
  107. pvPriv = (VOID*)OurImmLockIMCC(pCtx->hPrivate);
  108. }
  109. if (pvPriv)
  110. CopyMemory(pvPriv, pv, dwSize);
  111. OurImmUnlockIMCC(pCtx->hPrivate);
  112. OurImmUnlockIMC(hIMC);
  113. }