mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 624028 - Part 1: Implement "Pair a Device" dialog. r=rnewman
This commit is contained in:
parent
8cd3f41f05
commit
21d40144f5
@ -113,6 +113,7 @@ XPCOMUtils.defineLazyGetter(this, "CommonUI", function() {
|
||||
["MasterPasswordUI", "chrome://browser/content/MasterPasswordUI.js"],
|
||||
#ifdef MOZ_SERVICES_SYNC
|
||||
["WeaveGlue", "chrome://browser/content/sync.js"],
|
||||
["SyncPairDevice", "chrome://browser/content/sync.js"],
|
||||
#endif
|
||||
["WebappsUI", "chrome://browser/content/WebappsUI.js"],
|
||||
["SSLExceptions", "chrome://browser/content/exceptions.js"],
|
||||
|
@ -627,6 +627,32 @@
|
||||
</vbox>
|
||||
</dialog>
|
||||
</box>
|
||||
|
||||
<box id="syncpair-container" class="perm-modal-block" hidden="true">
|
||||
<dialog id="syncpair-dialog" class="content-dialog" flex="1">
|
||||
<hbox class="prompt-title">
|
||||
<description>&sync.pair.title;</description>
|
||||
</hbox>
|
||||
<separator class="prompt-line"/>
|
||||
<vbox id="syncpair-simple" class="syncsetup-page" flex="1">
|
||||
<scrollbox id="sync-message" class="prompt-message" orient="vertical" flex="1">
|
||||
<description class="syncsetup-desc syncsetup-center" flex="1">&sync.pair.description;</description>
|
||||
<description class="syncsetup-center link" flex="1" onclick="SyncPairDevice.close(); WeaveGlue.openTutorial();">&sync.setup.tutorial;</description>
|
||||
<separator/>
|
||||
<vbox align="center" flex="1">
|
||||
<textbox id="syncpair-code1" class="syncsetup-code" oninput="SyncPairDevice.onTextBoxInput(this);"/>
|
||||
<textbox id="syncpair-code2" class="syncsetup-code" oninput="SyncPairDevice.onTextBoxInput(this);"/>
|
||||
<textbox id="syncpair-code3" class="syncsetup-code" oninput="SyncPairDevice.onTextBoxInput(this);"/>
|
||||
</vbox>
|
||||
<separator flex="1"/>
|
||||
</scrollbox>
|
||||
<hbox class="prompt-buttons" pack="center">
|
||||
<button class="prompt-button" oncommand="SyncPairDevice.close();">&sync.setup.cancel;</button>
|
||||
<button id="syncpair-connectbutton" class="prompt-button" disabled="true" oncommand="SyncPairDevice.connect();">&sync.setup.connect;</button>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</dialog>
|
||||
</box>
|
||||
#endif
|
||||
|
||||
<arrowbox id="search-engines-popup" hidden="true" offset="18" flex="1" type="dialog">
|
||||
|
@ -598,3 +598,95 @@ let WeaveGlue = {
|
||||
this.setupData.serverURL = serverURL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const PIN_PART_LENGTH = 4;
|
||||
|
||||
let SyncPairDevice = {
|
||||
jpake: null,
|
||||
|
||||
open: function open() {
|
||||
this.code1.setAttribute("maxlength", PIN_PART_LENGTH);
|
||||
this.code2.setAttribute("maxlength", PIN_PART_LENGTH);
|
||||
this.code3.setAttribute("maxlength", PIN_PART_LENGTH);
|
||||
this.nextFocusEl = {code1: this.code2,
|
||||
code2: this.code3,
|
||||
code3: this.connectbutton};
|
||||
|
||||
document.getElementById("syncpair-container").hidden = false;
|
||||
BrowserUI.pushDialog(this);
|
||||
this.code1.focus();
|
||||
|
||||
// Kick off a sync. That way the server will have the most recent data from
|
||||
// this computer and it will show up immediately on the new device.
|
||||
Weave.SyncScheduler.scheduleNextSync(0);
|
||||
},
|
||||
|
||||
close: function close() {
|
||||
this.code1.value = this.code2.value = this.code3.value = "";
|
||||
this.code1.disabled = this.code2.disabled = this.code3.disabled = false;
|
||||
this.connectbutton.disabled = true;
|
||||
if (this.jpake) {
|
||||
this.jpake.abort();
|
||||
this.jpake = null;
|
||||
}
|
||||
document.getElementById("syncpair-container").hidden = true;
|
||||
BrowserUI.popDialog();
|
||||
},
|
||||
|
||||
onTextBoxInput: function onTextBoxInput(textbox) {
|
||||
if (textbox && textbox.value.length == PIN_PART_LENGTH) {
|
||||
let name = textbox.id.split("-")[1];
|
||||
this.nextFocusEl[name].focus();
|
||||
}
|
||||
|
||||
this.connectbutton.disabled =
|
||||
!(this.code1.value.length == PIN_PART_LENGTH &&
|
||||
this.code2.value.length == PIN_PART_LENGTH &&
|
||||
this.code3.value.length == PIN_PART_LENGTH);
|
||||
},
|
||||
|
||||
connect: function connect() {
|
||||
let self = this;
|
||||
let jpake = this.jpake = new Weave.JPAKEClient({
|
||||
onPaired: function onPaired() {
|
||||
let credentials = {account: Weave.Service.account,
|
||||
password: Weave.Service.password,
|
||||
synckey: Weave.Service.passphrase,
|
||||
serverURL: Weave.Service.serverURL};
|
||||
jpake.sendAndComplete(credentials);
|
||||
},
|
||||
onComplete: function onComplete() {
|
||||
self.jpake = null;
|
||||
self.close();
|
||||
|
||||
// Schedule a Sync for soonish to fetch the data uploaded by the
|
||||
// device with which we just paired.
|
||||
Weave.SyncScheduler.scheduleNextSync(Weave.SyncScheduler.activeInterval);
|
||||
},
|
||||
onAbort: function onAbort(error) {
|
||||
self.jpake = null;
|
||||
|
||||
// Aborted by user, ignore.
|
||||
if (error == Weave.JPAKE_ERROR_USERABORT) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.code1.value = self.code2.value = self.code3.value = "";
|
||||
self.code1.disabled = self.code2.disabled = self.code3.disabled = false;
|
||||
self.code1.focus();
|
||||
}
|
||||
});
|
||||
this.code1.disabled = this.code2.disabled = this.code3.disabled = true;
|
||||
this.connectbutton.disabled = true;
|
||||
|
||||
let pin = this.code1.value + this.code2.value + this.code3.value;
|
||||
let expectDelay = false;
|
||||
jpake.pairWithPIN(pin, expectDelay);
|
||||
}
|
||||
};
|
||||
["code1", "code2", "code3", "connectbutton"].forEach(function (id) {
|
||||
XPCOMUtils.defineLazyGetter(SyncPairDevice, id, function() {
|
||||
return document.getElementById("syncpair-" + id);
|
||||
});
|
||||
});
|
||||
|
@ -20,5 +20,8 @@
|
||||
<!ENTITY sync.setup.cancel "Cancel">
|
||||
<!ENTITY sync.setup.tutorial "Show me how">
|
||||
<!ENTITY sync.setup.waiting "Pairing in progress…">
|
||||
|
||||
<!ENTITY sync.pair.title "Pair a Device">
|
||||
<!ENTITY sync.pair.description "To activate your new device, select "Set Up Sync" on the device.">
|
||||
<!ENTITY sync.setup.close "Close">
|
||||
<!ENTITY sync.setup.waitingdownload "Your data is now being downloaded in the background. You can close this window at any time.">
|
||||
|
Loading…
Reference in New Issue
Block a user