home *** CD-ROM | disk | FTP | other *** search
/ Freelog 112 / FreelogNo112-NovembreDecembre2012.iso / Multimedia / Songbird / Songbird_2.0.0-2311_windows-i686-msvc8.exe / components / sbMigrate11pre1To11pre1b.js < prev    next >
Text File  |  2012-06-08  |  4KB  |  122 lines

  1. /*
  2. //
  3. // BEGIN SONGBIRD GPL
  4. //
  5. // This file is part of the Songbird web player.
  6. //
  7. // Copyright(c) 2005-2008 POTI, Inc.
  8. // http://songbirdnest.com
  9. //
  10. // This file may be licensed under the terms of of the
  11. // GNU General Public License Version 2 (the "GPL").
  12. //
  13. // Software distributed under the License is distributed
  14. // on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
  15. // express or implied. See the GPL for the specific language
  16. // governing rights and limitations.
  17. //
  18. // You should have received a copy of the GPL along with this
  19. // program. If not, go to http://www.gnu.org/licenses/gpl.html
  20. // or write to the Free Software Foundation, Inc.,
  21. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  22. //
  23. // END SONGBIRD GPL
  24. //
  25. */
  26.  
  27. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  28. Components.utils.import("resource://app/jsmodules/ArrayConverter.jsm");
  29. Components.utils.import("resource://app/jsmodules/sbLocalDatabaseMigrationUtils.jsm");
  30. Components.utils.import("resource://app/jsmodules/SBJobUtils.jsm");
  31.  
  32. const Cc = Components.classes;
  33. const Ci = Components.interfaces;
  34. const Cr = Components.results;
  35.  
  36. function LOG(s) {
  37.   dump("----++++----++++sbLibraryMigration " + 
  38.        sbLibraryMigration.versionString + ": " + 
  39.        s + 
  40.        "\n----++++----++++\n");
  41. }
  42.  
  43. function sbLibraryMigration()
  44. {
  45.   SBLocalDatabaseMigrationUtils.BaseMigrationHandler.call(this);
  46.   
  47.   this.fromVersion = 13;
  48.   this.toVersion   = 14;
  49.   this.versionString = this.fromVersion + " to " + 
  50.                        this.toVersion;
  51. }
  52.  
  53. //-----------------------------------------------------------------------------
  54. // sbLocalDatabaseMigration Implementation
  55. //-----------------------------------------------------------------------------
  56.  
  57. sbLibraryMigration.prototype = {
  58.   __proto__: SBLocalDatabaseMigrationUtils.BaseMigrationHandler.prototype,
  59.   classDescription: 'Songbird Migration Handler, version 13 to 14',
  60.   classID: Components.ID("{cd3b44bf-1f72-4006-aa06-2f00fc0948bb}"),
  61.   contractID: SBLocalDatabaseMigrationUtils.baseHandlerContractID + ' 13 to 14',
  62.  
  63.   _databaseLocation: null,
  64.   _databaseGUID: null,
  65.  
  66.   migrate: function sbLibraryMigration_migrate(aLibrary) {
  67.     try{
  68.  
  69.       this._databaseGUID = aLibrary.databaseGuid;
  70.       this._databaseLocation = aLibrary.databaseLocation;
  71.  
  72.       var query = this._createQuery();
  73.  
  74.       // Update the schema version to the destination version.
  75.       query.addQuery("update library_metadata set value = '" 
  76.                      + this.toVersion + "' where name = 'version'");
  77.       query.addQuery("commit");
  78.  
  79.       // Try to reduce db size
  80.       query.addQuery("VACUUM");
  81.  
  82.       var retval;
  83.       query.setAsyncQuery(true);
  84.       query.execute(retval);
  85.  
  86.       // Raise a flag indicating that this library will need all 
  87.       // sort info to be recomputed.
  88.       // Normally we'd call propertyCache.invalidateSortData(), but 
  89.       // at this point in startup the property cache does not exist yet.
  90.       var prefs = Cc["@mozilla.org/preferences-service;1"]
  91.                     .getService(Ci.nsIPrefBranch);
  92.       prefs.setBoolPref("songbird.propertycache." + 
  93.             this._databaseGUID + ".invalidSortData", true);
  94.       prefs.QueryInterface(Ci.nsIPrefService).savePrefFile(null);
  95.     }
  96.     catch (e) {
  97.       dump("Exception occured: " + e);
  98.       throw e;
  99.     }
  100.   },
  101.  
  102.   _createQuery: function sbLibraryMigration_createQuery() {
  103.     var query = Cc["@songbirdnest.com/Songbird/DatabaseQuery;1"]
  104.                   .createInstance(Ci.sbIDatabaseQuery);
  105.     query.databaseLocation = this._databaseLocation;
  106.     query.setDatabaseGUID(this._databaseGUID);
  107.     
  108.     return query;
  109.   }
  110.   
  111. };
  112.  
  113. //-----------------------------------------------------------------------------
  114. // Module
  115. //-----------------------------------------------------------------------------
  116. function NSGetModule(compMgr, fileSpec) {
  117.   return XPCOMUtils.generateModule([
  118.     sbLibraryMigration
  119.   ]);
  120. }
  121.  
  122.