Commit 7c5f93c1 authored by You-Sheng Yang's avatar You-Sheng Yang
Browse files

Merge pull request #10854 from vicamo/bugzilla/891233/deprecate-mozSms-in-cost-control

Bug 891233 - [Cost Control] use navigator.mozMobileMessage instead. r=sa...
parents 82e6fd4b 1a0d95ae
Loading
Loading
Loading
Loading
+7 −7
Changes for apps/costcontrol/js/costcontrol.js: 7 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -42,10 +42,10 @@ var CostControl = (function() {
    ConfigManager.requestAll(setupCostControl);
  }

  var sms, connection, telephony, statistics;
  var mobileMessageManager, connection, telephony, statistics;
  function loadAPIs() {
    if ('mozSms' in window.navigator) {
      sms = window.navigator.mozSms;
    if ('mozMobileMessage' in window.navigator) {
      mobileMessageManager = window.navigator.mozMobileMessage;
    }

    if ('mozMobileConnection' in window.navigator) {
@@ -62,8 +62,8 @@ var CostControl = (function() {
  // OTHER LOGIC

  // Check if a SMS matches the form of a balance request
  function isBalanceRequestSMS(sms, configuration) {
    return sms.receiver === configuration.balance.destination;
  function isBalanceRequestSMS(message, configuration) {
    return message.receiver === configuration.balance.destination;
  }

  // Perform a request. They must be specified via a request object with:
@@ -245,7 +245,7 @@ var CostControl = (function() {
    result.data = settings.lastBalance;

    // Send request SMS
    var newSMS = sms.send(
    var newSMS = mobileMessageManager.send(
      configuration.balance.destination,
      configuration.balance.text
    );
@@ -302,7 +302,7 @@ var CostControl = (function() {
    debug('Requesting TopUp with code', code, '...');

    // TODO: Ensure is free
    var newSMS = sms.send(
    var newSMS = mobileMessageManager.send(
      configuration.topup.destination,
      configuration.topup.text.replace(/\&code/g, code)
    );
+2 −2
Changes for apps/costcontrol/js/message_handler.js: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -454,8 +454,8 @@
            costcontrol.request({ type: 'balance' });
          }

          var manager = window.navigator.mozSms;
          var smsInfo = manager.getSegmentInfoForText(sms.body);
          var mobileMessageManager = window.navigator.mozMobileMessage;
          var smsInfo = mobileMessageManager.getSegmentInfoForText(sms.body);
          var realCount = smsInfo.segments;
          settings.lastTelephonyActivity.timestamp = new Date();
          settings.lastTelephonyActivity.smscount += realCount;