summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/org/kde/koala/KProtocolManager.java
blob: 5bd0f8975e7cef74295e66e9b1c93b888821466b (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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
//Auto-generated by kalyptus. DO NOT EDIT.
package org.kde.koala;

import org.kde.qt.Qt;
import org.kde.qt.QtSupport;

/**

 Provides information about I/O (Internet, etc.) settings chosen/set
 by the end user.
 KProtocolManager has a heap of static functions that allows only read
 access to KDE's IO related settings. These include proxy, cache, file
 transfer resumption, timeout and user-agent related settings.
 The information provided by this class is generic enough to be applicable
 to any application that makes use of KDE's IO sub-system.  Note that this
 mean the proxy, timeout etc. settings are saved in a separate user-specific
 config file and not in the config file of the application.
 Original author:
 Revised by:
		@author Dawit Alemayehu <adawit@kde.org>

		@short    Provides information about I/O (Internet, etc.
		@see KPAC

*/
public class KProtocolManager implements QtSupport {
	private long _qt;
	private boolean _allocatedInJavaWorld = true;
	protected KProtocolManager(Class dummy){}

	/**	
		 Types of proxy configuration
		
			<li>
			NoProxy     - No proxy is used
			</li>
			
			<li>
			ManualProxy - Proxies are manually configured
			</li>
			
			<li>
			PACProxy    - A Proxy configuration URL has been given
			</li>
			
			<li>
			WPADProxy   - A proxy should be automatically discovered
			</li>
			
			<li>
			EnvVarProxy - Use the proxy values set through environment variables.
			   
			</li>		@short    Types of proxy configuration
	*/
	public static final int NoProxy = 0;
	public static final int ManualProxy = 1;
	public static final int PACProxy = 2;
	public static final int WPADProxy = 3;
	public static final int EnvVarProxy = 4;

	/**	
		 Proxy authorization modes.
		
			<li>
			Prompt     - Ask for authorization as needed
			</li>
			
			<li>
			Automatic  - Use auto login as defined in .tdeionetrc files.
			</li>
				 NOTE: .tdeionetrc files have the same format as ftp .netrc files.
		 Please note the use of .tdeionetrc files is highly discouraged since
		 password is stored in clear text. For future releases the ability
		 to store preset password for proxy servers will probably be supported
		 through TDEWallet integration.
		   		@short    Proxy authorization modes.
	*/
	public static final int Prompt = 0;
	public static final int Automatic = 1;

	public KProtocolManager() {
		newKProtocolManager();
	}
	private native void newKProtocolManager();
	/**	
		 Returns the default user-agent string.
				@return the default user-agent string
   
		@short    Returns the default user-agent string.
	*/
	public static native String defaultUserAgent();
	/**	
		 Returns the default user-agent value.
			@param keys can be any of the following:
		
			<li>
			'o'	Show OS
			</li>
			
			<li>
			'v'	Show OS Version
			</li>
			
			<li>
			'p'	Show platform
			</li>
			
			<li>
			'm'	Show machine architecture
			</li>
			
			<li>
			'l'	Show language
			</li>
					@return the default user-agent value with the given <code>keys</code>
   
		@short    Returns the default user-agent value.
	*/
	public static native String defaultUserAgent(String keys);
	/**	
		 Returns the userAgent string configured for the
		 specified host.
			 If hostname is not found or is empty (i.e. "" or
		 null) this function will return the default
		 user agent.
			@param hostname name of the host
				@return specified userAgent string
   
		@short    Returns the userAgent string configured for the  specified host.
	*/
	public static native String userAgentForHost(String hostname);
	/**	
		 Returns the preferred timeout value for reading from
		 remote connections in seconds.
				@return timeout value for remote connection in secs.
   
		@short    Returns the preferred timeout value for reading from  remote connections in seconds.
	*/
	public static native int readTimeout();
	/**	
		 Returns the preferred timeout value for remote connections
		 in seconds.
				@return timeout value for remote connection in secs.
   
		@short    Returns the preferred timeout value for remote connections  in seconds.
	*/
	public static native int connectTimeout();
	/**	
		 Returns the preferred timeout value for proxy connections
		 in seconds.
				@return timeout value for proxy connection in secs.
   
		@short    Returns the preferred timeout value for proxy connections  in seconds.
	*/
	public static native int proxyConnectTimeout();
	/**	
		 Returns the preferred response timeout value for
		 remote connecting in seconds.
				@return timeout value for remote connection in seconds.
   
		@short    Returns the preferred response timeout value for  remote connecting in seconds.
	*/
	public static native int responseTimeout();
	/**	
		 Returns true if the user specified a proxy server to make connections.
				@short    Returns true if the user specified a proxy server to make connections.
		@see #slaveProtocol
		@see #proxyForURL
		@see #proxyFor
	*/
	public static native boolean useProxy();
	/**	
		 Returns true if the proxy settings should apply to the list
		 returned by {@link #noProxyFor}.
			 Normally addresses listed in the noProxyFor list are not routed
		 through a proxy server. However, if this function returns true,
		 then all addresses listed in the noProxyFor list are to be routed
		 through a proxy server where as those that are not should bypass it.
			 This function as well as {@link #noProxyFor} only apply when {@link #proxyType}
		 is <code>ManualProxy.</code>
				@short    Returns true if the proxy settings should apply to the list  returned by @ref noProxyFor.
		@see #proxyForURL
		@see #proxyFor
		@see #slaveProtocol
	*/
	public static native boolean useReverseProxy();
	/**	
		 Returns the type of proxy configuration that is used.
				@short    Returns the type of proxy configuration that is used.
		@see ProxyType
	*/
	public static native int proxyType();
	/**	
		 Returns the way proxy authorization should be handled.
				@short    Returns the way proxy authorization should be handled.
		@see ProxyAuthMode
	*/
	public static native int proxyAuthMode();
	/**	
		 Returns a comma-separated list of hostnames or partial
		 host-names that should bypass any proxy settings.
			 This function as well as {@link #useReverseProxy} only apply
		 when {@link #proxyType} is <code>ManualProxy.</code>
				@short    Returns a comma-separated list of hostnames or partial  host-names that should bypass any proxy settings.
		@see #useReverseProxy
		@see #proxyFor
		@see #proxyForURL
		@see #slaveProtocol
	*/
	public static native String noProxyFor();
	/**	
		 Returns the proxy server address for a given protocol.
			 NOTE: This function does not take the {@link #useReverseProxy}
		 settings into account.
			@param protocol the protocol whose proxy info is needed
				@return the proxy server address if one is available,
          or null if not available
   
		@short    Returns the proxy server address for a given protocol.
		@see #useReverseProxy
		@see #slaveProtocol
	*/
	public static native String proxyFor(String protocol);
	/**	
		 Returns the proxy server address for a given URL.
			 If {@link #proxyType} returns Automatic, an external service
		 called KPAC (a kded module) is used to determine the proxy
		 server. Otherwise, {@link #proxyFor} is invoked to determine
		 whether the URL needs to be routed through a proxy server.
			 NOTE: This function does not take the {@link #useReverseProxy}
		 or the {@link #noProxyFor} settings into account.
			@param url the URL whose proxy info is needed
				@return the proxy server address or the text "DIRECT"
          if no proxying is needed for the given address.
   
		@short    Returns the proxy server address for a given URL.
		@see #useReverseProxy
		@see #slaveProtocol
		@see #noProxyFor
	*/
	public static native String proxyForURL(KURL url);
	/**	
		 Marks this proxy as bad (down). It will not be used for the
		 next 30 minutes. (The script may supply an alternate proxy)
			@param proxy the proxy to mark as bad (as URL)
		   		@short    Marks this proxy as bad (down).
	*/
	public static native void badProxy(String proxy);
	/**	
		 Returns the URL of the script for automatic proxy configuration.
				@return the proxy configuration script
   
		@short    Returns the URL of the script for automatic proxy configuration.
	*/
	public static native String proxyConfigScript();
	/**	
		 Returns true/false to indicate whether a cache
		 should be used
				@return true to use the cache, false otherwisea
   
		@short    Returns true/false to indicate whether a cache  should be used
	*/
	public static native boolean useCache();
	/**	
		 Returns the maximum age in seconds cached files should be
		 kept before they are deleted as necessary.
				@return the maximum cache age in seconds
   
		@short    Returns the maximum age in seconds cached files should be  kept before they are deleted as necessary.
	*/
	public static native int maxCacheAge();
	/**	
		 Returns the maximum size that can be used for caching.
			 By default this function returns the DEFAULT_MAX_CACHE_SIZE
		 value as defined in http_slave_defaults.h.  Not that the
		 value returned is in bytes, hence a value of 5120 would mean
		 5 Kb.
				@return the maximum cache size in bytes
   
		@short    Returns the maximum size that can be used for caching.
	*/
	public static native int maxCacheSize();
	/**	
		 The directory which contains the cache files.
				@return the directory that contains the cache files
   
		@short    The directory which contains the cache files.
	*/
	public static native String cacheDir();
	/**	
		 Returns the Cache control directive to be used.
				@return the cache control value
   
		@short    Returns the Cache control directive to be used.
	*/
	public static native int cacheControl();
	/**	
		 Returns true if partial downloads should be
		 automatically resumed.
				@return true to resume partial downloads
   
		@short    Returns true if partial downloads should be  automatically resumed.
	*/
	public static native boolean autoResume();
	/**	
		 Returns true if partial downloads should be marked
		 with a ".part" extension.
				@return true if partial downloads should get an ".part" extension
   
		@short    Returns true if partial downloads should be marked  with a ".
	*/
	public static native boolean markPartial();
	/**	
		 Returns the minimum file size for keeping aborted
		 downloads.
			 Any data downloaded that does not meet this minimum
		 requirement will simply be discarded. The default size
		 is 5 KB.
				@return the minimum keep size for aborted downloads in bytes
   
		@short    Returns the minimum file size for keeping aborted  downloads.
	*/
	public static native int minimumKeepSize();
	/**	
		 Returns true if proxy connections should be persistent.
				@return true if proxy connections should be persistent

		@short    Returns true if proxy connections should be persistent.
	*/
	public static native boolean persistentProxyConnection();
	/**	
		 Returns true if connections should be persistent
				@return true if the connections should be persistent
   
		@short    Returns true if connections should be persistent
	*/
	public static native boolean persistentConnections();
	/**	
		 Force a reload of the general config file of
		 io-slaves ( tdeioslaverc).
		   		@short    Force a reload of the general config file of  io-slaves ( tdeioslaverc).
	*/
	public static native void reparseConfiguration();
	/**	
		 Return the protocol to use in order to handle the given <code>url</code>
		 It's usually the same, except that FTP, when handled by a proxy,
		 needs an HTTP ioslave.
			 When a proxy is to be used, proxy contains the URL for the proxy.
			@param url the url to check
			@param proxy the URL of the proxy to use
				@return the slave protocol (e.g. 'http'), can be null if unknown
   
		@short    Return the protocol to use in order to handle the given <code>url</code>  It's usually the same, except that FTP, when handled by a proxy,  needs an HTTP ioslave.
	*/
	public static native String slaveProtocol(KURL url, StringBuffer proxy);
	/**	
			 (Shared with SlaveConfig)
		   		@short
	*/
	public static native TDEConfig config();
	/** Deletes the wrapped C++ instance */
	protected native void finalize() throws InternalError;
	/** Delete the wrapped C++ instance ahead of finalize() */
	public native void dispose();
	/** Has the wrapped C++ instance been deleted? */
	public native boolean isDisposed();
}