Mercurial > cgi-bin > hgweb.cgi > JpegWasher
annotate src/name/blackcap/exifwasher/exiv2/native.cpp @ 10:9bbe6d803eba
Fixed ShowDialog.
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 10 Apr 2020 19:29:58 -0700 |
parents | efd9fe2d70d7 |
children | a59d84674fb0 |
rev | line source |
---|---|
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
1 #include <jni.h> |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
2 #include <exiv2/exiv2.hpp> |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
3 #include <exception> |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
4 #include <iostream> |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
5 #include <iomanip> |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
6 #include <cassert> |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
7 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
8 /* Functions for class name_blackcap_exifwasher_exiv2_Image */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
9 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
10 #ifndef _Included_name_blackcap_exifwasher_exiv2_Image |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
11 #define _Included_name_blackcap_exifwasher_exiv2_Image |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
12 #ifdef __cplusplus |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
13 extern "C" { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
14 #endif |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
15 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
16 /* |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
17 * Utility function to get pointer field. |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
18 */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
19 jlong getPointer(JNIEnv *jEnv, jobject jThis) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
20 return jEnv->GetLongField(jThis, jEnv->GetFieldID(jEnv->GetObjectClass(jThis), "pointer", "J")); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
21 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
22 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
23 /* |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
24 * Class: name_blackcap_exifwasher_exiv2_Image |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
25 * Method: _ctor |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
26 * Signature: (Ljava/lang/String;)J |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
27 */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
28 JNIEXPORT jlong JNICALL Java_name_blackcap_exifwasher_exiv2_Image__1ctor |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
29 (JNIEnv *jEnv, jobject jThis, jstring path) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
30 const char *cPath = jEnv->GetStringUTFChars(path, NULL); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
31 jlong ret = 0; |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
32 try { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
33 ret = reinterpret_cast<jlong> (Exiv2::ImageFactory::open(cPath).release()); |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
34 } catch (std::exception& e) { |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
35 jEnv->ExceptionClear(); |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
36 jclass ex = jEnv->FindClass("name/blackcap/exifwasher/exiv2/Exiv2Exception"); |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
37 jEnv->ThrowNew(ex, e.what()); |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
38 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
39 jEnv->ReleaseStringUTFChars(path, cPath); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
40 return ret; |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
41 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
42 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
43 /* |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
44 * Class: name_blackcap_exifwasher_exiv2_Image |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
45 * Method: _writeMetadata |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
46 * Signature: ()V |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
47 */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
48 JNIEXPORT void JNICALL Java_name_blackcap_exifwasher_exiv2_Image__1writeMetadata |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
49 (JNIEnv *jEnv, jobject jThis) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
50 Exiv2::Image *image = reinterpret_cast<Exiv2::Image *> (getPointer(jEnv, jThis)); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
51 if (jEnv->ExceptionCheck()) return; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
52 try { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
53 image->writeMetadata(); |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
54 } catch (std::exception& e) { |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
55 jEnv->ExceptionClear(); |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
56 jclass ex = jEnv->FindClass("name/blackcap/exifwasher/exiv2/Exiv2Exception"); |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
57 jEnv->ThrowNew(ex, e.what()); |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
58 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
59 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
60 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
61 /* |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
62 * Class: name_blackcap_exifwasher_exiv2_Image |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
63 * Method: _getMetadata |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
64 * Signature: ()J |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
65 */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
66 JNIEXPORT jlong JNICALL Java_name_blackcap_exifwasher_exiv2_Image__1getMetadata |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
67 (JNIEnv *jEnv, jobject jThis) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
68 Exiv2::Image *image = reinterpret_cast<Exiv2::Image *> (getPointer(jEnv, jThis)); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
69 if (jEnv->ExceptionCheck()) return 0; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
70 try { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
71 image->readMetadata(); |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
72 } catch (std::exception& e) { |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
73 jEnv->ExceptionClear(); |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
74 jclass ex = jEnv->FindClass("name/blackcap/exifwasher/exiv2/Exiv2Exception"); |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
75 jEnv->ThrowNew(ex, e.what()); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
76 return 0; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
77 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
78 return reinterpret_cast<jlong> (&(image->exifData())); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
79 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
80 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
81 /* |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
82 * Class: name_blackcap_exifwasher_exiv2_Image |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
83 * Method: _dtor |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
84 * Signature: ()V |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
85 */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
86 JNIEXPORT void JNICALL Java_name_blackcap_exifwasher_exiv2_Image__1dtor |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
87 (JNIEnv *jEnv, jobject jThis) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
88 Exiv2::Image *image = reinterpret_cast<Exiv2::Image *> (getPointer(jEnv, jThis)); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
89 if (jEnv->ExceptionCheck()) return; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
90 delete image; |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
91 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
92 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
93 #ifdef __cplusplus |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
94 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
95 #endif |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
96 #endif |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
97 /* Header for class name_blackcap_exifwasher_exiv2_ExifData */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
98 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
99 #ifndef _Included_name_blackcap_exifwasher_exiv2_ExifData |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
100 #define _Included_name_blackcap_exifwasher_exiv2_ExifData |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
101 #ifdef __cplusplus |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
102 extern "C" { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
103 #endif |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
104 /* |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
105 * Class: name_blackcap_exifwasher_exiv2_ExifData |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
106 * Method: _erase |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
107 * Signature: (Ljava/lang/String;)V |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
108 */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
109 JNIEXPORT void JNICALL Java_name_blackcap_exifwasher_exiv2_ExifData__1erase |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
110 (JNIEnv *jEnv, jobject jThis, jstring key) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
111 Exiv2::ExifData *data = reinterpret_cast<Exiv2::ExifData *> (getPointer(jEnv, jThis)); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
112 if (jEnv->ExceptionCheck()) return; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
113 const char *cKey = jEnv->GetStringUTFChars(key, NULL); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
114 Exiv2::ExifData::iterator found = data->findKey(Exiv2::ExifKey(std::string(cKey))); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
115 try { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
116 data->erase(found); |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
117 } catch (std::exception& e) { |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
118 jEnv->ExceptionClear(); |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
119 jclass ex = jEnv->FindClass("name/blackcap/exifwasher/exiv2/Exiv2Exception"); |
2
efd9fe2d70d7
Rationalize exceptions, code whitelist, add command-line tool.
David Barts <n5jrn@me.com>
parents:
1
diff
changeset
|
120 jEnv->ThrowNew(ex, e.what()); |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
121 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
122 jEnv->ReleaseStringUTFChars(key, cKey); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
123 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
124 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
125 /* |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
126 * Class: name_blackcap_exifwasher_exiv2_ExifData |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
127 * Method: _value |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
128 * Signature: (Ljava/lang/String;)Lname/blackcap/exifwasher/exiv2/ExifData/Value; |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
129 */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
130 JNIEXPORT jobject JNICALL Java_name_blackcap_exifwasher_exiv2_ExifData__1value |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
131 (JNIEnv *jEnv, jobject jThis, jstring key) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
132 Exiv2::ExifData *data = reinterpret_cast<Exiv2::ExifData *> (getPointer(jEnv, jThis)); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
133 if (jEnv->ExceptionCheck()) return NULL; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
134 const char *cKey = jEnv->GetStringUTFChars(key, NULL); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
135 Exiv2::ExifData::const_iterator found = data->findKey(Exiv2::ExifKey(std::string(cKey))); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
136 jEnv->ReleaseStringUTFChars(key, cKey); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
137 if (found == data->end()) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
138 return NULL; |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
139 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
140 jclass klass = jEnv->FindClass("name/blackcap/exifwasher/exiv2/ExifData$Value"); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
141 if (jEnv->ExceptionCheck()) return NULL; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
142 jstring type = jEnv->NewStringUTF(found->typeName()); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
143 jstring value = jEnv->NewStringUTF(found->toString().c_str()); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
144 jmethodID method = jEnv->GetMethodID(klass, "<init>", "(Ljava/lang/String;Ljava/lang/String;)V"); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
145 if (jEnv->ExceptionCheck()) return NULL; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
146 return jEnv->NewObject(klass, method, type, value); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
147 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
148 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
149 /* |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
150 * Class: name_blackcap_exifwasher_exiv2_ExifData |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
151 * Method: _keys |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
152 * Signature: ()[Ljava/lang/String; |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
153 */ |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
154 JNIEXPORT jobjectArray JNICALL Java_name_blackcap_exifwasher_exiv2_ExifData__1keys |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
155 (JNIEnv *jEnv, jobject jThis) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
156 Exiv2::ExifData *data = reinterpret_cast<Exiv2::ExifData *> (getPointer(jEnv, jThis)); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
157 if (jEnv->ExceptionCheck()) return NULL; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
158 jclass klass = jEnv->FindClass("java/lang/String"); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
159 if (jEnv->ExceptionCheck()) return NULL; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
160 jobjectArray ret = jEnv->NewObjectArray(data->count(), klass, NULL); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
161 if (jEnv->ExceptionCheck()) return NULL; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
162 Exiv2::ExifData::const_iterator end = data->end(); |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
163 jsize j = 0; |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
164 for (Exiv2::ExifData::const_iterator i = data->begin(); i != end; ++i) { |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
165 jEnv->SetObjectArrayElement(ret, j++, jEnv->NewStringUTF(i->key().c_str())); |
1
42277ce58ace
Improve exception handling; always use absolute paths on libs.
David Barts <n5jrn@me.com>
parents:
0
diff
changeset
|
166 if (jEnv->ExceptionCheck()) break; |
0
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
167 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
168 return ret; |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
169 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
170 |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
171 #ifdef __cplusplus |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
172 } |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
173 #endif |
db63d01a23c6
JNI calls and test case (finally!) seem to work.
David Barts <n5jrn@me.com>
parents:
diff
changeset
|
174 #endif |