Dne nedelja, 05. avgust 2012 20:05:58 UTC+2 je oseba Josh Matthews napisala:
> On 07/24/2012 06:54 AM, justSomeGuy wrote:
> 
> > Hi,
> 
> >
> 
> > I'm trying to get responses but I can't seem to figure out how to use 
> > nsiTraceableChannel. What I already did is that i registered an observer 
> > for http-on-modify-request and http-on-examine-response, which is working 
> > just fine. Now what I'm trying to do is use nsiTraceableChannel to replace 
> > a stream listener with my own which i implemented. This code is not working:
> 
> >
> 
> > ...
> 
> > nsresult rv;
> 
> >
> 
> > ...
> 
> > if(strcmp(aTopic, "http-on-examine-response"))
> 
> > {
> 
> >    nsCOMPtr<nsITraceableChannel> traceableChannel = 
> > do_QueryInterface(aSubject, &rv);
> 
> >    MyListener *myListener = new MyListener;
> 
> >    //nsCOMPtry<MyListener> myListener = new MyListener; //i tried this way 
> > too
> 
> >    rv = traceableChannel->SetNewListener(myListener, 
> > getter_AddRefs(myListener->mListener)); //I put the 
> > nsCOMPtr<nsIStreamListener> mListener; into the implementation of 
> > nsIStreamListener
> 
> > ...
> 
> > }
> 
> >
> 
> > It seems not to work. Am I doing something wrong (maybe i should create my 
> > object in a diferent way)? Because my implementation of onStartRequest, 
> > onDataAvailable and onStopRequest are never called.
> 
> >
> 
> > In rv (nsresult) i get 0 (NS_OK). But it seems that the listener was never 
> > replaced. I would realy apreciate your help.
> 
> >
> 
> > Thank you in advanced for your help!
> 
> >
> 
> 
> 
> Looking over this code again, |if(strcmp(aTopic, 
> 
> "http-on-examine-response"))| is incorrect. If that's present in the 
> 
> original code, you should fix it.

Thank you for your rapid response. If I may ask what is wrong with it. Because 
it does come into this part. It also creates MyListener ant the return

I also have the same line for the http-on-modify-request |if(strcmp(aTopic, 
"http-on-modify-request"))| and it seems to work just fine there. 

in fact in the observer i have:

if(strcmp(aTopic, "http-on-modify-request"))
{
//here everything works just fine. Can do everything i want.
}
else if(strcmp(aTopic, "http-on-examine-response"))
{
//it comes in here. it says it everything is ok

  nsCOMPtr<nsITraceableChannel> traceableChannel = do_QueryInterface(aSubject, 
&rv);
  MyListener *myListener = new MyListener;
  //nsCOMPtry<MyListener> myListener = new MyListener; //i tried this way too
  rv = traceableChannel->SetNewListener(myListener, 
getter_AddRefs(myListener->mListener)); //I put the nsCOMPtr<nsIStreamListener> 
mListener; into the implementation of nsIStreamListener
...

//but the listener doesn't seem to be changed.
}

If something is wrong with strcmp(aTopic, "http-on-modify-request") or 
strcmp(aTopic, "http-on-examine-response") i would really appreciate if you 
could point me to the right direction.

Really appreciate your help.
Regards
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to