Qt 4.8
Public Types | Public Slots | Public Functions | Static Public Functions | Properties | List of all members
QScriptDBusMessageConstructor Class Reference

#include <main.h>

Inheritance diagram for QScriptDBusMessageConstructor:
QObject QScriptable

Public Types

enum  MessageType {
  InvalidMessage = QDBusMessage::InvalidMessage, MethodCallMessage = QDBusMessage::MethodCallMessage, ReplyMessage = QDBusMessage::ReplyMessage, ErrorMessage = QDBusMessage::ErrorMessage,
  SignalMessage = QDBusMessage::SignalMessage
}
 

Public Slots

QDBusMessage createError (const QString &name, const QString &msg)
 
QDBusMessage createMethodCall (const QString &destination, const QString &path, const QString &interface, const QString &method)
 
QDBusMessage createSignal (const QString &path, const QString &interface, const QString &name)
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Public Functions

QScriptValue protoType () const
 
 QScriptDBusMessageConstructor (QScriptEngine *engine, QScriptValue extensionObject)
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QScriptable
QScriptValue argument (int index) const
 Returns the function argument at the given index, or an invalid QScriptValue if the Qt function was not invoked from script code. More...
 
int argumentCount () const
 Returns the number of arguments passed to the function in this invocation, or -1 if the Qt function was not invoked from script code. More...
 
QScriptContextcontext () const
 Returns a pointer to the QScriptContext associated with the current Qt function call, or 0 if the Qt function was not invoked from script code. More...
 
QScriptEngineengine () const
 Returns a pointer to the QScriptEngine associated with the current Qt function call, or 0 if the Qt function was not invoked from script code. More...
 
 QScriptable ()
 
QScriptValue thisObject () const
 Returns the `this' object associated with the current Qt function call, or an invalid QScriptValue if the Qt function was not invoked from script code. More...
 
 ~QScriptable ()
 

Static Public Functions

static QScriptValue createErrorReply (QScriptContext *context, QScriptEngine *engine)
 
static QScriptValue createReply (QScriptContext *context, QScriptEngine *engine)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Properties

QScriptValue proto
 

Additional Inherited Members

- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 148 of file main.h.

Enumerations

◆ MessageType

Constructors and Destructors

◆ QScriptDBusMessageConstructor()

QScriptDBusMessageConstructor::QScriptDBusMessageConstructor ( QScriptEngine engine,
QScriptValue  extensionObject 
)

Definition at line 214 of file main.cpp.

215  : QObject(engine)
216 {
217  proto = engine->newQMetaObject(metaObject(), engine->newQObject(this));
218 
219  proto.setProperty(QLatin1String("createReply"), engine->newFunction(createReply));
220  proto.setProperty(QLatin1String("createErrorReply"), engine->newFunction(createErrorReply));
221 
222  extensionObject.setProperty(QLatin1String("QDBusMessage"), proto);
223  engine->setDefaultPrototype(qMetaTypeId<QDBusMessage>(), proto);
224 }
QScriptValue newFunction(FunctionSignature signature, int length=0)
Creates a QScriptValue that wraps a native (C++) function.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QScriptValue createReply(QScriptContext *context, QScriptEngine *engine)
Definition: main.cpp:279
static QScriptValue createErrorReply(QScriptContext *context, QScriptEngine *engine)
Definition: main.cpp:293
QScriptValue newQObject(QObject *object, ValueOwnership ownership=QtOwnership, const QObjectWrapOptions &options=0)
Creates a QtScript object that wraps the given QObject object, using the given ownership.
void setProperty(const QString &name, const QScriptValue &value, const PropertyFlags &flags=KeepExistingFlags)
Sets the value of this QScriptValue&#39;s property with the given name to the given value.
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
QScriptValue newQMetaObject(const QMetaObject *metaObject, const QScriptValue &ctor=QScriptValue())
Creates a QtScript object that represents a QObject class, using the the given metaObject and constru...
void setDefaultPrototype(int metaTypeId, const QScriptValue &prototype)
Sets the default prototype of the C++ type identified by the given metaTypeId to prototype.
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

Functions

◆ createError

QDBusMessage QScriptDBusMessageConstructor::createError ( const QString name,
const QString msg 
)
slot

Definition at line 236 of file main.cpp.

237 {
238  return QDBusMessage::createError(name, msg);
239 }
static QDBusMessage createError(const QString &name, const QString &msg)
Constructs a new DBus message representing an error, with the given name and msg. ...

◆ createErrorReply()

QScriptValue QScriptDBusMessageConstructor::createErrorReply ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 293 of file main.cpp.

Referenced by QScriptDBusMessageConstructor().

294 {
295  if (context->argumentCount() != 2)
296  return engine->nullValue();
297 
298  QDBusMessage msg;
299  scriptValueToMessage(context->thisObject(), msg);
300 
301  QString name = context->argument(0).toString();
302  QString errMsg = context->argument(1).toString();
303  return messageToScriptValue(engine, msg.createErrorReply(name, errMsg));
304 }
QString toString() const
Returns the string value of this QScriptValue, as defined in ECMA-262 section 9.8, "ToString".
The QString class provides a Unicode character string.
Definition: qstring.h:83
QDBusMessage createErrorReply(const QString name, const QString &msg) const
Constructs a new DBus message representing an error reply message, with the given name and msg...
const char * name
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
static QScriptValue messageToScriptValue(QScriptEngine *engine, const QDBusMessage &message)
Definition: main.cpp:241
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
static void scriptValueToMessage(const QScriptValue &value, QDBusMessage &message)
Definition: main.cpp:264
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
QScriptValue argument(int index) const
Returns the function argument at the given index.
QScriptValue nullValue()
Returns a QScriptValue of the primitive type Null.

◆ createMethodCall

QDBusMessage QScriptDBusMessageConstructor::createMethodCall ( const QString destination,
const QString path,
const QString interface,
const QString method 
)
slot

Definition at line 231 of file main.cpp.

232 {
233  return QDBusMessage::createMethodCall(destination, path, interface, method);
234 }
static QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Constructs a new DBus message representing a method call.

◆ createReply()

QScriptValue QScriptDBusMessageConstructor::createReply ( QScriptContext context,
QScriptEngine engine 
)
static

Definition at line 279 of file main.cpp.

Referenced by QScriptDBusMessageConstructor().

280 {
281  QDBusMessage msg;
282  scriptValueToMessage(context->thisObject(), msg);
283 
284  QList<QVariant> args;
285  for (int i = 0; i < context->argumentCount(); ++i) {
286  QScriptValue value = context->argument(i);
287  args.append(value.toVariant());
288  }
289 
290  return messageToScriptValue(engine, msg.createReply(args));
291 }
QVariant toVariant() const
Returns the QVariant value of this QScriptValue, if it can be converted to a QVariant; otherwise retu...
int argumentCount() const
Returns the number of arguments passed to the function in this invocation.
QDBusMessage createReply(const QList< QVariant > &arguments=QList< QVariant >()) const
Constructs a new DBus message representing a reply, with the given arguments.
static QScriptValue messageToScriptValue(QScriptEngine *engine, const QDBusMessage &message)
Definition: main.cpp:241
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
static void scriptValueToMessage(const QScriptValue &value, QDBusMessage &message)
Definition: main.cpp:264
QScriptValue thisObject() const
Returns the `this&#39; object associated with this QScriptContext.
The QScriptValue class acts as a container for the Qt Script data types.
Definition: qscriptvalue.h:57
QScriptValue argument(int index) const
Returns the function argument at the given index.

◆ createSignal

QDBusMessage QScriptDBusMessageConstructor::createSignal ( const QString path,
const QString interface,
const QString name 
)
slot

Definition at line 226 of file main.cpp.

227 {
228  return QDBusMessage::createSignal(path, interface, name);
229 }
static QDBusMessage createSignal(const QString &path, const QString &interface, const QString &name)
Constructs a new DBus message with the given path, interface and name, representing a signal emission...

◆ protoType()

QScriptValue QScriptDBusMessageConstructor::protoType ( ) const
inline

Definition at line 163 of file main.h.

163 { return proto; }

Properties

◆ proto

QScriptValue QScriptDBusMessageConstructor::proto
private

Definition at line 175 of file main.h.

Referenced by QScriptDBusMessageConstructor().


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