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

Side by Side Diff: jni/JniFilterEngine.cpp

Issue 5327480814567424: Issue 1108 - Support notifications (Closed)
Patch Set: Created Jan. 30, 2015, 12:44 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
« no previous file with comments | « jni/Android.mk ('k') | jni/JniJsEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 109
110 try 110 try
111 { 111 {
112 AdblockPlus::SubscriptionPtr subscription = engine->GetSubscription(url); 112 AdblockPlus::SubscriptionPtr subscription = engine->GetSubscription(url);
113 113
114 return NewJniSubscription(env, subscription); 114 return NewJniSubscription(env, subscription);
115 } 115 }
116 CATCH_THROW_AND_RETURN(env, 0); 116 CATCH_THROW_AND_RETURN(env, 0);
117 } 117 }
118 118
119 static jobject JNICALL JniGetNotificationToShow(JNIEnv* env, jclass clazz, jlong ptr, jstring jUrl)
120 {
121 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr);
122 std::string url;
123 if (jUrl)
124 {
125 url = JniJavaToStdString(env, jUrl);
126 }
127
128 try
129 {
130 AdblockPlus::NotificationPtr notification = engine->GetNextNotificationToSho w(url);
131
132 return NewJniNotification(env, notification);
133 }
134 CATCH_THROW_AND_RETURN(env, 0);
135 }
136
119 static jobject JNICALL JniGetListedSubscriptions(JNIEnv* env, jclass clazz, jlon g ptr) 137 static jobject JNICALL JniGetListedSubscriptions(JNIEnv* env, jclass clazz, jlon g ptr)
120 { 138 {
121 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr); 139 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr);
122 140
123 try 141 try
124 { 142 {
125 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = engine->GetListedS ubscriptions(); 143 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = engine->GetListedS ubscriptions();
126 144
127 return SubscriptionsToArrayList(env, subscriptions); 145 return SubscriptionsToArrayList(env, subscriptions);
128 } 146 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 CATCH_AND_THROW(env) 333 CATCH_AND_THROW(env)
316 } 334 }
317 335
318 static JNINativeMethod methods[] = 336 static JNINativeMethod methods[] =
319 { 337 {
320 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor }, 338 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor },
321 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, 339 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun },
322 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter }, 340 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter },
323 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters }, 341 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters },
324 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription }, 342 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription },
343 { (char*)"getNotificationToShow", (char*)"(JLjava/lang/String;)" TYP("Notifica tion"), (void*)JniGetNotificationToShow },
325 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions }, 344 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions },
326 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions }, 345 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions },
327 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback }, 346 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback },
328 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback }, 347 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback },
329 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback }, 348 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback },
330 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback }, 349 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback },
331 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck }, 350 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck },
332 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors }, 351 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors },
333 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "Ljava/lang/String;)" TYP("Filter"), (void*)JniMatches }, 352 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "Ljava/lang/String;)" TYP("Filter"), (void*)JniMatches },
334 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany }, 353 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany },
335 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref }, 354 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref },
336 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, 355 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref },
337 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 356 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
338 }; 357 };
339 358
340 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) 359 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz)
341 { 360 {
342 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 361 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
343 } 362 }
OLDNEW
« no previous file with comments | « jni/Android.mk ('k') | jni/JniJsEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld