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.

289 lines
13 KiB

  1. /****************************************************************************/
  2. /* aoeapi.c */
  3. /* */
  4. /* RDP Order Encoder API functions. */
  5. /* */
  6. /* Copyright(c) Microsoft, PictureTel 1994-1997 */
  7. /* Copyright(c) Microsoft 1997-1999 */
  8. /****************************************************************************/
  9. #include <precomp.h>
  10. #define hdrstop
  11. #define TRC_FILE "aoeapi"
  12. #include <as_conf.hpp>
  13. /****************************************************************************/
  14. /* OE_Init */
  15. /****************************************************************************/
  16. void RDPCALL SHCLASS OE_Init(void)
  17. {
  18. TS_ORDER_CAPABILITYSET OrdersCaps;
  19. DC_BEGIN_FN("OE_Init");
  20. #define DC_INIT_DATA
  21. #include <aoedata.c>
  22. #undef DC_INIT_DATA
  23. /************************************************************************/
  24. /* Fill in our local capabilities structure used for order support. */
  25. /************************************************************************/
  26. /************************************************************************/
  27. /* First fill in the common capabilities structure header. */
  28. /************************************************************************/
  29. OrdersCaps.capabilitySetType = TS_CAPSETTYPE_ORDER;
  30. /************************************************************************/
  31. /* This is a purely diagnostic field in the capabilities. It is not */
  32. /* negotiated, so we can ignore it and set it to zero. */
  33. /************************************************************************/
  34. memset(OrdersCaps.terminalDescriptor, 0, sizeof(OrdersCaps.
  35. terminalDescriptor));
  36. /************************************************************************/
  37. /* Fill in the SaveBitmap capabilities. */
  38. /************************************************************************/
  39. OrdersCaps.pad4octetsA = ((UINT32)SAVE_BITMAP_WIDTH) *
  40. ((UINT32)SAVE_BITMAP_HEIGHT);
  41. OrdersCaps.desktopSaveXGranularity = SAVE_BITMAP_X_GRANULARITY;
  42. OrdersCaps.desktopSaveYGranularity = SAVE_BITMAP_Y_GRANULARITY;
  43. OrdersCaps.pad2octetsA = 0;
  44. /************************************************************************/
  45. // No fonts supported on server. We use glyph caching.
  46. /************************************************************************/
  47. OrdersCaps.numberFonts = (TSUINT16) 0;
  48. /************************************************************************/
  49. /* Fill in encoding capabilities */
  50. /************************************************************************/
  51. OrdersCaps.orderFlags = TS_ORDERFLAGS_NEGOTIATEORDERSUPPORT |
  52. TS_ORDERFLAGS_COLORINDEXSUPPORT;
  53. /************************************************************************/
  54. // Fill in which orders we support.
  55. /************************************************************************/
  56. OrdersCaps.maximumOrderLevel = ORD_LEVEL_1_ORDERS;
  57. memcpy(OrdersCaps.orderSupport, oeLocalOrdersSupported, TS_MAX_ORDERS);
  58. /************************************************************************/
  59. /* Set the text capability flags. */
  60. /************************************************************************/
  61. OrdersCaps.textFlags = TS_TEXTFLAGS_CHECKFONTASPECT |
  62. TS_TEXTFLAGS_USEBASELINESTART |
  63. TS_TEXTFLAGS_CHECKFONTSIGNATURES |
  64. TS_TEXTFLAGS_ALLOWDELTAXSIM |
  65. TS_TEXTFLAGS_ALLOWCELLHEIGHT;
  66. /************************************************************************/
  67. /* Fill in the multiparty fields, using properties if they exist. */
  68. /************************************************************************/
  69. OrdersCaps.pad2octetsB = 0;
  70. OrdersCaps.pad4octetsB = SAVE_BITMAP_WIDTH * SAVE_BITMAP_HEIGHT;
  71. OrdersCaps.desktopSaveSize = SAVE_BITMAP_WIDTH * SAVE_BITMAP_HEIGHT;
  72. TRC_NRM((TB, "SSI recv bitmap size %ld, send size %ld",
  73. OrdersCaps.desktopSaveSize, OrdersCaps.pad4octetsB));
  74. /************************************************************************/
  75. /* This 2.0 implementation supports sending desktop scroll orders. */
  76. /************************************************************************/
  77. // TODO: Do we still need this set?
  78. OrdersCaps.pad2octetsC = TRUE;
  79. // Unused but need to be zeroed.
  80. OrdersCaps.pad2octetsD = 0;
  81. OrdersCaps.textANSICodePage = 0;
  82. OrdersCaps.pad2octetsE = 0;
  83. /************************************************************************/
  84. /* Register the orders capabilties structure with the CPC. */
  85. /************************************************************************/
  86. CPC_RegisterCapabilities((PTS_CAPABILITYHEADER)&OrdersCaps,
  87. sizeof(TS_ORDER_CAPABILITYSET));
  88. DC_END_FN();
  89. }
  90. /****************************************************************************/
  91. /* FUNCTION: OE_PartyLeftShare */
  92. /* */
  93. /* Called when a part has left the share. */
  94. /* */
  95. /* PARAMETERS: */
  96. /* */
  97. /* personID - local ID of person leaving share. */
  98. /* newShareSize - number of people left in share excluding this one. */
  99. /****************************************************************************/
  100. void RDPCALL SHCLASS OE_PartyLeftShare(LOCALPERSONID localID,
  101. unsigned newShareSize)
  102. {
  103. DC_BEGIN_FN("OE_PartyLeftShare");
  104. TRC_NRM((TB, "PARTY %d left", localID));
  105. if (newShareSize > 0) {
  106. OEDetermineOrderSupport();
  107. DCS_TriggerUpdateShmCallback();
  108. }
  109. DC_END_FN();
  110. }
  111. /****************************************************************************/
  112. /* FUNCTION: OE_PartyJoiningShare */
  113. /* */
  114. /* Called when a party is ready to join the share. */
  115. /* */
  116. /* PARAMETERS: */
  117. /* */
  118. /* localID - local ID of person joining share. */
  119. /* oldShareSize - number of people in share excluding this one. */
  120. /* */
  121. /* RETURNS: TRUE if the party is acceptable, FALSE if not. */
  122. /****************************************************************************/
  123. BOOL RDPCALL SHCLASS OE_PartyJoiningShare(LOCALPERSONID localID,
  124. unsigned oldShareSize)
  125. {
  126. BOOL rc;
  127. DC_BEGIN_FN("OE_PartyJoiningShare");
  128. TRC_NRM((TB, "Person %04x joining share, oldShareSize(%d)", localID,
  129. oldShareSize));
  130. if (oldShareSize > 0) {
  131. rc = OEDetermineOrderSupport();
  132. DCS_TriggerUpdateShmCallback();
  133. }
  134. else {
  135. rc = TRUE;
  136. }
  137. DC_END_FN();
  138. return rc;
  139. }
  140. /****************************************************************************/
  141. /* OE_UpdateShm */
  142. /****************************************************************************/
  143. void RDPCALL SHCLASS OE_UpdateShm(void)
  144. {
  145. DC_BEGIN_FN("OE_UpdateShm");
  146. m_pShm->oe.colorIndices = oeColorIndexSupported;
  147. m_pShm->oe.sendSolidPatternBrushOnly = oeSendSolidPatternBrushOnly;
  148. m_pShm->oe.orderSupported = oeOrderSupported;
  149. m_pShm->oe.newCapsData = TRUE;
  150. DC_END_FN();
  151. }
  152. /****************************************************************************/
  153. /* OEDetermineOrderSupport */
  154. /* */
  155. /* Consider the local and remote parties, and determine the group of */
  156. /* common orders that are supported. */
  157. /****************************************************************************/
  158. BOOL RDPCALL SHCLASS OEDetermineOrderSupport(void)
  159. {
  160. BOOL CapsOK;
  161. DC_BEGIN_FN("OEDetermineOrderSupport");
  162. // Set the initial support to the local support.
  163. memcpy(oeOrderSupported, oeLocalOrdersSupported, TS_MAX_ORDERS);
  164. // By default we support sending colors as indices.
  165. oeColorIndexSupported = TRUE;
  166. // We normally support the client.
  167. CapsOK = TRUE;
  168. // Call the enumerate function to get the orders capabilities of the
  169. // remote parties.
  170. CPC_EnumerateCapabilities(TS_CAPSETTYPE_ORDER, (UINT_PTR)&CapsOK,
  171. OEEnumOrdersCaps);
  172. DC_END_FN();
  173. return CapsOK;
  174. }
  175. /****************************************************************************/
  176. /* OEEnumOrdersCaps() */
  177. /* */
  178. /* The callback routine which is called for each remote person, when */
  179. /* building up the common order support record. */
  180. /****************************************************************************/
  181. void RDPCALL SHCLASS OEEnumOrdersCaps(
  182. LOCALPERSONID localID,
  183. UINT_PTR UserData,
  184. PTS_CAPABILITYHEADER pCapabilities)
  185. {
  186. unsigned iOrder;
  187. BOOL *pCapsOK = (BOOL *)UserData;
  188. PTS_ORDER_CAPABILITYSET pOrdersCaps = (PTS_ORDER_CAPABILITYSET)
  189. pCapabilities;
  190. DC_BEGIN_FN("OEEnumOrdersCaps");
  191. // Check the orders in the orders capabilities. Note that
  192. // oeOrderSupported has already been initialized with what we support
  193. // locally, so we simply turn off what is not supported by this
  194. // remote node.
  195. for (iOrder = 0; iOrder < TS_MAX_ORDERS; iOrder++) {
  196. if (!pOrdersCaps->orderSupport[iOrder]) {
  197. /****************************************************************/
  198. /* The order is not supported at the level we want to send out */
  199. /* (currently ORD_LEVEL_1_ORDERS) so set the combined caps to */
  200. /* say not supported. */
  201. /****************************************************************/
  202. oeOrderSupported[iOrder] = FALSE;
  203. }
  204. }
  205. /************************************************************************/
  206. /* Check Order encoding support */
  207. /************************************************************************/
  208. TRC_NRM((TB, "Orders capabilities [%hd]: %hx", localID,
  209. pOrdersCaps->orderFlags));
  210. // OE2 negotiability should always be set by our client.
  211. if (!(pOrdersCaps->orderFlags & TS_ORDERFLAGS_NEGOTIATEORDERSUPPORT)) {
  212. TRC_ERR((TB,"Client does not have OE2 negotiability flag set"));
  213. *pCapsOK = FALSE;
  214. }
  215. // We do not support non-OE2 clients.
  216. if (pOrdersCaps->orderFlags & TS_ORDERFLAGS_CANNOTRECEIVEORDERS) {
  217. TRC_ERR((TB,"Client does not support OE2"));
  218. *pCapsOK = FALSE;
  219. }
  220. // Use of TS_ZERO_BOUNDS_DELTAS flag must be supported, it has been
  221. // present for all clients from RDP 4.0 onward.
  222. if (!(pOrdersCaps->orderFlags & TS_ORDERFLAGS_ZEROBOUNDSDELTASSUPPORT)) {
  223. TRC_ERR((TB, "Client does not support TS_ZERO_BOUNDS_DELTAS"));
  224. *pCapsOK = FALSE;
  225. }
  226. if (pOrdersCaps->orderFlags & TS_ORDERFLAGS_SOLIDPATTERNBRUSHONLY) {
  227. oeSendSolidPatternBrushOnly = TRUE;
  228. TRC_ALT((TB, "Only Solid and Pattern brushes supported"));
  229. }
  230. if (!(pOrdersCaps->orderFlags & TS_ORDERFLAGS_COLORINDEXSUPPORT)) {
  231. TRC_ALT((TB, "Disable Color Index Support"));
  232. oeColorIndexSupported = FALSE;
  233. }
  234. DC_END_FN();
  235. }