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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 if (!subscription.get()) | 155 if (!subscription.get()) |
156 { | 156 { |
157 return 0; | 157 return 0; |
158 } | 158 } |
159 | 159 |
160 jclass clazz = env->FindClass(PKG("Subscription")); | 160 jclass clazz = env->FindClass(PKG("Subscription")); |
161 jmethodID method = env->GetMethodID(clazz, "<init>", "(J)V"); | 161 jmethodID method = env->GetMethodID(clazz, "<init>", "(J)V"); |
162 return env->NewObject(clazz, method, JniPtrToLong(new AdblockPlus::Subscriptio
nPtr(subscription))); | 162 return env->NewObject(clazz, method, JniPtrToLong(new AdblockPlus::Subscriptio
nPtr(subscription))); |
163 } | 163 } |
164 | 164 |
| 165 inline jobject NewJniNotification(JNIEnv* env, const AdblockPlus::NotificationPt
r& notification) |
| 166 { |
| 167 if (!notification.get()) |
| 168 { |
| 169 return 0; |
| 170 } |
| 171 |
| 172 jclass clazz = env->FindClass(PKG("Notification")); |
| 173 jmethodID method = env->GetMethodID(clazz, "<init>", "(J)V"); |
| 174 return env->NewObject(clazz, method, JniPtrToLong(new AdblockPlus::Notificatio
nPtr(notification))); |
| 175 } |
| 176 |
165 #define CATCH_AND_THROW(jEnv) \ | 177 #define CATCH_AND_THROW(jEnv) \ |
166 catch (const std::exception& except) \ | 178 catch (const std::exception& except) \ |
167 { \ | 179 { \ |
168 JniThrowException(jEnv, except); \ | 180 JniThrowException(jEnv, except); \ |
169 } \ | 181 } \ |
170 catch (...) \ | 182 catch (...) \ |
171 { \ | 183 { \ |
172 JniThrowException(jEnv); \ | 184 JniThrowException(jEnv); \ |
173 } | 185 } |
174 | 186 |
175 #define CATCH_THROW_AND_RETURN(jEnv, retVal) \ | 187 #define CATCH_THROW_AND_RETURN(jEnv, retVal) \ |
176 catch (const std::exception& except) \ | 188 catch (const std::exception& except) \ |
177 { \ | 189 { \ |
178 JniThrowException(jEnv, except); \ | 190 JniThrowException(jEnv, except); \ |
179 return retVal; \ | 191 return retVal; \ |
180 } \ | 192 } \ |
181 catch (...) \ | 193 catch (...) \ |
182 { \ | 194 { \ |
183 JniThrowException(jEnv); \ | 195 JniThrowException(jEnv); \ |
184 return retVal; \ | 196 return retVal; \ |
185 } | 197 } |
186 | 198 |
187 #endif | 199 #endif |
OLD | NEW |