source: trunk/doc/html/qcopchannel.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 9.3 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qcopchannel_qws.cpp:55 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QCopChannel Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<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>
33
34<p>The QCopChannel class provides communication capabilities
35between several clients.
36<a href="#details">More...</a>
37<p><tt>#include &lt;<a href="qcopchannel_qws-h.html">qcopchannel_qws.h</a>&gt;</tt>
38<p>Inherits <a href="qobject.html">QObject</a>.
39<p><a href="qcopchannel-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn><a href="#QCopChannel"><b>QCopChannel</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;channel, QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn>virtual <a href="#~QCopChannel"><b>~QCopChannel</b></a> ()</li>
44<li class=fn>QCString <a href="#channel"><b>channel</b></a> () const</li>
45<li class=fn>virtual void <a href="#receive"><b>receive</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;msg, const&nbsp;QByteArray&nbsp;&amp;&nbsp;data )</li>
46</ul>
47<h2>Signals</h2>
48<ul>
49<li class=fn>void <a href="#received"><b>received</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;msg, const&nbsp;QByteArray&nbsp;&amp;&nbsp;data )</li>
50</ul>
51<h2>Static Public Members</h2>
52<ul>
53<li class=fn>bool <a href="#isRegistered"><b>isRegistered</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;channel )</li>
54<li class=fn>bool <a href="#send-2"><b>send</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;channel, const&nbsp;QCString&nbsp;&amp;&nbsp;msg )</li>
55<li class=fn>bool <a href="#send"><b>send</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;channel, const&nbsp;QCString&nbsp;&amp;&nbsp;msg, const&nbsp;QByteArray&nbsp;&amp;&nbsp;data )</li>
56</ul>
57<hr><a name="details"></a><h2>Detailed Description</h2>
58
59
60<p> The QCopChannel class provides communication capabilities
61between several clients.
62<p> The Qt Cop (QCOP) is a COmmunication Protocol, allowing clients to
63communicate both within the same address space and between
64different processes.
65<p> Currently, this facility is only available on Qt/Embedded. On X11
66and Windows we are exploring the use of existing standards such as
67DCOP and COM.
68<p> QCopChannel provides <a href="#send">send</a>() and <a href="#isRegistered">isRegistered</a>() which are static
69functions usable without an object.
70<p> The <a href="#channel">channel</a>() function returns the name of the channel.
71<p> In order to <em>listen</em> to the traffic on a channel, you should
72either subclass QCopChannel and reimplement <a href="#receive">receive</a>(), or
73<a href="qobject.html#connect">connect</a>() to the <a href="#received">received</a>() signal.
74
75<hr><h2>Member Function Documentation</h2>
76<h3 class=fn><a name="QCopChannel"></a>QCopChannel::QCopChannel ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;channel, <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
77</h3>
78Constructs a QCop channel and registers it with the server using
79the name <em>channel</em>. The standard <em>parent</em> and <em>name</em> arguments
80are passed on to the <a href="qobject.html">QObject</a> constructor.
81
82<h3 class=fn><a name="~QCopChannel"></a>QCopChannel::~QCopChannel ()<tt> [virtual]</tt>
83</h3>
84Destroys the client's end of the channel and notifies the server
85that the client has closed its connection. The server will keep
86the channel open until the last registered client detaches.
87
88<h3 class=fn><a href="qcstring.html">QCString</a> <a name="channel"></a>QCopChannel::channel () const
89</h3>
90Returns the name of the channel.
91
92<h3 class=fn>bool <a name="isRegistered"></a>QCopChannel::isRegistered ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;channel )<tt> [static]</tt>
93</h3>
94Queries the server for the existence of <em>channel</em>.
95<p> Returns TRUE if <em>channel</em> is registered; otherwise returns FALSE.
96
97<h3 class=fn>void <a name="receive"></a>QCopChannel::receive ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;msg, const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;data )<tt> [virtual]</tt>
98</h3>
99This virtual function allows subclasses of QCopChannel to process
100data received from their channel.
101<p> The default implementation emits the <a href="#received">received</a>() signal.
102<p> Note that the format of <em>data</em> has to be well defined in order to
103extract the information it contains.
104<p> Example:
105<pre>
106 void MyClass::receive( const <a href="qcstring.html">QCString</a> &amp;msg, const <a href="qbytearray.html">QByteArray</a> &amp;data )
107 {
108 <a href="qdatastream.html">QDataStream</a> stream( data, <a href="qfile.html#open">IO_ReadOnly</a> );
109 if ( msg == "execute(QString,QString)" ) {
110 <a href="qstring.html">QString</a> cmd, arg;
111 stream &gt;&gt; cmd &gt;&gt; arg;
112 ...
113 } else if ( msg == "delete(QString)" ) {
114 <a href="qstring.html">QString</a> filenname;
115 stream &gt;&gt; filename;
116 ...
117 } else ...
118 }
119 </pre>
120
121This example assumes that the <em>msg</em> is a DCOP-style function
122signature and the <em>data</em> contains the function's arguments. (See
123<a href="#send">send</a>().)
124<p> Using the DCOP convention is a recommendation, but not a
125requirement. Whatever convention you use the sender and receiver
126<em>must</em> agree on the argument types.
127<p> <p>See also <a href="#send">send</a>().
128
129<h3 class=fn>void <a name="received"></a>QCopChannel::received ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;msg, const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;data )<tt> [signal]</tt>
130</h3>
131
132<p> This signal is emitted with the <em>msg</em> and <em>data</em> whenever the
133<a href="#receive">receive</a>() function gets incoming data.
134
135<h3 class=fn>bool <a name="send"></a>QCopChannel::send ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;channel, const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;msg, const&nbsp;<a href="qbytearray.html">QByteArray</a>&nbsp;&amp;&nbsp;data )<tt> [static]</tt>
136</h3>
137Send the message <em>msg</em> on channel <em>channel</em> with data <em>data</em>.
138The message will be distributed to all clients subscribed to the
139channel.
140<p> Note that <a href="qdatastream.html">QDataStream</a> provides a convenient way to fill the byte
141array with auxiliary data.
142<p> Example:
143<pre>
144 <a href="qbytearray.html">QByteArray</a> ba;
145 <a href="qdatastream.html">QDataStream</a> stream( ba, <a href="qfile.html#open">IO_WriteOnly</a> );
146 stream &lt;&lt; QString("cat") &lt;&lt; QString("file.txt");
147 QCopChannel::<a href="#send">send</a>( "System/Shell", "execute(QString,QString)", ba );
148 </pre>
149
150Here the channel is "System/Shell". The <em>msg</em> is an arbitrary
151string, but in the example we've used the DCOP convention of
152passing a function signature. Such a signature is formatted as
153functionname(types) where types is a list of zero or more
154comma-separated type names, with no whitespace, no consts and no
155pointer or reference marks, i.e. no "*" or "&".
156<p> Using the DCOP convention is a recommendation, but not a
157requirement. Whatever convention you use the sender and receiver
158<em>must</em> agree on the argument types.
159<p> <p>See also <a href="#receive">receive</a>().
160
161<h3 class=fn>bool <a name="send-2"></a>QCopChannel::send ( const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;channel, const&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;msg )<tt> [static]</tt>
162</h3>
163This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
164<p> Send the message <em>msg</em> on channel <em>channel</em>. The message will be
165distributed to all clients subscribed to the <em>channel</em>.
166<p> <p>See also <a href="#receive">receive</a>().
167
168<!-- eof -->
169<hr><p>
170This file is part of the <a href="index.html">Qt toolkit</a>.
171Copyright &copy; 1995-2007
172<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
173<table width=100% cellspacing=0 border=0><tr>
174<td>Copyright &copy; 2007
175<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
176<td align=right><div align=right>Qt 3.3.8</div>
177</table></div></address></body>
178</html>
Note: See TracBrowser for help on using the repository browser.