1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
'\" 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 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.
.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 Qt documentation is provided in HTML format; it is
located at $QTDIR/doc/html and can be read using Qt 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 (qcopchannel.3qt) and the Qt
version (3.3.8).
|