1QCopChannel(3qt) QCopChannel(3qt)
2
3
4
6 QCopChannel - Communication capabilities between several clients
7
9 #include <qcopchannel_qws.h>
10
11 Inherits QObject.
12
13 Public Members
14 QCopChannel ( const QCString & channel, QObject * parent = 0, const
15 char * name = 0 )
16 virtual ~QCopChannel ()
17 QCString channel () const
18 virtual void receive ( const QCString & msg, const QByteArray & data )
19
20 Signals
21 void received ( const QCString & msg, const QByteArray & data )
22
23 Static Public Members
24 bool isRegistered ( const QCString & channel )
25 bool send ( const QCString & channel, const QCString & msg )
26 bool send ( const QCString & channel, const QCString & msg, const
27 QByteArray & data )
28
30 The QCopChannel class provides communication capabilities between
31 several clients.
32
33 The Qt Cop (QCOP) is a COmmunication Protocol, allowing clients to
34 communicate both within the same address space and between different
35 processes.
36
37 Currently, this facility is only available on Qt/Embedded. On X11 and
38 Windows we are exploring the use of existing standards such as DCOP and
39 COM.
40
41 QCopChannel provides send() and isRegistered() which are static
42 functions usable without an object.
43
44 The channel() function returns the name of the channel.
45
46 In order to listen to the traffic on a channel, you should either
47 subclass QCopChannel and reimplement receive(), or connect() to the
48 received() signal.
49
52 const char * name = 0 )
53 Constructs a QCop channel and registers it with the server using the
54 name channel. The standard parent and name arguments are passed on to
55 the QObject constructor.
56
58 Destroys the client's end of the channel and notifies the server that
59 the client has closed its connection. The server will keep the channel
60 open until the last registered client detaches.
61
63 Returns the name of the channel.
64
66 Queries the server for the existence of channel.
67
68 Returns TRUE if channel is registered; otherwise returns FALSE.
69
71 [virtual]
72 This virtual function allows subclasses of QCopChannel to process data
73 received from their channel.
74
75 The default implementation emits the received() signal.
76
77 Note that the format of data has to be well defined in order to extract
78 the information it contains.
79
80 Example:
81
82 void MyClass::receive( const QCString &msg, const QByteArray &data )
83 {
84 QDataStream stream( data, IO_ReadOnly );
85 if ( msg == "execute(QString,QString)" ) {
86 QString cmd, arg;
87 stream >> cmd >> arg;
88 ...
89 } else if ( msg == "delete(QString)" ) {
90 QString filenname;
91 stream >> filename;
92 ...
93 } else ...
94 }
95 This example assumes that the msg is a DCOP-style function signature
96 and the data contains the function's arguments. (See send().)
97
98 Using the DCOP convention is a recommendation, but not a requirement.
99 Whatever convention you use the sender and receiver must agree on the
100 argument types.
101
102 See also send().
103
105 [signal]
106 This signal is emitted with the msg and data whenever the receive()
107 function gets incoming data.
108
110 QByteArray & data ) [static]
111 Send the message msg on channel channel with data data. The message
112 will be distributed to all clients subscribed to the channel.
113
114 Note that QDataStream provides a convenient way to fill the byte array
115 with auxiliary data.
116
117 Example:
118
119 QByteArray ba;
120 QDataStream stream( ba, IO_WriteOnly );
121 stream << QString("cat") << QString("file.txt");
122 QCopChannel::send( "System/Shell", "execute(QString,QString)", ba );
123 Here the channel is "System/Shell". The msg is an arbitrary string, but
124 in the example we've used the DCOP convention of passing a function
125 signature. Such a signature is formatted as functionname(types) where
126 types is a list of zero or more comma-separated type names, with no
127 whitespace, no consts and no pointer or reference marks, i.e. no "*" or
128 "&".
129
130 Using the DCOP convention is a recommendation, but not a requirement.
131 Whatever convention you use the sender and receiver must agree on the
132 argument types.
133
134 See also receive().
135
137 [static]
138 This is an overloaded member function, provided for convenience. It
139 behaves essentially like the above function.
140
141 Send the message msg on channel channel. The message will be
142 distributed to all clients subscribed to the channel.
143
144 See also receive().
145
146
148 http://doc.trolltech.com/qcopchannel.html
149 http://www.trolltech.com/faq/tech.html
150
152 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
153 license file included in the distribution for a complete license
154 statement.
155
157 Generated automatically from the source code.
158
160 If you find a bug in Qt, please report it as described in
161 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
162 help you. Thank you.
163
164 The definitive Qt documentation is provided in HTML format; it is
165 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
166 web browser. This man page is provided as a convenience for those users
167 who prefer man pages, although this format is not officially supported
168 by Trolltech.
169
170 If you find errors in this manual page, please report them to qt-
171 bugs@trolltech.com. Please include the name of the manual page
172 (qcopchannel.3qt) and the Qt version (3.3.8).
173
174
175
176Trolltech AS 2 February 2007 QCopChannel(3qt)