Permalink
Browse files

Merge pull request #6842 from fabi1cazenave/apn

Bug 813854 - Add APN settings for MMS and SUPL, r=evelyn
  • Loading branch information...
2 parents d7a4181 + 1c15279 commit 2b436ac85a52ea98976a0ae7ffb2126a3cd05019 @fabi1cazenave fabi1cazenave committed Dec 6, 2012
View
@@ -383,21 +383,21 @@ <h2 data-l10n-id="availableOperators"> Network Operators in the Area </h2>
-->
</section>
- <!-- Connectivity :: Cellular & Data :: APN Settings -->
- <section role="region" hidden id="carrier-apnSettings">
+ <!-- Connectivity :: Cellular & Data :: Data Settings -->
+ <section role="region" hidden id="carrier-dataSettings">
<!--
<header>
<button type="reset"><span data-l10n-id="back" class="icon icon-back">Back</span></button>
<menu type="toolbar">
<button type="submit"><span data-l10n-id="ok">OK</span></button>
</menu>
- <h1 data-l10n-id="apnSettings"> APN Settings </h1>
+ <h1 data-l10n-id="dataSettings"> Data Settings </h1>
</header>
- <ul id="apnSettings-list">
- <li id="apnSettings-custom">
+ <ul class="apnSettings-list">
+ <li class="apnSettings-custom">
<label>
- <input type="radio" name="APN.name" value="_custom_" checked />
+ <input type="radio" name="ril.data.carrier" value="_custom_" checked />
<span></span>
</label>
<a data-l10n-id="custom">(custom settings)</a>
@@ -407,7 +407,7 @@ <h1 data-l10n-id="apnSettings"> APN Settings </h1>
<header>
<h2 data-l10n-id="advancedSettings"> Advanced Settings </h2>
</header>
- <ul id="apnSettings-advanced">
+ <ul class="apnSettings-advanced">
<li>
<p data-l10n-id="apn">APN</p>
<input type="text" data-setting="ril.data.apn" />
@@ -443,18 +443,100 @@ <h2 data-l10n-id="advancedSettings"> Advanced Settings </h2>
<h1 data-l10n-id="mmsSettings"> MMS Settings </h1>
</header>
- <ul>
+ <ul class="apnSettings-list">
+ <li class="apnSettings-custom">
+ <label>
+ <input type="radio" name="ril.mms.carrier" value="_custom_" checked />
+ <span></span>
+ </label>
+ <a data-l10n-id="custom">(custom settings)</a>
+ </li>
+ </ul>
+
+ <header>
+ <h2 data-l10n-id="advancedSettings"> Advanced Settings </h2>
+ </header>
+ <ul class="apnSettings-advanced">
+ <li>
+ <p data-l10n-id="apn">APN</p>
+ <input type="text" data-setting="ril.data.apn" />
+ </li>
+ <li>
+ <p data-l10n-id="identity">identity</p>
+ <input type="text" data-setting="ril.data.user" />
+ </li>
+ <li>
+ <p data-l10n-id="password">password</p>
+ <input type="text" data-setting="ril.data.passwd" />
+ </li>
+ <li>
+ <p data-l10n-id="httpProxyHost">HTTP Proxy Host</p>
+ <input type="text" data-setting="ril.data.httpProxyHost" />
+ </li>
+ <li>
+ <p data-l10n-id="httpProxyPort">HTTP Proxy Port</p>
+ <input type="text" data-setting="ril.data.httpProxyPort" />
+ </li>
<li>
<p data-l10n-id="mmsproxy">MMS Proxy</p>
- <input type="text" data-setting="ril.data.mmsproxy" value="foo" />
+ <input type="text" data-setting="ril.mms.mmsproxy" />
</li>
<li>
<p data-l10n-id="mmsport">MMS Port</p>
- <input type="text" data-setting="ril.data.mmsport" value="bar" />
+ <input type="text" data-setting="ril.mms.mmsport" />
</li>
<li>
<p data-l10n-id="mmsc">MMSC</p>
- <input type="text" data-setting="ril.data.mmsc" value="baz" />
+ <input type="text" data-setting="ril.mms.mmsc" />
+ </li>
+ </ul>
+ -->
+ </section>
+
+ <!-- Connectivity :: Cellular & Data :: A-GPS Settings -->
+ <section role="region" hidden id="carrier-suplSettings">
+ <!--
+ <header>
+ <button type="reset"><span data-l10n-id="back" class="icon icon-back">Back</span></button>
+ <menu type="toolbar">
+ <button type="submit"><span data-l10n-id="ok">OK</span></button>
+ </menu>
+ <h1 data-l10n-id="suplSettings"> A-GPS Settings </h1>
+ </header>
+
+ <ul class="apnSettings-list">
+ <li class="apnSettings-custom">
+ <label>
+ <input type="radio" name="ril.supl.carrier" value="_custom_" checked />
+ <span></span>
+ </label>
+ <a data-l10n-id="custom">(custom settings)</a>
+ </li>
+ </ul>
+
+ <header>
+ <h2 data-l10n-id="advancedSettings"> Advanced Settings </h2>
+ </header>
+ <ul class="apnSettings-advanced">
+ <li>
+ <p data-l10n-id="apn">APN</p>
+ <input type="text" data-setting="ril.supl.apn" />
+ </li>
+ <li>
+ <p data-l10n-id="identity">identity</p>
+ <input type="text" data-setting="ril.supl.user" />
+ </li>
+ <li>
+ <p data-l10n-id="password">password</p>
+ <input type="text" data-setting="ril.supl.passwd" />
+ </li>
+ <li>
+ <p data-l10n-id="httpProxyHost">HTTP Proxy Host</p>
+ <input type="text" data-setting="ril.supl.httpProxyHost" />
+ </li>
+ <li>
+ <p data-l10n-id="httpProxyPort">HTTP Proxy Port</p>
+ <input type="text" data-setting="ril.supl.httpProxyPort" />
</li>
</ul>
-->
@@ -516,8 +598,8 @@ <h2 data-l10n-id="advancedSettings"> Advanced Settings </h2>
</li>
<li>
<label>
- <button data-href="#carrier-apnSettings"
- data-l10n-id="apnSettings">APN Settings</button>
+ <button data-href="#carrier-dataSettings"
+ data-l10n-id="dataSettings">Data Settings</button>
</label>
</li>
<li hidden>
@@ -526,6 +608,12 @@ <h2 data-l10n-id="advancedSettings"> Advanced Settings </h2>
data-l10n-id="mmsSettings">MMS Settings</button>
</label>
</li>
+ <li>
+ <label>
+ <button data-href="#carrier-suplSettings"
+ data-l10n-id="suplSettings">A-GPS Settings</button>
+ </label>
+ </li>
</ul>
<script type="application/javascript" defer src="js/carrier.js"></script>
@@ -5,23 +5,25 @@
// handle carrier settings
var Carrier = (function newCarrier(window, document, undefined) {
- var APN_FILE = 'shared/resources/apn.json';
- var gAPNPanel = document.getElementById('carrier-apnSettings');
+ var APN_FILE = '/shared/resources/apn.json';
/**
* gCompatibleAPN holds all compatible APNs matching the current iccInfo
* (mcc,mnc) for every usage filter
*/
var gCompatibleAPN = null;
- var gUserChosenAPN = false;
// query <apn> elements matching the mcc/mnc arguments
- function queryAPN(callback, usageFilter) {
- usageFilter = usageFilter || 'default';
+ function queryAPN(callback, usage) {
if (!callback)
return;
+ var usageFilter = usage;
+ if (!usage || usage == 'data') {
+ usageFilter = 'default';
+ }
+
// filter APNs by usage
var filter = function(apnList) {
var found = [];
@@ -35,7 +37,7 @@ var Carrier = (function newCarrier(window, document, undefined) {
// early way out if the query has already been performed
if (gCompatibleAPN) {
- callback(filter(gCompatibleAPN));
+ callback(filter(gCompatibleAPN), usage);
return;
}
@@ -50,20 +52,25 @@ var Carrier = (function newCarrier(window, document, undefined) {
var mnc = gMobileConnection.iccInfo.mnc;
// get a list of matching APNs
gCompatibleAPN = apn[mcc] ? (apn[mcc][mnc] || []) : [];
- callback(filter(gCompatibleAPN));
+ callback(filter(gCompatibleAPN), usage);
}
};
xhr.send();
}
// update APN fields
- function updateAPNList(apnItems) {
- var apnList = document.getElementById('apnSettings-list');
- var lastItem = apnList.lastElementChild;
+ function updateAPNList(apnItems, usage) {
+ var apnPanel = document.getElementById('carrier-' + usage + 'Settings');
+ if (!apnPanel) // unsupported APN type
+ return;
+
+ var apnList = apnPanel.querySelector('.apnSettings-list');
+ var advForm = apnPanel.querySelector('.apnSettings-advanced');
+ var lastItem = apnList.querySelector('.apnSettings-custom');
// helper
function rilData(name) {
- var selector = 'input[data-setting="ril.data.' + name + '"]';
+ var selector = 'input[data-setting="ril.' + usage + '.' + name + '"]';
return document.querySelector(selector);
}
@@ -72,14 +79,19 @@ var Carrier = (function newCarrier(window, document, undefined) {
// create an <input type="radio"> element
var input = document.createElement('input');
input.type = 'radio';
- input.name = 'APN.name';
+ input.name = 'ril.' + usage + '.carrier';
input.value = item.carrier || item.apn;
input.onclick = function fillAPNData() {
rilData('apn').value = item.apn || '';
rilData('user').value = item.user || '';
rilData('passwd').value = item.password || '';
rilData('httpProxyHost').value = item.proxy || '';
rilData('httpProxyPort').value = item.port || '';
+ if (usage == 'mms') {
+ rilData('mmsc').value = item.mmsc || '';
+ rilData('mmsproxy').value = item.mmsproxy || '';
+ rilData('mmsport').value = item.mmsport || '';
+ }
};
// include the radio button element in a list item
@@ -106,11 +118,11 @@ var Carrier = (function newCarrier(window, document, undefined) {
apnList.insertBefore(createAPNItem(apnItems[i]), lastItem);
}
- // find the current APN
+ // find the current APN, relying on the carrier name
var settings = Settings.mozSettings;
- if (settings && !gUserChosenAPN) {
+ if (settings) {
var radios = apnList.querySelectorAll('input[type="radio"]');
- var key = 'APN.name';
+ var key = 'ril.' + usage + '.carrier';
var request = settings.createLock().get(key);
request.onsuccess = function() {
var found = false;
@@ -119,25 +131,21 @@ var Carrier = (function newCarrier(window, document, undefined) {
radios[i].checked = (request.result[key] === radios[i].value);
found = found || radios[i].checked;
}
- }
- if (!found) {
- lastItem.querySelector('input').checked = true;
+ if (!found) {
+ lastItem.querySelector('input').checked = true;
+ }
}
};
}
// set current APN to 'custom' on user modification
- gAPNPanel.onchange = function onChange(event) {
- gUserChosenAPN = true;
- if (event.target.type == 'text') {
- var lastInput = lastItem.querySelector('input');
- lastInput.checked = true;
- // send a 'change' event to update the related mozSetting
- var evtObject = document.createEvent('Event');
- evtObject.initEvent('change', true, false);
- lastInput.dispatchEvent(evtObject);
- }
+ advForm.onchange = function onCustomInput(event) {
+ lastItem.querySelector('input').checked = true;
};
+
+ // force data connection to restart if changes are validated
+ apnPanel.querySelector('button[type=submit]').onclick =
+ restartDataConnection;
}
// restart data connection by toggling it off and on again
@@ -323,19 +331,19 @@ var Carrier = (function newCarrier(window, document, undefined) {
// public API
return {
// display matching APNs
- fillAPNList: function carrier_fillAPNList() {
- queryAPN(updateAPNList);
- // force data connection to restart if changes are validated
- gAPNPanel.querySelector('button[type=submit]').onclick =
- restartDataConnection;
+ fillAPNList: function carrier_fillAPNList(usage) {
+ queryAPN(updateAPNList, usage);
},
// startup
init: function carrier_init() {
gMobileConnection.addEventListener('datachange', updateConnection);
updateConnection();
updateSelectionMode();
- this.fillAPNList(); // XXX this should be done later -- not during init()
+ // XXX this should be done later -- not during init()
+ this.fillAPNList('data');
+ this.fillAPNList('mms');
+ this.fillAPNList('supl');
}
};
})(this, document);
Oops, something went wrong.

0 comments on commit 2b436ac

Please sign in to comment.