| OLD | NEW | 
 | (Empty) | 
|    1 /* |  | 
|    2  * This file is part of Adblock Plus <https://adblockplus.org/>, |  | 
|    3  * Copyright (C) 2006-2016 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   const JniGlobalReference<jobject>::Ptr callbackObject; |  | 
|   46   const JniGlobalReference<jclass>::Ptr exceptionLoggerClass; |  | 
|   47 }; |  | 
|   48  |  | 
|   49 class JniEventCallback : public JniCallbackBase |  | 
|   50 { |  | 
|   51 public: |  | 
|   52   JniEventCallback(JNIEnv* env, jobject callbackObject); |  | 
|   53   void Callback(AdblockPlus::JsValueList& params); |  | 
|   54 }; |  | 
|   55  |  | 
|   56 class JniUpdateAvailableCallback : public JniCallbackBase |  | 
|   57 { |  | 
|   58 public: |  | 
|   59   JniUpdateAvailableCallback(JNIEnv* env, jobject callbackObject); |  | 
|   60   void Callback(const std::string& arg); |  | 
|   61 }; |  | 
|   62  |  | 
|   63 class JniUpdateCheckDoneCallback : public JniCallbackBase |  | 
|   64 { |  | 
|   65 public: |  | 
|   66   JniUpdateCheckDoneCallback(JNIEnv* env, jobject callbackObject); |  | 
|   67   void Callback(const std::string& arg); |  | 
|   68 }; |  | 
|   69  |  | 
|   70 class JniFilterChangeCallback : public JniCallbackBase |  | 
|   71 { |  | 
|   72 public: |  | 
|   73   JniFilterChangeCallback(JNIEnv* env, jobject callbackObject); |  | 
|   74   void Callback(const std::string& arg, const AdblockPlus::JsValuePtr jsValue); |  | 
|   75  |  | 
|   76 private: |  | 
|   77   const JniGlobalReference<jclass>::Ptr jsValueClass; |  | 
|   78 }; |  | 
|   79  |  | 
|   80 class JniLogSystemCallback : public JniCallbackBase, public AdblockPlus::LogSyst
     em |  | 
|   81 { |  | 
|   82 public: |  | 
|   83   JniLogSystemCallback(JNIEnv* env, jobject callbackObject); |  | 
|   84   void operator()(AdblockPlus::LogSystem::LogLevel logLevel, const std::string& 
     message, const std::string& source); |  | 
|   85  |  | 
|   86 private: |  | 
|   87   const JniGlobalReference<jclass>::Ptr logLevelClass; |  | 
|   88 }; |  | 
|   89  |  | 
|   90 class JniShowNotificationCallback : public JniCallbackBase |  | 
|   91 { |  | 
|   92 public: |  | 
|   93   JniShowNotificationCallback(JNIEnv* env, jobject callbackObject); |  | 
|   94   void Callback(const AdblockPlus::NotificationPtr&); |  | 
|   95  |  | 
|   96 private: |  | 
|   97   const JniGlobalReference<jclass>::Ptr notificationClass; |  | 
|   98 }; |  | 
|   99  |  | 
|  100 class JniWebRequest : public JniCallbackBase, public AdblockPlus::WebRequest |  | 
|  101 { |  | 
|  102 public: |  | 
|  103   JniWebRequest(JNIEnv* env, jobject callbackObject); |  | 
|  104   AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea
     derList& requestHeaders) const; |  | 
|  105  |  | 
|  106 private: |  | 
|  107   jobject NewTuple(JNIEnv* env, const std::string& a, const std::string& b) cons
     t; |  | 
|  108  |  | 
|  109   const JniGlobalReference<jclass>::Ptr tupleClass; |  | 
|  110   const JniGlobalReference<jclass>::Ptr serverResponseClass; |  | 
|  111 }; |  | 
|  112  |  | 
|  113 #endif /* JNICALLBACKS_H */ |  | 
| OLD | NEW |