summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomasz Sterna <tomek@xiaoka.com>2014-06-28 01:17:51 +0200
committerTomasz Sterna <tomek@xiaoka.com>2014-06-28 01:17:51 +0200
commit1d5e1b8dbb04d1ba916ff90445d22e0a145fd041 (patch)
tree48ad8df515cd8c5ee6f1d0f8d5c78033b4e012c1
parent5e00628e54cc2de39f0f893af01acb4596b501ce (diff)
Removed daemon features from appRELEASE_0.1
-rw-r--r--app/qml/pages/WatchPage.qml165
1 files changed, 1 insertions, 164 deletions
diff --git a/app/qml/pages/WatchPage.qml b/app/qml/pages/WatchPage.qml
index 6ffd06b..39312b3 100644
--- a/app/qml/pages/WatchPage.qml
+++ b/app/qml/pages/WatchPage.qml
@@ -43,173 +43,12 @@ import watch 0.1
Page {
id: page
+
property alias watchConnector: watchConnector
WatchConnector {
id: watchConnector
-
- onHangup: {
- // Watch instantiated hangup, follow the orders
- manager.hangupAll();
- }
- }
- property var callerDetails: new Object
-
- // This actually handles the voice call in SailfisOS
- VoiceCallManager {
- id:manager
-
- function hangupAll() {
- for (var index = 0; index < voiceCalls.count; index++) {
- voiceCalls.instance(index).hangup();
- }
- }
-
- onError: {
- console.log("Error: "+message)
- watchConnector.endPhoneCall();
- }
-
- function updateState() {
- //This needs cleaning up...
- var statusPriority = [
- VoiceCall.STATUS_ALERTING,
- VoiceCall.STATUS_DIALING,
- VoiceCall.STATUS_DISCONNECTED,
- VoiceCall.STATUS_ACTIVE,
- VoiceCall.STATUS_HELD,
- VoiceCall.STATUS_NULL
- ]
-
- var newPrimaryCall = null
- for (var p = 0; p < statusPriority.length; p++) {
- for (var i = 0; i < voiceCalls.count; i++) {
- if (voiceCalls.instance(i).status === statusPriority[p]) {
- newPrimaryCall = voiceCalls.instance(i)
- break
- }
- }
- if (newPrimaryCall) {
- break
- }
- }
- var person = "";
- if (newPrimaryCall && callerDetails[newPrimaryCall.handlerId]) {
- person = callerDetails[newPrimaryCall.handlerId].person
- }
-
- for (var ic = 0; ic < voiceCalls.count; ic++) {
- var call = voiceCalls.instance(ic)
- console.log("call: " + call.lineId + " state: " + call.statusText + " " + call.status + " " + call.handlerId + "\n")
- if (call.status === VoiceCall.STATUS_ALERTING || call.status === VoiceCall.STATUS_DIALING) {
- console.log("Tell outgoing: " + call.lineId);
- //FIXME: Not working?
- watchConnector.ring(call.lineId, person, 0);
- } else if (call.status === VoiceCall.STATUS_INCOMING || call.status === VoiceCall.STATUS_WAITING) {
- console.log("Tell incoming: " + call.lineId);
- watchConnector.ring(call.lineId, person);
- } else if (call.status === VoiceCall.STATUS_DISCONNECTED || call.status === VoiceCall.STATUS_NULL) {
- console.log("Endphone");
- watchConnector.endPhoneCall();
- } else if (call.status === VoiceCall.ACTIVE) {
- console.log("Startphone");
- watchConnector.startPhoneCall();
- }
- }
- }
- }
- Timer {
- id: updateStateTimer
- interval: 50
- onTriggered: manager.updateState()
- }
-
- // Receive the calls
- Instantiator {
- id: callMonitor
- model: manager.voiceCalls
-
- delegate: QtObject {
- property string callStatus: instance.status
- property string remoteUid
- property string person: ""
- onCallStatusChanged: {
- console.log("Status changed: " + callStatus);
- if (callStatus === VoiceCall.STATUS_DISCONNECTED || callStatus === VoiceCall.STATUS_NULL) {
- watchConnector.endPhoneCall();
- manager.updateState();
- } else {
- updateStateTimer.start();
- }
- }
- Component.onCompleted: {
- remoteUid = instance.lineId
- person = remoteUid !== "" ? people.personByPhoneNumber(remoteUid) : ""
- manager.updateState()
- }
- }
- onObjectAdded: {
- callerDetails[object.handlerId] = object
- }
- onObjectRemoved: {
- delete callerDetails[object.handlerId]
- manager.updateState()
- }
- }
-
- // Handle SMS (and other messages) via groups
- CommGroupManager {
- id: groupManager
- useBackgroundThread: true
- }
- CommContactGroupModel {
- id: groupModel
- manager: groupManager
-
- property var unreadGroups: [ ]
-
- onContactGroupCreated: {
- if (group.unreadMessages > 0) {
- unreadGroups.push(group)
- unreadSignalTimer.start()
- }
- }
-
- onContactGroupChanged: {
- var index = unreadGroups.indexOf(group)
- if (group.unreadMessages > 0 && index < 0) {
- unreadGroups.push(group)
- unreadSignalTimer.start()
- } else if (group.unreadMessages === 0 && index >= 0) {
- unreadGroups.splice(index, 1)
- unreadSignalTimer.start()
- }
- }
-
- onContactGroupRemoved: {
- var index = unreadGroups.indexOf(group)
- if (index >= 0) {
- unreadGroups.splice(index, 1)
- unreadSignalTimer.start()
- }
- }
-
- onUnreadGroupsChanged: {
- var group = groupModel.unreadGroups[0];
- if (group != undefined) {
- var name = group.contactNames.length ? group.contactNames[0] : group.groups[0].remoteUids[0];
- console.log("Msg: " + group.lastMessageText);
- console.log("From: " + name);
- watchConnector.sendSMSNotification(name?name:"Unknown", group.lastMessageText)
- }
- }
- }
- Timer {
- id: unreadSignalTimer
- interval: 1
- onTriggered: groupModel.unreadGroupsChanged()
}
-
SilicaFlickable {
anchors.fill: parent
@@ -278,5 +117,3 @@ Page {
}
}
}
-
-