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

IRC Nick Time (GMT-7) Message
feeling 02:06 hi~
is anybody here?
hi
Sunny_ 04:06 Hi FireBreath team
I want to understand when to use NPN_ReleaseVariantValue()
from mozilla documentation, It is not clear to me
graykos 04:06 helloo
Sunny_ 04:06 Hi graykos
can you tell me what is the use of NPN_ReleaseVariantValue?
from the document it is not clear to me
graykos 04:06 you got nice captcha-maker here)) i just got one captcha i can read but have no clue how to type))
maybe i can, but i'm not sure. need to read docs
cause i never used it
Sunny_ 04:06 Can you please help me with this?
graykos 04:06 i'll try, ok) can you give me a link to appropriate docs?
Sunny_ 04:06 http://dev.opera.com/articles/view/the-opera-plug-in-interface/#NPN_ReleaseVariantValue
https://developer.mozilla.org/en/NPN_ReleaseVariantValue
Thanks
graykos 04:06 its like "delete", isnt it?...
i mean C++ Object *o = new Object(); delete o; or something like that
nope?
Sunny_ 05:06 Ok, I will check. Thanks
graykos 05:06 that looks like truth... you allocate something so you need to mannually free the memory, cause no garbage collector exists
i got a question too
btw
can anyone show me the practical use of FB::JSObjectPtr???
in passing methods for callbacks
i mean some code
Oh, mighty taxilian! I'm calling for ya!
graykos 06:06 Anyone alive?
graykos 07:06 Anyone dead? x_x
dougma 07:06 graykos: you'll find lots of examples of JSObject in the FBTestPlugin project
danhigham 08:06 hey, I was hoping someone might be able to help me with a problem I have registering a browser plugin in Windows
when I run regsvr32, windows says it can't register the dll
I do have dependencies on three other libraries, should they be in the same folder when I try and register?
dougma 08:06 yes
danhigham 08:06 in os 10 I assume they are packed nicely in the plugin itself
ah ok
dougma 08:06 the dll is actually loaded and called by regsvr32
danhigham 08:06 do I need to copy the lib files too? I assume not
dougma 08:06 no
danhigham 08:06 awesome, were good!
thanks very much dougma
dougma 08:06 too easy!
danhigham 08:06 heh :-)
all works a treat, can't believe I didn't discover firebreath until a few days ago!
rizwan 08:06 Hi i am new to firebreath, I saw the tutorials about creating javascript method and reading property value. what if i want to execute a javascript command from plugin, how can i do that
for example, i want my plugin to read some parameters through param tag, and then do some calculation and execute a method (say) document.title = "new title";
is it possible to do that through plugin? please suggest something...
_neilg_ 08:06 Yes, that's possible
rizwan 08:06 can you give me some idea how to go about it
i mean how can i send JS command rather then just returning some value through plugin
_neilg_ 08:06 You know how to get the parameter?
rizwan 08:06 yes
i just tried it and it worked
_neilg_ 08:06 Right, good. :)
Now, bear in mind I actually haven't called from the plugin into the page via JavaScript, but I can tell you what I believe you need to do
In your JavaScript on your page you need to have something like:
function onPluginLoad()
{
alert("I'm loaded!");
}

document.getElementById("plugin").addEventListener("load", onPluginLoad, false);
The function could be called anything but MUST start with "on"
Then in your API FireBreath class in the header you'd add FB_JSAPI_EVENT(PluginLoad, 0, ());
Then from your code you could just call fire_PluginLoad();
You could make it pass a parameter to your JavaScript function which could be the title
In which case that would look like:
FB_JSAPI_EVENT(PluginLoad, 1, (const std::string&));
and
fire_PluginLoad("new document title");
Hope that helps!
http://www.firebreath.org/display/documentation/Firing+Events+from+JSAPI
rizwan 09:06 thank you for the information
I will have a look, sorry for delayed response, there was someone at the door :)))
graykos 09:06 hello?
rizwan 09:06 Another question, is it easy to render video and play in a windowed plugin using firebreath
just like flash does it
graykos 09:06 i don't know ^^
rizwan 09:06 @graykos, do you know how to make windowed plugin using firebreath. Do you know of any example?
graykos 09:06 nope
rizwan 09:06 Okay, seems like i cant get to play a video in firebreath based plugin
dougma 09:06 firebreath is not a video playback library...
graykos 09:06 seems like you need to wait until taxilian awakes
mb he can answer
and i'm interested if i can make somenameAPI class generated by fbgen singleton
dougma 09:06 it could always forward to a singleton
or you try returning a singleton instance from createJSAPI
rizwan 09:06 Ok Thanks, i guess i have to stick to flash if firebreath does not support video option. I thought may be integrating firebreath with google webrtc, if it can work
graykos 09:06 how>
?
dougma
ow, or mb you know one thing
look
i got JS function
and i want to pass it as a parameter into fb plugin to call it from there
(or, to be honest not from there, but from one level deeper)
I registered method with FB::JSObjectPtr parameter
and inside i try to set it to specific callback pointer
but i cant cause it says it cannot convert type of JSObjectPtr to this callback type
may be i am dumb
dougma 09:06 have you looked at the test plugin?
it does callbacks...
graykos 09:06 no, not already
dougma 09:06 you should look at that.
graykos 09:06 link please
^^
dougma 09:06 http://www.firebreath.org/display/documentation/FireBreath+Examples
graykos 09:06 there he is
hiii
taxilian 09:06 hello
seems like all the interesting stuff happens while I'm asleep =]
graykos 09:06 dougma
you know, that is terrifying
taxilian 09:06 what is terrifying?
graykos 09:06 when i try to imagine how to organize smth like this in my project i shit bricks
setting callbacks
i am looking now at test plugin
taxilian 09:06 what exactly are you trying to do?
sorry, I skimmed the history but there was a lot last night
graykos 09:06 i got fb plugin
and dll with needed functionality for me
i need to set callbacks for this dll to call JS via fb plugin
if you understand what i mean
me not))
taxilian 09:06 ok; there are two ways to do callbacks into javascript
well, three, technically
but two that I recommend
the first is using event handlers
the second is to actually pass a function in as a parameter
the third is to call into the DOM and find a global javascript function
graykos 09:06 look
taxilian 09:06 lol
graykos 09:06 i got a FB which can fire event to js on my plugin ui
but i god this dll which is communicating with FB
so the chain is
dll gots a signal
calls callback from FB
it fires event
JS handles
but to pass a func as a callback to dll i need to make it static
and when i do i cannot fire event from it
taxilian 09:06 do you control this dll?
graykos 09:06 no
taxilian 09:06 hmm. well, that's trickier
dougma 09:06 the dll callback interface must offer you a context ptr or something like that
taxilian 09:06 do you plan on being able to support more than one page open at a time?
i.e. what happens if you have two different plugins both running simultaneously
two instances of the same plugin, I mean
two pages with the plugin on it
graykos 09:06 nope, i really really need only one instance of plugin working at a time in a browser
taxilian 09:06 so you want to force it to only allow one?
graykos 09:06 it needs to be like singleton
taxilian 09:06 yeah, that's not real easy
but doableish
graykos 09:06 yep
taxilian 09:06 the question is, do you want it to only allow one or do you want all instances to be linked?
graykos 09:06 one
taxilian 09:06 okay; the first thing you'll need, then, is some way to inforce that. Basically create a static or global variable somewhere to act as a semaphore; doesn't have to be a real semaphore, it's just conceptually what you're doing
when a plugin starts up (constructor of your class) you check that variable, if it is 0 then increment it and mark your current instance somehow as being active
graykos 09:06 what i try to do now is to take JSObjectPtr as a parameter in some setSomeCallback()
taxilian 09:06 that's easy
!findfile FBTestPluginAPI.cpp
FireBreathBot 09:06 Found 1 matching file(s) in the master branch. First 1 are:
examples/FBTestPlugin/FBTestPluginAPI.cpp http://goo.gl/e2uMr
graykos 09:06 and to convert it to a Callback ptr which dll can take
and pass it there
taxilian 09:06 https://github.com/firebreath/FireBreath/blob/master/examples/FBTestPlugin/FBTestPluginAPI.cpp#L311
that's a good example
okay, that you won't be able to do
not directly
but what you can do is have a static weak_ptr to your plugin class
or to your JSAPI class, I suppose
graykos 10:06 looks like yes
taxilian 10:06 so when you have a plugin that you marked active (took the semaphore) when you create the JSAPI object you set it to the static weak_ptr as well
in your static callback you try to lock the weak_ptr; if it doesn't lock, then there isn't a plugin instance you can use, so you don't do anything
if it does lock, you call a method on that that calls back into javascript
make sense?
graykos 10:06 hm... i need some time to understand how to achieve this
taxilian 10:06 do you understand how shared_ptr and weak_ptr work?
graykos 10:06 think no
dougma 10:06 (as an aside... boost::weak_ptr changed my life!)
taxilian 10:06 it changed FireBreath significantly for the better as well =]
okay, quick rundown:
shared_ptr<type> is a reference counted smart pointer
so you assign it to another shared_ptr<type> and the refcount is now 2, etc
when the refcount hits 0 the destructor is called
it's a simple form of garbage collection, you might say
all of the "Ptr" types in FireBreath are actually typedefs for boost::shared_ptr<SomeObject>
so FB::JSObjectPtr is just a boost::shared_ptr<FB::JSObject>
with me so far?
graykos 10:06 ye
taxilian 10:06 okay; so the problem you sometimes have is that you need to know when something goes away, but it dosen't know to tell you
enter boost::weak_ptr
a boost::weak_ptr itself is not a pointer to the shared_ptr, but it has a "weak reference" to it
when a shared_ptr's reference count hits 0 and it gets released, all weak_ptrs basically become invalidated
so to use a weak_ptr, you have to call .lock() on it and it will return a shared_ptr
but if the shared_ptr has been released and the object destroyed, it will return a NULL shared_ptr
take a look at https://github.com/firebreath/FireBreath/blob/master/examples/FBTestPlugin/FBTestPluginAPI.cpp#L84
that's how getPlugin() works; the plugin has a shared_ptr reference to the JSAPI object, so if the JSAPI object had a reference to the plugin it would be a circular reference and nothing would ever get freed
but m_pluginWeak in that function is a weak_ptr, so it lets us hold onto a pointer to the plugin
if you have a static weak_ptr then you can use that to get the JSAPI object — if it exists still
and if it doesn't exist, then you can tell that as well
and you know there is no current plugin instance to work with
so you don't actually need (or want!) a singleton
because those are really dangerous in a plugin
graykos 10:06 ok
taxilian 10:06 actually, you have a singleton; it's the DLL. The trick is safely communicating between that singleton and your plugin instances, of which only one can be active at a time
graykos 10:06 thx, i ll take some time to really understand everything)
taxilian 10:06 when you get far enough to have specific questions again let us know =]
graykos 10:06 ok)
FireBreathBot 10:06 JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue created by junzhu
JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue updated by richard
DanielX 11:06 hi, I'm using FireBreath to make a browser plugin to handle joystick input and I have a question about linking libraries with cmake
taxilian 11:06 did you look at the libraries page on the wiki?
!wiki libraries
DanielX 11:06 yes
taxilian 11:06 ok
whats up?
darn net split...
DanielX 11:06 I want to follow the dynamic libraries with relative paths model but I don't know anything about CMake
I tossed an .so file into a lib directory below my project root
and added # add library dependencies here; leave ${PLUGIN_INTERNAL_DEPS} there unless you know what you're doing! target_link_libraries(${PROJECT_NAME} ${PLUGIN_INTERNAL_DEPS} "lib/ois-v1-3/libOIS-1.3.0.so" )
but that doesn't seem to be right
taxilian 11:06 it wouldn't be; you're relative to the build directory in this case
you can use ${CMAKE_CURRENT_SOURCE_DIR} to get the path to the directory your CMakeLists.txt for your project is in
and go relative to taht
DanielX 11:06 ok, I'll try that
is there a better way to do what I'm trying to accomplish or is the libs directory below the sources good?
taxilian 11:06 that's probably as good as anything
you're the one who ask the question on StackOverflow a day or two ago?
DanielX 11:06 yep
taxilian 11:06 thought so =]
I always like questions that let me legitimately put another link to FireBreath out there… ;-)
DanielX 11:06 yeah, it's working well for me
I actually started using it before you answered though
taxilian 11:06 good — that means it's not too hard to find
DanielX 11:06 just looking around at the options it seemed to be the best for what I needed
taxilian 11:06 that's because there really aren't many good options for writing browser plugins
but I think it's also a pretty good system =]
DanielX 11:06 I usually do JavaScript, Ruby and Rails, so this C++ stuff is brutal for me
taxilian 11:06 you'll get it; it's definitely a learning curve
FireBreath uses C++ pretty well to help avoid memory management issues, though
when in doubt, there are lots of examples in the FireBreath source code itself on how to do things
DanielX 11:06 cool, I'll read up and be back here if I get stuck on anything
taxilian 11:06 cool. good luck
DanielX 11:06 thanks again for your help
taxilian 11:06 no problem
DanielX: any plans to release this open source when you get it working?
DanielX 11:06 definitely, I'll probably get it up on github soon
taxilian 11:06 awesome; when you do, make sure you add a link from the examples page on FireBreath.org
DanielX 11:06 my main thing is making a browser based IDE for creating web based games
taxilian 11:06 huh… that sounds interesting
DanielX 11:06 and it crushes me that there is no simple way to get 8 Xbox controllers working in HTML5
taxilian 11:06 lol. yeah, that's one place where plugins will still be needed for a long time, I think… any time you need to interface with hardware other than keyboard/mouse
DanielX 11:06 Here's the game I've been working on that really needs gamepad support: (warning background music) http://pixieengine.com/projects/166/fullscreen
pixieengine is the online IDE I've made for creating HTML5 games
taxilian 11:06 looks pretty cool… is this done or still early?
DanielX 11:06 I figure that once I get this browser plugin (and the corresponding JS library) gamepad support could finally be taken for granted by browser based game developers
taxilian 11:06 (I just can't figure out what you're supposed to do :-P)
DanielX 11:06 it's a prototype that I've been working on for about 2 weeks
the physics and core interactions are solid, I just need to add graphics and gamepad support and polish it up a bit
taxilian 11:06 looks neat
DanielX 11:06 it's a hockey themed fighting game
the winning team is the one that scores the most goals, so maybe it's a fighting themed hockey game
taxilian 11:06 well let me know how that goes; it sounds like a cool project
DanielX 11:06 sure thing
FireBreathBot 12:06 JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue commented by junzhu "I was not using firebug. The thing is that we are not seeing this behavior on Windows plugin. I w..."
FireBreathBot 12:06 JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue updated by junzhu "The two hilighted memory blocks are never released."
JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue updated by junzhu "Here is the sample project."
taxilian 12:06 !findfile NPObjectAPI.cpp
FireBreathBot 12:06 Found 1 matching file(s) in the master branch. First 1 are:
src/NpapiCore/NPObjectAPI.cpp http://goo.gl/LMh7K
JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue commented by richard "Try adding this line to the end of the callMultipleFunctions block:
JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue commented by sundevils "That was the first thing I tried. But it has no effect."
JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue commented by richard "I'll have to tinker with it, then. I may not be able to get to this for a week or two, I have to..."
FireBreathBot 13:06 JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue commented by sundevils "Sure. Really appreciate your time."
_neilg_ 13:06 What the...?
I'm building a plugin on Windows on my machine for the first time in months and it doesn't work. I can't run regsvr32 on it - but Dependency Walker finds all of the dependencies just fine
taxilian 14:06 it probably hates you
_neilg_ 14:06 I think it does
I get "The specified procedure could not be found."
But... it has DllRegisterServer. I can see it! :)
taxilian 14:06 lol
no idea
_neilg_ 14:06 Me either. I think... I'm just going to reboot. It's a weird place to be!
FireBreathBot 15:06 JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue commented by sundevils "Well, adding "browser->ReleaseVariantValue(&npargs[2]);" line to the end of the callMultipleFunct..."
JIRA issue http://jira.firebreath.org/browse/FIREBREATH-104 issue commented by richard "interesting. Yeah, since that value doesn't seem to be getting released that is where I would ex..."