|
From: <si...@us...> - 2006-03-16 19:35:10
|
Revision: 563 Author: sickpig Date: 2006-03-16 11:34:50 -0800 (Thu, 16 Mar 2006) ViewCVS: http://svn.sourceforge.net/yaacs/?rev=563&view=rev Log Message: ----------- * change stuff to reflect tcliaxc modification (see https://developer.berlios.de/projects/tcliaxc/ change made to code at svn rev 8) * add status better voip status bar (yacati) ViewCVS Links: ------------- http://svn.sourceforge.net/yaacs/?rev=8&view=rev Modified Paths: -------------- trunk/yaacs/yavoip.tcl trunk/yacati.tcl Modified: trunk/yaacs/yavoip.tcl =================================================================== --- trunk/yaacs/yavoip.tcl 2006-03-16 19:28:46 UTC (rev 562) +++ trunk/yaacs/yavoip.tcl 2006-03-16 19:34:50 UTC (rev 563) @@ -25,12 +25,14 @@ variable ::yavoip::prefs variable ::yavoip::phone variable ::yavoip::state - variable ::yavoip::result + variable ::yavoip::result "" variable ::yavoip::dpref #TODO use this one for tell to the user the status of the call variable ::yavoip::status - variable ::yavoip::iaxcEvent + variable ::yavoip::iaxcEvent + + variable ::yavoip::completed false } # getAutodial - detect if a workstation is voip enabled @@ -77,13 +79,24 @@ ::yalog::error "An error occurs while calling $number. The error comes from iaxc package.\nError: $errb" return -1 } - ::yalog::debug "calling number: $number" - + set ::yavoip::result "" + set ::yavoip::completed false + while {!$::yavoip::completed} { + set evtList [list] + ::iaxc::iaxcGetEvents evtList + foreach e $evtList { + ::yavoip::phoneEvent $e + if {$::yavoip::completed} {break} + } + update + update idletask + } } else { ::yalog::error "Some problem here, I can't call, line state is $::yavoip::state and the phone to call is $number" return -1 } + return $::yavoip::result } @@ -92,52 +105,58 @@ # On harmless unhandle situation returns 0 # On error return -1 # On critical error return -2 -proc ::yavoip::phoneEvent {} { - # initialize the check call block - set iaxc_state_free 0 - set iaxc_state_active [expr 1<<1] - set iaxc_state_outgoing [expr 1<<2] - set iaxc_state_ringing [expr 1<<3] - set iaxc_state_complete [expr 1<<4] - set iaxc_state_selected [expr 1<<5] - set iaxc_state_busy [expr 1<<6] - set iaxc_state_transfer [expr 1<<7] - - set states [list $iaxc_state_free $iaxc_state_active $iaxc_state_outgoing \ - $iaxc_state_ringing $iaxc_state_complete $iaxc_state_selected $iaxc_state_busy \ - $iaxc_state_transfer] +proc ::yavoip::phoneEvent {e} { + #::iaxc::IAXC_CALL_STATE_FREE 0 + #::iaxc::IAXC_CALL_STATE_ACTIVE 2 + #::iaxc::IAXC_CALL_STATE_OUTGOING 4 + #::iaxc::IAXC_CALL_STATE_RINGING 8 + #::iaxc::IAXC_CALL_STATE_COMPLETE 16 + #::iaxc::IAXC_CALL_STATE_SELECTED 32 + #::iaxc::IAXC_CALL_STATE_BUSY 64 + #::iaxc::IAXC_CALL_STATE_TRANSFER 128 + set states [list $::iaxc::IAXC_CALL_STATE_FREE $::iaxc::IAXC_CALL_STATE_ACTIVE $::iaxc::IAXC_CALL_STATE_OUTGOING \ + $::iaxc::IAXC_CALL_STATE_RINGING $::iaxc::IAXC_CALL_STATE_COMPLETE $::iaxc::IAXC_CALL_STATE_SELECTED $::iaxc::IAXC_CALL_STATE_BUSY \ + $::iaxc::IAXC_CALL_STATE_TRANSFER] set names [list "free" "active" "outgoing" "ringing" "complete" "selected" "busy" \ "transfer"] - - switch -- $::yavoip::iaxcEvent(etype) { - 1 { - #TEXT - ::yalog::debug "type: $::yavoip::iaxcEvent(type)" - ::yalog::debug "callNo: $::yavoip::iaxcEvent(callNo)" - ::yalog::debug "message: $::yavoip::iaxcEvent(message)" - set ris $::yavoip::iaxcEvent(message) - if {($ris eq "OCCUPATO")||($ris eq "LIBERO")||($ris eq "INESISTENTE")} { - ::yavoip::hangup - #there's a tkwait on yacati wating for thi change - set ::yavoip::result $ris - } elseif {$ris=="Call disconnected by remote"} { - set yavoip::result "AGGANCIATO" - } - } - 3 { - #CALL_STATE - ::yalog::debug "callNo: $::yavoip::iaxcEvent(callNo)" - set strState "" - foreach s $states { - if {[expr $::yavoip::iaxcEvent(state) & $s] != 0} { - set stateName [lindex $names [lsearch $states $s]] - set strState "$strState$stateName " + set type [lindex $e 0] + switch -exact -- $type \ + $::iaxc::IAXC_EVENT_TEXT { + #TEXT + ::yalog::debug "type: [lindex $e 1]" + ::yalog::debug "callNo: [lindex $e 2]" + ::yalog::debug "message: [lindex $e 3]" + set ::yavoip::status [lindex $e 3] + set ris [lindex $e 3] + if {($ris eq "OCCUPATO")||($ris eq "LIBERO")||($ris eq "INESISTENTE")||($ris eq "AGGANCIATO")} { + set ::yavoip::result $ris } - } - ::yalog::debug "state: $strState --- $::yavoip::iaxcEvent(state)" - } - } - + } \ + $::iaxc::IAXC_EVENT_LEVELS { + } \ + $::iaxc::IAXC_EVENT_STATE { + ::yalog::debug "callNo: [lindex $e 1]" + set strState "" + foreach s $states { + if {[expr [lindex $e 2] & $s]} { + set stateName [lindex $names [lsearch $states $s]] + set strState "$strState$stateName " + } + } + ::yalog::debug "state: $strState" + #try to understand the call is active or not + if {![expr [lindex $e 2] & $::iaxc::IAXC_CALL_STATE_ACTIVE]} { + set ::yavoip::completed true + } + } \ + $::iaxc::IAXC_EVENT_NETSTAT { + } \ + $::iaxc::IAXC_EVENT_URL { + } \ + $::iaxc::IAXC_EVENT_VIDEO { + } \ + $::iaxc::IAXC_EVENT_REGISTRATION { + } \ } # Read conf parameter for registering to voip server, @@ -163,7 +182,7 @@ } set ::yavoip::state "free" - if {[catch {::iaxc::iaxcInit ::yavoip::iaxcEvent ::yavoip::phoneEvent} errb]} { + if {[catch {::iaxc::iaxcInit} errb]} { ::yalog::error "\[iaxc\] Unable to initialize iaxc package. Error msg follow: $errb" return -1 } @@ -200,7 +219,6 @@ ::yalog::error "\[iaxc\] Unable to hangup the line. Error message follow:\n$errb" return -1 } - set ::yavoip::result "AGGANCIATO" } # reset iaxc library handler Modified: trunk/yacati.tcl =================================================================== --- trunk/yacati.tcl 2006-03-16 19:28:46 UTC (rev 562) +++ trunk/yacati.tcl 2006-03-16 19:34:50 UTC (rev 563) @@ -64,7 +64,8 @@ variable ::yacati::call 0 variable ::yacati::autodial 0 variable ::yacati::volume 0 - + variable ::yacati::manualSave 0 + variable ::yacati::bb_detect 0; variable ::yacati::have_you_ever_be_detected 0; variable ::yacati::init_pausa 0; @@ -347,14 +348,15 @@ ## #Grid 8 labelframe .g8 -relief flat -entry .g8.estatus -relief groove -state normal -disabledforeground black -justify center -scale .g8.svolume -showvalue 0 -label [mc "Volume"] -from 0 -to 100 -width 10 -orient horizontal \ +entry .g8.estatic -relief groove -state normal -disabledforeground black -justify right +entry .g8.estatus -relief groove -state normal -disabledforeground black -justify center +scale .g8.svolume -showvalue 0 -from 0 -to 100 -width 10 -orient horizontal \ -variable ::yacati::volume -command {::snack::audio play_gain } #label .g8.lbvol -text 0 grid columnconfigure .g8 0 -weight 1 -grid .g8.estatus .g8.svolume -sticky news +grid .g8.estatic .g8.estatus .g8.svolume -sticky news #add grid 8 to root window grid .g8 -sticky news @@ -502,7 +504,8 @@ "note" { set obj ".g7.enote"} #group 8 - "voip_status" { set obj ".g8.estatus"} + "voip_status" { set obj ".g8.estatus" } + "voip_static" { set obj ".g8.estatic" } "volume" { set obj ".g8.svolume" } default { ::yalog::error "Widget doesen't exist: $name"; exit } @@ -631,6 +634,7 @@ } if { $yacati::autodial==1 } { + set ::yacati::manualSave 0 ::yacati::makeCall } @@ -644,17 +648,12 @@ # devo riagganciare e mettere il tutto a richiama ::yalog::debug "Button hangup pressed..." ::yavoip::hangup - set yacati::call 2 + set ::yacati::call 2 - ::yacati::setWdjValue voip_status "" disabled - ::yacati::setWdjText bt_new [mc "Recall"] normal - ::yacati::configureWdj bt_save state normal - ::yacati::configureWdj bt_finish state normal - [::yacati::getWdj con_state] configure -state normal - } elseif { $yacati::call==2 && $yacati::autodial==1 } { ::yalog::debug "Button recall pressed..." # qui entro solo se uno tenta di richiamare lo stesso numero + set ::yacati::manualSave 0 ::yacati::makeCall } @@ -832,6 +831,8 @@ yacati::configureWdj con_state state disabled yacati::configureWdj bt_finish state disabled yacati::configureWdj bt_begin state normal + ::yacati::setWdjValue voip_static "" disabled + set ::yavoip::status "" ::yacati::exitWindow $db_int $db_sample $reslist $survey(nome_tabella) $session(num_risp_turno) $::yacati::have_you_ever_be_detected $survey(idindagine) @@ -993,15 +994,15 @@ yacati::managePhones $db_sample - yalog::debug "Close session_activity $contact(s_activity)" + ::yalog::debug "Close session_activity $contact(s_activity)" ::cati::closeSessionActivity $db_int $contact(s_activity) 9 - yacati::configureWdj bbr state normal + ::yacati::configureWdj bbr state normal - if {$yacati::autodial==1} { + if {$::yacati::autodial==1} { + set ::yacati::manualSave 1 ::yavoip::hangup - yalog::debug "hang up the phone, from Call Back" - set ::yavoip::result "SALVATO" + ::yalog::debug "hang up the phone, from Call Back" } yacati::clearMask } @@ -1038,9 +1039,9 @@ yacati::configureWdj bbr state normal if {$yacati::autodial==1} { + set ::yacati::manualSave 1 ::yavoip::hangup ::yalog::debug "hang up the phone, from while sending fax" - set ::yavoip::result "SALVATO" } ::yatk_dlg::info [mc "Fax sent."] @@ -1133,9 +1134,9 @@ yacati::configureWdj bbr state normal if {$yacati::autodial==1} { - puts $yavoip::phone h + set ::yacati::manualSave 1 + ::yavoip::hangup yalog::debug "hang up the phone, while sending email " - set yavoip::result "SALVATO" } yatk_dlg::info [mc "Email sent."] @@ -1616,7 +1617,8 @@ yacati::clearCombo study yacati::clearCombo birthday if {$::yacati::autodial == 1} { - ::yacati::setWdjValue voip_status "" disabled + ::yacati::setWdjValue voip_static [mc "idle"] disabled + set ::yavoip::status [mc "idle"] } if {$yacati::survey(azienda)=="t"} {::yacati::incWdjState disabled} else {::yacati::popWdjState disabled} set yacati::call 0 @@ -2441,13 +2443,11 @@ [::yacati::getWdj con_state] configure -state normal yacati::clearCombo con_state set listres [split $callres -] - set callres [string trim [lindex $listres 0]] + set callres [string trim [lindex $listres 0]] switch $callres { "LIBERO" { [::yacati::getWdj con_state] insert entry 0 [lindex $survey(statox) 2]} "OCCUPATO" { [::yacati::getWdj con_state] insert entry 0 [lindex $survey(statox) 1]} "INESISTENTE" { [::yacati::getWdj con_state] insert entry 0 [lindex $survey(statox) 5]} - "AGGANCIATO" { [::yacati::getWdj con_state] delete entry 0 end} - "SALVATO" { set yavoip::result ""; return } "-2" { yatk_dlg::error [mc "Call the administrator, there is a problem with VoIP connections"] [::yacati::getWdj con_state] configure -state disabled @@ -2455,11 +2455,11 @@ } } set yacati::call 2 - ::yacati::setWdjValue voip_status "" disabled + ::yacati::setWdjValue voip_static [mc "idle"] disabled + set ::yavoip::status [mc "idle"] yacati::setWdjText bt_new [mc "Recall"] normal yacati::configureWdj bt_save state normal yacati::configureWdj bt_finish state normal - set yavoip::result "" } # Wrapper around yavoip::iaxCall, it only @@ -2473,33 +2473,27 @@ return } - if {[::yavoip::call [::yacati::get_phone_number [::yacati::get_active_phone]]]==-1} { + set ::yacati::call 1 + ::yacati::configureWdj bt_save state disabled + ::yacati::setWdjText bt_new [mc "Hangup"] normal + ::yacati::configureWdj bt_finish state disabled + ::yacati::configureWdj con_state state disabled + set telnumber [::yacati::get_phone_number [::yacati::get_active_phone]] + set status [mc "you're calling phone [::yacati::get_active_phone], number $telnumber "] + ::yacati::setWdjValue voip_static $status disabled + + set callres [::yavoip::call [::yacati::get_phone_number [::yacati::get_active_phone]]] + if {$callres == -1} { ::yavoip::hangup set ::yacati::call 2 ::yatk_dlg::error [mc "Error while calling selected phone number..."] - } else { - - set telnumber [::yacati::get_phone_number [::yacati::get_active_phone]] - set status [mc "you're calling phone [::yacati::get_active_phone], number $telnumber ..."] - ::yacati::setWdjValue voip_status $status disabled - - set ::yacati::call 1 - yacati::configureWdj bt_save state disabled - yacati::setWdjText bt_new [mc "Hangup"] normal - yacati::configureWdj bt_finish state disabled - yacati::configureWdj con_state state disabled - tkwait variable ::yavoip::result - - #after that yavoip::result is modified we check if - #the contact is saved trough invia email/fax/appuntamento - if {$yavoip::result=="SALVATO" && ($yacati::autodial==1)} { - set ::yacati::call 0 - ::yacati::clearMask - set ::yavoip::result "" - return - } - ::yacati::checkCallRes $::yavoip::result + return } + + #check for automatica outcomes classification + if {!$::yacati::manualSave} { + ::yacati::checkCallRes $callres + } } @@ -2650,8 +2644,8 @@ ## # Setting autodial yalog::message "Setting Autodialing..." -set yacati::autodial [yavoip::getAutodial $db_int [array get yacati::config]] -if {$yacati::autodial==1 && [::yavoip::conn [array get yacati::config]]==-1} { +set yacati::autodial [::yavoip::getAutodial $db_int [array get ::yacati::config]] +if {$yacati::autodial==1 && [::yavoip::conn [array get ::yacati::config]]==-1} { ::yalog::error "Somethig goes wrong while connetting to the VoIP server" set yacati::autodial 0 } @@ -2659,6 +2653,7 @@ if {$yacati::autodial==1} { #init audio manage interface + [::yacati::getWdj voip_status] configure -textvar ::yavoip::status set ::yacati::volume $yacati::config(BASE_VOLUME) ::snack::audio play_gain $::yacati::volume } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |