 Issue 5327480814567424:
  Issue 1108 - Support notifications  (Closed)
    
  
    Issue 5327480814567424:
  Issue 1108 - Support notifications  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| 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 Loading... | |
| 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) | |
| 
Felix Dahlke
2015/02/18 12:49:56
Should be called JniGetNextNotificationToShow, in
 
René Jeschke
2015/02/18 13:13:02
Done.
 | |
| 122 { | |
| 123 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr); | |
| 124 std::string url; | |
| 125 if (jUrl) | |
| 
Felix Dahlke
2015/02/18 12:49:56
Nit: JniJavaToStdString already does convert a nul
 
René Jeschke
2015/02/18 13:13:02
Hehe, ehem, sure ... I've written the function ...
 | |
| 126 { | |
| 127 url = JniJavaToStdString(env, jUrl); | |
| 128 } | |
| 129 | |
| 130 try | |
| 131 { | |
| 132 AdblockPlus::NotificationPtr notification = engine->GetNextNotificationToSho w(url); | |
| 133 | |
| 134 return NewJniNotification(env, notification); | |
| 135 } | |
| 136 CATCH_THROW_AND_RETURN(env, 0); | |
| 137 } | |
| 138 | |
| 121 static jobject JNICALL JniGetListedSubscriptions(JNIEnv* env, jclass clazz, jlon g ptr) | 139 static jobject JNICALL JniGetListedSubscriptions(JNIEnv* env, jclass clazz, jlon g ptr) | 
| 122 { | 140 { | 
| 123 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr); | 141 AdblockPlus::FilterEngine* engine = JniLongToTypePtr<AdblockPlus::FilterEngine >(ptr); | 
| 124 | 142 | 
| 125 try | 143 try | 
| 126 { | 144 { | 
| 127 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = engine->GetListedS ubscriptions(); | 145 std::vector<AdblockPlus::SubscriptionPtr> subscriptions = engine->GetListedS ubscriptions(); | 
| 128 | 146 | 
| 129 return SubscriptionsToArrayList(env, subscriptions); | 147 return SubscriptionsToArrayList(env, subscriptions); | 
| 130 } | 148 } | 
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 CATCH_AND_THROW(env) | 351 CATCH_AND_THROW(env) | 
| 334 } | 352 } | 
| 335 | 353 | 
| 336 static JNINativeMethod methods[] = | 354 static JNINativeMethod methods[] = | 
| 337 { | 355 { | 
| 338 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor }, | 356 { (char*)"ctor", (char*)"(J)J", (void*)JniCtor }, | 
| 339 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, | 357 { (char*)"isFirstRun", (char*)"(J)Z", (void*)JniIsFirstRun }, | 
| 340 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter }, | 358 { (char*)"getFilter", (char*)"(JLjava/lang/String;)" TYP("Filter"), (void*)Jni GetFilter }, | 
| 341 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters }, | 359 { (char*)"getListedFilters", (char*)"(J)Ljava/util/List;", (void*)JniGetListed Filters }, | 
| 342 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription }, | 360 { (char*)"getSubscription", (char*)"(JLjava/lang/String;)" TYP("Subscription") , (void*)JniGetSubscription }, | 
| 361 { (char*)"getNotificationToShow", (char*)"(JLjava/lang/String;)" TYP("Notifica tion"), (void*)JniGetNotificationToShow }, | |
| 343 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions }, | 362 { (char*)"getListedSubscriptions", (char*)"(J)Ljava/util/List;", (void*)JniGet ListedSubscriptions }, | 
| 344 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions }, | 363 { (char*)"fetchAvailableSubscriptions", (char*)"(J)Ljava/util/List;", (void*)J niFetchAvailableSubscriptions }, | 
| 345 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback }, | 364 { (char*)"setUpdateAvailableCallback", (char*)"(JJ)V", (void*)JniSetUpdateAvai lableCallback }, | 
| 346 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback }, | 365 { (char*)"removeUpdateAvailableCallback", (char*)"(J)V", (void*)JniRemoveUpdat eAvailableCallback }, | 
| 347 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback }, | 366 { (char*)"setFilterChangeCallback", (char*)"(JJ)V", (void*)JniSetFilterChangeC allback }, | 
| 348 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback }, | 367 { (char*)"removeFilterChangeCallback", (char*)"(J)V", (void*)JniRemoveFilterCh angeCallback }, | 
| 349 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck }, | 368 { (char*)"forceUpdateCheck", (char*)"(JJ)V", (void*)JniForceUpdateCheck }, | 
| 350 { (char*)"getElementHidingSelectors", (char*)"(JLjava/lang/String;)Ljava/util/ List;", (void*)JniGetElementHidingSelectors }, | 369 { (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 }, | 370 { (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 }, | 371 { (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 }, | 372 { (char*)"getPref", (char*)"(JLjava/lang/String;)" TYP("JsValue"), (void*)JniG etPref }, | 
| 354 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, | 373 { (char*)"setPref", (char*)"(JLjava/lang/String;J)V", (void*)JniSetPref }, | 
| 355 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 374 { (char*)"dtor", (char*)"(J)V", (void*)JniDtor } | 
| 356 }; | 375 }; | 
| 357 | 376 | 
| 358 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) | 377 extern "C" JNIEXPORT void JNICALL Java_org_adblockplus_libadblockplus_FilterEngi ne_registerNatives(JNIEnv *env, jclass clazz) | 
| 359 { | 378 { | 
| 360 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 379 env->RegisterNatives(clazz, methods, sizeof(methods) / sizeof(methods[0])); | 
| 361 } | 380 } | 
| OLD | NEW |