Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7225 from crh0716/824597
Browse files Browse the repository at this point in the history
Bug 824597 - Close the pair view when users press the home button while pairing r=evelyn hung, a=bb+
  • Loading branch information
crh0716 committed Jan 7, 2013
2 parents e8565f7 + c33a69f commit b2515d8
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 38 deletions.
43 changes: 28 additions & 15 deletions apps/settings/js/bluetooth.js
Expand Up @@ -530,23 +530,36 @@ onLocalized(function bluetoothSettings() {
}

function onRequestPairing(evt, method) {
var device = {
address: evt.address,
name: evt.name || _('unnamed-device'),
icon: evt.icon || 'bluetooth-default'
var showPairView = function bt_showPairView() {
var device = {
address: evt.address,
name: evt.name || _('unnamed-device'),
icon: evt.icon || 'bluetooth-default'
};

if (device.address !== pairingAddress) {
pairingAddress = device.address;
pairingMode = 'passive';
}
var passkey = evt.passkey || null;
var protocol = window.location.protocol;
var host = window.location.host;
childWindow = window.open(protocol + '//' + host + '/onpair.html',
'pair_screen', 'attention');
childWindow.onload = function childWindowLoaded() {
childWindow.PairView.init(pairingMode, method, device, passkey);
};
};

if (device.address !== pairingAddress) {
pairingAddress = device.address;
pairingMode = 'passive';
}
var passkey = evt.passkey || null;
var protocol = window.location.protocol;
var host = window.location.host;
childWindow = window.open(protocol + '//' + host + '/onpair.html',
'pair_screen', 'attention');
childWindow.onload = function childWindowLoaded() {
childWindow.PairView.init(pairingMode, method, device, passkey);
var req = navigator.mozSettings.createLock().get('lockscreen.locked');
req.onsuccess = function bt_onGetLocksuccess() {
if (!req.result['lockscreen.locked']) {
showPairView();
}
};
req.onerror = function bt_onGetLockError() {
// fallback to default value 'unlocked'
showPairView();
};
}

Expand Down
61 changes: 38 additions & 23 deletions apps/settings/js/onpair.js
Expand Up @@ -39,6 +39,7 @@ var PairView = {
var _ = navigator.mozL10n.get;
this.pairButton.addEventListener('click', this);
this.closeButton.addEventListener('click', this);
window.addEventListener('resize', this);

this.nameLabel.textContent = this._device.name;
this.deviceInfo.className = this._device.icon;
Expand Down Expand Up @@ -86,37 +87,51 @@ var PairView = {
onLocalized(PairView.show.bind(PairView));
},

close: function() {
window.opener.gDeviceList.setConfirmation(this._device.address, false);
window.close();
},

handleEvent: function pv_handleEvent(evt) {
var _ = navigator.mozL10n.get;
if (evt.type !== 'click' || !evt.target)
if (!evt.target)
return;

evt.preventDefault();
switch (evt.target.id) {
case 'button-pair':
this.pairDescription.textContent = _('device-status-waiting');
this.pairButton.disabled = true;
this.closeButton.disabled = true;
switch (this._pairMethod) {
case 'confirmation':
window.opener.gDeviceList.
setConfirmation(this._device.address, true);
break;
case 'pincode':
var value = this.pinInput.value;
window.opener.gDeviceList.setPinCode(this._device.address, value);
switch (evt.type) {
case 'click':
evt.preventDefault();
switch (evt.target.id) {
case 'button-pair':
this.pairDescription.textContent = _('device-status-waiting');
this.pairButton.disabled = true;
this.closeButton.disabled = true;
switch (this._pairMethod) {
case 'confirmation':
window.opener.gDeviceList.
setConfirmation(this._device.address, true);
break;
case 'pincode':
var value = this.pinInput.value;
window.opener.gDeviceList.setPinCode(this._device.address,
value);
break;
case 'passkey':
var value = this.passkeyInput.value;
window.opener.gDeviceList.setPasskey(this._device.address,
value);
break;
}
window.close();
break;
case 'passkey':
var value = this.passkeyInput.value;
window.opener.gDeviceList.setPasskey(this._device.address, value);
case 'button-close':
this.close();
break;
}
window.close();
break;

case 'button-close':
window.opener.gDeviceList.setConfirmation(this._device.address, false);
window.close();
case 'resize':
this.close();
break;
default:
break;
}
}
Expand Down

0 comments on commit b2515d8

Please sign in to comment.