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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 #include <string> | 18 #include <string> |
| 19 #include <sstream> |
| 20 #include <iostream> |
19 | 21 |
20 #include "Utils.h" | 22 #include "Utils.h" |
21 | 23 |
22 std::string JniJavaToStdString(JNIEnv* env, jstring str) | 24 std::string JniJavaToStdString(JNIEnv* env, jstring str) |
23 { | 25 { |
24 if (!str) | 26 if (!str) |
25 { | 27 { |
26 return std::string(); | 28 return std::string(); |
27 } | 29 } |
28 | 30 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 const AdblockPlus::SubscriptionPtr& subscription) | 117 const AdblockPlus::SubscriptionPtr& subscription) |
116 { | 118 { |
117 return NewJniObject(env, subscription, PKG("Subscription")); | 119 return NewJniObject(env, subscription, PKG("Subscription")); |
118 } | 120 } |
119 | 121 |
120 jobject NewJniNotification(JNIEnv* env, | 122 jobject NewJniNotification(JNIEnv* env, |
121 const AdblockPlus::NotificationPtr& notification) | 123 const AdblockPlus::NotificationPtr& notification) |
122 { | 124 { |
123 return NewJniObject(env, notification, PKG("Notification")); | 125 return NewJniObject(env, notification, PKG("Notification")); |
124 } | 126 } |
| 127 |
| 128 std::string JniStdStreamToStdString(std::istream *in) |
| 129 { |
| 130 std::string ret; |
| 131 char buffer[1024]; |
| 132 while (in->read(buffer, sizeof(buffer))) |
| 133 ret.append(buffer, sizeof(buffer)); |
| 134 ret.append(buffer, in->gcount()); |
| 135 return ret; |
| 136 } |
OLD | NEW |