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.

282 lines
13 KiB

  1. /****************************************************************************/
  2. /* assiapi.cpp */
  3. /* */
  4. /* SaveScreenBits Interceptor API functions. */
  5. /* */
  6. /* Copyright(c) Microsoft, PictureTel 1992-1996 */
  7. /* Copyright(c) Data Connection 1996 */
  8. /* (C) 1997-1998 Microsoft Corp. */
  9. /****************************************************************************/
  10. #include <precomp.h>
  11. #pragma hdrstop
  12. #define TRC_FILE "assiapi"
  13. #include <as_conf.hpp>
  14. /****************************************************************************/
  15. /* SSI_Init(..) */
  16. /****************************************************************************/
  17. void RDPCALL SHCLASS SSI_Init(void)
  18. {
  19. DC_BEGIN_FN("SSI_Init");
  20. #define DC_INIT_DATA
  21. #include <assidata.c>
  22. #undef DC_INIT_DATA
  23. TRC_DBG((TB, "Initializing SSI"));
  24. DC_END_FN();
  25. }
  26. /****************************************************************************/
  27. /* API FUNCTION: SSI_PartyJoiningShare */
  28. /* */
  29. /* Called when a new party is joining the share. */
  30. /* */
  31. /* PARAMETERS: */
  32. /* */
  33. /* locPersonID - local person ID of remote person joining the share. */
  34. /* */
  35. /* oldShareSize - the number of the parties which were in the share (ie */
  36. /* excludes the joining party). */
  37. /* */
  38. /* RETURNS: TRUE if the party can join the share. */
  39. /* FALSE if the party can NOT join the share. */
  40. /****************************************************************************/
  41. BOOL RDPCALL SHCLASS SSI_PartyJoiningShare(LOCALPERSONID locPersonID,
  42. unsigned oldShareSize)
  43. {
  44. PTS_ORDER_CAPABILITYSET pLocalOrderCaps;
  45. DC_BEGIN_FN("SSI_PartyJoiningShare");
  46. DC_IGNORE_PARAMETER(oldShareSize)
  47. /************************************************************************/
  48. /* If this is the first party in the share, reset the interceptor code. */
  49. /************************************************************************/
  50. if (oldShareSize == 0)
  51. {
  52. SSIResetInterceptor();
  53. }
  54. /************************************************************************/
  55. /* Redetermine the size of the save screen bitmap. */
  56. /************************************************************************/
  57. SSIRedetermineSaveBitmapSize();
  58. TRC_DBG((TB, "Person with network ID %d joining share", locPersonID));
  59. SSICapabilitiesChanged();
  60. DC_END_FN();
  61. return(TRUE);
  62. }
  63. /****************************************************************************/
  64. /* API FUNCTION: SSI_PartyLeftShare() */
  65. /* */
  66. /* SSI function called when a party has left the share. */
  67. /* */
  68. /* PARAMETERS: */
  69. /* */
  70. /* locPersonID - local person ID of remote person leaving the share. */
  71. /* */
  72. /* newShareSize - the number of the parties now in the call (ie excludes */
  73. /* the leaving party). */
  74. /****************************************************************************/
  75. void RDPCALL SHCLASS SSI_PartyLeftShare(LOCALPERSONID locPersonID,
  76. unsigned newShareSize)
  77. {
  78. DC_BEGIN_FN("SSI_PartyLeftShare");
  79. DC_IGNORE_PARAMETER(locPersonID)
  80. /************************************************************************/
  81. /* Redetermine the size of the save screen bitmap. */
  82. /************************************************************************/
  83. SSIRedetermineSaveBitmapSize();
  84. /************************************************************************/
  85. /* If this is the last party in the share, free all resources for the */
  86. /* call. */
  87. /************************************************************************/
  88. if (newShareSize == 0)
  89. {
  90. /********************************************************************/
  91. /* Discard all saved bitmaps. */
  92. /********************************************************************/
  93. SSIResetInterceptor();
  94. }
  95. else
  96. {
  97. /********************************************************************/
  98. /* Deal with new capabilities. */
  99. /********************************************************************/
  100. SSICapabilitiesChanged();
  101. }
  102. TRC_DBG((TB, "Person with network ID %d leaving share", locPersonID));
  103. DC_END_FN();
  104. }
  105. /****************************************************************************/
  106. /* FUNCTION: SSI_SyncUpdatesNow */
  107. /* */
  108. /* Called by the USR to start syncing data to the remote parties. */
  109. /* The datastream subsequently sent by the SSI must not refer to any */
  110. /* previously sent. */
  111. /****************************************************************************/
  112. void RDPCALL SHCLASS SSI_SyncUpdatesNow(void)
  113. {
  114. DC_BEGIN_FN("SSI_SyncUpdatesNow");
  115. /************************************************************************/
  116. /* Discard any saved bitmaps. This ensures that the subsequent */
  117. /* datastream will not refer to any previously sent data. */
  118. /************************************************************************/
  119. SSIResetInterceptor();
  120. DC_END_FN();
  121. }
  122. /****************************************************************************/
  123. /* FUNCTION: SSI_UpdateShm */
  124. /* */
  125. /* Updates the Shared Memory with local values. Called on WinStation */
  126. /* context. */
  127. /****************************************************************************/
  128. void RDPCALL SHCLASS SSI_UpdateShm(void)
  129. {
  130. DC_BEGIN_FN("SSI_UpdateShm");
  131. m_pShm->ssi.resetInterceptor =
  132. (m_pShm->ssi.resetInterceptor || ssiResetInterceptor);
  133. ssiResetInterceptor = FALSE;
  134. m_pShm->ssi.newSaveBitmapSize = ssiNewSaveBitmapSize;
  135. m_pShm->ssi.saveBitmapSizeChanged =
  136. (m_pShm->ssi.saveBitmapSizeChanged || ssiSaveBitmapSizeChanged);
  137. ssiSaveBitmapSizeChanged = FALSE;
  138. TRC_NRM((TB, "resetInterceptor(%u) newSaveBitmapSize(%u)"
  139. " saveBitmapSizeChanged(%u)",
  140. m_pShm->ssi.resetInterceptor,
  141. m_pShm->ssi.newSaveBitmapSize,
  142. m_pShm->ssi.saveBitmapSizeChanged ));
  143. DC_END_FN();
  144. }
  145. /****************************************************************************/
  146. /* FUNCTION: SSIEnumBitmapCacheCaps() */
  147. /* */
  148. /* Function passed to CPC_EnumerateCapabilities. It will be called with a */
  149. /* capability structure for each person in the call corresponding to the */
  150. /* TS_CAPSETTYPE_ORDER capability structure. */
  151. /* */
  152. /* PARAMETERS: */
  153. /* */
  154. /* personID - ID of person with these capabilities. */
  155. /* */
  156. /* pProtCaps - pointer to capabilities structure for this person. This */
  157. /* pointer is only valid within the call to this function. */
  158. /****************************************************************************/
  159. void RDPCALL SHCLASS SSIEnumBitmapCacheCaps(
  160. LOCALPERSONID personID,
  161. UINT_PTR UserData,
  162. PTS_CAPABILITYHEADER pCaps)
  163. {
  164. PTS_ORDER_CAPABILITYSET pOrderCaps;
  165. DC_BEGIN_FN("SSIEnumBitmapCacheCaps");
  166. DC_IGNORE_PARAMETER(UserData);
  167. pOrderCaps = (PTS_ORDER_CAPABILITYSET)pCaps;
  168. TRC_NRM((TB, "[%u]Receiver bitmap size %ld", (unsigned)personID,
  169. pOrderCaps->desktopSaveSize));
  170. /************************************************************************/
  171. /* Set the size of the local send save screen bitmap to the minimum of */
  172. /* its current size and this party's receive save screen bitmap size. */
  173. /************************************************************************/
  174. ssiNewSaveBitmapSize = min(ssiNewSaveBitmapSize,
  175. pOrderCaps->desktopSaveSize);
  176. DC_END_FN();
  177. }
  178. /****************************************************************************/
  179. /* FUNCTION: SSIRedetermineSaveBitmapSize */
  180. /* */
  181. /* Enumerates all the people in the share and redetermines the size of the */
  182. /* save screen bitmap depending on their and the local receive */
  183. /* capabilities. */
  184. /****************************************************************************/
  185. void RDPCALL SHCLASS SSIRedetermineSaveBitmapSize(void)
  186. {
  187. PTS_ORDER_CAPABILITYSET pOrderCaps;
  188. DC_BEGIN_FN("SSIRedetermineSaveBitmapSize");
  189. /************************************************************************/
  190. /* Enumerate all the save screen bitmap receive capabilities of the */
  191. /* parties in the share. The usable size of the send save screen */
  192. /* bitmap is then the minimum of all the remote receive sizes and the */
  193. /* local send size. */
  194. /************************************************************************/
  195. ssiNewSaveBitmapSize = SAVE_BITMAP_WIDTH * SAVE_BITMAP_HEIGHT;
  196. CPC_EnumerateCapabilities(TS_CAPSETTYPE_ORDER, NULL,
  197. SSIEnumBitmapCacheCaps);
  198. TRC_NRM((TB, "Sender bitmap size %ld", ssiNewSaveBitmapSize));
  199. DC_END_FN();
  200. }
  201. /****************************************************************************/
  202. /* SSIResetInterceptor */
  203. /* */
  204. /* DESCRIPTION: Reset the save screen bits interceptor */
  205. /****************************************************************************/
  206. void RDPCALL SHCLASS SSIResetInterceptor(void)
  207. {
  208. DC_BEGIN_FN("SSIResetInterceptor");
  209. /************************************************************************/
  210. /* Make sure the display driver resets the save level. */
  211. /************************************************************************/
  212. ssiResetInterceptor = TRUE;
  213. DCS_TriggerUpdateShmCallback();
  214. DC_END_FN();
  215. }
  216. /****************************************************************************/
  217. /* Name: SSICapabilitiesChanged */
  218. /* */
  219. /* Purpose: Called when the SSI capabilities have been renegotiated. */
  220. /****************************************************************************/
  221. void RDPCALL SHCLASS SSICapabilitiesChanged(void)
  222. {
  223. DC_BEGIN_FN("SSICapabilitiesChanged");
  224. ssiSaveBitmapSizeChanged = TRUE;
  225. DCS_TriggerUpdateShmCallback();
  226. DC_END_FN();
  227. }