~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qcopchannel.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/embedded/qcopchannel_qws.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QCopChannel Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QCopChannel Class Reference</h1>
 
21
<p>The QCopChannel class provides communication capabilities between several clients. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QCopChannel&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p>Inherits <a href="qobject.html">QObject</a>.</p>
 
24
<ul>
 
25
<li><a href="qcopchannel-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qcopchannel-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="public-functions"></a>
 
29
<h3>Public Functions</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="qcopchannel.html#QCopChannel">QCopChannel</a></b> ( const QString &amp; <i>channel</i>, QObject * <i>parent</i> = 0 )</li>
 
32
<li><div class="fn"/>virtual <b><a href="qcopchannel.html#dtor.QCopChannel">~QCopChannel</a></b> ()</li>
 
33
<li><div class="fn"/>QString <b><a href="qcopchannel.html#channel">channel</a></b> () const</li>
 
34
<li><div class="fn"/>virtual void <b><a href="qcopchannel.html#receive">receive</a></b> ( const QString &amp; <i>msg</i>, const QByteArray &amp; <i>data</i> )</li>
 
35
</ul>
 
36
<ul>
 
37
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
38
</ul>
 
39
<a name="signals"></a>
 
40
<h3>Signals</h3>
 
41
<ul>
 
42
<li><div class="fn"/>void <b><a href="qcopchannel.html#received">received</a></b> ( const QString &amp; <i>msg</i>, const QByteArray &amp; <i>data</i> )</li>
 
43
</ul>
 
44
<ul>
 
45
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
46
</ul>
 
47
<a name="static-public-members"></a>
 
48
<h3>Static Public Members</h3>
 
49
<ul>
 
50
<li><div class="fn"/>bool <b><a href="qcopchannel.html#isRegistered">isRegistered</a></b> ( const QString &amp; <i>channel</i> )</li>
 
51
<li><div class="fn"/>bool <b><a href="qcopchannel.html#send">send</a></b> ( const QString &amp; <i>channel</i>, const QString &amp; <i>msg</i>, const QByteArray &amp; <i>data</i> )</li>
 
52
<li><div class="fn"/>bool <b><a href="qcopchannel.html#send-2">send</a></b> ( const QString &amp; <i>channel</i>, const QString &amp; <i>msg</i> )</li>
 
53
</ul>
 
54
<ul>
 
55
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
56
</ul>
 
57
<h3>Additional Inherited Members</h3>
 
58
<ul>
 
59
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
60
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
61
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
62
</ul>
 
63
<a name="details"></a>
 
64
<hr />
 
65
<h2>Detailed Description</h2>
 
66
<p>The QCopChannel class provides communication capabilities between several clients.</p>
 
67
<p>The Qt Cop (QCOP) is a COmmunication Protocol, allowing clients to communicate both within the same address space and between different processes.</p>
 
68
<p>Currently, this facility is only available on Qt/Embedded. On <a href="winsystem.html#x11">X11</a> and Windows we are exploring the use of existing standards such as DCOP and COM.</p>
 
69
<p>QCopChannel provides <a href="qcopchannel.html#send">send</a>() and <a href="qcopchannel.html#isRegistered">isRegistered</a>() which are static functions usable without an object.</p>
 
70
<p>The <a href="qcopchannel.html#channel">channel</a>() function returns the name of the channel.</p>
 
71
<p>In order to <i>listen</i> to the traffic on a channel, you should either subclass QCopChannel and reimplement <a href="qcopchannel.html#receive">receive</a>(), or <a href="qobject.html#connect">connect</a>() to the <a href="qcopchannel.html#received">received</a>() signal.</p>
 
72
<hr />
 
73
<h2>Member Function Documentation</h2>
 
74
<h3 class="fn"><a name="QCopChannel"></a>QCopChannel::QCopChannel ( const <a href="qstring.html">QString</a> &amp; <i>channel</i>, <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
 
75
<p>Constructs a QCop channel and registers it with the server using the name <i>channel</i>. The standard <i>parent</i> argument is passed on to the <a href="qobject.html">QObject</a> constructor.</p>
 
76
<h3 class="fn"><a name="dtor.QCopChannel"></a>QCopChannel::~QCopChannel ()&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
77
<p>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.</p>
 
78
<h3 class="fn"><a name="channel"></a><a href="qstring.html">QString</a> QCopChannel::channel () const</h3>
 
79
<p>Returns the name of the channel.</p>
 
80
<h3 class="fn"><a name="isRegistered"></a>bool QCopChannel::isRegistered ( const <a href="qstring.html">QString</a> &amp; <i>channel</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
81
<p>Queries the server for the existence of <i>channel</i>.</p>
 
82
<p>Returns true if <i>channel</i> is registered; otherwise returns false.</p>
 
83
<h3 class="fn"><a name="receive"></a>void QCopChannel::receive ( const <a href="qstring.html">QString</a> &amp; <i>msg</i>, const <a href="qbytearray.html">QByteArray</a> &amp; <i>data</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
84
<p>This virtual function allows subclasses of <a href="qcopchannel.html">QCopChannel</a> to process data received from their channel.</p>
 
85
<p>The default implementation emits the <a href="qcopchannel.html#received">received</a>() signal.</p>
 
86
<p>Note that the format of <i>data</i> has to be well defined in order to extract the information it contains.</p>
 
87
<p>Example:</p>
 
88
<pre>&nbsp;   void MyClass::receive(const QString &amp;msg, const QByteArray &amp;data)
 
89
    {
 
90
        QDataStream in(data);
 
91
        if (msg == &quot;execute(QString,QString)&quot;) {
 
92
            QString cmd;
 
93
            QString arg;
 
94
            in &gt;&gt; cmd &gt;&gt; arg;
 
95
            ...
 
96
        } else if (msg == &quot;delete(QString)&quot;) {
 
97
            QString fileName;
 
98
            in &gt;&gt; fileName;
 
99
            ...
 
100
        } else {
 
101
            ...
 
102
        }
 
103
    }</pre>
 
104
<p>This example assumes that the <i>msg</i> is a DCOP-style function signature and the <i>data</i> contains the function's arguments. (See <a href="qcopchannel.html#send">send</a>().)</p>
 
105
<p>Using the DCOP convention is a recommendation, but not a requirement. Whatever convention you use the sender and receiver <i>must</i> agree on the argument types.</p>
 
106
<p>See also <a href="qcopchannel.html#send">send</a>().</p>
 
107
<h3 class="fn"><a name="received"></a>void QCopChannel::received ( const <a href="qstring.html">QString</a> &amp; <i>msg</i>, const <a href="qbytearray.html">QByteArray</a> &amp; <i>data</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
108
<p>This signal is emitted with the <i>msg</i> and <i>data</i> whenever the <a href="qcopchannel.html#receive">receive</a>() function gets incoming data.</p>
 
109
<h3 class="fn"><a name="send"></a>bool QCopChannel::send ( const <a href="qstring.html">QString</a> &amp; <i>channel</i>, const <a href="qstring.html">QString</a> &amp; <i>msg</i>, const <a href="qbytearray.html">QByteArray</a> &amp; <i>data</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
110
<p>Send the message <i>msg</i> on channel <i>channel</i> with data <i>data</i>. The message will be distributed to all clients subscribed to the channel.</p>
 
111
<p>Note that <a href="qdatastream.html">QDataStream</a> provides a convenient way to fill the byte array with auxiliary data.</p>
 
112
<p>Example:</p>
 
113
<pre>&nbsp;   QByteArray data;
 
114
    QDataStream out(&amp;data, QIODevice::WriteOnly);
 
115
    out &lt;&lt; QString(&quot;cat&quot;) &lt;&lt; QString(&quot;file.txt&quot;);
 
116
    QCopChannel::send(&quot;System/Shell&quot;, &quot;execute(QString,QString)&quot;,
 
117
                      data);</pre>
 
118
<p>Here the channel is &quot;System/Shell&quot;. The <i>msg</i> 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 &quot;functionname(types)&quot; 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 &quot;*&quot; or &quot;&amp;&quot;.</p>
 
119
<p>Using the DCOP convention is a recommendation, but not a requirement. Whatever convention you use the sender and receiver <i>must</i> agree on the argument types.</p>
 
120
<p>See also <a href="qcopchannel.html#receive">receive</a>().</p>
 
121
<h3 class="fn"><a name="send-2"></a>bool QCopChannel::send ( const <a href="qstring.html">QString</a> &amp; <i>channel</i>, const <a href="qstring.html">QString</a> &amp; <i>msg</i> )&nbsp;&nbsp;<tt> [static]</tt></h3>
 
122
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
123
<p>Send the message <i>msg</i> on channel <i>channel</i>. The message will be distributed to all clients subscribed to the <i>channel</i>.</p>
 
124
<p>See also <a href="qcopchannel.html#receive">receive</a>().</p>
 
125
<p /><address><hr /><div align="center">
 
126
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
127
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
128
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
129
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
130
</tr></table></div></address></body>
 
131
</html>