Source code of Windows XP (NT5)
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.

316 lines
9.7 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. address.c
  5. Abstract:
  6. TAPI Service Provider functions related to manipulating addresses.
  7. TSPI_lineGetAddressCaps
  8. TSPI_lineGetAddressStatus
  9. Environment:
  10. User Mode - Win32
  11. --*/
  12. ///////////////////////////////////////////////////////////////////////////////
  13. // //
  14. // Include files //
  15. // //
  16. ///////////////////////////////////////////////////////////////////////////////
  17. #include "globals.h"
  18. #include "provider.h"
  19. #include "version.h"
  20. #include "line.h"
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // //
  23. // TSPI procedures //
  24. // //
  25. ///////////////////////////////////////////////////////////////////////////////
  26. LONG
  27. TSPIAPI
  28. TSPI_lineGetAddressCaps(
  29. DWORD dwDeviceID,
  30. DWORD dwAddressID,
  31. DWORD dwTSPIVersion,
  32. DWORD dwExtVersion,
  33. LPLINEADDRESSCAPS pAddressCaps
  34. )
  35. /*++
  36. Routine Description:
  37. This function queries the specified address on the specified line device
  38. to determine its telephony capabilities.
  39. The line device IDs supported by a particular driver are numbered
  40. sequentially starting at a value set by the TAPI DLL using the
  41. TSPI_lineSetDeviceIDBase function.
  42. The version number supplied has been negotiated by the TAPI DLL using
  43. TSPI_lineNegotiateTSPIVersion.
  44. Arguments:
  45. dwDeviceID - Specifies the line device containing the address to be
  46. queried.
  47. dwAddressID - Specifies the address on the given line device whose
  48. capabilities are to be queried.
  49. dwTSPIVersion - Specifies the version number of the Telephony SPI to be
  50. used. The high order word contains the major version number; the low
  51. order word contains the minor version number.
  52. dwExtVersion - Specifies the version number of the service
  53. provider-specific extensions to be used. This number can be left
  54. zero if no device specific extensions are to be used. Otherwise,
  55. the high order word contains the major version number; the low
  56. order word contain the minor version number.
  57. pAddressCaps - Specifies a far pointer to a variable sized structure
  58. of type LINEADDRESSCAPS. Upon successful completion of the request,
  59. this structure is filled with address capabilities information.
  60. Return Values:
  61. Returns zero if the function is successful or a negative error
  62. number if an error has occurred. Possible error returns are:
  63. LINEERR_BADDEVICEID - The specified line device ID is out of the range
  64. of line devices IDs supported by this driver.
  65. LINEERR_INVALADDRESSID - The specified address ID is out of range.
  66. LINEERR_INCOMPATIBLEVERSION - The specified TSPI and/or extension
  67. version number is not supported by the Service Provider for the
  68. specified line device.
  69. LINEERR_INVALEXTVERSION - The app requested an invalid extension
  70. version number.
  71. LINEERR_STRUCTURETOOSMALL - The dwTotalSize member of a structure
  72. does not specify enough memory to contain the fixed portion of
  73. the structure. The dwNeededSize field has been set to the amount
  74. required.
  75. --*/
  76. {
  77. DWORD dwAddressSize;
  78. PH323_LINE pLine = NULL;
  79. // make sure this is a version we support
  80. if (!H323ValidateTSPIVersion(dwTSPIVersion)) {
  81. // do not support tspi version
  82. return LINEERR_INCOMPATIBLEAPIVERSION;
  83. }
  84. // make sure this is a version we support
  85. if (!H323ValidateExtVersion(dwExtVersion)) {
  86. // do not support extensions
  87. return LINEERR_INVALEXTVERSION;
  88. }
  89. // make sure address id is supported
  90. if (!H323IsValidAddressID(dwAddressID)) {
  91. // invalid address id
  92. return LINEERR_INVALADDRESSID;
  93. }
  94. // retrieve line device pointer from device id
  95. if (!H323GetLineFromIDAndLock(&pLine, dwDeviceID)) {
  96. // invalid line device id
  97. return LINEERR_BADDEVICEID;
  98. }
  99. // determine size of address name
  100. dwAddressSize = H323SizeOfWSZ(pLine->wszAddr);
  101. // calculate number of bytes needed
  102. pAddressCaps->dwNeededSize = sizeof(LINEADDRESSCAPS) +
  103. dwAddressSize
  104. ;
  105. // validate buffer allocated is large enough
  106. if (pAddressCaps->dwTotalSize >= pAddressCaps->dwNeededSize) {
  107. // record amount of memory used
  108. pAddressCaps->dwUsedSize = pAddressCaps->dwNeededSize;
  109. // position address name after fixed portion
  110. pAddressCaps->dwAddressSize = dwAddressSize;
  111. pAddressCaps->dwAddressOffset = sizeof(LINEADDRESSCAPS);
  112. // copy address name after fixed portion
  113. memcpy((LPBYTE)pAddressCaps + pAddressCaps->dwAddressOffset,
  114. (LPBYTE)pLine->wszAddr,
  115. pAddressCaps->dwAddressSize
  116. );
  117. } else if (pAddressCaps->dwTotalSize >= sizeof(LINEADDRESSCAPS)) {
  118. H323DBG((
  119. DEBUG_LEVEL_WARNING,
  120. "lineaddresscaps structure too small for strings.\n"
  121. ));
  122. // record amount of memory used
  123. pAddressCaps->dwUsedSize = sizeof(LINEADDRESSCAPS);
  124. } else {
  125. H323DBG((
  126. DEBUG_LEVEL_ERROR,
  127. "lineaddresscaps structure too small.\n"
  128. ));
  129. // release line device
  130. H323UnlockLine(pLine);
  131. // allocated structure too small
  132. return LINEERR_STRUCTURETOOSMALL;
  133. }
  134. H323DBG((
  135. DEBUG_LEVEL_VERBOSE,
  136. "addr 0 capabilities requested.\n"
  137. ));
  138. // transfer associated device id
  139. pAddressCaps->dwLineDeviceID = dwDeviceID;
  140. // initialize number of calls allowed per address
  141. pAddressCaps->dwMaxNumActiveCalls = H323_MAXCALLSPERADDR;
  142. // initialize supported address capabilities
  143. pAddressCaps->dwAddressSharing = H323_ADDR_ADDRESSSHARING;
  144. pAddressCaps->dwCallInfoStates = H323_ADDR_CALLINFOSTATES;
  145. pAddressCaps->dwCallStates = H323_ADDR_CALLSTATES;
  146. pAddressCaps->dwDisconnectModes = H323_ADDR_DISCONNECTMODES;
  147. pAddressCaps->dwAddrCapFlags = H323_ADDR_CAPFLAGS;
  148. pAddressCaps->dwCallFeatures = H323_ADDR_CALLFEATURES;
  149. pAddressCaps->dwAddressFeatures = H323_ADDR_ADDRFEATURES;
  150. pAddressCaps->dwCallerIDFlags = H323_ADDR_CALLERIDFLAGS;
  151. pAddressCaps->dwCalledIDFlags = H323_ADDR_CALLEDIDFLAGS;
  152. // initialize unsupported address capabilities
  153. pAddressCaps->dwConnectedIDFlags = LINECALLPARTYID_UNAVAIL;
  154. pAddressCaps->dwRedirectionIDFlags = LINECALLPARTYID_UNAVAIL;
  155. pAddressCaps->dwRedirectingIDFlags = LINECALLPARTYID_UNAVAIL;
  156. // release line device
  157. H323UnlockLine(pLine);
  158. // success
  159. return NOERROR;
  160. }
  161. LONG
  162. TSPIAPI
  163. TSPI_lineGetAddressStatus(
  164. HDRVLINE hdLine,
  165. DWORD dwAddressID,
  166. LPLINEADDRESSSTATUS pAddressStatus
  167. )
  168. /*++
  169. Routine Description:
  170. This operation allows the TAPI DLL to query the specified address for its
  171. current status.
  172. Arguments:
  173. hdLine - Specifies the Service Provider's opaque handle to the line
  174. containing the address to be queried.
  175. dwAddressID - Specifies an address on the given open line device.
  176. This is the address to be queried.
  177. pAddressStatus - Specifies a far pointer to a variable sized data
  178. structure of type LINEADDRESSSTATUS.
  179. Return Values:
  180. Returns zero if the function is successful or a negative error
  181. number if an error has occurred. Possible error returns are:
  182. LINEERR_INVALLINEHANDLE - The specified device handle is invalid.
  183. LINEERR_INVALADDRESSID - The specified address ID is out of range.
  184. LINEERR_STRUCTURETOOSMALL - The dwTotalSize member of a structure
  185. does not specify enough memory to contain the fixed portion of
  186. the structure. The dwNeededSize field has been set to the amount
  187. required.
  188. --*/
  189. {
  190. PH323_LINE pLine = NULL;
  191. // make sure address id is supported
  192. if (!H323IsValidAddressID(dwAddressID)) {
  193. // invalid address id
  194. return LINEERR_INVALADDRESSID;
  195. }
  196. // retrieve line device pointer from handle
  197. if (!H323GetLineAndLock(&pLine, hdLine)) {
  198. // invalid line device handle
  199. return LINEERR_INVALLINEHANDLE;
  200. }
  201. // calculate the number of bytes required
  202. pAddressStatus->dwNeededSize = sizeof(LINEADDRESSSTATUS);
  203. // see if lineaddressstatus structure is of correct size
  204. if (pAddressStatus->dwTotalSize < pAddressStatus->dwNeededSize) {
  205. H323DBG((
  206. DEBUG_LEVEL_ERROR,
  207. "lineaddressstatus structure too small.\n"
  208. ));
  209. // release line device
  210. H323UnlockLine(pLine);
  211. // allocated structure too small
  212. return LINEERR_STRUCTURETOOSMALL;
  213. }
  214. // record amount of memory used
  215. pAddressStatus->dwUsedSize = pAddressStatus->dwNeededSize;
  216. // transfer number of active calls from line device structure
  217. pAddressStatus->dwNumActiveCalls = pLine->pCallTable->dwNumInUse;
  218. // specify that outbound call is possible on the address
  219. pAddressStatus->dwAddressFeatures = H323_ADDR_ADDRFEATURES;
  220. // release line device
  221. H323UnlockLine(pLine);
  222. // success
  223. return NOERROR;
  224. }