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");
32 const Cc = Components.classes;
33 const Ci = Components.interfaces;
34 const Cr = Components.results;
44 SBLocalDatabaseMigrationUtils.BaseMigrationHandler.call(
this);
49 this._propertyNames = {};
50 this._resourceProperties = [];
52 this._propertyManager =
Cc[
"@songbirdnest.com/Songbird/Properties/PropertyManager;1"]
53 .getService(
Ci.sbIPropertyManager);
61 __proto__: SBLocalDatabaseMigrationUtils.BaseMigrationHandler.prototype,
64 classID: Components.ID(
"{54A1D507-D085-4bfe-B729-1FFA13291C24}"),
65 contractID: SBLocalDatabaseMigrationUtils.baseHandlerContractID +
"0.6.1 to 0.7.0",
67 _databaseLocation:
null,
71 _resourceProperties:
null,
73 _propertyManager:
null,
75 migrate:
function sbLDBM061to070_migrate(aLibrary) {
76 this._databaseGUID = aLibrary.databaseGuid;
77 this._databaseLocation = aLibrary.databaseLocation;
79 this._getPropertyNames();
80 this._getResourceProperties();
82 var query = this._createQuery();
83 query.addQuery(
"begin");
87 for(let
i = 0;
i < this._resourceProperties.length; ++
i) {
88 let propertyId = this._propertyNames[this._resourceProperties[
i].propId];
89 let mediaItemId = this._resourceProperties[
i].itemId;
90 let
value = this._resourceProperties[
i].o;
92 if(this._propertyManager.hasProperty(propertyId)) {
93 let propertyInfo = this._propertyManager.getPropertyInfo(propertyId);
94 if(propertyInfo.type ==
"text") {
95 let
str =
"update resource_properties set obj_sortable = ? where media_item_id = ? and property_id = ?";
99 let sortableValue = propertyInfo.makeSortable(value);
101 query.bindStringParameter(0, sortableValue);
102 query.bindStringParameter(1, mediaItemId);
103 query.bindStringParameter(2, this._resourceProperties[
i].propId);
105 LOG(
"update resource_properties set obj_sortable = " +
107 " where media_item_id = " +
109 " and property_id = " + this._resourceProperties[
i].propId);
118 query.addQuery(
"drop table resource_properties_fts_all");
121 query.addQuery(
"create virtual table resource_properties_fts_all using FTS3 ( alldata )");
124 var ftsDataSub =
"select media_item_id, group_concat(obj_sortable) from resource_properties group by media_item_id";
125 var ftsLoadData =
"insert into resource_properties_fts_all (rowid, alldata) " + ftsDataSub;
127 query.addQuery(ftsLoadData);
130 query.addQuery(
"update library_metadata set value = '6' where name = 'version'");
133 query.addQuery(
"commit");
136 query.setAsyncQuery(
true);
137 query.execute(retval);
139 var sip =
Cc[
"@mozilla.org/supports-interface-pointer;1"]
140 .createInstance(
Ci.nsISupportsInterfacePointer);
143 this._titleText =
"Library Migration Helper";
144 this._statusText =
"Migrating 0.6.1 database to 0.7.0 database...";
145 this.migrationQuery = query;
147 this.startNotificationTimer();
148 SBJobUtils.showProgressDialog(sip.data,
null, 0);
149 this.stopNotificationTimer();
152 _createQuery:
function sbLDBM061to070_createQuery() {
153 var query =
Cc[
"@songbirdnest.com/Songbird/DatabaseQuery;1"]
154 .createInstance(
Ci.sbIDatabaseQuery);
155 query.databaseLocation = this._databaseLocation;
156 query.setDatabaseGUID(this._databaseGUID);
161 _getPropertyNames:
function sbLDBM061to070_getPropertyNames() {
162 var query = this._createQuery();
163 var str =
"select property_id, property_name from properties";
167 query.execute(retval);
169 var resultSet = query.getResultObject();
171 var rowCount = resultSet.getRowCount();
172 for(let currentRow = 0; currentRow < rowCount; ++currentRow) {
173 let propertyId = resultSet.getRowCell(currentRow, 0);
174 this._propertyNames[propertyId] = resultSet.getRowCell(currentRow, 1);
178 _getResourceProperties:
function sbLDBM061to070_getResourceProperties() {
179 var query = this._createQuery();
180 var str =
"select media_item_id, property_id, obj from resource_properties";
184 query.execute(retval);
186 var resultSet = query.getResultObject();
188 var rowCount = resultSet.getRowCount();
189 for(let currentRow = 0; currentRow < rowCount; ++currentRow) {
190 let mediaItemId = resultSet.getRowCell(currentRow, 0);
191 let propertyId = resultSet.getRowCell(currentRow, 1);
192 let obj = resultSet.getRowCell(currentRow, 2);
194 var
entry = {itemId: mediaItemId, propId: propertyId, o: obj };
195 this._resourceProperties.push(entry);
206 return XPCOMUtils.generateModule([
function sbLocalDatabaseMigrate061to070()
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
sbDeviceFirmwareAutoCheckForUpdate prototype classID
_getSelectedPageStyle s i