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.

241 lines
7.4 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. address.cpp
  5. Abstract:
  6. TAPI Service Provider functions related to manipulating addresses.
  7. TSPI_lineGetAddressCaps
  8. TSPI_lineGetAddressStatus
  9. Author:
  10. Nikhil Bobde (NikhilB)
  11. Revision History:
  12. --*/
  13. //
  14. // Include files
  15. //
  16. #include "globals.h"
  17. #include "line.h"
  18. //
  19. // TSPI procedures
  20. //
  21. LONG
  22. TSPIAPI
  23. TSPI_lineGetAddressCaps(
  24. DWORD dwDeviceID,
  25. DWORD dwAddressID,
  26. DWORD dwTSPIVersion,
  27. DWORD dwExtVersion,
  28. LPLINEADDRESSCAPS pAddressCaps
  29. )
  30. /*++
  31. Routine Description:
  32. This function queries the specified address on the specified line device
  33. to determine its telephony capabilities.
  34. The line device IDs supported by a particular driver are numbered
  35. sequentially starting at a value set by the TAPI DLL using the
  36. TSPI_lineSetDeviceIDBase function.
  37. The version number supplied has been negotiated by the TAPI DLL using
  38. TSPI_lineNegotiateTSPIVersion.
  39. Arguments:
  40. dwDeviceID - Specifies the line device containing the address to be
  41. queried.
  42. dwAddressID - Specifies the address on the given line device whose
  43. capabilities are to be queried.
  44. dwTSPIVersion - Specifies the version number of the Telephony SPI to be
  45. used. The high order word contains the major version number; the low
  46. order word contains the minor version number.
  47. dwExtVersion - Specifies the version number of the service
  48. provider-specific extensions to be used. This number can be left
  49. zero if no device specific extensions are to be used. Otherwise,
  50. the high order word contains the major version number; the low
  51. order word contain the minor version number.
  52. pAddressCaps - Specifies a far pointer to a variable sized structure
  53. of type LINEADDRESSCAPS. Upon successful completion of the request,
  54. this structure is filled with address capabilities information.
  55. Return Values:
  56. Returns zero if the function is successful or a negative error
  57. number if an error has occurred. Possible error returns are:
  58. LINEERR_BADDEVICEID - The specified line device ID is out of the range
  59. of line devices IDs supported by this driver.
  60. LINEERR_INVALADDRESSID - The specified address ID is out of range.
  61. LINEERR_INCOMPATIBLEVERSION - The specified TSPI and/or extension
  62. version number is not supported by the Service Provider for the
  63. specified line device.
  64. LINEERR_INVALEXTVERSION - The app requested an invalid extension
  65. version number.
  66. LINEERR_STRUCTURETOOSMALL - The dwTotalSize member of a structure
  67. does not specify enough memory to contain the fixed portion of
  68. the structure. The dwNeededSize field has been set to the amount
  69. required.
  70. --*/
  71. {
  72. LONG retVal;
  73. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_lineGetAddressCaps - Entered." ));
  74. if( g_pH323Line -> GetDeviceID() != dwDeviceID )
  75. {
  76. // do not recognize device
  77. return LINEERR_BADDEVICEID;
  78. }
  79. // make sure this is a version we support
  80. if (!H323ValidateTSPIVersion(dwTSPIVersion))
  81. {
  82. // do not support tspi version
  83. return LINEERR_INCOMPATIBLEAPIVERSION;
  84. }
  85. // make sure this is a version we support
  86. if (!H323ValidateExtVersion(dwExtVersion))
  87. {
  88. // do not support extensions
  89. retVal = LINEERR_INVALEXTVERSION;
  90. goto exit;
  91. }
  92. // make sure address id is supported
  93. if( g_pH323Line -> IsValidAddressID(dwAddressID) == FALSE )
  94. {
  95. // invalid address id
  96. retVal = LINEERR_INVALADDRESSID;
  97. goto exit;
  98. }
  99. retVal = g_pH323Line -> CopyLineInfo( dwDeviceID, pAddressCaps );
  100. exit:
  101. return retVal;
  102. }
  103. /*++
  104. Routine Description:
  105. This operation allows the TAPI DLL to query the specified address for its
  106. current status.
  107. Arguments:
  108. hdLine - Specifies the Service Provider's opaque handle to the line
  109. containing the address to be queried.
  110. dwAddressID - Specifies an address on the given open line device.
  111. This is the address to be queried.
  112. pAddressStatus - Specifies a far pointer to a variable sized data
  113. structure of type LINEADDRESSSTATUS.
  114. Return Values:
  115. Returns zero if the function is successful or a negative error
  116. number if an error has occurred. Possible error returns are:
  117. LINEERR_INVALLINEHANDLE - The specified device handle is invalid.
  118. LINEERR_INVALADDRESSID - The specified address ID is out of range.
  119. LINEERR_STRUCTURETOOSMALL - The dwTotalSize member of a structure
  120. does not specify enough memory to contain the fixed portion of
  121. the structure. The dwNeededSize field has been set to the amount
  122. required.
  123. --*/
  124. LONG
  125. TSPIAPI
  126. TSPI_lineGetAddressStatus(
  127. HDRVLINE hdLine,
  128. DWORD dwAddressID,
  129. LPLINEADDRESSSTATUS pAddressStatus
  130. )
  131. {
  132. LONG retVal = NOERROR;
  133. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_lineGetAddressStatus - Entered." ));
  134. // make sure address id is supported
  135. if( g_pH323Line -> IsValidAddressID(dwAddressID) == FALSE )
  136. {
  137. // invalid address id
  138. return LINEERR_INVALADDRESSID;
  139. }
  140. //lock the line device
  141. g_pH323Line -> Lock();
  142. // calculate the number of bytes required
  143. pAddressStatus->dwNeededSize = sizeof(LINEADDRESSSTATUS);
  144. // see if lineaddressstatus structure is of correct size
  145. if (pAddressStatus->dwTotalSize < pAddressStatus->dwNeededSize)
  146. {
  147. H323DBG(( DEBUG_LEVEL_ERROR,
  148. "lineaddressstatus structure too small."
  149. ));
  150. //unlock the line device
  151. g_pH323Line -> Unlock();
  152. // allocated structure too small
  153. return LINEERR_STRUCTURETOOSMALL;
  154. }
  155. // record amount of memory used
  156. pAddressStatus->dwUsedSize = pAddressStatus->dwNeededSize;
  157. // transfer number of active calls from line device structure
  158. pAddressStatus->dwNumActiveCalls = g_pH323Line -> GetNoOfCalls();
  159. // specify that outbound call is possible on the address
  160. pAddressStatus->dwAddressFeatures = H323_ADDR_ADDRFEATURES;
  161. if( g_pH323Line->GetCallForwardParams() &&
  162. (g_pH323Line->GetCallForwardParams()->fForwardingEnabled) )
  163. {
  164. pAddressStatus->dwNumRingsNoAnswer = g_pH323Line->m_dwNumRingsNoAnswer;
  165. pAddressStatus->dwForwardOffset = pAddressStatus->dwUsedSize;
  166. retVal = g_pH323Line->CopyAddressForwardInfo( pAddressStatus );
  167. }
  168. //unlock the line device
  169. g_pH323Line -> Unlock();
  170. H323DBG(( DEBUG_LEVEL_TRACE, "TSPI_lineGetAddressStatus - Exited." ));
  171. // success
  172. return retVal;
  173. }