[190] | 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"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { 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 Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main 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 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
|
---|
| 35 | between several clients.
|
---|
| 36 | <a href="#details">More...</a>
|
---|
| 37 | <p><tt>#include <<a href="qcopchannel_qws-h.html">qcopchannel_qws.h</a>></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 QCString & channel, QObject * parent = 0, const char * 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 QCString & msg, const QByteArray & data )</li>
|
---|
| 46 | </ul>
|
---|
| 47 | <h2>Signals</h2>
|
---|
| 48 | <ul>
|
---|
| 49 | <li class=fn>void <a href="#received"><b>received</b></a> ( const QCString & msg, const QByteArray & 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 QCString & channel )</li>
|
---|
| 54 | <li class=fn>bool <a href="#send-2"><b>send</b></a> ( const QCString & channel, const QCString & msg )</li>
|
---|
| 55 | <li class=fn>bool <a href="#send"><b>send</b></a> ( const QCString & channel, const QCString & msg, const QByteArray & data )</li>
|
---|
| 56 | </ul>
|
---|
| 57 | <hr><a name="details"></a><h2>Detailed Description</h2>
|
---|
| 58 |
|
---|
| 59 |
|
---|
| 60 | <p> The QCopChannel class provides communication capabilities
|
---|
| 61 | between several clients.
|
---|
| 62 | <p> The Qt Cop (QCOP) is a COmmunication Protocol, allowing clients to
|
---|
| 63 | communicate both within the same address space and between
|
---|
| 64 | different processes.
|
---|
| 65 | <p> Currently, this facility is only available on Qt/Embedded. On X11
|
---|
| 66 | and Windows we are exploring the use of existing standards such as
|
---|
| 67 | DCOP and COM.
|
---|
| 68 | <p> QCopChannel provides <a href="#send">send</a>() and <a href="#isRegistered">isRegistered</a>() which are static
|
---|
| 69 | functions 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
|
---|
| 72 | either 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 <a href="qcstring.html">QCString</a> & channel, <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 )
|
---|
| 77 | </h3>
|
---|
| 78 | Constructs a QCop channel and registers it with the server using
|
---|
| 79 | the name <em>channel</em>. The standard <em>parent</em> and <em>name</em> arguments
|
---|
| 80 | are 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>
|
---|
| 84 | Destroys the client's end of the channel and notifies the server
|
---|
| 85 | that the client has closed its connection. The server will keep
|
---|
| 86 | the 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>
|
---|
| 90 | Returns the name of the channel.
|
---|
| 91 |
|
---|
| 92 | <h3 class=fn>bool <a name="isRegistered"></a>QCopChannel::isRegistered ( const <a href="qcstring.html">QCString</a> & channel )<tt> [static]</tt>
|
---|
| 93 | </h3>
|
---|
| 94 | Queries 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 <a href="qcstring.html">QCString</a> & msg, const <a href="qbytearray.html">QByteArray</a> & data )<tt> [virtual]</tt>
|
---|
| 98 | </h3>
|
---|
| 99 | This virtual function allows subclasses of QCopChannel to process
|
---|
| 100 | data 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
|
---|
| 103 | extract the information it contains.
|
---|
| 104 | <p> Example:
|
---|
| 105 | <pre>
|
---|
| 106 | void MyClass::receive( const <a href="qcstring.html">QCString</a> &msg, const <a href="qbytearray.html">QByteArray</a> &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 >> cmd >> arg;
|
---|
| 112 | ...
|
---|
| 113 | } else if ( msg == "delete(QString)" ) {
|
---|
| 114 | <a href="qstring.html">QString</a> filenname;
|
---|
| 115 | stream >> filename;
|
---|
| 116 | ...
|
---|
| 117 | } else ...
|
---|
| 118 | }
|
---|
| 119 | </pre>
|
---|
| 120 |
|
---|
| 121 | This example assumes that the <em>msg</em> is a DCOP-style function
|
---|
| 122 | signature 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
|
---|
| 125 | requirement. 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 <a href="qcstring.html">QCString</a> & msg, const <a href="qbytearray.html">QByteArray</a> & 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 <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>
|
---|
| 136 | </h3>
|
---|
| 137 | Send the message <em>msg</em> on channel <em>channel</em> with data <em>data</em>.
|
---|
| 138 | The message will be distributed to all clients subscribed to the
|
---|
| 139 | channel.
|
---|
| 140 | <p> Note that <a href="qdatastream.html">QDataStream</a> provides a convenient way to fill the byte
|
---|
| 141 | array 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 << QString("cat") << QString("file.txt");
|
---|
| 147 | QCopChannel::<a href="#send">send</a>( "System/Shell", "execute(QString,QString)", ba );
|
---|
| 148 | </pre>
|
---|
| 149 |
|
---|
| 150 | Here the channel is "System/Shell". The <em>msg</em> is an arbitrary
|
---|
| 151 | string, but in the example we've used the DCOP convention of
|
---|
| 152 | passing a function signature. Such a signature is formatted as
|
---|
| 153 | functionname(types) where types is a list of zero or more
|
---|
| 154 | comma-separated type names, with no whitespace, no consts and no
|
---|
| 155 | pointer or reference marks, i.e. no "*" or "&".
|
---|
| 156 | <p> Using the DCOP convention is a recommendation, but not a
|
---|
| 157 | requirement. 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 <a href="qcstring.html">QCString</a> & channel, const <a href="qcstring.html">QCString</a> & msg )<tt> [static]</tt>
|
---|
| 162 | </h3>
|
---|
| 163 | This 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
|
---|
| 165 | distributed 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>
|
---|
| 170 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 171 | Copyright © 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 © 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>
|
---|