B2G/gaia/apps/communications/dialer/js/call_log_db.js
/**
   * Updates the records from the groups object store with a given contact
   * information.
   * This function will likely be called within the handlers of the
   * 'oncontactchange' event.
   *
   * param contact
   *        Contact object
   * param callback
   *        Function to be called after updating the group or when an error
   *        is found.
   *
   * return (via callback) count of affected records or an error message if
   *                       needed.
   */
Updates the records from the groups object store with a given contact
information.
This function will likely be called within the handlers of the
'oncontactchange' event.

param contact
Contact object
param callback
Function to be called after updating the group or when an error
is found.

return (via callback) count of affected records or an error message if
needed.
Updates the records from the groups object store with a given contact information . This function will likely be called within the handlers of the ' oncontactchange ' event . param contact Contact object param callback Function to be called after updating the group or when an error is found . return ( via callback ) count of affected records or an error message if needed .
function updateGroupContactInfo(contact,
                                                          matchingTel,
                                                          callback) {
    var self = this;
    this._newTxn('readwrite', [this._dbGroupsStore],
                  function(error, txn, store) {
      if (error) {
        self._asyncReturn(callback, error);
        return;
      }
      if (!contact) {
        self._asyncReturn(callback, 0);
        return;
      }
      var count = 0;
      var req = store.index('number')
                     .openCursor(IDBKeyRange.only(matchingTel.value));
      req.onsuccess = function onsuccess(event) {
        var cursor = event.target.result;
        if (cursor && cursor.value) {
          var group = cursor.value;
          group.contactId = contact.id;
          if (Array.isArray(contact.photo) && contact.photo[0]) {
            group.contactPhoto = contact.photo[0];
          }
          if (matchingTel) {
            var primaryInfo = Utils.getPhoneNumberPrimaryInfo(matchingTel,
                                                              contact);
            if (Array.isArray(primaryInfo) && primaryInfo[0]) {
              primaryInfo = primaryInfo[0];
            }
            group.contactPrimaryInfo = String(primaryInfo);
            if (Array.isArray(matchingTel.type) && matchingTel.type[0]) {
              group.contactMatchingTelType = String(matchingTel.type[0]);
            }
            if (matchingTel.carrier) {
              group.contactMatchingTelCarrier = String(matchingTel.carrier);
            }
          }
          cursor.update(group);
          count++;
          cursor.continue();
        } else {
          self._asyncReturn(callback, count);
          self._updateCacheRevision();
        }
      };
      req.onerror = function onerror(event) {
        self._asyncReturn(callback, event.target.error.name);
      };
    });
  }
function updateGroupContactInfo ( contact , matchingTel , callback ) { var self = this ; this . _newTxn ( 'readwrite' , [ this . _dbGroupsStore ] , function ( error , txn , store ) { if ( error ) { self . _asyncReturn ( callback , error ) ; return ; } if ( ! contact ) { self . _asyncReturn ( callback , 0 ) ; return ; } var count = 0 ; var req = store . index ( 'number' ) . openCursor ( IDBKeyRange . only ( matchingTel . value ) ) ; req . onsuccess = function onsuccess ( event ) { var cursor = event . target . result ; if ( cursor && cursor . value ) { var group = cursor . value ; group . contactId = contact . id ; if ( Array . isArray ( contact . photo ) && contact . photo [ 0 ] ) { group . contactPhoto = contact . photo [ 0 ] ; } if ( matchingTel ) { var primaryInfo = Utils . getPhoneNumberPrimaryInfo ( matchingTel , contact ) ; if ( Array . isArray ( primaryInfo ) && primaryInfo [ 0 ] ) { primaryInfo = primaryInfo [ 0 ] ; } group . contactPrimaryInfo = String ( primaryInfo ) ; if ( Array . isArray ( matchingTel . type ) && matchingTel . type [ 0 ] ) { group . contactMatchingTelType = String ( matchingTel . type [ 0 ] ) ; } if ( matchingTel . carrier ) { group . contactMatchingTelCarrier = String ( matchingTel . carrier ) ; } } cursor . update ( group ) ; count ++ ; cursor . continue ( ) ; } else { self . _asyncReturn ( callback , count ) ; self . _updateCacheRevision ( ) ; } } ; req . onerror = function onerror ( event ) { self . _asyncReturn ( callback , event . target . error . name ) ; } ; } ) ; }
Updates the records from the groups object store with a given contact
 information.
Updates the records from the groups object store with a given contact information .