summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/org/kde/koala/KURIFilterData.java
blob: 4563fbb4e54ddc1c1c6697b65e8c8740cc3096c9 (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
//Auto-generated by kalyptus. DO NOT EDIT.
package org.kde.koala;

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

/**

 A basic message object used for exchanging filtering
 information between the filter plugins and the application
 requesting the filtering service.
 Use this object if you retquire a more detailed information
 about the URI you want to filter. Any application can create
 an instance of this class and send it to KURIFilter to
 have the plugins fill out all possible information about the
 URI.
 <b></b>xample
 <pre>
   String text = "kde.org";
   KURIFilterData d = text;
   boolean filtered = KURIFilter.self().filter( d );
   cout << "URL: " << text.latin1() << endl
        << "Filtered URL: " << d.uri().url().latin1() << endl
        << "URI Type: " << d.uriType() << endl
        << "Was Filtered: " << filtered << endl;
 </pre>
 The above code should yield the following output:
 <pre>
   URI: kde.org
   Filtered URI: http://kde.org
   URI Type: 0            <== means NET_PROTOCOL
   Was Filtered: 1        <== means the URL was successfully filtered
 </pre>
		@author Dawit Alemayehu <adawit at kde.org>

		@short A message object for exchanging filtering URI info.

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

	/**	
		 Describes the type of the URI that was filtered.
		 Here is a brief description of the types:
		
			<li>
			NET_PROTOCOL - Any network protocol: http, ftp, nttp, pop3, etc...
			</li>
			
			<li>
			LOCAL_FILE   - A local file whose executable flag is not set
			</li>
			
			<li>
			LOCAL_DIR    - A local directory
			</li>
			
			<li>
			EXECUTABLE   - A local file whose executable flag is set
			</li>
			
			<li>
			HELP         - A man or info page
			</li>
			
			<li>
			SHELL        - A shell executable (ex: echo "Test..." >> ~/testfile)
			</li>
			
			<li>
			BLOCKED      - A URI that should be blocked/filtered (ex: ad filtering)
			</li>
			
			<li>
			ERROR        - An incorrect URI (ex: "~johndoe" when user johndoe
			                    does not exist in that system )
			</li>
			
			<li>
			UNKNOWN      - A URI that is not identified. Default value when
			                    a KURIFilterData is first created.
			     
			</li>		@short    Describes the type of the URI that was filtered.
	*/
	public static final int NET_PROTOCOL = 0;
	public static final int LOCAL_FILE = 1;
	public static final int LOCAL_DIR = 2;
	public static final int EXECUTABLE = 3;
	public static final int HELP = 4;
	public static final int SHELL = 5;
	public static final int BLOCKED = 6;
	public static final int ERROR = 7;
	public static final int UNKNOWN = 8;

	/**	
		 Default constructor.
			 Creates a URIFilterData object.
		     		@short    Default constructor.
	*/
	public KURIFilterData() {
		newKURIFilterData();
	}
	private native void newKURIFilterData();
	/**	
		 Creates a URIFilterData object from the given URL.
			@param url is the URL to be filtered.
		     		@short    Creates a URIFilterData object from the given URL.
	*/
	public KURIFilterData(KURL url) {
		newKURIFilterData(url);
	}
	private native void newKURIFilterData(KURL url);
	/**	
		 Creates a URIFilterData object from the given string.
			@param url is the string to be filtered.
		     		@short    Creates a URIFilterData object from the given string.
	*/
	public KURIFilterData(String url) {
		newKURIFilterData(url);
	}
	private native void newKURIFilterData(String url);
	/**	
		 Copy constructor.
			 Creates a URIFilterData object from another
		 URI filter data object.
			@param data the uri filter data to be copied.
		     		@short    Copy constructor.
	*/
	public KURIFilterData(KURIFilterData data) {
		newKURIFilterData(data);
	}
	private native void newKURIFilterData(KURIFilterData data);
	/**	
		 Returns the filtered or the original URL.
			 This function returns the filtered url if one
		 of the plugins successfully filtered the original
		 URL.  Otherwise, it returns the original URL.
		 See hasBeenFiltered() and
				@return the filtered or original url.
     
		@short    Returns the filtered or the original URL.
	*/
	public native KURL uri();
	/**	
		 Returns an error message.
			 This functions returns the error message set
		 by the plugin whenever the uri type is set to
		 KURIFilterData.ERROR.  Otherwise, it returns
		 a null.
				@return the error message or a NULL when there is none.
     
		@short    Returns an error message.
	*/
	public native String errorMsg();
	/**	
		 Returns the URI type.
			 This method always returns KURIFilterData.UNKNOWN
		 if the given URL was not filtered.
				@return the type of the URI
     
		@short    Returns the URI type.
	*/
	public native int uriType();
	/**	
		 Sets the URL to be filtered.
			 Use this function to set the string to be
		 filtered when you construct an empty filter
		 object.
			@param url the string to be filtered.
		     		@short    Sets the URL to be filtered.
	*/
	public native void setData(String url);
	/**	
		 Same as above except the argument is a URL.
			 Use this function to set the string to be
		 filtered when you construct an empty filter
		 object.
			@param url the URL to be filtered.
		     		@short    Same as above except the argument is a URL.
	*/
	public native void setData(KURL url);
	/**	
		 Sets the absolute path to be used whenever the supplied
		 data is a relative local URL.
			 NOTE: This function should only be used for local resources,
		 i.e. the "file:/" protocol. It is useful for specifying the
		 absolute path in cases where the actual URL might be relative.
		 meta object.  If deriving the path from a KURL, make sure you
		 set the argument for this function to the result of calling
		 path () instead of url ().
			@param abs_path the abolute path to the local resource.
				@return true if absolute path is successfully set. Otherwise, false.
     
		@short    Sets the absolute path to be used whenever the supplied  data is a relative local URL.
	*/
	public native boolean setAbsolutePath(String abs_path);
	/**	
		 Returns the absolute path if one has already been set.
				@return the absolute path, or null

		@short    Returns the absolute path if one has already been set.
		@see #hasAbsolutePath
	*/
	public native String absolutePath();
	/**	
		 Checks whether the supplied data had an absolute path.
				@return true if the supplied data has an absolute path

		@short    Checks whether the supplied data had an absolute path.
		@see #absolutePath
	*/
	public native boolean hasAbsolutePath();
	/**	
		 Returns the command line options and arguments for a
		 local resource when present.
				@return options and arguments when present, otherwise null
     
		@short    Returns the command line options and arguments for a  local resource when present.
	*/
	public native String argsAndOptions();
	/**	
		 Checks whether the current data is a local resource with
		 command line options and arguments.
				@return true if the current data has command line options and arguments
     
		@short    Checks whether the current data is a local resource with  command line options and arguments.
	*/
	public native boolean hasArgsAndOptions();
	/**	
		 Returns the name of the icon that matches
		 the current filtered URL.
			 NOTE that this function will return a NULL
		 string by default and when no associated icon
		 is found.
				@return the name of the icon associated with the resource,
         or null if not found
     
		@short    Returns the name of the icon that matches  the current filtered URL.
	*/
	public native String iconName();
	/**	
		 Check whether the provided uri is executable or not.
			 Setting this to false ensures that typing the name of
		 an executable does not start that application. This is
		 useful in the location bar of a browser. The default
		 value is true.
				@short    Check whether the provided uri is executable or not.
	*/
	public native void setCheckForExecutables(boolean check);
	/**	
				@return true if the filters should attempt to check whether the
 supplied uri is an executable. False otherwise.

		@short
	*/
	public native boolean checkForExecutables();
	/**	
				@return the string as typed by the user, before any URL processing is done

		@short
	*/
	public native String typedString();
	/**	
		 Initializes the KURIFilterData on construction.
			@param url the URL to initialize the object with
		     		@short    Initializes the KURIFilterData on construction.
	*/
	protected native void init(KURL url);
	/**	
		 Initializes the KURIFilterData on construction.
			@param url the URL to initialize the object with
		     		@short    Initializes the KURIFilterData on construction.
	*/
	protected native void init(String url);
	protected native void init();
	/** 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();
}