Index: libadblockplus-android/jni/JniIsAllowedConnectionTypeCallback.cpp |
diff --git a/libadblockplus-android/jni/JniShowNotificationCallback.cpp b/libadblockplus-android/jni/JniIsAllowedConnectionTypeCallback.cpp |
similarity index 61% |
copy from libadblockplus-android/jni/JniShowNotificationCallback.cpp |
copy to libadblockplus-android/jni/JniIsAllowedConnectionTypeCallback.cpp |
index 38f2d9df5f51c2f1d1b47898b9d8ae15f3beafb9..678e5767c821ceb8e199ae08210b1b4df27aa4ed 100644 |
--- a/libadblockplus-android/jni/JniShowNotificationCallback.cpp |
+++ b/libadblockplus-android/jni/JniIsAllowedConnectionTypeCallback.cpp |
@@ -16,45 +16,48 @@ |
*/ |
#include "JniCallbacks.h" |
+#include "Utils.h" |
anton
2017/03/10 06:50:40
is seems to be Rietveld bug here: the file was abs
|
static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jobject callbackObject) |
{ |
try |
{ |
- return JniPtrToLong(new JniShowNotificationCallback(env, callbackObject)); |
+ JniIsAllowedConnectionTypeCallback* callback = |
+ new JniIsAllowedConnectionTypeCallback(env, callbackObject); |
+ |
+ return JniPtrToLong(callback); |
} |
CATCH_THROW_AND_RETURN(env, 0) |
} |
static void JNICALL JniDtor(JNIEnv* env, jclass clazz, jlong ptr) |
{ |
- delete JniLongToTypePtr<JniShowNotificationCallback>(ptr); |
+ delete JniLongToTypePtr<JniIsAllowedConnectionTypeCallback>(ptr); |
} |
-JniShowNotificationCallback::JniShowNotificationCallback(JNIEnv* env, |
+JniIsAllowedConnectionTypeCallback::JniIsAllowedConnectionTypeCallback(JNIEnv* env, |
jobject callbackObject) |
: JniCallbackBase(env, callbackObject) |
{ |
} |
-void JniShowNotificationCallback::Callback( |
- const AdblockPlus::NotificationPtr& notificationPtr) |
+bool JniIsAllowedConnectionTypeCallback::Callback(const std::string* allowedConnectionType) |
{ |
JNIEnvAcquire env(GetJavaVM()); |
jmethodID method = env->GetMethodID( |
- *JniLocalReference<jclass>(*env, |
- env->GetObjectClass(GetCallbackObject())), |
- "showNotificationCallback", "(" TYP("Notification") ")V"); |
+ *JniLocalReference<jclass>(*env, env->GetObjectClass(GetCallbackObject())), |
+ "isConnectionAllowed", |
+ "(Ljava/lang/String;)Z"); |
- if (method) |
- { |
- JniLocalReference<jobject> jNotification(*env, NewJniNotification(*env, |
- notificationPtr)); |
- env->CallVoidMethod(GetCallbackObject(), method, *jNotification); |
- } |
+ jstring jAllowedConnectionType = |
+ (allowedConnectionType != NULL |
+ ? JniStdStringToJava(*env, *allowedConnectionType) |
+ : NULL); |
+ bool result = env->CallBooleanMethod(GetCallbackObject(), method, jAllowedConnectionType); |
CheckAndLogJavaException(*env); |
+ return result; |
} |
static JNINativeMethod methods[] = |
@@ -63,7 +66,7 @@ static JNINativeMethod methods[] = |
{ (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
}; |
-extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_ShowNotificationCallback_registerNatives(JNIEnv *env, jclass clazz) |
+extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_IsAllowedConnectionCallback_registerNatives(JNIEnv *env, jclass clazz) |
{ |
env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
} |