The QCopChannel class provides communication capabilities between several clients.
.PP
The Qt Cop (QCOP) is a COmmunication Protocol, allowing clients to communicate both within the same address space and between different processes.
.PP
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.
.PP
QCopChannel provides send() and isRegistered() which are static functions usable without an object.
.PP
The channel() function returns the name of the channel.
.PP
In order to \fIlisten\fR to the traffic on a channel, you should either subclass QCopChannel and reimplement receive(), or connect() to the received() signal.
Constructs a QCop channel and registers it with the server using the name \fIchannel\fR. The standard \fIparent\fR and \fIname\fR arguments are passed on to the QObject constructor.
Destroys the client's end of the channel and notifies the server that the client has closed its connection. The server will keep the channel open until the last registered client detaches.
Using the DCOP convention is a recommendation, but not a requirement. Whatever convention you use the sender and receiver \fImust\fR agree on the argument types.
Send the message \fImsg\fR on channel \fIchannel\fR with data \fIdata\fR. The message will be distributed to all clients subscribed to the channel.
.PP
Note that QDataStream provides a convenient way to fill the byte array with auxiliary data.
.PP
Example:
.PP
.nf
.br
QByteArray ba;
.br
QDataStream stream( ba, IO_WriteOnly );
.br
stream << QString("cat") << QString("file.txt");
.br
QCopChannel::send( "System/Shell", "execute(QString,QString)", ba );
.br
.fi
Here the channel is "System/Shell". The \fImsg\fR 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 \fImust\fR agree on the argument types.