KJS::Value JSObjectProxy::get( KJS::ExecState *exec, const KJS::Identifier &p ) const { if ( !isAllowed( exec->interpreter() ) ) { kdWarning() << "JS get request from unknown interpreter, ignoring" << endl; return KJS::Null(); } if ( !policy->isPropertyAllowed( this, obj, p.ascii() ) ) return ObjectImp::get( exec, p ); if ( !obj ) { kdDebug( 80001 ) << "JS getting '" << p.ustring().qstring() << "' but qobj has died" << endl; return ObjectImp::get( exec, p ); } kdDebug( 80001 ) << "JS getting '" << p.ascii() << endl; // Properties QString prop = p.ustring().qstring(); QMetaObject *meta = obj->metaObject(); if ( meta->findProperty( p.ascii(), true ) != -1 ) { QVariant val = obj->property( prop.ascii() ); kdDebug( 80001 ) << "JS getting '" << p.ascii() << "' ( " << val.typeName() << ")" << endl; return convertToValue( exec, val ); } return ObjectImp::get ( exec, p ); }
void JSObjectProxy::put( KJS::ExecState *exec, const KJS::Identifier &p, const KJS::Value &v, int attr ) { if ( !isAllowed( exec->interpreter() ) ) { kdWarning() << "JS put request from unknown interpreter, ignoring" << endl; return ; } if ( !policy->hasCapability( JSSecurityPolicy::CapabilitySetProperties ) ) { ObjectImp::put( exec, p, v, attr ); return ; } if ( !obj ) { kdDebug( 80001 ) << "JS setting '" << p.ascii() << "' but qobj has died" << endl; ObjectImp::put( exec, p, v, attr ); return ; } // Properties QMetaObject *meta = obj->metaObject(); int propIndex = meta->findProperty( p.ascii(), true ); if ( propIndex != -1 ) { QVariant val = convertToVariant( exec, v ); if ( meta->property(propIndex, true)->isEnumType() ) { obj->setProperty( p.ascii(), val.toUInt() ); } else if ( val.isValid() ) { obj->setProperty( p.ascii(), val ); } else { kdWarning(80001) << "Error setting value." << endl; } } else { ObjectImp::put( exec, p, v, attr ); } if ( jspart->factory() ->eventMapper() ->isEventHandler( p ) ) { if ( evproxy.isNull() ) evproxy = new KJSEmbed::JSObjectEventProxy( this ); evproxy->addFilter( jspart->factory() ->eventMapper() ->findEventType( p ) ); kdDebug( 80001 ) << "Adding event handler " << p.ascii() << endl; } }