IRC Log Viewer » #firebreath » 2013-06-17

IRC Nick Time (GMT-7) Message
Bor0 02:06 what is an easy way to call a javascript function through the C++ code?
reichi_ 02:06
Bor0 03:06 got it, thanks :
reichi_ 03:06 yw
follow_me8 05:06 Hi
I have a question. Is it possible to build firebreath plugin without ActiveX support at all ?
kylehuff 05:06 follow_me8: Not that I have heard of, but I'm not an authority. I would suggest using the search feature of the IRC logs. let me dig out the link for you
follow_me8: here you go;
you might find something relevant there if nobody with some more concise knowledge doesn't chime in beforehand
follow_me8 05:06 Thank you ! Will take a look at logs for now
kylehuff 05:06 np; good luck
taxilian 09:06 follow_me8: why would you want to build it w/out activex support?
Wavey 10:06 hello everybody
If anybody is around, I have a quiestion about Browser Streams...
kylehuff 10:06 Wavey: it is best to just ask, and if someone is around and has input, they will respond when they are available
Wavey 10:06 Sure, kylehuff, you are right. Let me prepare it ;)
So, what I want is to create a browser stream and get a callback function called for every data chunk that arrives...
I am struggling to figure out what happens in the SimpleStreamHelper
I was using CURL to do HTTP requests, and I want to move to browserStreams. Therefore I created a 'DownloadProvider' class on which you can plug handlers
The class has this signature:
class DownloadProvider { public: DownloadProvider() { this->userData = NULL; this->progressFeedback = NULL; this->handleData = NULL; this->dataLength = 0; this->dataPos = 0; } virtual int startDownload( std::string url ); void setHandler( void (*cb)( DownloadProvider * p, void *,size_t ), void * cbData ); void
Hm.. not the pretties representation ...
What should happen is : A 'download provider' overloads the startDownload( std::string url ); function and it should call the handleData( DownloadProvider * p, void * ptr, size_t len ); callback when data arrives
Now I am trying to make a child class that uses BrowserStream to do the same thing
(blocking of course)
I think I am not really clear ... if anybody is interested into checking this with me, let me know to say a bit more...
To summarize : I want somehow a function download(URL std::string) that will create a BrowserStream and call a void(* callback)(void * dataPtr, size_t dataLen) function when the data arrives.
In order to be a bit more clear, here is my code :
for some reason the CVMBrowserProviderHelper functions are never called
(I am sharing code between the plugin and a stand-alone executable and that's why I need both CURLDownloadProvider and CVMBrowserProvider classes...
taxilian 11:06 Wavey: take a look at SimpleStreamsHelper for an example of how it should work
Wavey 11:06 I did, but I was kind of lost...
I realized that using setCallback you can get feedback when the process is completed...
while using setEventSink you can get progress events
(Using the FB::BrowserStreamRequest since the the BrowserHost->createStream( url, EventSink, bool bool) is deprecated)
.. What's actually the chain of actions to take in order to get a feedback on a PluginEventSinkPtr class?
So far I do:
taxilian 11:06 how are you creating it? If you don't hold the shared_ptr to the sink it won't stick around
Wavey 11:06 Check the gist :
I create the Sink and waiting on mutex
taxilian 11:06 sory, I'm really busy right now and while I glanced at your code I haven't had time to read it completely
is this on the main thread?
Wavey 11:06 Don't bother reading it all, just the line I sent you
on another boost::thread
taxilian 11:06 hmm. you might try using SyncRequest on simplestreamshelper just as a proof of concept
you might consider just updating SimpleStreamsHelper to add a version that allows a data arrived callback
instead of keeping a buffer and returning it all when done
I've meant to do that for a long time, but I just don't have time to write features that I don't need and aren't mainstream anymore
Wavey 11:06 Hm.. I'll have a look on it
Let's see if I manage to make a successful SimpleStreamsHelper SuncRequest to start with...
taxilian 11:06 good luck =]
Wavey 11:06 What's the concept, in general, to make a browser stream request?
Ok, too abstract question I think ...
let me check SimpleStreamsHelper first and I'll be back XD
taxilian 11:06 =]
yeah, I'm not sure what exactly you're looking for on that Q
Wavey 11:06 I wanted to follow the chain of actions that happen when you request a browser stream...
and what parts are FireBreath job and what parts is browser job
taxilian 11:06 my suggestion, try SimpleStreamsHelper and set a bunch of breakpoints to see what is going on =]
Wavey 11:06 Yeah, I am on it ;)
taxilian 11:06 'cause it's been too long, I don't know if I remember the details exactly
when you're done feel free to update the docs on the website =]
Wavey 11:06 sure :)
By the way, are browser streams restricted by CORS?
taxilian 11:06 CORS?
they are not
Wavey 11:06 ok, good XD
igoroliveira 11:06 taxilian: it is possible to pass an array by reference? i want to change from the plugin side the value of one array of floats
taxilian 11:06 yes, pass it as a JSObjectPtr
const JSObjectPtr&
igoroliveira 11:06 great!
Wavey 11:06 taxilia, I get an "Invalid Callback" exception using SynchronousRequest (called by SynchronousGet)
taxilian 11:06 sounds like it's an invalid callback, then
Wavey 11:06 Using the latest stable 1.7 zip from the downloads page
taxilian 11:06 did you attach a debugger?
Wavey 11:06 yup Vs
thrown by AsyncRequest
because !req.getCallback()
taxilian 11:06 that indicates that callback is null
trying to remember
I think callback may be a weak ptr
which would mean it's gone away by the time it tries to use it
Wavey 11:06 I see that you don't set a callback on SynchronousGet
Ps. Should I switch on git version?
taxilian 11:06 I would
but it should be the same thing
it's just much easier to deal with from git
Wavey 11:06 Ah.. I think I know
You prepare the FB::HttpCallback, but you don't assign it to the request ...
let' me check
taxilian 11:06 that's possible =]
pull requests are welcome
Wavey 11:06 Ps. What are these _1, _2 ... here? : boost::bind(&SyncHTTPHelper::getURLCallback, &helper, _1, _2, _3 _4)
ok, forget it ... I completely forgot the lookup features of VS ...
taxilian 11:06 google boost::bind
lookup features won't help you
that tells it to expect 4 parameters
Wavey 11:06 you underestimate the power of VS (lolz) : static boost::arg<1> _1
taxilian 11:06 heh
Wavey 11:06 yup.. works
but I violated your const& definition
FB::SimpleStreamHelper::SynchronousRequest( const FB::BrowserHostPtr& host, BrowserStreamRequest& req)
(2nd const is out)
because I need to change the callback
req.setCallback( cb )
(You already prepare cb but you don't use it)
unless you recommend another way :/
SimpleStreamHelper.cpp line 117
Ok, and now I think I know how to get progress events :P
Why are you using const& ?
taxilian 12:06 I want to say that was a bug that's been fixed in the latest version
I use const because you should always use const unless you specifically want it to be non-const
Wavey 12:06 It seems that it will also fail on the latest master on github :/
(haven't tried though... I just see that you also don't use the callback there too)
taxilian 12:06 interesting. might be that we just missed it there
I bet nobody else uses the syncrequest method
i'ts pretty new
Wavey 12:06 Check this :
You define cb, but you don't use it
I removed 'const' from req, because I had to do : req.setCallback(cb)
taxilian 12:06 hmm. yep, bet I never tested that one
sorry about that =]
good catch
pull requests are welcome =]
Wavey 12:06 np ;)
taxilian 12:06 PRAW
Wavey 12:06 yup :P
I just wanted to know about your const approach
Guest48233 12:06 Hi friends! So can somebody show how to send to browser my own object, then change it in browser, then send it back object to plugin. i'll be very thankfull for simple example=)
taxilian 12:06 Wavey: yeah, I just always const things unless they need to not be const; it helps catch bugs before they become bugs
Guest48233 there are a few options
you can create another JSAPI object and return that
or you can use m_host->getDOMWindow()->createObject() which returns a JSObjectPtr wrapping a normal javascript object, change it with ->SetProperty, and return it to the page, and then you can pass the same object into another function as a FB::JSObjectPtr and do the same thing again
more details on the website under interacting with javascript
Wavey 12:06 Damn...
It works, but I get an assertion failure, that (as I judge by the comment) means that I have a circular reference to BrowserHost
What could this mean, and what might be the best practice to avoid it?
follow_me8 12:06 mainly because of plugin size. I don't need IE support
There is enother issue - I'm getting "Type Error" with Chrome and FB plugin
kylehuff 12:06 I get that too when I just do window.myplugin, however, all of the methods work as intended. not sure if that is the same as what you see follow_me8
follow_me8 12:06 compiled without any changes from generated template
I get that when I trying to get plugin object using "getElementByid"
I can't access any of plugin's methods
any ideas ?