LEFT | RIGHT |
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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 |
(...skipping 10 matching lines...) Expand all Loading... |
21 : Subscription(Type::DOWNLOADABLE, id), mFixedTitle(false), mLastCheck(0), | 21 : Subscription(Type::DOWNLOADABLE, id), mFixedTitle(false), mLastCheck(0), |
22 mHardExpiration(0), mSoftExpiration(0), mLastDownload(0), mLastSuccess(0), | 22 mHardExpiration(0), mSoftExpiration(0), mLastDownload(0), mLastSuccess(0), |
23 mErrorCount(0), mDataRevision(0), mDownloadCount(0) | 23 mErrorCount(0), mDataRevision(0), mDownloadCount(0) |
24 { | 24 { |
25 SetTitle(id); | 25 SetTitle(id); |
26 } | 26 } |
27 | 27 |
28 OwnedString DownloadableSubscription::Serialize() const | 28 OwnedString DownloadableSubscription::Serialize() const |
29 { | 29 { |
30 OwnedString result(Subscription::Serialize()); | 30 OwnedString result(Subscription::Serialize()); |
31 const std::size_t BUFFER_SIZE = 32; | |
32 char buffer[BUFFER_SIZE]; | |
33 if (mFixedTitle) | 31 if (mFixedTitle) |
34 result.append(u"fixedTitle=true\n"_str); | 32 result.append(u"fixedTitle=true\n"_str); |
35 if (!mHomepage.empty()) | 33 if (!mHomepage.empty()) |
36 { | 34 { |
37 result.append(u"homepage="_str); | 35 result.append(u"homepage="_str); |
38 result.append(mHomepage); | 36 result.append(mHomepage); |
39 result.append(u'\n'); | 37 result.append(u'\n'); |
40 } | 38 } |
41 if (mLastCheck) | 39 if (mLastCheck) |
42 { | 40 { |
43 result.append(u"lastCheck="_str); | 41 result.append(u"lastCheck="_str); |
44 int len = snprintf(buffer, BUFFER_SIZE, "%.0f", mLastCheck); | 42 result.append(mLastCheck); |
45 result.append(buffer, len); | |
46 result.append(u'\n'); | 43 result.append(u'\n'); |
47 } | 44 } |
48 if (mHardExpiration) | 45 if (mHardExpiration) |
49 { | 46 { |
50 result.append(u"expires="_str); | 47 result.append(u"expires="_str); |
51 int len = snprintf(buffer, BUFFER_SIZE, "%.0f", mHardExpiration); | 48 result.append(mHardExpiration); |
52 result.append(buffer, len); | |
53 result.append(u'\n'); | 49 result.append(u'\n'); |
54 } | 50 } |
55 if (mSoftExpiration) | 51 if (mSoftExpiration) |
56 { | 52 { |
57 result.append(u"softExpiration="_str); | 53 result.append(u"softExpiration="_str); |
58 int len = snprintf(buffer, BUFFER_SIZE, "%.0f", mSoftExpiration); | 54 result.append(mSoftExpiration); |
59 result.append(buffer, len); | |
60 result.append(u'\n'); | 55 result.append(u'\n'); |
61 } | 56 } |
62 if (mLastDownload) | 57 if (mLastDownload) |
63 { | 58 { |
64 result.append(u"lastDownload="_str); | 59 result.append(u"lastDownload="_str); |
65 int len = snprintf(buffer, BUFFER_SIZE, "%.0f", mLastDownload); | 60 result.append(mLastDownload); |
66 result.append(buffer, len); | |
67 result.append(u'\n'); | 61 result.append(u'\n'); |
68 } | 62 } |
69 if (!mDownloadStatus.empty()) | 63 if (!mDownloadStatus.empty()) |
70 { | 64 { |
71 result.append(u"downloadStatus="_str); | 65 result.append(u"downloadStatus="_str); |
72 result.append(mDownloadStatus); | 66 result.append(mDownloadStatus); |
73 result.append(u'\n'); | 67 result.append(u'\n'); |
74 } | 68 } |
75 if (mLastSuccess) | 69 if (mLastSuccess) |
76 { | 70 { |
77 result.append(u"lastSuccess="_str); | 71 result.append(u"lastSuccess="_str); |
78 int len = snprintf(buffer, BUFFER_SIZE, "%.0f", mLastSuccess); | 72 result.append(mLastSuccess); |
79 result.append(buffer, len); | |
80 result.append(u'\n'); | 73 result.append(u'\n'); |
81 } | 74 } |
82 if (mErrorCount) | 75 if (mErrorCount) |
83 { | 76 { |
84 result.append(u"errors="_str); | 77 result.append(u"errors="_str); |
85 int len = snprintf(buffer, BUFFER_SIZE, "%i", mErrorCount); | 78 result.append(mErrorCount); |
86 result.append(buffer, len); | |
87 result.append(u'\n'); | 79 result.append(u'\n'); |
88 } | 80 } |
89 if (mDataRevision) | 81 if (mDataRevision) |
90 { | 82 { |
91 result.append(u"version="_str); | 83 result.append(u"version="_str); |
92 int len = snprintf(buffer, BUFFER_SIZE, "%.0f", mDataRevision); | 84 result.append(mDataRevision); |
93 result.append(buffer, len); | |
94 result.append(u'\n'); | 85 result.append(u'\n'); |
95 } | 86 } |
96 if (!mRequiredVersion.empty()) | 87 if (!mRequiredVersion.empty()) |
97 { | 88 { |
98 result.append(u"requiredVersion="_str); | 89 result.append(u"requiredVersion="_str); |
99 result.append(mRequiredVersion); | 90 result.append(mRequiredVersion); |
100 result.append(u'\n'); | 91 result.append(u'\n'); |
101 } | 92 } |
102 if (mDownloadCount) | 93 if (mDownloadCount) |
103 { | 94 { |
104 result.append(u"downloadCount="_str); | 95 result.append(u"downloadCount="_str); |
105 int len = snprintf(buffer, BUFFER_SIZE, "%i", mDownloadCount); | 96 result.append(mDownloadCount); |
106 result.append(buffer, len); | |
107 result.append(u'\n'); | 97 result.append(u'\n'); |
108 } | 98 } |
109 return result; | 99 return result; |
110 } | 100 } |
LEFT | RIGHT |