svn-gvsig-desktop / tags / v2_0_0_prep_before_2001 / libraries / libjni-readecw-linux / src / ecw_jni_config.c @ 41849
History | View | Annotate | Download (10.8 KB)
1 | 1448 | igbrotru | /**********************************************************
|
---|---|---|---|
2 | ** Copyright 2004 Earth Resource Mapping Ltd.
|
||
3 | ** This document contains proprietary source code of
|
||
4 | ** Earth Resource Mapping Ltd, and can only be used under
|
||
5 | ** one of the three licenses as described in the
|
||
6 | ** license.txt file supplied with this distribution.
|
||
7 | ** See separate license.txt file for license details
|
||
8 | ** and conditions.
|
||
9 | **
|
||
10 | ** This software is covered by US patent #6,442,298,
|
||
11 | ** #6,102,897 and #6,633,688. Rights to use these patents
|
||
12 | ** is included in the license agreements.
|
||
13 | **
|
||
14 | ** FILE: ecw_jni_config.c
|
||
15 | ** CREATED: 10 May 2004
|
||
16 | ** AUTHOR: Mark Sheridan
|
||
17 | ** PURPOSE: Java wrappers for JNI usage of the ECW config functions NCSecwSetConfig() && NCSecwGetConfig()
|
||
18 | ** For some bizarre reason those calls were implemented as var args, since Java doesnt have var_args
|
||
19 | ** it makes this code very verbose and prone to errors.
|
||
20 | ** EDITS:
|
||
21 | **
|
||
22 | **
|
||
23 | *******************************************************/
|
||
24 | |||
25 | #include "NCSErrors.h" |
||
26 | #include "NCSECW.h" |
||
27 | #include "JNCSEcwConfig.h" |
||
28 | |||
29 | #ifndef JNI_VERSION_1_2
|
||
30 | #error You must compile this class against a 1.2 virtual machine specification |
||
31 | #endif
|
||
32 | |||
33 | static void ThrowRuntimeEx(JNIEnv *pEnv, char *pMessage) |
||
34 | { |
||
35 | // throw an exception of the type "java.lang.RuntimeException"
|
||
36 | jclass runTimeExCls = (*pEnv)->FindClass(pEnv, "java/lang/RuntimeException");
|
||
37 | |||
38 | if (runTimeExCls != NULL) |
||
39 | { |
||
40 | (*pEnv)->ThrowNew(pEnv, runTimeExCls, (const char *)pMessage); |
||
41 | } |
||
42 | |||
43 | (*pEnv)->DeleteLocalRef(pEnv, runTimeExCls); |
||
44 | } |
||
45 | |||
46 | /*
|
||
47 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
48 | * Method: SetTextureDither
|
||
49 | * Signature: (Z)V
|
||
50 | */
|
||
51 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setTextureDither
|
||
52 | (JNIEnv *pEnv, jclass clazz, jboolean bValue) |
||
53 | { |
||
54 | if (NCSecwSetConfig(NCSCFG_TEXTURE_DITHER, bValue) != NCS_SUCCESS)
|
||
55 | { |
||
56 | ThrowRuntimeEx(pEnv, "Error setting texture dither property.");
|
||
57 | } |
||
58 | } |
||
59 | |||
60 | /*
|
||
61 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
62 | * Method: GetTextureDither
|
||
63 | * Signature: ()Z
|
||
64 | */
|
||
65 | JNIEXPORT jboolean JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getTextureDither |
||
66 | (JNIEnv *pEnv, jclass clazz) |
||
67 | { |
||
68 | jboolean bValue = FALSE; |
||
69 | if (NCSecwGetConfig(NCSCFG_TEXTURE_DITHER, &bValue) != NCS_SUCCESS)
|
||
70 | { |
||
71 | ThrowRuntimeEx(pEnv, "Error getting texture dither property.");
|
||
72 | } |
||
73 | return bValue;
|
||
74 | } |
||
75 | |||
76 | /*
|
||
77 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
78 | * Method: SetForceFileReopen
|
||
79 | * Signature: (Z)V
|
||
80 | */
|
||
81 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setForceFileReopen
|
||
82 | (JNIEnv *pEnv, jclass clazz, jboolean bValue) |
||
83 | { |
||
84 | if (NCSecwSetConfig(NCSCFG_FORCE_FILE_REOPEN, bValue) != NCS_SUCCESS)
|
||
85 | { |
||
86 | ThrowRuntimeEx(pEnv, "Error setting force file reopen property.");
|
||
87 | } |
||
88 | } |
||
89 | |||
90 | /*
|
||
91 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
92 | * Method: GetForceFileReopen
|
||
93 | * Signature: ()Z
|
||
94 | */
|
||
95 | JNIEXPORT jboolean JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getForceFileReopen |
||
96 | (JNIEnv *pEnv, jclass clazz) |
||
97 | { |
||
98 | jboolean bValue = FALSE; |
||
99 | if (NCSecwGetConfig(NCSCFG_FORCE_FILE_REOPEN, &bValue) != NCS_SUCCESS)
|
||
100 | { |
||
101 | ThrowRuntimeEx(pEnv, "Error getting force file reopen property.");
|
||
102 | } |
||
103 | return bValue;
|
||
104 | } |
||
105 | |||
106 | |||
107 | /*
|
||
108 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
109 | * Method: SetCacheMaxMem
|
||
110 | * Signature: (J)V
|
||
111 | */
|
||
112 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setCacheMaxMem
|
||
113 | (JNIEnv *pEnv, jclass clazz, jlong value) |
||
114 | { |
||
115 | if (NCSecwSetConfig(NCSCFG_CACHE_MAXMEM, value) != NCS_SUCCESS)
|
||
116 | { |
||
117 | ThrowRuntimeEx(pEnv, "Error setting cache max mem property.");
|
||
118 | } |
||
119 | } |
||
120 | |||
121 | |||
122 | /*
|
||
123 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
124 | * Method: GetCacheMaxMen
|
||
125 | * Signature: ()J
|
||
126 | */
|
||
127 | JNIEXPORT jlong JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getCacheMaxMen |
||
128 | (JNIEnv *pEnv, jclass clazz) |
||
129 | { |
||
130 | jlong value = 0;
|
||
131 | if (NCSecwGetConfig(NCSCFG_CACHE_MAXMEM, &value) != NCS_SUCCESS)
|
||
132 | { |
||
133 | ThrowRuntimeEx(pEnv, "Error getting cache max mem property.");
|
||
134 | } |
||
135 | return value;
|
||
136 | } |
||
137 | |||
138 | |||
139 | /*
|
||
140 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
141 | * Method: SetCacheMaxOpenFiles
|
||
142 | * Signature: (I)V
|
||
143 | */
|
||
144 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setCacheMaxOpenFiles
|
||
145 | (JNIEnv *pEnv, jclass clazz, jint value) |
||
146 | { |
||
147 | if (NCSecwSetConfig(NCSCFG_CACHE_MAXOPEN, value) != NCS_SUCCESS)
|
||
148 | { |
||
149 | ThrowRuntimeEx(pEnv, "Error setting cache max open files property.");
|
||
150 | } |
||
151 | } |
||
152 | |||
153 | |||
154 | /*
|
||
155 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
156 | * Method: GetCacheMaxOpenFiles
|
||
157 | * Signature: ()I
|
||
158 | */
|
||
159 | JNIEXPORT jint JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getCacheMaxOpenFiles |
||
160 | (JNIEnv *pEnv, jclass clazz) |
||
161 | { |
||
162 | jint value = 0;
|
||
163 | if (NCSecwGetConfig(NCSCFG_CACHE_MAXOPEN, &value) != NCS_SUCCESS)
|
||
164 | { |
||
165 | ThrowRuntimeEx(pEnv, "Error getting cache max open files property.");
|
||
166 | } |
||
167 | return value;
|
||
168 | } |
||
169 | |||
170 | |||
171 | /*
|
||
172 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
173 | * Method: SetBlockingTimeMS
|
||
174 | * Signature: (I)V
|
||
175 | */
|
||
176 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setBlockingTimeMS
|
||
177 | (JNIEnv *pEnv, jclass clazz, jint value) |
||
178 | { |
||
179 | if (NCSecwSetConfig(NCSCFG_BLOCKING_TIME_MS, value) != NCS_SUCCESS)
|
||
180 | { |
||
181 | ThrowRuntimeEx(pEnv, "Error setting cache max open files property.");
|
||
182 | } |
||
183 | } |
||
184 | |||
185 | |||
186 | /*
|
||
187 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
188 | * Method: GetBlockingTimeMS
|
||
189 | * Signature: ()I
|
||
190 | */
|
||
191 | JNIEXPORT jint JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getBlockingTimeMS |
||
192 | (JNIEnv *pEnv, jclass clazz) |
||
193 | { |
||
194 | jint value = 0;
|
||
195 | if (NCSecwGetConfig(NCSCFG_BLOCKING_TIME_MS, &value) != NCS_SUCCESS)
|
||
196 | { |
||
197 | ThrowRuntimeEx(pEnv, "Error getting cache max open files property.");
|
||
198 | } |
||
199 | return value;
|
||
200 | } |
||
201 | |||
202 | /*
|
||
203 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
204 | * Method: SetRefreshTimeMS
|
||
205 | * Signature: (I)V
|
||
206 | */
|
||
207 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setRefreshTimeMS
|
||
208 | (JNIEnv *pEnv, jclass clazz, jint value) |
||
209 | { |
||
210 | if (NCSecwSetConfig(NCSCFG_REFRESH_TIME_MS, value) != NCS_SUCCESS)
|
||
211 | { |
||
212 | ThrowRuntimeEx(pEnv, "Error setting refresh time property.");
|
||
213 | } |
||
214 | } |
||
215 | |||
216 | |||
217 | /*
|
||
218 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
219 | * Method: GetRefreshTimeMS
|
||
220 | * Signature: ()I
|
||
221 | */
|
||
222 | JNIEXPORT jint JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getRefreshTimeMS |
||
223 | (JNIEnv *pEnv, jclass clazz) |
||
224 | { |
||
225 | jint value = 0;
|
||
226 | if (NCSecwGetConfig(NCSCFG_REFRESH_TIME_MS, &value) != NCS_SUCCESS)
|
||
227 | { |
||
228 | ThrowRuntimeEx(pEnv, "Error getting refresh time property.");
|
||
229 | } |
||
230 | return value;
|
||
231 | } |
||
232 | |||
233 | |||
234 | /*
|
||
235 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
236 | * Method: SetPurgeDelayMS
|
||
237 | * Signature: (I)V
|
||
238 | */
|
||
239 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setPurgeDelayMS
|
||
240 | (JNIEnv *pEnv, jclass clazz, jint value) |
||
241 | { |
||
242 | if (NCSecwSetConfig(NCSCFG_PURGE_DELAY_MS, value) != NCS_SUCCESS)
|
||
243 | { |
||
244 | ThrowRuntimeEx(pEnv, "Error setting purge delay property.");
|
||
245 | } |
||
246 | } |
||
247 | |||
248 | |||
249 | /*
|
||
250 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
251 | * Method: GetPurgeDelayMS
|
||
252 | * Signature: ()I
|
||
253 | */
|
||
254 | JNIEXPORT jint JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getPurgeDelayMS |
||
255 | (JNIEnv *pEnv, jclass clazz) |
||
256 | { |
||
257 | jint value = 0;
|
||
258 | if (NCSecwGetConfig(NCSCFG_REFRESH_TIME_MS, &value) != NCS_SUCCESS)
|
||
259 | { |
||
260 | ThrowRuntimeEx(pEnv, "Error getting purge delay property.");
|
||
261 | } |
||
262 | return value;
|
||
263 | } |
||
264 | |||
265 | |||
266 | /*
|
||
267 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
268 | * Method: SetFilePurgeDelayMS
|
||
269 | * Signature: (I)V
|
||
270 | */
|
||
271 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setFilePurgeDelayMS
|
||
272 | (JNIEnv *pEnv, jclass clazz, jint value) |
||
273 | { |
||
274 | if (NCSecwSetConfig(NCSCFG_FILE_PURGE_DELAY_MS, value) != NCS_SUCCESS)
|
||
275 | { |
||
276 | ThrowRuntimeEx(pEnv, "Error setting file purge delay property.");
|
||
277 | } |
||
278 | } |
||
279 | |||
280 | |||
281 | /*
|
||
282 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
283 | * Method: GetFilePurgeDelayMS
|
||
284 | * Signature: ()I
|
||
285 | */
|
||
286 | JNIEXPORT jint JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getFilePurgeDelayMS |
||
287 | (JNIEnv *pEnv, jclass clazz) |
||
288 | { |
||
289 | jint value = 0;
|
||
290 | if (NCSecwGetConfig(NCSCFG_FILE_PURGE_DELAY_MS, &value) != NCS_SUCCESS)
|
||
291 | { |
||
292 | ThrowRuntimeEx(pEnv, "Error getting file purge delay property.");
|
||
293 | } |
||
294 | return value;
|
||
295 | } |
||
296 | |||
297 | |||
298 | /*
|
||
299 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
300 | * Method: SetMinPurgeDelayMS
|
||
301 | * Signature: (I)V
|
||
302 | */
|
||
303 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setMinPurgeDelayMS
|
||
304 | (JNIEnv *pEnv, jclass clazz, jint value) |
||
305 | { |
||
306 | if (NCSecwSetConfig(NCSCFG_MIN_FILE_PURGE_DELAY_MS, value) != NCS_SUCCESS)
|
||
307 | { |
||
308 | ThrowRuntimeEx(pEnv, "Error setting min file purge delay property.");
|
||
309 | } |
||
310 | } |
||
311 | |||
312 | |||
313 | /*
|
||
314 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
315 | * Method: GetMinPurgeDelayMS
|
||
316 | * Signature: ()I
|
||
317 | */
|
||
318 | JNIEXPORT jint JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getMinPurgeDelayMS |
||
319 | (JNIEnv *pEnv, jclass clazz) |
||
320 | { |
||
321 | jint value = 0;
|
||
322 | if (NCSecwGetConfig(NCSCFG_MIN_FILE_PURGE_DELAY_MS, &value) != NCS_SUCCESS)
|
||
323 | { |
||
324 | ThrowRuntimeEx(pEnv, "Error getting min file purge delay property.");
|
||
325 | } |
||
326 | return value;
|
||
327 | } |
||
328 | |||
329 | |||
330 | /*
|
||
331 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
332 | * Method: SetProxy
|
||
333 | * Signature: (Ljava/lang/String;)V
|
||
334 | */
|
||
335 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setECWPProxy
|
||
336 | (JNIEnv *pEnv, jclass clazz, jstring value) |
||
337 | { |
||
338 | const char *proxy = (*pEnv)->GetStringUTFChars(pEnv, value, (jboolean *)NULL); |
||
339 | |||
340 | if (proxy != NULL) |
||
341 | { |
||
342 | if (NCSecwSetConfig(NCSCFG_ECWP_PROXY, proxy) != NCS_SUCCESS)
|
||
343 | { |
||
344 | ThrowRuntimeEx(pEnv, "Error setting proxy property.");
|
||
345 | } |
||
346 | |||
347 | (*pEnv)->ReleaseStringUTFChars(pEnv, value, proxy); |
||
348 | } |
||
349 | } |
||
350 | |||
351 | |||
352 | /*
|
||
353 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
354 | * Method: GetProxy
|
||
355 | * Signature: ()Ljava/lang/String;
|
||
356 | */
|
||
357 | JNIEXPORT jstring JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getECWPProxy |
||
358 | (JNIEnv *pEnv, jclass clazz) |
||
359 | { |
||
360 | char *pvalue = NULL; |
||
361 | |||
362 | if (NCSecwGetConfig(NCSCFG_ECWP_PROXY, &pvalue) != NCS_SUCCESS)
|
||
363 | { |
||
364 | ThrowRuntimeEx(pEnv, "Error getting proxy property.");
|
||
365 | } |
||
366 | else
|
||
367 | { |
||
368 | return (*pEnv)->NewStringUTF(pEnv, pvalue);
|
||
369 | } |
||
370 | return (*pEnv)->NewStringUTF(pEnv, ""); |
||
371 | } |
||
372 | |||
373 | |||
374 | /*
|
||
375 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
376 | * Method: SetForceLowMemCompress
|
||
377 | * Signature: (Z)V
|
||
378 | */
|
||
379 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setForceLowMemCompress
|
||
380 | (JNIEnv *pEnv, jclass clazz, jboolean bValue) |
||
381 | { |
||
382 | if (NCSecwSetConfig(NCSCFG_FORCE_LOWMEM_COMPRESS, bValue) != NCS_SUCCESS)
|
||
383 | { |
||
384 | ThrowRuntimeEx(pEnv, "Error setting low mem compress property.");
|
||
385 | } |
||
386 | } |
||
387 | |||
388 | |||
389 | /*
|
||
390 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
391 | * Method: GetForceLowMemCompress
|
||
392 | * Signature: ()Z
|
||
393 | */
|
||
394 | JNIEXPORT jboolean JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getForceLowMemCompress |
||
395 | (JNIEnv *pEnv, jclass clazz) |
||
396 | { |
||
397 | jboolean bValue = FALSE; |
||
398 | if (NCSecwGetConfig(NCSCFG_FORCE_LOWMEM_COMPRESS, &bValue) != NCS_SUCCESS)
|
||
399 | { |
||
400 | ThrowRuntimeEx(pEnv, "Error getting low mem compress property.");
|
||
401 | } |
||
402 | return bValue;
|
||
403 | } |
||
404 | |||
405 | |||
406 | /*
|
||
407 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
408 | * Method: SetECWPReconnect
|
||
409 | * Signature: (Z)V
|
||
410 | */
|
||
411 | JNIEXPORT void JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_setECWPReconnect
|
||
412 | (JNIEnv *pEnv, jclass clazz, jboolean bValue) |
||
413 | { |
||
414 | if (NCSecwSetConfig(NCSCFG_TRY_ECWP_RECONNECT, bValue) != NCS_SUCCESS)
|
||
415 | { |
||
416 | ThrowRuntimeEx(pEnv, "Error setting ECWP reconnect property.");
|
||
417 | } |
||
418 | } |
||
419 | |||
420 | |||
421 | /*
|
||
422 | * Class: com_ermapper_ecw_JNCSEcwConfig
|
||
423 | * Method: GetECWPReconnect
|
||
424 | * Signature: ()Z
|
||
425 | */
|
||
426 | JNIEXPORT jboolean JNICALL Java_com_ermapper_ecw_JNCSEcwConfig_getECWPReconnect |
||
427 | (JNIEnv *pEnv, jclass clazz) |
||
428 | { |
||
429 | jboolean bValue = FALSE; |
||
430 | if (NCSecwGetConfig(NCSCFG_TRY_ECWP_RECONNECT, &bValue) != NCS_SUCCESS)
|
||
431 | { |
||
432 | ThrowRuntimeEx(pEnv, "Error getting ECWP reconnect property.");
|
||
433 | } |
||
434 | return bValue;
|
||
435 | } |