зеркало из https://github.com/mozilla/snowl.git
assign sources and people place IDs to support alta88's Places integration work
This commit is contained in:
Родитель
57eaf09cd1
Коммит
cad0fca4a9
|
@ -70,7 +70,7 @@ let SnowlDatastore = {
|
|||
//**************************************************************************//
|
||||
// Database Creation & Access
|
||||
|
||||
_dbVersion: 11,
|
||||
_dbVersion: 12,
|
||||
|
||||
_dbSchema: {
|
||||
// Note: datetime values like messages:timestamp are stored as Julian dates.
|
||||
|
@ -108,7 +108,8 @@ let SnowlDatastore = {
|
|||
"humanURI TEXT",
|
||||
"username TEXT",
|
||||
"lastRefreshed REAL",
|
||||
"importance INTEGER"
|
||||
"importance INTEGER",
|
||||
"placeID INTEGER"
|
||||
]
|
||||
},
|
||||
|
||||
|
@ -206,7 +207,8 @@ let SnowlDatastore = {
|
|||
// all of them and select from it at display time?
|
||||
"name TEXT NOT NULL",
|
||||
"homeURL TEXT",
|
||||
"iconURL TEXT"
|
||||
"iconURL TEXT",
|
||||
"placeID INTEGER"
|
||||
]
|
||||
},
|
||||
|
||||
|
@ -479,11 +481,11 @@ let SnowlDatastore = {
|
|||
* FIXME: special case the calling of this function so we don't have to
|
||||
* rename it every time we increase the schema version.
|
||||
*/
|
||||
_dbMigrate0To11: function(dbConnection) {
|
||||
_dbMigrate0To12: function(dbConnection) {
|
||||
this._dbCreate(dbConnection);
|
||||
},
|
||||
|
||||
_dbMigrate4To11: function(dbConnection) {
|
||||
_dbMigrate4To12: function(dbConnection) {
|
||||
this._dbMigrate4To5(dbConnection);
|
||||
this._dbMigrate5To6(dbConnection);
|
||||
this._dbMigrate6To7(dbConnection);
|
||||
|
@ -491,41 +493,52 @@ let SnowlDatastore = {
|
|||
this._dbMigrate8To9(dbConnection);
|
||||
this._dbMigrate9To10(dbConnection);
|
||||
this._dbMigrate10To11(dbConnection);
|
||||
this._dbMigrate11To12(dbConnection);
|
||||
},
|
||||
|
||||
_dbMigrate5To11: function(dbConnection) {
|
||||
_dbMigrate5To12: function(dbConnection) {
|
||||
this._dbMigrate5To6(dbConnection);
|
||||
this._dbMigrate6To7(dbConnection);
|
||||
this._dbMigrate7To8(dbConnection);
|
||||
this._dbMigrate8To9(dbConnection);
|
||||
this._dbMigrate9To10(dbConnection);
|
||||
this._dbMigrate10To11(dbConnection);
|
||||
this._dbMigrate11To12(dbConnection);
|
||||
},
|
||||
|
||||
_dbMigrate6To11: function(dbConnection) {
|
||||
_dbMigrate6To12: function(dbConnection) {
|
||||
this._dbMigrate6To7(dbConnection);
|
||||
this._dbMigrate7To8(dbConnection);
|
||||
this._dbMigrate8To9(dbConnection);
|
||||
this._dbMigrate9To10(dbConnection);
|
||||
this._dbMigrate10To11(dbConnection);
|
||||
this._dbMigrate11To12(dbConnection);
|
||||
},
|
||||
|
||||
_dbMigrate7To11: function(dbConnection) {
|
||||
_dbMigrate7To12: function(dbConnection) {
|
||||
this._dbMigrate7To8(dbConnection);
|
||||
this._dbMigrate8To9(dbConnection);
|
||||
this._dbMigrate9To10(dbConnection);
|
||||
this._dbMigrate10To11(dbConnection);
|
||||
this._dbMigrate11To12(dbConnection);
|
||||
},
|
||||
|
||||
_dbMigrate8To11: function(dbConnection) {
|
||||
_dbMigrate8To12: function(dbConnection) {
|
||||
this._dbMigrate8To9(dbConnection);
|
||||
this._dbMigrate9To10(dbConnection);
|
||||
this._dbMigrate10To11(dbConnection);
|
||||
this._dbMigrate11To12(dbConnection);
|
||||
},
|
||||
|
||||
_dbMigrate9To11: function(dbConnection) {
|
||||
_dbMigrate9To12: function(dbConnection) {
|
||||
this._dbMigrate9To10(dbConnection);
|
||||
this._dbMigrate10To11(dbConnection);
|
||||
this._dbMigrate11To12(dbConnection);
|
||||
},
|
||||
|
||||
_dbMigrate10To12: function(dbConnection) {
|
||||
this._dbMigrate10To11(dbConnection);
|
||||
this._dbMigrate11To12(dbConnection);
|
||||
},
|
||||
|
||||
_dbMigrate4To5: function(aDBConnection) {
|
||||
|
@ -679,6 +692,14 @@ let SnowlDatastore = {
|
|||
dbConnection.executeSimpleSQL("UPDATE collections SET iconURL = 'chrome://snowl/skin/person-16.png' WHERE groupIDColumn = 'authors.id'");
|
||||
},
|
||||
|
||||
/**
|
||||
* Migrate the database schema from version 11 to version 12.
|
||||
*/
|
||||
_dbMigrate11To12: function(dbConnection) {
|
||||
dbConnection.executeSimpleSQL("ALTER TABLE sources ADD COLUMN placeID INTEGER");
|
||||
dbConnection.executeSimpleSQL("ALTER TABLE people ADD COLUMN placeID INTEGER");
|
||||
},
|
||||
|
||||
get _selectHasSourceStatement() {
|
||||
let statement = this.createStatement(
|
||||
"SELECT name FROM sources WHERE machineURI = :machineURI"
|
||||
|
|
|
@ -76,8 +76,8 @@ function stringToArray(string) {
|
|||
return array;
|
||||
}
|
||||
|
||||
function SnowlFeed(aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance) {
|
||||
SnowlSource.init.call(this, aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance);
|
||||
function SnowlFeed(aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance, aPlaceID) {
|
||||
SnowlSource.init.call(this, aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance, aPlaceID);
|
||||
}
|
||||
|
||||
SnowlFeed.prototype = {
|
||||
|
@ -138,6 +138,8 @@ SnowlFeed.prototype = {
|
|||
|
||||
importance: null,
|
||||
|
||||
placeID: null,
|
||||
|
||||
get faviconSvc() {
|
||||
return SnowlSource.faviconSvc;
|
||||
},
|
||||
|
|
|
@ -110,15 +110,16 @@ SnowlIdentity.create = function(sourceID, externalID, name, homeURL, iconURL) {
|
|||
|
||||
SnowlIdentity.prototype = {};
|
||||
|
||||
function SnowlPerson(id, name) {
|
||||
function SnowlPerson(id, name, placeID) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.placeID = placeID;
|
||||
}
|
||||
|
||||
SnowlPerson.__defineGetter__("_getAllStatement",
|
||||
function() {
|
||||
let statement = SnowlDatastore.createStatement(
|
||||
"SELECT id, name FROM people ORDER BY name"
|
||||
"SELECT id, name, placeID FROM people ORDER BY name"
|
||||
);
|
||||
this.__defineGetter__("_getAllStatement", function() { return statement });
|
||||
return this._getAllStatement;
|
||||
|
@ -132,7 +133,9 @@ SnowlPerson.getAll = function() {
|
|||
|
||||
try {
|
||||
while (statement.step())
|
||||
people.push(new SnowlPerson(statement.row.id, statement.row.name));
|
||||
people.push(new SnowlPerson(statement.row.id,
|
||||
statement.row.name,
|
||||
statement.row.placeID));
|
||||
}
|
||||
finally {
|
||||
statement.reset();
|
||||
|
|
|
@ -181,13 +181,14 @@ let SnowlService = {
|
|||
URI.get(row.humanURI),
|
||||
row.username,
|
||||
SnowlDateUtils.julianToJSDate(row.lastRefreshed),
|
||||
row.importance);
|
||||
row.importance,
|
||||
row.placeID);
|
||||
},
|
||||
|
||||
get _getAccountStatement() {
|
||||
delete this._getAccountStatement;
|
||||
return this._getAccountStatement = SnowlDatastore.createStatement(
|
||||
"SELECT id, type, name, machineURI, humanURI, username, lastRefreshed, importance " +
|
||||
"SELECT id, type, name, machineURI, humanURI, username, lastRefreshed, importance, placeID " +
|
||||
"FROM sources WHERE id = :id"
|
||||
);
|
||||
},
|
||||
|
@ -215,7 +216,7 @@ let SnowlService = {
|
|||
get _accountsStatement() {
|
||||
delete this._accountsStatement;
|
||||
return this._accountsStatement = SnowlDatastore.createStatement(
|
||||
"SELECT id, type, name, machineURI, humanURI, username, lastRefreshed, importance " +
|
||||
"SELECT id, type, name, machineURI, humanURI, username, lastRefreshed, importance, placeID " +
|
||||
"FROM sources"
|
||||
);
|
||||
},
|
||||
|
|
|
@ -124,7 +124,7 @@ Cu.import("resource://snowl/modules/utils.js");
|
|||
* for other subclasses that access them via __lookupGetter__.
|
||||
*/
|
||||
let SnowlSource = {
|
||||
init: function(aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance) {
|
||||
init: function(aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance, aPlaceID) {
|
||||
this.id = aID;
|
||||
this.name = aName;
|
||||
this.machineURI = aMachineURI;
|
||||
|
@ -132,6 +132,7 @@ let SnowlSource = {
|
|||
this.username = aUsername;
|
||||
this._lastRefreshed = aLastRefreshed;
|
||||
this.importance = aImportance;
|
||||
this.placeID = aPlaceID;
|
||||
},
|
||||
|
||||
// How often to refresh sources, in milliseconds.
|
||||
|
@ -193,6 +194,9 @@ let SnowlSource = {
|
|||
// relative to other sources to which the user is subscribed.
|
||||
importance: null,
|
||||
|
||||
// The ID of the place representing this source in a list of collections.
|
||||
placeID: null,
|
||||
|
||||
// Favicon Service
|
||||
get faviconSvc() {
|
||||
let faviconSvc = Cc["@mozilla.org/browser/favicon-service;1"].
|
||||
|
|
|
@ -119,8 +119,8 @@ const AUTH_REALM = "Snowl";
|
|||
// FIXME: make the constructor accept credentials instead of passing them
|
||||
// to the subscribe function.
|
||||
|
||||
function SnowlTwitter(aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance) {
|
||||
SnowlSource.init.call(this, aID, aName, MACHINE_URI, HUMAN_URI, aUsername, aLastRefreshed, aImportance);
|
||||
function SnowlTwitter(aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance, aPlaceID) {
|
||||
SnowlSource.init.call(this, aID, aName, MACHINE_URI, HUMAN_URI, aUsername, aLastRefreshed, aImportance, aPlaceID);
|
||||
SnowlTarget.init.call(this);
|
||||
}
|
||||
|
||||
|
@ -179,6 +179,8 @@ SnowlTwitter.prototype = {
|
|||
|
||||
importance: null,
|
||||
|
||||
placeID: null,
|
||||
|
||||
get faviconSvc() {
|
||||
return SnowlSource.faviconSvc;
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче