|
|
etDialAnswer Sample Program Source Code
Const ONE_SECOND = 0.000011574
Dim State As String
Dim gsPath As String
Dim gsWavPath As String
Dim gdtConnected As Date
Private Sub UpdatePhoneDisplay()
If Not etLine1.PhoneAvailable Then
CheckPhone.Enabled = False
PictureHandsetOnHook.Visible = False
PictureHandsetOffHook.Visible = False
FrameSpeakerphone.Enabled = False
OptionSPOnHook.Enabled = False
OptionSPOffHook.Enabled = False
LabelSPVolume.Enabled = False
TextSPVolume.Enabled = False
CommandSPVolumeApply.Enabled = False
LabelSPGain.Enabled = False
TextSPGain.Enabled = False
CommandSPGainApply.Enabled = False
Else
CheckPhone.Enabled = True
If etPhone1.HandsetOnHook Then
PictureHandsetOnHook.Visible = True
PictureHandsetOffHook.Visible = False
Else
PictureHandsetOnHook.Visible = False
PictureHandsetOffHook.Visible = True
End If
FrameSpeakerphone.Enabled = True
etPhone1.DeviceID = etLine1.PhoneID
If (CheckPhone.Value = 1) And (Not etPhone1.DeviceActive) Then
etPhone1.DeviceActive = True
End If
If Not etPhone1.SpeakerphoneAvailable Then
FrameSpeakerphone.Enabled = False
OptionSPOnHook.Enabled = False
OptionSPOffHook.Enabled = False
LabelSPVolume.Enabled = False
TextSPVolume.Enabled = False
CommandSPVolumeApply.Enabled = False
LabelSPGain.Enabled = False
TextSPGain.Enabled = False
CommandSPGainApply.Enabled = False
Else
FrameSpeakerphone.Enabled = True
OptionSPOnHook.Enabled = True
OptionSPOffHook.Enabled = True
OptionSPOnHook.Value = etPhone1.SpeakerphoneOnHook
OptionSPOffHook.Value = etPhone1.SpeakerphoneMicrophoneAndSpeaker
If etPhone1.SpeakerphoneVolumeAvailable Then
TextSPVolume.Text = Str(etPhone1.SpeakerphoneVolume)
LabelSPVolume.Enabled = True
TextSPVolume.Enabled = True
CommandSPVolumeApply.Enabled = True
Else
LabelSPVolume.Enabled = False
TextSPVolume.Enabled = False
CommandSPVolumeApply.Enabled = False
End If
If etPhone1.SpeakerphoneGainAvailable Then
TextSPGain.Text = Str(etPhone1.SpeakerphoneGain)
LabelSPGain.Enabled = True
TextSPGain.Enabled = True
CommandSPGainApply.Enabled = True
Else
LabelSPGain.Enabled = False
TextSPGain.Enabled = False
CommandSPGainApply.Enabled = False
End If
End If
End If
End Sub
Private Sub CheckActive_Click()
If CheckActive.Value = 0 Then
If etLine1.DeviceActive Then
If etPhone1.DeviceActive Then
'Deactivate the phone device before the line device
TextStatus.Text = TextStatus.Text & _
"etPhone1.DeviceActive = False" & vbCrLf
etPhone1.DeviceActive = False
If etPhone1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab & _
"Error = " & etPhone1.ErrorText & vbCrLf
End If
End If
TextStatus.Text = TextStatus.Text &
_
"etLine1.DeviceActive = False" & vbCrLf
etLine1.DeviceActive = False
If Not etLine1.DeviceActive Then
CommandDial.Enabled = False
CommandDialtone.Enabled = False
Else
TextStatus.Text = TextStatus.Text & vbTab & _
"Error = " & etLine1.ErrorText & vbCrLf
CheckActive.Value = 1
End If
End If
Else
If Not etLine1.DeviceActive Then
CommandAnswer.Enabled = True
CommandHangup.Enabled = False
CommandDialtone.Enabled = True
CheckPlayOnConnect.Enabled = True
TextWaveFile.Enabled = True
CheckLoop.Enabled = True
CheckPhone.Enabled = True
PictureHandsetOnHook.Enabled = True
PictureHandsetOffHook.Enabled = True
FrameSpeakerphone.Enabled = True
OptionSPOffHook.Enabled = True
OptionSPOnHook.Enabled = True
LabelSPVolume.Enabled = True
LabelSPGain.Enabled = True
TextSPVolume.Enabled = True
TextSPGain.Enabled = True
CommandSPVolumeApply.Enabled = True
CommandSPGainApply.Enabled = True
LabelRecord.Enabled = True
CommandRecord.Enabled = True
TextStatus.Text = TextStatus.Text &
_
"etLine1.DeviceActive = True" & vbCrLf
etLine1.DeviceActive = True
If etLine1.ErrorNumber = INVALID_SERIAL_NUMBER Then
MsgBox ("Error opening line device: " & etLine1.ErrorText & _
vbCrLf & vbCrLf & _
"See the help topic:" & vbCrLf & vbCrLf & _
vbTab & "Why Serial Numbers Are Important")
End If
If (Not etLine1.DeviceActive) And
_
(etLine1.ErrorNumber = LINEERR_INVALMEDIAMODE) And _
(InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) Then
CommandAnswer.Enabled = False
CommandDialtone.Enabled = False
CheckPlayOnConnect.Enabled = False
TextWaveFile.Enabled = False
CheckLoop.Enabled = False
CheckPhone.Enabled = False
PictureHandsetOnHook.Enabled = False
PictureHandsetOffHook.Enabled = False
FrameSpeakerphone.Enabled = False
OptionSPOffHook.Enabled = False
OptionSPOnHook.Enabled = False
LabelSPVolume.Enabled = False
LabelSPGain.Enabled = False
TextSPVolume.Enabled = False
TextSPGain.Enabled = False
CommandSPVolumeApply.Enabled = False
CommandSPGainApply.Enabled = False
LabelRecord.Enabled = False
CommandRecord.Enabled = False
etLine1.PrivilegeNone = True
etLine1.DeviceActive = True
MsgBox ("TeleTools has detected that your device is a (" + _
etLine1.DeviceName & _
") DATA modem and therefore has no voice capabilities." &_
vbCrLf & vbCrLf & "TeleTools will now force a " & _
"compatibility mode in order to allow you to " & _
"continue while greying out options your modem may not "&_
" support." & vbCrLf & vbCrLf & _
"This device will be able to:" & vbCrLf & vbCrLf & _
vbTab & "DIAL" & vbCrLf & vbCrLf & _
"If you think you have a voice modem, expected more " & _
"functionality, or other programs provide more " & _
"functionality with this modem, see the " & _
"topic 'Working with Modems' in the Appendix of the " & _
"TeleTools help file.")
End If
If etLine1.DeviceActive Then
CommandDial.Enabled = True
If CheckPhone.Value = 1 Then
'Activate the phone device after the line device
etPhone1.DeviceActive = True
If Not etPhone1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab & "Error = " & _
etPhone1.ErrorText & vbCrLf
End If
End If
' Not all telephony devices are capable of controling the volume
' of the wave play device. This includes modems that use the
' Microsoft UnimodemV telephony service provider. The following
' code checks to see if the Unimodem TSP is being used and
' disables etPlay from working with the volume properties.
If InStr(1, etLine1.TAPITSP, "Modem", 1) > 0 Then
etPlay1.VolumeEnabled = False
Else
etPlay1.VolumeEnabled = True
End If
Else
TextStatus.Text = TextStatus.Text & vbTab & "Error = " &
_
etLine1.ErrorText & vbCrLf
CheckActive.Value = 0
End If
End If
If etLine1.WavePlayAvailable Then
CheckPlayOnConnect.Enabled = True
TextWaveFile.Enabled = True
CheckLoop.Enabled = True
Else
CheckPlayOnConnect.Enabled = False
TextWaveFile.Enabled = False
CheckLoop.Enabled = False
End If
UpdatePhoneDisplay
If (etPhone1.AboutLevel = "Professional") Or _
(etPhone1.AboutLevel = "Enterprise") Then
If etLine1.PhoneAvailable Then
CheckPhone.Value = 1
Else
CheckPhone.Value = 0
End If
End If
End Sub
Private Sub CheckLoop_Click()
If CheckLoop = 1 Then
etPlay1.DeviceLoop = True
Else
etPlay1.DeviceLoop = False
End If
End Sub
Private Sub CheckPhone_Click()
If CheckPhone.Value = 0 Then
If etPhone1.DeviceActive Then
'Deactivate the phone device before the line device
TextStatus.Text = TextStatus.Text &
_
"etPhone1.DeviceActive = False" & vbCrLf
etPhone1.DeviceActive = False
If etPhone1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab & _
"Error = " & etPhone1.ErrorText & vbCrLf
CheckPhone.Value = 1
End If
End If
Else
If (etLine1.DeviceActive) And (Not etPhone1.DeviceActive) Then
TextStatus.Text = TextStatus.Text &
_
"etPhone1.DeviceActive = True" & vbCrLf
etPhone1.DeviceActive = True
If Not etPhone1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab & _
"Error = " & etPhone1.ErrorText & vbCrLf
CheckPhone.Value = 0
End If
End If
End If
UpdatePhoneDisplay
End Sub
Private Sub ComboDevice_Click()
If etLine1.DeviceActive Then
CheckActive.Value = 0
End If
TextStatus.Text = TextStatus.Text & "etLine1.DeviceID = " &
_
Str(ComboDevice.ListIndex) & vbCrLf
etLine1.DeviceID = ComboDevice.ListIndex
If etLine1.ErrorNumber <> 0 Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"Error = " & etLine1.ErrorText & vbCrLf
Else
etLine1.PrivilegeMonitor = True
etLine1.PrivilegeOwner = True
End If
End Sub
Private Sub CommandAnswer_Click()
TextStatus.Text = TextStatus.Text & "Answering" & vbCrLf
If Not etLine1.CallAnswer Then
TextStatus.Text = TextStatus.Text &
_
vbTab & "Error = " & etLine1.ErrorText & vbCrLf
End If
End Sub
Private Sub CommandClear_Click()
TextStatus.Text = ""
End Sub
Private Sub CommandDial_Click()
State = "Dial"
etLine1.CallPhoneNumber = TextPhoneNumber.Text
TextStatus.Text = TextStatus.Text & _
"Dialing [" & TextPhoneNumber.Text & "]" & vbCrLf
If etLine1.CallDial Then
CommandDial.Enabled = False
CommandDialtone.Enabled = False
CommandHangup.Enabled = True
Else
TimerAutomatedAnsweringDevice.Enabled = False
etLine1.CallMonitorSilenceActive = False
TextStatus.Text = TextStatus.Text &
_
vbTab & "Error = " & etLine1.ErrorText & vbCrLf
etLine1.CallHangup 'Just in case the device didn't drop the call
End If
End Sub
Private Sub CommandDialtone_Click()
State = "Dialtone test"
etLine1.CallPhoneNumber = "W;"
TextStatus.Text = TextStatus.Text & "Testing for
dialtone" & vbCrLf
If (etLine1.PrivilegeNone = True) And _
(etLine1.DeviceMediaModesActive =
LINEMEDIAMODE_DATAMODEM) Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"This will not work because this device is not be 100% TAPI compliant"_
& vbCrLf
Else
If Not etLine1.CallDial Then
TextStatus.Text = TextStatus.Text &
_
vbTab & "Error = " & etLine1.ErrorText & vbCrLf
End If
End If
End Sub
Private Sub CommandHangup_Click()
TextStatus.Text = TextStatus.Text & "Hangup" & vbCrLf
'We need to make sure that the wave play device is deactivated.
'This code can be found in 4 location.
'CommandHangup_Click, etLine1_OnDisconnected, etLine1_OnIdle and Form_Unload
If etPlay1.DeviceActive Then
etPlay1.DeviceActive = False
If etPlay1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"Error = " & etPlay1.ErrorText & vbCrLf
End If
End If
If etRecord1.DeviceActive Then
etRecord1.DeviceActive = False
If etRecord1.DeviceActive Then
TextStatus.Text = TextStatus.Text &
_
vbTab & "Error = " & etRecord1.ErrorText & vbCrLf
End If
End If
CommandRecord.Enabled = False
TimerAutomatedAnsweringDevice.Enabled = False
If etLine1.CallMonitorSilenceActive Then
etLine1.CallMonitorSilenceActive = False
End If
If Not etLine1.CallHangup Then
TextStatus.Text = TextStatus.Text &
_
vbTab & "Error = " & etLine1.ErrorText & vbCrLf
End If
End Sub
Private Sub CommandRecord_MouseDown(Button As Integer, Shift As Integer,
_
X As Single, Y As Single)
'Not all telephony devices are capable of recording with the format
'PCM 8,000 hz, 16 bit, Mono. For example if you are using a Dialogic
'card you will need to use the following line of code to select a
'different format.
If InStr(1, etLine1.TAPITSP, "Dialogic", 1) > 0 Then
etRecord1.SourceFormatID = wfuLaw08000M08
Else
etRecord1.SourceFormatID = wfPCM08000M16
End If
etRecord1.SourceFileName = App.Path & "\temp.wav"
TextStatus.Text = TextStatus.Text & _
"Recording wave file [" & etRecord1.SourceFileName & "]" & vbCrLf
etRecord1.DeviceID = etLine1.WaveRecordID
etRecord1.DeviceActive = True
If Not etRecord1.DeviceActive Then
TextStatus.Text = TextStatus.Text &
_
vbTab & "Error = " & etRecord1.ErrorText & vbCrLf
End If
End Sub
Private Sub CommandRecord_MouseUp(Button As Integer, Shift As Integer,
_
X As Single, Y As Single)
If etRecord1.DeviceActive Then
TextStatus.Text = TextStatus.Text &
_
"Stop recording wave file [" & etRecord1.SourceFileName & "]" & vbCrLf
etRecord1.DeviceActive = False
If etRecord1.DeviceActive Then
TextStatus.Text = TextStatus.Text &
_
vbTab & "Error = " & etRecord1.ErrorText & vbCrLf
Else
If etPlay1.DeviceActive Then
etPlay1.DeviceActive = False
End If
TextStatus.Text = TextStatus.Text &
_
"Playing wave file [" & etRecord1.SourceFileName & "]" & vbCrLf
etPlay1.SourceFileName = etRecord1.SourceFileName
etPlay1.DeviceID = etLine1.WavePlayID
etPlay1.DeviceActive = True
If etRecord1.DeviceActive Then
TextStatus.Text = TextStatus.Text & _
vbTab & "Error = " & etPlay1.ErrorText & vbCrLf
End If
End If
End If
End Sub
Private Sub CommandSPGainApply_Click()
etPhone1.SpeakerphoneGain = Val(TextSPGain.Text)
DoEvents
TextSPGain.Text = Str(etPhone1.SpeakerphoneGain)
End Sub
Private Sub CommandSPVolumeApply_Click()
etPhone1.SpeakerphoneVolume = Val(TextSPVolume.Text)
DoEvents
TextSPVolume.Text = Str(etPhone1.SpeakerphoneVolume)
End Sub
Private Sub etLine1_OnBusy(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnBusy" & vbCrLf
CommandHangup_Click
End Sub
Private Sub etLine1_OnCallBegin(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnCallBegin" & vbCrLf
End Sub
Private Sub etLine1_OnCalledID(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnCalledID" & vbCrLf
TextStatus.Text = TextStatus.Text & _
vbTab & "CalledIDName = " & etLine1.CallCalledIDName & vbCrLf
TextStatus.Text = TextStatus.Text & _
vbTab & "CalledIDNumber = " & etLine1.CallCalledIDNumber & vbCrLf
End Sub
Private Sub etLine1_OnCallEnd(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnCallEnd" & vbCrLf
End Sub
Private Sub etLine1_OnCallerID(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text &
etLine1.OnCallerID" & vbCrLf
TextStatus.Text = TextStatus.Text & _
vbTab & "CallerIDName = " & etLine1.CallCallerIDName & vbCrLf
TextStatus.Text = TextStatus.Text & _
vbTab & "CallerIDNumber = " & etLine1.CallCallerIDNumber & vbCrLf
End Sub
Private Sub etLine1_OnConnected(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnConnected" & vbCrLf
If (etLine1.AboutLevel = "Standard") Or _
(etLine1.AboutLevel = "Professional") Or _
(etLine1.AboutLevel = "Enterprise") Then
If (etLine1.CallOrigin =
LINECALLORIGIN_OUTBOUND) Then
'Modems do not support monitor silence.
If (InStr(1, etLine1.TAPITSP, "Modem", 1) = 0) And _
((etLine1.AddressCapabilitiesCallFeatures And _
LINECALLFEATURE_MONITORTONES) <> 0) Then
'Modems do not report LINECALLFEATURE_MONITORTONES correctly!
TextStatus.Text = TextStatus.Text & _
vbTab & "Check for automated device" & vbCrLf
TextStatus.Text = TextStatus.Text & _
vbTab & vbTab & "etLine1.CallMonitorSilenceActive = True" & vbCrLf
TimerAutomatedAnsweringDevice.Enabled = True
gdtConnected = Now
etLine1.CallMonitorSilenceDuration = 1500
etLine1.CallMonitorSilenceActive = True
If (Not etLine1.CallMonitorSilenceActive) Then
TextStatus.Text = TextStatus.Text & vbTab & vbTab & _
"Error = " & etLine1.ErrorText & vbCrLf
End If
'See the events etLine.OnSilence &
'TimerAutomatedAnsweringDevice.Timer
End If
End If
End If
CommandAnswer.Enabled = False
CommandHangup.Enabled = True
If CheckPlayOnConnect.Value = 1 Then
If Not etLine1.WavePlayAvailable Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"etLine1.WavePlayAvailable = False" & vbCrLf
Else
TextStatus.Text = TextStatus.Text & vbTab &
_
"Playing wave file [" & TextWaveFile.Text & "]" & vbCrLf
etPlay1.DeviceID = etLine1.WavePlayID
etPlay1.SourceFileName = TextWaveFile.Text
CheckLoop_Click
etPlay1.DeviceActive = True
If Not etPlay1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab & vbTab & _
"Error = " & etPlay1.ErrorText & vbCrLf
End If
End If
End If
' Modems do not report LINECALLFEATURE_MONITORDIGITS correctly!
' Use this method to check for modems
If (InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) Then
If (Not etLine1.PrivilegeNone) Then
' Using a voice modem
etLine1.CallMonitorDigitsActive = True
End If
Else
If (etLine1.AddressCapabilitiesCallFeatures And
_
LINECALLFEATURE_MONITORDIGITS) <> 0 Then
etLine1.CallMonitorDigitsActive = True
End If
End If
If etLine1.WaveRecordAvailable Then
CommandRecord.Enabled = True
Else
CommandRecord.Enabled = False
End If
End Sub
Private Sub etLine1_OnConnectedID(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnConnectedID" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab &
"ConnectedIDName = " &_
etLine1.CallConnectedIDName & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab &
"ConnectedIDNumber = " & _
etLine1.CallConnectedIDNumber & vbCrLf
End Sub
Private Sub etLine1_OnDialing(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnDialing" & vbCrLf
End Sub
Private Sub etLine1_OnDialtone(ByVal CallHandle As Long)
If State = "Dialtone test" Then
TextStatus.Text = TextStatus.Text & vbTab & State & " Successful" & vbCrLf
etLine1.CallHangup
Else
TextStatus.Text = TextStatus.Text & "etLine1.OnDialtone" & vbCrLf
End If
End Sub
Private Sub etLine1_OnDigitReceived(ByVal CallHandle As Long,
_
ByVal Digit As Integer, ByVal Tag As Long)
TextStatus.Text = TextStatus.Text & _
"etLine1.OnDigitReceived [" & Chr(Digit) & "]" & vbCrLf
If etPlay1.DeviceActive Then
' Stop playing wave file when a digit is received
etPlay1.DeviceActive = False
End If
If etLine1.WavePlayAvailable Then
CheckLoop = 0 ' Turn off the looping wave file
etPlay1.DeviceID = etLine1.WavePlayID
etPlay1.SourceFileName = App.Path &
"\" & Chr(Digit)
TextStatus.Text = TextStatus.Text & vbTab &
_
"Playing wave file [" & etPlay1.SourceFileName & "]" & vbCrLf
etPlay1.DeviceActive = True
If Not etPlay1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab & vbTab &
_
"Error = " & etPlay1.ErrorText & vbCrLf
End If
End If
End Sub
Private Sub etLine1_OnDisconnected(ByVal CallHandle As Long)
If State = "Dialtone test" Then
If (etLine1.CallDisconnectMode =
LINEDISCONNECTMODE_NODIALTONE) Or _
(etLine1.CallDisconnectMode =
LINEDISCONNECTMODE_OUTOFORDER) Then
TextStatus.Text = TextStatus.Text & vbTab & "Failure" & vbCrLf
End If
End If
TextStatus.Text = TextStatus.Text & "etLine1.OnDisconnected" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & _
"etLine1.CallDisconnectMode = " & _
etLine1.StringLINEDISCONNECTMODE(etLine1.CallDisconnectMode) & vbCrLf
TimerAutomatedAnsweringDevice.Enabled = False
If etLine1.CallMonitorSilenceActive Then
etLine1.CallMonitorSilenceActive = False
End If
' We need to make sure that the wave play device is deactivated.
' This code can be found in 4 location.
' CommandHangup_Click, etLine1_OnDisconnected, etLine1_OnIdle and Form_Unload
If etPlay1.DeviceActive Then
etPlay1.DeviceActive = False
If etPlay1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"Error = " & ePlay1.ErrorText & vbCrLf
End If
End If
If etRecord1.DeviceActive Then
etRecord1.DeviceActive = False
If etRecord1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"Error = " & etRecord1.ErrorText & vbCrLf
End If
End If
CommandRecord.Enabled = False
If etLine1.CallState <> LINECALLSTATE_IDLE Then
etLine1.CallHangup
End If
End Sub
Private Sub etLine1_OnError()
TextStatus.Text = TextStatus.Text & "etLine1.OnError" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & "etLine1.ErrorText = " &
_
etLine1.ErrorText & vbCrLf
End Sub
Private Sub etLine1_OnIdle(ByVal CallHandle As Long)
State = ""
TextStatus.Text = TextStatus.Text & "etLine1.OnIdle" & vbCrLf
CommandAnswer.Enabled = False
If Not etLine1.PrivilegeNone Then
CommandDialtone.Enabled = True
End If
CommandHangup.Enabled = False
CommandDial.Enabled = True
TimerAutomatedAnsweringDevice.Enabled = False
'If this is not a data modem then enabled the "Check For Dialtone" button
If Not etLine1.PrivilegeNone Then
CommandDialtone.Enabled = True
End If
If etLine1.CallMonitorDigitsActive Then
etLine1.CallMonitorDigitsActive = False
End If
If etLine1.CallMonitorSilenceActive Then
etLine1.CallMonitorSilenceActive = False
End If
' We need to make sure that the wave play device is deactivated.
' This code can be found in 4 location.
' CommandHangup_Click, etLine1_OnDisconnected, etLine1_OnIdle and Form_Unload
If etPlay1.DeviceActive Then
etPlay1.DeviceActive = False
If etPlay1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"Error = " & etPlay1.ErrorText & vbCrLf
End If
End If
If etRecord1.DeviceActive Then
etRecord1.DeviceActive = False
If etRecord1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"Error = " & etRecord1.ErrorText & vbCrLf
End If
End If
CommandRecord.Enabled = False
End Sub
Private Sub etLine1_OnOffering(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnOffering" & vbCrLf
CommandAnswer.Enabled = True
CommandDialtone.Enabled = False
End Sub
Private Sub etLine1_OnRedirectingID(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnRedirectingID" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & "RedirectingIDName = " &_
etLine1.CallRedirectingIDName & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & "RedirectingIDNumber = " &_
etLine1.CallRedirectingIDNumber & vbCrLf
End Sub
Private Sub etLine1_OnRedirectionID(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnRedirectionID" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & "RedirectionIDName = " &_
etLine1.CallRedirectionIDName & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & "RedirectionIDNumber = " &_
etLine1.CallRedirectionIDNumber & vbCrLf
End Sub
Private Sub etLine1_OnRing(ByVal Count As Long, ByVal RingMode As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnRing [" & Str(Count) & ", " &_
Str(RingMode) & "]" & vbCrLf
End Sub
Private Sub etLine1_OnRingBack(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnRingBack" & vbCrLf
End Sub
Private Sub etLine1_OnSilence(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnSilence" & vbCrLf
If etLine1.CallOrigin = LINECALLORIGIN_OUTBOUND Then
TimerAutomatedAnsweringDevice.Enabled = False
etLine1.CallMonitorSilenceActive = False
If ((Now - gdtConnected) < (ONE_SECOND * 3)) Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"Silence detected in less than 3 seconds" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & vbTab &
_
"Likely a human" & vbCrLf
Else
TextStatus.Text = TextStatus.Text & vbTab &
_
"Silence detected in greater than 3 seconds" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & vbTab &
_
"Likely an automated device" & vbCrLf
End If
End If
End Sub
Private Sub etLine1_OnSpecialInfo(ByVal CallHandle As Long)
TextStatus.Text = TextStatus.Text & "etLine1.OnSpecialInfo" & vbCrLf
End Sub
Private Sub etPhone1_OnDigitDown(ByVal wDetail As Integer)
TextStatus.Text = TextStatus.Text & _
"etPhone1.OnDigitDown [" & Chr(wDetail) & "]" & vbCrLf
End Sub
Private Sub etPhone1_OnDigitUp(ByVal wDetail As Integer)
TextStatus.Text = TextStatus.Text & _
"etPhone1.OnDigitUp [" & Chr(wDetail) & "]" & vbCrLf
End Sub
Private Sub etPhone1_OnError()
TextStatus.Text = TextStatus.Text & "etPhone1.OnError" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & _
"etPhone1.ErrorText = " & etPhone1.ErrorText & vbCrLf
End Sub
Private Sub etPhone1_OnHandsetHookSwitch()
TextStatus.Text = TextStatus.Text & "etPhone1.OnHandsetHookSwitch" & vbCrLf
If etPhone1.HandsetMicrophoneAndSpeaker Then
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.HandsetMicrophoneAndSpeaker = True" & vbCrLf
Else
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.HandsetMicrophoneAndSpeaker = False" & vbCrLf
End If
If etPhone1.HandsetMicrophoneOnly Then
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.HandsetMicrophoneOnly = True" & vbCrLf
Else
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.HandsetMicrophoneOnly = False" & vbCrLf
End If
If etPhone1.HandsetOnHook Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"etPhone1.HandsetOnHook = True" & vbCrLf
Else
TextStatus.Text = TextStatus.Text & vbTab &
_
"etPhone1.HandsetOnHook = False" & vbCrLf
End If
If etPhone1.HandsetSpeakerOnly Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"etPhone1.HandsetSpeakerOnly = True" & vbCrLf
Else
TextStatus.Text = TextStatus.Text & vbTab &
_
"etPhone1.HandsetSpeakerOnly = False" & vbCrLf
End If
UpdatePhoneDisplay
End Sub
Private Sub etPhone1_OnPhoneState()
TextStatus.Text = TextStatus.Text & "etPhone1.OnPhoneState [" &
_
Hex(etPhone1.DeviceState) & "] [" & _
Hex(etPhone1.DeviceStateDetails) & "]" & vbCrLf
End Sub
Private Sub etPhone1_OnSpeakerphoneGain()
TextStatus.Text = TextStatus.Text & "etPhone1.OnSpeakerphoneGain" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & "etPhone1.SpeakerphoneGain = " &_
Str(etPhone1.SpeakerphoneGain) & vbCrLf
TextSPGain.Text = Str(etPhone1.SpeakerphoneGain)
End Sub
Private Sub etPhone1_OnSpeakerphoneHookSwitch()
TextStatus.Text = TextStatus.Text & _
"etPhone1.OnSpeakerphoneHookSwitch" & vbCrLf
If etPhone1.SpeakerphoneMicrophoneAndSpeaker Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"etPhone1.SpeakerphoneMicrophoneAndSpeaker = True" & vbCrLf
OptionSPOffHook.Value = True
Else
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.SpeakerphoneMicrophoneAndSpeaker = False" & vbCrLf
End If
If etPhone1.SpeakerphoneMicrophoneOnly Then
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.SpeakerphoneMicrophoneOnly = True" & vbCrLf
OptionSPOffHook.Value = True
Else
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.SpeakerphoneMicrophoneOnly = False" & vbCrLf
End If
If etPhone1.SpeakerphoneOnHook Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"etPhone1.SpeakerphoneOnHook = True" & vbCrLf
OptionSPOnHook.Value = True
Else
TextStatus.Text = TextStatus.Text & vbTab &
_
"etPhone1.SpeakerphoneOnHook = False" & vbCrLf
End If
If etPhone1.SpeakerphoneSpeakerOnly Then
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.SpeakerphoneSpeakerOnly = True" & vbCrLf
OptionSPOffHook.Value = True
Else
TextStatus.Text = TextStatus.Text & vbTab &_
"etPhone1.SpeakerphoneSpeakerOnly = False" & vbCrLf
End If
End Sub
Private Sub etPhone1_OnSpeakerphoneVolume()
TextStatus.Text = TextStatus.Text & _
"etPhone1.OnSpeakerphoneVolume" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & _
"etPhone1.SpeakerphoneVolume = " & Str(etPhone1.SpeakerphoneVolume) & vbCrLf
TextSPVolume.Text = Str(etPhone1.SpeakerphoneVolume)
End Sub
Private Sub etPlay1_OnDone()
TextStatus.Text = TextStatus.Text & "etPlay1.OnDone" & vbCrLf
End Sub
Private Sub etPlay1_OnError()
TextStatus.Text = TextStatus.Text & "etPlay1.OnError" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & "etPlay1.ErrorText = " &_
etPlay1.ErrorText & vbCrLf
End Sub
Private Sub etPlay1_OnLoaded()
TextStatus.Text = TextStatus.Text & "etPlay1.OnLoaded" & vbCrLf
End Sub
Private Sub etPlay1_OnLoop()
TextStatus.Text = TextStatus.Text & "etPlay1.OnLoop" & vbCrLf
End Sub
Private Sub etPlay1_OnWarning(bContinue As Boolean)
TextStatus.Text = TextStatus.Text & "etPlay1.OnWarning" & vbCrLf
If MsgBox("Error playing: " & etPlay1.ErrorText, vbOKCancel) = vbCancel Then
bContinue = False
Else
bContinue = True
End If
End Sub
Private Sub etRecord1_OnError()
TextStatus.Text = TextStatus.Text & "etRecord1.OnError" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & "etRecord1.ErrorText = " &_
etRecord1.ErrorText & vbCrLf
End Sub
Private Sub etRecord1_OnWarning(bContinue As Boolean)
TextStatus.Text = TextStatus.Text & "etRecord1.OnError" & vbCrLf
If MsgBox("Error recording: " & etRecord1.ErrorText, vbOKCancel)=vbCancel Then
bContinue = False
Else
bContinue = True
End If
End Sub
Private Sub Form_Load()
'Enabled all ExceleTel TeleTools controls before using them
etLine1.Enabled = True
etPhone1.Enabled = True
etPlay1.Enabled = True
etRecord1.Enabled = True
TextWaveFile.Text = App.Path & "\et"
ComboDevice.Clear
etLine1.DeviceID = 0
For L = 0 To etLine1.DeviceCount - 1
ComboDevice.AddItem etLine1.DeviceList(L)
Next L
If ComboDevice.ListCount > 0 Then
ComboDevice.Text = ComboDevice.List(0)
End If
ComboDevice.ListIndex = 0
End Sub
Private Sub Form_Resize()
If Form1.Width < 6810 Then
TextStatus.Width = 6495
Else
TextStatus.Width = Form1.Width - 315
End If
If Form1.Height < 5970 Then
TextStatus.Height = 5495
Else
TextStatus.Height = Form1.Height - TextStatus.Top - 475
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
' We need to make sure that the wave play device is deactivated.
'This code can be found in 4 location.
' CommandHangup_Click, etLine1_OnDisconnected, etLine1_OnIdle and Form_Unload
If etPlay1.DeviceActive Then
etPlay1.DeviceActive = False
If etPlay1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab &
_
"Error = " & etPlay1.ErrorText & vbCrLf
End If
End If
'Close the etLine control when closing the form
If etRecord1.DeviceActive Then
etRecord1.DeviceActive = False
If etRecord1.DeviceActive Then
TextStatus.Text = TextStatus.Text & vbTab & "Error = " &_
etRecord1.ErrorText & vbCrLf
End If
End If
CommandRecord.Enabled = False
etLine1.DeviceActive = False
End Sub
Private Sub OptionSPOffHook_Click()
etPhone1.SpeakerphoneMicrophoneAndSpeaker = OptionSPOffHook.Value
End Sub
Private Sub OptionSPOnHook_Click()
etPhone1.SpeakerphoneOnHook = OptionSPOnHook.Value
End Sub
Private Sub TextSPGain_LostFocus()
TextSPGain.Text = Str(Val(TextSPGain.Text))
If (Val(TextSPGain.Text) < 0) Or (Val(TextSPGain.Text) > 100) Then
TextSPGain.Text = Str(etPhone1.SpeakerphoneGain)
End If
End Sub
Private Sub TextSPVolume_LostFocus()
TextSPVolume.Text = Str(Val(TextSPVolume.Text))
If (Val(TextSPVolume.Text) < 0) Or (Val(TextSPVolume.Text) > 100) Then
TextSPVolume.Text = Str(etPhone1.SpeakerphoneVolume)
End If
End Sub
Private Sub TimerAutomatedAnsweringDevice_Timer()
TimerAutomatedAnsweringDevice.Enabled = False
etLine1.CallMonitorSilenceActive = False
TextStatus.Text = TextStatus.Text & "Silence not detected in " & _
Str(TimerAutomatedAnsweringDevice.Interval) & " milliseconds" & vbCrLf
TextStatus.Text = TextStatus.Text & vbTab & _
"Likely an automated device" & vbCrLf
End Sub
|