?? dtmf.vb
字號:
TranslateDigitMode = "LINEDIGITMODE_DTMFEND"
Case Else
TranslateDigitMode = "Unknown Digit Mode = " & nDigitMode & " !"
End Select
End Function
Function TranslateGenerateTerm(ByRef lGenerationTermination As Long) As String
Select Case lGenerationTermination
Case LINEGENERATETERM_DONE
TranslateGenerateTerm = "LINEGENERATETERM_DONE"
Case LINEGENERATETERM_CANCEL
TranslateGenerateTerm = "LINEGENERATETERM_CANCEL"
Case Else
TranslateGenerateTerm = "Unknown GenerationTermination value = " & lGenerationTermination & " !"
End Select
End Function
Function TranslateCallMediaEvent(ByRef lCallMediaEvent As Long) As String
Select Case lCallMediaEvent
Case JulMar.Tapi3.CALL_MEDIA_EVENT.CME_NEW_STREAM
TranslateCallMediaEvent = "CME_NEW_STREAM"
Case JulMar.Tapi3.CALL_MEDIA_EVENT.CME_STREAM_ACTIVE
TranslateCallMediaEvent = "CME_STREAM_ACTIVE"
Case JulMar.Tapi3.CALL_MEDIA_EVENT.CME_STREAM_FAIL
TranslateCallMediaEvent = "CME_STREAM_FAIL"
Case JulMar.Tapi3.CALL_MEDIA_EVENT.CME_STREAM_INACTIVE
TranslateCallMediaEvent = "CME_STREAM_INACTIVE"
Case JulMar.Tapi3.CALL_MEDIA_EVENT.CME_STREAM_NOT_USED
TranslateCallMediaEvent = "CME_STREAM_NOT_USED"
Case JulMar.Tapi3.CALL_MEDIA_EVENT.CME_TERMINAL_FAIL
TranslateCallMediaEvent = "CME_TERMINAL_FAIL"
Case Else
TranslateCallMediaEvent = "Unknown CallMediaEvent = " & lCallMediaEvent & " !"
End Select
End Function
Function TranslateCallMediaEventCause(ByRef lCallMediaEventCause As Long) As String
Select Case lCallMediaEventCause
Case JulMar.Tapi3.CALL_MEDIA_EVENT_CAUSE.CMC_BAD_DEVICE
TranslateCallMediaEventCause = "CMC_BAD_DEVICE"
Case JulMar.Tapi3.CALL_MEDIA_EVENT_CAUSE.CMC_CONNECT_FAIL
TranslateCallMediaEventCause = "CMC_CONNECT_FAIL"
Case JulMar.Tapi3.CALL_MEDIA_EVENT_CAUSE.CMC_LOCAL_REQUEST
TranslateCallMediaEventCause = "CMC_LOCAL_REQUEST"
Case JulMar.Tapi3.CALL_MEDIA_EVENT_CAUSE.CMC_MEDIA_RECOVERED
TranslateCallMediaEventCause = "CMC_MEDIA_RECOVERED"
Case JulMar.Tapi3.CALL_MEDIA_EVENT_CAUSE.CMC_MEDIA_TIMEOUT
TranslateCallMediaEventCause = "CMC_MEDIA_TIMEOUT"
Case JulMar.Tapi3.CALL_MEDIA_EVENT_CAUSE.CMC_REMOTE_REQUEST
TranslateCallMediaEventCause = "CMC_REMOTE_REQUEST"
Case JulMar.Tapi3.CALL_MEDIA_EVENT_CAUSE.CMC_UNKNOWN
TranslateCallMediaEventCause = "CMC_UNKNOWN"
Case Else
TranslateCallMediaEventCause = "Unknown CallMediaEventCause = " & lCallMediaEventCause & " !"
End Select
End Function
'Looks in combo with addresses and sees what address was selected.
'Looks in the related "data" field and finds out the index memorized for
'that address. This index represents the index in the objTapi.objcollAddresses.
'Return 0 if no address is selected.
'Otherwise return its index, which should be a value between 1 and Addresses.Count
Private Function FindOriginationAddressIndex() As Integer
On Error Resume Next 'this will catch errors
Dim nResult As Integer
Dim indexAddr As Integer
'prepare return value
FindOriginationAddressIndex = 0
If cmbAddresses.Items.Count > 0 Then
'read data field of selected combo item
indexAddr = VB6.GetItemData(cmbAddresses, cmbAddresses.SelectedIndex)
nResult = PrintT3Result("FindOriginationAddressIndex: retrieve selected address from combo")
If nResult = NO_ERROR Then
FindOriginationAddressIndex = indexAddr
End If
End If
Exit Function
End Function
'Returns the last tapi3 error that caused the function to fail,
'or NO_ERROR if there were no tapi3 failures.
'(i.e.: don't return error codes produced inside error handlers)
Private Function InitializeTapiObjects() As Integer
On Error Resume Next
Dim nResult As Integer
If mbInitialized = True Then
InitializeTapiObjects = NO_ERROR
Exit Function
End If
txtStatus.Text = txtStatus.Text & Chr(13) & Chr(10)
txtStatus.Text = txtStatus.Text & "Tapi initialization: start..."
txtStatus.SelectionStart = Len(txtStatus.Text)
txtStatus.SelectionLength = 0
Me.Refresh()
'call Initialize; this must be called before
'any other tapi functions are called.
mobjTapi.Initialize()
nResult = PrintT3Result("objTapi.Initialize")
If nResult <> NO_ERROR Then
PrintT3Result("Release objTapi")
GoTo ErrorExit
End If
NormalExit:
txtStatus.Text = txtStatus.Text & Chr(13) & Chr(10)
txtStatus.Text = txtStatus.Text & "Tapi initialization: finished."
txtStatus.SelectionStart = Len(txtStatus.Text)
txtStatus.SelectionLength = 0
Me.Refresh()
mbInitialized = True
InitializeTapiObjects = NO_ERROR
Exit Function
ErrorExit:
txtStatus.Text = txtStatus.Text & Chr(13) & Chr(10)
txtStatus.Text = txtStatus.Text & "Tapi initialization: failed."
txtStatus.SelectionStart = Len(txtStatus.Text)
txtStatus.SelectionLength = 0
Me.Refresh()
mbInitialized = False
InitializeTapiObjects = nResult
Exit Function
End Function
Private Function ReleaseAllMembers() As Integer
If mbInitialized = False Then
Exit Function
End If
'release all member objects
mobjCall = Nothing
Call ReleaseAudioTerminals(mvarArrAudioTerminals)
mobjOrigAddress = Nothing
System.Diagnostics.Debug.Assert((Not (mobjTapi Is Nothing)), "")
mobjTapi.Shutdown()
mobjTapi = Nothing
End Function
'
'This function receives a call object and an array with the terminals
'to be selected;
'- it first queries the stream control object from the call object;
'- it then selects each terminal on a stream that matches
'the media type and the terminal direction.
'
'If an error is encountered, the function finishes right away and returns
'that error.
'
'Notes:
' 1 - the received array might contain "Null" terminals (the value Nothing)
'in its items - so we need to check the termials before using them.
' 2 - ITStreamControl is not supported on all addresses (depending on the TSP)
'therefore querying for this interface might fail.
'
Public Function SelectTerminalsOnStreams(ByRef objITBCC As JulMar.Tapi3.TCall, ByRef varArrTerminals As Object) As TestError
On Error Resume Next
Dim MyError As TestError
SelectTerminalsOnStreams = TestError.TErr_Ok
Dim nTermIndex As Integer
'get streams collection object
Dim objITCollStreams() As JulMar.Tapi3.TStream
objITCollStreams = objITBCC.Streams
MyError = PrintT3Result("objITStreamControl.Streams")
If MyError <> 0 Then
SelectTerminalsOnStreams = TestError.TErr_Fail
Exit Function
End If
'find matching stream for each terminal and select the terminal
Dim objCrtITStream As JulMar.Tapi3.TStream
For nTermIndex = LBound(varArrTerminals) To UBound(varArrTerminals)
If Not (varArrTerminals(nTermIndex) Is Nothing) Then
'find matching stream
MyError = FindMatchingStream(objITCollStreams, varArrTerminals(nTermIndex), objCrtITStream)
If MyError = TestError.TErr_Fail Then
SelectTerminalsOnStreams = TestError.TErr_Fail
Exit Function
End If
'select terminal
Call objCrtITStream.SelectTerminal(varArrTerminals(nTermIndex))
MyError = PrintT3Result("objCrtITStream.SelectTerminal")
If MyError <> 0 Then
SelectTerminalsOnStreams = TestError.TErr_Fail
Exit Function
End If
End If
Next nTermIndex
End Function
'
'This function searches in objITCollStreams the first stream that matches
'the "media type" and "direction" specified by objITTerminal;
'if it finds such a stream, it returns a reference to it;
'otherwise it returns "Nothing"
'
Private Function FindMatchingStream(ByVal objITCollStreams() As JulMar.Tapi3.TStream, ByVal objITTerminal As JulMar.Tapi3.TTerminal, ByRef robjITStream As JulMar.Tapi3.TStream) As TestError
On Error Resume Next
Dim MyError As TestError
FindMatchingStream = TestError.TErr_Ok
'initialize return value
'UPGRADE_NOTE: Object robjITStream may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
robjITStream = Nothing
'read media type and direction from terminal
Dim lMediaType As Integer
Dim lDirection As JulMar.Tapi3.TERMINAL_DIRECTION
lMediaType = objITTerminal.MediaType
MyError = PrintT3Result("objITTerminal.MediaType")
If MyError <> 0 Then
FindMatchingStream = TestError.TErr_Fail
Exit Function
End If
lDirection = objITTerminal.Direction
MyError = PrintT3Result("objITTerminal.Direction")
If MyError <> 0 Then
FindMatchingStream = TestError.TErr_Fail
Exit Function
End If
'search stream that matches this media and direction
Dim nCount, nIndex As Integer
Dim objCrtStream As JulMar.Tapi3.TStream
Dim lCrtMediaType As Integer
Dim lCrtDirection As JulMar.Tapi3.TERMINAL_DIRECTION
nCount = objITCollStreams.Length
MyError = PrintT3Result("objITCollStreams.Count")
If MyError <> 0 Then
FindMatchingStream = TestError.TErr_Fail
Exit Function
End If
For nIndex = 0 To nCount - 1
objCrtStream = objITCollStreams(nIndex)
MyError = PrintT3Result("objITCollStreams.Item(nIndex)")
If MyError <> 0 Then
FindMatchingStream = TestError.TErr_Fail
Exit Function
End If
lCrtMediaType = objCrtStream.MediaType
MyError = PrintT3Result("objCrtStream.MediaType")
If MyError <> 0 Then
FindMatchingStream = TestError.TErr_Fail
Exit Function
End If
lCrtDirection = objCrtStream.Direction
MyError = PrintT3Result("objCrtStream.Direction")
If MyError <> 0 Then
FindMatchingStream = TestError.TErr_Fail
Exit Function
End If
If lMediaType = lCrtMediaType And lDirection = lCrtDirection Then
'set return value
robjITStream = objCrtStream
PrintT3Result("Set robjITStream = objCrtStream")
'quit loop, we're done
Exit For
End If
Next nIndex
Exit Function
End Function
'Reads the last error from Err object
'If Err.Number = 0, it means that no error had occurred.
'Returns the error code found in Err.Number when this function is called.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -