I'm trying to work on a Mozilla extension which intercepts and
displays a
certain content type (WML content). This is currently done in my
wmlbrowser
extension (wmlbrowser.mozdev.org) but not in a very satisfactory
manner. I am
currently trying to use nsIURIContentListener to deal with the
content.
So far I have successfully written an instance of
nsIURIContentListener and
registered it with the nsIURILoader, but when I try and return an
nsIStreamListener in the doContent method, the object I return never
seems to
get called.
I don't know whether I'm just doing something dumb or whether it's
harder than
I think. (I'm not really sure that I'm doing the right thing in terms
of 'out'
parameters with Javascript.)
The IDL for doContent is:
boolean doContent(in string aContentType,
in boolean aIsContentPreferred,
in nsIRequest aRequest,
out nsIStreamListener aContentHandler);
I have (brief excerpt):
doContent: function(contentType, isContentPreferred, request,
contentHandler)
{
this.logger.logStringMessage("wmlBrowserContentListener
doContent " + contentType);
// Ignore content types which we don't care about
if (contentType != "text/vnd.wap.wml") {
return false;
}
contentHandler.value = new wmlContentHandler ();
return true;
},
and then for wmlContentHandler I have:
function wmlContentHandler () {
this.logger =
Components.classes['@mozilla.org/consoleservice;1'].getService(Components.interfaces.nsIConsoleService);
}
wmlContentHandler.prototype = {
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsISupports) ||
iid.equals(Components.interfaces.nsIRequestObserver) ||
iid.equals(Components.interfaces.nsIStreamListener)) {
return this;
} else {
throw Components.results.NS_ERROR_NO_INTERFACE;
}
},
onStartRequest: function (channel, context) {
window.alert ("onStartRequest");
this.logger.logStringMessage("wmlBrowserContentListener
onStartRequest ");
},
onStopRequest: function (channel, context, status) {
this.logger.logStringMessage("wmlBrowserContentListener
onStopRequest ");
},
onDataAvailable: function (request, context, inputStream, offset,
count) {
this.logger.logStringMessage("wmlBrowserContentListener
onDataAvailable " + count);
}
}
Can anyone see any problems with this?
--
Matthew
_______________________________________________
Mozilla-netlib mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-netlib