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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include "JniCallbacks.h" | 18 #include "JniCallbacks.h" |
19 #include "Utils.h" | |
20 | 19 |
21 JniIsAllowedConnectionTypeCallback::JniIsAllowedConnectionTypeCallback(JNIEnv* e
nv, | 20 JniIsAllowedConnectionTypeCallback::JniIsAllowedConnectionTypeCallback(JNIEnv* e
nv, |
22 jobject callbackObject) | 21 jobject callbackObject) |
23 : JniCallbackBase(env, callbackObject) | 22 : JniCallbackBase(env, callbackObject) |
24 { | 23 { |
25 } | 24 } |
26 | 25 |
27 bool JniIsAllowedConnectionTypeCallback::Callback(const std::string* allowedConn
ectionType) | 26 bool JniIsAllowedConnectionTypeCallback::Callback(const std::string* allowedConn
ectionType) |
28 { | 27 { |
29 JNIEnvAcquire env(GetJavaVM()); | 28 JNIEnvAcquire env(GetJavaVM()); |
30 | 29 |
31 jmethodID method = env->GetMethodID( | 30 jmethodID method = env->GetMethodID( |
32 *JniLocalReference<jclass>(*env, env->GetObjectClass(GetCallbackObject()))
, | 31 *JniLocalReference<jclass>(*env, env->GetObjectClass(GetCallbackObject()))
, |
33 "isConnectionAllowed", | 32 "isConnectionAllowed", |
34 "(Ljava/lang/String;)Z"); | 33 "(Ljava/lang/String;)Z"); |
35 | 34 |
36 jstring jAllowedConnectionType = | 35 jstring jAllowedConnectionType = |
37 (allowedConnectionType != NULL | 36 (allowedConnectionType != NULL |
38 ? JniStdStringToJava(*env, *allowedConnectionType) | 37 ? JniStdStringToJava(*env, *allowedConnectionType) |
39 : NULL); | 38 : NULL); |
40 bool result = env->CallBooleanMethod(GetCallbackObject(), method, jAllowedConn
ectionType); | 39 bool result = env->CallBooleanMethod(GetCallbackObject(), method, jAllowedConn
ectionType); |
41 | 40 |
42 CheckAndLogJavaException(*env); | 41 CheckAndLogJavaException(*env); |
43 return result; | 42 return result; |
44 } | 43 } |
OLD | NEW |