Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | |
3 * Copyright (C) 2006-2014 Eyeo GmbH | |
4 * | |
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 | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * Adblock Plus is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
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/>. | |
16 */ | |
17 | |
18 #ifndef JNICALLBACKS_H | |
19 #define JNICALLBACKS_H | |
20 | |
21 #include <AdblockPlus.h> | |
22 #include "Utils.h" | |
23 #include "JniJsValue.h" | |
24 | |
25 class JniCallbackBase | |
26 { | |
27 public: | |
28 JniCallbackBase(JNIEnv* env, jobject callbackObject); | |
29 virtual ~JniCallbackBase(); | |
30 void LogException(JNIEnv* env, jthrowable throwable) const; | |
31 void CheckAndLogJavaException(JNIEnv* env) const; | |
32 | |
33 JavaVM* GetJavaVM() const | |
34 { | |
35 return javaVM; | |
36 } | |
37 | |
38 jobject GetCallbackObject() const | |
39 { | |
40 return callbackObject->get(); | |
41 } | |
42 | |
43 private: | |
44 JavaVM* javaVM; | |
45 JniGlobalReference<jobject>::Ptr callbackObject; | |
46 JniGlobalReference<jclass>::Ptr exceptionLoggerClass; | |
47 }; | |
48 | |
49 class JniEventCallback : public JniCallbackBase | |
50 { | |
51 public: | |
52 JniEventCallback(JNIEnv* env, jobject callbackObject); | |
53 virtual ~JniEventCallback(); | |
Felix Dahlke
2014/03/28 17:28:41
A virtual destructor is only required for base cla
René Jeschke
2014/04/11 12:25:53
Done.
| |
54 void Callback(AdblockPlus::JsValueList& params); | |
55 }; | |
56 | |
57 class JniUpdaterCallback : public JniCallbackBase | |
58 { | |
59 public: | |
60 JniUpdaterCallback(JNIEnv* env, jobject callbackObject); | |
61 virtual ~JniUpdaterCallback(); | |
62 void Callback(const std::string& arg); | |
63 }; | |
64 | |
65 class JniFilterChangeCallback : public JniCallbackBase | |
66 { | |
67 public: | |
68 JniFilterChangeCallback(JNIEnv* env, jobject callbackObject); | |
69 virtual ~JniFilterChangeCallback(); | |
70 void Callback(const std::string& arg, const AdblockPlus::JsValuePtr jsValue); | |
71 }; | |
72 | |
73 class JniLogSystemCallback : public JniCallbackBase, public AdblockPlus::LogSyst em | |
74 { | |
75 public: | |
76 JniLogSystemCallback(JNIEnv* env, jobject callbackObject); | |
77 virtual ~JniLogSystemCallback(); | |
78 void operator()(AdblockPlus::LogSystem::LogLevel logLevel, const std::string& message, const std::string& source); | |
79 | |
80 private: | |
81 JniGlobalReference<jclass>::Ptr logLevelClass; | |
82 }; | |
83 | |
84 class JniWebRequest : public JniCallbackBase, public AdblockPlus::WebRequest | |
85 { | |
86 public: | |
87 JniWebRequest(JNIEnv* env, jobject callbackObject); | |
88 virtual ~JniWebRequest(); | |
89 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const; | |
90 | |
91 private: | |
92 jobject NewTuple(JNIEnv* env, const std::string& a, const std::string& b) cons t; | |
93 | |
94 JniGlobalReference<jclass>::Ptr tupleClass; | |
95 JniGlobalReference<jclass>::Ptr serverResponseClass; | |
96 }; | |
97 | |
98 #endif /* JNICALLBACKS_H */ | |
OLD | NEW |