Q: Howto expose one QObject-inherited object to JS namespace ?
Kun Xi
bookstack at gmail.com
Thu Aug 4 11:47:55 CEST 2005
Hello Geiser,
Sorry to bother you again. I have spend several hours in googling and
digging into the kjsembed source code, tring to figure out how to
expose the C++ object to JS namespace.
The background of this question is soc-kde-scripting project. I have
exposed the KABCore instance mCore as "Contacts" and I found several
interesting things:
1) Only public slot function can be accessed even the JSSecurityPolicy
is set to CapabilityAll. Is this that designed deliberatedly ?
2) To access the addressBook in KABCore, I added the following lines
in KABCore::publishObject() :
{
KJSEmbedPart *js = KPIM::KJSEngine::instance();
JSSecurityPolicy::setDefaultPolicy( JSSecurityPolicy::CapabilityAll );
KJS::Object root = js->addObject(this, "Contacts");
js->addObject( mAddressBook, root, "addressBook" );
}
The JS could access Contacts, but complains that the addressBook is
unamed( KAB::AddressBook ). It is recoganized inherited from QObject.
My question is: How could I expose mAddressBook ? Should I develop a
wrapper class or use JSOpaqueProxy to delegate mAddressBook ? Could
you be kind enough to provide some small examples ?
The same applies to the KOrganizer, I need to expose the object from
libkcal. No idea how to implement this.
Thanks.
Best regards,
Kun Xi
More information about the Kde-soc
mailing list