const CLASSNAME = "SongbirdPlayHistoryItem"; const CONTRACTID = "@skrul.com/songbird-play-history-item;1"; const CID = Components.ID("{a0bdc163-39c5-4396-9126-2c79bc406ef4}"); const Cc = Components.classes; const Ci = Components.interfaces; function PlayHistoryItem() { this._idx = null; this._ts = null; this._playlistRef = null; this._playlistIndex = null; this._metadataTitle = null; this._metadataArtist = null; this._metadataAlbum = null; this._metadataUrl = null; this._metadataUuid = null; this._metadataLength = null; this._startState = null; this._startTime = null; this._stopState = null; this._stopTime = null; this._stopPosition = null; } function d(s) { dump(">>>>>>>>>>>>> PlayHistoryItem: " + s + "\n"); } // nsISupports PlayHistoryItem.prototype.QueryInterface = function(aIID) {5 if(!aIID.equals(Ci.nsISupports) && !aIID.equals(Ci.sbIPlayHistoryItem)) throw Components.results.NS_ERROR_NO_INTERFACE; return this; } // sbPlayHistoryItem PlayHistoryItem.prototype.init = function(aIdx, aTs, aPlaylistRef, aPlaylistIndex, aMetadataTitle, aMetadataArtist, aMetadataAlbum, aMetadataUrl, aMetadataUuid, aMetadataLength, aStartState, aStartTime, aStopState, aStopTime, aStopPosition) { this._idx = aIdx; this._ts = aTs; this._playlistRef = aPlaylistRef; this._playlistIndex = aPlaylistIndex; this._metadataTitle = aMetadataTitle; this._metadataArtist = aMetadataArtist; this._metadataAlbum = aMetadataAlbum; this._metadataUrl = aMetadataUrl; this._metadataUuid = aMetadataUuid; this._metadataLength = aMetadataLength; this._startState = aStartState; this._startTime = aStartTime; this._stopState = aStopState; this._stopTime = aStopTime; this._stopPosition = aStopPosition; } PlayHistoryItem.prototype.started = function(aPlaylistRef, aPlaylistIndex, aMetadataTitle, aMetadataArtist, aMetadataAlbum, aMetadataUrl, aMetadataUuid, aMetadataLength, aStartState, aStartTime) { this.init(0, 0, aPlaylistRef, aPlaylistIndex, aMetadataTitle, aMetadataArtist, aMetadataAlbum, aMetadataUrl, aMetadataUuid, aMetadataLength, aStartState, aStartTime, Ci.sbIPlayHistoryItem.STOP_STATE_NONE, -1, -1); } PlayHistoryItem.prototype.stopped = function(aStopState, aStopTime, aStopPosition) { this._stopState = aStopState; this._stopTime = aStopTime; this._stopPosition = aStopPosition; } PlayHistoryItem.prototype.setIdxTs = function(aIdx, aTs) { this._idx = aIdx; this._ts = aTs; } PlayHistoryItem.prototype.toString = function() { return "" + "idx: " + this._idx + ", " + "ts: " + this._ts + ", " + "playlistRef: " + this._playlistRef + ", " + "playlistIndex: " + this._playlistIndex + ", " + "metadataTitle: " + this._metadataTitle + ", " + "metadataArtist: " + this._metadataArtist + ", " + "metadataAlbum: " + this._metadataAlbum + ", " + "metadataUrl: " + this._metadataUrl + ", " + "metadataUuid: " + this._metadataUuid + ", " + "metadataLength: " + this._metadataLength + ", " + "startState: " + this._startState + ", " + "startTime: " + new Date(this._startTime) + ", " + "stopState: " + this._stopState + ", " + "stopTime: " + (this._stopTime > 0 ? new Date(this._stopTime) : "none") + ", " + "stopPosition: " + this._stopPosition; } PlayHistoryItem.prototype.__defineGetter__("idx", function() { return this._idx; } ); PlayHistoryItem.prototype.__defineGetter__("ts", function() { return this._ts; } ); PlayHistoryItem.prototype.__defineGetter__("playlistRef", function() { return this._playlistRef; } ); PlayHistoryItem.prototype.__defineGetter__("playlistIndex", function() { return this._playlistIndex; } ); PlayHistoryItem.prototype.__defineGetter__("metadataTitle", function() { return this._metadataTitle; } ); PlayHistoryItem.prototype.__defineGetter__("metadataArtist", function() { return this._metadataArtist; } ); PlayHistoryItem.prototype.__defineGetter__("metadataAlbum", function() { return this._metadataAlbum; } ); PlayHistoryItem.prototype.__defineGetter__("metadataUrl", function() { return this._metadataUrl; } ); PlayHistoryItem.prototype.__defineGetter__("metadataUuid", function() { return this._metadataUuid; } ); PlayHistoryItem.prototype.__defineGetter__("metadataLength", function() { return this._metadataLength; } ); PlayHistoryItem.prototype.__defineGetter__("startState", function() { return this._startState; } ); PlayHistoryItem.prototype.__defineGetter__("startTime", function() { return this._startTime; } ); PlayHistoryItem.prototype.__defineGetter__("stopState", function() { return this._stopState; } ); PlayHistoryItem.prototype.__defineGetter__("stopTime", function() { return this._stopTime; } ); PlayHistoryItem.prototype.__defineGetter__("stopPosition", function() { return this._stopPosition; } ); /** * XPCOM Registration */ var Module = new Object(); Module.registerSelf = function(compMgr, fileSpec, location, type) { compMgr = compMgr.QueryInterface(Ci.nsIComponentRegistrar); compMgr.registerFactoryLocation(CID, CLASSNAME, CONTRACTID, fileSpec, location, type); } Module.getClassObject = function(compMgr, cid, iid) { if(!cid.equals(CID)) { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; } if(!iid.equals(Ci.nsIFactory)) { throw Components.results.NS_ERROR_NO_INTERFACE; } return Factory; } Module.canUnload = function(compMgr) { return true; } var Factory = {}; Factory.createInstance = function(outer, iid) { if(outer != null) { throw Components.results.NS_ERROR_NO_AGGREGATION; } return new PlayHistoryItem(); } function NSGetModule(compMgr, fileSpec) { return Module; }