2
* This file is part of dialer-app
4
* Copyright (C) 2013-2017 Canonical Ltd.
7
* Sebastien Bacher <sebastien.bacher@canonical.com>
8
* Jonas G. Drange <jonas.drange@canonical.com>
10
* This program is free software: you can redistribute it and/or modify it
11
* under the terms of the GNU General Public License version 3, as published
12
* by the Free Software Foundation.
14
* This program is distributed in the hope that it will be useful, but
15
* WITHOUT ANY WARRANTY; without even the implied warranties of
16
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
17
* PURPOSE. See the GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License along
20
* with this program. If not, see <http://www.gnu.org/licenses/>.
22
* TODO: Add centrally stored setting for each call forwarding that describes a
25
* TODO: If a setting failed to be set, the error text should be followed by
26
* “Contact {carrier name} for more information.”.
31
import MeeGo.QOfono 0.2
32
import Ubuntu.Components 1.3
33
import Ubuntu.Components.ListItems 1.3 as ListItem
34
import Ubuntu.Components.Popups 1.3
35
import Ubuntu.Components.Themes.Ambiance 0.1
36
import Ubuntu.Content 1.3
37
import "callForwardingUtils.js" as Utils
41
objectName: "callForwardingPage"
44
property string headerTitle: i18n.tr("Call forwarding")
45
property QtObject editing: null
46
property QtObject activeItem: null
47
property var activeTransfer
58
PropertyChanges { target: fwdSomeTitle; enabled: false }
59
PropertyChanges { target: fwdAll; enabled: false; }
60
PropertyChanges { target: fwdBusy; enabled: false; }
61
PropertyChanges { target: fwdLost; enabled: false; }
62
PropertyChanges { target: fwdUnreachable; enabled: false; }
63
when: fwdAll.busy || fwdBusy.busy || fwdLost.busy || fwdUnreachable.busy
67
PropertyChanges { target: fwdSomeTitle; enabled: false }
68
PropertyChanges { target: fwdFailedLabel; visible: true }
69
PropertyChanges { target: fwdAll; enabled: false; }
70
PropertyChanges { target: fwdBusy; enabled: false; }
71
PropertyChanges { target: fwdLost; enabled: false; }
72
PropertyChanges { target: fwdUnreachable; enabled: false; }
76
PropertyChanges { target: fwdAll; enabled: false; explicit: true }
77
PropertyChanges { target: fwdBusy; enabled: false; explicit: true }
78
PropertyChanges { target: fwdLost; enabled: false; explicit: true }
79
PropertyChanges { target: fwdUnreachable; enabled: false; explicit: true }
80
PropertyChanges { target: fwdSomeTitle; enabled: false }
82
name: "editingEnabled"
85
editing.enabled = true;
88
when: editing !== null
92
PropertyChanges { target: fwdSomeTitle; }
93
PropertyChanges { target: fwdBusy; enabled: false; value: ""; checked: false }
94
PropertyChanges { target: fwdLost; enabled: false; value: ""; checked: false }
95
PropertyChanges { target: fwdUnreachable; enabled: false; value: ""; checked: false }
96
when: fwdAll.value !== ""
103
// this is necessary to avoid the page to appear below the header
105
flickableDirection: Flickable.VerticalFlick
108
bottomMargin: keyboardButtons.height + keyboard.height
110
contentHeight: contents.height + units.gu(2)
111
contentWidth: parent.width
113
// after add a new field we need to wait for the contentHeight to
114
// change to scroll to the correct position
115
onContentHeightChanged: Utils.show(page.activeItem)
119
anchors { left: parent.left; right: parent.right }
124
anchors { left: parent.left; right: parent.right }
125
rule: "voiceUnconditional"
126
callForwarding: callForwarding
127
text: i18n.tr("Forward every incoming call")
128
onEnteredEditMode: {page.editing = fwdAll; Utils.show(field)}
129
onLeftEditMode: page.editing = null
135
left: parent.left; right: parent.right; margins: units.gu(1)
138
wrapMode: Text.WordWrap
140
horizontalAlignment: Text.AlignHCenter
141
verticalAlignment: Text.AlignVCenter
142
text: i18n.tr("Redirects all phone calls to another number.")
149
left: parent.left; right: parent.right; margins: units.gu(2)
152
wrapMode: Text.WordWrap
154
text: i18n.tr("Call forwarding status can't be checked " +
155
"now. Try again later.")
156
color: theme.palette.normal.negative
157
horizontalAlignment: Text.AlignHCenter
162
text: i18n.tr("Forward incoming calls when:")
167
objectName: "fwdBusy"
168
anchors { left: parent.left; right: parent.right }
169
callForwarding: callForwarding
171
text: i18n.tr("I'm on another call")
172
onEnteredEditMode: {page.editing = fwdBusy; Utils.show(field)}
173
onLeftEditMode: page.editing = null
178
objectName: "fwdLost"
179
anchors { left: parent.left; right: parent.right }
180
callForwarding: callForwarding
182
text: i18n.tr("I don't answer")
183
onEnteredEditMode: {page.editing = fwdLost; Utils.show(field)}
184
onLeftEditMode: page.editing = null
189
objectName: "fwdUnreachable"
190
anchors { left: parent.left; right: parent.right }
191
callForwarding: callForwarding
192
rule: "voiceNotReachable"
193
text: i18n.tr("My phone is unreachable")
195
page.editing = fwdUnreachable;
198
onLeftEditMode: page.editing = null
210
color: Theme.palette.selected.background
211
visible: editing !== null
215
objectName: "contactsButton"
218
leftMargin: units.gu(1)
219
verticalCenter: parent.verticalCenter
221
activeFocusOnPress: false
222
enabled: editing && !editing.busy
223
text: i18n.tr("Contacts...")
224
onClicked: page.activeTransfer = contactPicker.request()
229
objectName: "cancelButton"
232
rightMargin: units.gu(1)
233
verticalCenter: parent.verticalCenter
235
enabled: editing && !editing.busy
236
text: i18n.tr("Cancel")
237
onClicked: editing.cancel()
242
objectName: "setButton"
245
rightMargin: units.gu(1)
246
verticalCenter: parent.verticalCenter
248
enabled: editing && !editing.busy && editing.field.text
250
activeFocusOnPress: false
251
onClicked: editing.save()
257
anchors.bottom: parent.bottom
259
if (page.activeItem) {
260
Utils.show(page.activeItem);
266
id: chooseNumberDialog
270
title: i18n.tr("Please select a phone number")
272
ListItem.ItemSelector {
277
activeFocusOnPress: false
279
text: i18n.tr("Numbers")
280
model: contact.phoneNumbers
282
delegate: OptionSelectorDelegate {
283
text: modelData.number
284
activeFocusOnPress: false
287
editing.field.text = contact.phoneNumbers[index].number;
288
PopupUtils.close(dialog);
295
id: hadNoNumberDialog
298
title: i18n.tr("Could not forward to this contact")
299
text: i18n.tr("Contact not associated with any phone number.")
302
activeFocusOnPress: false
303
onClicked: PopupUtils.close(dialog)
311
function parseContact(vcardContact) {
317
if (contacts.length === 0) {
318
console.warn('no contacts parsed');
321
contact = parseContact(contacts[0]);
322
if (contact.phoneNumbers.length < 1) {
323
PopupUtils.open(hadNoNumberDialog);
324
} else if (contact.phoneNumbers.length > 1) {
325
PopupUtils.open(chooseNumberDialog, page, {
329
editing.field.text = contact.phoneNumber.number;
335
ContentTransferHint {
338
activeTransfer: page.activeTransfer
343
contentType: ContentType.Contacts
344
handler: ContentHandler.Source
345
selectionType: ContentTransfer.Single
349
target: page.activeTransfer ? page.activeTransfer : null
351
if (page.activeTransfer.state === ContentTransfer.Charged) {
352
contactParser.vCardUrl = page.activeTransfer.items[0].url;
358
target: callForwarding
359
onGetPropertiesFailed: page.state = "forwardFailed";
362
OfonoCallForwarding {
365
function updateSummary () {
368
// Clear the summary and exit if any of the values are unknown.
369
if (typeof voiceUnconditional === 'undefined' ||
370
typeof voiceBusy === 'undefined' ||
371
typeof voiceNoReply === 'undefined' ||
372
typeof voiceNotReachable === 'undefined') {
373
sim.setCallForwardingSummary('');
377
if (voiceUnconditional) {
378
val = i18n.tr("All calls");
379
} else if (voiceBusy || voiceNoReply || voiceNotReachable) {
380
val = i18n.tr("Some calls")
384
sim.setCallForwardingSummary(val);
387
Component.onCompleted: updateSummary()
388
onVoiceUnconditionalChanged: updateSummary()
389
onVoiceBusyChanged: updateSummary()
390
onVoiceNoReplyChanged: updateSummary()
391
onVoiceNotReachableChanged: updateSummary()