You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
171 lines
6.5 KiB
171 lines
6.5 KiB
'\" t
|
|
.TH QCopChannel 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
|
|
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
|
|
.\" license file included in the distribution for a complete license
|
|
.\" statement.
|
|
.\"
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
QCopChannel \- Communication capabilities between several clients
|
|
.SH SYNOPSIS
|
|
\fC#include <qcopchannel_qws.h>\fR
|
|
.PP
|
|
Inherits QObject.
|
|
.PP
|
|
.SS "Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "\fBQCopChannel\fR ( const QCString & channel, QObject * parent = 0, const char * name = 0 )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual \fB~QCopChannel\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "QCString \fBchannel\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBreceive\fR ( const QCString & msg, const QByteArray & data )"
|
|
.br
|
|
.in -1c
|
|
.SS "Signals"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "void \fBreceived\fR ( const QCString & msg, const QByteArray & data )"
|
|
.br
|
|
.in -1c
|
|
.SS "Static Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "bool \fBisRegistered\fR ( const QCString & channel )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBsend\fR ( const QCString & channel, const QCString & msg )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBsend\fR ( const QCString & channel, const QCString & msg, const QByteArray & data )"
|
|
.br
|
|
.in -1c
|
|
.SH DESCRIPTION
|
|
The QCopChannel class provides communication capabilities between several clients.
|
|
.PP
|
|
The TQt 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.
|
|
.SH MEMBER FUNCTION DOCUMENTATION
|
|
.SH "QCopChannel::QCopChannel ( const QCString & channel, QObject * parent = 0, const char * name = 0 )"
|
|
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.
|
|
.SH "QCopChannel::~QCopChannel ()\fC [virtual]\fR"
|
|
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.
|
|
.SH "QCString QCopChannel::channel () const"
|
|
Returns the name of the channel.
|
|
.SH "bool QCopChannel::isRegistered ( const QCString & channel )\fC [static]\fR"
|
|
Queries the server for the existence of \fIchannel\fR.
|
|
.PP
|
|
Returns TRUE if \fIchannel\fR is registered; otherwise returns FALSE.
|
|
.SH "void QCopChannel::receive ( const QCString & msg, const QByteArray & data )\fC [virtual]\fR"
|
|
This virtual function allows subclasses of QCopChannel to process data received from their channel.
|
|
.PP
|
|
The default implementation emits the received() signal.
|
|
.PP
|
|
Note that the format of \fIdata\fR has to be well defined in order to extract the information it contains.
|
|
.PP
|
|
Example:
|
|
.PP
|
|
.nf
|
|
.br
|
|
void MyClass::receive( const QCString &msg, const QByteArray &data )
|
|
.br
|
|
{
|
|
.br
|
|
QDataStream stream( data, IO_ReadOnly );
|
|
.br
|
|
if ( msg == "execute(QString,QString)" ) {
|
|
.br
|
|
QString cmd, arg;
|
|
.br
|
|
stream >> cmd >> arg;
|
|
.br
|
|
...
|
|
.br
|
|
} else if ( msg == "delete(QString)" ) {
|
|
.br
|
|
QString filenname;
|
|
.br
|
|
stream >> filename;
|
|
.br
|
|
...
|
|
.br
|
|
} else ...
|
|
.br
|
|
}
|
|
.br
|
|
.fi
|
|
This example assumes that the \fImsg\fR is a DCOP-style function signature and the \fIdata\fR contains the function's arguments. (See send().)
|
|
.PP
|
|
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.
|
|
.PP
|
|
See also send().
|
|
.SH "void QCopChannel::received ( const QCString & msg, const QByteArray & data )\fC [signal]\fR"
|
|
This signal is emitted with the \fImsg\fR and \fIdata\fR whenever the receive() function gets incoming data.
|
|
.SH "bool QCopChannel::send ( const QCString & channel, const QCString & msg, const QByteArray & data )\fC [static]\fR"
|
|
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 "&".
|
|
.PP
|
|
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.
|
|
.PP
|
|
See also receive().
|
|
.SH "bool QCopChannel::send ( const QCString & channel, const QCString & msg )\fC [static]\fR"
|
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
|
.PP
|
|
Send the message \fImsg\fR on channel \fIchannel\fR. The message will be distributed to all clients subscribed to the \fIchannel\fR.
|
|
.PP
|
|
See also receive().
|
|
|
|
.SH "SEE ALSO"
|
|
.BR http://doc.trolltech.com/qcopchannel.html
|
|
.BR http://www.trolltech.com/faq/tech.html
|
|
.SH COPYRIGHT
|
|
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
|
|
license file included in the distribution for a complete license
|
|
statement.
|
|
.SH AUTHOR
|
|
Generated automatically from the source code.
|
|
.SH BUGS
|
|
If you find a bug in Qt, please report it as described in
|
|
.BR http://doc.trolltech.com/bughowto.html .
|
|
Good bug reports help us to help you. Thank you.
|
|
.P
|
|
The definitive TQt documentation is provided in HTML format; it is
|
|
located at $QTDIR/doc/html and can be read using TQt Assistant or with
|
|
a web browser. This man page is provided as a convenience for those
|
|
users who prefer man pages, although this format is not officially
|
|
supported by Trolltech.
|
|
.P
|
|
If you find errors in this manual page, please report them to
|
|
.BR qt-bugs@trolltech.com .
|
|
Please include the name of the manual page (tqcopchannel.3qt) and the Qt
|
|
version (3.3.8).
|