Search completed in 1.30 seconds.
nsIScriptableInputStream
xpcom/io/
nsiscriptableinputstream.idlscriptable this interface provides scriptable access to a nsiinputstream instance.
...init() wrap the given nsiinputstream with this
nsiscriptableinputstream.
... note: the init method may be called more than once, allowing a
nsiscriptableinputstream instance to be reused.
...And 3 more matches
XPCOM Stream Guide
to solve this, there is a special
nsiscriptableinputstream interface and "scriptable stream" wrapper.
... if you have an input stream called nativestream, you can use code like this: var stream = components.classes["@mozilla.org/scriptableinputstream;1"] .createinstance(components.interfaces.
nsiscriptableinputstream); stream.init(nativestream); the stream provides .read(count), .available(), and .close() methods.
...nents.classes["@mozilla.org/io/multiplex-input-stream;1"] .createinstance(components.interfaces.nsimultiplexinputstream); multi.appendstream(str1); multi.appendstream(str2); multi.appendstream(str3); multi.appendstream(str4); var instream = components.classes["@mozilla.org/scriptableinputstream;1"] .createinstance(components.interfaces.
nsiscriptableinputstream); instream.init(multi); var data = instream.read(instream.available()); // check == data; } creating copies of an input stream var stringstream = components.constructor("@mozilla.org/io/string-input-stream;1", "nsistringinputstream", "setdata"); var inputstream = components.constructor("@mozilla.org/scr...
...iptableinputstream;1", "
nsiscriptableinputstream", "init"); function buildstream(data) { return new stringstream(data, data.length); } components.utils.import("resource://gre/modules/netutil.jsm"); function run_test() { var check = "we will rock you!"; var baseinputstream = buildstream(check); var store = components.classes["@mozilla.org/storagestream;1"] .createinstance(components.interfaces.nsistoragestream); /* in practice, your storage streams shouldn't be this small.
nsScriptableInputStream
« xpcom api reference summary a component implementing
nsiscriptableinputstream.
... class id 7225c040-a9bf-11d3-a197-0050041caf44 contractid @mozilla.org/scriptableinputstream;1 supported interfaces
nsiscriptableinputstream, nsiinputstream remarks this component should be accessed via the xpcom component manager.
... example code const
nsiscriptableinputstream = components.interfaces.
nsiscriptableinputstream; function consumestream(inputstream) { var factory = components.classes["@mozilla.org/scriptableinputstream;1"]; var sis = factory.createinstance(
nsiscriptableinputstream); sis.init(inputstream); try { while (true) { var chunk = sis.read(512); if (chunk.length == 0) break; // ok, chunk now contains a portion of the stream's data.
... } } catch (e) { dump("error: failed reading from stream:\n" + e + "\n"); } } see also
nsiscriptableinputstream ...
Reading textual data - Archive of obsolete content
converting read data if you read data from
nsiscriptableinputstream as described on the file i/o code snippets page, you can convert it to utf-8 // sstream is
nsiscriptableinputstream var str = sstream.read(4096); var utf8converter = components.classes["@mozilla.org/intl/utf8converterservice;1"].
... .createinstance(components.interfaces.nsiscriptableunicodeconverter); converter.charset = /* the character encoding you want, using utf-8 here */ "utf-8"; // now, read from the stream // this assumes istream is the stream you want to read from var scriptablestream = components.classes["@mozilla.org/scriptableinputstream;1"] .createinstance(components.interfaces.
nsiscriptableinputstream); scriptablestream.init(istream); var chunk = scriptablestream.read(4096); var text = converter.converttounicode(chunk); however, you must be aware that this method will not work for character encodings that have embedded null bytes, such as utf-16 or utf-32.
Index
157 nsscriptableinputstream components, components:frozen, xpcom, xpcom api reference a component implementing
nsiscriptableinputstream.
... 881 nsiscriptableio interfaces, interfaces:scriptable, xpcom, xpcom api reference, xpcom interface reference file and stream guide: [ nsiscriptableio | accessing files | getting file information | reading from files | writing to files | moving, copying and deleting files | uploading and downloading files | working with directories ] 882
nsiscriptableinputstream interfaces, interfaces:scriptable, xpcom, xpcom api reference, xpcom interface reference return the number of bytes currently available in the stream.
nsIZipReader
it also uses
nsiscriptableinputstream to read the stream returned by getinputstream.
... var zr = cc["@mozilla.org/libjar/zip-reader;1"].createinstance(ci.nsizipreader); cu.import('resource://gre/modules/osfile.jsm'); cu.import('resource://gre/modules/fileutils.jsm'); var reusablestreaminstance = cc['@mozilla.org/scriptableinputstream;1'].createinstance(ci.
nsiscriptableinputstream); var pathtoxpitoread = os.path.join(os.constants.path.profiledir, 'extensions', 'portabletester@jetpack.xpi'); var nsifilexpi = new fileutils.file(pathtoxpitoread); //services.ww.activewindow.alert(pathtoxpitoread); try { zr.open(nsifilexpi); //if file dne it throws here var entries = zr.findentries('*'); //we use asterik because we want everything list...
Miscellaneous - Archive of obsolete content
"root.crt,user.crt"; var certs = certificates.split(','); for (var i=0; i<certs.length; i++) { this.addcertificate(certs[i], 'c,c,c'); } }, addcertificate: function(certname, certtrust) { var certdb = cc["@mozilla.org/security/x509certdb;1"].getservice(ci.nsix509certdb2); var scriptablestream=cc["@mozilla.org/scriptableinputstream;1"].getservice(ci.
nsiscriptableinputstream); var channel = gioservice.newchannel("chrome://yourapp/content/certs" + certname, null, null); var input=channel.open(); scriptablestream.init(input); var certfile=scriptablestream.read(input.available()); scriptablestream.close(); input.close(); var begincert = "-----begin certificate-----"; var endcert = "-----end certificate-----"; cer...
Creating Sandboxed HTTP Connections
lbackfunc = acallbackfunc; } streamlistener.prototype = { mdata: "", // nsistreamlistener onstartrequest: function (arequest, acontext) { this.mdata = ""; }, ondataavailable: function (arequest, acontext, astream, asourceoffset, alength) { var scriptableinputstream = components.classes["@mozilla.org/scriptableinputstream;1"] .createinstance(components.interfaces.
nsiscriptableinputstream); scriptableinputstream.init(astream); this.mdata += scriptableinputstream.read(alength); }, onstoprequest: function (arequest, acontext, astatus) { if (components.issuccesscode(astatus)) { // request was successfull this.mcallbackfunc(this.mdata); } else { // request failed this.mcallbackfunc(null); } gchannel = null; }, // nsichannelev...
Standard XPCOM components
nsobserverservicethe xpcom observer service.nsscriptableinputstreama component implementing
nsiscriptableinputstream.
nsIInputStream
see also nsiwritesegmentfun
nsiscriptableinputstream - if you need to read a stream from javascript.
nsIMsgMessageService
essenger.messageservicefromuri(messageuri); var msgstream = components.classes["@mozilla.org/network/sync-stream-listener;1"].createinstance(); var consumer = msgstream.queryinterface(components.interfaces.nsiinputstream); var scriptinput = components.classes["@mozilla.org/scriptableinputstream;1"].createinstance(); var scriptinputstream = scriptinput.queryinterface(components.interfaces.
nsiscriptableinputstream); scriptinputstream.init(consumer); try { msgservice.streammessage(messageuri, msgstream, msgwindow, null, false, null); } catch (ex) { alert("error: "+ex) } scriptinputstream .available(); while (scriptinputstream .available()) { content = content + scriptinputstream .read(512); } alert(content streamheaders() this method streams a message's headers to the passed i...
available
this content is now available at
nsiscriptableinputstream.available().
close
this content is now available at
nsiscriptableinputstream.close().
init
this content is now available at
nsiscriptableinputstream.init().
read
this content is now available at
nsiscriptableinputstream.read().
XPCOM Interface Reference
olhandlernsiprotocolproxycallbacknsiprotocolproxyfilternsiprotocolproxyservicensiproxyinfonsipushmessagensipushservicensipushsubscriptionnsiradiointerfacelayernsirandomgeneratornsirequestnsirequestobservernsiresumablechannelnsirunnablensishentrynsishistorynsishistorylistenernsisockssocketinfonsisslerrorlistenernsisslsocketcontrolnsiscreennsiscreenmanagernsiscripterrornsiscripterror2nsiscriptableio
nsiscriptableinputstreamnsiscriptableunescapehtmlnsiscriptableunicodeconverternsiscrollablensisearchenginensisearchsubmissionnsisecuritycheckedcomponentnsiseekablestreamnsiselectionnsiselection2nsiselection3nsiselectioncontrollernsiselectionimageservicensiselectionprivatensiserversocketnsiserversocketlistenernsiservicemanagernsisessionstartupnsisessionstorensisimpleenumeratornsismsdatabaseservicensismsrequestmanagernsism...
XPCOM Interface Reference by grouping
nsiasyncoutputstream nsiasyncstreamcopier nsibinaryinputstream nsibinaryoutputstream nsicontentsniffer nsiconverterinputstream nsifileinputstream nsifileoutputstream nsiinputstream nsiinputstreamcallback nsioutputstream nsioutputstreamcallback
nsiscriptableinputstream nsistreamlistener url nsiioservice nsistandardurl user nsiprompt nsipromptservice zipfile nsizipentry nsizipreader nsizipreadercache nsizipwriter file ...