|
From: <si...@us...> - 2006-04-10 12:12:35
|
Revision: 649 Author: sickpig Date: 2006-04-10 05:12:22 -0700 (Mon, 10 Apr 2006) ViewCVS: http://svn.sourceforge.net/yaacs/?rev=649&view=rev Log Message: ----------- * now yacati is tested also with voip enabled * drop .yaacsphonerc stuff * check for registration result Modified Paths: -------------- trunk/yaacs/yavoip.tcl trunk/yacati.tcl Modified: trunk/yaacs/yavoip.tcl =================================================================== --- trunk/yaacs/yavoip.tcl 2006-04-10 10:09:43 UTC (rev 648) +++ trunk/yaacs/yavoip.tcl 2006-04-10 12:12:22 UTC (rev 649) @@ -33,6 +33,10 @@ variable ::yavoip::iaxcEvent variable ::yavoip::completed false + + # registration aux vars + variable ::yavoip::checkReg + variable ::yavoip::regRes } # getAutodial - detect if a workstation is voip enabled @@ -53,11 +57,7 @@ } else { set room [lindex $res 0] set user_pass [lindex $res 1] - set name [file join "$::env(HOME)" ".yaacsphonerc"] - set fd [open $name w] - puts $fd "preferred_codec $conf(CODEC) ext $user_pass pass $user_pass user $user_pass server $conf(IAX_SERVER)" - close $fd - yalog::debug "settings yaacsphone saved, autodial : 1" + array set ::yavoip::prefs [list preferred_codec $conf(CODEC) ext $user_pass pass $user_pass user $user_pass server $conf(IAX_SERVER)] set result 1; } return $result @@ -153,6 +153,8 @@ $::iaxc::IAXC_EVENT_VIDEO { } \ $::iaxc::IAXC_EVENT_REGISTRATION { + set ::yavoip::regRs [lindex $e 2] + set yavoip::checkReg true } \ } @@ -166,30 +168,44 @@ array set conf $config set ::yavoip::dpref $conf(DIALPREFIX) - set pref_vars "server user pass ext preferred_codec" - set rcfile [file join $env(HOME) ".yaacsphonerc"] - - if {[catch { - set fd [open $rcfile r] - array set ::yavoip::prefs [read $fd] - close $fd - }]} { - ::yalog::error "I'm not able to get .yaacaphonerc in $env(HOME)" - return -1 - } set ::yavoip::state "free" if {[catch {::iaxc::iaxcInit} errb]} { ::yalog::error "\[iaxc\] Unable to initialize iaxc package. Error msg follow: $errb" - return -1 + return [list -1 [mc "Error while initializing voip extransions (iaxc)"]] } ::yalog::debug "Regitration to the server starting...." + if {[catch {::iaxc::iaxcRegister $::yavoip::prefs(user) $::yavoip::prefs(pass) $::yavoip::prefs(server)} errb]} { ::yalog::error "\[iaxc\] Registration to server failed with message: $errb " - return -1 + return [list -1 [mc "Error registration failed"]] } + # as you can see from libiax2 src we've to check if + # registration is accepted or not + # iax-client.h:#define IAX_EVENT_REGACK 18 /* Registration reply */ + # iax-client.h:#define IAX_EVENT_REGREJ 30 /* Registration reply */ + set ::yavoip::checkReg false + set ::yavoip::regRes "" + ::yalog::info "Checking for registration success" + while {!$::yavoip::checkReg} { + foreach e [::iaxc::iaxcGetEvents] { + ::yavoip::phoneEvent $e + if {$::yavoip::checkReg} {break} + } + update + update idletask + } + + switch $::yavoip::regRes { + 18 { + ::yalog::error "registration failed" + return [list -1 [mc "Registration rejected due to auth issues"]] + } + 30 {::yalog::info "registration accepted"; return 0} + } + switch $::yavoip::prefs(preferred_codec) { gsm {set codec [expr 1 << 1]} ulaw {set codec [expr 1 << 2]} @@ -205,8 +221,9 @@ if {[catch {::iaxc::iaxcAudioEncoding $codec} errb]} { ::yalog::error "Unable to set the preferred codec" - } - + return [list -1 [mc "Error while stting preferred codec"]] + } + return 0 } # Hangup the phone Modified: trunk/yacati.tcl =================================================================== --- trunk/yacati.tcl 2006-04-10 10:09:43 UTC (rev 648) +++ trunk/yacati.tcl 2006-04-10 12:12:22 UTC (rev 649) @@ -2517,11 +2517,12 @@ ## # Setting autodial yalog::message "Setting Autodialing..." -set yacati::autodial [::yavoip::getAutodial $db [array get ::yacati::config]] -if {$yacati::autodial==1 && [::yavoip::conn [array get ::yacati::config]]==-1} { +set voipConnRes [::yavoip::conn [array get ::yacati::config]] +set ::yacati::autodial [::yavoip::getAutodial $db [array get ::yacati::config]] +if {$yacati::autodial==1 && [lindex $voipConnRes 0]==-1} { ::yalog::error "Somethig goes wrong while connetting to the VoIP server" - ::yatk_dlg::info "Cannot connect to the VoIP server, the session \ - will be started without VoIP support!" + ::yatk_dlg::info [mc "Connection to the VoIP server failed with this message:\n\n%s\n\n\ + The session will be started without VoIP support!" [lindex $voipConnRes 1]] set yacati::autodial 0 } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |