Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: jni/abpEngine.cpp

Issue 5336189238247424: Populate AppInfo properly (Closed)
Patch Set: Created Nov. 15, 2013, 1:41 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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 11 matching lines...) Expand all
22 #include "Utils.h" 22 #include "Utils.h"
23 #include "debug.h" 23 #include "debug.h"
24 24
25 JavaVM* globalJvm; 25 JavaVM* globalJvm;
26 AdblockPlus::FilterEngine* filterEngine; 26 AdblockPlus::FilterEngine* filterEngine;
27 jobject jniObject; 27 jobject jniObject;
28 bool manualUpdate = false; 28 bool manualUpdate = false;
29 29
30 extern "C" 30 extern "C"
31 { 31 {
32 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_initialize(JNIEn v *pEnv, jobject, jstring basepath); 32 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_initialize(
33 JNIEnv *pEnv, jobject object, jstring basePath, jstring version,
34 jstring sdkVersion, jstring locale, jboolean developmentBuild);
33 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_release(JNIEnv * pEnv, jobject); 35 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_release(JNIEnv * pEnv, jobject);
34 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_isFirstRun(J NIEnv *pEnv, jobject); 36 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_isFirstRun(J NIEnv *pEnv, jobject);
35 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getListe dSubscriptions(JNIEnv *pEnv, jobject); 37 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getListe dSubscriptions(JNIEnv *pEnv, jobject);
36 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getRecom mendedSubscriptions(JNIEnv *pEnv, jobject); 38 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getRecom mendedSubscriptions(JNIEnv *pEnv, jobject);
37 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_addSubscription( JNIEnv *pEnv, jobject, jstring url); 39 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_addSubscription( JNIEnv *pEnv, jobject, jstring url);
38 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_removeSubscripti on(JNIEnv *pEnv, jobject, jstring url); 40 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_removeSubscripti on(JNIEnv *pEnv, jobject, jstring url);
39 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_refreshSubscript ion(JNIEnv *pEnv, jobject, jstring url); 41 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_refreshSubscript ion(JNIEnv *pEnv, jobject, jstring url);
40 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_actualizeSubscri ptionStatus(JNIEnv *pEnv, jobject, jstring url); 42 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_actualizeSubscri ptionStatus(JNIEnv *pEnv, jobject, jstring url);
41 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(JNIE nv *pEnv, jobject, jstring url, jstring contentType, jstring documentUrl); 43 JNIEXPORT jboolean JNICALL Java_org_adblockplus_android_ABPEngine_matches(JNIE nv *pEnv, jobject, jstring url, jstring contentType, jstring documentUrl);
42 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getSelec torsForDomain(JNIEnv *pEnv, jobject, jstring domain); 44 JNIEXPORT jobjectArray JNICALL Java_org_adblockplus_android_ABPEngine_getSelec torsForDomain(JNIEnv *pEnv, jobject, jstring domain);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 187
186 jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) 188 jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
187 { 189 {
188 return JNI_VERSION_1_6; 190 return JNI_VERSION_1_6;
189 } 191 }
190 192
191 void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved) 193 void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
192 { 194 {
193 } 195 }
194 196
195 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_initialize(JNIEnv *pEnv, jobject pObject, jstring basepath) 197 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_initialize(
198 JNIEnv *pEnv, jobject pObject, jstring basePath, jstring version,
199 jstring sdkVersion, jstring locale, jboolean developmentBuild)
196 { 200 {
197 D(D_WARN, "nativeInitialize()"); 201 D(D_WARN, "nativeInitialize()");
198 int status = pEnv->GetJavaVM(&globalJvm); 202 int status = pEnv->GetJavaVM(&globalJvm);
199 203
200 jniObject = pEnv->NewGlobalRef(pObject); 204 jniObject = pEnv->NewGlobalRef(pObject);
201 205
202 const std::string path = GetString(pEnv, basepath); 206 AdblockPlus::AppInfo appInfo;
207 appInfo.name = "adblockplusandroid";
208 appInfo.version = GetString(pEnv, version);
209 appInfo.application = "android";
210 appInfo.applicationVersion = GetString(pEnv, sdkVersion);
211 appInfo.locale = GetString(pEnv, locale);
212 appInfo.developmentBuild = developmentBuild;
203 213
204 AdblockPlus::AppInfo appInfo; 214 D(D_INFO, "AppInfo: name=%s, version=%s, application=%s, applicationVersion=%s , locale=%s, developmentBuild=%s",
205 // TODO Should be extracted from the manifest 215 appInfo.name.c_str(), appInfo.version.c_str(), appInfo.application.c_str(),
206 appInfo.version = "1.1.2"; 216 appInfo.applicationVersion.c_str(), appInfo.locale.c_str(),
207 appInfo.name = "adblockplusandroid"; 217 appInfo.developmentBuild ? "true" : "false");
208 appInfo.application = "android";
209 218
210 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New(appInfo)); 219 AdblockPlus::JsEnginePtr jsEngine(AdblockPlus::JsEngine::New(appInfo));
211 220
212 AdblockPlus::DefaultFileSystem* defaultFileSystem = new AdblockPlus::DefaultFi leSystem(); 221 AdblockPlus::DefaultFileSystem* defaultFileSystem = new AdblockPlus::DefaultFi leSystem();
213 AndroidLogSystem* androidLogSystem = new AndroidLogSystem(); 222 AndroidLogSystem* androidLogSystem = new AndroidLogSystem();
214 AndroidWebRequest* androidWebRequest = new AndroidWebRequest(globalJvm); 223 AndroidWebRequest* androidWebRequest = new AndroidWebRequest(globalJvm);
215 224
216 defaultFileSystem->SetBasePath(path); 225 defaultFileSystem->SetBasePath(GetString(pEnv, basePath));
217 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(androidLogSystem)); 226 jsEngine->SetLogSystem(AdblockPlus::LogSystemPtr(androidLogSystem));
218 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(defaultFileSystem)); 227 jsEngine->SetFileSystem(AdblockPlus::FileSystemPtr(defaultFileSystem));
219 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(androidWebRequest)); 228 jsEngine->SetWebRequest(AdblockPlus::WebRequestPtr(androidWebRequest));
220 jsEngine->SetEventCallback("updateAvailable", std::tr1::bind(&UpdateAvailableC allback, std::tr1::placeholders::_1)); 229 jsEngine->SetEventCallback("updateAvailable", std::tr1::bind(&UpdateAvailableC allback, std::tr1::placeholders::_1));
221 230
222 filterEngine = new AdblockPlus::FilterEngine(jsEngine); 231 filterEngine = new AdblockPlus::FilterEngine(jsEngine);
223 filterEngine->SetFilterChangeCallback(&FilterChangedCallback); 232 filterEngine->SetFilterChangeCallback(&FilterChangedCallback);
224 } 233 }
225 234
226 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_release(JNIEnv *pE nv, jobject) 235 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_release(JNIEnv *pE nv, jobject)
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 351 }
343 352
344 return ret; 353 return ret;
345 } 354 }
346 355
347 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_checkUpdates(JNIEn v *pEnv, jobject) 356 JNIEXPORT void JNICALL Java_org_adblockplus_android_ABPEngine_checkUpdates(JNIEn v *pEnv, jobject)
348 { 357 {
349 manualUpdate = true; 358 manualUpdate = true;
350 filterEngine->ForceUpdateCheck(UpdaterCallback); 359 filterEngine->ForceUpdateCheck(UpdaterCallback);
351 } 360 }
OLDNEW
« no previous file with comments | « no previous file | src/org/adblockplus/android/ABPEngine.java » ('j') | src/org/adblockplus/android/ABPEngine.java » ('J')

Powered by Google App Engine
This is Rietveld