summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorMatt Porter <mporter@konsulko.com>2017-05-18 22:43:27 -0400
committerMatt Porter <mporter@konsulko.com>2017-05-19 10:01:02 -0400
commit91520f0839b47641162b2f4ba5e788f6a602b4e4 (patch)
tree47864b1e5d5c3ff1e5145a34bb4dbd4206af75f2 /app
parented2a6d1359b7967d56172c0a37660181722a2019 (diff)
Add telephony binding event support and UI call status notification
Add supports for incoming call, dialing call, and terminated call events in the telephony binding. The phone UI is enhanced to make use of these telephony binding events to display a notifications of phone call status. These include generate a ring tone and displaying incoming phone number information, outgoing phone number being dialed, and halt of the ring tone and clearing of the notification space when a call is terminated. AGL-Bug: SPEC-598 Change-Id: Ied610b70c2e6edb1f631decd417cdbd39746a558 Signed-off-by: Matt Porter <mporter@konsulko.com>
Diffstat (limited to 'app')
-rw-r--r--app/Dialer.qml37
-rw-r--r--app/api/Telephony.qml20
2 files changed, 49 insertions, 8 deletions
diff --git a/app/Dialer.qml b/app/Dialer.qml
index 49495b3..5dc800a 100644
--- a/app/Dialer.qml
+++ b/app/Dialer.qml
@@ -28,6 +28,33 @@ Item {
API.Telephony {
id: telephony
url: bindingAddress
+ property string callStatus: "idle"
+ property string callClipColp: ""
+
+ onCallStatusChanged: {
+ if (callStatus == "incoming") {
+ ringtone.active = true
+ callStatusLabel.text = "Incoming call from " + callClipColp
+ } else if (callStatus == "dialing") {
+ callStatusLabel.text = "Calling " + callClipColp
+ } else if (callStatus == "idle") {
+ ringtone.active = false
+ callStatusLabel.text = ""
+ }
+ }
+ }
+
+ Loader {
+ id: ringtone
+ active: false
+ sourceComponent: Component {
+ SoundEffect {
+ loops: SoundEffect.Infinite
+ source: './Phone.wav'
+ category: 'phone'
+ Component.onCompleted: play()
+ }
+ }
}
signal showContacts
@@ -105,6 +132,12 @@ Item {
}
}
+ Label {
+ id: callStatusLabel
+ Layout.alignment: Qt.AlignHCenter
+ text: ""
+ }
+
ToggleButton {
id: callButton
Layout.alignment: Qt.AlignHCenter
@@ -123,11 +156,11 @@ Item {
if (contact.name === '')
contact.name = 'Unknown'
history.insert(0, contact)
- telephony.dial(number.text)
+ telephony.dial(number.text)
} else {
name.text = ''
number.text = ''
- telephony.hangup()
+ telephony.hangup()
}
}
}
diff --git a/app/api/Telephony.qml b/app/api/Telephony.qml
index 25af055..721a51a 100644
--- a/app/api/Telephony.qml
+++ b/app/api/Telephony.qml
@@ -39,7 +39,6 @@ WebSocket {
var json = JSON.parse(message)
var request = json[2].request
var response = json[2].response
- console.debug("response: " + JSON.stringify(response))
switch (json[0]) {
case msgid.call:
break
@@ -52,10 +51,22 @@ WebSocket {
console.debug("Hangup response")
}
break
- case msg.reterr:
+ case msgid.reterr:
root.statusString = "Bad return value, binding probably not installed"
break
- case MessageId.event:
+ case msgid.event:
+ var payload = JSON.parse(JSON.stringify(json[2]))
+ var event = payload.event
+ var data = payload.data
+ if (event == "telephony/incomingCall") {
+ callClipColp = data.clip
+ callStatus = "incoming"
+ } else if (event == "telephony/dialingCall") {
+ callClipColp = data.colp
+ callStatus = "dialing"
+ } else if (event == "telephony/terminatedCall") {
+ callStatus = "idle"
+ }
break
}
}
@@ -63,7 +74,6 @@ WebSocket {
onStatusChanged: {
switch (status) {
case WebSocket.Open:
- console.debug("onStatusChanged: Open")
break
case WebSocket.Error:
root.statusString = "WebSocket error: " + root.errorString
@@ -73,13 +83,11 @@ WebSocket {
function sendSocketMesage(verb, parameter) {
var requestJson = [ msgid.call, payloadLength, apiString + '/' + verb, parameter ]
- console.debug("sendSocketMessage: " + JSON.stringify(requestJson))
verbs.push(verb)
sendTextMessage(JSON.stringify(requestJson))
}
function dial(number) {
- console.debug("Dialing " + number)
var parameterJson = { value: number }
sendSocketMesage("dial", parameterJson)
}