1
|
1 /****************************************************************************
|
|
2 **
|
39
|
3 ** Copyright (C) 1992-2009 Nokia. All rights reserved.
|
1
|
4 **
|
|
5 ** This file is part of Qt Jambi.
|
|
6 **
|
39
|
7 ** Commercial Usage
|
|
8 Licensees holding valid Qt Commercial licenses may use this file in
|
|
9 accordance with the Qt Commercial License Agreement provided with the
|
|
10 Software or, alternatively, in accordance with the terms contained in
|
|
11 a written agreement between you and Nokia.
|
|
12
|
|
13 GNU Lesser General Public License Usage
|
|
14 Alternatively, this file may be used under the terms of the GNU Lesser
|
|
15 General Public License version 2.1 as published by the Free Software
|
|
16 Foundation and appearing in the file LICENSE.LGPL included in the
|
|
17 packaging of this file. Please review the following information to
|
|
18 ensure the GNU Lesser General Public License version 2.1 requirements
|
|
19 will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
20
|
|
21 In addition, as a special exception, Nokia gives you certain
|
|
22 additional rights. These rights are described in the Nokia Qt LGPL
|
|
23 Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
|
|
24 package.
|
|
25
|
|
26 GNU General Public License Usage
|
|
27 Alternatively, this file may be used under the terms of the GNU
|
|
28 General Public License version 3.0 as published by the Free Software
|
|
29 Foundation and appearing in the file LICENSE.GPL included in the
|
|
30 packaging of this file. Please review the following information to
|
|
31 ensure the GNU General Public License version 3.0 requirements will be
|
|
32 met: http://www.gnu.org/copyleft/gpl.html.
|
|
33
|
|
34 If you are unsure which license is appropriate for your use, please
|
|
35 contact the sales department at qt-sales@nokia.com.
|
1
|
36
|
|
37 **
|
|
38 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
39 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
40 **
|
|
41 ****************************************************************************/
|
|
42
|
|
43 package generator;
|
|
44
|
39
|
45 import com.trolltech.qt.*;
|
|
46 import com.trolltech.qt.network.*;
|
1
|
47
|
|
48 class QHostInfo___ extends QHostInfo {
|
|
49 /**
|
|
50 * Looks up the IP address(es) associated with host name <code>name</code>,
|
|
51 * and returns an ID for the lookup. When the result of the lookup is ready,
|
|
52 * the specified method in <code>receiver</code> is called with a
|
|
53 * <code>QHostInfo</code> argument. The <code>QHostInfo</code> object can
|
|
54 * then be inspected to get the results of the lookup.
|
|
55 *
|
|
56 * @param name The host name.
|
|
57 * @param receiver The object on which the method will be called.
|
|
58 * @param methodName The name of a method which takes a single <code>QHostInfo</code> argument.
|
|
59 */
|
39
|
60 public static int lookupHost(String name, com.trolltech.qt.core.QObject receiver, String methodName)
|
1
|
61 {
|
39
|
62 methodName = com.trolltech.qt.internal.QtJambiInternal.SlotPrefix + methodName + "(QHostInfo)";
|
|
63 return lookupHost(name, receiver, com.trolltech.qt.QNativePointer.createCharPointer(methodName));
|
1
|
64 }
|
|
65
|
|
66 /**
|
|
67 * Looks up the IP address(es) associated with host name <code>name</code>,
|
|
68 * and returns an ID for the lookup. When the result of the lookup is ready,
|
|
69 * the specified signal is emitted with a <code>QHostInfo</code> argument.
|
|
70 * The <code>QHostInfo</code> object can then be inspected to get the results
|
|
71 * of the lookup.
|
|
72 *
|
|
73 * @param name The host name.
|
|
74 * @param signal The signal to emit. Must take a single <code>QHostInfo</code>
|
|
75 * argument, and must be contained in a <code>QObject</code>
|
|
76 * subclass.
|
|
77 */
|
39
|
78 public static int lookupHost(String name, com.trolltech.qt.QSignalEmitter.Signal1<QHostInfo> signal)
|
1
|
79 {
|
39
|
80 if (!(signal.containingObject() instanceof com.trolltech.qt.core.QObject)) {
|
1
|
81 throw new IllegalArgumentException("Only signals contained in QObject subclasses are supported. "
|
|
82 + "Signal's class is '" + signal.containingObject().getClass() + "'.");
|
|
83 }
|
|
84
|
39
|
85 String methodName = com.trolltech.qt.internal.QtJambiInternal.SignalPrefix + signal.name() + "(QHostInfo)";
|
|
86 return lookupHost(name, (com.trolltech.qt.core.QObject)signal.containingObject(),
|
|
87 com.trolltech.qt.QNativePointer.createCharPointer(methodName));
|
1
|
88 }
|
|
89 }// class
|
|
90
|
|
91 class QAbstractSocket___ extends QAbstractSocket {
|
|
92
|
|
93 public Signal2<QNetworkProxy, QAuthenticator> proxyAuthenticationRequired = new Signal2<QNetworkProxy, QAuthenticator>();
|
|
94 private boolean inEmission = false;
|
|
95
|
|
96 private void emitProxyAuthenticationRequiredPrivate(QNetworkProxy proxy, QAuthenticator authenticator) {
|
|
97 if (!inEmission) {
|
|
98 inEmission = true;
|
|
99 proxyAuthenticationRequiredPrivate.emit(proxy, authenticator.nativePointer());
|
|
100 inEmission = false;
|
|
101 }
|
|
102 }
|
|
103
|
|
104 private void emitProxyAuthenticationRequired(QNetworkProxy proxy, QNativePointer authenticator) {
|
|
105 if (!inEmission) {
|
|
106 inEmission = true;
|
|
107 proxyAuthenticationRequired.emit(proxy, QAuthenticator.fromNativePointer(authenticator));
|
|
108 inEmission = false;
|
|
109 }
|
|
110 }
|
|
111
|
39
|
112 public final void connectToHost(String host, int port, com.trolltech.qt.core.QIODevice.OpenMode mode) {
|
1
|
113 connectToHost(host, (char) port, mode);
|
|
114 }
|
|
115
|
39
|
116 public final void connectToHost(String host, int port, com.trolltech.qt.core.QIODevice.OpenModeFlag ... mode) {
|
1
|
117 connectToHost(host, (char) port, mode);
|
|
118 }
|
|
119
|
|
120 public final void connectToHost(String host, int port) {
|
|
121 connectToHost(host, (char) port);
|
|
122 }
|
|
123
|
39
|
124 public final void connectToHost(QHostAddress host, int port, com.trolltech.qt.core.QIODevice.OpenMode mode) {
|
1
|
125 connectToHost(host, (char) port, mode);
|
|
126 }
|
|
127
|
39
|
128 public final void connectToHost(QHostAddress host, int port, com.trolltech.qt.core.QIODevice.OpenModeFlag ... mode) {
|
1
|
129 connectToHost(host, (char) port, mode);
|
|
130 }
|
|
131
|
|
132 public final void connectToHost(QHostAddress host, int port)
|
|
133 {
|
|
134 connectToHost(host, (char) port);
|
|
135 }
|
|
136
|
39
|
137 protected void connectToHostImplementation(String host, int port, com.trolltech.qt.core.QIODevice.OpenMode mode) {
|
1
|
138 connectToHostImplementation(host, (char) port, mode);
|
|
139 }
|
|
140
|
39
|
141 protected void connectToHostImplementation(String host, int port, com.trolltech.qt.core.QIODevice.OpenModeFlag ... mode) {
|
1
|
142 connectToHostImplementation(host, (char) port, mode);
|
|
143 }
|
|
144
|
|
145 protected void connectToHostImplementation(String host, int port) {
|
|
146 connectToHostImplementation(host, (char) port);
|
|
147 }
|
|
148
|
|
149 public final int localPort()
|
|
150 {
|
|
151 return localPort_private();
|
|
152 }
|
|
153
|
|
154 public final int peerPort() {
|
|
155 return peerPort_private();
|
|
156 }
|
|
157
|
|
158 protected final void setLocalPort(int port) {
|
|
159 setLocalPort((char) port);
|
|
160 }
|
|
161
|
|
162 protected final void setPeerPort(int port) {
|
|
163 setPeerPort((char) port);
|
|
164 }
|
|
165
|
|
166 }// class
|
|
167
|
|
168 class QSslSocket___ extends QSslSocket {
|
|
169
|
39
|
170 protected void connectToHostImplementation(String host, int port, com.trolltech.qt.core.QIODevice.OpenMode mode) {
|
1
|
171 connectToHostImplementation(host, (char) port, mode);
|
|
172 }
|
|
173
|
39
|
174 protected void connectToHostImplementation(String host, int port, com.trolltech.qt.core.QIODevice.OpenModeFlag ... mode) {
|
1
|
175 connectToHostImplementation(host, (char) port, mode);
|
|
176 }
|
|
177
|
|
178 protected void connectToHostImplementation(String host, int port) {
|
|
179 connectToHostImplementation(host, (char) port);
|
|
180 }
|
|
181 }// class
|
|
182
|
|
183 class QHttp___ extends QHttp {
|
|
184
|
|
185 public Signal2<QNetworkProxy, QAuthenticator> proxyAuthenticationRequired = new Signal2<QNetworkProxy, QAuthenticator>();
|
|
186 private boolean inEmission = false;
|
|
187
|
|
188 private void emitProxyAuthenticationRequiredPrivate(QNetworkProxy proxy, QAuthenticator authenticator) {
|
|
189 if (!inEmission) {
|
|
190 inEmission = true;
|
|
191 proxyAuthenticationRequiredPrivate.emit(proxy, authenticator.nativePointer());
|
|
192 inEmission = false;
|
|
193 }
|
|
194 }
|
|
195
|
|
196 private void emitProxyAuthenticationRequired(QNetworkProxy proxy, QNativePointer authenticator) {
|
|
197 if (!inEmission) {
|
|
198 inEmission = true;
|
|
199 proxyAuthenticationRequired.emit(proxy, QAuthenticator.fromNativePointer(authenticator));
|
|
200 inEmission = false;
|
|
201 }
|
|
202 }
|
|
203
|
|
204 public Signal3<String, Integer, QAuthenticator> authenticationRequired = new Signal3<String, Integer, QAuthenticator>();
|
|
205 private boolean inEmissionAuthenticationRequired = false;
|
|
206
|
|
207 private void emitAuthenticationRequiredPrivate(String hostName, int port, QAuthenticator authenticator) {
|
|
208 if (!inEmissionAuthenticationRequired) {
|
|
209 inEmissionAuthenticationRequired = true;
|
|
210 authenticationRequiredPrivate.emit(hostName, (char) port, authenticator.nativePointer());
|
|
211 inEmissionAuthenticationRequired = false;
|
|
212 }
|
|
213 }
|
|
214
|
|
215 private void emitAuthenticationRequired(String hostName, char port, QNativePointer authenticator) {
|
|
216 if (!inEmissionAuthenticationRequired) {
|
|
217 inEmissionAuthenticationRequired = true;
|
|
218 authenticationRequired.emit(hostName, (int) port, QAuthenticator.fromNativePointer(authenticator));
|
|
219 inEmissionAuthenticationRequired = false;
|
|
220 }
|
|
221 }
|
|
222
|
|
223 public QHttp(String hostname) {
|
|
224 this(hostname, (char) 80);
|
|
225 }
|
|
226
|
|
227 public QHttp(String hostname, int port) {
|
|
228 this(hostname, (char) port);
|
|
229 }
|
|
230
|
39
|
231 public QHttp(String hostname, int port, com.trolltech.qt.core.QObject parent) {
|
1
|
232 this(hostname, (char) port, parent);
|
|
233 }
|
|
234
|
39
|
235 public QHttp(java.lang.String hostname, com.trolltech.qt.network.QHttp.ConnectionMode mode) {
|
1
|
236 this(hostname, mode, '\0');
|
|
237 }
|
|
238
|
|
239 public QHttp(String hostname, QHttp.ConnectionMode mode, int port) {
|
|
240 this(hostname, mode, (char) port);
|
|
241 }
|
|
242
|
39
|
243 public QHttp(String hostname, QHttp.ConnectionMode mode, int port, com.trolltech.qt.core.QObject parent) {
|
1
|
244 this(hostname, mode, (char) port, parent);
|
|
245 }
|
|
246
|
|
247 public final int setHost(String hostName, QHttp.ConnectionMode mode) {
|
|
248 return setHost(hostName, mode, '\0');
|
|
249 }
|
|
250
|
|
251 public final int setHost(String hostname, QHttp.ConnectionMode mode, int port) {
|
|
252 return setHost(hostname, mode, (char) port);
|
|
253 }
|
|
254
|
|
255 public final int setHost(String hostname) {
|
|
256 return setHost(hostname, (char) 80);
|
|
257 }
|
|
258
|
|
259 public final int setHost(String hostname, int port) {
|
|
260 return setHost(hostname, (char) port);
|
|
261 }
|
|
262
|
|
263 }// class
|
|
264
|
|
265 class QTcpServer___ extends QTcpServer {
|
|
266
|
|
267 public final boolean listen(QHostAddress address, int port) {
|
|
268 return listen(address, (char) port);
|
|
269 }
|
|
270
|
|
271 public final boolean listen(QHostAddress address) {
|
|
272 return listen(address, '\0');
|
|
273 }
|
|
274
|
|
275 public final boolean listen() {
|
39
|
276 return listen(new com.trolltech.qt.network.QHostAddress(com.trolltech.qt.network.QHostAddress.SpecialAddress.Any));
|
1
|
277 }
|
|
278
|
|
279 public final int serverPort() {
|
|
280 return serverPort_private();
|
|
281 }
|
|
282
|
|
283 public enum Result {
|
|
284 Success, Failure, TimedOut
|
|
285 }
|
|
286
|
|
287 public final Result waitForNewConnection(int msec) {
|
|
288 QNativePointer np = new QNativePointer(QNativePointer.Type.Boolean);
|
|
289 boolean success = waitForNewConnection(msec, np);
|
|
290
|
|
291 return (np.booleanValue() ? Result.TimedOut : (success ? Result.Success : Result.Failure));
|
|
292 }
|
|
293
|
|
294 public final Result waitForNewConnection() {
|
|
295 return waitForNewConnection(0);
|
|
296 }
|
|
297
|
|
298 }// class
|
|
299
|
|
300 class QUdpSocket___ extends QUdpSocket {
|
|
301
|
|
302 public final boolean bind(QHostAddress address, int port) {
|
|
303 return bind_private(address, (char) port);
|
|
304 }
|
|
305
|
|
306 public final boolean bind() {
|
|
307 return bind_private();
|
|
308 }
|
|
309
|
|
310 public final boolean bind(int port) {
|
|
311 return bind_private((char) port);
|
|
312 }
|
|
313
|
|
314 public final boolean bind(QHostAddress address, int port, BindFlag ... mode) {
|
|
315 return bind_private(address, (char) port, mode);
|
|
316 }
|
|
317
|
|
318 public final boolean bind(QHostAddress address, int port, BindMode mode) {
|
|
319 return bind_private(address, (char) port, mode);
|
|
320 }
|
|
321
|
|
322 public final boolean bind(int port, BindFlag ... mode) {
|
|
323 return bind_private((char) port, mode);
|
|
324 }
|
|
325
|
|
326 public final boolean bind(int port, BindMode mode) {
|
|
327 return bind_private((char) port, mode);
|
|
328 }
|
|
329
|
|
330 public static class HostInfo {
|
|
331 public HostInfo() {
|
|
332 address = new QHostAddress();
|
|
333 port = 0;
|
|
334 }
|
|
335
|
|
336 public QHostAddress address;
|
|
337 public int port;
|
|
338 }
|
|
339
|
|
340 public final int readDatagram(byte data[], HostInfo info) {
|
|
341 QNativePointer np = new QNativePointer(QNativePointer.Type.Byte, data.length);
|
|
342 QNativePointer address = info != null && info.address != null ? info.address.nativePointer() : null;
|
|
343 QNativePointer port = new QNativePointer(QNativePointer.Type.Char);
|
|
344
|
|
345 int len = (int) readDatagram(np, data.length, address, port);
|
|
346 if (info != null)
|
|
347 info.port = port.charValue();
|
|
348 for (int i = 0; i < len; ++i)
|
|
349 data[i] = np.byteAt(i);
|
|
350
|
|
351 return len;
|
|
352 }
|
|
353
|
|
354 public final int readDatagram(byte data[]) {
|
|
355 return readDatagram(data, null);
|
|
356 }
|
|
357
|
|
358 public final int writeDatagram(byte data[], QHostAddress address, int port) {
|
39
|
359 QNativePointer np = com.trolltech.qt.internal.QtJambiInternal.byteArrayToNativePointer(data);
|
1
|
360 return (int) writeDatagram(np, data.length, address, (char) port);
|
|
361 }
|
|
362
|
39
|
363 public final int writeDatagram(com.trolltech.qt.core.QByteArray data, QHostAddress address, int port) {
|
1
|
364 return (int) writeDatagram(data, address, (char) port);
|
|
365 }
|
|
366
|
|
367 }// class
|
|
368
|
|
369 class QNetworkProxy___ extends QNetworkProxy {
|
|
370
|
|
371 public QNetworkProxy(QNetworkProxy.ProxyType type) {
|
|
372 this(type, null, '\0');
|
|
373 }
|
|
374
|
|
375 public QNetworkProxy(QNetworkProxy.ProxyType type, String host) {
|
|
376 this(type, host, '\0');
|
|
377 }
|
|
378
|
|
379 public QNetworkProxy(QNetworkProxy.ProxyType type, String host, int port) {
|
|
380 this(type, host, (char) port);
|
|
381 }
|
|
382
|
|
383 public QNetworkProxy(QNetworkProxy.ProxyType type, String host, int port, String username) {
|
|
384 this(type, host, (char) port, username);
|
|
385 }
|
|
386
|
|
387 public QNetworkProxy(QNetworkProxy.ProxyType type, String host, int port, String username, String password) {
|
|
388 this(type, host, (char) port, username, password);
|
|
389 }
|
|
390
|
|
391 public final void setPort(int port) {
|
|
392 setPort((char) port);
|
|
393 }
|
|
394
|
|
395 public final int port() {
|
|
396 return port_private();
|
|
397 }
|
|
398
|
|
399 }// class
|
|
400
|
|
401 class QNetworkAccessManager___ extends QNetworkAccessManager {
|
|
402 public Signal2<QNetworkProxy, QAuthenticator> proxyAuthenticationRequired = new Signal2<QNetworkProxy, QAuthenticator>();
|
|
403 private boolean inEmission = false;
|
|
404
|
|
405 private void emitProxyAuthenticationRequiredPrivate(QNetworkProxy proxy, QAuthenticator authenticator)
|
|
406 {
|
|
407 if (!inEmission)
|
|
408 {
|
|
409 inEmission = true;
|
|
410 proxyAuthenticationRequiredPrivate.emit(proxy, authenticator.nativePointer());
|
|
411 inEmission = false;
|
|
412 }
|
|
413 }
|
|
414
|
|
415 private void emitProxyAuthenticationRequired(QNetworkProxy proxy, QNativePointer authenticator)
|
|
416 {
|
|
417 if (!inEmission)
|
|
418 {
|
|
419 inEmission = true;
|
|
420 proxyAuthenticationRequired.emit(proxy, QAuthenticator.fromNativePointer(authenticator));
|
|
421 inEmission = false;
|
|
422 }
|
|
423 }
|
|
424
|
|
425 public Signal2<QNetworkReply, QAuthenticator> authenticationRequired = new Signal2<QNetworkReply, QAuthenticator>();
|
|
426 private boolean inEmissionAuthenticationRequired = false;
|
|
427
|
|
428 private void emitAuthenticationRequiredPrivate(QNetworkReply reply, QAuthenticator authenticator)
|
|
429 {
|
|
430 if (!inEmissionAuthenticationRequired)
|
|
431 {
|
|
432 inEmissionAuthenticationRequired = true;
|
|
433 authenticationRequiredPrivate.emit(reply, authenticator.nativePointer());
|
|
434 inEmissionAuthenticationRequired = false;
|
|
435 }
|
|
436 }
|
|
437
|
|
438 private void emitAuthenticationRequired(QNetworkReply reply, QNativePointer authenticator)
|
|
439 {
|
|
440 if (!inEmissionAuthenticationRequired)
|
|
441 {
|
|
442 inEmissionAuthenticationRequired = true;
|
|
443 authenticationRequired.emit(reply, QAuthenticator.fromNativePointer(authenticator));
|
|
444 inEmissionAuthenticationRequired = false;
|
|
445 }
|
|
446 }
|
|
447
|
|
448 }// class
|
|
449
|
|
450 class QLocalServer___ extends QLocalServer {
|
|
451
|
|
452 public enum Result {
|
|
453 Success, Failure, TimedOut
|
|
454 }
|
|
455
|
|
456 public final Result waitForNewConnection(int msec) {
|
|
457 QNativePointer np = new QNativePointer(QNativePointer.Type.Boolean);
|
|
458 boolean success = waitForNewConnection(msec, np);
|
|
459
|
|
460 return (np.booleanValue() ? Result.TimedOut : (success ? Result.Success : Result.Failure));
|
|
461 }
|
|
462
|
|
463 public final Result waitForNewConnection() {
|
|
464 return waitForNewConnection(0);
|
|
465 }
|
|
466
|
|
467 }// class
|