|
From: <si...@us...> - 2006-04-10 15:46:16
|
Revision: 651 Author: sickpig Date: 2006-04-10 08:46:05 -0700 (Mon, 10 Apr 2006) ViewCVS: http://svn.sourceforge.net/yaacs/?rev=651&view=rev Log Message: ----------- * better yavoip error handling plus a few typo fix here and there Modified Paths: -------------- trunk/yaacs/yavoip.tcl trunk/yacati.tcl Modified: trunk/yaacs/yavoip.tcl =================================================================== --- trunk/yaacs/yavoip.tcl 2006-04-10 15:42:46 UTC (rev 650) +++ trunk/yaacs/yavoip.tcl 2006-04-10 15:46:05 UTC (rev 651) @@ -36,7 +36,21 @@ # registration aux vars variable ::yavoip::checkReg - variable ::yavoip::regRes + variable ::yavoip::regRes + + # error message + variable ::yavoip::ERRMSG + + # error codes + + variable ::yavoip::ERR + variable ::yavoip::ERR_ONCALL -2 + variable ::yavoip::ERR_GEN -3 + variable ::yavoip::ERR_INIT -4 + variable ::yavoip::ERR_REGREJ -5 + variable ::yavoip::ERR_CODEC -6 + variable ::yavoip::ERR_HANGUP -7 + variable ::yavoip::ERR_QUIT -8 } # getAutodial - detect if a workstation is voip enabled @@ -77,6 +91,8 @@ if {[catch {::iaxc::iaxcCall "$prefix$::yavoip::prefs(server)/$yavoip::dpref$number"} errb]} { ::yalog::error "An error occurs while calling $number. The error comes from iaxc package.\nError: $errb" + set ::yavoip::ERRMSG [mc "An error occur while calling"] + set ::yavoip::ERR $::yavoip::ERR_ONCALL return -1 } ::yalog::debug "calling number: $number" @@ -92,17 +108,18 @@ } } else { ::yalog::error "Some problem here, I can't call, line state is $::yavoip::state and the phone to call is $number" - return -1 + + set ::yavoip::ERRMSG [mc "An error occur while calling"] + set ::yavoip::ERR $::yavoip::ERR_GENERIC + return -1 } return $::yavoip::result } -# Bridge result from iaxcli.c to user interface -# On handled situation returns a string (OCCUPATO,LIBERO,INESISTENTE) -# On harmless unhandle situation returns 0 -# On error return -1 -# On critical error return -2 +# This function poll iaxc thread to understand what's going on +# with voip stuff ;) +#@param e - a list of string that describe a iaxc event proc ::yavoip::phoneEvent {e} { #::iaxc::IAXC_CALL_STATE_FREE 0 #::iaxc::IAXC_CALL_STATE_ACTIVE 2 @@ -153,7 +170,7 @@ $::iaxc::IAXC_EVENT_VIDEO { } \ $::iaxc::IAXC_EVENT_REGISTRATION { - set ::yavoip::regRs [lindex $e 2] + set ::yavoip::regRes [lindex $e 2] set yavoip::checkReg true } \ } @@ -172,14 +189,17 @@ set ::yavoip::state "free" if {[catch {::iaxc::iaxcInit} errb]} { ::yalog::error "\[iaxc\] Unable to initialize iaxc package. Error msg follow: $errb" - return [list -1 [mc "Error while initializing voip extransions (iaxc)"]] + set ::yavoip::ERRMSG [mc "Error while initializing voip extransions (iaxc)"]] + set ::yavoip::ERR $::yavoip::ERR_INIT + return -1 } ::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 [list -1 [mc "Error registration failed"]] + set ::yavoip::ERRMSG [mc "Error registratio failed"]] + set ::yavoip::ERR $::yavoip::ERR_REGREJ + return -1 } # as you can see from libiax2 src we've to check if @@ -188,7 +208,7 @@ # iax-client.h:#define IAX_EVENT_REGREJ 30 /* Registration reply */ set ::yavoip::checkReg false set ::yavoip::regRes "" - ::yalog::info "Checking for registration success" + ::yalog::message "Checking for registration success" while {!$::yavoip::checkReg} { foreach e [::iaxc::iaxcGetEvents] { ::yavoip::phoneEvent $e @@ -199,11 +219,13 @@ } switch $::yavoip::regRes { - 18 { + 30 { ::yalog::error "registration failed" - return [list -1 [mc "Registration rejected due to auth issues"]] + set ::yavoip::ERRMSG [mc "Registration rejected due to auth issues"] + set ::yavoip::ERR $::yavoip::ERR_REGREJ + return -1 } - 30 {::yalog::info "registration accepted"; return 0} + 18 {::yalog::message "registration accepted"; return 0} } switch $::yavoip::prefs(preferred_codec) { @@ -221,7 +243,9 @@ if {[catch {::iaxc::iaxcAudioEncoding $codec} errb]} { ::yalog::error "Unable to set the preferred codec" - return [list -1 [mc "Error while stting preferred codec"]] + set ::yavoip::ERRMSG [mc "Unable to set the preferred codec"]] + set ::yavoip::ERR $::yavoip::ERR_CODEC + return -1 } return 0 } @@ -231,7 +255,9 @@ ::yalog::debug "hang up the phone" if {[catch {::iaxc::iaxcHangUp} errb]} { ::yalog::error "\[iaxc\] Unable to hangup the line. Error message follow:\n$errb" - return -1 + set ::yavoip::ERRMSG [mc "Unable to hangup the line"] + set ::yavoip::ERR $::yavoip::ERR_HANGUP + return -1 } } @@ -240,6 +266,8 @@ ::yalog::debug "reset iaxc library handler" if {[catch {::iaxc::iaxcQuit} errb]} { ::yalog::error "\[iaxc\] Unable to reset library handler. Error message follow:\n$errb" - return -1 + set ::yavoip::ERRMSG [mc "Error while shutting down voip extension"] + set ::yavoip::ERR $::yavoip::ERR_QUIT + return -1 } } Modified: trunk/yacati.tcl =================================================================== --- trunk/yacati.tcl 2006-04-10 15:42:46 UTC (rev 650) +++ trunk/yacati.tcl 2006-04-10 15:46:05 UTC (rev 651) @@ -2517,13 +2517,12 @@ ## # Setting autodial yalog::message "Setting Autodialing..." -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} { +if {$yacati::autodial==1 && [::yavoip::conn [array get ::yacati::config]]==-1} { ::yalog::error "Somethig goes wrong while connetting to the VoIP server" ::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 + The session will be started without VoIP support!" $::yavoip::ERRMSG] + set ::yacati::autodial 0 } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |