Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TE_DETECTTONE in VB

0 views
Skip to first unread message

Leandro

unread,
Jul 31, 2005, 2:58:52 PM7/31/05
to
Greetings,
I am developing a simple application in VB where desire to monitor some
tones of the line. The code is down, however I am I always have an error.
I thank any aid
========================================================
Dim gobjTapi As TAPI
Const TAPI3_ALL_TAPI_EVENTS = _
TE_ACDGROUP Or _
TE_ADDRESS Or _
TE_AGENT Or _
TE_AGENTHANDLER Or _
TE_AGENTSESSION Or _
TE_CALLHUB Or _
TE_CALLINFOCHANGE Or _
TE_CALLMEDIA Or _
TE_CALLNOTIFICATION Or _
TE_CALLSTATE Or _
TE_DIGITEVENT Or _
TE_GENERATEEVENT Or _
TE_PRIVATE Or _
TE_QOSEVENT Or _
TE_QUEUE Or _
TE_REQUEST Or _
TE_TAPIOBJECT Or _
TE_TONEEVENT
Dim WithEvents gobjTapiWithEvents As TAPI
Dim objCollAddresses As ITCollection
Dim gobjAddress As ITAddress
Dim glRegistrationToken As Long
Dim objCall As ITAddress

Public teste1 As ITLegacyCallMediaControl2
Public teste2 As ITDetectTone


Private Sub Form_Load()
'inicia a tapi
iniTAPI
'procura um endereço que de suporte
ListaDisp
'Notificação
Notificacao

Set teste2 = CreateDetectToneObject
teste2.AppSpecific = 1
teste2.Duration = 10
teste2.Frequency(0) = 941
teste2.Frequency(1) = 1209


End Sub


Public Sub ListaDisp()

Dim nSelectedType As Long
Dim lLoop As Long
Dim objCrtAddress As ITAddress
Dim lAddrTypes As Long
Dim objMediaSupport As ITMediaSupport
Dim objAddressCaps As ITAddressCapabilities
Dim lMediaTypes As Long


Set objCollAddresses = gobjTapi.Addresses

disp.Clear

For a = 1 To objCollAddresses.Count

Set objCrtAddress = objCollAddresses.Item(a)

If objCrtAddress.ServiceProviderName <> "kmddsp.tsp" And _
objCrtAddress.ServiceProviderName <> "ndptsp.tsp" And _
objCrtAddress.ServiceProviderName <> "ipconf.tsp" And _
objCrtAddress.ServiceProviderName <> "h323.tsp" Then

Set objMediaSupport = objCrtAddress
lMediaTypes = objMediaSupport.MediaTypes

If lMediaTypes And TAPIMEDIATYPE_AUDIO Then

Set objAddressCaps = objCrtAddress

On Error Resume Next
Dim objITTerminalSupport As ITTerminalSupport
Set objITTerminalSupport = objAddressCaps

If Not (objITTerminalSupport Is Nothing) Then
'não é um datamodem
disp.AddItem objCrtAddress.AddressName
End If

Set objITTerminalSupport = Nothing
On Error GoTo 0
End If
End If

Next
disp.ListIndex = 0

End Sub


Public Sub iniTAPI()

If gobjTapi Is Nothing Then

Set gobjTapi = New TAPI
Call gobjTapi.Initialize
gobjTapi.EventFilter = TAPI3_ALL_TAPI_EVENTS
Set gobjTapiWithEvents = gobjTapi

End If

End Sub


Private Sub Notificacao()

If glRegistrationToken <> 0 Then
Call gobjTapi.UnregisterNotifications(glRegistrationToken)
glRegistrationToken = 0
End If

Dim fOwner, fMonitor As Boolean
Dim lMediaTypes, lCallbackInstance As Long
fOwner = True 'se terá chamadas entrantes
fMonitor = True 'se monitorará chamadas
lMediaTypes = TAPIMEDIATYPE_DATAMODEM
lCallbackInstance = 1

Set objCollAddresses = gobjTapi.Addresses
Debug.Print disp.Text
Set gobjAddress = objCollAddresses.Item(PegaDisp(disp.Text,
objCollAddresses))
Set objCollAddresses = Nothing

On Error Resume Next

glRegistrationToken = gobjTapi.RegisterCallNotifications( _
gobjAddress, fMonitor, fOwner, lMediaTypes, lCallbackInstance)

If Err.Number <> 0 Then
Dim strMsg As String
strMsg = "O registro de Notificação Falhou."
MsgBox (strMsg)
End If

End Sub


Private Sub Ligar_Click()

'On Error GoTo Erro:

If Ligar.Caption = "Ligar" Then

Debug.Print "Efetivamos a ligação"
'Efetuando uma ligação
If Text1.Text = "" Or disp.Text = "" Then
MsgBox "Selecione um dispositivo e digite o número"
Exit Sub
End If
Ligar.Caption = "Desligar"

Set gobjCall = gobjAddress.CreateCall(dest, LINEADDRESSTYPE_PHONENUMBER,
TAPIMEDIATYPE_DATAMODEM)
'Call SelecionaTerminal
gobjCall.Connect (False)

Else 'desligamos
Debug.Print "Finalizamos a ligação"

End If

Exit Sub
Erro:
Ligar.Caption = "Ligar"
MsgBox Err.Description
Err.Clear
End Sub

'Selecionamos o dispositivo pelo seu nome
Public Function PegaDisp(nome As String, objCollAddresses As ITCollection)
Dim a As Long
Dim objCrtAddress As ITAddress

For a = 1 To objCollAddresses.Count
Set objCrtAddress = objCollAddresses.Item(a)
If objCrtAddress.AddressName = nome Then
PegaDisp = a 'encontramos
Exit Function
End If
Next
PegaDisp = -1

End Function

Private Sub Finalizar()
'MATAMOS A APLICAÇÃO
If Not gobjTapi Is Nothing Then
If glRegistrationToken <> 0 Then
Call gobjTapi.UnregisterNotifications(glRegistrationToken)
End If
gobjTapi.Shutdown
End If
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Finalizar
End Sub

Public Sub SelecionaTerminal()
On Error GoTo ErroRotina

'query for ITBasicCallControl, the call control interface
Dim objCallControl As ITBasicCallControl
Set objCallControl = gobjReceivedCallInfo

'query ITTerminalSupport from Address object
Dim objTerminalSupport As ITTerminalSupport
Set objTerminalSupport = gobjAddress

Dim objTerminal As ITTerminal
Set objTerminal = objTerminalSupport.GetDefaultStaticTerminal(MediaType,
Dir)

'release not needed objects
Set objTerminalSupport = Nothing

'Select the terminal before answering
'we'll need the ITStreamControl interface for doing this.

Dim objStreamControl As ITStreamControl
Set objStreamControl = objCallControl

If Not (objStreamControl Is Nothing) Then
Dim objITCollStreams As ITCollection

Set objITCollStreams = objStreamControl.Streams

Dim nIndex As Long, objCrtStream As ITStream

For nIndex = 1 To objITCollStreams.Count
Set objCrtStream = objITCollStreams.Item(nIndex)
If objCrtStream.MediaType = lMediaType Then
If objCrtStream.Direction = Dir Then
Call objCrtStream.SelectTerminal(objTerminal)
End If
End If
Set objCrtStream = Nothing
Next nIndex

Set objITCollStreams = Nothing
Set objStreamControl = Nothing
End If

ErroRotina:

Debug.Print "Erro ao selecionar um terminal"

End Sub

Private Sub gobjTapiWithEvents_Event(ByVal TapiEvent As TAPI3Lib.TAPI_EVENT,
ByVal pEvent As Object)
Select Case TapiEvent

Case TE_PHONEEVENT
Debug.Print "CASE TE_PHONEEVENT"
Case TE_TONEEVENT
Debug.Print "CASE TE_TONEEVENT"
Case TE_ACDGROUP
Debug.Print "CASE TE_ACDGROUP"
Case TE_AGENT
Debug.Print "CASE TE_AGENT"
Case TE_AGENTHANDLER
Debug.Print "CASE TE_AGENTHANDLER"
Case TE_AGENTSESSION
Debug.Print "CASE TE_AGENTSESSION"
Case TE_CALLHUB
Debug.Print "CASE TE_CALLHUB"
Case TE_CALLMEDIA
Debug.Print "CASE TE_CALLMEDIA"
Case TE_GENERATEEVENT
Debug.Print "CASE TE_GENERATEEVENT"
Case TE_PRIVATE
Debug.Print "CASE TE_PRIVATE"
Case TE_QOSEVENT
Debug.Print "CASE TE_QOSEVENT"
Case TE_QUEUE
Debug.Print "CASE TE_QUEUE"
Case TE_REQUEST
Debug.Print "CASE TE_REQUEST"
Case TE_TAPIOBJECT
Debug.Print "CASE TE_TAPIOBJECT"
Case TE_CALLNOTIFICATION
Debug.Print "CASE TE_CALLNOTIFICATION"
Case TE_CALLINFOCHANGE
Debug.Print "CASE TE_CALLINFOCHANGE"
Case TE_CALLSTATE
Debug.Print "CASE TE_CALLSTATE"
Case TE_DIGITEVENT
Debug.Print "CASE TE_DIGITEVENT"
Case TE_ADDRESS
Debug.Print "CASE TE_ADDRESS"
Case TE_TONEEVENT

Debug.Print "CASE TE_TONEEVENT"
MsgBox "Sucess OPA OPA OPA"

Case Else
Debug.Print "EVENTO SEM CODIGO"
End Select

Set pEvent = Nothing

End Sub


Andreas Marschall [MVP TAPI]

unread,
Jul 31, 2005, 11:28:14 PM7/31/05
to
"Leandro" <lea...@livremail.com.br> schrieb im Newsbeitrag
news:upBskHgl...@TK2MSFTNGP10.phx.gbl...

> I am developing a simple application in VB where desire to monitor some
> tones of the line. The code is down, however I am I always have an error.


Leandro,
what is your actual problem?
Where do you get what error?

What device / TSP are you using?
What OS/SP are you using?

It is recommended to post TAPI questions only to the managed TAPI newsgroup:
microsoft.public.win32.programmer.tapi
See my TAPI and TSPI FAQ:
Q: What newsgroups are covering TAPI ?
http://www.i-b-a-m.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm#_Q:_What_newsgroups

What does your issue have to do with RAS?
What does your issue have to do with Win95?
Win95 surely doesn't support TAPI3 which you are using.

--
Best Regards
Andreas Marschall
Microsoft MVP for TAPI / Windows SDK
TAPI / TSP Developer and Tester
http://www.I-B-A-M.de/Andreas_Marschall's_TAPI_and_TSPI_FAQ.htm
* Please post all messages and replies to the newsgroup so all may
* benefit from the discussion. Private mail is usually not replied to.
* This posting is provided "AS IS" with no warranties, and confers no rights.

0 new messages