| 1 | // For license of this file, see <project-root-folder>/LICENSE.md.cxx . . $ `<file>/src/librssguard/miscellaneous/textfactory.cpp`/ |
| 2 | |
| 3 | #include "miscellaneous/textfactory.h"cxx . . $ `<file>/src/librssguard/miscellaneous/textfactory.h`/ |
| 4 | |
| 5 | #include "3rd-party/boolinq/boolinq.h"cxx . . $ `<file>/src/librssguard/3rd-party/boolinq/boolinq.h`/ |
| 6 | #include "3rd-party/sc/simplecrypt.h"cxx . . $ `<file>/src/librssguard/3rd-party/sc/simplecrypt.h`/ |
| 7 | #include "definitions/definitions.h"cxx . . $ `<file>/src/librssguard/definitions/definitions.h`/ |
| 8 | #include "exceptions/applicationexception.h"cxx . . $ `<file>/src/librssguard/exceptions/applicationexception.h`/ |
| 9 | #include "miscellaneous/application.h"cxx . . $ `<file>/src/librssguard/miscellaneous/application.h`/ |
| 10 | #include "miscellaneous/iofactory.h"cxx . . $ `<file>/src/librssguard/miscellaneous/iofactory.h`/ |
| 11 | #include "miscellaneous/settings.h"cxx . . $ `<file>/src/librssguard/miscellaneous/settings.h`/ |
| 12 | |
| 13 | #include <QDir> |
| 14 | #include <QLocale> |
| 15 | #include <QRandomGenerator64> |
| 16 | #include <QString> |
| 17 | #include <QStringList> |
| 18 | #include <QTextDocument> |
| 19 | |
| 20 | quint64cxx . . $ quint64# TextFactorycxx . . $ TextFactory#::s_encryptionKeycxx . . $ TextFactory#s_encryptionKey. = 0x0; |
| 21 | |
| 22 | TextFactorycxx . . $ TextFactory#::TextFactorycxx . . $ TextFactory#TextFactory(49f6e7a06ebc5aa8).() = default; |
| 23 | |
| 24 | QStringcxx . . $ QString# TextFactorycxx . . $ TextFactory#::extractUsernameFromEmailcxx . . $ TextFactory#extractUsernameFromEmail(fd988a2ab94d906b).(const QStringcxx . . $ QString#& email_address) { |
| 25 | const int zav = email_address.indexOfcxx . . $ QString#indexOf(7f9dda0319baab1e).('@'cxx . . $ QChar#QChar(93d577a3e9528307).); |
| 26 | |
| 27 | if (zav >= 0) { |
| 28 | return email_address.midcxx . . $ QString#mid(5eea715ff28b9227).(0, zav); |
| 29 | } |
| 30 | else { |
| 31 | return email_addresscxx . . $ QString#QString(132dd6869045752b).; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | QColorcxx . . $ QColor# TextFactorycxx . . $ TextFactory#::generateColorFromTextcxx . . $ TextFactory#generateColorFromText(9e6ac3906205eeaf).(const QStringcxx . . $ QString#& text) { |
| 36 | quint32cxx . . $ quint32# color = 0; |
| 37 | |
| 38 | for (const QCharcxx . . $ QChar# chr : text) { |
| 39 | color += chr.unicodecxx . . $ QChar#unicode(a45d90656f9dea2b).(); |
| 40 | } |
| 41 | |
| 42 | // NOTE: https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically |
| 43 | int hue = color % 360; |
| 44 | |
| 45 | return QColorcxx . . $ QColor#::fromHsvcxx . . $ QColor#fromHsv(785b6f35cae7fe1c).(hue, 200, 240); |
| 46 | } |
| 47 | |
| 48 | QColorcxx . . $ QColor# TextFactorycxx . . $ TextFactory#::generateRandomColorcxx . . $ TextFactory#generateRandomColor(f5857e16334315e5).() { |
| 49 | int hue = QRandomGeneratorcxx . . $ QRandomGenerator#::globalcxx . . $ QRandomGenerator#global(2e1e8c46584af0f7).()->generatecxx . . $ QRandomGenerator#generate(db52760e79bf9054).() % 360; |
| 50 | auto clr = QColorcxx . . $ QColor#::fromHsvcxx . . $ QColor#fromHsv(785b6f35cae7fe1c).(hue, 200, 240); |
| 51 | |
| 52 | return clr; |
| 53 | } |
| 54 | |
| 55 | int TextFactorycxx . . $ TextFactory#::stringHeightcxx . . $ TextFactory#stringHeight(7fa286f5963668da).(const QStringcxx . . $ QString#& string, const QFontMetricscxx . . $ QFontMetrics#& metrics) { |
| 56 | const int count_lines = string.splitcxx . . $ QString#split(4e27fcb098d1f780).(QL1Ccxx . . $ `src/librssguard/definitions/definitions.h:455:9`!('\n')).sizecxx . . $ QList#size(6b0412d51016192f).(); |
| 57 | |
| 58 | return metrics.heightcxx . . $ QFontMetrics#height(455f465bc33b4cdf).() * count_lines; |
| 59 | } |
| 60 | |
| 61 | int TextFactorycxx . . $ TextFactory#::stringWidthcxx . . $ TextFactory#stringWidth(7fa286f5963668da).(const QStringcxx . . $ QString#& string, const QFontMetricscxx . . $ QFontMetrics#& metrics) { |
| 62 | const QStringListcxx . . $ QStringList# lines = string.splitcxx . . $ QString#split(4e27fcb098d1f780).(QL1Ccxx . . $ `src/librssguard/definitions/definitions.h:455:9`!('\n')); |
| 63 | int width = 0; |
| 64 | |
| 65 | for (const QStringcxx . . $ QString#& line : lines) { |
| 66 | int line_width = metrics.horizontalAdvancecxx . . $ QFontMetrics#horizontalAdvance(91f46685ef4c12b5).(line); |
| 67 | |
| 68 | if (line_width > width) { |
| 69 | width = line_width; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | return width; |
| 74 | } |
| 75 | |
| 76 | bool TextFactorycxx . . $ TextFactory#::couldBeHtmlcxx . . $ TextFactory#couldBeHtml(e1defb592416720d).(const QStringcxx . . $ QString#& string) { |
| 77 | const QStringcxx . . $ QString# sstring = string.simplifiedcxx . . $ QString#simplified(dca2c5857e9adf82).(); |
| 78 | |
| 79 | static QRegularExpressioncxx . . $ QRegularExpression# |
| 80 | tag_expcxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("^<(" |
| 81 | "a|abbr|address|area|article|aside|audio|" |
| 82 | "b|base|bdi|bdo|blockquote|body|br|button|" |
| 83 | "canvas|caption|cite|code|col|colgroup|" |
| 84 | "data|datalist|dd|del|details|dfn|dialog|div|dl|dt|" |
| 85 | "em|embed|" |
| 86 | "fieldset|figcaption|figure|footer|form|" |
| 87 | "h1|h2|h3|h4|h5|h6|head|header|hgroup|hr|html|" |
| 88 | "i|iframe|img|input|ins|" |
| 89 | "kbd|" |
| 90 | "label|legend|li|link|" |
| 91 | "main|map|mark|menu|meta|meter|" |
| 92 | "nav|noscript|" |
| 93 | "object|ol|optgroup|option|output|" |
| 94 | "p|picture|pre|progress|" |
| 95 | "q|" |
| 96 | "rp|rt|ruby|" |
| 97 | "s|samp|script|search|section|select|slot|small|source|span|strong|style|sub|summary|sup|" |
| 98 | "table|tbody|td|template|textarea|tfoot|th|thead|time|title|tr|track|" |
| 99 | "u|ul|" |
| 100 | "var|video|" |
| 101 | "wbr|" |
| 102 | "!" |
| 103 | ")")); |
| 104 | |
| 105 | return tag_exp.matchcxx . . $ QRegularExpression#match(d076266091fa4922).(sstring).hasMatchcxx . . $ QRegularExpressionMatch#hasMatch(50ce9a9e25b4a850).() || Qtcxx . . $ Qt/::mightBeRichTextcxx . . $ Qt/mightBeRichText(e31aa80dbfa39f3d).(sstringcxx . . $ QAnyStringView#QAnyStringView(132dd6869045752b).); |
| 106 | } |
| 107 | |
| 108 | QDateTimecxx . . $ QDateTime# TextFactorycxx . . $ TextFactory#::parseDateTimecxx . . $ TextFactory#parseDateTime(a28da78309843c43).(const QStringcxx . . $ QString#& date_time, QStringcxx . . $ QString#* used_dt_format) { |
| 109 | QStringcxx . . $ QString# input_date = date_timecxx . . $ QString#QString(132dd6869045752b)..simplifiedcxx . . $ QString#simplified(dca2c5857e9adf82).() |
| 110 | .replacecxx . . $ QString#replace(192e628656427d1c).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("GMT"), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("+0000")) |
| 111 | .replacecxx . . $ QString#replace(192e628656427d1c).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("UTC"), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("+0000")) |
| 112 | .replacecxx . . $ QString#replace(192e628656427d1c).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("UT"), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("+0000")) |
| 113 | .replacecxx . . $ QString#replace(192e628656427d1c).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("EDT"), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("-0400")) |
| 114 | .replacecxx . . $ QString#replace(192e628656427d1c).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("EST"), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("-0500")) |
| 115 | .replacecxx . . $ QString#replace(192e628656427d1c).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("PDT"), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("-0700")) |
| 116 | .replacecxx . . $ QString#replace(192e628656427d1c).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("PST"), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("-0800")) |
| 117 | .replacecxx . . $ QString#replace(bb08417d5c5b4bb6).(QRegularExpressioncxx . . $ QRegularExpression#QRegularExpression(4279d2539df7cd4a).(QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\\.(\\d{3})\\d{3}")), QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(".\\1")); |
| 118 | |
| 119 | if (input_date.isEmptycxx . . $ QString#isEmpty(3482b152b9333168).()) { |
| 120 | return QDateTimecxx . . $ QDateTime#QDateTime(ced63f7c635d850d).(); |
| 121 | } |
| 122 | |
| 123 | QLocalecxx . . $ QLocale# localecxx . . $ QLocale#QLocale(ed1ff50864f5f3dc).(QLocalecxx . . $ QLocale#::Languagecxx . . $ QLocale#Language#::Ccxx . . $ QLocale#C.); |
| 124 | QDateTimecxx . . $ QDateTime# dtcxx . . $ QDateTime#QDateTime(ced63f7c635d850d).; |
| 125 | QStringListcxx . . $ QStringList# date_patterns = dateTimePatternscxx . . $ TextFactory#dateTimePatterns(83e97a3b04836c1e).(true); |
| 126 | |
| 127 | if (used_dt_format != nullptr && !used_dt_format->isEmptycxx . . $ QString#isEmpty(3482b152b9333168).()) { |
| 128 | date_patterns.prependcxx . . $ QList#prepend(200d2dc08238a4ed).(*used_dt_format); |
| 129 | } |
| 130 | |
| 131 | // QDateTime dt1 = locale.toDateTime("GMT", "t"); |
| 132 | // QString dt2 = dt1.toString(); |
| 133 | |
| 134 | for (const QStringcxx . . $ QString#& pattern : stdcxx . . $ std/::as_constcxx . . $ std/as_const(1dc117cbefefc300).(date_patterns)) { |
| 135 | #if QT_VERSIONcxx . . $ `<external>/3898848398875472725/qtversionchecks.h:17:9`! >= 0x060700 // Qt >= 6.7.0 |
| 136 | dt =cxx . . $ QDateTime#`operator=`(6dbf9ff24243cdf2). locale.toDateTimecxx . . $ QLocale#toDateTime(ba5a78118bf3ff49).(input_date, pattern, 2000); |
| 137 | #else |
| 138 | dt = locale.toDateTime(input_date, pattern); |
| 139 | #endif |
| 140 | |
| 141 | if (dt.isValidcxx . . $ QDateTime#isValid(50ce9a9e25b4a850).()) { |
| 142 | // Make sure that this date/time is considered UTC. |
| 143 | dt =cxx . . $ QDateTime#`operator=`(6dbf9ff24243cdf2). dt.toUTCcxx . . $ QDateTime#toUTC(4e062b5c490497ac).(); |
| 144 | |
| 145 | if (used_dt_format != nullptr) { |
| 146 | used_dt_format->clearcxx . . $ QString#clear(49f6e7a06ebc5aa8).(); |
| 147 | used_dt_format->appendcxx . . $ QString#append(6a89d0b7f4d2681c).(pattern); |
| 148 | } |
| 149 | |
| 150 | return dtcxx . . $ QDateTime#QDateTime(a828cb3fdb02fcd1).; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | qCriticalNNcxx . . $ `src/librssguard/definitions/definitions.h:421:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_COREcxx . . $ `src/librssguard/definitions/definitions.h:178:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Date/time string NOT recognized:" <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(input_date); |
| 155 | return QDateTimecxx . . $ QDateTime#QDateTime(ced63f7c635d850d).(); |
| 156 | } |
| 157 | |
| 158 | QDateTimecxx . . $ QDateTime# TextFactorycxx . . $ TextFactory#::parseDateTimecxx . . $ TextFactory#parseDateTime(f757a3a63fdb8414).(qint64cxx . . $ qint64# milis_from_epoch) { |
| 159 | return QDateTimecxx . . $ QDateTime#::fromMSecsSinceEpochcxx . . $ QDateTime#fromMSecsSinceEpoch(3ddfaf8b563ea524).(milis_from_epoch, Qtcxx . . $ Qt/::TimeSpeccxx . . $ Qt/TimeSpec#::UTCcxx . . $ Qt/UTC.); |
| 160 | } |
| 161 | |
| 162 | QStringListcxx . . $ QStringList# TextFactorycxx . . $ TextFactory#::dateTimePatternscxx . . $ TextFactory#dateTimePatterns(83e97a3b04836c1e).(bool with_tzs) { |
| 163 | QStringListcxx . . $ QStringList# patcxx . . $ QList#QList(ced63f7c635d850d).; |
| 164 | |
| 165 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy-MM-ddTHH:mm:ss"); |
| 166 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy-MM-ddTHH:mm:ss.z"); |
| 167 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy-MM-ddTHH:mm:ss.zzz"); |
| 168 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy-MM-ddThh:mm:ss"); |
| 169 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy-MM-dd HH:mm:ss.z"); |
| 170 | |
| 171 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy-MM-ddThh:mm"); |
| 172 | |
| 173 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyyMMddThhmmss"); |
| 174 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyyMMdd"); |
| 175 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy"); |
| 176 | |
| 177 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy-MM-dd"); |
| 178 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("yyyy-MM"); |
| 179 | |
| 180 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("MMM dd yyyy hh:mm:ss"); |
| 181 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("MMM d yyyy hh:mm:ss"); |
| 182 | |
| 183 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("ddd, dd MMM yyyy HH:mm:ss"); |
| 184 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("ddd, dd MMM yyyy HH:mm"); |
| 185 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("ddd, dd MMM yy HH:mm:ss"); |
| 186 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("ddd, dd MMMM yyyy HH:mm:ss"); |
| 187 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("ddd, d MMM yyyy HH:mm:ss"); |
| 188 | |
| 189 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("ddd, MM/dd/yyyy - HH:mm"); |
| 190 | |
| 191 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("dd MMM yyyy hh:mm:ss"); |
| 192 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("dd MMM yyyy hh:mm"); |
| 193 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("dd MMM yyyy"); |
| 194 | |
| 195 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("d MMM yyyy HH:mm:ss"); |
| 196 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("d MMM yyyy HH:mm"); |
| 197 | |
| 198 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("dd-MM-yyyy - HH:mm"); |
| 199 | |
| 200 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("hh:mm:ss"); |
| 201 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("h:m:s"); |
| 202 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("h:mm"); |
| 203 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("H:mm"); |
| 204 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("h:m"); |
| 205 | pat <<cxx . . $ QList#`operator<<`(457f2c2a0db63381). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("h.m"); |
| 206 | |
| 207 | if (with_tzs) { |
| 208 | for (int i = 0; i < pat.sizecxx . . $ QList#size(6b0412d51016192f).(); i += 3) { |
| 209 | QStringcxx . . $ QString# base_pattern = pat.valuecxx . . $ QList#value(be5542f01a25b32e).(i); |
| 210 | |
| 211 | pat.insertcxx . . $ QList#insert(ba0d07b93c58566c).(i + 1, base_pattern +cxx . . $ operator+(adfbdceb504720ce). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("t")); |
| 212 | pat.insertcxx . . $ QList#insert(ba0d07b93c58566c).(i + 2, base_pattern +cxx . . $ operator+(adfbdceb504720ce). QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!(" t")); |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | return pat; |
| 217 | } |
| 218 | |
| 219 | QStringcxx . . $ QString# TextFactorycxx . . $ TextFactory#::encryptcxx . . $ TextFactory#encrypt(8566f3882fd92083).(const QStringcxx . . $ QString#& text, quint64cxx . . $ quint64# key) { |
| 220 | return SimpleCryptcxx . . $ SimpleCrypt#(key == 0 ? initializeSecretEncryptionKeycxx . . $ TextFactory#initializeSecretEncryptionKey(73266883b0c7072b).() : key).encryptToStringcxx . . $ SimpleCrypt#encryptToString(fd988a2ab94d906b).(text); |
| 221 | } |
| 222 | |
| 223 | QStringcxx . . $ QString# TextFactorycxx . . $ TextFactory#::decryptcxx . . $ TextFactory#decrypt(8566f3882fd92083).(const QStringcxx . . $ QString#& text, quint64cxx . . $ quint64# key) { |
| 224 | return SimpleCryptcxx . . $ SimpleCrypt#(key == 0 ? initializeSecretEncryptionKeycxx . . $ TextFactory#initializeSecretEncryptionKey(73266883b0c7072b).() : key).decryptToStringcxx . . $ SimpleCrypt#decryptToString(fd988a2ab94d906b).(text); |
| 225 | } |
| 226 | |
| 227 | QStringcxx . . $ QString# TextFactorycxx . . $ TextFactory#::newlinecxx . . $ TextFactory#newline(4365c3963150523e).() { |
| 228 | #if defined(Q_OS_WIN) |
| 229 | return QSL("\r\n"); |
| 230 | #elif defined(Q_OS_MACOS) |
| 231 | return QSL("\r"); |
| 232 | #else |
| 233 | return QSLcxx . . $ `src/librssguard/definitions/definitions.h:442:9`!("\n"); |
| 234 | #endif |
| 235 | } |
| 236 | |
| 237 | QStringcxx . . $ QString# TextFactorycxx . . $ TextFactory#::capitalizeFirstLettercxx . . $ TextFactory#capitalizeFirstLetter(fd988a2ab94d906b).(const QStringcxx . . $ QString#& sts) { |
| 238 | if (sts.isEmptycxx . . $ QString#isEmpty(3482b152b9333168).()) { |
| 239 | return stscxx . . $ QString#QString(132dd6869045752b).; |
| 240 | } |
| 241 | else { |
| 242 | return sts[cxx . . $ QString#`operator[]`(f90fa9c2d02215fc).0].toUppercxx . . $ QChar#toUpper(e5ddf3948a40da3f).() +cxx . . $ operator+(adfbdceb504720ce). sts.midcxx . . $ QString#mid(5eea715ff28b9227).(1); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | enum class TokenStatecxx . . $ TokenState# { |
| 247 | // We are not inside argument, we are between arguments. |
| 248 | Normalcxx . . $ TokenState#Normal., |
| 249 | |
| 250 | // We have detected escape "\" character coming from double-quoted argument. |
| 251 | EscapedFromDoubleQuotescxx . . $ TokenState#EscapedFromDoubleQuotes., |
| 252 | |
| 253 | // We have detected escape "\" character coming from spaced argument. |
| 254 | EscapedFromSpacedcxx . . $ TokenState#EscapedFromSpaced., |
| 255 | |
| 256 | // We are inside argument which was separated by spaces. |
| 257 | InsideArgSpacedcxx . . $ TokenState#InsideArgSpaced., |
| 258 | |
| 259 | // We are inside argument. |
| 260 | InsideArgDoubleQuotescxx . . $ TokenState#InsideArgDoubleQuotes., |
| 261 | |
| 262 | // We are inside argument, do not evaluate anything, just take it all |
| 263 | // as arw text. |
| 264 | InsideArgSingleQuotescxx . . $ TokenState#InsideArgSingleQuotes. |
| 265 | }; |
| 266 | |
| 267 | QStringListcxx . . $ QStringList# TextFactorycxx . . $ TextFactory#::tokenizeProcessArgumentscxx . . $ TextFactory#tokenizeProcessArguments(8335580dfd879b35).(const QStringcxx . . $ QString#& command) { |
| 268 | // Each argument containing spaces must be enclosed with single '' or double "" quotes. |
| 269 | // Some characters must be escaped with \ to keep their textual values as |
| 270 | // long as double-quoted argument is used. |
| 271 | |
| 272 | if (command.isEmptycxx . . $ QString#isEmpty(3482b152b9333168).()) { |
| 273 | return {cxx . . $ QList#QList(ced63f7c635d850d).}; |
| 274 | } |
| 275 | |
| 276 | // We append space to end of command to make sure that |
| 277 | // ending space-separated argument is processed. |
| 278 | QStringcxx . . $ QString# my_command = command +cxx . . $ operator+(adfbdceb504720ce). u' '; |
| 279 | |
| 280 | TokenStatecxx . . $ TokenState# state = TokenStatecxx . . $ TokenState#::Normalcxx . . $ TokenState#Normal.; |
| 281 | QStringListcxx . . $ QStringList# argscxx . . $ QList#QList(ced63f7c635d850d).; |
| 282 | QStringcxx . . $ QString# argcxx . . $ QString#QString(ced63f7c635d850d).; |
| 283 | |
| 284 | for (QCharcxx . . $ QChar# chr : my_command) { |
| 285 | switch (state) { |
| 286 | case TokenStatecxx . . $ TokenState#::Normalcxx . . $ TokenState#Normal.: { |
| 287 | switch (chr.unicodecxx . . $ QChar#unicode(334a79a2ab08c7a0).()) { |
| 288 | case u'"': |
| 289 | // We start double-quoted argument. |
| 290 | state = TokenStatecxx . . $ TokenState#::InsideArgDoubleQuotescxx . . $ TokenState#InsideArgDoubleQuotes.; |
| 291 | continue; |
| 292 | |
| 293 | case u'\'': |
| 294 | // We start single-quoted argument. |
| 295 | state = TokenStatecxx . . $ TokenState#::InsideArgSingleQuotescxx . . $ TokenState#InsideArgSingleQuotes.; |
| 296 | continue; |
| 297 | |
| 298 | case u' ': |
| 299 | // Whitespace, just go on. |
| 300 | continue; |
| 301 | |
| 302 | default: |
| 303 | // We found some actual text which marks |
| 304 | // beginning of argument, we assume spaced argument. |
| 305 | arg.appendcxx . . $ QString#append(3a2ffbdf8ecc25e2).(chr); |
| 306 | state = TokenStatecxx . . $ TokenState#::InsideArgSpacedcxx . . $ TokenState#InsideArgSpaced.; |
| 307 | continue; |
| 308 | } |
| 309 | |
| 310 | break; |
| 311 | } |
| 312 | |
| 313 | case TokenStatecxx . . $ TokenState#::EscapedFromDoubleQuotescxx . . $ TokenState#EscapedFromDoubleQuotes.: { |
| 314 | // Previous character was "\". |
| 315 | arg.appendcxx . . $ QString#append(3a2ffbdf8ecc25e2).(chr); |
| 316 | state = TokenStatecxx . . $ TokenState#::InsideArgDoubleQuotescxx . . $ TokenState#InsideArgDoubleQuotes.; |
| 317 | break; |
| 318 | } |
| 319 | |
| 320 | case TokenStatecxx . . $ TokenState#::EscapedFromSpacedcxx . . $ TokenState#EscapedFromSpaced.: { |
| 321 | // Previous character was "\". |
| 322 | arg.appendcxx . . $ QString#append(3a2ffbdf8ecc25e2).(chr); |
| 323 | state = TokenStatecxx . . $ TokenState#::InsideArgSpacedcxx . . $ TokenState#InsideArgSpaced.; |
| 324 | break; |
| 325 | } |
| 326 | |
| 327 | case TokenStatecxx . . $ TokenState#::InsideArgSpacedcxx . . $ TokenState#InsideArgSpaced.: { |
| 328 | switch (chr.unicodecxx . . $ QChar#unicode(334a79a2ab08c7a0).()) { |
| 329 | // NOTE: Probably disable escaping in spaced arguments to provide simpler UX? |
| 330 | /* |
| 331 | case u'\\': |
| 332 | // We found escaped! |
| 333 | state = TokenState::EscapedFromSpaced; |
| 334 | continue; |
| 335 | */ |
| 336 | |
| 337 | case u' ': |
| 338 | // We need to end this argument. |
| 339 | args.appendcxx . . $ QList#append(200d2dc08238a4ed).(arg); |
| 340 | arg.clearcxx . . $ QString#clear(49f6e7a06ebc5aa8).(); |
| 341 | state = TokenStatecxx . . $ TokenState#::Normalcxx . . $ TokenState#Normal.; |
| 342 | continue; |
| 343 | |
| 344 | default: |
| 345 | arg.appendcxx . . $ QString#append(3a2ffbdf8ecc25e2).(chr); |
| 346 | break; |
| 347 | } |
| 348 | |
| 349 | break; |
| 350 | } |
| 351 | |
| 352 | case TokenStatecxx . . $ TokenState#::InsideArgDoubleQuotescxx . . $ TokenState#InsideArgDoubleQuotes.: { |
| 353 | switch (chr.unicodecxx . . $ QChar#unicode(334a79a2ab08c7a0).()) { |
| 354 | case u'\\': |
| 355 | // We found escaped! |
| 356 | state = TokenStatecxx . . $ TokenState#::EscapedFromDoubleQuotescxx . . $ TokenState#EscapedFromDoubleQuotes.; |
| 357 | continue; |
| 358 | |
| 359 | case u'"': |
| 360 | // We need to end this argument. |
| 361 | args.appendcxx . . $ QList#append(200d2dc08238a4ed).(arg); |
| 362 | arg.clearcxx . . $ QString#clear(49f6e7a06ebc5aa8).(); |
| 363 | state = TokenStatecxx . . $ TokenState#::Normalcxx . . $ TokenState#Normal.; |
| 364 | continue; |
| 365 | |
| 366 | default: |
| 367 | arg.appendcxx . . $ QString#append(3a2ffbdf8ecc25e2).(chr); |
| 368 | break; |
| 369 | } |
| 370 | |
| 371 | break; |
| 372 | } |
| 373 | |
| 374 | case TokenStatecxx . . $ TokenState#::InsideArgSingleQuotescxx . . $ TokenState#InsideArgSingleQuotes.: { |
| 375 | switch (chr.unicodecxx . . $ QChar#unicode(334a79a2ab08c7a0).()) { |
| 376 | case u'\'': |
| 377 | // We need to end this argument. |
| 378 | args.appendcxx . . $ QList#append(200d2dc08238a4ed).(arg); |
| 379 | arg.clearcxx . . $ QString#clear(49f6e7a06ebc5aa8).(); |
| 380 | state = TokenStatecxx . . $ TokenState#::Normalcxx . . $ TokenState#Normal.; |
| 381 | continue; |
| 382 | |
| 383 | default: |
| 384 | arg.appendcxx . . $ QString#append(3a2ffbdf8ecc25e2).(chr); |
| 385 | break; |
| 386 | } |
| 387 | |
| 388 | break; |
| 389 | } |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | switch (state) { |
| 394 | case TokenStatecxx . . $ TokenState#::EscapedFromSpacedcxx . . $ TokenState#EscapedFromSpaced.: |
| 395 | case TokenStatecxx . . $ TokenState#::EscapedFromDoubleQuotescxx . . $ TokenState#EscapedFromDoubleQuotes.: |
| 396 | throw ApplicationExceptioncxx . . $ ApplicationException#(QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("escape sequence not completed")); |
| 397 | break; |
| 398 | |
| 399 | case TokenStatecxx . . $ TokenState#::InsideArgDoubleQuotescxx . . $ TokenState#InsideArgDoubleQuotes.: |
| 400 | throw ApplicationExceptioncxx . . $ ApplicationException#(QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("closing \" is missing")); |
| 401 | break; |
| 402 | |
| 403 | case TokenStatecxx . . $ TokenState#::InsideArgSingleQuotescxx . . $ TokenState#InsideArgSingleQuotes.: |
| 404 | throw ApplicationExceptioncxx . . $ ApplicationException#(QObjectcxx . . $ QObject#::trcxx . . $ QObject#tr(75d9f1c324b4579d).("closing ' is missing")); |
| 405 | break; |
| 406 | |
| 407 | default: |
| 408 | break; |
| 409 | } |
| 410 | |
| 411 | return args; |
| 412 | } |
| 413 | |
| 414 | QStringcxx . . $ QString# TextFactorycxx . . $ TextFactory#::shortencxx . . $ TextFactory#shorten(28db0a4afda64396).(const QStringcxx . . $ QString#& input, int text_length_limit) { |
| 415 | if (input.sizecxx . . $ QString#size(6b0412d51016192f).() > text_length_limit) { |
| 416 | return input.leftcxx . . $ QString#left(32d917b74df1c30e).(text_length_limit - ELLIPSIS_LENGTHcxx . . $ `src/librssguard/definitions/definitions.h:80:9`!) +cxx . . $ operator+(adfbdceb504720ce). QStringcxx . . $ QString#QString(f6601692316e540c).(ELLIPSIS_LENGTHcxx . . $ `src/librssguard/definitions/definitions.h:80:9`!, QL1Ccxx . . $ `src/librssguard/definitions/definitions.h:455:9`!('.')); |
| 417 | } |
| 418 | else { |
| 419 | return inputcxx . . $ QString#QString(132dd6869045752b).; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | quint64cxx . . $ quint64# TextFactorycxx . . $ TextFactory#::initializeSecretEncryptionKeycxx . . $ TextFactory#initializeSecretEncryptionKey(73266883b0c7072b).() { |
| 424 | if (s_encryptionKeycxx . . $ TextFactory#s_encryptionKey. == 0x0) { |
| 425 | // Check if file with encryption key exists. |
| 426 | QStringcxx . . $ QString# encryption_file_path = qAppcxx . . $ `src/librssguard/miscellaneous/application.h:30:9`!->settingscxx . . $ Application#settings(951936487a2d9252).()->pathNamecxx . . $ Settings#pathName(6ef7b6c27b00b43d).() +cxx . . $ operator+(adfbdceb504720ce). QDircxx . . $ QDir#::separatorcxx . . $ QDir#separator(44eb9225326fcbf5).() +cxx . . $ operator+(adfbdceb504720ce). ENCRYPTION_FILE_NAMEcxx . . $ `src/librssguard/definitions/definitions.h:97:9`!; |
| 427 | |
| 428 | try { |
| 429 | s_encryptionKeycxx . . $ TextFactory#s_encryptionKey. = quint64cxx . . $ quint64#(QStringcxx . . $ QString#QString(45672f3c6961a244).(IOFactorycxx . . $ IOFactory#::readFilecxx . . $ IOFactory#readFile(743b31b35d83e992).(encryption_file_path)).toULongLongcxx . . $ QString#toULongLong(fab7f4fb36759c3a).()); |
| 430 | } |
| 431 | catch (ApplicationExceptioncxx . . $ ApplicationException#&) { |
| 432 | // Well, key does not exist or is invalid, generate and save one. |
| 433 | s_encryptionKeycxx . . $ TextFactory#s_encryptionKey. = generateSecretEncryptionKeycxx . . $ TextFactory#generateSecretEncryptionKey(73266883b0c7072b).(); |
| 434 | |
| 435 | try { |
| 436 | IOFactorycxx . . $ IOFactory#::writeFilecxx . . $ IOFactory#writeFile(88f4c41ca0e941aa).(encryption_file_path, QStringcxx . . $ QString#::numbercxx . . $ QString#number(f5a84b9651713264).(s_encryptionKeycxx . . $ TextFactory#s_encryptionKey.).toLocal8Bitcxx . . $ QString#toLocal8Bit(7c2073558a834e49).()); |
| 437 | } |
| 438 | catch (ApplicationExceptioncxx . . $ ApplicationException#& ex) { |
| 439 | qCriticalNNcxx . . $ `src/librssguard/definitions/definitions.h:421:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). LOGSEC_COREcxx . . $ `src/librssguard/definitions/definitions.h:178:9`! <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). "Failed to write newly generated encryption key to file, error" |
| 440 | <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). QUOTE_W_SPACE_DOTcxx . . $ `src/librssguard/definitions/definitions.h:430:9`!(ex.message()) |
| 441 | <<cxx . . $ QDebug#`operator<<`(d8a917b173851aad). " Now, your passwords won't be readable after you start this application again."; |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | return s_encryptionKeycxx . . $ TextFactory#s_encryptionKey.; |
| 447 | } |
| 448 | |
| 449 | quint64cxx . . $ quint64# TextFactorycxx . . $ TextFactory#::generateSecretEncryptionKeycxx . . $ TextFactory#generateSecretEncryptionKey(73266883b0c7072b).() { |
| 450 | return QRandomGenerator64cxx . . $ QRandomGenerator64#::globalcxx . . $ QRandomGenerator64#global(1450d87071e8057e).()->generatecxx . . $ QRandomGenerator64#generate(73266883b0c7072b).(); |
| 451 | } |