# KJSEmbed::JSObjectProxy Class Reference

A JS object that provides a binding to a QObject. More...

`#include <jsobjectproxy.h>`

Inheritance diagram for KJSEmbed::JSObjectProxy:

List of all members.

## Public Member Functions

| JSObjectProxy (KJSEmbedPart *part, QObject *target)
| JSObjectProxy (KJSEmbedPart *part, QObject *target, QObject *root)
| JSObjectProxy (KJSEmbedPart *part, QObject *target, QObject *root, const JSSecurityPolicy *sp)
virtual | ~JSObjectProxy ()
KJSEmbedPart * | part () const
KJS::Interpreter * | interpreter () const
QObject * | rootObject () const
QObject * | object () const
QWidget * | widget () const
void * | toVoidStar ()
bool | inherits (const char *clazz)
const JSSecurityPolicy * | securityPolicy () const
void | setSecurityPolicy (const JSSecurityPolicy *sp)
virtual KJS::Value | get (KJS::ExecState *exec, const KJS::Identifier &p) const
virtual void | put (KJS::ExecState *exec, const KJS::Identifier &p, const KJS::Value &v, int attr=KJS::None)
virtual KJS::UString | toString (KJS::ExecState *exec) const
virtual void | addBindings (KJS::ExecState *exec, KJS::Object &object)

## Protected Member Functions

void | addBindingsClass (KJS::ExecState *exec, KJS::Object &object)
void | addBindingsEnum (KJS::ExecState *exec, KJS::Object &object)
void | addBindingsSlots (KJS::ExecState *exec, KJS::Object &object)

## Friends

class | Bindings::JSObjectProxyImp

## Detailed Description

A JS object that provides a binding to a QObject.

### Introduction

This class defines a that allows scripts to access the properties of a QObject. The scripts can also create child objects, load dialogs from .ui files created by Designer and navigate the object tree in a similar manner to the DCOP/QObject bridge.

### Example Usage

The following example creates a that provides a binding to the properties of a . This binding is then used to create a property 'edit' for the object 'jsparent'.

       QLineEdit *edit = new QLineEdit();
       KJSEmbed::JSObjectProxy *proxy = new KJSEmbed::JSObjectProxy( js, edit );
       jsparent.put( js->globalExec(), "edit", proxy );

### Security Facilities

In order to ensure scripts don't run amok and to ensure the script interpreter used by KHTML remains secure, JSObjectProxy applies a security policy. Every time a script tries to access an object or property the following tests are performed:

- Does this request come from the correct ?
- Is the script allowed to access the specified QObject?
- Is the script allowed to access the specified property?

The KJSEmbed::JSSecurityPolicy class decides if the request should be granted. The security policy is automatically inherited by any child proxies created using the object tree accessor methods.

See also:
  KJSEmbed::JSFactory

Author:
  Richard Moore, rich@kde.org
  Id
    jsobjectproxy.h,v 1.30 2004/06/06 02:07:28 rich Exp

## Constructor & Destructor Documentation

KJSEmbed::JSObjectProxy::JSObjectProxy | ( | KJSEmbedPart * | part,
|  | QObject * | target
| ) |

| Create a JS binding to the target object. The binding will allow scripts to access any QObject that is descended the target and no others.

KJSEmbed::JSObjectProxy::JSObjectProxy | ( | KJSEmbedPart * | part,
|  | QObject * | target,
|  | QObject * | root
| ) |

| Create a JS binding to the target object. The binding will allow scripts to access any QObject that is descended from the specified root. If the specified root is 0 then access is granted to all objects.

KJSEmbed::JSObjectProxy::JSObjectProxy | ( | KJSEmbedPart * | part,
|  | QObject * | target,
|  | QObject * | root,
|  | const JSSecurityPolicy * | sp
| ) |

| Create a JS binding to the target object. The binding will allow scripts to access any QObject that is descended from the specified root, according to the specified JSSecurityPolicy . If the specified root is 0 then access is granted to all objects.

virtual KJSEmbed::JSObjectProxy::~JSObjectProxy | ( |  | ) | `[inline, virtual]`

## Member Function Documentation

virtual void KJSEmbed::JSObjectProxy::addBindings | ( | KJS::ExecState * | exec,
|  | KJS::Object & | object
| ) | `[virtual]`

Adds methods for traversing the QObject tree to the specified .

Only QObjects descended from the root specified in the constructor can be reached through JS proxies created with these bindings.

- properties()
- create(...)

void KJSEmbed::JSObjectProxy::addBindingsClass | ( | KJS::ExecState * | exec,
|  | KJS::Object & | object
| ) | `[protected]`

void KJSEmbed::JSObjectProxy::addBindingsEnum | ( | KJS::ExecState * | exec,
|  | KJS::Object & | object
| ) | `[protected]`

| Adds bindings for the constants defined by enums of the target.

void KJSEmbed::JSObjectProxy::addBindingsSlots | ( | KJS::ExecState * | exec,
|  | KJS::Object & | object
| ) | `[protected]`

| Adds bindings for slots defined by the target of the proxy.

virtual KJS::Value KJSEmbed::JSObjectProxy::get | ( | KJS::ExecState * | exec,
|  | const KJS::Identifier & | p
| ) | const`[virtual]`

| Reimplemented to return the value of the specified property if present.

bool KJSEmbed::JSObjectProxy::inherits | ( | const char * | clazz | ) | `[inline]`

| Returns true iff the content of this proxy inherits the specified base-class. Reimplemented from KJSEmbed::JSProxy.

KJS::Interpreter* KJSEmbed::JSObjectProxy::interpreter | ( |  | ) | const`[inline]`

| Returns the interpreter in which this proxy lives.

QObject* KJSEmbed::JSObjectProxy::object | ( |  | ) | const`[inline]`

| Returns the QObject the proxy is attached to.

KJSEmbedPart* KJSEmbed::JSObjectProxy::part | ( |  | ) | const`[inline]`

| Returns the KJSEmbedPart in which this proxy lives.

virtual void KJSEmbed::JSObjectProxy::put | ( | KJS::ExecState * | exec,
|  | const KJS::Identifier & | p,
|  | const KJS::Value & | v,
|  | int | attr = KJS::None
| ) | `[virtual]`

| Reimplemented to set the value of the specified property if possible.

QObject* KJSEmbed::JSObjectProxy::rootObject | ( |  | ) | const`[inline]`

| Returns the root object that defines the limit of the scope of this proxy.

const JSSecurityPolicy* KJSEmbed::JSObjectProxy::securityPolicy | ( |  | ) | const`[inline]`

| Returns the JSSecurityPolicy of the proxy.

void KJSEmbed::JSObjectProxy::setSecurityPolicy | ( | const JSSecurityPolicy * | sp | ) |

| Specifies the JSSecurityPolicy that should be applied to this proxy. Setting the policy to 0 restores the default policy.

virtual KJS::UString KJSEmbed::JSObjectProxy::toString | ( | KJS::ExecState * | exec | ) | const`[virtual]`

| Reimplemented to return the name and class of the target.

void* KJSEmbed::JSObjectProxy::toVoidStar | ( |  | ) | `[inline]`

| Returns the contents of this proxy as a void * pointer. This method should be virtual, but is not for b/c. Reimplemented from KJSEmbed::JSProxy.

QWidget* KJSEmbed::JSObjectProxy::widget | ( |  | ) | const`[inline]`

| Returns the associated QWidget, or 0 if the object is not a widget.

## Friends And Related Function Documentation

friend class Bindings::JSObjectProxyImp`[friend]`

The documentation for this class was generated from the following file:

- jsobjectproxy.h