|
|
Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The QCopChannel class provides communication capabilities between several clients. More...
#include <qcopchannel_qws.h>
Inherits QObject.
The QCopChannel class provides communication capabilities between several clients.
The Qt Cop (QCOP) is a COmmunication Protocol, allowing clients to communicate both within the same address space and between different processes.
Currently, this facility is only available on Qt/Embedded. On X11 and Windows we are exploring the use of existing standards such as DCOP and COM.
QCopChannel provides send() and isRegistered() which are static functions usable without an object.
The channel() function returns the name of the channel.
In order to listen to the traffic on a channel, you should either subclass QCopChannel and reimplement receive(), or connect() to the received() signal.
Returns TRUE if channel is registered; otherwise returns FALSE.
The default implementation emits the received() signal.
Note that the format of data has to be well defined in order to extract the information it contains.
Example:
void MyClass::receive( const QCString &msg, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "execute(QString,QString)" ) { QString cmd, arg; stream >> cmd >> arg; ... } else if ( msg == "delete(QString)" ) { QString filenname; stream >> filename; ... } else ... }This example assumes that the msg is a DCOP-style function signature and the data contains the function's arguments. (See send().)
Using the DCOP convention is a recommendation, but not a requirement. Whatever convention you use the sender and receiver must agree on the argument types.
See also send().
This signal is emitted with the msg and data whenever the receive() function gets incoming data.
Note that QDataStream provides a convenient way to fill the byte array with auxiliary data.
Example:
QByteArray ba; QDataStream stream( ba, IO_WriteOnly ); stream << QString("cat") << QString("file.txt"); QCopChannel::send( "System/Shell", "execute(QString,QString)", ba );Here the channel is "System/Shell". The msg is an arbitrary string, but in the example we've used the DCOP convention of passing a function signature. Such a signature is formatted as functionname(types) where types is a list of zero or more comma-separated type names, with no whitespace, no consts and no pointer or reference marks, i.e. no "*" or "&".
Using the DCOP convention is a recommendation, but not a requirement. Whatever convention you use the sender and receiver must agree on the argument types.
See also receive().
Send the message msg on channel channel. The message will be distributed to all clients subscribed to the channel.
See also receive().
This file is part of the Qt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | Qt 3.3.8
|