Added an option (extra notification) to discard an incoming call #157

master
Maarten van Gompel 4 years ago
parent 24f8ed8478
commit c58fa6a1e9
  1. 7
      scripts/modem/sxmo_modemcall.sh
  2. 13
      scripts/modem/sxmo_modemmonitor.sh

@ -1,5 +1,6 @@
#!/usr/bin/env sh #!/usr/bin/env sh
LOGDIR="$XDG_DATA_HOME"/sxmo/modem LOGDIR="$XDG_DATA_HOME"/sxmo/modem
NOTIFDIR="$XDG_DATA_HOME"/sxmo/notifications
ALSASTATEFILE="$XDG_CACHE_HOME"/precall.alsa.state ALSASTATEFILE="$XDG_CACHE_HOME"/precall.alsa.state
CACHEDIR="$XDG_CACHE_HOME"/sxmo CACHEDIR="$XDG_CACHE_HOME"/sxmo
trap "gracefulexit" INT TERM trap "gracefulexit" INT TERM
@ -86,6 +87,7 @@ toggleflagset() {
acceptcall() { acceptcall() {
CALLID="$1" CALLID="$1"
rm "$NOTIFDIR/incomingcall_${CALLID}_notification"* 2>dev/null #there can be multiple actionable notifications for one call (pickup/discard)
echo "sxmo_modemcall: Attempting to initialize CALLID $CALLID">&2 echo "sxmo_modemcall: Attempting to initialize CALLID $CALLID">&2
DIRECTION="$( DIRECTION="$(
mmcli --voice-status -o "$CALLID" -K | mmcli --voice-status -o "$CALLID" -K |
@ -115,6 +117,11 @@ acceptcall() {
hangup() { hangup() {
CALLID="$1" CALLID="$1"
rm "$NOTIFDIR/incomingcall_${CALLID}_notification"* 2>dev/null #there can be multiple actionable notifications for one call (pickup/discard)
if [ ! -f "$CACHEDIR/${CALLID}.pickedupcall" ]; then
#this call was never picked up and hung up immediately, so it is a discarded call
touch "$CACHEDIR/${CALLID}.discardedcall" #this signals that we discarded this call to other asynchronously running processes
fi
modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --hangup modem_cmd_errcheck -m "$(modem_n)" -o "$CALLID" --hangup
log_event "call_hangup" "$CALLID" log_event "call_hangup" "$CALLID"
modem_cmd_errcheck -m "$(modem_n)" --voice-delete-call="$CALLID" modem_cmd_errcheck -m "$(modem_n)" --voice-delete-call="$CALLID"

@ -70,11 +70,15 @@ checkforfinishedcalls() {
); do ); do
FINISHEDNUMBER="$(lookupnumberfromcallid "$FINISHEDCALLID")" FINISHEDNUMBER="$(lookupnumberfromcallid "$FINISHEDCALLID")"
mmcli -m "$(modem_n)" --voice-delete-call "$FINISHEDCALLID" mmcli -m "$(modem_n)" --voice-delete-call "$FINISHEDCALLID"
rm -f "$NOTIFDIR/incomingcall_${FINISHEDCALLID}_notification" rm -f "$NOTIFDIR/incomingcall_${FINISHEDCALLID}_notification"* #there may be multiple actionable notification for one call
TIME="$(date --iso-8601=seconds)" TIME="$(date --iso-8601=seconds)"
mkdir -p "$LOGDIR" mkdir -p "$LOGDIR"
if [ -f "$CACHEDIR/${FINISHEDCALLID}.pickedupcall" ]; then if [ -f "$CACHEDIR/${FINISHEDCALLID}.discardedcall" ]; then
echo "sxmo_modemmonitor: Discarded call from $FINISHEDNUMBER">&2
rm -f "$CACHEDIR/${FINISHEDCALLID}.discardedcall"
printf %b "$TIME\tcall_discarded\t$FINISHEDNUMBER\n" >> "$LOGDIR/modemlog.tsv"
elif [ -f "$CACHEDIR/${FINISHEDCALLID}.pickedupcall" ]; then
#this call was picked up #this call was picked up
pkill -f sxmo_modemcall.sh #kill call (softly) in case it is still in progress (remote party hung up) pkill -f sxmo_modemcall.sh #kill call (softly) in case it is still in progress (remote party hung up)
echo "sxmo_modemmonitor: Finished call from $FINISHEDNUMBER">&2 echo "sxmo_modemmonitor: Finished call from $FINISHEDNUMBER">&2
@ -125,6 +129,11 @@ checkforincomingcalls() {
"sxmo_modemcall.sh pickup $VOICECALLID" \ "sxmo_modemcall.sh pickup $VOICECALLID" \
none \ none \
"Pickup - $CONTACTNAME" & "Pickup - $CONTACTNAME" &
sxmo_notificationwrite.sh \
"$NOTIFDIR/incomingcall_${VOICECALLID}_notification_discard" \
"sxmo_modemcall.sh hangup $VOICECALLID" \
none \
"Discard - $CONTACTNAME" &
echo "sxmo_modemmonitor: Call from number: $INCOMINGNUMBER (VOICECALLID: $VOICECALLID)">&2 echo "sxmo_modemmonitor: Call from number: $INCOMINGNUMBER (VOICECALLID: $VOICECALLID)">&2
} }

Loading…
Cancel
Save