OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2017 eyeo GmbH |
| 4 * |
| 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 |
| 7 * published by the Free Software Foundation. |
| 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 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/>. |
| 16 */ |
| 17 |
| 18 #include "DownloadableSubscription.h" |
| 19 |
| 20 DownloadableSubscription::DownloadableSubscription(const String& id) |
| 21 : Subscription(Type::DOWNLOADABLE, id), mFixedTitle(false), mLastCheck(0), |
| 22 mHardExpiration(0), mSoftExpiration(0), mLastDownload(0), mLastSuccess(0), |
| 23 mErrorCount(0), mDataRevision(0), mDownloadCount(0) |
| 24 { |
| 25 SetTitle(id); |
| 26 } |
| 27 |
| 28 OwnedString DownloadableSubscription::Serialize() const |
| 29 { |
| 30 OwnedString result(Subscription::Serialize()); |
| 31 if (mFixedTitle) |
| 32 result.append(u"fixedTitle=true\n"_str); |
| 33 if (!mHomepage.empty()) |
| 34 { |
| 35 result.append(u"homepage="_str); |
| 36 result.append(mHomepage); |
| 37 result.append(u'\n'); |
| 38 } |
| 39 if (mLastCheck) |
| 40 { |
| 41 result.append(u"lastCheck="_str); |
| 42 result.append(static_cast<int64_t>(mLastCheck)); |
| 43 result.append(u'\n'); |
| 44 } |
| 45 if (mHardExpiration) |
| 46 { |
| 47 result.append(u"expires="_str); |
| 48 result.append(static_cast<int64_t>(mHardExpiration)); |
| 49 result.append(u'\n'); |
| 50 } |
| 51 if (mSoftExpiration) |
| 52 { |
| 53 result.append(u"softExpiration="_str); |
| 54 result.append(static_cast<int64_t>(mSoftExpiration)); |
| 55 result.append(u'\n'); |
| 56 } |
| 57 if (mLastDownload) |
| 58 { |
| 59 result.append(u"lastDownload="_str); |
| 60 result.append(static_cast<int64_t>(mLastDownload)); |
| 61 result.append(u'\n'); |
| 62 } |
| 63 if (!mDownloadStatus.empty()) |
| 64 { |
| 65 result.append(u"downloadStatus="_str); |
| 66 result.append(mDownloadStatus); |
| 67 result.append(u'\n'); |
| 68 } |
| 69 if (mLastSuccess) |
| 70 { |
| 71 result.append(u"lastSuccess="_str); |
| 72 result.append(static_cast<int64_t>(mLastSuccess)); |
| 73 result.append(u'\n'); |
| 74 } |
| 75 if (mErrorCount) |
| 76 { |
| 77 result.append(u"errors="_str); |
| 78 result.append(mErrorCount); |
| 79 result.append(u'\n'); |
| 80 } |
| 81 if (mDataRevision) |
| 82 { |
| 83 result.append(u"version="_str); |
| 84 result.append(static_cast<int64_t>(mDataRevision)); |
| 85 result.append(u'\n'); |
| 86 } |
| 87 if (!mRequiredVersion.empty()) |
| 88 { |
| 89 result.append(u"requiredVersion="_str); |
| 90 result.append(mRequiredVersion); |
| 91 result.append(u'\n'); |
| 92 } |
| 93 if (mDownloadCount) |
| 94 { |
| 95 result.append(u"downloadCount="_str); |
| 96 result.append(mDownloadCount); |
| 97 result.append(u'\n'); |
| 98 } |
| 99 return result; |
| 100 } |
OLD | NEW |