flyson
flyso****@users*****
2006年 2月 11日 (土) 19:43:15 JST
Index: bbs2chreader/components/nsBbs2chProtocolHandler.js diff -u bbs2chreader/components/nsBbs2chProtocolHandler.js:1.9 bbs2chreader/components/nsBbs2chProtocolHandler.js:1.10 --- bbs2chreader/components/nsBbs2chProtocolHandler.js:1.9 Wed Dec 14 00:45:28 2005 +++ bbs2chreader/components/nsBbs2chProtocolHandler.js Sat Feb 11 19:43:15 2006 @@ -109,7 +109,7 @@ tmpChannel.init(aURI, "text/xml", "Shift_JIS", new Bbs2chBoardRss()); break; default: - tmpChannel = this._createStringChannel(aURI, "application/x-bbs2ch", aURI.spec); + tmpChannel = new BogusChannel(aURI, "application/x-bbs2ch"); break; } @@ -138,22 +138,59 @@ _redirectChannel: function(aURISpec){ var channelURI = this._ioService.newURI(aURISpec, null, null); return this._ioService.newChannelFromURI(channelURI); + } +} + + +function BogusChannel(aURI, aContentType){ + this.URI = aURI; + this.originalURI = aURI; + this.contentType = aContentType; +} + +BogusChannel.prototype = { + QueryInterface: function(aIID){ + if(aIID.equals(Components.interfaces.nsIChannel)) return this; + if(aIID.equals(Components.interfaces.nsIRequest)) return this; + if(aIID.equals(Components.interfaces.nsISupports)) return this; + + throw Components.results.NS_ERROR_NO_INTERFACE; + }, + + loadAttributes: null, + contentLength: 0, + owner: null, + loadGroup: null, + notificationCallbacks: null, + securityInfo: null, + status: Components.results.NS_OK, + + resume: function(){ + throw Components.results.NS_ERROR_NOT_IMPLEMENTED; }, + suspend: function(){ + throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + }, + + open: function(){ + throw Components.results.NS_ERROR_NOT_IMPLEMENTED; + }, + asyncOpen: function(aObserver, aContext){ + + aObserver.onStartRequest(this, aContext); + }, + + asyncRead: function(aListener, aContext){ + aListener.onStartRequest(this, aContext); + }, + + isPending: function(){ + return true; + }, - _createStringChannel: function(aURI, aContentType, aContent){ - var inputStreamChannel = Components.classes["@mozilla.org/network/input-stream-channel;1"] - .createInstance(Components.interfaces.nsIInputStreamChannel); - var stringInputStream = Components.classes["@mozilla.org/io/string-input-stream;1"] - .createInstance(Components.interfaces.nsIStringInputStream); - - stringInputStream.setData(aContent, aContent.length); - - inputStreamChannel.setURI(aURI); - inputStreamChannel.contentType = aContentType; - inputStreamChannel.contentStream = stringInputStream; - inputStreamChannel.contentLength = aContent.length; - return inputStreamChannel; + cancel: function(aStatus){ + this.status = aStatus; } }