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

Delta Between Two Patch Sets: jni/JniSubscription.cpp

Issue 6606493159784448: New JNI bindings (Closed)
Left Patch Set: Added missing copyright header Created March 14, 2014, 11:37 a.m.
Right Patch Set: Removed TODO from AppInfo. Created April 11, 2014, 1:28 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « jni/JniLogSystem.cpp ('k') | jni/JniUpdaterCallback.cpp » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 <AdblockPlus.h> 18 #include <AdblockPlus.h>
19 #include "Utils.h" 19 #include "Utils.h"
20 #include "JniJsValue.h" 20 #include "JniJsValue.h"
21 21
22 static AdblockPlus::Subscription* GetSubscriptionPtr(jlong ptr) 22 static AdblockPlus::Subscription* GetSubscriptionPtr(jlong ptr)
23 { 23 {
24 return AdblockPlus::Android::JniLong2TypePtr<AdblockPlus::SubscriptionPtr>(ptr )->get(); 24 return JniLongToTypePtr<AdblockPlus::SubscriptionPtr>(ptr)->get();
25 } 25 }
26 26
27 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jsValue) 27 static jlong JNICALL JniCtor(JNIEnv* env, jclass clazz, jlong jsValue)
28 { 28 {
29 TRY 29 try
30 { 30 {
31 return AdblockPlus::Android::JniPtr2Long( 31 return JniPtrToLong(new AdblockPlus::SubscriptionPtr(new AdblockPlus::Subscr iption(JniGetJsValuePtr(jsValue))));
32 new AdblockPlus::SubscriptionPtr(new AdblockPlus::Subscription(AdblockPl us::Android::JniGetJsValuePtr(jsValue))));
33 } 32 }
34 CATCH_THROW_AND_RETURN(env, 0) 33 CATCH_THROW_AND_RETURN(env, 0)
35 } 34 }
36 35
37 static jboolean JNICALL JniIsListed(JNIEnv* env, jclass clazz, jlong ptr) 36 static jboolean JNICALL JniIsListed(JNIEnv* env, jclass clazz, jlong ptr)
38 { 37 {
39 TRY 38 try
40 { 39 {
41 return GetSubscriptionPtr(ptr)->IsListed() ? JNI_TRUE : JNI_FALSE; 40 return GetSubscriptionPtr(ptr)->IsListed() ? JNI_TRUE : JNI_FALSE;
42 } 41 }
43 CATCH_THROW_AND_RETURN(env, JNI_FALSE) 42 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
44 } 43 }
45 44
46 static void JNICALL JniAddToList(JNIEnv* env, jclass clazz, jlong ptr) 45 static void JNICALL JniAddToList(JNIEnv* env, jclass clazz, jlong ptr)
47 { 46 {
48 TRY 47 try
49 { 48 {
50 GetSubscriptionPtr(ptr)->AddToList(); 49 GetSubscriptionPtr(ptr)->AddToList();
51 } 50 }
52 CATCH_AND_THROW(env) 51 CATCH_AND_THROW(env)
53 } 52 }
54 53
55 static void JNICALL JniRemoveFromList(JNIEnv* env, jclass clazz, jlong ptr) 54 static void JNICALL JniRemoveFromList(JNIEnv* env, jclass clazz, jlong ptr)
56 { 55 {
57 TRY 56 try
58 { 57 {
59 GetSubscriptionPtr(ptr)->RemoveFromList(); 58 GetSubscriptionPtr(ptr)->RemoveFromList();
60 } 59 }
61 CATCH_AND_THROW(env) 60 CATCH_AND_THROW(env)
62 } 61 }
63 62
64 static void JNICALL JniUpdateFilters(JNIEnv* env, jclass clazz, jlong ptr) 63 static void JNICALL JniUpdateFilters(JNIEnv* env, jclass clazz, jlong ptr)
65 { 64 {
66 TRY 65 try
67 { 66 {
68 GetSubscriptionPtr(ptr)->UpdateFilters(); 67 GetSubscriptionPtr(ptr)->UpdateFilters();
69 } 68 }
70 CATCH_AND_THROW(env) 69 CATCH_AND_THROW(env)
71 } 70 }
72 71
73 static jboolean JNICALL JniIsUpdating(JNIEnv* env, jclass clazz, jlong ptr) 72 static jboolean JNICALL JniIsUpdating(JNIEnv* env, jclass clazz, jlong ptr)
74 { 73 {
75 TRY 74 try
76 { 75 {
77 return GetSubscriptionPtr(ptr)->IsUpdating() ? JNI_TRUE : JNI_FALSE; 76 return GetSubscriptionPtr(ptr)->IsUpdating() ? JNI_TRUE : JNI_FALSE;
78 } 77 }
79 CATCH_THROW_AND_RETURN(env, JNI_FALSE) 78 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
80 } 79 }
81 80
82 static jboolean JNICALL JniOperatorEquals(JNIEnv* env, jclass clazz, jlong ptr, jlong otherPtr) 81 static jboolean JNICALL JniOperatorEquals(JNIEnv* env, jclass clazz, jlong ptr, jlong otherPtr)
83 { 82 {
84 AdblockPlus::Subscription* me = GetSubscriptionPtr(ptr); 83 AdblockPlus::Subscription* me = GetSubscriptionPtr(ptr);
85 AdblockPlus::Subscription* other = GetSubscriptionPtr(otherPtr); 84 AdblockPlus::Subscription* other = GetSubscriptionPtr(otherPtr);
86 85
87 TRY 86 try
88 { 87 {
89 return *me == *other ? JNI_TRUE : JNI_FALSE; 88 return *me == *other ? JNI_TRUE : JNI_FALSE;
90 } 89 }
91 CATCH_THROW_AND_RETURN(env, JNI_FALSE) 90 CATCH_THROW_AND_RETURN(env, JNI_FALSE)
92 } 91 }
93 92
94 static JNINativeMethod methods[] = 93 static JNINativeMethod methods[] =
95 { 94 {
96 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor }, 95 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor },
97 { (char*)"isListed", (char*)"(J)Z", (void*)JniIsListed }, 96 { (char*)"isListed", (char*)"(J)Z", (void*)JniIsListed },
98 { (char*)"addToList", (char*)"(J)V", (void*)JniAddToList }, 97 { (char*)"addToList", (char*)"(J)V", (void*)JniAddToList },
99 { (char*)"removeFromList", (char*)"(J)V", (void*)JniRemoveFromList }, 98 { (char*)"removeFromList", (char*)"(J)V", (void*)JniRemoveFromList },
100 { (char*)"updateFilters", (char*)"(J)V", (void*)JniUpdateFilters }, 99 { (char*)"updateFilters", (char*)"(J)V", (void*)JniUpdateFilters },
101 { (char*)"isUpdating", (char*)"(J)Z", (void*)JniIsUpdating }, 100 { (char*)"isUpdating", (char*)"(J)Z", (void*)JniIsUpdating },
102 { (char*)"operatorEquals", (char*)"(JJ)Z", (void*)JniOperatorEquals }, }; 101 { (char*)"operatorEquals", (char*)"(JJ)Z", (void*)JniOperatorEquals }
102 };
103 103
104 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_android_api_Subscription_ registerNatives(JNIEnv *env, jclass clazz) 104 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_Subscripti on_registerNatives(JNIEnv *env, jclass clazz)
105 { 105 {
106 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 106 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
107 } 107 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld