| Index: jni/Utils.cpp |
| diff --git a/jni/Utils.cpp b/jni/Utils.cpp |
| index b4c7cb60e982458591b1c75958a25b3f9c13912c..c148c9527b4e0be7ce237daba83a30e2b4a85022 100644 |
| --- a/jni/Utils.cpp |
| +++ b/jni/Utils.cpp |
| @@ -1,6 +1,6 @@ |
| /* |
| * This file is part of Adblock Plus <http://adblockplus.org/>, |
| - * Copyright (C) 2006-2014 Eyeo GmbH |
| + * Copyright (C) 2006-2013 Eyeo GmbH |
|
Felix Dahlke
2014/03/28 08:29:00
Why this?
René Jeschke
2014/03/28 10:59:15
Ah, this was definitely a mistake. (Merge went wro
|
| * |
| * Adblock Plus is free software: you can redistribute it and/or modify |
| * it under the terms of the GNU General Public License version 3 as |
| @@ -15,6 +15,8 @@ |
| * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| */ |
| +#include <string> |
| + |
| #include "Utils.h" |
| #include "Debug.h" |
| @@ -36,3 +38,46 @@ const std::string GetString(JNIEnv *pEnv, jstring str) |
| return value; |
| } |
| + |
| +std::string AdblockPlus::Android::JniJava2StdString(JNIEnv* env, jstring str) |
| +{ |
| + if (!str) |
| + { |
| + return std::string(); |
| + } |
| + |
| + const char* cStr = env->GetStringUTFChars(str, 0); |
| + std::string ret(cStr); |
| + env->ReleaseStringUTFChars(str, cStr); |
| + |
| + return ret; |
| +} |
| + |
| +jobject AdblockPlus::Android::NewJniArrayList(JNIEnv* env) |
| +{ |
| + jclass clazz = env->FindClass("java/util/ArrayList"); |
| + jmethodID ctor = env->GetMethodID(clazz, "<init>", "()V"); |
| + return env->NewObject(clazz, ctor); |
| +} |
| + |
| +void AdblockPlus::Android::JniAddObjectToList(JNIEnv* env, jobject list, jobject value) |
| +{ |
| + jmethodID add = env->GetMethodID(env->GetObjectClass(list), "add", "(Ljava/lang/Object;)Z"); |
| + env->CallBooleanMethod(list, add, value); |
| +} |
| + |
| +void AdblockPlus::Android::JniThrowException(JNIEnv* env, const std::string& message) |
| +{ |
| + jclass clazz = env->FindClass(PKG("AdblockPlusException")); |
| + env->ThrowNew(clazz, message.c_str()); |
| +} |
| + |
| +void AdblockPlus::Android::JniThrowException(JNIEnv* env, const std::exception& e) |
| +{ |
| + JniThrowException(env, e.what()); |
| +} |
| + |
| +void AdblockPlus::Android::JniThrowException(JNIEnv* env) |
| +{ |
| + JniThrowException(env, "Unknown exception from libAdblockPlus"); |
| +} |