summaryrefslogtreecommitdiffstats
path: root/doc/html/qcopchannel.html
blob: 44b9b660233419cfb4c8eb4b5cc9e35043afcf6e (plain)
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>TQCopChannel 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>TQCopChannel Class Reference</h1>

<p>The TQCopChannel 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">TQObject</a>.
<p><a href="qcopchannel-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQCopChannel"><b>TQCopChannel</b></a> ( const&nbsp;TQCString&nbsp;&amp;&nbsp;channel, TQObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn>virtual <a href="#~TQCopChannel"><b>~TQCopChannel</b></a> ()</li>
<li class=fn>TQCString <a href="#channel"><b>channel</b></a> () const</li>
<li class=fn>virtual void <a href="#receive"><b>receive</b></a> ( const&nbsp;TQCString&nbsp;&amp;&nbsp;msg, const&nbsp;TQByteArray&nbsp;&amp;&nbsp;data )</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#received"><b>received</b></a> ( const&nbsp;TQCString&nbsp;&amp;&nbsp;msg, const&nbsp;TQByteArray&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;TQCString&nbsp;&amp;&nbsp;channel )</li>
<li class=fn>bool <a href="#send-2"><b>send</b></a> ( const&nbsp;TQCString&nbsp;&amp;&nbsp;channel, const&nbsp;TQCString&nbsp;&amp;&nbsp;msg )</li>
<li class=fn>bool <a href="#send"><b>send</b></a> ( const&nbsp;TQCString&nbsp;&amp;&nbsp;channel, const&nbsp;TQCString&nbsp;&amp;&nbsp;msg, const&nbsp;TQByteArray&nbsp;&amp;&nbsp;data )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


<p> The TQCopChannel class provides communication capabilities
between several clients.
<p> The TQt Cop (TQCOP) 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 TQt/Embedded. On X11
and Windows we are exploring the use of existing standards such as
DCOP and COM.
<p> TQCopChannel 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 TQCopChannel 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="TQCopChannel"></a>TQCopChannel::TQCopChannel ( const&nbsp;<a href="qcstring.html">TQCString</a>&nbsp;&amp;&nbsp;channel, <a href="qobject.html">TQObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs a TQCop 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">TQObject</a> constructor.

<h3 class=fn><a name="~TQCopChannel"></a>TQCopChannel::~TQCopChannel ()<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">TQCString</a> <a name="channel"></a>TQCopChannel::channel () const
</h3>
Returns the name of the channel.

<h3 class=fn>bool <a name="isRegistered"></a>TQCopChannel::isRegistered ( const&nbsp;<a href="qcstring.html">TQCString</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>TQCopChannel::receive ( const&nbsp;<a href="qcstring.html">TQCString</a>&nbsp;&amp;&nbsp;msg, const&nbsp;<a href="qbytearray.html">TQByteArray</a>&nbsp;&amp;&nbsp;data )<tt> [virtual]</tt>
</h3>
This virtual function allows subclasses of TQCopChannel 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">TQCString</a> &amp;msg, const <a href="qbytearray.html">TQByteArray</a> &amp;data )
    {
        <a href="qdatastream.html">TQDataStream</a> stream( data, <a href="qfile.html#open">IO_ReadOnly</a> );
        if ( msg == "execute(TQString,TQString)" ) {
            <a href="qstring.html">TQString</a> cmd, arg;
            stream &gt;&gt; cmd &gt;&gt; arg;
            ...
        } else if ( msg == "delete(TQString)" ) {
            <a href="qstring.html">TQString</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
retquirement. 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>TQCopChannel::received ( const&nbsp;<a href="qcstring.html">TQCString</a>&nbsp;&amp;&nbsp;msg, const&nbsp;<a href="qbytearray.html">TQByteArray</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>TQCopChannel::send ( const&nbsp;<a href="qcstring.html">TQCString</a>&nbsp;&amp;&nbsp;channel, const&nbsp;<a href="qcstring.html">TQCString</a>&nbsp;&amp;&nbsp;msg, const&nbsp;<a href="qbytearray.html">TQByteArray</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">TQDataStream</a> provides a convenient way to fill the byte
array with auxiliary data.
<p> Example:
<pre>
    <a href="qbytearray.html">TQByteArray</a> ba;
    <a href="qdatastream.html">TQDataStream</a> stream( ba, <a href="qfile.html#open">IO_WriteOnly</a> );
    stream &lt;&lt; TQString("cat") &lt;&lt; TQString("file.txt");
    TQCopChannel::<a href="#send">send</a>( "System/Shell", "execute(TQString,TQString)", 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
retquirement. 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>TQCopChannel::send ( const&nbsp;<a href="qcstring.html">TQCString</a>&nbsp;&amp;&nbsp;channel, const&nbsp;<a href="qcstring.html">TQCString</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">TQt 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>TQt 3.3.8</div>
</table></div></address></body>
</html>