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.

166 lines
6.3 KiB

  1. /**MOD+**********************************************************************/
  2. /* Module: fsapi.cpp */
  3. /* */
  4. /* Purpose: Font Sender API functions */
  5. /* */
  6. /* Copyright(C) Microsoft Corporation 1997 */
  7. /* */
  8. /****************************************************************************/
  9. #include <adcg.h>
  10. extern "C" {
  11. #define TRC_GROUP TRC_GROUP_CORE
  12. #define TRC_FILE "afsapi"
  13. #include <atrcapi.h>
  14. }
  15. #include "autil.h"
  16. #include "wui.h"
  17. #include "cd.h"
  18. #include "fs.h"
  19. #include "sl.h"
  20. CFS::CFS(CObjs* objs)
  21. {
  22. _pClientObjects = objs;
  23. }
  24. CFS::~CFS()
  25. {
  26. }
  27. /****************************************************************************/
  28. // FS_Init
  29. //
  30. // Initialize Font Sender
  31. /****************************************************************************/
  32. VOID DCAPI CFS::FS_Init(VOID)
  33. {
  34. DC_BEGIN_FN("FS_Init");
  35. _pSl = _pClientObjects->_pSlObject;
  36. _pUt = _pClientObjects->_pUtObject;
  37. _pUi = _pClientObjects->_pUiObject;
  38. /************************************************************************/
  39. /* Initialize FS data */
  40. /************************************************************************/
  41. TRC_DBG((TB, _T("FS Initialize")));
  42. _FS.sentFontPDU = FALSE;
  43. DC_END_FN();
  44. } /* FS_Init */
  45. /****************************************************************************/
  46. // FS_Term
  47. //
  48. // This is an empty function since we don't enumerate fonts anymore. We
  49. // use glyphs instead of fonts for text display. We still keep FS_Term
  50. // is to have a symmetric function with FS_Init
  51. /****************************************************************************/
  52. VOID DCAPI CFS::FS_Term(VOID)
  53. {
  54. DC_BEGIN_FN("FS_Term");
  55. TRC_DBG((TB, _T("Empty FS_Term")));
  56. DC_END_FN();
  57. } /* FS_Term */
  58. /****************************************************************************/
  59. // FS_Enable
  60. //
  61. // This is an empty function since we don't enumerate fonts anymore. We
  62. // use glyphs instead of fonts for text display. We still keep FS_Enable
  63. // is to have a symmetric function with FS_Disable
  64. /****************************************************************************/
  65. VOID DCAPI CFS::FS_Enable(VOID)
  66. {
  67. DC_BEGIN_FN("FS_Enable");
  68. TRC_DBG((TB, _T("Empty FS_Enable")));
  69. DC_END_FN();
  70. } /* FS_Enable */
  71. /****************************************************************************/
  72. // FS_Disable
  73. //
  74. // Disable _FS.
  75. /****************************************************************************/
  76. VOID DCAPI CFS::FS_Disable(VOID)
  77. {
  78. DC_BEGIN_FN("FS_Disable");
  79. TRC_NRM((TB, _T("Disabled")));
  80. // reset sentFontPDU flag
  81. _FS.sentFontPDU = FALSE;
  82. DC_END_FN();
  83. } /* FS_Disable */
  84. /****************************************************************************/
  85. // FS_SendZeroFontList
  86. //
  87. // Attempts to send an empty FontList PDU. The zero-font packet maintains
  88. // backward compatibility with RDP 4.0 servers where RDPWD waits on the
  89. // font list packet to arrive before allowing the session to continue.
  90. // Font support is otherwise not required, so we can send zero fonts.
  91. /****************************************************************************/
  92. DCVOID DCAPI CFS::FS_SendZeroFontList(DCUINT unusedParm)
  93. {
  94. unsigned short PktLen;
  95. SL_BUFHND hBuffer;
  96. PTS_FONT_LIST_PDU pFontListPDU;
  97. DC_BEGIN_FN("FS_SendFontList");
  98. DC_IGNORE_PARAMETER(unusedParm);
  99. // Only send font PDU if we haven't already done so
  100. if (!_FS.sentFontPDU) {
  101. PktLen = sizeof(TS_FONT_LIST_PDU) - sizeof(TS_FONT_ATTRIBUTE);
  102. if (_pSl->SL_GetBuffer(PktLen, (PPDCUINT8)&pFontListPDU, &hBuffer)) {
  103. TRC_NRM((TB, _T("Successfully alloc'd font list packet")));
  104. pFontListPDU->shareDataHeader.shareControlHeader.pduType =
  105. TS_PDUTYPE_DATAPDU | TS_PROTOCOL_VERSION;
  106. pFontListPDU->shareDataHeader.shareControlHeader.totalLength = PktLen;
  107. pFontListPDU->shareDataHeader.shareControlHeader.pduSource =
  108. _pUi->UI_GetClientMCSID();
  109. pFontListPDU->shareDataHeader.shareID = _pUi->UI_GetShareID();
  110. pFontListPDU->shareDataHeader.pad1 = 0;
  111. pFontListPDU->shareDataHeader.streamID = TS_STREAM_LOW;
  112. pFontListPDU->shareDataHeader.pduType2 = TS_PDUTYPE2_FONTLIST;
  113. pFontListPDU->shareDataHeader.generalCompressedType = 0;
  114. pFontListPDU->shareDataHeader.generalCompressedLength = 0;
  115. pFontListPDU->numberFonts = 0;
  116. pFontListPDU->totalNumFonts = 0;
  117. pFontListPDU->listFlags = TS_FONTLIST_FIRST | TS_FONTLIST_LAST;
  118. pFontListPDU->entrySize = sizeof(TS_FONT_ATTRIBUTE);
  119. TRC_NRM((TB, _T("Send zero length font list")));
  120. _pSl->SL_SendPacket((PDCUINT8)pFontListPDU, PktLen, RNS_SEC_ENCRYPT,
  121. hBuffer, _pUi->UI_GetClientMCSID(), _pUi->UI_GetChannelID(),
  122. TS_MEDPRIORITY);
  123. _FS.sentFontPDU = TRUE;
  124. }
  125. else {
  126. // If we fail to allocate a buffer then we will try again when we get
  127. // an UH_OnBufferAvailable() on WinSock FD_WRITE.
  128. TRC_ALT((TB, _T("Failed to alloc font list packet")));
  129. pFontListPDU = NULL;
  130. }
  131. }
  132. DC_END_FN();
  133. } /* FS_SendZeroFontList */