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

Delta Between Two Patch Sets: jni/JniFilterEngine.cpp

Issue 5327480814567424: Issue 1108 - Support notifications (Closed)
Left Patch Set: Show Android notifications Created Feb. 17, 2015, 1:51 p.m.
Right Patch Set: Only one Notification displayed now Created Feb. 18, 2015, 3:42 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/Android.mk ('k') | jni/JniNotification.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 <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 JniGetNotificationToShow(JNIEnv* env, jclass clazz, jlong ptr, jstring jUrl) 121 static jobject JNICALL JniGetNextNotificationToShow(JNIEnv* env, jclass clazz, j long ptr, jstring jUrl)
122 { 122 {
123 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr); 123 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr);
124 std::string url; 124 std::string url = JniJavaToStdString(env, jUrl);
125 if (jUrl)
126 {
127 url = JniJavaToStdString(env, jUrl);
128 }
129 125
130 try 126 try
131 { 127 {
132 AdblockPlus::NotificationPtr notification = engine->GetNextNotificationToSho w(url); 128 AdblockPlus::NotificationPtr notification = engine->GetNextNotificationToSho w(url);
133 129
134 return NewJniNotification(env, notification); 130 return NewJniNotification(env, notification);
135 } 131 }
136 CATCH_THROW_AND_RETURN(env, 0); 132 CATCH_THROW_AND_RETURN(env, 0);
137 } 133 }
138 134
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 CATCH_AND_THROW(env) 347 CATCH_AND_THROW(env)
352 } 348 }
353 349
354 static JNINativeMethod methods[] = 350 static JNINativeMethod methods[] =
355 { 351 {
356 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor }, 352 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor },
357 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, 353 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun },
358 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter }, 354 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter },
359 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters }, 355 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters },
360 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription }, 356 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription },
361 { (char*)"getNotificationToShow", (char*)"(JLjava/lang/String;)" TYP("Notifica tion"), (void*)JniGetNotificationToShow }, 357 { (char*)"getNextNotificationToShow", (char*)"(JLjava/lang/String;)" TYP("Noti fication"), (void*)JniGetNextNotificationToShow },
362 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions }, 358 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions },
363 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions }, 359 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions },
364 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback }, 360 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback },
365 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback }, 361 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback },
366 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback }, 362 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback },
367 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback }, 363 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback },
368 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck }, 364 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck },
369 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors }, 365 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors },
370 { (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 },
371 { (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 },
372 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref }, 368 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref },
373 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, 369 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref },
374 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } 370 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor }
375 }; 371 };
376 372
377 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)
378 { 374 {
379 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); 375 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0]));
380 } 376 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld