Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android/jni/JniIsAllowedConnectionTypeCallback.cpp

Issue 29379647: Issue 4948 - add possibility to not send data depending on connection properties (Closed)
Patch Set: after Sergei's comments minor clean-up Created March 15, 2017, 10:35 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
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"
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]));
}

Powered by Google App Engine
This is Rietveld