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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 "DownloadableSubscription.h" | 18 #include "DownloadableSubscription.h" |
19 | 19 |
20 ABP_NS_USING | 20 ABP_NS_USING |
21 | 21 |
22 DownloadableSubscription::DownloadableSubscription(const String& id) | 22 DownloadableSubscription::DownloadableSubscription(const String& id, const KeyVa
lues& properties) |
23 : Subscription(classType, id), mFixedTitle(false), mLastCheck(0), | 23 : Subscription(classType, id, properties), mFixedTitle(false), mLastCheck(0)
, |
24 mHardExpiration(0), mSoftExpiration(0), mLastDownload(0), mLastSuccess(0), | 24 mHardExpiration(0), mSoftExpiration(0), mLastDownload(0), mLastSuccess(0), |
25 mErrorCount(0), mDataRevision(0), mDownloadCount(0) | 25 mErrorCount(0), mDataRevision(0), mDownloadCount(0) |
26 { | 26 { |
27 SetTitle(id); | 27 const auto* titleProp = findPropertyValue(properties, u"title"_str); |
| 28 SetTitle(titleProp ? *titleProp : id); |
| 29 parseProperty(properties, mFixedTitle, u"fixedTitle"_str); |
| 30 parseProperty(properties, mHomepage, u"homepage"_str); |
| 31 parseProperty(properties, mLastCheck, u"lastCheck"_str); |
| 32 parseProperty(properties, mHardExpiration, u"expires"_str); |
| 33 parseProperty(properties, mSoftExpiration, u"softExpiration"_str); |
| 34 parseProperty(properties, mLastDownload, u"lastDownload"_str); |
| 35 parseProperty(properties, mDownloadStatus, u"downloadStatus"_str); |
| 36 parseProperty(properties, mLastSuccess, u"lastSuccess"_str); |
| 37 parseProperty(properties, mErrorCount, u"errors"_str); |
| 38 parseProperty(properties, mDataRevision, u"version"_str); |
| 39 parseProperty(properties, mRequiredVersion, u"requiredVersion"_str); |
| 40 parseProperty(properties, mDownloadCount, u"downloadCount"_str); |
28 } | 41 } |
29 | 42 |
30 OwnedString DownloadableSubscription::Serialize() const | 43 OwnedString DownloadableSubscription::SerializeProperties() const |
31 { | 44 { |
32 OwnedString result(Subscription::Serialize()); | 45 OwnedString result(Subscription::DoSerializeProperties()); |
33 if (mFixedTitle) | 46 if (mFixedTitle) |
34 result.append(u"fixedTitle=true\n"_str); | 47 result.append(u"fixedTitle=true\n"_str); |
35 if (!mHomepage.empty()) | 48 if (!mHomepage.empty()) |
36 { | 49 { |
37 result.append(u"homepage="_str); | 50 result.append(u"homepage="_str); |
38 result.append(mHomepage); | 51 result.append(mHomepage); |
39 result.append(u'\n'); | 52 result.append(u'\n'); |
40 } | 53 } |
41 if (mLastCheck) | 54 if (mLastCheck) |
42 { | 55 { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 result.append(u'\n'); | 106 result.append(u'\n'); |
94 } | 107 } |
95 if (mDownloadCount) | 108 if (mDownloadCount) |
96 { | 109 { |
97 result.append(u"downloadCount="_str); | 110 result.append(u"downloadCount="_str); |
98 result.append(mDownloadCount); | 111 result.append(mDownloadCount); |
99 result.append(u'\n'); | 112 result.append(u'\n'); |
100 } | 113 } |
101 return result; | 114 return result; |
102 } | 115 } |
OLD | NEW |