Index: compiled/subscription/DownloadableSubscription.cpp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/compiled/subscription/DownloadableSubscription.cpp |
@@ -0,0 +1,109 @@ |
+/* |
+ * This file is part of Adblock Plus <https://adblockplus.org/>, |
+ * Copyright (C) 2006-2017 eyeo GmbH |
+ * |
+ * Adblock Plus is free software: you can redistribute it and/or modify |
+ * it under the terms of the GNU General Public License version 3 as |
+ * published by the Free Software Foundation. |
+ * |
+ * Adblock Plus is distributed in the hope that it will be useful, |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+ * GNU General Public License for more details. |
+ * |
+ * You should have received a copy of the GNU General Public License |
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
+ */ |
+ |
+#include "DownloadableSubscription.h" |
+ |
+DownloadableSubscription::DownloadableSubscription(const String& id) |
+ : Subscription(Type::DOWNLOADABLE, id), mFixedTitle(false), mLastCheck(0), |
+ mHardExpiration(0), mSoftExpiration(0), mLastDownload(0), mLastSuccess(0), |
+ mErrorCount(0), mDataRevision(0), mDownloadCount(0) |
+{ |
+ SetTitle(id); |
+} |
+ |
+OwnedString DownloadableSubscription::Serialize() const |
+{ |
+ OwnedString result(Subscription::Serialize()); |
+ char buffer[32]; |
+ if (mFixedTitle) |
+ result.append(u"fixedTitle=true\n"_str); |
+ if (!mHomepage.empty()) |
+ { |
+ result.append(u"homepage="_str); |
+ result.append(mHomepage); |
+ result.append(u'\n'); |
+ } |
+ if (mLastCheck) |
+ { |
+ result.append(u"lastCheck="_str); |
+ int len = sprintf(buffer, "%.0f", mLastCheck); |
hub
2017/03/31 03:17:21
I think we should use snprintf() here. Just to be
Wladimir Palant
2017/04/04 14:45:37
Right, this won't hurt.
|
+ result.append(buffer, len); |
+ result.append(u'\n'); |
+ } |
+ if (mHardExpiration) |
+ { |
+ result.append(u"expires="_str); |
+ int len = sprintf(buffer, "%.0f", mHardExpiration); |
+ result.append(buffer, len); |
+ result.append(u'\n'); |
+ } |
+ if (mSoftExpiration) |
+ { |
+ result.append(u"softExpiration="_str); |
+ int len = sprintf(buffer, "%.0f", mSoftExpiration); |
+ result.append(buffer, len); |
+ result.append(u'\n'); |
+ } |
+ if (mLastDownload) |
+ { |
+ result.append(u"lastDownload="_str); |
+ int len = sprintf(buffer, "%.0f", mLastDownload); |
+ result.append(buffer, len); |
+ result.append(u'\n'); |
+ } |
+ if (!mDownloadStatus.empty()) |
+ { |
+ result.append(u"downloadStatus="_str); |
+ result.append(mDownloadStatus); |
+ result.append(u'\n'); |
+ } |
+ if (mLastSuccess) |
+ { |
+ result.append(u"lastSuccess="_str); |
+ int len = sprintf(buffer, "%.0f", mLastSuccess); |
+ result.append(buffer, len); |
+ result.append(u'\n'); |
+ } |
+ if (mErrorCount) |
+ { |
+ result.append(u"errors="_str); |
+ int len = sprintf(buffer, "%i", mErrorCount); |
+ result.append(buffer, len); |
+ result.append(u'\n'); |
+ } |
+ if (mDataRevision) |
+ { |
+ result.append(u"version="_str); |
+ int len = sprintf(buffer, "%.0f", mDataRevision); |
+ result.append(buffer, len); |
+ result.append(u'\n'); |
+ } |
+ if (!mRequiredVersion.empty()) |
+ { |
+ result.append(u"requiredVersion="_str); |
+ result.append(mRequiredVersion); |
+ result.append(u'\n'); |
+ } |
+ if (mDownloadCount) |
+ { |
+ result.append(u"downloadCount="_str); |
+ int len = sprintf(buffer, "%i", mDownloadCount); |
+ result.append(buffer, len); |
+ result.append(u'\n'); |
+ } |
+ return result; |
+} |