sbMigrate10To11pre1.js
Go to the documentation of this file.
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 
44 {
45  SBLocalDatabaseMigrationUtils.BaseMigrationHandler.call(this);
46 
47  this.fromVersion = 12;
48  this.toVersion = 13;
49 }
50 
51 //-----------------------------------------------------------------------------
52 // sbLocalDatabaseMigration Implementation
53 //-----------------------------------------------------------------------------
54 
55 sbLibraryMigration.prototype = {
56  __proto__: SBLocalDatabaseMigrationUtils.BaseMigrationHandler.prototype,
57  classDescription: 'Songbird Migration Handler, version 12 to 13',
58  classID: Components.ID("{98aafd32-9ed8-4a67-9cb6-1d8babe3c0c9}"),
59  contractID: SBLocalDatabaseMigrationUtils.baseHandlerContractID + ' 12 to 13',
60 
61  _databaseLocation: null,
62  _databaseGUID: null,
63 
64  migrate: function sbLibraryMigration_migrate(aLibrary) {
65  try{
66  this._databaseGUID = aLibrary.databaseGuid;
67  this._databaseLocation = aLibrary.databaseLocation;
68 
69  var query = this._createQuery();
70 
71  // Add the new searchable column
72  query.addQuery("alter table resource_properties add obj_searchable text");
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([
119  ]);
120 }
121 
const Cr
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
const Ci
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
const Cc
function sbLibraryMigration()
return null
Definition: FeedWriter.js:1143
var prefs
Definition: FeedWriter.js:1169
function LOG(s)
sbDeviceFirmwareAutoCheckForUpdate prototype classID
function NSGetModule(compMgr, fileSpec)