B2G/gecko/toolkit/mozapps/extensions/XPIProviderUtils.js
/**
   * Retrieves migration data from the old extensions.rdf database.
   *
   * @return an object holding information about what add-ons were previously
   *         userDisabled and any updated compatibility information
   */
Retrieves migration data from the old extensions.rdf database.
@return an object holding information about what add-ons were previously
userDisabled and any updated compatibility information
Retrieves migration data from the old extensions . rdf database . @return an object holding information about what add - ons were previously userDisabled and any updated compatibility information
function XPIDB_getMigrateDataFromRDF(aDbWasMissing) {
    let rdffile = FileUtils.getFile(KEY_PROFILEDIR, [FILE_OLD_DATABASE], true);
    if (!rdffile.exists())
      return null;
    LOG("Migrating data from " + FILE_OLD_DATABASE);
    let migrateData = {};
    try {
      let ds = gRDF.GetDataSourceBlocking(Services.io.newFileURI(rdffile).spec);
      let root = Cc["@mozilla.org/rdf/container;1"].
                 createInstance(Ci.nsIRDFContainer);
      root.Init(ds, gRDF.GetResource(RDFURI_ITEM_ROOT));
      let elements = root.GetElements();
      while (elements.hasMoreElements()) {
        let source = elements.getNext().QueryInterface(Ci.nsIRDFResource);
        let location = getRDFProperty(ds, source, "installLocation");
        if (location) {
          if (!(location in migrateData))
            migrateData[location] = {};
          let id = source.ValueUTF8.substring(PREFIX_ITEM_URI.length);
          migrateData[location][id] = {
            version: getRDFProperty(ds, source, "version"),
            userDisabled: false,
            targetApplications: []
          }
          let disabled = getRDFProperty(ds, source, "userDisabled");
          if (disabled == "true" || disabled == "needs-disable")
            migrateData[location][id].userDisabled = true;
          let targetApps = ds.GetTargets(source, EM_R("targetApplication"),
                                         true);
          while (targetApps.hasMoreElements()) {
            let targetApp = targetApps.getNext()
                                      .QueryInterface(Ci.nsIRDFResource);
            let appInfo = {
              id: getRDFProperty(ds, targetApp, "id")
            };
            let minVersion = getRDFProperty(ds, targetApp, "updatedMinVersion");
            if (minVersion) {
              appInfo.minVersion = minVersion;
              appInfo.maxVersion = getRDFProperty(ds, targetApp, "updatedMaxVersion");
            }
            else {
              appInfo.minVersion = getRDFProperty(ds, targetApp, "minVersion");
              appInfo.maxVersion = getRDFProperty(ds, targetApp, "maxVersion");
            }
            migrateData[location][id].targetApplications.push(appInfo);
          }
        }
      }
    }
    catch (e) {
      WARN("Error reading " + FILE_OLD_DATABASE, e);
      migrateData = null;
    }
    return migrateData;
  }
function XPIDB_getMigrateDataFromRDF ( aDbWasMissing ) { let rdffile = FileUtils . getFile ( KEY_PROFILEDIR , [ FILE_OLD_DATABASE ] , true ) ; if ( ! rdffile . exists ( ) ) return null ; LOG ( "Migrating data from " + FILE_OLD_DATABASE ) ; let migrateData = { } ; try { let ds = gRDF . GetDataSourceBlocking ( Services . io . newFileURI ( rdffile ) . spec ) ; let root = Cc [ "@mozilla.org/rdf/container;1" ] . createInstance ( Ci . nsIRDFContainer ) ; root . Init ( ds , gRDF . GetResource ( RDFURI_ITEM_ROOT ) ) ; let elements = root . GetElements ( ) ; while ( elements . hasMoreElements ( ) ) { let source = elements . getNext ( ) . QueryInterface ( Ci . nsIRDFResource ) ; let location = getRDFProperty ( ds , source , "installLocation" ) ; if ( location ) { if ( ! ( location in migrateData ) ) migrateData [ location ] = { } ; let id = source . ValueUTF8 . substring ( PREFIX_ITEM_URI . length ) ; migrateData [ location ] [ id ] = { version : getRDFProperty ( ds , source , "version" ) , userDisabled : false , targetApplications : [ ] } let disabled = getRDFProperty ( ds , source , "userDisabled" ) ; if ( disabled == "true" || disabled == "needs-disable" ) migrateData [ location ] [ id ] . userDisabled = true ; let targetApps = ds . GetTargets ( source , EM_R ( "targetApplication" ) , true ) ; while ( targetApps . hasMoreElements ( ) ) { let targetApp = targetApps . getNext ( ) . QueryInterface ( Ci . nsIRDFResource ) ; let appInfo = { id : getRDFProperty ( ds , targetApp , "id" ) } ; let minVersion = getRDFProperty ( ds , targetApp , "updatedMinVersion" ) ; if ( minVersion ) { appInfo . minVersion = minVersion ; appInfo . maxVersion = getRDFProperty ( ds , targetApp , "updatedMaxVersion" ) ; } else { appInfo . minVersion = getRDFProperty ( ds , targetApp , "minVersion" ) ; appInfo . maxVersion = getRDFProperty ( ds , targetApp , "maxVersion" ) ; } migrateData [ location ] [ id ] . targetApplications . push ( appInfo ) ; } } } } catch ( e ) { WARN ( "Error reading " + FILE_OLD_DATABASE , e ) ; migrateData = null ; } return migrateData ; }
Retrieves migration data from the old extensions.rdf database.
Retrieves migration data from the old extensions . rdf database .
// Migrate data from extensions.rdf