discussion at:
http://www.powerbasic.com/support/pb...ad.php?t=13294
update 4 nov 18, 2005
made possible by the kind insight and help of jose rocca. many, many thanks sir.
[CODE]
#compile exe "tapitest.exe"
#dim all
%tapi_current_version = &h00020000 ' version 2.0
#if %tapi_current_version >= &h000020000 ' for completeness
' these constants are mutually exclusive - there's no way to specify more
' than one at a time (and it doesn't make sense, either) so they're ordinal rather than bits.
%lineinitializeexoption_usehiddenwindow = &h00000001 ' tapi v2.0
%lineinitializeexoption_useevent = &h00000002 ' tapi v2.0
%lineinitializeexoption_usecompletionport = &h00000003 ' tapi v2.0
#endif
#include "win32api.inc"
#include "tapi32.inc"
declare function createconnection( stitle as string, totdev as dword ) as string
declare function negotiateapiversions( totdev as dword, appapiver as dword ) as string
declare function getlinedevcaps( totdev as dword ) as string
declare function gettapistructstring( byval ptrtapistruct as long, byval offset as long, byval length as long ) as string
declare function deviceinfo( dev as long ) as string
declare function deviceconfigdialog( byval dev as long, byval ownerhwnd as long ) as string
declare function dialingpropertiesdialog( byval dev as long, byval ownerhwnd as long, appapiver as dword ) as string
declare function openline( dev as long ) as string
declare function processcanonical( hlineapp as long, dev as long ) as string
declare function makecallasynch( znumtodial as asciiz*%max_path ) as string
declare function dropcallasynch( ) as string
declare function deallocatecall( ) as string
declare function closeline( ) as string
declare function shutdownline( ) as string
declare function paintdevicon( byval dev as long, hicon as long ) as string
declare function showtext( stxt as string ) as long
declare function linecallbackfunc( byval hdevice as dword, byval dwmsg as dword, byval dwcallbackinstance as dword, _
byval dwparam1 as dword,byval dwparam2 as dword,byval dwparam3 as dword ) as long
type tapilinetype
zlinename as asciiz*%max_path ' dwlinenameoffset, dwlinenamesize)
zproviderinfo as asciiz*%max_path ' dwproviderinfooffset, dwproviderinfosize)
zswitchinfo as asciiz*%max_path ' dwswitchinfooffset, dwswitchinfosize)
currentlineid as dword ' device number
permanentlineid as dword ' dwpermanentlineid
stringformat as dword ' dwstringformat
numaddresses as dword ' dwnumaddresses
maxdatarate as dword ' dwmaxrate
bearermodes as dword ' dwbearermodes
addressmodes as dword ' dwaddressmodes
mediamodes as dword ' dwmediamodes
generatetonemaxnumfreq as dword ' dwgeneratetonemaxnumfreq
generatetonemodes as dword ' dwgeneratetonemodes
numterminals as dword ' dwnumterminals
negapiver as dword ' negotiated api version
extapiver as lineextensionid ' extension api versions
linesupportsvoicecalls as long ' can make a voice call
znumtodial as asciiz*%max_path ' number user wants to dial
zdialablestring as asciiz*%max_path ' contains all info
zdisplayablestring as asciiz*%max_path ' does not display credit card info
currentcountry as dword ' country/region code configured in currentlocation
destcountry as dword ' destination country/region code of the translated address
translateresults as dword ' code to string contents
translatedefn as string*48 ' explanation of translation result
end type
global tapiline() as tapilinetype
global requestingcall, droppingcall as long ' global call state flags
global hdbg, hdlg, hcall, hline, hlineapp, done as long
global lpfncallback as dword ' pointer to the function callback
%loapi = &h10003 ' default tapi 1.3 (&h00010003) ' %early_tapi_version
%hiapi = &h30000 ' default tapi 3.0 (&h00030000) ' %tapi_current_version
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function createconnection( stitle as string, totdev as dword ) as string
local retval, hinstance as long
local lpnumdevs as dword
local ztemp as asciiz * 255
local lpfncallback as long ptr
local lip as lineinitializeexparams
function = " ' no problems
showtext "initializing tapi & enumerating lines"
ztemp = stitle '
hinstance = 0
lip.dwtotalsize = len(lip) 'init params
lip.dwoptions = %lineinitializeexoption_usehiddenwindow
' what is important to notice regarding lineinitializeex is that
' you can select one of two mechanisms by which tapi will notify the
' application of telephony events: hidden window or event handle.
' in this example we are using hidden window.
' when the hidden window method of notification is used in a tapi application, tapi creates a hidden
' window for the application in the context of the thread that called lineinitializeex. if the thread that
' calls lineinitializeex does not retrieve and dispatch windows messages, the hidden window does not
' receive windows messages, and in turn, the callback function registered by the tapi application is not called.
' calling lineinitialize is equivalent to calling lineinitializeex with the lineinitializeexoption_usehiddenwindow
' option, so using lineinitialize instead of lineinitializeex results in the same behavior.
' make sure the thread that calls lineinitializeex contains a message loop that retrieves and
' dispatches messages for the hidden window.
lpfncallback = codeptr(linecallbackfunc) ' pointer to callback function
retval = lineinitializeex( hlineapp, _ ' lphlineapp lphlineapp - handle used in all tapi functions calls
hinstance, _ ' hinstance hinstance - exeordll instance handle
byval lpfncallback, _ ' linecallback lpfncallback - callback function to return asynchronous notifications
ztemp, _ ' lpcwstr lpszfriendlyappname - name to indicate who is calling tapi
lpnumdevs, _ ' lpdword lpdwnumdevs - number of available tapi devices, 0 to dwnumdevices-1
%hiapi, _ ' lpdword lpdwapiversion - negotiate tapi version
lip) ' lplineinitializeexparams lip - hidden window or event handle
' returns 0 if successful
if retval <> 0 then
select case cdwd(retval)
case %lineerr_invalappname : function = "invalid application name"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_inifilecorrupt : function = "the ini file is corrupted"
case %lineerr_invalpointer : function = "invalid pointer"
case %lineerr_reinit : function = "the application attempted to initialize tapi twice"
case %lineerr_nomem : function = "no memory available"
case %lineerr_invalparam : function = "invalid parameter"
case else : function = "undefined error"+str$(retval) + " = &h" + hex$(retval)
end select
exit function
end if
'================================
if lpnumdevs = 0 then
function = "no tapi devices found" 'no lines!
totdev = 0
else
totdev = lpnumdevs-1
end if
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function negotiateapiversions( totdev as dword, appapiver as dword ) as string
local retval as long
local dev as dword
local lxid as lineextensionid
function = " ' no problems
showtext "negotiating api ver for lines"
redim tapiline(totdev)
for dev = 0 to totdev ' negotiate and cache api versions for each line
retval = linenegotiateapiversion( hlineapp, dev, %loapi, %hiapi, tapiline(dev).negapiver, lxid) ' returns a long
'print #hdbg, str$(dev) + ", negotiated api ver=" + str$(hi(word,tapiline(dev).negapiver)) + "." + str$(lo(word,tapiline(dev).negapiver))
if retval <> 0 then
select case cdwd(retval)
case %lineerr_baddeviceid : function = "the device identifier provided is incorrect"
case %lineerr_nodriver : function = "no driver was found"
case %lineerr_incompatibleapiversion : function = "the api version is incompatible"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_invalapphandle : function = "the application handle was invalid"
case %lineerr_resourceunavail : function = "the resource is unavailable"
case %lineerr_invalpointer : function = "the pointer is invalid"
case %lineerr_uninitialized : function = "the parameter is uninitialized"
case %lineerr_nomem : function = "no memory is available"
case %lineerr_operationunavail : function = "the operation is unavailable"
case %lineerr_nodevice : tapiline(dev).zlinename = "device not found" : iterate ' handle this differently
case else : function = "undefined error"+str$(retval)
end select ' "device not found" can occur on a laptop with pcmcia card coming out of hibernation.
tapiline(dev).negapiver = 0 'no compatible api negotiated for this line
exit function
else ' print #hdbg, "extapiversions=" + str$(lxid.dwextensionid0) + str$(lxid.dwextensionid1) + str$(lxid.dwextensionid2) + str$(lxid.dwextensionid3)
' if the service provider for the specified dwdeviceid parameter supports provider-specific extensions,
' then, upon a successful negotiation, this structure is filled with the extension identifier of
' these extensions. this structure contains all zeros if the line provides no extensions. an application
' can ignore the returned parameter if it does not use extensions.
tapiline(dev).extapiver.dwextensionid0 = lxid.dwextensionid0 ' save extension version (dev-specific features) if available
tapiline(dev).extapiver.dwextensionid1 = lxid.dwextensionid1
tapiline(dev).extapiver.dwextensionid2 = lxid.dwextensionid2
tapiline(dev).extapiver.dwextensionid3 = lxid.dwextensionid3
if tapiline(dev).negapiver > appapiver then appapiver = tapiline(dev).negapiver ' highest ver found
end if
next
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function getlinedevcaps( totdev as dword ) as string
' this function queries a specified line device to determine its telephony capabilities.
' the returned data is valid for all addresses on the line device
' linegetdevcaps(byval hlineapp as dword, byval dwdeviceid as dword, byval dwapiversion as dword, byval dwextversion as dword, lplinedevcaps as linedevcaps)
local retval, lpdata, numelem as long
local dev as dword
local linecaps() as linedevcaps ' variable-length structures that tapi may throw at you
function = " ' no problems
showtext "getting line device info"
' note: dwneededsize will return zero if the memory size is too small to start with hence
' the test for %lineerr_structuretoosmall right after the function call. this test alone
' is not sufficient as the function may not return this error when the totalsize is still
' less than the neededsize! hence the test for both.
' retval is a long variable yet the constant is defined as a dword in tapi32.inc hence
' the need to convert retval to a dword. of course none of this is in msdn....
numelem = 1 ' starting memory size
dim linecaps(numelem-1) ' first attempt
linecaps(0).dwtotalsize = sizeof(linedevcaps) * numelem ' size of the udt
for dev = 0 to totdev
if tapiline(dev).negapiver = 0 then iterate ' not found in api negotiation
do
retval = linegetdevcaps( hlineapp, dev, tapiline(dev).negapiver, 0, linecaps(0) ) 'request tapi to fill udt with info
if cdwd(retval) = %lineerr_structuretoosmall or linecaps(0).dwtotalsize < linecaps(0).dwneededsize then ' increase buffer size
'print #hdbg, str$(dev) + ", numelem=" + str$(numelem) + ", totalsize=" + str$(linecaps(0).dwtotalsize) + ", neededsize=" + str$(linecaps(0).dwneededsize)
incr numelem ' once increased, just leave it that size for next device
if numelem > 20 then ' something else is wrong
function = "memory increased x"+str$(numelem)+" and still not big enough for linecaps!"
exit function
end if '
redim linecaps(numelem-1) ' assign more memory
linecaps(0).dwtotalsize = sizeof(linedevcaps) * numelem
else ' print #hdbg, str$(dev) + ", numelem=" + str$(numelem) + ", totalsize=" + str$(linecaps(0).dwtotalsize) + ", neededsize=" + str$(linecaps(0).dwneededsize)
exit loop
end if
loop
'================================
if retval <> 0 then
select case cdwd(retval)
case %lineerr_structuretoosmall : function = "the structure is too small" ' buffer size is too small
case %lineerr_baddeviceid : function = "bad device id provided"
case %lineerr_nomem : function = "no memory is available"
case %lineerr_incompatibleapiversion : function = "api version is incompatible"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_incompatibleextversion : function = "extension version is incompatible"
case %lineerr_resourceunavail : function = "the resource is unavailable"
case %lineerr_invalapphandle : function = "the application handle is invalid"
case %lineerr_invalpointer : function = "invalid pointer"
case %lineerr_uninitialized : function = "the parameter is uninitialized"
case %lineerr_nodriver : function = "no driver was found"
case %lineerr_operationunavail : function = "the operation is unavailable"
case %lineerr_nodevice : function = "no device was found"
case else : function = "undefined error"+str$(retval)
end select
exit function
end if
'================================
'store udt info in class local variables
tapiline(dev).currentlineid = dev
tapiline(dev).zlinename = gettapistructstring(varptr(linecaps(0)), linecaps(0).dwlinenameoffset, linecaps(0).dwlinenamesize)
tapiline(dev).zproviderinfo = gettapistructstring(varptr(linecaps(0)), linecaps(0).dwproviderinfooffset, linecaps(0).dwproviderinfosize)
tapiline(dev).zswitchinfo = gettapistructstring(varptr(linecaps(0)), linecaps(0).dwswitchinfooffset, linecaps(0).dwswitchinfosize)
tapiline(dev).permanentlineid = linecaps(0).dwpermanentlineid
tapiline(dev).stringformat = linecaps(0).dwstringformat
tapiline(dev).numaddresses = linecaps(0).dwnumaddresses
tapiline(dev).maxdatarate = linecaps(0).dwmaxrate
tapiline(dev).bearermodes = linecaps(0).dwbearermodes
tapiline(dev).addressmodes = linecaps(0).dwaddressmodes
tapiline(dev).mediamodes = linecaps(0).dwmediamodes
tapiline(dev).generatetonemaxnumfreq = linecaps(0).dwgeneratetonemaxnumfreq
tapiline(dev).generatetonemodes = linecaps(0).dwgeneratetonemodes
tapiline(dev).numterminals = linecaps(0).dwnumterminals
'================================
if %linebearermode_voice and tapiline(dev).bearermodes then 'check if line supports making voice calls
if %linemediamode_interactivevoice and tapiline(dev).mediamodes then
tapiline(dev).linesupportsvoicecalls = 1
end if
end if
'================================
combobox add hdlg, 98, str$(dev) + " - " + trim$(tapiline(dev).zlinename) ' add the device to the combobox
'================================
next
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function gettapistructstring(byval ptrtapistruct as long, byval offset as long, byval length as long) as string
local stemp as string
function = "
if length then ' handle erroneous input
if offset then '
stemp = space$(length)
copymemory byval strptr(stemp), byval ptrtapistruct+offset, length
function = stemp
end if
end if
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function deviceinfo( dev as long ) as string
local stemp, smsg as string
smsg = "
smsg = smsg + "tapi line name: " + tapiline(dev).zlinename + $crlf
smsg = smsg + "tapi line: #" + str$(tapiline(dev).currentlineid) + $crlf '
smsg = smsg + "tapi provider info: " + tapiline(dev).zproviderinfo + $crlf
smsg = smsg + "tapi switch info: " + tapiline(dev).zswitchinfo + $crlf
smsg = smsg + $crlf + "permanent line id: " + str$(tapiline(dev).permanentlineid) + $crlf
select case tapiline(dev).stringformat
case %stringformat_ascii
smsg = smsg + "string format: stringformat_ascii" + $crlf
case %stringformat_dbcs
smsg = smsg + "string format: stringformat_dbcs" + $crlf
case %stringformat_unicode
smsg = smsg + "string format: stringformat_unicode" + $crlf
case %stringformat_binary
smsg = smsg + "string format: stringformat_binary" + $crlf
case else
end select
smsg = smsg + "number of addresses associated with this line: " + str$(tapiline(dev).numaddresses) + $crlf
smsg = smsg + "max data rate: " + str$(tapiline(dev).maxdatarate) + $crlf
smsg = smsg + $crlf + "bearer modes supported:" + $crlf
if %linebearermode_voice and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_voice" + $crlf
if %linebearermode_speech and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_speech" + $crlf
if %linebearermode_data and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_data" + $crlf
if %linebearermode_altspeechdata and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_altspeechdata" + $crlf
if %linebearermode_multiuse and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_multiuse" + $crlf
if %linebearermode_noncallsignaling and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_noncallsignaling" + $crlf
smsg = smsg + $crlf + "address modes supported:" + $crlf
if tapiline(dev).addressmodes and %lineaddressmode_addressid then smsg = smsg + $tab + "lineaddressmode_addressid" + $crlf
if tapiline(dev).addressmodes and %lineaddressmode_dialableaddr then smsg = smsg + $tab + "lineaddressmode_dialableaddr" + $crlf
smsg = smsg + $crlf + "media modes supported:" + $crlf
if %linemediamode_adsi and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_adsi" + $crlf
if %linemediamode_automatedvoice and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_automatedvoice" + $crlf
if %linemediamode_datamodem and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_datamodem" + $crlf
if %linemediamode_digitaldata and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_digitaldata" + $crlf
if %linemediamode_g3fax and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_g3fax" + $crlf
if %linemediamode_g4fax and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_g4fax" + $crlf
if %linemediamode_interactivevoice and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_interactivevoice" + $crlf
if %linemediamode_mixed and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_mixed" + $crlf
if %linemediamode_tdd and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_tdd" + $crlf
if %linemediamode_teletex and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_teletex" + $crlf
if %linemediamode_telex and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_telex" + $crlf
if %linemediamode_unknown and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_unknown" + $crlf
if %linemediamode_videotex and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_videotex" + $crlf
smsg = smsg + $crlf + "line tone generation supported: " + str$(tapiline(dev).generatetonemaxnumfreq) + $crlf
if tapiline(dev).generatetonemaxnumfreq then 'show if tone generation is supported
if %linetonemode_beep and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_beep" + $crlf
if %linetonemode_billing and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_billing" + $crlf
if %linetonemode_busy and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_busy" + $crlf
if %linetonemode_custom and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_custom" + $crlf
if %linetonemode_ringback and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_ringback" + $crlf
end if
smsg = smsg + "number of terminals for this line: " + str$(tapiline(dev).numterminals) + $crlf
function = smsg '
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function deviceconfigdialog( byval dev as long, byval ownerhwnd as long ) as string
local ztemp as asciiz*255
local retval as long
function = " ' no problems
ztemp = " ' highest level of config available
retval = lineconfigdialog( tapiline(dev).currentlineid, ownerhwnd, ztemp)
if retval <> 0 then
select case cdwd(retval)
case %lineerr_baddeviceid : function = "the device id is incorrect"
case %lineerr_nomem : function = "not enough memory is available"
case %lineerr_inuse : function = "the line is in use"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_invaldeviceclass : function = "the device class is invalid"
case %lineerr_resourceunavail : function = "the resource is unavailable"
case %lineerr_invalparam : function = "the parameter is invalid"
case %lineerr_uninitialized : function = "the parameter is uninitialized"
case %lineerr_invalpointer : function = "the pointer is invalid"
case %lineerr_operationunavail : function = "the operation is unavailable"
case %lineerr_nodevice : function = "the device was not found"
case else : function = "undefined error"+str$(retval) + " = &h" + hex$(retval)
end select
end if
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function dialingpropertiesdialog(byval dev as long, byval ownerhwnd as long, appapiver as dword ) as string
local retval as long
function = " ' no problems
retval = linetranslatedialog(hlineapp, tapiline(dev).currentlineid, appapiver, ownerhwnd, tapiline(dev).znumtodial)
if retval <> 0 then
select case cdwd(retval)
case %lineerr_baddeviceid : function = "the device id is incorrect"
case %lineerr_invalparam : function = "the parameter is invalid"
case %lineerr_incompatibleapiversion : function = "the api version is incompatible"
case %lineerr_invalpointer : function = "the pointer is invalid"
case %lineerr_inifilecorrupt : function = "the ini file is corrupt"
case %lineerr_nodriver : function = "the driver was not found"
case %lineerr_inuse : function = "the line is in use"
case %lineerr_nomem : function = "not enough memory is available"
case %lineerr_invaladdress : function = "the address is invalid"
case %lineerr_invalapphandle : function = "the application handle is invalid"
case %lineerr_operationfailed : function = "the operation failed"
case else : function = "unknown return value=" + str$(retval) + " = &h" + hex$(retval)
end select
end if
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function openline( dev as long ) as string ' hline is global
local privileges, mediamodes as long
local retval as long
local dwfncallback as dword ptr
' dwprivileges defines which privileges your application is
' interested in obtaining. possible values are linecallprivilege_none,
' linecallprivilege_monitor, and linecallprivilege_owner. if you do not need
' any stuff on incoming calls, simply put linecallprivilege_none there. in
' case you really want to deal with incoming/outgoing calls, specify the
' appropriate privilege level. the dwmediamodes parameter is used only if
' linecallprivilege_owner is set. it declares which media modes are of
' interest for your application.
privileges = %linecallprivilege_none
mediamodes = %linemediamode_interactivevoice
'================================
function = " ' no problems
showtext "opening line #" + str$(dev)
if hline <> 0 then ' check line is not allready open
function = "line allready open on this device"
exit function
end if
'================================
dwfncallback = codeptr(linecallbackfunc) ' pointer to callback function
'================================
'n.b. you should pass the pointer to linecallbackfunc in lineinitializeex and 0 in lineopen.
' the dwcallbackinstance parameter is not a pointer to a callback function,
' but user-instance data. apparently, the vb code is using it to pass a
' pointer to a class and then doing some tweaking to be able to call the
' members of the class using a dotted syntax.
retval = lineopen( hlineapp, _ '
dev, _ ' dword dwdeviceid
hline, _ ' lphline lphline - line handle for the corresponding opened line device
tapiline(dev).negapiver, _ ' dword dwapiversion
byval 0, _ ' dword dwextversion
byval 0, _ ' dword_ptr dwcallbackinstance - user instance data
privileges, _ ' dword dwprivileges
mediamodes, _ ' dword dwmediamodes
byval 0& ) ' lplinecallparams const lpcallparams, usually set to null
'================================
if retval < 0 then ' zero indicates success. a negative error number indicates that an error occurred
select case cdwd(retval)
case %lineerr_allocated : function = "the line cannot be opened, serial port may be in use"
case %lineerr_linemapperfailed : function = "no lines found matching requirements specified in lpcallparams"
case %lineerr_baddeviceid : function = "the device id is incorrect"
case %lineerr_nodriver : function = "the driver was not found"
case %lineerr_incompatibleapiversion : function = "the api version is incompatible"
case %lineerr_nomem : function = "not enough memory is available"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_invalapphandle : function = "the application handle is invalid"
case %lineerr_resourceunavail : function = "he resource is unavailable"
case %lineerr_invalmediamode : function = "the media mode is invalid"
case %lineerr_structuretoosmall : function = "the structure is too small"
case %lineerr_invalpointer : function = "the pointer is invalid"
case %lineerr_uninitialized : function = "lthe parameter is uninitialized"
case %lineerr_invalprivselect : function = "the priviledges are invalid"
case %lineerr_reinit : function = "the application attempted to initialize tapi twice"
case %lineerr_nodevice : function = "the device was not found"
case %lineerr_operationunavail : function = "the operation is unavailable"
case else : function = "unknown return value=" + str$(retval) + " = &h" + hex$(retval)
end select
end if ' print #hdbg, "lineopen() retval="+str$(retval)+"(zero indicates success), tapiver="+str$(tapiline(dev).negapiver)
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function processcanonical( hlineapp as long, dev as long ) as string ' hline is global
'a common practice is that phone numbers are stored in canonical format,
'which includes international the dialing code, area code, and so forth. an
'actual call may use a modified form of this number depending on current
'location, local or long distance call, and so forth. therefore, the
'initial phone number should be translated into a dialable form. to proceed
'with this task, you need to call linetranslateaddress. similar to
'linegetdevcaps, you might be required to call this function several times
'until a correctly sized memory block is passed to keep its output.
'the canonical address format is:
' + country/regioncode ( areacode ) subscribernumber
'for example, this is how you would enter a us number in canonical address format:
'+1 (425) 555-0100
local retval, numelem as long
local trnsadd() as linetranslateoutput
function = " ' no problems
showtext "processing canonical number"
if tapiline(dev).negapiver = 0 then ' not found in api negotiation
function = "th
http://www.powerbasic.com/support/pb...ad.php?t=13294
update 4 nov 18, 2005
made possible by the kind insight and help of jose rocca. many, many thanks sir.
[CODE]
#compile exe "tapitest.exe"
#dim all
%tapi_current_version = &h00020000 ' version 2.0
#if %tapi_current_version >= &h000020000 ' for completeness
' these constants are mutually exclusive - there's no way to specify more
' than one at a time (and it doesn't make sense, either) so they're ordinal rather than bits.
%lineinitializeexoption_usehiddenwindow = &h00000001 ' tapi v2.0
%lineinitializeexoption_useevent = &h00000002 ' tapi v2.0
%lineinitializeexoption_usecompletionport = &h00000003 ' tapi v2.0
#endif
#include "win32api.inc"
#include "tapi32.inc"
declare function createconnection( stitle as string, totdev as dword ) as string
declare function negotiateapiversions( totdev as dword, appapiver as dword ) as string
declare function getlinedevcaps( totdev as dword ) as string
declare function gettapistructstring( byval ptrtapistruct as long, byval offset as long, byval length as long ) as string
declare function deviceinfo( dev as long ) as string
declare function deviceconfigdialog( byval dev as long, byval ownerhwnd as long ) as string
declare function dialingpropertiesdialog( byval dev as long, byval ownerhwnd as long, appapiver as dword ) as string
declare function openline( dev as long ) as string
declare function processcanonical( hlineapp as long, dev as long ) as string
declare function makecallasynch( znumtodial as asciiz*%max_path ) as string
declare function dropcallasynch( ) as string
declare function deallocatecall( ) as string
declare function closeline( ) as string
declare function shutdownline( ) as string
declare function paintdevicon( byval dev as long, hicon as long ) as string
declare function showtext( stxt as string ) as long
declare function linecallbackfunc( byval hdevice as dword, byval dwmsg as dword, byval dwcallbackinstance as dword, _
byval dwparam1 as dword,byval dwparam2 as dword,byval dwparam3 as dword ) as long
type tapilinetype
zlinename as asciiz*%max_path ' dwlinenameoffset, dwlinenamesize)
zproviderinfo as asciiz*%max_path ' dwproviderinfooffset, dwproviderinfosize)
zswitchinfo as asciiz*%max_path ' dwswitchinfooffset, dwswitchinfosize)
currentlineid as dword ' device number
permanentlineid as dword ' dwpermanentlineid
stringformat as dword ' dwstringformat
numaddresses as dword ' dwnumaddresses
maxdatarate as dword ' dwmaxrate
bearermodes as dword ' dwbearermodes
addressmodes as dword ' dwaddressmodes
mediamodes as dword ' dwmediamodes
generatetonemaxnumfreq as dword ' dwgeneratetonemaxnumfreq
generatetonemodes as dword ' dwgeneratetonemodes
numterminals as dword ' dwnumterminals
negapiver as dword ' negotiated api version
extapiver as lineextensionid ' extension api versions
linesupportsvoicecalls as long ' can make a voice call
znumtodial as asciiz*%max_path ' number user wants to dial
zdialablestring as asciiz*%max_path ' contains all info
zdisplayablestring as asciiz*%max_path ' does not display credit card info
currentcountry as dword ' country/region code configured in currentlocation
destcountry as dword ' destination country/region code of the translated address
translateresults as dword ' code to string contents
translatedefn as string*48 ' explanation of translation result
end type
global tapiline() as tapilinetype
global requestingcall, droppingcall as long ' global call state flags
global hdbg, hdlg, hcall, hline, hlineapp, done as long
global lpfncallback as dword ' pointer to the function callback
%loapi = &h10003 ' default tapi 1.3 (&h00010003) ' %early_tapi_version
%hiapi = &h30000 ' default tapi 3.0 (&h00030000) ' %tapi_current_version
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function createconnection( stitle as string, totdev as dword ) as string
local retval, hinstance as long
local lpnumdevs as dword
local ztemp as asciiz * 255
local lpfncallback as long ptr
local lip as lineinitializeexparams
function = " ' no problems
showtext "initializing tapi & enumerating lines"
ztemp = stitle '
hinstance = 0
lip.dwtotalsize = len(lip) 'init params
lip.dwoptions = %lineinitializeexoption_usehiddenwindow
' what is important to notice regarding lineinitializeex is that
' you can select one of two mechanisms by which tapi will notify the
' application of telephony events: hidden window or event handle.
' in this example we are using hidden window.
' when the hidden window method of notification is used in a tapi application, tapi creates a hidden
' window for the application in the context of the thread that called lineinitializeex. if the thread that
' calls lineinitializeex does not retrieve and dispatch windows messages, the hidden window does not
' receive windows messages, and in turn, the callback function registered by the tapi application is not called.
' calling lineinitialize is equivalent to calling lineinitializeex with the lineinitializeexoption_usehiddenwindow
' option, so using lineinitialize instead of lineinitializeex results in the same behavior.
' make sure the thread that calls lineinitializeex contains a message loop that retrieves and
' dispatches messages for the hidden window.
lpfncallback = codeptr(linecallbackfunc) ' pointer to callback function
retval = lineinitializeex( hlineapp, _ ' lphlineapp lphlineapp - handle used in all tapi functions calls
hinstance, _ ' hinstance hinstance - exeordll instance handle
byval lpfncallback, _ ' linecallback lpfncallback - callback function to return asynchronous notifications
ztemp, _ ' lpcwstr lpszfriendlyappname - name to indicate who is calling tapi
lpnumdevs, _ ' lpdword lpdwnumdevs - number of available tapi devices, 0 to dwnumdevices-1
%hiapi, _ ' lpdword lpdwapiversion - negotiate tapi version
lip) ' lplineinitializeexparams lip - hidden window or event handle
' returns 0 if successful
if retval <> 0 then
select case cdwd(retval)
case %lineerr_invalappname : function = "invalid application name"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_inifilecorrupt : function = "the ini file is corrupted"
case %lineerr_invalpointer : function = "invalid pointer"
case %lineerr_reinit : function = "the application attempted to initialize tapi twice"
case %lineerr_nomem : function = "no memory available"
case %lineerr_invalparam : function = "invalid parameter"
case else : function = "undefined error"+str$(retval) + " = &h" + hex$(retval)
end select
exit function
end if
'================================
if lpnumdevs = 0 then
function = "no tapi devices found" 'no lines!
totdev = 0
else
totdev = lpnumdevs-1
end if
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function negotiateapiversions( totdev as dword, appapiver as dword ) as string
local retval as long
local dev as dword
local lxid as lineextensionid
function = " ' no problems
showtext "negotiating api ver for lines"
redim tapiline(totdev)
for dev = 0 to totdev ' negotiate and cache api versions for each line
retval = linenegotiateapiversion( hlineapp, dev, %loapi, %hiapi, tapiline(dev).negapiver, lxid) ' returns a long
'print #hdbg, str$(dev) + ", negotiated api ver=" + str$(hi(word,tapiline(dev).negapiver)) + "." + str$(lo(word,tapiline(dev).negapiver))
if retval <> 0 then
select case cdwd(retval)
case %lineerr_baddeviceid : function = "the device identifier provided is incorrect"
case %lineerr_nodriver : function = "no driver was found"
case %lineerr_incompatibleapiversion : function = "the api version is incompatible"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_invalapphandle : function = "the application handle was invalid"
case %lineerr_resourceunavail : function = "the resource is unavailable"
case %lineerr_invalpointer : function = "the pointer is invalid"
case %lineerr_uninitialized : function = "the parameter is uninitialized"
case %lineerr_nomem : function = "no memory is available"
case %lineerr_operationunavail : function = "the operation is unavailable"
case %lineerr_nodevice : tapiline(dev).zlinename = "device not found" : iterate ' handle this differently
case else : function = "undefined error"+str$(retval)
end select ' "device not found" can occur on a laptop with pcmcia card coming out of hibernation.
tapiline(dev).negapiver = 0 'no compatible api negotiated for this line
exit function
else ' print #hdbg, "extapiversions=" + str$(lxid.dwextensionid0) + str$(lxid.dwextensionid1) + str$(lxid.dwextensionid2) + str$(lxid.dwextensionid3)
' if the service provider for the specified dwdeviceid parameter supports provider-specific extensions,
' then, upon a successful negotiation, this structure is filled with the extension identifier of
' these extensions. this structure contains all zeros if the line provides no extensions. an application
' can ignore the returned parameter if it does not use extensions.
tapiline(dev).extapiver.dwextensionid0 = lxid.dwextensionid0 ' save extension version (dev-specific features) if available
tapiline(dev).extapiver.dwextensionid1 = lxid.dwextensionid1
tapiline(dev).extapiver.dwextensionid2 = lxid.dwextensionid2
tapiline(dev).extapiver.dwextensionid3 = lxid.dwextensionid3
if tapiline(dev).negapiver > appapiver then appapiver = tapiline(dev).negapiver ' highest ver found
end if
next
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function getlinedevcaps( totdev as dword ) as string
' this function queries a specified line device to determine its telephony capabilities.
' the returned data is valid for all addresses on the line device
' linegetdevcaps(byval hlineapp as dword, byval dwdeviceid as dword, byval dwapiversion as dword, byval dwextversion as dword, lplinedevcaps as linedevcaps)
local retval, lpdata, numelem as long
local dev as dword
local linecaps() as linedevcaps ' variable-length structures that tapi may throw at you
function = " ' no problems
showtext "getting line device info"
' note: dwneededsize will return zero if the memory size is too small to start with hence
' the test for %lineerr_structuretoosmall right after the function call. this test alone
' is not sufficient as the function may not return this error when the totalsize is still
' less than the neededsize! hence the test for both.
' retval is a long variable yet the constant is defined as a dword in tapi32.inc hence
' the need to convert retval to a dword. of course none of this is in msdn....
numelem = 1 ' starting memory size
dim linecaps(numelem-1) ' first attempt
linecaps(0).dwtotalsize = sizeof(linedevcaps) * numelem ' size of the udt
for dev = 0 to totdev
if tapiline(dev).negapiver = 0 then iterate ' not found in api negotiation
do
retval = linegetdevcaps( hlineapp, dev, tapiline(dev).negapiver, 0, linecaps(0) ) 'request tapi to fill udt with info
if cdwd(retval) = %lineerr_structuretoosmall or linecaps(0).dwtotalsize < linecaps(0).dwneededsize then ' increase buffer size
'print #hdbg, str$(dev) + ", numelem=" + str$(numelem) + ", totalsize=" + str$(linecaps(0).dwtotalsize) + ", neededsize=" + str$(linecaps(0).dwneededsize)
incr numelem ' once increased, just leave it that size for next device
if numelem > 20 then ' something else is wrong
function = "memory increased x"+str$(numelem)+" and still not big enough for linecaps!"
exit function
end if '
redim linecaps(numelem-1) ' assign more memory
linecaps(0).dwtotalsize = sizeof(linedevcaps) * numelem
else ' print #hdbg, str$(dev) + ", numelem=" + str$(numelem) + ", totalsize=" + str$(linecaps(0).dwtotalsize) + ", neededsize=" + str$(linecaps(0).dwneededsize)
exit loop
end if
loop
'================================
if retval <> 0 then
select case cdwd(retval)
case %lineerr_structuretoosmall : function = "the structure is too small" ' buffer size is too small
case %lineerr_baddeviceid : function = "bad device id provided"
case %lineerr_nomem : function = "no memory is available"
case %lineerr_incompatibleapiversion : function = "api version is incompatible"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_incompatibleextversion : function = "extension version is incompatible"
case %lineerr_resourceunavail : function = "the resource is unavailable"
case %lineerr_invalapphandle : function = "the application handle is invalid"
case %lineerr_invalpointer : function = "invalid pointer"
case %lineerr_uninitialized : function = "the parameter is uninitialized"
case %lineerr_nodriver : function = "no driver was found"
case %lineerr_operationunavail : function = "the operation is unavailable"
case %lineerr_nodevice : function = "no device was found"
case else : function = "undefined error"+str$(retval)
end select
exit function
end if
'================================
'store udt info in class local variables
tapiline(dev).currentlineid = dev
tapiline(dev).zlinename = gettapistructstring(varptr(linecaps(0)), linecaps(0).dwlinenameoffset, linecaps(0).dwlinenamesize)
tapiline(dev).zproviderinfo = gettapistructstring(varptr(linecaps(0)), linecaps(0).dwproviderinfooffset, linecaps(0).dwproviderinfosize)
tapiline(dev).zswitchinfo = gettapistructstring(varptr(linecaps(0)), linecaps(0).dwswitchinfooffset, linecaps(0).dwswitchinfosize)
tapiline(dev).permanentlineid = linecaps(0).dwpermanentlineid
tapiline(dev).stringformat = linecaps(0).dwstringformat
tapiline(dev).numaddresses = linecaps(0).dwnumaddresses
tapiline(dev).maxdatarate = linecaps(0).dwmaxrate
tapiline(dev).bearermodes = linecaps(0).dwbearermodes
tapiline(dev).addressmodes = linecaps(0).dwaddressmodes
tapiline(dev).mediamodes = linecaps(0).dwmediamodes
tapiline(dev).generatetonemaxnumfreq = linecaps(0).dwgeneratetonemaxnumfreq
tapiline(dev).generatetonemodes = linecaps(0).dwgeneratetonemodes
tapiline(dev).numterminals = linecaps(0).dwnumterminals
'================================
if %linebearermode_voice and tapiline(dev).bearermodes then 'check if line supports making voice calls
if %linemediamode_interactivevoice and tapiline(dev).mediamodes then
tapiline(dev).linesupportsvoicecalls = 1
end if
end if
'================================
combobox add hdlg, 98, str$(dev) + " - " + trim$(tapiline(dev).zlinename) ' add the device to the combobox
'================================
next
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function gettapistructstring(byval ptrtapistruct as long, byval offset as long, byval length as long) as string
local stemp as string
function = "
if length then ' handle erroneous input
if offset then '
stemp = space$(length)
copymemory byval strptr(stemp), byval ptrtapistruct+offset, length
function = stemp
end if
end if
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function deviceinfo( dev as long ) as string
local stemp, smsg as string
smsg = "
smsg = smsg + "tapi line name: " + tapiline(dev).zlinename + $crlf
smsg = smsg + "tapi line: #" + str$(tapiline(dev).currentlineid) + $crlf '
smsg = smsg + "tapi provider info: " + tapiline(dev).zproviderinfo + $crlf
smsg = smsg + "tapi switch info: " + tapiline(dev).zswitchinfo + $crlf
smsg = smsg + $crlf + "permanent line id: " + str$(tapiline(dev).permanentlineid) + $crlf
select case tapiline(dev).stringformat
case %stringformat_ascii
smsg = smsg + "string format: stringformat_ascii" + $crlf
case %stringformat_dbcs
smsg = smsg + "string format: stringformat_dbcs" + $crlf
case %stringformat_unicode
smsg = smsg + "string format: stringformat_unicode" + $crlf
case %stringformat_binary
smsg = smsg + "string format: stringformat_binary" + $crlf
case else
end select
smsg = smsg + "number of addresses associated with this line: " + str$(tapiline(dev).numaddresses) + $crlf
smsg = smsg + "max data rate: " + str$(tapiline(dev).maxdatarate) + $crlf
smsg = smsg + $crlf + "bearer modes supported:" + $crlf
if %linebearermode_voice and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_voice" + $crlf
if %linebearermode_speech and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_speech" + $crlf
if %linebearermode_data and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_data" + $crlf
if %linebearermode_altspeechdata and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_altspeechdata" + $crlf
if %linebearermode_multiuse and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_multiuse" + $crlf
if %linebearermode_noncallsignaling and tapiline(dev).bearermodes then smsg = smsg + $tab + "linebearermode_noncallsignaling" + $crlf
smsg = smsg + $crlf + "address modes supported:" + $crlf
if tapiline(dev).addressmodes and %lineaddressmode_addressid then smsg = smsg + $tab + "lineaddressmode_addressid" + $crlf
if tapiline(dev).addressmodes and %lineaddressmode_dialableaddr then smsg = smsg + $tab + "lineaddressmode_dialableaddr" + $crlf
smsg = smsg + $crlf + "media modes supported:" + $crlf
if %linemediamode_adsi and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_adsi" + $crlf
if %linemediamode_automatedvoice and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_automatedvoice" + $crlf
if %linemediamode_datamodem and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_datamodem" + $crlf
if %linemediamode_digitaldata and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_digitaldata" + $crlf
if %linemediamode_g3fax and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_g3fax" + $crlf
if %linemediamode_g4fax and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_g4fax" + $crlf
if %linemediamode_interactivevoice and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_interactivevoice" + $crlf
if %linemediamode_mixed and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_mixed" + $crlf
if %linemediamode_tdd and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_tdd" + $crlf
if %linemediamode_teletex and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_teletex" + $crlf
if %linemediamode_telex and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_telex" + $crlf
if %linemediamode_unknown and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_unknown" + $crlf
if %linemediamode_videotex and tapiline(dev).mediamodes then smsg = smsg + $tab + "linemediamode_videotex" + $crlf
smsg = smsg + $crlf + "line tone generation supported: " + str$(tapiline(dev).generatetonemaxnumfreq) + $crlf
if tapiline(dev).generatetonemaxnumfreq then 'show if tone generation is supported
if %linetonemode_beep and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_beep" + $crlf
if %linetonemode_billing and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_billing" + $crlf
if %linetonemode_busy and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_busy" + $crlf
if %linetonemode_custom and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_custom" + $crlf
if %linetonemode_ringback and tapiline(dev).generatetonemodes then smsg = smsg + $tab + "linetonemode_ringback" + $crlf
end if
smsg = smsg + "number of terminals for this line: " + str$(tapiline(dev).numterminals) + $crlf
function = smsg '
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function deviceconfigdialog( byval dev as long, byval ownerhwnd as long ) as string
local ztemp as asciiz*255
local retval as long
function = " ' no problems
ztemp = " ' highest level of config available
retval = lineconfigdialog( tapiline(dev).currentlineid, ownerhwnd, ztemp)
if retval <> 0 then
select case cdwd(retval)
case %lineerr_baddeviceid : function = "the device id is incorrect"
case %lineerr_nomem : function = "not enough memory is available"
case %lineerr_inuse : function = "the line is in use"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_invaldeviceclass : function = "the device class is invalid"
case %lineerr_resourceunavail : function = "the resource is unavailable"
case %lineerr_invalparam : function = "the parameter is invalid"
case %lineerr_uninitialized : function = "the parameter is uninitialized"
case %lineerr_invalpointer : function = "the pointer is invalid"
case %lineerr_operationunavail : function = "the operation is unavailable"
case %lineerr_nodevice : function = "the device was not found"
case else : function = "undefined error"+str$(retval) + " = &h" + hex$(retval)
end select
end if
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function dialingpropertiesdialog(byval dev as long, byval ownerhwnd as long, appapiver as dword ) as string
local retval as long
function = " ' no problems
retval = linetranslatedialog(hlineapp, tapiline(dev).currentlineid, appapiver, ownerhwnd, tapiline(dev).znumtodial)
if retval <> 0 then
select case cdwd(retval)
case %lineerr_baddeviceid : function = "the device id is incorrect"
case %lineerr_invalparam : function = "the parameter is invalid"
case %lineerr_incompatibleapiversion : function = "the api version is incompatible"
case %lineerr_invalpointer : function = "the pointer is invalid"
case %lineerr_inifilecorrupt : function = "the ini file is corrupt"
case %lineerr_nodriver : function = "the driver was not found"
case %lineerr_inuse : function = "the line is in use"
case %lineerr_nomem : function = "not enough memory is available"
case %lineerr_invaladdress : function = "the address is invalid"
case %lineerr_invalapphandle : function = "the application handle is invalid"
case %lineerr_operationfailed : function = "the operation failed"
case else : function = "unknown return value=" + str$(retval) + " = &h" + hex$(retval)
end select
end if
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function openline( dev as long ) as string ' hline is global
local privileges, mediamodes as long
local retval as long
local dwfncallback as dword ptr
' dwprivileges defines which privileges your application is
' interested in obtaining. possible values are linecallprivilege_none,
' linecallprivilege_monitor, and linecallprivilege_owner. if you do not need
' any stuff on incoming calls, simply put linecallprivilege_none there. in
' case you really want to deal with incoming/outgoing calls, specify the
' appropriate privilege level. the dwmediamodes parameter is used only if
' linecallprivilege_owner is set. it declares which media modes are of
' interest for your application.
privileges = %linecallprivilege_none
mediamodes = %linemediamode_interactivevoice
'================================
function = " ' no problems
showtext "opening line #" + str$(dev)
if hline <> 0 then ' check line is not allready open
function = "line allready open on this device"
exit function
end if
'================================
dwfncallback = codeptr(linecallbackfunc) ' pointer to callback function
'================================
'n.b. you should pass the pointer to linecallbackfunc in lineinitializeex and 0 in lineopen.
' the dwcallbackinstance parameter is not a pointer to a callback function,
' but user-instance data. apparently, the vb code is using it to pass a
' pointer to a class and then doing some tweaking to be able to call the
' members of the class using a dotted syntax.
retval = lineopen( hlineapp, _ '
dev, _ ' dword dwdeviceid
hline, _ ' lphline lphline - line handle for the corresponding opened line device
tapiline(dev).negapiver, _ ' dword dwapiversion
byval 0, _ ' dword dwextversion
byval 0, _ ' dword_ptr dwcallbackinstance - user instance data
privileges, _ ' dword dwprivileges
mediamodes, _ ' dword dwmediamodes
byval 0& ) ' lplinecallparams const lpcallparams, usually set to null
'================================
if retval < 0 then ' zero indicates success. a negative error number indicates that an error occurred
select case cdwd(retval)
case %lineerr_allocated : function = "the line cannot be opened, serial port may be in use"
case %lineerr_linemapperfailed : function = "no lines found matching requirements specified in lpcallparams"
case %lineerr_baddeviceid : function = "the device id is incorrect"
case %lineerr_nodriver : function = "the driver was not found"
case %lineerr_incompatibleapiversion : function = "the api version is incompatible"
case %lineerr_nomem : function = "not enough memory is available"
case %lineerr_operationfailed : function = "the operation failed"
case %lineerr_invalapphandle : function = "the application handle is invalid"
case %lineerr_resourceunavail : function = "he resource is unavailable"
case %lineerr_invalmediamode : function = "the media mode is invalid"
case %lineerr_structuretoosmall : function = "the structure is too small"
case %lineerr_invalpointer : function = "the pointer is invalid"
case %lineerr_uninitialized : function = "lthe parameter is uninitialized"
case %lineerr_invalprivselect : function = "the priviledges are invalid"
case %lineerr_reinit : function = "the application attempted to initialize tapi twice"
case %lineerr_nodevice : function = "the device was not found"
case %lineerr_operationunavail : function = "the operation is unavailable"
case else : function = "unknown return value=" + str$(retval) + " = &h" + hex$(retval)
end select
end if ' print #hdbg, "lineopen() retval="+str$(retval)+"(zero indicates success), tapiver="+str$(tapiline(dev).negapiver)
'================================
end function
'¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
function processcanonical( hlineapp as long, dev as long ) as string ' hline is global
'a common practice is that phone numbers are stored in canonical format,
'which includes international the dialing code, area code, and so forth. an
'actual call may use a modified form of this number depending on current
'location, local or long distance call, and so forth. therefore, the
'initial phone number should be translated into a dialable form. to proceed
'with this task, you need to call linetranslateaddress. similar to
'linegetdevcaps, you might be required to call this function several times
'until a correctly sized memory block is passed to keep its output.
'the canonical address format is:
' + country/regioncode ( areacode ) subscribernumber
'for example, this is how you would enter a us number in canonical address format:
'+1 (425) 555-0100
local retval, numelem as long
local trnsadd() as linetranslateoutput
function = " ' no problems
showtext "processing canonical number"
if tapiline(dev).negapiver = 0 then ' not found in api negotiation
function = "th
Comment