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
171
172
173
174
175
176
177
178
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qcopchannel_qws.cpp:55 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QCopChannel Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
<a href="index.html">
<font color="#004faf">Home</font></a>
| <a href="classes.html">
<font color="#004faf">All Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped Classes</font></a>
| <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QCopChannel Class Reference</h1>
<p>The QCopChannel class provides communication capabilities
between several clients.
<a href="#details">More...</a>
<p><tt>#include <<a href="qcopchannel_qws-h.html">qcopchannel_qws.h</a>></tt>
<p>Inherits <a href="qobject.html">QObject</a>.
<p><a href="qcopchannel-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QCopChannel"><b>QCopChannel</b></a> ( const QCString & channel, QObject * parent = 0, const char * name = 0 )</li>
<li class=fn>virtual <a href="#~QCopChannel"><b>~QCopChannel</b></a> ()</li>
<li class=fn>QCString <a href="#channel"><b>channel</b></a> () const</li>
<li class=fn>virtual void <a href="#receive"><b>receive</b></a> ( const QCString & msg, const QByteArray & data )</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#received"><b>received</b></a> ( const QCString & msg, const QByteArray & data )</li>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>bool <a href="#isRegistered"><b>isRegistered</b></a> ( const QCString & channel )</li>
<li class=fn>bool <a href="#send-2"><b>send</b></a> ( const QCString & channel, const QCString & msg )</li>
<li class=fn>bool <a href="#send"><b>send</b></a> ( const QCString & channel, const QCString & msg, const QByteArray & data )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
<p> The QCopChannel class provides communication capabilities
between several clients.
<p> The Qt Cop (QCOP) is a COmmunication Protocol, allowing clients to
communicate both within the same address space and between
different processes.
<p> 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.
<p> QCopChannel provides <a href="#send">send</a>() and <a href="#isRegistered">isRegistered</a>() which are static
functions usable without an object.
<p> The <a href="#channel">channel</a>() function returns the name of the channel.
<p> In order to <em>listen</em> to the traffic on a channel, you should
either subclass QCopChannel and reimplement <a href="#receive">receive</a>(), or
<a href="qobject.html#connect">connect</a>() to the <a href="#received">received</a>() signal.
<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QCopChannel"></a>QCopChannel::QCopChannel ( const <a href="qcstring.html">QCString</a> & channel, <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 )
</h3>
Constructs a QCop channel and registers it with the server using
the name <em>channel</em>. The standard <em>parent</em> and <em>name</em> arguments
are passed on to the <a href="qobject.html">QObject</a> constructor.
<h3 class=fn><a name="~QCopChannel"></a>QCopChannel::~QCopChannel ()<tt> [virtual]</tt>
</h3>
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.
<h3 class=fn><a href="qcstring.html">QCString</a> <a name="channel"></a>QCopChannel::channel () const
</h3>
Returns the name of the channel.
<h3 class=fn>bool <a name="isRegistered"></a>QCopChannel::isRegistered ( const <a href="qcstring.html">QCString</a> & channel )<tt> [static]</tt>
</h3>
Queries the server for the existence of <em>channel</em>.
<p> Returns TRUE if <em>channel</em> is registered; otherwise returns FALSE.
<h3 class=fn>void <a name="receive"></a>QCopChannel::receive ( const <a href="qcstring.html">QCString</a> & msg, const <a href="qbytearray.html">QByteArray</a> & data )<tt> [virtual]</tt>
</h3>
This virtual function allows subclasses of QCopChannel to process
data received from their channel.
<p> The default implementation emits the <a href="#received">received</a>() signal.
<p> Note that the format of <em>data</em> has to be well defined in order to
extract the information it contains.
<p> Example:
<pre>
void MyClass::receive( const <a href="qcstring.html">QCString</a> &msg, const <a href="qbytearray.html">QByteArray</a> &data )
{
<a href="qdatastream.html">QDataStream</a> stream( data, <a href="qfile.html#open">IO_ReadOnly</a> );
if ( msg == "execute(QString,QString)" ) {
<a href="qstring.html">QString</a> cmd, arg;
stream >> cmd >> arg;
...
} else if ( msg == "delete(QString)" ) {
<a href="qstring.html">QString</a> filenname;
stream >> filename;
...
} else ...
}
</pre>
This example assumes that the <em>msg</em> is a DCOP-style function
signature and the <em>data</em> contains the function's arguments. (See
<a href="#send">send</a>().)
<p> Using the DCOP convention is a recommendation, but not a
requirement. Whatever convention you use the sender and receiver
<em>must</em> agree on the argument types.
<p> <p>See also <a href="#send">send</a>().
<h3 class=fn>void <a name="received"></a>QCopChannel::received ( const <a href="qcstring.html">QCString</a> & msg, const <a href="qbytearray.html">QByteArray</a> & data )<tt> [signal]</tt>
</h3>
<p> This signal is emitted with the <em>msg</em> and <em>data</em> whenever the
<a href="#receive">receive</a>() function gets incoming data.
<h3 class=fn>bool <a name="send"></a>QCopChannel::send ( const <a href="qcstring.html">QCString</a> & channel, const <a href="qcstring.html">QCString</a> & msg, const <a href="qbytearray.html">QByteArray</a> & data )<tt> [static]</tt>
</h3>
Send the message <em>msg</em> on channel <em>channel</em> with data <em>data</em>.
The message will be distributed to all clients subscribed to the
channel.
<p> Note that <a href="qdatastream.html">QDataStream</a> provides a convenient way to fill the byte
array with auxiliary data.
<p> Example:
<pre>
<a href="qbytearray.html">QByteArray</a> ba;
<a href="qdatastream.html">QDataStream</a> stream( ba, <a href="qfile.html#open">IO_WriteOnly</a> );
stream << QString("cat") << QString("file.txt");
QCopChannel::<a href="#send">send</a>( "System/Shell", "execute(QString,QString)", ba );
</pre>
Here the channel is "System/Shell". The <em>msg</em> 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 "&".
<p> Using the DCOP convention is a recommendation, but not a
requirement. Whatever convention you use the sender and receiver
<em>must</em> agree on the argument types.
<p> <p>See also <a href="#receive">receive</a>().
<h3 class=fn>bool <a name="send-2"></a>QCopChannel::send ( const <a href="qcstring.html">QCString</a> & channel, const <a href="qcstring.html">QCString</a> & msg )<tt> [static]</tt>
</h3>
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
<p> Send the message <em>msg</em> on channel <em>channel</em>. The message will be
distributed to all clients subscribed to the <em>channel</em>.
<p> <p>See also <a href="#receive">receive</a>().
<!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright © 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright © 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>
|