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

Unified Diff: jni/Utils.cpp

Issue 5327480814567424: Issue 1108 - Support notifications (Closed)
Patch Set: Only one Notification displayed now Created Feb. 18, 2015, 3:42 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « jni/Utils.h ('k') | src/org/adblockplus/android/ABPEngine.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jni/Utils.cpp
diff --git a/jni/Utils.cpp b/jni/Utils.cpp
index ad7b5054de7acf72316126c83bcebb24171be229..9845b4d4c1cf5ea3e5449b0ff431143702cf3243 100644
--- a/jni/Utils.cpp
+++ b/jni/Utils.cpp
@@ -86,3 +86,39 @@ JNIEnvAcquire::~JNIEnvAcquire()
javaVM->DetachCurrentThread();
}
}
+
+template<typename T>
+static jobject NewJniObject(JNIEnv* env, const T& value, const char* javaClass)
+{
+ if (!value.get())
+ {
+ return 0;
+ }
+
+ JniLocalReference<jclass> clazz(
+ env,
+ env->FindClass(javaClass));
+ jmethodID method = env->GetMethodID(*clazz, "<init>", "(J)V");
+
+ return env->NewObject(
+ *clazz,
+ method,
+ JniPtrToLong(new T(value)));
+}
+
+jobject NewJniFilter(JNIEnv* env, const AdblockPlus::FilterPtr& filter)
+{
+ return NewJniObject(env, filter, PKG("Filter"));
+}
+
+jobject NewJniSubscription(JNIEnv* env,
+ const AdblockPlus::SubscriptionPtr& subscription)
+{
+ return NewJniObject(env, subscription, PKG("Subscription"));
+}
+
+jobject NewJniNotification(JNIEnv* env,
+ const AdblockPlus::NotificationPtr& notification)
+{
+ return NewJniObject(env, notification, PKG("Notification"));
+}
« no previous file with comments | « jni/Utils.h ('k') | src/org/adblockplus/android/ABPEngine.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld