fix WRONG feed article counting

This commit is contained in:
Martin Rotter 2023-08-21 08:42:06 +02:00
parent ac4836d140
commit 0fbefcdca9
4 changed files with 100 additions and 178 deletions

View File

@ -422,89 +422,89 @@ version by clicking this popup notification.</source>
<context>
<name>DownloadItem</name>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="262"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="272"/>
<source>Error opening output file: %1</source>
<translation>Error opening output file: %1</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="106"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="110"/>
<source>Select destination for downloaded file</source>
<translation>Select destination for downloaded file</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="288"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="298"/>
<source>Error: %1</source>
<translation>Error: %1</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="132"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="137"/>
<source>Download directory couldn&apos;t be created</source>
<translation>Download directory couldn&apos;t be created</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="273"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="283"/>
<source>Error when saving file: %1</source>
<translation>Error when saving file: %1</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="380"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="390"/>
<source>%1 of %2 (%3 per second) - %4</source>
<translation>%1 of %2 (%3 per second) - %4</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="390"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="401"/>
<source>%1 of %2 - download completed</source>
<translation>%1 of %2 - download completed</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="212"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="217"/>
<source>Cannot open file</source>
<translation>Cannot open file</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="212"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="218"/>
<source>Cannot open output file. Open it manually.</source>
<translation>Cannot open output file. Open it manually.</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="220"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="228"/>
<source>Cannot open directory</source>
<translation>Cannot open directory</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="221"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="229"/>
<source>Cannot open output directory. Open it manually.</source>
<translation>Cannot open output directory. Open it manually.</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="431"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="442"/>
<source>Download finished</source>
<translation>Download finished</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="432"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="443"/>
<source>File &apos;%1&apos; is downloaded.
Click here to open parent directory.</source>
<translation>File &apos;%1&apos; is downloaded.
Click here to open parent directory.</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="442"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="454"/>
<source>URL: %1</source>
<translation>URL: %1</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="443"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="455"/>
<source>Local file: %1</source>
<translation>Local file: %1</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="112"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="116"/>
<source>Selection of local file cancelled.</source>
<translation>Selection of local file cancelled.</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="435"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="447"/>
<source>Open folder</source>
<translation type="unfinished"></translation>
</message>
@ -537,7 +537,7 @@ Click here to open parent directory.</translation>
<context>
<name>DownloadManager</name>
<message numerus="yes">
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="725"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="742"/>
<source>%n minutes remaining</source>
<translation type="unfinished">
<numerusform></numerusform>
@ -545,7 +545,7 @@ Click here to open parent directory.</translation>
</translation>
</message>
<message numerus="yes">
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="729"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="746"/>
<source>%n seconds remaining</source>
<translation type="unfinished">
<numerusform></numerusform>
@ -553,27 +553,12 @@ Click here to open parent directory.</translation>
</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="741"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="758"/>
<source>bytes</source>
<translation>bytes</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="745"/>
<source>kB</source>
<translation>kB</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="749"/>
<source>MB</source>
<translation>MB</translation>
</message>
<message>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="753"/>
<source>GB</source>
<translation>GB</translation>
</message>
<message numerus="yes">
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="583"/>
<location filename="../src/librssguard/network-web/downloadmanager.cpp" line="599"/>
<source>Downloading %n file(s)...</source>
<translation type="unfinished">
<numerusform></numerusform>
@ -1285,22 +1270,17 @@ QtWebEngine cache folder -&gt; &quot;%7&quot;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/services/gmail/gui/formaddeditemail.ui" line="35"/>
<source>...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/services/gmail/gui/formaddeditemail.ui" line="50"/>
<location filename="../src/librssguard/services/gmail/gui/formaddeditemail.ui" line="46"/>
<source>Contents of your e-mail message</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/services/gmail/gui/formaddeditemail.ui" line="67"/>
<location filename="../src/librssguard/services/gmail/gui/formaddeditemail.ui" line="63"/>
<source>Subject</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/services/gmail/gui/formaddeditemail.ui" line="77"/>
<location filename="../src/librssguard/services/gmail/gui/formaddeditemail.ui" line="73"/>
<source>Title of your message</source>
<translation type="unfinished"></translation>
</message>
@ -1337,19 +1317,9 @@ QtWebEngine cache folder -&gt; &quot;%7&quot;</source>
<source>Edit label &apos;%1&apos;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/services/abstract/gui/formaddeditlabel.ui" line="19"/>
<source>...</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FormAddEditProbe</name>
<message>
<location filename="../src/librssguard/services/abstract/gui/formaddeditprobe.ui" line="17"/>
<source>...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/services/abstract/gui/formaddeditprobe.cpp" line="12"/>
<source>Name for your query</source>
@ -4028,26 +3998,15 @@ Login tokens expiration: %2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/richtexteditor/mrichtextedit.ui" line="388"/>
<location filename="../src/librssguard/gui/richtexteditor/mrichtextedit.ui" line="419"/>
<source>.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/richtexteditor/mrichtextedit.ui" line="416"/>
<location filename="../src/librssguard/gui/richtexteditor/mrichtextedit.ui" line="413"/>
<source>Text background color</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/richtexteditor/mrichtextedit.ui" line="435"/>
<location filename="../src/librssguard/gui/richtexteditor/mrichtextedit.ui" line="429"/>
<source>Font size</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/richtexteditor/mrichtextedit.ui" line="472"/>
<source>...</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/richtexteditor/mrichtextedit.cpp" line="67"/>
<source>Standard</source>
@ -4151,11 +4110,6 @@ Login tokens expiration: %2</source>
<source>Unknown error: &apos;%1&apos;.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/database/mariadbdriver.cpp" line="94"/>
<source>MariaDB</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>MessageBrowser</name>
@ -4334,11 +4288,6 @@ Login tokens expiration: %2</source>
<source>Title</source>
<translation>Title</translation>
</message>
<message>
<location filename="../src/librssguard/core/messagesmodel.cpp" line="287"/>
<source>Url</source>
<translation>Url</translation>
</message>
<message>
<location filename="../src/librssguard/core/messagesmodel.cpp" line="288"/>
<source>Author</source>
@ -4419,6 +4368,11 @@ Login tokens expiration: %2</source>
<source>feed icon</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/core/messagesmodel.cpp" line="287"/>
<source>URL</source>
<translation type="unfinished">URL </translation>
</message>
<message>
<location filename="../src/librssguard/core/messagesmodel.cpp" line="297"/>
<source>RTL</source>
@ -4860,25 +4814,15 @@ Login tokens expiration: %2</source>
<context>
<name>NetworkProxyDetails</name>
<message>
<location filename="../src/librssguard/gui/reusable/networkproxydetails.cpp" line="18"/>
<location filename="../src/librssguard/gui/reusable/networkproxydetails.cpp" line="21"/>
<source>No proxy</source>
<translation type="unfinished">No proxy</translation>
</message>
<message>
<location filename="../src/librssguard/gui/reusable/networkproxydetails.cpp" line="19"/>
<location filename="../src/librssguard/gui/reusable/networkproxydetails.cpp" line="22"/>
<source>System proxy</source>
<translation type="unfinished">System proxy</translation>
</message>
<message>
<location filename="../src/librssguard/gui/reusable/networkproxydetails.cpp" line="20"/>
<source>Socks5</source>
<translation type="unfinished">Socks5</translation>
</message>
<message>
<location filename="../src/librssguard/gui/reusable/networkproxydetails.cpp" line="21"/>
<source>Http</source>
<translation type="unfinished">Http</translation>
</message>
<message>
<location filename="../src/librssguard/gui/reusable/networkproxydetails.ui" line="14"/>
<source>Form</source>
@ -5920,11 +5864,6 @@ File filter for external e-mail selection dialog.</extracomment>
<source>Opera 12 or older</source>
<translation type="unfinished">Opera 12 or older</translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.cpp" line="185"/>
<source>Mozilla Thunderbird</source>
<translation type="unfinished">Mozilla Thunderbird</translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.cpp" line="300"/>
<source>Enter (optional) parameters:</source>
@ -5936,93 +5875,88 @@ File filter for external e-mail selection dialog.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="18"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="21"/>
<source>Network</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="24"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="27"/>
<source>Do not accept any incoming cookies</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="31"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="34"/>
<source>Enable HTTP/2</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="39"/>
<source>WebEngine</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="45"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="48"/>
<source>Custom &quot;QTWEBENGINE_CHROMIUM_FLAGS&quot; flags</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="55"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="58"/>
<source>Disable cache</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="63"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="66"/>
<source>External web browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="69"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="72"/>
<source>Always open hyperlinks in external web browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="89"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="203"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="92"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="206"/>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If unchecked, then default system-wide web browser is used.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="92"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="95"/>
<source>Use custom external web browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="104"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="107"/>
<source>Web browser executable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="116"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="119"/>
<source>Executable file of web browser</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="129"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="246"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="132"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="249"/>
<source>&amp;Browse</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="138"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="255"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="141"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="258"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.cpp" line="39"/>
<source>Parameters</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="148"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="265"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="151"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="268"/>
<source>Parameters passed to executable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="155"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="272"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="158"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="275"/>
<source>Use sample arguments for</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="169"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="172"/>
<source>Select browser</source>
<translation type="unfinished"></translation>
</message>
@ -6032,27 +5966,27 @@ File filter for external e-mail selection dialog.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="184"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="187"/>
<source>External e-mail client</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="206"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="209"/>
<source>Use custom external e-mail client</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="218"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="221"/>
<source>E-mail client executable</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="233"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="236"/>
<source>Executable file of e-mail client</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="286"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="289"/>
<source>Select client</source>
<translation type="unfinished"></translation>
</message>
@ -6064,22 +5998,22 @@ File filter for external e-mail selection dialog.</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="301"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="304"/>
<source>External tools</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="336"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="339"/>
<source>&amp;Add tool</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="346"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="349"/>
<source>&amp;Edit selected tool</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="356"/>
<location filename="../src/librssguard/gui/settings/settingsbrowsermail.ui" line="359"/>
<source>&amp;Delete selected tool</source>
<translation type="unfinished"></translation>
</message>
@ -6843,21 +6777,11 @@ Also, relaunch &quot;Settings&quot; dialog after you install Node.js.</source>
<source>Node.js has version %1.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsnodejs.cpp" line="110"/>
<source>Node.js: %1.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsnodejs.cpp" line="118"/>
<source>NPM has version %1.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsnodejs.cpp" line="121"/>
<source>NPM: %1.</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/librssguard/gui/settings/settingsnodejs.cpp" line="135"/>
<source>You cannot choose file, you have to choose FOLDER.</source>

View File

@ -36,17 +36,11 @@
#include <QtDebug>
#include <QtGlobal>
SimpleCrypt::SimpleCrypt() :
m_key(0),
m_compressionMode(CompressionAlways),
m_protectionMode(ProtectionHash),
m_lastError(ErrorNoError) {}
SimpleCrypt::SimpleCrypt()
: m_key(0), m_compressionMode(CompressionAlways), m_protectionMode(ProtectionHash), m_lastError(ErrorNoError) {}
SimpleCrypt::SimpleCrypt(quint64 key) :
m_key(key),
m_compressionMode(CompressionAlways),
m_protectionMode(ProtectionHash),
m_lastError(ErrorNoError) {
SimpleCrypt::SimpleCrypt(quint64 key)
: m_key(key), m_compressionMode(CompressionAlways), m_protectionMode(ProtectionHash), m_lastError(ErrorNoError) {
splitKey();
}
@ -86,13 +80,13 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) {
CryptoFlags flags = CryptoFlagNone;
if (m_compressionMode == CompressionAlways) {
ba = qCompress(ba, 9); //maximum compression
ba = qCompress(ba, 9); // maximum compression
flags |= CryptoFlagCompression;
}
else if (m_compressionMode == CompressionAuto) {
QByteArray compressed = qCompress(ba, 9);
if (compressed.count() < ba.count()) {
if (compressed.size() < ba.size()) {
ba = compressed;
flags |= CryptoFlagCompression;
}
@ -118,13 +112,13 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) {
integrityProtection += hash.result();
}
//prepend a random char to the string
// prepend a random char to the string
char randomChar = char(QRandomGenerator::global()->generate() & 0xFF);
ba = randomChar + integrityProtection + ba;
int pos(0);
char lastChar(0);
int cnt = ba.count();
int cnt = ba.size();
while (pos < cnt) {
ba[pos] = ba.at(pos) ^ m_keyParts.at(pos % 8) ^ lastChar;
@ -134,8 +128,8 @@ QByteArray SimpleCrypt::encryptToByteArray(QByteArray plaintext) {
QByteArray resultArray;
resultArray.append(char(0x03)); //version for future updates to algorithm
resultArray.append(char(flags)); //encryption flags
resultArray.append(char(0x03)); // version for future updates to algorithm
resultArray.append(char(flags)); // encryption flags
resultArray.append(ba);
m_lastError = ErrorNoError;
return resultArray;
@ -187,13 +181,13 @@ QByteArray SimpleCrypt::decryptToByteArray(QByteArray cypher) {
QByteArray ba = cypher;
if (cypher.count() < 3) {
if (cypher.size() < 3) {
return QByteArray();
}
char version = ba.at(0);
if (version != 3) { //we only work with version 3
if (version != 3) { // we only work with version 3
m_lastError = ErrorUnknownVersion;
qWarning() << "Invalid version or not a cyphertext.";
return QByteArray();
@ -203,7 +197,7 @@ QByteArray SimpleCrypt::decryptToByteArray(QByteArray cypher) {
ba = ba.mid(2);
int pos(0);
int cnt(ba.count());
int cnt(ba.size());
char lastChar = 0;
while (pos < cnt) {
@ -214,7 +208,7 @@ QByteArray SimpleCrypt::decryptToByteArray(QByteArray cypher) {
++pos;
}
ba = ba.mid(1); //chop off the random number at the start
ba = ba.mid(1); // chop off the random number at the start
bool integrityOk(true);
if (flags.testFlag(CryptoFlagChecksum)) {

View File

@ -58,15 +58,15 @@
class SimpleCrypt {
public:
/**
CompressionMode describes if compression will be applied to the data to be
encrypted.
*/
enum CompressionMode {
CompressionAuto, /*!< Only apply compression if that results in a shorter plaintext. */
CompressionAlways, /*!< Always apply compression. Note that for short inputs, a compression may result in longer data */
CompressionNever /*!< Never apply compression. */
CompressionAuto, /*!< Only apply compression if that results in a shorter plaintext. */
CompressionAlways, /*!< Always apply compression. Note that for short inputs, a compression may result in longer
data */
CompressionNever /*!< Never apply compression. */
};
/**
@ -78,19 +78,22 @@ class SimpleCrypt {
appears to be valid after decryption.
*/
enum IntegrityProtectionMode {
ProtectionNone, /*!< The integerity of the encrypted data is not protected. It is not really possible to detect a wrong key, for instance. */
ProtectionChecksum,/*!< A simple checksum is used to verify that the data is in order. If not, an empty string is returned. */
ProtectionHash /*!< A cryptographic hash is used to verify the integrity of the data. This method produces a much stronger, but longer check */
ProtectionNone, /*!< The integerity of the encrypted data is not protected. It is not really possible to detect a
wrong key, for instance. */
ProtectionChecksum, /*!< A simple checksum is used to verify that the data is in order. If not, an empty string is
returned. */
ProtectionHash /*!< A cryptographic hash is used to verify the integrity of the data. This method produces a much
stronger, but longer check */
};
/**
Error describes the type of error that occured.
*/
enum Error {
ErrorNoError, /*!< No error occurred. */
ErrorNoKeySet, /*!< No key was set. You can not encrypt or decrypt without a valid key. */
ErrorUnknownVersion, /*!< The version of this data is unknown, or the data is otherwise not valid. */
ErrorIntegrityFailed /*!< The integrity check of the data failed. Perhaps the wrong key was used. */
ErrorNoError, /*!< No error occurred. */
ErrorNoKeySet, /*!< No key was set. You can not encrypt or decrypt without a valid key. */
ErrorUnknownVersion, /*!< The version of this data is unknown, or the data is otherwise not valid. */
ErrorIntegrityFailed /*!< The integrity check of the data failed. Perhaps the wrong key was used. */
};
/**
@ -228,12 +231,14 @@ class SimpleCrypt {
*/
QByteArray decryptToByteArray(QByteArray cypher);
//enum to describe options that have been used for the encryption. Currently only one, but
//that only leaves room for future extensions like adding a cryptographic hash...
enum CryptoFlag {CryptoFlagNone = 0,
CryptoFlagCompression = 0x01,
CryptoFlagChecksum = 0x02,
CryptoFlagHash = 0x04};
// enum to describe options that have been used for the encryption. Currently only one, but
// that only leaves room for future extensions like adding a cryptographic hash...
enum CryptoFlag {
CryptoFlagNone = 0,
CryptoFlagCompression = 0x01,
CryptoFlagChecksum = 0x02,
CryptoFlagHash = 0x04
};
Q_DECLARE_FLAGS(CryptoFlags, CryptoFlag)

View File

@ -678,8 +678,7 @@ ArticleCounts DatabaseQueries::getMessageCountsForFeed(const QSqlDatabase& db,
q.setForwardOnly(true);
q.prepare(QSL("SELECT COUNT(*), SUM(is_read) FROM Messages "
"WHERE feed = :feed AND is_deleted = 0 AND is_pdeleted = 0 AND "
" is_read = 0 AND account_id = :account_id;"));
"WHERE feed = :feed AND is_deleted = 0 AND is_pdeleted = 0 AND account_id = :account_id;"));
q.bindValue(QSL(":feed"), feed_custom_id);
q.bindValue(QSL(":account_id"), account_id);