aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/addrbook/AddrBookContactQuery.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/native/addrbook/AddrBookContactQuery.c')
-rw-r--r--src/native/addrbook/AddrBookContactQuery.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/native/addrbook/AddrBookContactQuery.c b/src/native/addrbook/AddrBookContactQuery.c
index 1045214..415ce67 100644
--- a/src/native/addrbook/AddrBookContactQuery.c
+++ b/src/native/addrbook/AddrBookContactQuery.c
@@ -44,6 +44,41 @@ AddrBookContactQuery_getPtrCallbackMethodID(JNIEnv *jniEnv, jobject callback)
return callbackMethodID;
}
+jmethodID
+AddrBookContactQuery_getStringCallbackMethodID(
+ JNIEnv *jniEnv, jobject callback)
+{
+ jclass callbackClass;
+ jmethodID callbackMethodID = 0;
+
+ /*
+ * Make sure that the specified arguments are valid. For example, check
+ * whether callback exists and has the necessary signature.
+ */
+ if (callback)
+ {
+ callbackClass = (*jniEnv)->GetObjectClass(jniEnv, callback);
+ if (callbackClass)
+ {
+ callbackMethodID
+ = (*jniEnv)->GetMethodID(
+ jniEnv,
+ callbackClass, "callback", "(Ljava/lang/String;)Z");
+ if (!callbackMethodID)
+ {
+ Exception_throwNew(
+ jniEnv, "java/lang/IllegalArgumentException", "callback");
+ }
+ }
+ }
+ else
+ {
+ Exception_throwNew(
+ jniEnv, "java/lang/NullPointerException", "callback");
+ }
+ return callbackMethodID;
+}
+
static void
Exception_throwNew(JNIEnv *jniEnv, const char *className, const char *message)
{