OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 19 matching lines...) Expand all Loading... |
30 { | 30 { |
31 delete JniLongToTypePtr<JniShowNotificationCallback>(ptr); | 31 delete JniLongToTypePtr<JniShowNotificationCallback>(ptr); |
32 } | 32 } |
33 | 33 |
34 JniShowNotificationCallback::JniShowNotificationCallback(JNIEnv* env, | 34 JniShowNotificationCallback::JniShowNotificationCallback(JNIEnv* env, |
35 jobject callbackObject) | 35 jobject callbackObject) |
36 : JniCallbackBase(env, callbackObject) | 36 : JniCallbackBase(env, callbackObject) |
37 { | 37 { |
38 } | 38 } |
39 | 39 |
40 void JniShowNotificationCallback::Callback( | 40 void JniShowNotificationCallback::Callback(AdblockPlus::Notification& notificati
on) |
41 const AdblockPlus::NotificationPtr& notificationPtr) | |
42 { | 41 { |
43 JNIEnvAcquire env(GetJavaVM()); | 42 JNIEnvAcquire env(GetJavaVM()); |
44 | 43 |
45 jmethodID method = env->GetMethodID( | 44 jmethodID method = env->GetMethodID( |
46 *JniLocalReference<jclass>(*env, | 45 *JniLocalReference<jclass>(*env, |
47 env->GetObjectClass(GetCallbackObject())), | 46 env->GetObjectClass(GetCallbackObject())), |
48 "showNotificationCallback", "(" TYP("Notification") ")V"); | 47 "showNotificationCallback", "(" TYP("Notification") ")V"); |
49 | 48 |
50 if (method) | 49 if (method) |
51 { | 50 { |
52 JniLocalReference<jobject> jNotification(*env, NewJniNotification(*env, | 51 JniLocalReference<jobject> jNotification(*env, NewJniNotification(*env, noti
fication)); |
53 notificationPtr)); | |
54 env->CallVoidMethod(GetCallbackObject(), method, *jNotification); | 52 env->CallVoidMethod(GetCallbackObject(), method, *jNotification); |
55 } | 53 } |
56 | 54 |
57 CheckAndLogJavaException(*env); | 55 CheckAndLogJavaException(*env); |
58 } | 56 } |
59 | 57 |
60 static JNINativeMethod methods[] = | 58 static JNINativeMethod methods[] = |
61 { | 59 { |
62 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, | 60 { (char*)"ctor", (char*)"(Ljava/lang/Object;)J", (void*)JniCtor }, |
63 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 61 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } |
64 }; | 62 }; |
65 | 63 |
66 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_ShowNotifi
cationCallback_registerNatives(JNIEnv *env, jclass clazz) | 64 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_ShowNotifi
cationCallback_registerNatives(JNIEnv *env, jclass clazz) |
67 { | 65 { |
68 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 66 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); |
69 } | 67 } |
OLD | NEW |