Merge lp:~jonas-drange/ubuntu-system-settings/rtm-1388044 into lp:ubuntu-system-settings/rtm-14.09
- rtm-1388044
- Merge into rtm-14.09
Status: | Rejected |
---|---|
Rejected by: | Jonas G. Drange |
Proposed branch: | lp:~jonas-drange/ubuntu-system-settings/rtm-1388044 |
Merge into: | lp:ubuntu-system-settings/rtm-14.09 |
Diff against target: |
828 lines (+488/-223) 7 files modified
plugins/cellular/Components/MultiSim.qml (+3/-4) plugins/cellular/Components/RadioSingleSim.qml (+59/-0) plugins/cellular/Components/SingleSim.qml (+4/-15) plugins/cellular/PageCarrierAndApn.qml (+68/-0) plugins/cellular/PageCarriersAndApns.qml (+43/-22) plugins/cellular/PageChooseCarrier.qml (+205/-182) plugins/cellular/carriers.js (+106/-0) |
To merge this branch: | bzr merge lp:~jonas-drange/ubuntu-system-settings/rtm-1388044 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ken VanDine | Needs Fixing | ||
PS Jenkins bot | continuous-integration | Needs Fixing | |
Review via email: mp+244477@code.launchpad.net |
Commit message
[cellular/carriers] new Carrier & APN entry, as well as a major refactor of carrier selection code warranted by the design change.
Description of the change
[cellular/carriers] new Carrier & APN entry, as well as a major refactor of carrier selection code warranted by the design change.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:949
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild:
http://
Ken VanDine (ken-vandine) wrote : | # |
Getting a merge conflict
Unmerged revisions
- 949. By Jonas G. Drange
-
merge manually, since this just didn't merge at all
- 948. By Jonas G. Drange
-
merging ~jonas-
drange/ ubuntu- system- settings/ cellular- manual- carrier- persist- fix-1388044
Preview Diff
1 | === modified file 'plugins/cellular/Components/MultiSim.qml' |
2 | --- plugins/cellular/Components/MultiSim.qml 2014-10-06 19:38:06 +0000 |
3 | +++ plugins/cellular/Components/MultiSim.qml 2014-12-11 16:59:19 +0000 |
4 | @@ -36,8 +36,6 @@ |
5 | anchors { left: parent.left; right: parent.right } |
6 | } |
7 | |
8 | - ListItem.Divider {} |
9 | - |
10 | ListItem.SingleValue { |
11 | text : i18n.tr("Hotspot disabled because Wi-Fi is off.") |
12 | visible: showAllUI && !hotspotItem.visible |
13 | @@ -67,10 +65,11 @@ |
14 | ListItem.SingleValue { |
15 | text: i18n.tr("Carriers") |
16 | id: chooseCarrier |
17 | - objectName: "chooseCarrier" |
18 | + objectName: "carrierApnEntry" |
19 | progression: enabled |
20 | + showDivider: false |
21 | onClicked: { |
22 | - pageStack.push(Qt.resolvedUrl("../PageChooseCarriers.qml"), { |
23 | + pageStack.push(Qt.resolvedUrl("../PageCarriersAndApns.qml"), { |
24 | sims: sims |
25 | }); |
26 | } |
27 | |
28 | === added file 'plugins/cellular/Components/RadioSingleSim.qml' |
29 | --- plugins/cellular/Components/RadioSingleSim.qml 1970-01-01 00:00:00 +0000 |
30 | +++ plugins/cellular/Components/RadioSingleSim.qml 2014-12-11 16:59:19 +0000 |
31 | @@ -0,0 +1,59 @@ |
32 | +/* |
33 | + * Copyright (C) 2014 Canonical Ltd |
34 | + * |
35 | + * This program is free software: you can redistribute it and/or modify |
36 | + * it under the terms of the GNU General Public License version 3 as |
37 | + * published by the Free Software Foundation. |
38 | + * |
39 | + * This program is distributed in the hope that it will be useful, |
40 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
41 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
42 | + * GNU General Public License for more details. |
43 | + * |
44 | + * You should have received a copy of the GNU General Public License |
45 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
46 | + * |
47 | + * Authors: |
48 | + * Jonas G. Drange <jonas.drange@canonical.com> |
49 | + * |
50 | +*/ |
51 | +import QtQuick 2.0 |
52 | +import SystemSettings 1.0 |
53 | +import Ubuntu.Components 0.1 |
54 | +import Ubuntu.Components.ListItems 0.1 as ListItem |
55 | + |
56 | +Column { |
57 | + height: childrenRect.height |
58 | + |
59 | + property alias selector: selector |
60 | + |
61 | + SettingsItemTitle { text: i18n.tr("Connection type:") } |
62 | + |
63 | + ListItem.ItemSelector { |
64 | + id: selector |
65 | + showDivider: false |
66 | + expanded: true |
67 | + |
68 | + // an empty string is not a valid preference, which means |
69 | + // we disregard the interace and disable the selector |
70 | + enabled: sim.radioSettings.technologyPreference !== "" |
71 | + model: sim.radioSettings.modemTechnologies |
72 | + |
73 | + delegate: OptionSelectorDelegate { |
74 | + objectName: sim.path + "_radio_" + modelData |
75 | + text: { |
76 | + return { |
77 | + 'gsm': i18n.tr("2G only (saves battery)"), |
78 | + 'umts': i18n.tr("2G/3G (faster)"), |
79 | + 'lte': i18n.tr("2G/3G/4G (faster)") |
80 | + }[modelData] |
81 | + } |
82 | + showDivider: false |
83 | + } |
84 | + selectedIndex: model.indexOf(sim.radioSettings.technologyPreference) |
85 | + onDelegateClicked: { |
86 | + sim.radioSettings.technologyPreference = model[index]; |
87 | + } |
88 | + } |
89 | + |
90 | +} |
91 | |
92 | === modified file 'plugins/cellular/Components/SingleSim.qml' |
93 | --- plugins/cellular/Components/SingleSim.qml 2014-10-02 09:50:11 +0000 |
94 | +++ plugins/cellular/Components/SingleSim.qml 2014-12-11 16:59:19 +0000 |
95 | @@ -57,21 +57,10 @@ |
96 | ListItem.SingleValue { |
97 | text: i18n.tr("Carrier"); |
98 | id: chooseCarrier |
99 | - objectName: "chooseCarrier" |
100 | + objectName: "carrierApnEntry" |
101 | progression: enabled |
102 | - value: sim.netReg.name || i18n.tr("N/A") |
103 | - enabled: sim.netReg.status !== "" |
104 | - onClicked: { |
105 | - pageStack.push(Qt.resolvedUrl("../PageChooseCarrier.qml"), { |
106 | - sim: sim, |
107 | - title: i18n.tr("Carrier") |
108 | - }) |
109 | - } |
110 | - } |
111 | - |
112 | - ListItem.Standard { |
113 | - text: i18n.tr("APN") |
114 | - progression: true |
115 | - visible: showAllUI |
116 | + onClicked: pageStack.push(Qt.resolvedUrl("../PageCarrierAndApn.qml"), { |
117 | + sim: sim |
118 | + }) |
119 | } |
120 | } |
121 | |
122 | === added file 'plugins/cellular/PageCarrierAndApn.qml' |
123 | --- plugins/cellular/PageCarrierAndApn.qml 1970-01-01 00:00:00 +0000 |
124 | +++ plugins/cellular/PageCarrierAndApn.qml 2014-12-11 16:59:19 +0000 |
125 | @@ -0,0 +1,68 @@ |
126 | +/* |
127 | +/* |
128 | + * Copyright (C) 2014 Canonical Ltd |
129 | + * |
130 | + * This program is free software: you can redistribute it and/or modify |
131 | + * it under the terms of the GNU General Public License version 3 as |
132 | + * published by the Free Software Foundation. |
133 | + * |
134 | + * This program is distributed in the hope that it will be useful, |
135 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
136 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
137 | + * GNU General Public License for more details. |
138 | + * |
139 | + * You should have received a copy of the GNU General Public License |
140 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
141 | + * |
142 | + * Authors: |
143 | + * Jonas G. Drange <jonas.drange@canonical.com> |
144 | + * |
145 | +*/ |
146 | +import QtQuick 2.0 |
147 | +import SystemSettings 1.0 |
148 | +import Ubuntu.Components 0.1 |
149 | +import Ubuntu.Components.ListItems 0.1 as ListItem |
150 | + |
151 | +ItemPage { |
152 | + id: root |
153 | + title: i18n.tr("Carrier") |
154 | + objectName: "carrierApnPage" |
155 | + flickable: null |
156 | + |
157 | + property var sim |
158 | + |
159 | + Flickable { |
160 | + anchors.fill: parent |
161 | + contentWidth: parent.width |
162 | + contentHeight: contentItem.childrenRect.height |
163 | + boundsBehavior: (contentHeight > root.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds |
164 | + |
165 | + Column { |
166 | + anchors.left: parent.left |
167 | + anchors.right: parent.right |
168 | + |
169 | + ListItem.SingleValue { |
170 | + text: i18n.tr("Carrier") |
171 | + objectName: "carrier" |
172 | + value: sim.netReg.name ? sim.netReg.name : i18n.tr("None") |
173 | + enabled: (sim.netReg.status !== "") && |
174 | + (sim.netReg.mode !== "auto-only") |
175 | + progression: enabled |
176 | + onClicked: pageStack.push(Qt.resolvedUrl("PageChooseCarrier.qml"), { |
177 | + sim: sim, |
178 | + title: i18n.tr("Carrier") |
179 | + }) |
180 | + } |
181 | + |
182 | + ListItem.Standard { |
183 | + text: i18n.tr("APN") |
184 | + objectName: "apn" |
185 | + progression: enabled |
186 | + enabled: sim.connMan.powered |
187 | + onClicked: pageStack.push(Qt.resolvedUrl("PageChooseApn.qml"), { |
188 | + sim: sim |
189 | + }) |
190 | + } |
191 | + } |
192 | + } |
193 | +} |
194 | |
195 | === renamed file 'plugins/cellular/PageChooseCarriers.qml' => 'plugins/cellular/PageCarriersAndApns.qml' |
196 | --- plugins/cellular/PageChooseCarriers.qml 2014-10-06 19:38:06 +0000 |
197 | +++ plugins/cellular/PageCarriersAndApns.qml 2014-12-11 16:59:19 +0000 |
198 | @@ -25,7 +25,8 @@ |
199 | ItemPage { |
200 | id: root |
201 | title: i18n.tr("Carriers") |
202 | - objectName: "chooseCarriersPage" |
203 | + objectName: "carrierApnPage" |
204 | + flickable: null |
205 | |
206 | property var sims |
207 | |
208 | @@ -39,38 +40,58 @@ |
209 | anchors.left: parent.left |
210 | anchors.right: parent.right |
211 | |
212 | - ListItem.Standard { |
213 | + SettingsItemTitle { |
214 | text: sims[0].title |
215 | } |
216 | |
217 | ListItem.SingleValue { |
218 | - objectName: "chooseCarrierSim1" |
219 | - value: sims[0].netReg.name ? sims[0].netReg.name : i18n.tr("N/A") |
220 | - enabled: sims[0].netReg.status !== "" |
221 | - progression: true |
222 | - onClicked: { |
223 | - pageStack.push(Qt.resolvedUrl("PageChooseCarrier.qml"), { |
224 | - sim: sims[0], |
225 | - title: sims[0].title |
226 | - }) |
227 | - } |
228 | + text: i18n.tr("Carrier") |
229 | + objectName: sims[0].path + "_carriers" |
230 | + value: sims[0].netReg.name ? sims[0].netReg.name : |
231 | + i18n.tr("None") |
232 | + enabled: (sims[0].netReg.status !== "") && |
233 | + (sims[0].netReg.mode !== "auto-only") |
234 | + progression: enabled |
235 | + onClicked: pageStack.push(Qt.resolvedUrl("PageChooseCarrier.qml"), { |
236 | + sim: sims[0], |
237 | + title: sims[0].title |
238 | + }) |
239 | } |
240 | |
241 | ListItem.Standard { |
242 | + text: i18n.tr("APN") |
243 | + progression: enabled |
244 | + enabled: sims[0].connMan.powered |
245 | + onClicked: pageStack.push(Qt.resolvedUrl("PageChooseApn.qml"), { |
246 | + sim: sims[0] |
247 | + }) |
248 | + } |
249 | + |
250 | + SettingsItemTitle { |
251 | text: sims[1].title |
252 | } |
253 | |
254 | ListItem.SingleValue { |
255 | - objectName: "chooseCarrierSim2" |
256 | - value: sims[1].netReg.name ? sims[1].netReg.name : i18n.tr("N/A") |
257 | - enabled: sims[1].netReg.status !== "" |
258 | - progression: true |
259 | - onClicked: { |
260 | - pageStack.push(Qt.resolvedUrl("PageChooseCarrier.qml"), { |
261 | - sim: sims[1], |
262 | - title: sims[1].title |
263 | - }) |
264 | - } |
265 | + text: i18n.tr("Carrier") |
266 | + objectName: sims[1].path + "_carriers" |
267 | + value: sims[1].netReg.name ? sims[1].netReg.name : |
268 | + i18n.tr("None") |
269 | + enabled: (sims[1].netReg.status !== "") && |
270 | + (sims[1].netReg.mode !== "auto-only") |
271 | + progression: enabled |
272 | + onClicked: pageStack.push(Qt.resolvedUrl("PageChooseCarrier.qml"), { |
273 | + sim: sims[1], |
274 | + title: sims[1].title |
275 | + }) |
276 | + } |
277 | + |
278 | + ListItem.Standard { |
279 | + text: i18n.tr("APN") |
280 | + progression: enabled |
281 | + enabled: sims[1].connMan.powered |
282 | + onClicked: pageStack.push(Qt.resolvedUrl("PageChooseApn.qml"), { |
283 | + sim: sims[1] |
284 | + }) |
285 | } |
286 | } |
287 | } |
288 | |
289 | === modified file 'plugins/cellular/PageChooseCarrier.qml' |
290 | --- plugins/cellular/PageChooseCarrier.qml 2014-10-06 12:56:18 +0000 |
291 | +++ plugins/cellular/PageChooseCarrier.qml 2014-12-11 16:59:19 +0000 |
292 | @@ -4,6 +4,7 @@ |
293 | * Copyright (C) 2013 Canonical Ltd. |
294 | * |
295 | * Contact: Iain Lane <iain.lane@canonical.com> |
296 | + * Jonas G. Drange <jonas.drange@canonical.com> |
297 | * |
298 | * This program is free software: you can redistribute it and/or modify it |
299 | * under the terms of the GNU General Public License version 3, as published |
300 | @@ -24,213 +25,235 @@ |
301 | import Ubuntu.Components 1.1 |
302 | import Ubuntu.Components.ListItems 1.0 as ListItem |
303 | import MeeGo.QOfono 0.2 |
304 | +import "carriers.js" as CHelper |
305 | |
306 | ItemPage { |
307 | id: root |
308 | title: i18n.tr("Carrier") |
309 | - |
310 | objectName: "chooseCarrierPage" |
311 | + flickable: null |
312 | |
313 | property var sim |
314 | - |
315 | - property variant operatorNames |
316 | - property int mode |
317 | - |
318 | - QtObject { |
319 | - id: d |
320 | - property bool __suppressActivation : true; |
321 | - } |
322 | - |
323 | - Component.onCompleted: { |
324 | - updateNetworkOperators(); |
325 | - } |
326 | - |
327 | - Connections { |
328 | - target: sim.netReg |
329 | - onNetworkOperatorsChanged: updateNetworkOperators(); |
330 | - onCurrentOperatorPathChanged: buildLists(); |
331 | - } |
332 | - |
333 | - // map of operatorPath : netOp |
334 | - property var operators: ({}) |
335 | - function updateNetworkOperators() |
336 | - { |
337 | - var tmp = sim.netReg.networkOperators; |
338 | - var added = tmp.filter(function(i) { |
339 | - return operators[i] === undefined; |
340 | - }); |
341 | - var removed = Object.keys(operators).filter(function(i) { |
342 | - return tmp.indexOf(i) === -1; |
343 | - }) |
344 | - |
345 | - removed.forEach(function(currentValue, index, array) { |
346 | - // just asserting to verify the logic |
347 | - // remove once proven functional |
348 | - if (operators[currentValue] === undefined) { |
349 | - throw "updateNetworkOperators: removed is broken"; |
350 | - } |
351 | - |
352 | - operators[currentValue].destroy(); |
353 | - delete operators[currentValue]; |
354 | - }); |
355 | - |
356 | - added.forEach(function(currentValue, index, array) { |
357 | - // just asserting to verify the logic |
358 | - // remove once proven functional |
359 | - if (operators[currentValue] !== undefined) { |
360 | - throw "updateNetworkOperators: added is broken"; |
361 | - } |
362 | - |
363 | - operators[currentValue] = netOp.createObject(parent, |
364 | - { |
365 | - "operatorPath": currentValue |
366 | - }); |
367 | - }); |
368 | - |
369 | - // just asserting to verify the logic |
370 | - // remove once proven functional |
371 | - if (Object.keys(operators).length !== tmp.length) { |
372 | - throw "Object.keys(operators).length !== tmp.length"; |
373 | - } |
374 | - tmp.forEach(function(currentValue, index, array) { |
375 | - if (operators[currentValue] === undefined) |
376 | - throw "operators[currentValue] === undefined"; |
377 | - }); |
378 | - |
379 | - buildLists(); |
380 | - } |
381 | - |
382 | - function buildLists() |
383 | - { |
384 | - d.__suppressActivation = true; |
385 | - var oN = new Array(); |
386 | - |
387 | - for (var i in operators) { |
388 | - var tempOp = operators[i]; |
389 | - if (tempOp.status === "forbidden") |
390 | - continue |
391 | - oN.push(tempOp.name); |
392 | - } |
393 | - operatorNames = oN; |
394 | - |
395 | - var cur = operators[sim.netReg.currentOperatorPath]; |
396 | - carrierSelector.selectedIndex = cur === undefined ? -1 : operatorNames.indexOf(cur.name); |
397 | - d.__suppressActivation = false; |
398 | - } |
399 | + property bool scanning: true |
400 | + property bool working: false |
401 | + |
402 | + states: [ |
403 | + State { |
404 | + name: "auto" |
405 | + when: sim.netReg.mode === "auto" |
406 | + PropertyChanges { |
407 | + target: otherOperators |
408 | + selectedIndex: -1 |
409 | + } |
410 | + PropertyChanges { |
411 | + target: allOperators |
412 | + height: 0 |
413 | + opacity: 0 |
414 | + } |
415 | + }, |
416 | + State { |
417 | + name: "manual" |
418 | + when: sim.netReg.mode === "manual" |
419 | + PropertyChanges { |
420 | + target: otherOperators |
421 | + height: 0 |
422 | + opacity: 0 |
423 | + } |
424 | + } |
425 | + /* Note that we do not consider auto-only since this page is not |
426 | + reachable in that case (see Carrier & APN page). */ |
427 | + ] |
428 | |
429 | Component { |
430 | id: netOp |
431 | OfonoNetworkOperator { |
432 | onRegisterComplete: { |
433 | - if (error === OfonoNetworkOperator.InProgressError) { |
434 | - console.warn("registerComplete failed with error: " + errorString); |
435 | - } else if (error !== OfonoNetworkOperator.NoError) { |
436 | - console.warn("registerComplete failed with error: " + errorString + " Falling back to default"); |
437 | + if (error !== OfonoNetworkOperator.NoError) { |
438 | + console.warn("Register complete:", errorString); |
439 | + console.warn("Falling back to default operator."); |
440 | sim.netReg.registration(); |
441 | } |
442 | - } |
443 | - onNameChanged: buildLists(); |
444 | - onStatusChanged: buildLists(); |
445 | - } |
446 | - } |
447 | + working = false; |
448 | + } |
449 | + } |
450 | + } |
451 | + |
452 | + Connections { |
453 | + /* The following is a hack: If a scan is in progress and we call |
454 | + scan() on netReg, it emits a scanError _and_ scanFinished. |
455 | + We look at the scanError message, set this property to true if |
456 | + it says a scan is in progress. This way we can ignore the bad |
457 | + scanFinished signal. Filed bug against libqofono[1]. |
458 | + [1] https://github.com/nemomobile/libqofono/issues/52 |
459 | + */ |
460 | + property bool __scanInProgress: false |
461 | + |
462 | + target: sim.netReg |
463 | + onScanFinished: { |
464 | + if (scanning && !__scanInProgress) { |
465 | + scanning = false; |
466 | + } |
467 | + __scanInProgress = false; |
468 | + } |
469 | + onScanError: { |
470 | + if (message === "Operation already in progress") { |
471 | + console.warn('A scan was already in progress.'); |
472 | + __scanInProgress = true; |
473 | + } else { |
474 | + scanning = false; |
475 | + __scanInProgress = false; |
476 | + console.warn("onScanError: " + message); |
477 | + } |
478 | + } |
479 | + onModeChanged: modeSelector.selectedIndex = (mode === "auto") ? 0 : -1 |
480 | + } |
481 | + |
482 | + Component.onCompleted: sim.netReg.scan() |
483 | |
484 | Flickable { |
485 | id: scrollWidget |
486 | anchors.fill: parent |
487 | contentWidth: parent.width |
488 | - contentHeight: parent.height |
489 | - boundsBehavior: (contentHeight > parent.height) ? Flickable.DragAndOvershootBounds : Flickable.StopAtBounds |
490 | + contentHeight: contentItem.childrenRect.height |
491 | + boundsBehavior: (contentHeight > root.height) ? |
492 | + Flickable.DragAndOvershootBounds : Flickable.StopAtBounds |
493 | |
494 | - ColumnLayout { |
495 | + Column { |
496 | anchors { |
497 | left: parent.left |
498 | right: parent.right |
499 | } |
500 | - |
501 | - ListItem.ItemSelector { |
502 | - id: chooseCarrier |
503 | - objectName: "autoChooseCarrierSelector" |
504 | - expanded: true |
505 | - enabled: sim.netReg.mode !== "auto-only" |
506 | - text: i18n.tr("Choose carrier:") |
507 | - model: [i18n.tr("Automatically"), i18n.tr("Manually")] |
508 | - |
509 | - delegate: OptionSelectorDelegate { showDivider: false } |
510 | - selectedIndex: sim.netReg.mode === "manual" ? 1 : 0 |
511 | - |
512 | - // we only want to do this per user input |
513 | + spacing: 0 |
514 | + |
515 | + SettingsItemTitle { |
516 | + text: i18n.tr("Carrier") |
517 | + |
518 | + ActivityIndicator { |
519 | + anchors { |
520 | + right: parent.right |
521 | + top: parent.top |
522 | + margins: units.gu(1.5) |
523 | + } |
524 | + running: true |
525 | + opacity: scanning || working ? 1 : 0 |
526 | + Behavior on opacity { |
527 | + NumberAnimation { |
528 | + duration: UbuntuAnimation.SnapDuration |
529 | + } |
530 | + } |
531 | + } |
532 | + } |
533 | + |
534 | + ListItem.ItemSelector { |
535 | + id: modeSelector |
536 | + objectName: "mode" |
537 | + expanded: true |
538 | + enabled: !scanning && !working |
539 | + opacity: enabled ? 1 : 0.5 |
540 | + model: [i18n.tr("Automatically")] |
541 | + delegate: OptionSelectorDelegate { |
542 | + text: { |
543 | + // modelData is "Automatically" |
544 | + if (sim.netReg.mode === "auto") { |
545 | + return sim.netReg.name ? |
546 | + modelData + " [ " + sim.netReg.name + " ]" : |
547 | + modelData |
548 | + } else { |
549 | + return modelData; |
550 | + } |
551 | + } |
552 | + showDivider: false |
553 | + } |
554 | + selectedIndex: sim.netReg.mode === "auto" ? 0 : -1 |
555 | + |
556 | + /* When registration() fails, the UI state may end up in an |
557 | + undefined state. Issue[1] has been filed against libqofono. |
558 | + [1] https://github.com/nemomobile/libqofono/issues/54 |
559 | + */ |
560 | + onDelegateClicked: sim.netReg.registration() |
561 | + } |
562 | + |
563 | + // In manual mode, all non-forbidden operators are shown. |
564 | + ListItem.ItemSelector { |
565 | + id: allOperators |
566 | + objectName: "allOperators" |
567 | + expanded: true |
568 | + enabled: !scanning && !working |
569 | + opacity: enabled ? 1 : 0.5 |
570 | + model: CHelper.getOps(sim.netReg.networkOperators) |
571 | + delegate: OptionSelectorDelegate { |
572 | + objectName: "carrier" |
573 | + showDivider: false |
574 | + text: modelData.name |
575 | + } |
576 | + onDelegateClicked: { |
577 | + CHelper.setOp(model[index].operatorPath); |
578 | + working = true; |
579 | + } |
580 | + selectedIndex: { |
581 | + var curop = sim.netReg.currentOperatorPath; |
582 | + return model.indexOf(CHelper.getOrCreateOpQml(curop)); |
583 | + } |
584 | + |
585 | + Behavior on height { |
586 | + NumberAnimation { |
587 | + duration: UbuntuAnimation.SnapDuration |
588 | + } |
589 | + } |
590 | + |
591 | + Behavior on opacity { |
592 | + NumberAnimation { |
593 | + duration: UbuntuAnimation.SnapDuration |
594 | + } |
595 | + } |
596 | + } |
597 | + |
598 | + /* When registration mode is "Automatic", this list contains all |
599 | + the non-forbidden operators except the current one. When the user |
600 | + taps one of the elements in this selector, it will be hidden, |
601 | + and the mode will switch to "Manual". */ |
602 | + ListItem.ItemSelector { |
603 | + id: otherOperators |
604 | + objectName: "otherOperators" |
605 | + expanded: true |
606 | + enabled: !scanning && !working |
607 | + opacity: enabled ? 1 : 0.5 |
608 | + model: CHelper.getOps(sim.netReg.networkOperators, |
609 | + [sim.netReg.currentOperatorPath]) |
610 | + delegate: OptionSelectorDelegate { |
611 | + objectName: "carrier" |
612 | + showDivider: false |
613 | + text: modelData.name |
614 | + } |
615 | + onDelegateClicked: { |
616 | + var clickedOp = model[index].operatorPath; |
617 | + CHelper.setOp(clickedOp); |
618 | + |
619 | + // Update immediately and do not wait for netReg |
620 | + allOperators.selectedIndex = allOperators.model.indexOf( |
621 | + CHelper.getOrCreateOpQml(clickedOp)); |
622 | + working = true; |
623 | + } |
624 | onSelectedIndexChanged: { |
625 | - if (selectedIndex === -1 || d.__suppressActivation) |
626 | - return; |
627 | - |
628 | - if (selectedIndex === 0) { |
629 | - sim.netReg.registration(); |
630 | - } else if (selectedIndex === 1) { |
631 | - if (sim.netReg.status !== "searching") |
632 | - sim.netReg.scan(); |
633 | - } |
634 | - } |
635 | - } |
636 | - ListItem.SingleControl { |
637 | - enabled: chooseCarrier.selectedIndex === 1 |
638 | - anchors { |
639 | - left: parent.left |
640 | - leftMargin: units.gu(0) |
641 | - } |
642 | - control: ColumnLayout { |
643 | - id: child |
644 | - width: parent.width - units.gu(4) |
645 | - anchors.left: parent.left |
646 | - RowLayout { |
647 | - id: searchingRow |
648 | - spacing: units.gu(1) |
649 | - |
650 | - visible: sim.netReg.status === "searching" |
651 | - ActivityIndicator { |
652 | - id: activityIndicator |
653 | - anchors.verticalCenter: parent.verticalCenter |
654 | - running: parent.visible |
655 | - } |
656 | - Label { |
657 | - anchors.verticalCenter: parent.verticalCenter |
658 | - text: i18n.tr("Searching for carriers…") |
659 | - } |
660 | - } |
661 | - ListItem.ItemSelector { |
662 | - id: carrierSelector |
663 | - objectName: "carrierSelector" |
664 | - expanded: true |
665 | - enabled: sim.netReg.status !== "searching" && chooseCarrier.selectedIndex === 1 |
666 | - // work around ItemSelector not having a visual change depending on being disabled |
667 | - opacity: enabled ? 1.0 : 0.5 |
668 | - width: parent.width |
669 | - model: operatorNames |
670 | - delegate: OptionSelectorDelegate { enabled: carrierSelector.enabled; showDivider: false } |
671 | - onSelectedIndexChanged: { |
672 | - if (selectedIndex === -1 || d.__suppressActivation) |
673 | - return; |
674 | - |
675 | - // this assumes operator names are unique, |
676 | - // revise if not so |
677 | - for (var op in operators) { |
678 | - if (operators[op].name === operatorNames[selectedIndex]) { |
679 | - operators[op].registerOperator(); |
680 | - return; |
681 | - } |
682 | - } |
683 | - // just asserting to verify the logic |
684 | - // remove once proven functional |
685 | - throw "should not be reached."; |
686 | - } |
687 | - } |
688 | - } |
689 | - } |
690 | - ListItem.Standard { |
691 | - text: i18n.tr("APN") |
692 | - progression: true |
693 | - enabled: sim.connMan.powered |
694 | - onClicked: { |
695 | - pageStack.push(Qt.resolvedUrl("PageChooseApn.qml"), {sim: sim}) |
696 | + /* When e.g. the model changes, the selectedIndex is set to |
697 | + 0. Ignore this, since we never want the selectedIndex to be |
698 | + anything other than -1. This component is shown only when |
699 | + registration is "Automatic". */ |
700 | + if (selectedIndex >= 0) { |
701 | + selectedIndex = -1; |
702 | + } |
703 | + } |
704 | + |
705 | + Behavior on height { |
706 | + NumberAnimation { |
707 | + duration: UbuntuAnimation.SnapDuration |
708 | + } |
709 | + } |
710 | + |
711 | + Behavior on opacity { |
712 | + NumberAnimation { |
713 | + duration: UbuntuAnimation.SnapDuration |
714 | + } |
715 | } |
716 | } |
717 | } |
718 | |
719 | === added file 'plugins/cellular/carriers.js' |
720 | --- plugins/cellular/carriers.js 1970-01-01 00:00:00 +0000 |
721 | +++ plugins/cellular/carriers.js 2014-12-11 16:59:19 +0000 |
722 | @@ -0,0 +1,106 @@ |
723 | +// Map of path to OfonoNetworkOperator objects |
724 | +var _pathToQml = {} |
725 | + |
726 | +/* |
727 | +Given an array of paths, it will create and associate |
728 | +an OfonoNetworkOperator QML object for each new path. |
729 | + |
730 | +It will also delete any QML that is not in given list of paths. |
731 | + |
732 | +@param {Array} paths - Array of operator paths |
733 | +@return {undefined} |
734 | +*/ |
735 | +function updateOperatorQML (paths) { |
736 | + _garbageCollect(paths); |
737 | + _createQml(paths); |
738 | +} |
739 | + |
740 | +function _garbageCollect (paths) { |
741 | + var path; |
742 | + for (path in _pathToQml) { |
743 | + if (_pathToQml.hasOwnProperty(path)) { |
744 | + if (paths.indexOf(path) === -1) { |
745 | + _pathToQml[path].destroy(); |
746 | + delete _pathToQml[path]; |
747 | + } |
748 | + } |
749 | + } |
750 | +} |
751 | + |
752 | +function _createQml (paths) { |
753 | + paths.forEach(function (path, i) { |
754 | + if (!_pathToQml.hasOwnProperty(path)) { |
755 | + _pathToQml[path] = netOp.createObject(root, { |
756 | + 'operatorPath': path |
757 | + }); |
758 | + } |
759 | + }); |
760 | +} |
761 | + |
762 | +/* |
763 | +Takes a list of paths and returns |
764 | +OfonoNetworkOperator objects for each path. |
765 | + |
766 | +This function will create OfonoNetworkOperator |
767 | +objects. |
768 | + |
769 | +@param {Array} paths - Array of operator paths |
770 | +@param {Array} ignore - Array of operator paths to ignore |
771 | +@return {Array} of OfonoNetworkOperators |
772 | +*/ |
773 | +function getOps (paths, ignore) { |
774 | + var ret = []; |
775 | + ignore = ignore || []; |
776 | + paths.forEach(function (op) { |
777 | + var ofonoOp = getOrCreateOpQml(op); |
778 | + if (ignore.indexOf(op) >= 0) { |
779 | + return; |
780 | + } else if (ofonoOp.status === "forbidden") { |
781 | + return; |
782 | + } |
783 | + ret.push(ofonoOp); |
784 | + }); |
785 | + return ret; |
786 | +} |
787 | + |
788 | +/* |
789 | +@param path String an operator path |
790 | +@return {Object|null} OfonoNetworkOperator|null - null if no QML exist for path |
791 | +*/ |
792 | +function getOp (path) { |
793 | + if (_pathToQml.hasOwnProperty(path)) { |
794 | + return _pathToQml[path]; |
795 | + } else { |
796 | + return null; |
797 | + } |
798 | +} |
799 | + |
800 | +/* |
801 | +Returns an operator. Before returning it sees |
802 | +if we have created QML for this operator path |
803 | +before. QML is created if not. |
804 | + |
805 | +It is guaranteed that a QML object will be returned. |
806 | + |
807 | +@param {String} path - an operator path |
808 | +@return {Object} OfonoNetworkOperator - the created qml |
809 | +*/ |
810 | +function getOrCreateOpQml (path) { |
811 | + if (getOp(path)) { |
812 | + return getOp(path); |
813 | + } else { |
814 | + _createQml([path]); |
815 | + return getOp(path); |
816 | + } |
817 | +} |
818 | + |
819 | +/* |
820 | +Registers operator on path |
821 | + |
822 | +@param {String} path - operator to register |
823 | +@return {undefined} |
824 | +*/ |
825 | +function setOp (path) { |
826 | + var op = getOrCreateOpQml(path); |
827 | + op.registerOperator(); |
828 | +} |
FAILED: Continuous integration, rev:949 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- rtm-14. 09-ci/5/ jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- rtm-14. 09-14.09- armhf-ci/ 6/console
http://
Executed test runs:
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- rtm-14. 09-ci/5/ rebuild
http://