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

  1. /*
  2.  *=BEGIN SONGBIRD GPL
  3.  *
  4.  * This file is part of the Songbird web player.
  5.  *
  6.  * Copyright(c) 2005-2009 POTI, Inc.
  7.  * http://www.songbirdnest.com
  8.  *
  9.  * This file may be licensed under the terms of of the
  10.  * GNU General Public License Version 2 (the ``GPL'').
  11.  *
  12.  * Software distributed under the License is distributed
  13.  * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
  14.  * express or implied. See the GPL for the specific language
  15.  * governing rights and limitations.
  16.  *
  17.  * You should have received a copy of the GPL along with this
  18.  * program. If not, go to http://www.gnu.org/licenses/gpl.html
  19.  * or write to the Free Software Foundation, Inc.,
  20.  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  21.  *
  22.  *=END SONGBIRD GPL
  23.  */
  24.  
  25. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  26. Components.utils.import("resource://app/jsmodules/ArrayConverter.jsm");
  27. Components.utils.import("resource://app/jsmodules/sbLocalDatabaseMigrationUtils.jsm");
  28. Components.utils.import("resource://app/jsmodules/SBJobUtils.jsm");
  29. Components.utils.import("resource://app/jsmodules/sbProperties.jsm");
  30.  
  31. const Cc = Components.classes;
  32. const Ci = Components.interfaces;
  33. const Cr = Components.results;
  34.  
  35. const FROM_VERSION = 21;
  36. const TO_VERSION = 22;
  37.  
  38. function LOG(s) {
  39.   dump("----++++----++++sbLibraryMigration " +
  40.        FROM_VERSION + " to " + TO_VERSION + ": " +
  41.        s +
  42.        "\n----++++----++++\n");
  43. }
  44.  
  45. function sbLibraryMigration()
  46. {
  47.   SBLocalDatabaseMigrationUtils.BaseMigrationHandler.call(this);
  48. }
  49.  
  50. //-----------------------------------------------------------------------------
  51. // sbLocalDatabaseMigration Implementation
  52. //-----------------------------------------------------------------------------
  53.  
  54. sbLibraryMigration.prototype = {
  55.   __proto__: SBLocalDatabaseMigrationUtils.BaseMigrationHandler.prototype,
  56.   classDescription: 'Songbird Migration Handler, version ' +
  57.                      FROM_VERSION + ' to ' + TO_VERSION,
  58.   classID: Components.ID("{73b78226-1dd2-11b2-92ba-c4ba81af8fc1}"),
  59.   contractID: SBLocalDatabaseMigrationUtils.baseHandlerContractID +
  60.               FROM_VERSION + 'to' + TO_VERSION,
  61.  
  62.   fromVersion: FROM_VERSION,
  63.   toVersion: TO_VERSION,
  64.   migrate: function sbLibraryMigration_migrate(aLibrary) {
  65.     try{
  66.       this.startNotificationTimer();
  67.       this._databaseGUID = aLibrary.databaseGuid;
  68.       this._databaseLocation = aLibrary.databaseLocation;
  69.  
  70.       // Run a query that will mark the library as migrated
  71.       query = this.createMigrationQuery(aLibrary);
  72.       query.addQuery(<>
  73.         CREATE INDEX idx_media_items_content_mime_type
  74.           ON media_items(content_mime_type);
  75.         </>);
  76.       query.addQuery(<>
  77.         UPDATE media_items
  78.           SET content_mime_type = "audio"
  79.           WHERE content_mime_type IS NULL
  80.             OR NOT content_mime_type IN ("audio", "video")
  81.         </>);
  82.       query.addQuery("commit");
  83.       query.setAsyncQuery(false);
  84.       if (query.execute() != 0) {
  85.         throw("Query failed: " + query.getLastError());
  86.       }
  87.     }
  88.     catch (e) {
  89.       LOG("Exception occured: " + e);
  90.       throw e;
  91.     }
  92.     finally {
  93.       this.stopNotificationTimer();
  94.     }
  95.   },
  96.  
  97. ///// sbIJobProgress
  98.   get status() Ci.sbIJobProgress.STATUS_RUNNING,
  99.   get progress() 0,
  100.   get total() 0,
  101.   get errorCount() 0,
  102.   getErrorMessages: ArrayConverter.stringEnumerator([]),
  103.   /// addJobProgressListener / removeJobProgressListener not implemented
  104. ///// sbIJobProgressCancellable
  105.   get canCancel() false,
  106.   cancel: function sbLibMig21to22_cancel() { throw Cr.NS_ERROR_NOT_IMPLEMENTED }
  107. };
  108.  
  109. //-----------------------------------------------------------------------------
  110. // Module
  111. //-----------------------------------------------------------------------------
  112. function NSGetModule(compMgr, fileSpec) {
  113.   return XPCOMUtils.generateModule([
  114.     sbLibraryMigration
  115.   ]);
  116. }
  117.  
  118.