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: Even more renaming, ignore INVALID/QUESTION Created Feb. 18, 2015, 3 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 <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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 try 112 try
113 { 113 {
114 AdblockPlus::SubscriptionPtr subscription = engine->GetSubscription(url); 114 AdblockPlus::SubscriptionPtr subscription = engine->GetSubscription(url);
115 115
116 return NewJniSubscription(env, subscription); 116 return NewJniSubscription(env, subscription);
117 } 117 }
118 CATCH_THROW_AND_RETURN(env, 0); 118 CATCH_THROW_AND_RETURN(env, 0);
119 } 119 }
120 120
121 static jobject JNICALL JniGetNextNotificationToShow(JNIEnv* env, jclass clazz, j long ptr, jstring jUrl)
122 {
123 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr);
124 std::string url = JniJavaToStdString(env, jUrl);
125
126 try
127 {
128 AdblockPlus::NotificationPtr notification = engine->GetNextNotificationToSho w(url);
129
130 return NewJniNotification(env, notification);
131 }
132 CATCH_THROW_AND_RETURN(env, 0);
133 }
134
121 static jobject JNICALL JniGetListedSubscriptions(JNIEnv* env, jclass clazz, jlon g ptr) 135 static jobject JNICALL JniGetListedSubscriptions(JNIEnv* env, jclass clazz, jlon g ptr)
122 { 136 {
123 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr); 137 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr);
124 138
125 try 139 try
126 { 140 {
127 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = engine->GetListedS ubscriptions(); 141 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = engine->GetListedS ubscriptions();
128 142
129 return SubscriptionsToArrayList(env, subscriptions); 143 return SubscriptionsToArrayList(env, subscriptions);
130 } 144 }
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 CATCH_AND_THROW(env) 347 CATCH_AND_THROW(env)
334 } 348 }
335 349
336 static JNINativeMethod methods[] = 350 static JNINativeMethod methods[] =
337 { 351 {
338 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor }, 352 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor },
339 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, 353 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun },
340 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter }, 354 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter },
341 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters }, 355 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters },
342 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription }, 356 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription },
357 { (char*)"getNextNotificationToShow", (char*)"(JLjava/lang/String;)" TYP("Noti fication"), (void*)JniGetNextNotificationToShow },
343 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions }, 358 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions },
344 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions }, 359 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions },
345 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback }, 360 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback },
346 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback }, 361 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback },
347 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback }, 362 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback },
348 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback }, 363 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback },
349 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck }, 364 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck },
350 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors }, 365 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors },
351 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "Ljava/lang/String;)" TYP("Filter"), (void*)JniMatches }, 366 { (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*)JniMatchesMany }, 367 { (char*)"matches", (char*)"(JLjava/lang/String;" TYP("FilterEngine$ContentTyp e") "[Ljava/lang/String;)" TYP("Filter"), (void*)JniMatchesMany },
353 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref }, 368 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref },
354 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, 369 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref },
355 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 370 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
356 }; 371 };
357 372
358 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) 373 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz)
359 { 374 {
360 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 375 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
361 } 376 }
OLDNEW

Powered by Google App Engine
This is Rietveld