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