| 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   char buffer[32]; | 
|  | 32   if (mFixedTitle) | 
|  | 33     result.append(u"fixedTitle=true\n"_str); | 
|  | 34   if (!mHomepage.empty()) | 
|  | 35   { | 
|  | 36     result.append(u"homepage="_str); | 
|  | 37     result.append(mHomepage); | 
|  | 38     result.append(u'\n'); | 
|  | 39   } | 
|  | 40   if (mLastCheck) | 
|  | 41   { | 
|  | 42     result.append(u"lastCheck="_str); | 
|  | 43     int len = sprintf(buffer, "%.0f", mLastCheck); | 
|  | 44     result.append(buffer, len); | 
|  | 45     result.append(u'\n'); | 
|  | 46   } | 
|  | 47   if (mHardExpiration) | 
|  | 48   { | 
|  | 49     result.append(u"expires="_str); | 
|  | 50     int len = sprintf(buffer, "%.0f", mHardExpiration); | 
|  | 51     result.append(buffer, len); | 
|  | 52     result.append(u'\n'); | 
|  | 53   } | 
|  | 54   if (mSoftExpiration) | 
|  | 55   { | 
|  | 56     result.append(u"softExpiration="_str); | 
|  | 57     int len = sprintf(buffer, "%.0f", mSoftExpiration); | 
|  | 58     result.append(buffer, len); | 
|  | 59     result.append(u'\n'); | 
|  | 60   } | 
|  | 61   if (mLastDownload) | 
|  | 62   { | 
|  | 63     result.append(u"lastDownload="_str); | 
|  | 64     int len = sprintf(buffer, "%.0f", mLastDownload); | 
|  | 65     result.append(buffer, len); | 
|  | 66     result.append(u'\n'); | 
|  | 67   } | 
|  | 68   if (!mDownloadStatus.empty()) | 
|  | 69   { | 
|  | 70     result.append(u"downloadStatus="_str); | 
|  | 71     result.append(mDownloadStatus); | 
|  | 72     result.append(u'\n'); | 
|  | 73   } | 
|  | 74   if (mLastSuccess) | 
|  | 75   { | 
|  | 76     result.append(u"lastSuccess="_str); | 
|  | 77     int len = sprintf(buffer, "%.0f", mLastSuccess); | 
|  | 78     result.append(buffer, len); | 
|  | 79     result.append(u'\n'); | 
|  | 80   } | 
|  | 81   if (mErrorCount) | 
|  | 82   { | 
|  | 83     result.append(u"errors="_str); | 
|  | 84     int len = sprintf(buffer, "%i", mErrorCount); | 
|  | 85     result.append(buffer, len); | 
|  | 86     result.append(u'\n'); | 
|  | 87   } | 
|  | 88   if (mDataRevision) | 
|  | 89   { | 
|  | 90     result.append(u"version="_str); | 
|  | 91     int len = sprintf(buffer, "%.0f", mDataRevision); | 
|  | 92     result.append(buffer, len); | 
|  | 93     result.append(u'\n'); | 
|  | 94   } | 
|  | 95   if (!mRequiredVersion.empty()) | 
|  | 96   { | 
|  | 97     result.append(u"requiredVersion="_str); | 
|  | 98     result.append(mRequiredVersion); | 
|  | 99     result.append(u'\n'); | 
|  | 100   } | 
|  | 101   if (mDownloadCount) | 
|  | 102   { | 
|  | 103     result.append(u"downloadCount="_str); | 
|  | 104     int len = sprintf(buffer, "%i", mDownloadCount); | 
|  | 105     result.append(buffer, len); | 
|  | 106     result.append(u'\n'); | 
|  | 107   } | 
|  | 108   return result; | 
|  | 109 } | 
| OLD | NEW | 
|---|