diff --git a/apps/pin_collect/Makefile b/apps/pin_collect/Makefile new file mode 100644 index 00000000..dc027698 --- /dev/null +++ b/apps/pin_collect/Makefile @@ -0,0 +1,54 @@ + +NAME=pincollect +VERSION=2.3.0-1 + +PYTHON_VERSION=2.3 + +LIBDIR=. +LIB_INSTALLDIR="/usr/lib/sems/ivr" +TARBALL_PREFIX=sems-app-${NAME} +TARBALL="${TARBALL_PREFIX}-${VERSION}.tar.gz" + +BASEDIR?=${basedir} + +GROUP="root" +OWNER="root" + +BIN_PERMISSIONS="755" +LIB_PERMISSIONS="644" + +PYCHECKERARGS = --stdlib +PYCHECKERDOCARGS = --classdoc --funcdoc + +.PHONY: all +all: clean compile + +clean: + find . -iname "*\.pyc" -o -iname "*\.py~" | xargs rm -f + rm -f ${TARBALL_PREFIX}*.tar.gz + +compile: + /usr/bin/python${PYTHON_VERSION} /usr/lib/python${PYTHON_VERSION}/compileall.py -q ${LIBDIR} + +install: all + install -d ${BASEDIR}/${LIB_INSTALLDIR} + install -m ${LIB_PERMISSIONS} -o ${OWNER} -g ${GROUP} ${LIBDIR}/*.pyc ${BASEDIR}/${LIB_INSTALLDIR} + +uninstall: + @echo "please remove the files from ${LIB_INSTALLDIR} manually." + +fulltest: + find | grep /Test | grep -v ".svn" | grep \\.py$$ | sed -e "s#^./##g" | bash -e - + +check: + find ${LIBDIR}/ | grep \\.py$$ | grep -v Test | PYTHONPATH=$(PYTHONPATH):../ivr/moc xargs pychecker ${PYCHECKERARGS} + +doccheck: + find ${LIBDIR}/ | grep \\.py$$ | grep -v Test | xargs pychecker ${PYCHECKERARGS} ${PYCHECKERDOCARGS} + +dist: all + tar -cvzf ${TARBALL} . --exclude=*.tar.gz \ + --exclude=.svn \ + --exclude=*~ + + diff --git a/apps/pin_collect/etc/pin_collect.conf b/apps/pin_collect/etc/pin_collect.conf new file mode 100644 index 00000000..3bad31ca --- /dev/null +++ b/apps/pin_collect/etc/pin_collect.conf @@ -0,0 +1,3 @@ +welcome_msg=/usr/lib/sems/audio/pincollect/welcome.wav +pin_msg=/usr/lib/sems/audio/pincollect/enter_pin.wav + diff --git a/apps/pin_collect/pin_collect.py b/apps/pin_collect/pin_collect.py new file mode 100644 index 00000000..86fa132a --- /dev/null +++ b/apps/pin_collect/pin_collect.py @@ -0,0 +1,87 @@ +from log import * +from ivr import * + +collect = 0 +connect = 1 +connected = 2 + +HINT_TIMER = 1 +HINT_TIMEOUT = 10 # seconds until hint msg is played + +CONF_TIMER = 2 + +# def loopedTTS(str): +# af = IvrAudioFile.tts(str) +# af.loop = True +# return af + +class IvrDialog(IvrDialogBase): + + welcome_msg = None + auth_ok_msg = None + auth_fail_msg = None + pin_msg = None + + state = collect + keys = '' + + conf_to = '' + conf_uri = '' + conf_duration = 0 + conf_participants = 0 + + def sessionInfo(self): + debug("IVR Session info:") + debug(" user: " + self.dialog.user) + debug(" domain: " + self.dialog.domain) + debug(" sip_ip: " + self.dialog.sip_ip) + debug(" sip_port: " + self.dialog.sip_port) + debug(" local_uri: " + self.dialog.local_uri) + debug(" remote_uri: " + self.dialog.remote_uri) + debug(" contact_uri: " + self.dialog.contact_uri) + debug(" callid: " + self.dialog.callid) + debug(" remote_tag: " + self.dialog.remote_tag) + debug(" local_tag: " + self.dialog.local_tag) + debug(" remote_party:" + self.dialog.remote_party) + debug(" local_party: " + self.dialog.local_party) + debug(" route: " + self.dialog.route) + debug(" next_hop: " + self.dialog.next_hop) + debug(" cseq: " + str(self.dialog.cseq)) + + def onSessionStart(self,hdrs): + self.sessionInfo() + self.setNoRelayonly() + + self.welcome_msg = IvrAudioFile() + self.welcome_msg.open(config['welcome_msg'],AUDIO_READ) + + self.pin_msg = IvrAudioFile() + self.pin_msg.open(config['pin_msg'],AUDIO_READ) + + self.enqueue(self.welcome_msg,None) + self.enqueue(self.pin_msg,None) + + def onBye(self): + self.stopSession() + + def onDtmf(self,key,duration): + if self.state == collect: + if key < 10: + self.keys += str(key) + debug("added key, PIN = " + self.keys) + self.setTimer(HINT_TIMER, HINT_TIMEOUT) + elif key == 10: + self.state = connect + self.removeTimer(HINT_TIMER) + self.redirect("sip:" + self.dialog.user + \ + self.keys + "@" + \ + self.dialog.domain) + self.stopSession() + + def onEmptyQueue(self): + if self.state == collect: + self.setTimer(HINT_TIMER, HINT_TIMEOUT) + + def onTimer(self, id): + if id == HINT_TIMER and self.state == collect: + self.enqueue(self.pin_msg, None) diff --git a/apps/pin_collect/wav/enter_pin.wav b/apps/pin_collect/wav/enter_pin.wav new file mode 100644 index 00000000..c77fba02 Binary files /dev/null and b/apps/pin_collect/wav/enter_pin.wav differ diff --git a/apps/pin_collect/wav/welcome.wav b/apps/pin_collect/wav/welcome.wav new file mode 100644 index 00000000..f981aa0d Binary files /dev/null and b/apps/pin_collect/wav/welcome.wav differ