@@ -19,6 +19,7 @@
1919
2020import QtQuick 2.0
2121import Ubuntu.Components 0.1
22+import QMenuModel 0.1
2223import "../Components"
2324
2425Loader {
@@ -26,7 +27,7 @@ Loader {
2627
2728 property QtObject menuModel: null
2829 property QtObject menuData: null
29− property int menuIndex
30+ property int menuIndex : -1
3031 property int maxHeight
3132 readonly property bool fullscreen: menuData.type === "com.canonical.snapdecision.pinlock"
3233
@@ -46,6 +47,13 @@ Loader {
4647 }
4748 }
4849
50+ function getExtendedProperty(object, propertyName, defaultValue) {
51+ if (object && object.hasOwnProperty(propertyName)) {
52+ return object[propertyName];
53+ }
54+ return defaultValue;
55+ }
56+
4957 Component {
5058 id: textfield
5159
@@ -121,14 +129,14 @@ Loader {
121129 right: parent.right
122130 }
123131 height: menuFactory.maxHeight
124− infoText: i18n.tr("Enter SIM PIN")
125− errorText: i18n.tr("Sorry, incorrect PIN")
126− minPinLength: 4
127− maxPinLength: 8
132+ infoText: notification.summary
133+ errorText: errorAction.valid ? errorAction.state : ""
134+ retryText: notification.body
128135 background: shell.background
129136
130137 onEntered: {
131138 menuModel.changeState(menuIndex, passphrase);
139+ clear(false);
132140 }
133141
134142 onCancel: {
@@ -139,6 +147,70 @@ Loader {
139147 shell.activateApplication("dialer-app")
140148 menuModel.activate(menuIndex, false)
141149 }
150+
151+ property var extendedData: menuData && menuData.ext || undefined
152+
153+ property var pinMinMaxAction : UnityMenuAction {
154+ model: menuModel
155+ index: menuIndex
156+ name: getExtendedProperty(extendedData, "xCanonicalPinMinMax", "")
157+
158+ onStateChanged: {
159+ var min = pinMinMaxAction.state[0];
160+ var max = pinMinMaxAction.state[1];
161+
162+ if (min === 0) min = -1;
163+ if (max === 0) max = -1;
164+
165+ minPinLength = min
166+ maxPinLength = max
167+ }
168+ }
169+
170+ property var popupAction: UnityMenuAction {
171+ model: menuModel
172+ index: menuIndex
173+ name: getExtendedProperty(extendedData, "xCanonicalPinPopup", "")
174+ onStateChanged: {
175+ if (state !== "")
176+ showInfoPopup("", state);
177+ }
178+ }
179+ onInfoPopupConfirmed: {
180+ popupAction.activate();
181+ }
182+
183+ Timer {
184+ id: errorTimer
185+ interval: 4000;
186+ running: false;
187+ repeat: false
188+ onTriggered: {
189+ errorAction.activate();
190+ }
191+ }
192+ property var errorAction: UnityMenuAction {
193+ model: menuModel
194+ index: menuIndex
195+ name: getExtendedProperty(extendedData, "xCanonicalPinError", "")
196+ onStateChanged: {
197+ errorText = state;
198+ if (state !== "") {
199+ clear(true);
200+ errorTimer.running = true;
201+ }
202+ }
203+ }
204+
205+ function loadAttributes() {
206+ if (!menuModel || menuIndex == -1) return;
207+ menuModel.loadExtendedAttributes(menuIndex, {'x-canonical-pin-min-max': 'string',
208+ 'x-canonical-pin-popup': 'string',
209+ 'x-canonical-pin-error': 'string'});
210+ }
211+ Component.onCompleted: {
212+ loadAttributes();
213+ }
142214 }
143215 }
144216}