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.
qt3/doc/html/qcopchannel.html

179 lines
9.2 KiB

<!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&nbsp;Classes</font></a>
| <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
| <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
| <a href="groups.html">
<font color="#004faf">Grouped&nbsp;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 &lt;<a href="qcopchannel_qws-h.html">qcopchannel_qws.h</a>&gt;</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&nbsp;QCString&nbsp;&amp;&nbsp;channel, QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;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&nbsp;QCString&nbsp;&amp;&nbsp;msg, const&nbsp;QByteArray&nbsp;&amp;&nbsp;data )</li>
</ul>
<h2>Signals</h2>
<ul>
<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>
</ul>
<h2>Static Public Members</h2>
<ul>
<li class=fn>bool <a href="#isRegistered"><b>isRegistered</b></a> ( const&nbsp;QCString&nbsp;&amp;&nbsp;channel )</li>
<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>
<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>
</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&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 )
</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&nbsp;<a href="qcstring.html">QCString</a>&nbsp;&amp;&nbsp;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&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>
</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> &amp;msg, const <a href="qbytearray.html">QByteArray</a> &amp;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 &gt;&gt; cmd &gt;&gt; arg;
...
} else if ( msg == "delete(QString)" ) {
<a href="qstring.html">QString</a> filenname;
stream &gt;&gt; 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&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>
</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&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>
</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 &lt;&lt; QString("cat") &lt;&lt; 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&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>
</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 &copy; 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 &copy; 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>