clazy refactorings

This commit is contained in:
Martin Rotter 2021-09-13 12:45:07 +02:00
parent 3bdcdc0c21
commit 95ac855d16
97 changed files with 718 additions and 701 deletions

View file

@ -26,7 +26,7 @@
<url type="donation">https://github.com/sponsors/martinrotter</url>
<content_rating type="oars-1.1" />
<releases>
<release version="4.0.2" date="2021-09-08"/>
<release version="4.0.2" date="2021-09-13"/>
</releases>
<content_rating type="oars-1.0">
<content_attribute id="violence-cartoon">none</content_attribute>

View file

@ -65,7 +65,7 @@ QString Enclosures::encodeEnclosuresToString(const QList<Enclosure>& enclosures)
}
Message::Message() {
m_title = m_url = m_author = m_contents = m_rawContents = m_feedId = m_customId = m_customHash = QSL("");
m_title = m_url = m_author = m_contents = m_rawContents = m_feedId = m_customId = m_customHash = QL1S("");
m_enclosures = QList<Enclosure>();
m_accountId = m_id = 0;
m_score = 0.0;

View file

@ -2327,5 +2327,5 @@ bool DatabaseQueries::storeNewOauthTokens(const QSqlDatabase& db,
}
QString DatabaseQueries::unnulifyString(const QString& str) {
return str.isNull() ? QSL("") : str;
return str.isNull() ? QL1S("") : str;
}

View file

@ -132,7 +132,7 @@ void FormMessageFiltersManager::filterMessagesLikeThis(const Message& msg) {
addNewFilter(filter_script);
}
void FormMessageFiltersManager::showMessageContextMenu(const QPoint& pos) {
void FormMessageFiltersManager::showMessageContextMenu(QPoint pos) {
Message* msg = m_msgModel->messageForRow(m_ui.m_treeExistingMessages->indexAt(pos).row());
if (msg != nullptr) {

View file

@ -26,7 +26,7 @@ class FormMessageFiltersManager : public QDialog {
private slots:
void filterMessagesLikeThis(const Message& msg);
void showMessageContextMenu(const QPoint& pos);
void showMessageContextMenu(QPoint pos);
void removeSelectedFilter();
void addNewFilter(const QString& filter_script = QString());
void saveSelectedFilter();

View file

@ -76,7 +76,12 @@ void FormUpdate::checkForUpdates() {
m_updateInfo = update.first.at(0);
m_ui.m_tabInfo->setEnabled(true);
m_ui.m_lblAvailableRelease->setText(m_updateInfo.m_availableVersion);
#if QT_VERSION >= 0x050E00 // Qt >= 5.14.0
m_ui.m_txtChanges->setMarkdown(m_updateInfo.m_changes);
#else
m_ui.m_txtChanges->setText(m_updateInfo.m_changes);
#endif
if (SystemFactory::isVersionNewer(m_updateInfo.m_availableVersion, QSL(APP_VERSION))) {
m_btnUpdate->setVisible(true);

View file

@ -36,7 +36,7 @@ MessagesView::MessagesView(QWidget* parent)
setModel(m_proxyModel);
setupAppearance();
header()->setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
connect(header(), &QHeaderView::customContextMenuRequested, this, [=](const QPoint& point) {
connect(header(), &QHeaderView::customContextMenuRequested, this, [=](QPoint point) {
TreeViewColumnsMenu mm(header());
mm.exec(header()->mapToGlobal(point));
});

View file

@ -107,10 +107,10 @@ void SettingsDatabase::onMysqlDatabaseChanged(const QString& new_database) {
void SettingsDatabase::selectSqlBackend(int index) {
const QString selected_db_driver = m_ui->m_cmbDatabaseDriver->itemData(index).toString();
if (selected_db_driver == APP_DB_SQLITE_DRIVER) {
if (selected_db_driver == QSL(APP_DB_SQLITE_DRIVER)) {
m_ui->m_stackedDatabaseDriver->setCurrentIndex(0);
}
else if (selected_db_driver == APP_DB_MYSQL_DRIVER) {
else if (selected_db_driver == QSL(APP_DB_MYSQL_DRIVER)) {
m_ui->m_stackedDatabaseDriver->setCurrentIndex(1);
}
else {
@ -185,7 +185,7 @@ void SettingsDatabase::saveSettings() {
// Save SQLite.
settings()->setValue(GROUP(Database), Database::UseInMemory, new_inmemory);
if (QSqlDatabase::isDriverAvailable(APP_DB_MYSQL_DRIVER)) {
if (QSqlDatabase::isDriverAvailable(QSL(APP_DB_MYSQL_DRIVER))) {
// Save MySQL.
settings()->setValue(GROUP(Database), Database::MySQLHostname, m_ui->m_txtMysqlHostname->lineEdit()->text());
settings()->setValue(GROUP(Database), Database::MySQLUsername, m_ui->m_txtMysqlUsername->lineEdit()->text());

View file

@ -8,7 +8,7 @@
SettingsGeneral::SettingsGeneral(Settings* settings, QWidget* parent)
: SettingsPanel(settings, parent), m_ui(new Ui::SettingsGeneral) {
m_ui->setupUi(this);
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(APP_NAME));
m_ui->m_checkAutostart->setText(m_ui->m_checkAutostart->text().arg(QSL(APP_NAME)));
connect(m_ui->m_checkAutostart, &QCheckBox::stateChanged, this, &SettingsGeneral::dirtifySettings);
connect(m_ui->m_checkForUpdatesOnStart, &QCheckBox::stateChanged, this, &SettingsGeneral::dirtifySettings);

View file

@ -99,7 +99,7 @@ void SettingsGui::loadSettings() {
auto icons = qApp->icons()->installedIconThemes();
for (const QString& icon_theme_name : qAsConst(icons)) {
if (icon_theme_name == APP_NO_THEME) {
if (icon_theme_name == QSL(APP_NO_THEME)) {
// Add just "no theme" on other systems.
//: Label for disabling icon theme.
#if defined(Q_OS_LINUX)

View file

@ -40,7 +40,7 @@ void SettingsLocalization::loadSettings() {
item->setText(0, language.m_name);
item->setText(1, language.m_code);
item->setText(2, language.m_author);
item->setIcon(0, qApp->icons()->miscIcon(QString(FLAG_ICON_SUBFOLDER) + QDir::separator() + language.m_code));
item->setIcon(0, qApp->icons()->miscIcon(QSL(FLAG_ICON_SUBFOLDER) + QDir::separator() + language.m_code));
}
m_ui->m_treeLanguages->sortByColumn(0, Qt::SortOrder::AscendingOrder);

View file

@ -157,7 +157,7 @@ void SystemTrayIcon::setNumber(int number, bool any_new_message) {
}
void SystemTrayIcon::showMessage(const QString& title, const QString& message, QSystemTrayIcon::MessageIcon icon,
int milliseconds_timeout_hint, std::function<void()> functor) {
int milliseconds_timeout_hint, const std::function<void()>& functor) {
if (m_connection != nullptr) {
// Disconnect previous bubble click signalling.
disconnect(m_connection);

View file

@ -44,7 +44,7 @@ class SystemTrayIcon : public QSystemTrayIcon {
void setNumber(int number = -1, bool any_new_message = false);
void showMessage(const QString& title, const QString& message, MessageIcon icon = Information,
int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, std::function<void()> functor = nullptr);
int milliseconds_timeout_hint = TRAY_ICON_BUBBLE_TIMEOUT, const std::function<void ()>& functor = nullptr);
// Returns true if tray area is available and icon can be displayed.
static bool isSystemTrayAreaAvailable();

View file

@ -20,7 +20,7 @@ TabBar::~TabBar() {
qDebugNN << LOGSEC_GUI << "Destroying TabBar instance.";
}
void TabBar::setTabType(int index, const TabBar::TabType& type) {
void TabBar::setTabType(int index, TabBar::TabType type) {
const auto button_position = static_cast<ButtonPosition>(style()->styleHint(QStyle::StyleHint::SH_TabBar_CloseButtonPosition,
nullptr,
this));

View file

@ -24,7 +24,7 @@ class TabBar : public QTabBar {
virtual ~TabBar();
// Getter/setter for tab type.
void setTabType(int index, const TabBar::TabType& type);
void setTabType(int index, TabType type);
TabBar::TabType tabType(int index) const;
private slots:

View file

@ -306,7 +306,7 @@ void TabWidget::removeTab(int index, bool clear_from_memory) {
QTabWidget::removeTab(index);
}
int TabWidget::addTab(TabContent* widget, const QIcon& icon, const QString& label, const TabBar::TabType& type) {
int TabWidget::addTab(TabContent* widget, const QIcon& icon, const QString& label, TabBar::TabType type) {
const int index = QTabWidget::addTab(widget, icon, label);
tabBar()->setTabType(index, type);
@ -314,7 +314,7 @@ int TabWidget::addTab(TabContent* widget, const QIcon& icon, const QString& labe
return index;
}
int TabWidget::addTab(TabContent* widget, const QString& label, const TabBar::TabType& type) {
int TabWidget::addTab(TabContent* widget, const QString& label, TabBar::TabType type) {
const int index = QTabWidget::addTab(widget, label);
tabBar()->setTabType(index, type);
@ -322,7 +322,7 @@ int TabWidget::addTab(TabContent* widget, const QString& label, const TabBar::Ta
return index;
}
int TabWidget::insertTab(int index, QWidget* widget, const QIcon& icon, const QString& label, const TabBar::TabType& type) {
int TabWidget::insertTab(int index, QWidget* widget, const QIcon& icon, const QString& label, TabBar::TabType type) {
const int tab_index = QTabWidget::insertTab(index, widget, icon, label);
tabBar()->setTabType(tab_index, type);
@ -330,7 +330,7 @@ int TabWidget::insertTab(int index, QWidget* widget, const QIcon& icon, const QS
return tab_index;
}
int TabWidget::insertTab(int index, QWidget* widget, const QString& label, const TabBar::TabType& type) {
int TabWidget::insertTab(int index, QWidget* widget, const QString& label, TabBar::TabType type) {
const int tab_index = QTabWidget::insertTab(index, widget, label);
tabBar()->setTabType(tab_index, type);
@ -354,7 +354,7 @@ void TabWidget::fixContentsAfterMove(int from, int to) {
to = qMax(from, to);
for (; from <= to; from++) {
auto* content = static_cast<TabContent*>(widget(from));
auto* content = widget(from);
content->setIndex(from);
}

View file

@ -27,13 +27,13 @@ class TabWidget : public QTabWidget {
// Manimulators for tabs.
int addTab(TabContent* widget, const QString&,
const TabBar::TabType& type = TabBar::TabType::NonClosable);
TabBar::TabType type = TabBar::TabType::NonClosable);
int addTab(TabContent* widget, const QIcon& icon,
const QString& label, const TabBar::TabType& type = TabBar::TabType::NonClosable);
const QString& label, TabBar::TabType type = TabBar::TabType::NonClosable);
int insertTab(int index, QWidget* widget, const QString& label,
const TabBar::TabType& type = TabBar::TabType::Closable);
TabBar::TabType type = TabBar::TabType::Closable);
int insertTab(int index, QWidget* widget, const QIcon& icon,
const QString& label, const TabBar::TabType& type = TabBar::TabType::NonClosable);
const QString& label, TabBar::TabType type = TabBar::TabType::NonClosable);
void removeTab(int index, bool clear_from_memory);
// Returns tab bar.

View file

@ -53,18 +53,18 @@ QList<QAction*> FeedsToolBar::convertActions(const QStringList& actions) {
// Add existing standard action.
spec_actions.append(matching_action);
}
else if (action_name == SEPARATOR_ACTION_NAME) {
else if (action_name == QSL(SEPARATOR_ACTION_NAME)) {
// Add new separator.
auto* act = new QAction(this);
act->setSeparator(true);
spec_actions.append(act);
}
else if (action_name == SEARCH_BOX_ACTION_NAME) {
else if (action_name == QSL(SEARCH_BOX_ACTION_NAME)) {
// Add search box.
spec_actions.append(m_actionSearchMessages);
}
else if (action_name == SPACER_ACTION_NAME) {
else if (action_name == QSL(SPACER_ACTION_NAME)) {
// Add new spacer.
auto* spacer = new QWidget(this);

View file

@ -55,22 +55,22 @@ QList<QAction*> MessagesToolBar::convertActions(const QStringList& actions) {
// Add existing standard action.
spec_actions.append(matching_action);
}
else if (action_name == SEPARATOR_ACTION_NAME) {
else if (action_name == QSL(SEPARATOR_ACTION_NAME)) {
// Add new separator.
auto* act = new QAction(this);
act->setSeparator(true);
spec_actions.append(act);
}
else if (action_name == SEARCH_BOX_ACTION_NAME) {
else if (action_name == QSL(SEARCH_BOX_ACTION_NAME)) {
// Add search box.
spec_actions.append(m_actionSearchMessages);
}
else if (action_name == HIGHLIGHTER_ACTION_NAME) {
else if (action_name == QSL(HIGHLIGHTER_ACTION_NAME)) {
// Add filter button.
spec_actions.append(m_actionMessageHighlighter);
}
else if (action_name == SPACER_ACTION_NAME) {
else if (action_name == QSL(SPACER_ACTION_NAME)) {
// Add new spacer.
auto* spacer = new QWidget(this);

View file

@ -103,14 +103,14 @@ QList<QAction*> StatusBar::convertActions(const QStringList& actions) {
widget_to_add->setVisible(progress_visible);
}
else {
if (action_name == SEPARATOR_ACTION_NAME) {
QLabel* lbl = new QLabel(QString::fromUtf8(""), this);
if (action_name == QSL(SEPARATOR_ACTION_NAME)) {
QLabel* lbl = new QLabel(QSL(""), this);
widget_to_add = lbl;
action_to_add = new QAction(this);
action_to_add->setSeparator(true);
}
else if (action_name == SPACER_ACTION_NAME) {
else if (action_name == QSL(SPACER_ACTION_NAME)) {
QLabel* lbl = new QLabel(QSL("\t\t"), this);
widget_to_add = lbl;

View file

@ -61,12 +61,14 @@ void ToolBarEditor::resetToolBar() {
}
}
void ToolBarEditor::loadEditor(const QList<QAction*> activated_actions, const QList<QAction*> available_actions) {
void ToolBarEditor::loadEditor(const QList<QAction*>& activated_actions, const QList<QAction*>& available_actions) {
m_ui->m_listActivatedActions->clear();
m_ui->m_listAvailableActions->clear();
for (const QAction* action : activated_actions) {
QListWidgetItem* action_item = new QListWidgetItem(action->icon(), action->text().replace('&', ""), m_ui->m_listActivatedActions);
QListWidgetItem* action_item = new QListWidgetItem(action->icon(),
action->text().replace('&', QL1S("")),
m_ui->m_listActivatedActions);
if (action->isSeparator()) {
action_item->setData(Qt::ItemDataRole::UserRole, SEPARATOR_ACTION_NAME);
@ -87,21 +89,23 @@ void ToolBarEditor::loadEditor(const QList<QAction*> activated_actions, const QL
for (QAction* action : available_actions) {
if (!activated_actions.contains(action)) {
QListWidgetItem* action_item = new QListWidgetItem(action->icon(), action->text().replace('&', ""), m_ui->m_listAvailableActions);
QListWidgetItem* action_item = new QListWidgetItem(action->icon(),
action->text().replace('&', QL1S("")),
m_ui->m_listAvailableActions);
if (action->isSeparator()) {
action_item->setData(Qt::UserRole, SEPARATOR_ACTION_NAME);
action_item->setData(Qt::ItemDataRole::UserRole, QSL(SEPARATOR_ACTION_NAME));
action_item->setText(tr("Separator"));
action_item->setToolTip(tr("Separator"));
action_item->setIcon(qApp->icons()->fromTheme(QSL("insert-object")));
}
else if (action->property("type").isValid()) {
action_item->setData(Qt::UserRole, action->property("type").toString());
action_item->setData(Qt::ItemDataRole::UserRole, action->property("type").toString());
action_item->setText(action->property("name").toString());
action_item->setToolTip(action_item->text());
}
else {
action_item->setData(Qt::UserRole, action->objectName());
action_item->setData(Qt::ItemDataRole::UserRole, action->objectName());
action_item->setToolTip(action->toolTip());
}
}
@ -219,7 +223,7 @@ void ToolBarEditor::deleteSelectedAction() {
QListWidgetItem* selected_item = items.at(0);
const QString data_item = selected_item->data(Qt::ItemDataRole::UserRole).toString();
if (data_item == SEPARATOR_ACTION_NAME || data_item == SPACER_ACTION_NAME) {
if (data_item == QSL(SEPARATOR_ACTION_NAME) || data_item == QSL(SPACER_ACTION_NAME)) {
m_ui->m_listActivatedActions->takeItem(m_ui->m_listActivatedActions->row(selected_item));
updateActionsAvailability();
}
@ -242,7 +246,7 @@ void ToolBarEditor::deleteAllActions() {
while ((taken_item = m_ui->m_listActivatedActions->takeItem(0)) != nullptr) {
data_item = taken_item->data(Qt::ItemDataRole::UserRole).toString();
if (data_item != SEPARATOR_ACTION_NAME && data_item != SPACER_ACTION_NAME) {
if (data_item != QSL(SEPARATOR_ACTION_NAME) && data_item != QSL(SPACER_ACTION_NAME)) {
m_ui->m_listAvailableActions->insertItem(m_ui->m_listAvailableActions->currentRow() + 1, taken_item);
}
}

View file

@ -49,7 +49,7 @@ class ToolBarEditor : public QWidget {
void setupChanged();
private:
void loadEditor(const QList<QAction*> activated_actions, const QList<QAction*> available_actions);
void loadEditor(const QList<QAction*>& activated_actions, const QList<QAction*>& available_actions);
QScopedPointer<Ui::ToolBarEditor> m_ui;
BaseBar* m_toolBar;

View file

@ -181,7 +181,7 @@ bool WebBrowser::eventFilter(QObject* watched, QEvent* event) {
void WebBrowser::openCurrentSiteInSystemBrowser() {
auto url = m_webView->url();
if (!url.isValid() || url.host().contains(APP_LOW_NAME)) {
if (!url.isValid() || url.host().contains(QSL(APP_LOW_NAME))) {
return;
}
@ -257,7 +257,7 @@ void WebBrowser::onLoadingFinished(bool success) {
if (success) {
auto url = m_webView->url();
if (url.isValid() && !url.host().contains(APP_LOW_NAME)) {
if (url.isValid() && !url.host().contains(QSL(APP_LOW_NAME))) {
m_actionOpenInSystemBrowser->setEnabled(true);
}

View file

@ -39,7 +39,7 @@ bool WebViewer::canDecreaseZoom() {
bool WebViewer::event(QEvent* event) {
if (event->type() == QEvent::Type::ChildAdded) {
QChildEvent* child_ev = static_cast<QChildEvent*>(event);
QWidget* w = dynamic_cast<QWidget*>(child_ev->child());
QWidget* w = qobject_cast<QWidget*>(child_ev->child());
if (w != nullptr) {
w->installEventFilter(this);
@ -109,7 +109,7 @@ void WebViewer::loadMessages(const QList<Message>& messages, RootItem* root) {
QString enc_url;
if (!enclosure.m_url.contains(QRegularExpression(QSL("^(http|ftp|\\/)")))) {
enc_url = QString(INTERNAL_URL_PASSATTACHMENT) + QL1S("/?") + enclosure.m_url;
enc_url = QSL(INTERNAL_URL_PASSATTACHMENT) + QL1S("/?") + enclosure.m_url;
}
else {
enc_url = enclosure.m_url;
@ -179,7 +179,7 @@ void WebViewer::clear() {
bool previously_enabled = isEnabled();
setEnabled(false);
setHtml("<!DOCTYPE html><html><body</body></html>", QUrl(INTERNAL_URL_BLANK));
setHtml(QSL("<!DOCTYPE html><html><body</body></html>"), QUrl(QSL(INTERNAL_URL_BLANK)));
setEnabled(previously_enabled);
}
@ -222,7 +222,7 @@ void WebViewer::contextMenuEvent(QContextMenuEvent* event) {
}
if (menu_ext_tools->actions().isEmpty()) {
QAction* act_not_tools = new QAction("No external tools activated");
QAction* act_not_tools = new QAction(tr("No external tools activated"));
act_not_tools->setEnabled(false);
menu_ext_tools->addAction(act_not_tools);

View file

@ -435,7 +435,7 @@ SystemTrayIcon* Application::trayIcon() {
}
QIcon Application::desktopAwareIcon() const {
auto from_theme = m_icons->fromTheme(APP_LOW_NAME);
auto from_theme = m_icons->fromTheme(QSL(APP_LOW_NAME));
if (!from_theme.isNull()) {
return from_theme;

View file

@ -35,7 +35,7 @@ QString ExternalTool::parameters() const {
}
ExternalTool ExternalTool::fromString(const QString& str) {
QStringList outer = str.split(EXTERNAL_TOOL_SEPARATOR);
QStringList outer = str.split(QSL(EXTERNAL_TOOL_SEPARATOR));
if (outer.size() != 2) {
throw ApplicationException(QObject::tr("Passed external tool representation is not valid."));

View file

@ -113,19 +113,19 @@ void IconFactory::loadCurrentIconTheme() {
qWarningNN << "Icon theme"
<< QUOTE_W_SPACE(theme_name_from_settings)
<< "cannot be loaded because it is not installed. Activating \"no\" icon theme.";
QIcon::setThemeName(APP_NO_THEME);
QIcon::setThemeName(QSL(APP_NO_THEME));
#endif
}
}
QStringList IconFactory::installedIconThemes() const {
QStringList icon_theme_names; icon_theme_names << APP_NO_THEME;
QStringList icon_theme_names = { QSL(APP_NO_THEME) };
// Iterate all directories with icon themes.
QStringList icon_themes_paths = QIcon::themeSearchPaths();
QStringList filters_index;
filters_index.append("index.theme");
filters_index.append(QSL("index.theme"));
icon_themes_paths.removeDuplicates();
for (const QString& icon_path : icon_themes_paths) {

View file

@ -22,7 +22,7 @@ bool IOFactory::isFolderWritable(const QString& folder) {
real_file += QDir::separator();
}
real_file += "test-permissions-file";
real_file += QSL("test-permissions-file");
return QTemporaryFile(real_file).open();
}

View file

@ -27,7 +27,7 @@ void Localization::loadActiveLanguage() {
<< "Starting to load active localization. Desired localization is"
<< QUOTE_W_SPACE_DOT(desired_localization);
if (app_translator->load(QLocale(desired_localization), "rssguard", QSL("_"), APP_LANG_PATH)) {
if (app_translator->load(QLocale(desired_localization), QSL("rssguard"), QSL("_"), APP_LANG_PATH)) {
const QString real_loaded_locale = app_translator->translate("QObject", "LANG_ABBREV");
Application::installTranslator(app_translator);
@ -46,10 +46,10 @@ void Localization::loadActiveLanguage() {
<< "was not loaded. Loading"
<< QUOTE_W_SPACE(DEFAULT_LOCALE)
<< "instead.";
desired_localization = DEFAULT_LOCALE;
desired_localization = QSL(DEFAULT_LOCALE);
}
if (qt_translator->load(QLocale(desired_localization), "qtbase", QSL("_"), APP_LANG_PATH)) {
if (qt_translator->load(QLocale(desired_localization), QSL("qtbase"), QSL("_"), APP_LANG_PATH)) {
Application::installTranslator(qt_translator);
qDebugNN << LOGSEC_CORE
<< "Qt localization"

View file

@ -350,7 +350,7 @@ DVALUE(QStringList) Browser::ExternalToolsDef = QStringList();
// Categories.
DKEY CategoriesExpandStates::ID = "categories_expand_states";
Settings::Settings(const QString& file_name, Format format, const SettingsProperties::SettingsType& type, QObject* parent)
Settings::Settings(const QString& file_name, Format format, SettingsProperties::SettingsType type, QObject* parent)
: QSettings(file_name, format, parent), m_initializationStatus(type) {}
Settings::~Settings() = default;

View file

@ -449,7 +449,7 @@ class Settings : public QSettings {
private:
// Constructor.
explicit Settings(const QString& file_name, Format format, const SettingsProperties::SettingsType& type, QObject* parent = nullptr);
explicit Settings(const QString& file_name, Format format, SettingsProperties::SettingsType type, QObject* parent = nullptr);
SettingsProperties::SettingsType m_initializationStatus;
};

View file

@ -15,7 +15,7 @@ void SkinFactory::loadCurrentSkin() {
QList<QString> skin_names_to_try;
skin_names_to_try.append(selectedSkinName());
skin_names_to_try.append(APP_SKIN_DEFAULT);
skin_names_to_try.append(QSL(APP_SKIN_DEFAULT));
bool skin_parsed;
Skin skin_data;
QString skin_name;

View file

@ -125,12 +125,12 @@ bool SystemFactory::setAutoStartStatus(AutoStartStatus new_status) {
switch (new_status) {
case AutoStartStatus::Enabled:
registry_key.setValue(APP_LOW_NAME,
registry_key.setValue(QSL(APP_LOW_NAME),
Application::applicationFilePath().replace(QL1C('/'), QL1C('\\')));
return true;
case AutoStartStatus::Disabled:
registry_key.remove(APP_LOW_NAME);
registry_key.remove(QSL(APP_LOW_NAME));
return true;
default:
@ -199,18 +199,18 @@ void SystemFactory::checkForUpdates() const {
emit updatesChecked(result);
downloader->deleteLater();
});
downloader->downloadFile(RELEASES_LIST);
downloader->downloadFile(QSL(RELEASES_LIST));
}
void SystemFactory::checkForUpdatesOnStartup() {
if (qApp->settings()->value(GROUP(General), SETTING(General::UpdateOnStartup)).toBool()) {
QObject::connect(qApp->system(), &SystemFactory::updatesChecked,
this, [&](QPair<QList<UpdateInfo>, QNetworkReply::NetworkError> updates) {
this, [&](const QPair<QList<UpdateInfo>, QNetworkReply::NetworkError>& updates) {
QObject::disconnect(qApp->system(), &SystemFactory::updatesChecked, this, nullptr);
if (!updates.first.isEmpty() &&
updates.second == QNetworkReply::NetworkError::NoError &&
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, APP_VERSION)) {
SystemFactory::isVersionNewer(updates.first.at(0).m_availableVersion, QSL(APP_VERSION))) {
qApp->showGuiMessage(Notification::Event::NewAppVersionAvailable,
QObject::tr("New version available"),
QObject::tr("Click the bubble for more information."),
@ -279,24 +279,24 @@ QList<UpdateInfo> SystemFactory::parseUpdatesFile(const QByteArray& updates_file
for (QJsonValueRef i : document) {
QJsonObject release = i.toObject();
if (release["tag_name"].toString() == QSL("devbuild")) {
if (release[QSL("tag_name")].toString() == QSL("devbuild")) {
continue;
}
UpdateInfo update;
update.m_availableVersion = release["tag_name"].toString();
update.m_date = QDateTime::fromString(release["published_at"].toString(), QSL("yyyy-MM-ddTHH:mm:ssZ"));
update.m_changes = release["body"].toString();
QJsonArray assets = release["assets"].toArray();
update.m_availableVersion = release[QSL("tag_name")].toString();
update.m_date = QDateTime::fromString(release[QSL("published_at")].toString(), QSL("yyyy-MM-ddTHH:mm:ssZ"));
update.m_changes = release[QSL("body")].toString();
QJsonArray assets = release[QSL("assets")].toArray();
for (QJsonValueRef j : assets) {
QJsonObject asset = j.toObject();
UpdateUrl url;
url.m_fileUrl = asset["browser_download_url"].toString();
url.m_name = asset["name"].toString();
url.m_size = asset["size"].toVariant().toString() + tr(" bytes");
url.m_fileUrl = asset[QSL("browser_download_url")].toString();
url.m_name = asset[QSL("name")].toString();
url.m_size = asset[QSL("size")].toVariant().toString() + tr(" bytes");
update.m_urls.append(url);
}

View file

@ -23,7 +23,7 @@ AdBlockDialog::AdBlockDialog(QWidget* parent)
m_ui.m_cbEnable->setChecked(m_manager->isEnabled());
GuiUtilities::applyDialogProperties(*this,
qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE),
qApp->icons()->miscIcon(QSL(ADBLOCK_ICON_ACTIVE)),
tr("AdBlock configuration"));
connect(m_ui.m_btnHelp, &QPushButton::clicked, this, [=]() {

View file

@ -48,7 +48,7 @@ void AdBlockIcon::createMenu(QMenu* menu) {
menu->addAction(tr("Show AdBlock &settings"), m_manager, &AdBlockManager::showDialog);
}
void AdBlockIcon::showMenu(const QPoint& pos) {
void AdBlockIcon::showMenu(QPoint pos) {
QMenu menu;
createMenu(&menu);
@ -57,6 +57,6 @@ void AdBlockIcon::showMenu(const QPoint& pos) {
void AdBlockIcon::setIcon(bool adblock_enabled) {
QAction::setIcon(adblock_enabled
? qApp->icons()->miscIcon(ADBLOCK_ICON_ACTIVE)
: qApp->icons()->miscIcon(ADBLOCK_ICON_DISABLED));
? qApp->icons()->miscIcon(QSL(ADBLOCK_ICON_ACTIVE))
: qApp->icons()->miscIcon(QSL(ADBLOCK_ICON_ACTIVE)));
}

View file

@ -19,7 +19,7 @@ class AdBlockIcon : public QAction {
void setIcon(bool adblock_enabled);
private slots:
void showMenu(const QPoint& pos);
void showMenu(QPoint pos);
private:
void createMenu(QMenu* menu = nullptr);

View file

@ -159,14 +159,14 @@ void AdBlockManager::setCustomFilters(const QStringList& custom_filters) {
}
QString AdBlockManager::generateJsForElementHiding(const QString& css) {
QString source = QL1S("(function() {"
"var head = document.getElementsByTagName('head')[0];"
"if (!head) return;"
"var css = document.createElement('style');"
"css.setAttribute('type', 'text/css');"
"css.appendChild(document.createTextNode('%1'));"
"head.appendChild(css);"
"})()");
QString source = QSL("(function() {"
"var head = document.getElementsByTagName('head')[0];"
"if (!head) return;"
"var css = document.createElement('style');"
"css.setAttribute('type', 'text/css');"
"css.appendChild(document.createTextNode('%1'));"
"head.appendChild(css);"
"})()");
QString style = css;
style.replace(QL1S("'"), QL1S("\\'"));
@ -197,10 +197,10 @@ BlockingResult AdBlockManager::askServerIfBlocked(const QString& fp_url, const Q
QByteArray out;
QElapsedTimer tmr;
req_obj["fp_url"] = fp_url;
req_obj["url"] = url;
req_obj["url_type"] = url_type,
req_obj["filter"] = true;
req_obj[QSL("fp_url")] = fp_url;
req_obj[QSL("url")] = url;
req_obj[QSL("url_type")] = url_type,
req_obj[QSL("filter")] = true;
tmr.start();
@ -221,12 +221,12 @@ BlockingResult AdBlockManager::askServerIfBlocked(const QString& fp_url, const Q
<< " ms.";
QJsonObject out_obj = QJsonDocument::fromJson(out).object();
bool blocking = out_obj["filter"].toObject()["match"].toBool();
bool blocking = out_obj[QSL("filter")].toObject()[QSL("match")].toBool();
return {
blocking,
blocking
? out_obj["filter"].toObject()["filter"].toObject()["filter"].toString()
? out_obj[QSL("filter")].toObject()[QSL("filter")].toObject()[QSL("filter")].toString()
: QString()
};
}
@ -240,8 +240,8 @@ QString AdBlockManager::askServerForCosmeticRules(const QString& url) const {
QByteArray out;
QElapsedTimer tmr;
req_obj["url"] = url;
req_obj["cosmetic"] = true;
req_obj[QSL("url")] = url;
req_obj[QSL("cosmetic")] = true;
tmr.start();
@ -263,7 +263,7 @@ QString AdBlockManager::askServerForCosmeticRules(const QString& url) const {
QJsonObject out_obj = QJsonDocument::fromJson(out).object();
return out_obj["cosmetic"].toObject()["styles"].toString();
return out_obj[QSL("cosmetic")].toObject()[QSL("styles")].toString();
}
else {
throw NetworkException(network_res.first);

View file

@ -141,7 +141,7 @@ QString DownloadItem::saveFileName(const QString& directory) const {
if (m_reply->hasRawHeader("Content-Disposition")) {
QString value = QLatin1String(m_reply->rawHeader("Content-Disposition"));
QRegularExpression exp(".*filename=?\"([^\"]+)\"?");
QRegularExpression exp(QSL(".*filename=?\"([^\"]+)\"?"));
QRegularExpressionMatch match = exp.match(value);
if (match.isValid()) {
@ -737,7 +737,7 @@ QString DownloadManager::dataString(qint64 size) {
unit = tr("GB");
}
return QString(QL1S("%1 %2")).arg(new_size, 0, 'f', 1).arg(unit);
return QSL("%1 %2").arg(new_size, 0, 'f', 1).arg(unit);
}
DownloadModel::DownloadModel(DownloadManager* download_manager, QObject* parent)

View file

@ -140,7 +140,7 @@ void GoogleSuggest::doneCompletion() {
QListWidgetItem* item = popup->currentItem();
if (item != nullptr) {
editor->submit(QString(GOOGLE_SEARCH_URL).arg(item->text()));
editor->submit(QSL(GOOGLE_SEARCH_URL).arg(item->text()));
}
}
@ -150,7 +150,7 @@ void GoogleSuggest::preventSuggest() {
void GoogleSuggest::autoSuggest() {
m_enteredText = QUrl::toPercentEncoding(editor->text());
QString url = QString(GOOGLE_SUGGEST_URL).arg(m_enteredText);
QString url = QSL(GOOGLE_SUGGEST_URL).arg(m_enteredText);
m_downloader->downloadFile(url);
}

View file

@ -16,8 +16,8 @@
QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const QString& html) {
QStringList feeds;
QRegularExpression rx(FEED_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption);
QRegularExpression rx_href(FEED_HREF_REGEX_MATCHER, QRegularExpression::PatternOption::CaseInsensitiveOption);
QRegularExpression rx(QSL(FEED_REGEX_MATCHER), QRegularExpression::PatternOption::CaseInsensitiveOption);
QRegularExpression rx_href(QSL(FEED_HREF_REGEX_MATCHER), QRegularExpression::PatternOption::CaseInsensitiveOption);
rx_href.optimize();
@ -29,10 +29,12 @@ QStringList NetworkFactory::extractFeedLinksFromHtmlPage(const QUrl& url, const
QString feed_link = rx_href.match(link_tag).captured(1);
if (feed_link.startsWith(QL1S("//"))) {
feed_link = QString(URI_SCHEME_HTTP) + feed_link.mid(2);
feed_link = QSL(URI_SCHEME_HTTP) + feed_link.mid(2);
}
else if (feed_link.startsWith(QL1C('/'))) {
feed_link = url.toString(QUrl::RemovePath | QUrl::RemoveQuery | QUrl::StripTrailingSlash) + feed_link;
feed_link = url.toString(QUrl::UrlFormattingOption::RemovePath |
QUrl::UrlFormattingOption::RemoveQuery |
QUrl::UrlFormattingOption::StripTrailingSlash) + feed_link;
}
feeds.append(feed_link);
@ -46,8 +48,8 @@ QPair<QByteArray, QByteArray> NetworkFactory::generateBasicAuthHeader(const QStr
return QPair<QByteArray, QByteArray>(QByteArray(), QByteArray());
}
else {
QString basic_value = username + ":" + password;
QString header_value = QString("Basic ") + QString(basic_value.toUtf8().toBase64());
QString basic_value = username + QSL(":") + password;
QString header_value = QSL("Basic ") + QString(basic_value.toUtf8().toBase64());
return QPair<QByteArray, QByteArray>(HTTP_HEADERS_AUTHORIZATION, header_value.toLocal8Bit());
}
@ -185,7 +187,7 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QPair<QStri
host = host.mid(4);
}
const QString ddg_icon_service = QString("https://external-content.duckduckgo.com/ip3/%1.ico").arg(host);
const QString ddg_icon_service = QSL("https://external-content.duckduckgo.com/ip3/%1.ico").arg(host);
network_result = performNetworkOperation(ddg_icon_service,
timeout,
@ -216,7 +218,7 @@ QNetworkReply::NetworkError NetworkFactory::downloadIcon(const QList<QPair<QStri
NetworkResult NetworkFactory::performNetworkOperation(const QString& url, int timeout, const QByteArray& input_data,
QByteArray& output, QNetworkAccessManager::Operation operation,
QList<QPair<QByteArray, QByteArray>> additional_headers,
const QList<QPair<QByteArray, QByteArray>>& additional_headers,
bool protected_contents,
const QString& username, const QString& password,
const QNetworkProxy& custom_proxy) {
@ -251,7 +253,7 @@ NetworkResult NetworkFactory::performNetworkOperation(const QString& url,
QHttpMultiPart* input_data,
QList<HttpResponse>& output,
QNetworkAccessManager::Operation operation,
QList<QPair<QByteArray, QByteArray>> additional_headers,
const QList<QPair<QByteArray, QByteArray>>& additional_headers,
bool protected_contents,
const QString& username,
const QString& password,

View file

@ -40,8 +40,7 @@ class NetworkFactory {
const QByteArray& input_data,
QByteArray& output,
QNetworkAccessManager::Operation operation,
QList<QPair<QByteArray,
QByteArray>> additional_headers = QList<QPair<QByteArray, QByteArray>>(),
const QList<QPair<QByteArray, QByteArray>>& additional_headers = QList<QPair<QByteArray, QByteArray>>(),
bool protected_contents = false,
const QString& username = QString(),
const QString& password = QString(),
@ -50,8 +49,7 @@ class NetworkFactory {
QHttpMultiPart* input_data,
QList<HttpResponse>& output,
QNetworkAccessManager::Operation operation,
QList<QPair<QByteArray,
QByteArray>> additional_headers = QList<QPair<QByteArray, QByteArray>>(),
const QList<QPair<QByteArray, QByteArray>>& additional_headers = QList<QPair<QByteArray, QByteArray>>(),
bool protected_contents = false,
const QString& username = QString(),
const QString& password = QString(),

View file

@ -46,7 +46,7 @@ OAuth2Service::OAuth2Service(const QString& auth_url, const QString& token_url,
const QString& client_secret, const QString& scope, QObject* parent)
: QObject(parent),
m_id(QString::number(QRandomGenerator::global()->generate())), m_timerId(-1),
m_redirectionHandler(new OAuthHttpHandler(tr("You can close this window now. Go back to %1.").arg(APP_NAME), this)),
m_redirectionHandler(new OAuthHttpHandler(tr("You can close this window now. Go back to %1.").arg(QSL(APP_NAME)), this)),
m_functorOnLogin(std::function<void()>()) {
m_tokenGrantType = QSL("authorization_code");
m_tokenUrl = QUrl(token_url);
@ -89,10 +89,10 @@ QString OAuth2Service::bearer() {
[this]() {
login();
});
return QString();
return {};
}
else {
return QString("Bearer %1").arg(accessToken());
return QSL("Bearer %1").arg(accessToken());
}
}
@ -212,9 +212,9 @@ void OAuth2Service::tokenRequestFinished(QNetworkReply* network_reply) {
emit tokensRetrieveError(QString(), NetworkFactory::networkErrorText(network_reply->error()));
}
else if (root_obj.keys().contains("error")) {
QString error = root_obj.value("error").toString();
QString error_description = root_obj.value("error_description").toString();
else if (root_obj.keys().contains(QSL("error"))) {
QString error = root_obj.value(QSL("error")).toString();
QString error_description = root_obj.value(QSL("error_description")).toString();
qWarningNN << LOGSEC_OAUTH
<< "JSON error when obtaining token response:"

View file

@ -65,9 +65,9 @@ bool WebFactory::sendMessageViaEmail(const Message& message) {
else {
// Send it via mailto protocol.
// NOTE: http://en.wikipedia.org/wiki/Mailto
return QDesktopServices::openUrl(QString("mailto:?subject=%1&body=%2").arg(QString(QUrl::toPercentEncoding(message.m_title)),
QString(QUrl::toPercentEncoding(stripTags(
message.m_contents)))));
return QDesktopServices::openUrl(QSL("mailto:?subject=%1&body=%2").arg(QString(QUrl::toPercentEncoding(message.m_title)),
QString(QUrl::toPercentEncoding(stripTags(
message.m_contents)))));
}
}
@ -99,7 +99,7 @@ bool WebFactory::openUrlInExternalBrowser(const QString& url) const {
QMessageBox::Icon::Critical,
tr("Navigate to website manually"),
tr("%1 was unable to launch your web browser with the given URL, you need to open the "
"below website URL in your web browser manually.").arg(APP_NAME),
"below website URL in your web browser manually.").arg(QSL(APP_NAME)),
{},
url,
QMessageBox::StandardButton::Ok);
@ -205,10 +205,10 @@ QString WebFactory::unescapeHtml(const QString& html) {
}
QString WebFactory::processFeedUriScheme(const QString& url) {
if (url.startsWith(URI_SCHEME_FEED)) {
if (url.startsWith(QSL(URI_SCHEME_FEED))) {
return QSL(URI_SCHEME_HTTPS) + url.mid(QSL(URI_SCHEME_FEED).size());
}
else if (url.startsWith(URI_SCHEME_FEED_SHORT)) {
else if (url.startsWith(QSL(URI_SCHEME_FEED_SHORT))) {
return url.mid(QSL(URI_SCHEME_FEED_SHORT).size());
}
else {

View file

@ -51,12 +51,12 @@ bool WebPage::acceptNavigationRequest(const QUrl& url, NavigationType type, bool
if (blocked.m_blocked) {
// This website is entirely blocked.
setHtml(qApp->skins()->adBlockedPage(url.toString(), blocked.m_blockedByFilter),
QUrl::fromUserInput(INTERNAL_URL_ADBLOCKED));
QUrl::fromUserInput(QSL(INTERNAL_URL_ADBLOCKED)));
return false;
}
}
if (url.toString().startsWith(INTERNAL_URL_PASSATTACHMENT) &&
if (url.toString().startsWith(QSL(INTERNAL_URL_PASSATTACHMENT)) &&
root != nullptr &&
root->getParentServiceRoot()->downloadAttachmentOnMyOwn(url)) {
return false;

View file

@ -143,7 +143,7 @@ Feed::Status Feed::status() const {
return m_status;
}
void Feed::setStatus(const Feed::Status& status, const QString& status_text) {
void Feed::setStatus(Feed::Status status, const QString& status_text) {
m_status = status;
m_statusString = status_text;
}

View file

@ -68,7 +68,7 @@ class Feed : public RootItem {
Status status() const;
QString statusString() const;
void setStatus(const Status& status, const QString& status_text = {});
void setStatus(Feed::Status status, const QString& status_text = {});
QString source() const;
void setSource(const QString& source);

View file

@ -176,8 +176,8 @@ QVariant RootItem::data(int column, int role) const {
int count_all = countOfAllMessages();
return qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::CountFormat)).toString()
.replace(PLACEHOLDER_UNREAD_COUNTS, count_unread < 0 ? QSL("-") : QString::number(count_unread))
.replace(PLACEHOLDER_ALL_COUNTS, count_all < 0 ? QSL("-") : QString::number(count_all));
.replace(QSL(PLACEHOLDER_UNREAD_COUNTS), count_unread < 0 ? QSL("-") : QString::number(count_unread))
.replace(QSL(PLACEHOLDER_ALL_COUNTS), count_all < 0 ? QSL("-") : QString::number(count_all));
}
}
else {
@ -537,19 +537,19 @@ void RootItem::setCustomId(const QString& custom_id) {
}
Category* RootItem::toCategory() const {
return dynamic_cast<Category*>(const_cast<RootItem*>(this));
return qobject_cast<Category*>(const_cast<RootItem*>(this));
}
Feed* RootItem::toFeed() const {
return dynamic_cast<Feed*>(const_cast<RootItem*>(this));
return qobject_cast<Feed*>(const_cast<RootItem*>(this));
}
Label* RootItem::toLabel() const {
return dynamic_cast<Label*>(const_cast<RootItem*>(this));
return qobject_cast<Label*>(const_cast<RootItem*>(this));
}
ServiceRoot* RootItem::toServiceRoot() const {
return dynamic_cast<ServiceRoot*>(const_cast<RootItem*>(this));
return qobject_cast<ServiceRoot*>(const_cast<RootItem*>(this));
}
bool RootItem::keepOnTop() const {

View file

@ -238,7 +238,7 @@ void ServiceRoot::appendCommonNodes() {
}
}
bool ServiceRoot::cleanFeeds(QList<Feed*> items, bool clean_read_only) {
bool ServiceRoot::cleanFeeds(const QList<Feed*>& items, bool clean_read_only) {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
if (DatabaseQueries::cleanFeeds(database, textualFeedIds(items), clean_read_only, accountId())) {
@ -565,7 +565,7 @@ QStringList ServiceRoot::customIDSOfMessagesForItem(RootItem* item) {
}
}
bool ServiceRoot::markFeedsReadUnread(QList<Feed*> items, RootItem::ReadStatus read) {
bool ServiceRoot::markFeedsReadUnread(const QList<Feed*>& items, RootItem::ReadStatus read) {
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
if (DatabaseQueries::markFeedsReadUnread(database, textualFeedIds(items), accountId(), read)) {
@ -585,26 +585,24 @@ QStringList ServiceRoot::textualFeedUrls(const QList<Feed*>& feeds) const {
stringy_urls.reserve(feeds.size());
for (const Feed* feed : feeds) {
stringy_urls.append(!feed->source().isEmpty() ? feed->source() : QL1S("no-url"));
stringy_urls.append(!feed->source().isEmpty() ? feed->source() : QSL("no-url"));
}
return stringy_urls;
}
QStringList ServiceRoot::textualFeedIds(const QList<Feed*>& feeds) const {
QStringList stringy_ids;
stringy_ids.reserve(feeds.size());
QStringList stringy_ids; stringy_ids.reserve(feeds.size());
for (const Feed* feed : feeds) {
stringy_ids.append(QString("'%1'").arg(feed->customId()));
stringy_ids.append(QSL("'%1'").arg(feed->customId()));
}
return stringy_ids;
}
QStringList ServiceRoot::customIDsOfMessages(const QList<ImportanceChange>& changes) {
QStringList list;
QStringList list; list.reserve(changes.size());
for (const auto& change : changes) {
list.append(change.first.m_customId);
@ -614,7 +612,7 @@ QStringList ServiceRoot::customIDsOfMessages(const QList<ImportanceChange>& chan
}
QStringList ServiceRoot::customIDsOfMessages(const QList<Message>& messages) {
QStringList list;
QStringList list; list.reserve(messages.size());
for (const Message& message : messages) {
list.append(message.m_customId);
@ -639,32 +637,32 @@ void ServiceRoot::setAccountId(int account_id) {
bool ServiceRoot::loadMessagesForItem(RootItem* item, MessagesModel* model) {
if (item->kind() == RootItem::Kind::Bin) {
model->setFilter(QString("Messages.is_deleted = 1 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
model->setFilter(QSL("Messages.is_deleted = 1 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
.arg(QString::number(accountId())));
}
else if (item->kind() == RootItem::Kind::Important) {
model->setFilter(QString("Messages.is_important = 1 AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
model->setFilter(QSL("Messages.is_important = 1 AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
.arg(QString::number(accountId())));
}
else if (item->kind() == RootItem::Kind::Unread) {
model->setFilter(QString("Messages.is_read = 0 AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
model->setFilter(QSL("Messages.is_read = 0 AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1")
.arg(QString::number(accountId())));
}
else if (item->kind() == RootItem::Kind::Label) {
// Show messages with particular label.
model->setFilter(QString("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1 AND "
"(SELECT COUNT(*) FROM LabelsInMessages WHERE account_id = %1 AND message = Messages.custom_id AND label = '%2') > 0")
model->setFilter(QSL("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1 AND "
"(SELECT COUNT(*) FROM LabelsInMessages WHERE account_id = %1 AND message = Messages.custom_id AND label = '%2') > 0")
.arg(QString::number(accountId()), item->customId()));
}
else if (item->kind() == RootItem::Kind::Labels) {
// Show messages with any label.
model->setFilter(QString("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1 AND "
"(SELECT COUNT(*) FROM LabelsInMessages WHERE account_id = %1 AND message = Messages.custom_id) > 0")
model->setFilter(QSL("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1 AND "
"(SELECT COUNT(*) FROM LabelsInMessages WHERE account_id = %1 AND message = Messages.custom_id) > 0")
.arg(QString::number(accountId())));
}
else if (item->kind() == RootItem::Kind::ServiceRoot) {
model->setFilter(
QString("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1").arg(
QSL("Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %1").arg(
QString::number(accountId())));
qDebugNN << "Displaying messages from account:" << QUOTE_W_SPACE_DOT(accountId());
@ -678,7 +676,7 @@ bool ServiceRoot::loadMessagesForItem(RootItem* item, MessagesModel* model) {
}
model->setFilter(
QString("Feeds.custom_id IN (%1) AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %2").arg(
QSL("Feeds.custom_id IN (%1) AND Messages.is_deleted = 0 AND Messages.is_pdeleted = 0 AND Messages.account_id = %2").arg(
filter_clause,
QString::
number(accountId())));
@ -769,7 +767,9 @@ bool ServiceRoot::onAfterMessagesDelete(RootItem* selected_item, const QList<Mes
return true;
}
bool ServiceRoot::onBeforeLabelMessageAssignmentChanged(const QList<Label*> labels, const QList<Message>& messages, bool assign) {
bool ServiceRoot::onBeforeLabelMessageAssignmentChanged(const QList<Label*>& labels,
const QList<Message>& messages,
bool assign) {
auto cache = dynamic_cast<CacheForServiceRoot*>(this);
if (cache != nullptr) {
@ -781,7 +781,9 @@ bool ServiceRoot::onBeforeLabelMessageAssignmentChanged(const QList<Label*> labe
return true;
}
bool ServiceRoot::onAfterLabelMessageAssignmentChanged(const QList<Label*> labels, const QList<Message>& messages, bool assign) {
bool ServiceRoot::onAfterLabelMessageAssignmentChanged(const QList<Label*>& labels,
const QList<Message>& messages,
bool assign) {
Q_UNUSED(messages)
Q_UNUSED(assign)
@ -817,7 +819,7 @@ CacheForServiceRoot* ServiceRoot::toCache() const {
return dynamic_cast<CacheForServiceRoot*>(const_cast<ServiceRoot*>(this));
}
void ServiceRoot::assembleFeeds(Assignment feeds) {
void ServiceRoot::assembleFeeds(const Assignment& feeds) {
QHash<int, Category*> categories = getHashedSubTreeCategories();
for (const AssignmentItem& feed : feeds) {
@ -835,24 +837,25 @@ void ServiceRoot::assembleFeeds(Assignment feeds) {
}
}
void ServiceRoot::assembleCategories(Assignment categories) {
void ServiceRoot::assembleCategories(const Assignment& categories) {
Assignment editable_categories = categories;
QHash<int, RootItem*> assignments;
assignments.insert(NO_PARENT_CATEGORY, this);
// Add top-level categories.
while (!categories.isEmpty()) {
for (int i = 0; i < categories.size(); i++) {
if (assignments.contains(categories.at(i).first)) {
while (!editable_categories.isEmpty()) {
for (int i = 0; i < editable_categories.size(); i++) {
if (assignments.contains(editable_categories.at(i).first)) {
// Parent category of this category is already added.
assignments.value(categories.at(i).first)->appendChild(categories.at(i).second);
assignments.value(editable_categories.at(i).first)->appendChild(editable_categories.at(i).second);
// Now, added category can be parent for another categories, add it.
assignments.insert(categories.at(i).second->id(), categories.at(i).second);
assignments.insert(editable_categories.at(i).second->id(), editable_categories.at(i).second);
// Remove the category from the list, because it was
// added to the final collection.
categories.removeAt(i);
editable_categories.removeAt(i);
i--;
}
}

View file

@ -160,10 +160,14 @@ class ServiceRoot : public RootItem {
virtual bool onAfterMessagesDelete(RootItem* selected_item, const QList<Message>& messages);
// Called BEFORE some labels are assigned/deassigned from/to messages.
virtual bool onBeforeLabelMessageAssignmentChanged(const QList<Label*> labels, const QList<Message>& messages, bool assign);
virtual bool onBeforeLabelMessageAssignmentChanged(const QList<Label*>& labels,
const QList<Message>& messages,
bool assign);
// Called AFTER some labels are assigned/deassigned from/to messages.
virtual bool onAfterLabelMessageAssignmentChanged(const QList<Label*> labels, const QList<Message>& messages, bool assign);
virtual bool onAfterLabelMessageAssignmentChanged(const QList<Label*>& labels,
const QList<Message>& messages,
bool assign);
// Called BEFORE the list of messages is about to be restored from recycle bin
// by the user from message list.
@ -199,10 +203,10 @@ class ServiceRoot : public RootItem {
QIcon feedIconForMessage(const QString& feed_custom_id) const;
// Removes all/read only messages from given underlying feeds.
bool cleanFeeds(QList<Feed*> items, bool clean_read_only);
bool cleanFeeds(const QList<Feed*>& items, bool clean_read_only);
// Marks all messages from feeds read/unread.
bool markFeedsReadUnread(QList<Feed*> items, ReadStatus read);
bool markFeedsReadUnread(const QList<Feed*>& items, ReadStatus read);
// Obvious methods to wrap signals.
void itemChanged(const QList<RootItem*>& items);
@ -258,8 +262,8 @@ class ServiceRoot : public RootItem {
void removeLeftOverMessageLabelAssignments();
// Takes lists of feeds/categories and assembles them into the tree structure.
void assembleCategories(Assignment categories);
void assembleFeeds(Assignment feeds);
void assembleCategories(const Assignment& categories);
void assembleFeeds(const Assignment& feeds);
signals:
void proxyChanged(QNetworkProxy proxy);

View file

@ -27,7 +27,7 @@ QString FeedlyEntryPoint::name() const {
}
QString FeedlyEntryPoint::code() const {
return SERVICE_CODE_FEEDLY;
return QSL(SERVICE_CODE_FEEDLY);
}
QString FeedlyEntryPoint::description() const {
@ -37,7 +37,7 @@ QString FeedlyEntryPoint::description() const {
}
QString FeedlyEntryPoint::author() const {
return APP_AUTHOR;
return QSL(APP_AUTHOR);
}
QIcon FeedlyEntryPoint::icon() const {

View file

@ -26,17 +26,17 @@
FeedlyNetwork::FeedlyNetwork(QObject* parent)
: QObject(parent), m_service(nullptr),
#if defined(FEEDLY_OFFICIAL_SUPPORT)
m_oauth(new OAuth2Service(QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_AUTH,
QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_TOKEN,
TextFactory::decrypt(FEEDLY_CLIENT_ID, OAUTH_DECRYPTION_KEY),
TextFactory::decrypt(FEEDLY_CLIENT_SECRET, OAUTH_DECRYPTION_KEY),
FEEDLY_API_SCOPE, this)),
m_oauth(new OAuth2Service(QSL(FEEDLY_API_URL_BASE) + QSL(FEEDLY_API_URL_AUTH),
QSL(FEEDLY_API_URL_BASE) + QSL(FEEDLY_API_URL_TOKEN),
TextFactory::decrypt(QSL(FEEDLY_CLIENT_ID), OAUTH_DECRYPTION_KEY),
TextFactory::decrypt(QSL(FEEDLY_CLIENT_SECRET), OAUTH_DECRYPTION_KEY),
QSL(FEEDLY_API_SCOPE), this)),
#endif
m_username(QString()),
m_developerAccessToken(QString()), m_batchSize(FEEDLY_DEFAULT_BATCH_SIZE), m_downloadOnlyUnreadMessages(false) {
#if defined(FEEDLY_OFFICIAL_SUPPORT)
m_oauth->setRedirectUrl(QString(OAUTH_REDIRECT_URI) + QL1C(':') + QString::number(FEEDLY_API_REDIRECT_URI_PORT),
m_oauth->setRedirectUrl(QSL(OAUTH_REDIRECT_URI) + QL1C(':') + QString::number(FEEDLY_API_REDIRECT_URI_PORT),
true);
connect(m_oauth, &OAuth2Service::tokensRetrieveError, this, &FeedlyNetwork::onTokensError);
@ -108,7 +108,7 @@ void FeedlyNetwork::tagEntries(const QString& tag_id, const QStringList& msg_cus
QByteArray input_data;
QJsonObject input;
input["entryIds"] = QJsonArray::fromStringList(msg_custom_ids);
input[QSL("entryIds")] = QJsonArray::fromStringList(msg_custom_ids);
input_data = QJsonDocument(input).toJson(QJsonDocument::JsonFormat::Compact);
auto result = NetworkFactory::performNetworkOperation(target_url,
@ -145,9 +145,9 @@ void FeedlyNetwork::markers(const QString& action, const QStringList& msg_custom
QByteArray output;
QJsonObject input;
input["action"] = action;
input["type"] = QSL("entries");
input["entryIds"] = QJsonArray::fromStringList(msg_custom_ids);
input[QSL("action")] = action;
input[QSL("type")] = QSL("entries");
input[QSL("entryIds")] = QJsonArray::fromStringList(msg_custom_ids);
QByteArray input_data = QJsonDocument(input).toJson(QJsonDocument::JsonFormat::Compact);
auto result = NetworkFactory::performNetworkOperation(target_url,
@ -230,53 +230,53 @@ QList<Message> FeedlyNetwork::decodeStreamContents(const QByteArray& stream_cont
QJsonDocument json = QJsonDocument::fromJson(stream_contents);
auto active_labels = m_service->labelsNode() != nullptr ? m_service->labelsNode()->labels() : QList<Label*>();
continuation = json.object()["continuation"].toString();
continuation = json.object()[QSL("continuation")].toString();
auto items = json.object()["items"].toArray();
auto items = json.object()[QSL("items")].toArray();
for (const QJsonValue& entry : qAsConst(items)) {
const QJsonObject& entry_obj = entry.toObject();
Message message;
message.m_feedId = entry_obj["origin"].toObject()["streamId"].toString();
message.m_title = entry_obj["title"].toString();
message.m_author = entry_obj["author"].toString();
message.m_contents = entry_obj["content"].toObject()["content"].toString();
message.m_feedId = entry_obj[QSL("origin")].toObject()[QSL("streamId")].toString();
message.m_title = entry_obj[QSL("title")].toString();
message.m_author = entry_obj[QSL("author")].toString();
message.m_contents = entry_obj[QSL("content")].toObject()[QSL("content")].toString();
message.m_rawContents = QJsonDocument(entry_obj).toJson(QJsonDocument::JsonFormat::Compact);
if (message.m_contents.isEmpty()) {
message.m_contents = entry_obj["summary"].toObject()["content"].toString();
message.m_contents = entry_obj[QSL("summary")].toObject()[QSL("content")].toString();
}
message.m_createdFromFeed = true;
message.m_created = QDateTime::fromMSecsSinceEpoch(entry_obj["published"].toVariant().toLongLong(),
message.m_created = QDateTime::fromMSecsSinceEpoch(entry_obj[QSL("published")].toVariant().toLongLong(),
Qt::TimeSpec::UTC);
message.m_customId = entry_obj["id"].toString();
message.m_isRead = !entry_obj["unread"].toBool();
message.m_url = entry_obj["canonicalUrl"].toString();
message.m_customId = entry_obj[QSL("id")].toString();
message.m_isRead = !entry_obj[QSL("unread")].toBool();
message.m_url = entry_obj[QSL("canonicalUrl")].toString();
if (message.m_url.isEmpty()) {
message.m_url = entry_obj["canonical"].toObject()["href"].toString();
message.m_url = entry_obj[QSL("canonical")].toObject()[QSL("href")].toString();
}
auto enclosures = entry_obj["enclosure"].toArray();
auto enclosures = entry_obj[QSL("enclosure")].toArray();
for (const QJsonValue& enc : qAsConst(enclosures)) {
const QJsonObject& enc_obj = enc.toObject();
const QString& enc_href = enc_obj["href"].toString();
const QString& enc_href = enc_obj[QSL("href")].toString();
if (!boolinq::from(message.m_enclosures).any([enc_href](const Enclosure& existing_enclosure) {
return existing_enclosure.m_url == enc_href;
})) {
message.m_enclosures.append(Enclosure(enc_href, enc_obj["type"].toString()));
message.m_enclosures.append(Enclosure(enc_href, enc_obj[QSL("type")].toString()));
}
}
auto tags = entry_obj["tags"].toArray();
auto tags = entry_obj[QSL("tags")].toArray();
for (const QJsonValue& tag : qAsConst(tags)) {
const QJsonObject& tag_obj = tag.toObject();
const QString& tag_id = tag_obj["id"].toString();
const QString& tag_id = tag_obj[QSL("id")].toString();
if (tag_id.endsWith(FEEDLY_API_SYSTEM_TAG_SAVED)) {
message.m_isImportant = true;
@ -346,33 +346,34 @@ RootItem* FeedlyNetwork::decodeCollections(const QByteArray& json, bool obtain_i
QJsonObject cat_obj = cat.toObject();
auto* category = new Category(parent);
category->setTitle(cat_obj["label"].toString());
category->setCustomId(cat_obj["id"].toString());
category->setTitle(cat_obj[QSL("label")].toString());
category->setCustomId(cat_obj[QSL("id")].toString());
auto feeds = cat["feeds"].toArray();
auto feeds = cat[QSL("feeds")].toArray();
for (const QJsonValue& fee : qAsConst(feeds)) {
QJsonObject fee_obj = fee.toObject();
if (used_feeds.contains(fee_obj["id"].toString())) {
if (used_feeds.contains(fee_obj[QSL("id")].toString())) {
qWarningNN << LOGSEC_FEEDLY
<< "Feed"
<< QUOTE_W_SPACE(fee_obj["id"].toString())
<< QUOTE_W_SPACE(fee_obj[QSL("id")].toString())
<< "is already decoded and cannot be placed under several categories.";
continue;
}
auto* feed = new Feed(category);
feed->setTitle(fee_obj["title"].toString());
feed->setDescription(fee_obj["description"].toString());
feed->setCustomId(fee_obj["id"].toString());
feed->setSource(fee_obj[QSL("website")].toString());
feed->setTitle(fee_obj[QSL("title")].toString());
feed->setDescription(fee_obj[QSL("description")].toString());
feed->setCustomId(fee_obj[QSL("id")].toString());
if (obtain_icons) {
QIcon icon;
auto result = NetworkFactory::downloadIcon({ { fee_obj["iconUrl"].toString(), true },
{ fee_obj["website"].toString(), false },
{ fee_obj["logo"].toString(), true } },
auto result = NetworkFactory::downloadIcon({ { fee_obj[QSL("iconUrl")].toString(), true },
{ fee_obj[QSL("website")].toString(), false },
{ fee_obj[QSL("logo")].toString(), true } },
timeout,
icon,
proxy);
@ -461,14 +462,14 @@ QList<RootItem*> FeedlyNetwork::tags() {
for (const QJsonValue& tag : qAsConst(tags)) {
const QJsonObject& tag_obj = tag.toObject();
QString name_id = tag_obj["id"].toString();
QString name_id = tag_obj[QSL("id")].toString();
if (name_id.endsWith(FEEDLY_API_SYSTEM_TAG_READ) ||
name_id.endsWith(FEEDLY_API_SYSTEM_TAG_SAVED)) {
continue;
}
QString plain_name = tag_obj["label"].toString();
QString plain_name = tag_obj[QSL("label")].toString();
auto* new_lbl = new Label(plain_name, TextFactory::generateColorFromText(name_id));
new_lbl->setCustomId(name_id);
@ -559,23 +560,23 @@ void FeedlyNetwork::setOauth(OAuth2Service* oauth) {
QString FeedlyNetwork::fullUrl(FeedlyNetwork::Service service) const {
switch (service) {
case Service::Profile:
return QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_PROFILE;
return QSL(FEEDLY_API_URL_BASE) + QSL(FEEDLY_API_URL_PROFILE);
case Service::Collections:
return QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_COLLETIONS;
return QSL(FEEDLY_API_URL_BASE) + QSL(FEEDLY_API_URL_COLLETIONS);
case Service::Tags:
case Service::TagEntries:
return QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_TAGS;
return QSL(FEEDLY_API_URL_BASE) + QSL(FEEDLY_API_URL_TAGS);
case Service::StreamContents:
return QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_STREAM_CONTENTS;
return QSL(FEEDLY_API_URL_BASE) + QSL(FEEDLY_API_URL_STREAM_CONTENTS);
case Service::Markers:
return QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_MARKERS;
return QSL(FEEDLY_API_URL_BASE) + QSL(FEEDLY_API_URL_MARKERS);
default:
return FEEDLY_API_URL_BASE;
return QSL(FEEDLY_API_URL_BASE);
}
}
@ -586,11 +587,11 @@ QString FeedlyNetwork::bearer() const {
}
#endif
return QString("Bearer %1").arg(m_developerAccessToken);
return QSL("Bearer %1").arg(m_developerAccessToken);
}
QPair<QByteArray, QByteArray> FeedlyNetwork::bearerHeader(const QString& bearer) const {
return { QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), bearer.toLocal8Bit() };
return { QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), bearer.toLocal8Bit() };
}
bool FeedlyNetwork::downloadOnlyUnreadMessages() const {

View file

@ -47,29 +47,29 @@ bool FeedlyServiceRoot::editViaGui() {
QVariantHash FeedlyServiceRoot::customDatabaseData() const {
QVariantHash data;
data["username"] = m_network->username();
data["dat"] = m_network->developerAccessToken();
data[QSL("username")] = m_network->username();
data[QSL("dat")] = m_network->developerAccessToken();
#if defined(FEEDLY_OFFICIAL_SUPPORT)
data["refresh_token"] = m_network->oauth()->refreshToken();
data[QSL("refresh_token")] = m_network->oauth()->refreshToken();
#endif
data["batch_size"] = m_network->batchSize();
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
data[QSL("batch_size")] = m_network->batchSize();
data[QSL("download_only_unread")] = m_network->downloadOnlyUnreadMessages();
return data;
}
void FeedlyServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
m_network->setUsername(data["username"].toString());
m_network->setDeveloperAccessToken(data["dat"].toString());
m_network->setUsername(data[QSL("username")].toString());
m_network->setDeveloperAccessToken(data[QSL("dat")].toString());
#if defined(FEEDLY_OFFICIAL_SUPPORT)
m_network->oauth()->setRefreshToken(data["refresh_token"].toString());
m_network->oauth()->setRefreshToken(data[QSL("refresh_token")].toString());
#endif
m_network->setBatchSize(data["batch_size"].toInt());
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
m_network->setBatchSize(data[QSL("batch_size")].toInt());
m_network->setDownloadOnlyUnreadMessages(data[QSL("download_only_unread")].toBool());
}
QList<Message> FeedlyServiceRoot::obtainNewMessages(Feed* feed,
@ -128,8 +128,8 @@ void FeedlyServiceRoot::saveAllCachedData(bool ignore_errors) {
if (!ids.isEmpty()) {
try {
network()->markers(key == RootItem::ReadStatus::Read
? FEEDLY_MARKERS_READ
: FEEDLY_MARKERS_UNREAD, ids);
? QSL(FEEDLY_MARKERS_READ)
: QSL(FEEDLY_MARKERS_UNREAD), ids);
}
catch (const NetworkException& net_ex) {
qCriticalNN << LOGSEC_FEEDLY
@ -237,7 +237,7 @@ ServiceRoot::LabelOperation FeedlyServiceRoot::supportedLabelOperations() const
}
void FeedlyServiceRoot::updateTitle() {
setTitle(QString("%1 (Feedly)").arg(TextFactory::extractUsernameFromEmail(m_network->username())));
setTitle(QSL("%1 (Feedly)").arg(TextFactory::extractUsernameFromEmail(m_network->username())));
}
RootItem* FeedlyServiceRoot::obtainNewTreeForSyncIn() const {

View file

@ -68,7 +68,7 @@ FeedlyAccountDetails::FeedlyAccountDetails(QWidget* parent) : QWidget(parent), m
}
void FeedlyAccountDetails::getDeveloperAccessToken() {
qApp->web()->openUrlInExternalBrowser(FEEDLY_GENERATE_DAT);
qApp->web()->openUrlInExternalBrowser(QSL(FEEDLY_GENERATE_DAT));
}
#if defined(FEEDLY_OFFICIAL_SUPPORT)
@ -101,7 +101,7 @@ void FeedlyAccountDetails::onAuthGranted() {
try {
auto prof = factory.profile(m_lastProxy);
m_ui.m_txtUsername->lineEdit()->setText(prof["email"].toString());
m_ui.m_txtUsername->lineEdit()->setText(prof[QSL("email")].toString());
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok,
tr("Tested successfully. You may be prompted to login once more."),
tr("Your access was approved."));
@ -134,7 +134,7 @@ void FeedlyAccountDetails::performTest(const QNetworkProxy& custom_proxy) {
try {
auto prof = factory.profile(custom_proxy);
m_ui.m_txtUsername->lineEdit()->setText(prof["email"].toString());
m_ui.m_txtUsername->lineEdit()->setText(prof[QSL("email")].toString());
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok,
tr("Login was successful."),
tr("Access granted."));

View file

@ -2,9 +2,9 @@
#include "services/gmail/gmailentrypoint.h"
#include "database/databasequeries.h"
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "database/databasequeries.h"
#include "miscellaneous/iconfactory.h"
#include "services/gmail/definitions.h"
#include "services/gmail/gmailserviceroot.h"
@ -29,7 +29,7 @@ QString GmailEntryPoint::name() const {
}
QString GmailEntryPoint::code() const {
return SERVICE_CODE_GMAIL;
return QSL(SERVICE_CODE_GMAIL);
}
QString GmailEntryPoint::description() const {
@ -37,7 +37,7 @@ QString GmailEntryPoint::description() const {
}
QString GmailEntryPoint::author() const {
return APP_AUTHOR;
return QSL(APP_AUTHOR);
}
QIcon GmailEntryPoint::icon() const {

View file

@ -29,8 +29,8 @@
GmailNetworkFactory::GmailNetworkFactory(QObject* parent) : QObject(parent),
m_service(nullptr), m_username(QString()), m_batchSize(GMAIL_DEFAULT_BATCH_SIZE),
m_downloadOnlyUnreadMessages(false),
m_oauth2(new OAuth2Service(GMAIL_OAUTH_AUTH_URL, GMAIL_OAUTH_TOKEN_URL,
{}, {}, GMAIL_OAUTH_SCOPE, this)) {
m_oauth2(new OAuth2Service(QSL(GMAIL_OAUTH_AUTH_URL), QSL(GMAIL_OAUTH_TOKEN_URL),
{}, {}, QSL(GMAIL_OAUTH_SCOPE), this)) {
initializeOauth();
}
@ -83,13 +83,13 @@ QString GmailNetworkFactory::sendEmail(Mimesis::Message msg, const QNetworkProxy
QByteArray input_data = rfc_email.toUtf8();
QList<QPair<QByteArray, QByteArray>> headers;
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
m_oauth2->bearer().toLocal8Bit()));
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(),
QString("message/rfc822").toLocal8Bit()));
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(),
QSL("message/rfc822").toLocal8Bit()));
QByteArray out;
auto result = NetworkFactory::performNetworkOperation(GMAIL_API_SEND_MESSAGE,
auto result = NetworkFactory::performNetworkOperation(QSL(GMAIL_API_SEND_MESSAGE),
DOWNLOAD_TIMEOUT,
input_data,
out,
@ -103,7 +103,7 @@ QString GmailNetworkFactory::sendEmail(Mimesis::Message msg, const QNetworkProxy
if (result.first != QNetworkReply::NetworkError::NoError) {
if (!out.isEmpty()) {
QJsonDocument doc = QJsonDocument::fromJson(out);
auto json_message = doc.object()["error"].toObject()["message"].toString();
auto json_message = doc.object()[QSL("error")].toObject()[QSL("message")].toString();
throw ApplicationException(json_message);
}
@ -113,7 +113,7 @@ QString GmailNetworkFactory::sendEmail(Mimesis::Message msg, const QNetworkProxy
}
else {
QJsonDocument doc = QJsonDocument::fromJson(out);
auto msg_id = doc.object()["id"].toString();
auto msg_id = doc.object()[QSL("id")].toString();
return msg_id;
}
@ -121,11 +121,11 @@ QString GmailNetworkFactory::sendEmail(Mimesis::Message msg, const QNetworkProxy
void GmailNetworkFactory::initializeOauth() {
#if defined(GMAIL_OFFICIAL_SUPPORT)
m_oauth2->setClientSecretId(TextFactory::decrypt(GMAIL_CLIENT_ID, OAUTH_DECRYPTION_KEY));
m_oauth2->setClientSecretSecret(TextFactory::decrypt(GMAIL_CLIENT_SECRET, OAUTH_DECRYPTION_KEY));
m_oauth2->setClientSecretId(TextFactory::decrypt(QSL(GMAIL_CLIENT_ID), OAUTH_DECRYPTION_KEY));
m_oauth2->setClientSecretSecret(TextFactory::decrypt(QSL(GMAIL_CLIENT_SECRET), OAUTH_DECRYPTION_KEY));
#endif
m_oauth2->setRedirectUrl(QString(OAUTH_REDIRECT_URI) +
m_oauth2->setRedirectUrl(QSL(OAUTH_REDIRECT_URI) +
QL1C(':') +
QString::number(GMAIL_OAUTH_REDIRECT_URI_PORT),
true);
@ -170,13 +170,13 @@ Downloader* GmailNetworkFactory::downloadAttachment(const QString& msg_id,
}
else {
auto* downloader = new Downloader();
QString target_url = QString(GMAIL_API_GET_ATTACHMENT).arg(msg_id, attachment_id);
QString target_url = QSL(GMAIL_API_GET_ATTACHMENT).arg(msg_id, attachment_id);
if (custom_proxy.type() != QNetworkProxy::ProxyType::DefaultProxy) {
downloader->setProxy(custom_proxy);
}
downloader->appendRawHeader(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), bearer.toLocal8Bit());
downloader->appendRawHeader(QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), bearer.toLocal8Bit());
downloader->downloadFile(target_url);
return downloader;
@ -201,15 +201,15 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id,
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
do {
target_url = GMAIL_API_MSGS_LIST;
target_url += QString("?labelIds=%1").arg(stream_id);
target_url = QSL(GMAIL_API_MSGS_LIST);
target_url += QSL("?labelIds=%1").arg(stream_id);
if (downloadOnlyUnreadMessages()) {
target_url += QString("&labelIds=%1").arg(GMAIL_SYSTEM_LABEL_UNREAD);
target_url += QSL("&labelIds=%1").arg(QSL(GMAIL_SYSTEM_LABEL_UNREAD));
}
if (batchSize() > 0) {
target_url += QString("&maxResults=%1").arg(batchSize());
target_url += QSL("&maxResults=%1").arg(batchSize());
}
if (!next_page_token.isEmpty()) {
@ -222,7 +222,7 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id,
{},
messages_raw_data,
QNetworkAccessManager::Operation::GetOperation,
{ { QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
{ { QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
bearer.toLocal8Bit() } },
false,
{},
@ -265,7 +265,7 @@ QList<Message> GmailNetworkFactory::messages(const QString& stream_id,
}
QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::ReadStatus status,
QStringList custom_ids,
const QStringList& custom_ids,
const QNetworkProxy& custom_proxy) {
QString bearer = m_oauth2->bearer().toLocal8Bit();
@ -275,10 +275,10 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::Read
QList<QPair<QByteArray, QByteArray>> headers;
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
m_oauth2->bearer().toLocal8Bit()));
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(),
QString(GMAIL_CONTENT_TYPE_JSON).toLocal8Bit()));
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(),
QSL(GMAIL_CONTENT_TYPE_JSON).toLocal8Bit()));
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QJsonObject param_obj;
@ -293,18 +293,18 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesRead(RootItem::Read
param_add.append(GMAIL_SYSTEM_LABEL_UNREAD);
}
param_obj["addLabelIds"] = param_add;
param_obj["removeLabelIds"] = param_remove;
param_obj[QSL("addLabelIds")] = param_add;
param_obj[QSL("removeLabelIds")] = param_remove;
// We need to operate withing allowed batches.
for (int i = 0; i < custom_ids.size(); i += GMAIL_MAX_BATCH_SIZE) {
auto batch = custom_ids.mid(i, GMAIL_MAX_BATCH_SIZE);
param_obj["ids"] = QJsonArray::fromStringList(batch);
param_obj[QSL("ids")] = QJsonArray::fromStringList(batch);
QJsonDocument param_doc(param_obj);
QByteArray output;
auto result = NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
auto result = NetworkFactory::performNetworkOperation(QSL(GMAIL_API_BATCH_UPD_LABELS),
timeout,
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
output,
@ -334,10 +334,10 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesStarred(RootItem::I
QList<QPair<QByteArray, QByteArray>> headers;
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
m_oauth2->bearer().toLocal8Bit()));
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(),
QString(GMAIL_CONTENT_TYPE_JSON).toLocal8Bit()));
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_CONTENT_TYPE).toLocal8Bit(),
QSL(GMAIL_CONTENT_TYPE_JSON).toLocal8Bit()));
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QJsonObject param_obj;
@ -352,18 +352,18 @@ QNetworkReply::NetworkError GmailNetworkFactory::markMessagesStarred(RootItem::I
param_remove.append(GMAIL_SYSTEM_LABEL_STARRED);
}
param_obj["addLabelIds"] = param_add;
param_obj["removeLabelIds"] = param_remove;
param_obj[QSL("addLabelIds")] = param_add;
param_obj[QSL("removeLabelIds")] = param_remove;
// We need to operate withing allowed batches.
for (int i = 0; i < custom_ids.size(); i += GMAIL_MAX_BATCH_SIZE) {
auto batch = custom_ids.mid(i, GMAIL_MAX_BATCH_SIZE);
param_obj["ids"] = QJsonArray::fromStringList(batch);
param_obj[QSL("ids")] = QJsonArray::fromStringList(batch);
QJsonDocument param_doc(param_obj);
QByteArray output;
auto result = NetworkFactory::performNetworkOperation(GMAIL_API_BATCH_UPD_LABELS,
auto result = NetworkFactory::performNetworkOperation(QSL(GMAIL_API_BATCH_UPD_LABELS),
timeout,
param_doc.toJson(QJsonDocument::JsonFormat::Compact),
output,
@ -391,12 +391,12 @@ QVariantHash GmailNetworkFactory::getProfile(const QNetworkProxy& custom_proxy)
QList<QPair<QByteArray, QByteArray>> headers;
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
m_oauth2->bearer().toLocal8Bit()));
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray output;
auto result = NetworkFactory::performNetworkOperation(GMAIL_API_GET_PROFILE,
auto result = NetworkFactory::performNetworkOperation(QSL(GMAIL_API_GET_PROFILE),
timeout,
{},
output,
@ -447,48 +447,48 @@ void GmailNetworkFactory::onAuthFailed() {
bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json, const QString& feed_id) {
QHash<QString, QString> headers;
auto json_headers = json["payload"].toObject()["headers"].toArray();
auto json_headers = json[QSL("payload")].toObject()[QSL("headers")].toArray();
for (const QJsonValue& header : qAsConst(json_headers)) {
headers.insert(header.toObject()["name"].toString(), header.toObject()["value"].toString());
headers.insert(header.toObject()[QSL("name")].toString(), header.toObject()["value"].toString());
}
msg.m_isRead = true;
msg.m_rawContents = QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact);
// Assign correct main labels/states.
auto labelids = json["labelIds"].toArray().toVariantList();
auto labelids = json[QSL("labelIds")].toArray().toVariantList();
for (const QVariant& label : qAsConst(labelids)) {
QString lbl = label.toString();
if (lbl == QL1S(GMAIL_SYSTEM_LABEL_UNREAD)) {
if (lbl == QSL(GMAIL_SYSTEM_LABEL_UNREAD)) {
msg.m_isRead = false;
}
else if (lbl == QL1S(GMAIL_SYSTEM_LABEL_STARRED)) {
else if (lbl == QSL(GMAIL_SYSTEM_LABEL_STARRED)) {
msg.m_isImportant = true;
}
// RSS Guard does not support multi-labeling of messages, thus each message can have MAX single label.
// Every message which is in INBOX, must be in INBOX, even if Gmail API returns more labels for the message.
// I have to always decide which single label is most important one.
if (lbl == QL1S(GMAIL_SYSTEM_LABEL_INBOX) && feed_id != QL1S(GMAIL_SYSTEM_LABEL_INBOX)) {
if (lbl == QSL(GMAIL_SYSTEM_LABEL_INBOX) && feed_id != QSL(GMAIL_SYSTEM_LABEL_INBOX)) {
// This message is in INBOX label too, but this updated feed is not INBOX,
// we want to leave this message in INBOX and not duplicate it to other feed/label.
return false;
}
if (lbl == QL1S(GMAIL_SYSTEM_LABEL_TRASH) && feed_id != QL1S(GMAIL_SYSTEM_LABEL_TRASH)) {
if (lbl == QSL(GMAIL_SYSTEM_LABEL_TRASH) && feed_id != QSL(GMAIL_SYSTEM_LABEL_TRASH)) {
// This message is in trash, but this updated feed is not recycle bin, we do not want
// this message to appear anywhere.
return false;
}
}
msg.m_author = headers["From"];
msg.m_title = headers["Subject"];
msg.m_author = headers[QSL("From")];
msg.m_title = headers[QSL("Subject")];
msg.m_createdFromFeed = true;
msg.m_created = TextFactory::parseDateTime(headers["Date"]);
msg.m_created = TextFactory::parseDateTime(headers[QSL("Date")]);
QString aa = msg.m_rawContents;
@ -499,11 +499,11 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
QString backup_contents;
QList<QJsonObject> parts_to_process, parts;
parts_to_process.append(json["payload"].toObject());
parts_to_process.append(json[QSL("payload")].toObject());
while (!parts_to_process.isEmpty()) {
auto this_part = parts_to_process.takeFirst();
auto nested_parts = this_part["parts"].toArray();
auto nested_parts = this_part[QSL("parts")].toArray();
for (const QJsonValue& prt : qAsConst(nested_parts)) {
auto prt_obj = prt.toObject();
@ -513,24 +513,24 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
}
}
if (json["payload"].toObject().contains(QSL("body"))) {
parts.prepend(json["payload"].toObject());
if (json[QSL("payload")].toObject().contains(QSL("body"))) {
parts.prepend(json[QSL("payload")].toObject());
}
for (const QJsonObject& part : qAsConst(parts)) {
QJsonObject body = part["body"].toObject();
QString mime = part["mimeType"].toString();
QString filename = part["filename"].toString();
QJsonObject body = part[QSL("body")].toObject();
QString mime = part[QSL("mimeType")].toString();
QString filename = part[QSL("filename")].toString();
if (filename.isEmpty() && mime.startsWith(QSL("text/"))) {
// We have textual data of e-mail.
// We check if it is HTML.
if (msg.m_contents.isEmpty()) {
if (mime.contains(QL1S("text/html"))) {
msg.m_contents = QByteArray::fromBase64(body["data"].toString().toUtf8(), QByteArray::Base64Option::Base64UrlEncoding);
msg.m_contents = QByteArray::fromBase64(body[QSL("data")].toString().toUtf8(), QByteArray::Base64Option::Base64UrlEncoding);
}
else if (backup_contents.isEmpty()) {
backup_contents = QByteArray::fromBase64(body["data"].toString().toUtf8(), QByteArray::Base64Option::Base64UrlEncoding);
backup_contents = QByteArray::fromBase64(body[QSL("data")].toString().toUtf8(), QByteArray::Base64Option::Base64UrlEncoding);
backup_contents = backup_contents
.replace(QSL("\r\n"), QSL("\n"))
@ -542,8 +542,8 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
else if (!filename.isEmpty()) {
// We have attachment.
msg.m_enclosures.append(Enclosure(filename +
QL1S(GMAIL_ATTACHMENT_SEP) + msg.m_customId +
QL1S(GMAIL_ATTACHMENT_SEP) + body["attachmentId"].toString(),
QSL(GMAIL_ATTACHMENT_SEP) + msg.m_customId +
QSL(GMAIL_ATTACHMENT_SEP) + body[QSL("attachmentId")].toString(),
filename + QString(" (%1 KB)").arg(QString::number(body["size"].toInt() / 1000.0))));
}
}
@ -555,7 +555,9 @@ bool GmailNetworkFactory::fillFullMessage(Message& msg, const QJsonObject& json,
return true;
}
QMap<QString, QString> GmailNetworkFactory::getMessageMetadata(const QString& msg_id, const QStringList& metadata, const QNetworkProxy& custom_proxy) {
QMap<QString, QString> GmailNetworkFactory::getMessageMetadata(const QString& msg_id,
const QStringList& metadata,
const QNetworkProxy& custom_proxy) {
QString bearer = m_oauth2->bearer();
if (bearer.isEmpty()) {
@ -566,10 +568,10 @@ QMap<QString, QString> GmailNetworkFactory::getMessageMetadata(const QString& ms
QByteArray output;
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
bearer.toLocal8Bit()));
QString query = QString("%1/%2?format=metadata&metadataHeaders=%3").arg(GMAIL_API_MSGS_LIST,
QString query = QString("%1/%2?format=metadata&metadataHeaders=%3").arg(QSL(GMAIL_API_MSGS_LIST),
msg_id,
metadata.join(QSL("&metadataHeaders=")));
NetworkResult res = NetworkFactory::performNetworkOperation(query,
@ -586,12 +588,12 @@ QMap<QString, QString> GmailNetworkFactory::getMessageMetadata(const QString& ms
if (res.first == QNetworkReply::NetworkError::NoError) {
QJsonDocument doc = QJsonDocument::fromJson(output);
QMap<QString, QString> result;
auto json_headers = doc.object()["payload"].toObject()["headers"].toArray();
auto json_headers = doc.object()[QSL("payload")].toObject()[QSL("headers")].toArray();
for (const auto& header : json_headers) {
QJsonObject obj_header = header.toObject();
result.insert(obj_header["name"].toString(), obj_header["value"].toString());
result.insert(obj_header[QSL("name")].toString(), obj_header[QSL("value")].toString());
}
return result;
@ -622,7 +624,7 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(QList<Message>& messages,
QHttpPart part;
part.setRawHeader(HTTP_HEADERS_CONTENT_TYPE, GMAIL_CONTENT_TYPE_HTTP);
QString full_msg_endpoint = QString("GET /gmail/v1/users/me/messages/%1\r\n").arg(msg.m_customId);
QString full_msg_endpoint = QSL("GET /gmail/v1/users/me/messages/%1\r\n").arg(msg.m_customId);
part.setBody(full_msg_endpoint.toUtf8());
multi->append(part);
@ -633,7 +635,7 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(QList<Message>& messages,
QList<HttpResponse> output;
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
headers.append(QPair<QByteArray, QByteArray>(QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
bearer.toLocal8Bit()));
NetworkResult res = NetworkFactory::performNetworkOperation(GMAIL_API_BATCH,
@ -651,13 +653,13 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(QList<Message>& messages,
// We parse each part of HTTP response (it contains HTTP headers and payload with msg full data).
for (const HttpResponse& part : qAsConst(output)) {
QJsonObject msg_doc = QJsonDocument::fromJson(part.body().toUtf8()).object();
QString msg_id = msg_doc["id"].toString();
QString msg_id = msg_doc[QSL("id")].toString();
if (msgs.contains(msg_id)) {
Message& msg = messages[msgs.value(msg_id)];
if (!fillFullMessage(msg, msg_doc, feed_id)) {
qWarningNN << "Failed to get full message for custom ID:" << QUOTE_W_SPACE_DOT(msg.m_customId);
qWarningNN << LOGSEC_GMAIL << "Failed to get full message for custom ID:" << QUOTE_W_SPACE_DOT(msg.m_customId);
}
}
}
@ -676,16 +678,16 @@ QList<Message> GmailNetworkFactory::decodeLiteMessages(const QString& messages_j
QString& next_page_token) {
QList<Message> messages;
QJsonObject top_object = QJsonDocument::fromJson(messages_json_data.toUtf8()).object();
QJsonArray json_msgs = top_object["messages"].toArray();
QJsonArray json_msgs = top_object[QSL("messages")].toArray();
next_page_token = top_object["nextPageToken"].toString();
next_page_token = top_object[QSL("nextPageToken")].toString();
messages.reserve(json_msgs.count());
for (const QJsonValue& obj : json_msgs) {
auto message_obj = obj.toObject();
Message message;
message.m_customId = message_obj["id"].toString();
message.m_customId = message_obj[QSL("id")].toString();
message.m_feedId = stream_id;
messages.append(message);

View file

@ -43,7 +43,7 @@ class GmailNetworkFactory : public QObject {
Downloader* downloadAttachment(const QString& msg_id, const QString& attachment_id, const QNetworkProxy& custom_proxy);
QList<Message> messages(const QString& stream_id, Feed::Status& error, const QNetworkProxy& custom_proxy);
QNetworkReply::NetworkError markMessagesRead(RootItem::ReadStatus status,
QStringList custom_ids,
const QStringList& custom_ids,
const QNetworkProxy& custom_proxy);
QNetworkReply::NetworkError markMessagesStarred(RootItem::Importance importance,
const QStringList& custom_ids,

View file

@ -53,25 +53,25 @@ void GmailServiceRoot::writeNewEmail() {
QVariantHash GmailServiceRoot::customDatabaseData() const {
QVariantHash data;
data["username"] = m_network->username();
data["batch_size"] = m_network->batchSize();
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
data["client_id"] = m_network->oauth()->clientId();
data["client_secret"] = m_network->oauth()->clientSecret();
data["refresh_token"] = m_network->oauth()->refreshToken();
data["redirect_uri"] = m_network->oauth()->redirectUrl();
data[QSL("username")] = m_network->username();
data[QSL("batch_size")] = m_network->batchSize();
data[QSL("download_only_unread")] = m_network->downloadOnlyUnreadMessages();
data[QSL("client_id")] = m_network->oauth()->clientId();
data[QSL("client_secret")] = m_network->oauth()->clientSecret();
data[QSL("refresh_token")] = m_network->oauth()->refreshToken();
data[QSL("redirect_uri")] = m_network->oauth()->redirectUrl();
return data;
}
void GmailServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
m_network->setUsername(data["username"].toString());
m_network->setBatchSize(data["batch_size"].toInt());
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
m_network->oauth()->setClientId(data["client_id"].toString());
m_network->oauth()->setClientSecret(data["client_secret"].toString());
m_network->oauth()->setRefreshToken(data["refresh_token"].toString());
m_network->oauth()->setRedirectUrl(data["redirect_uri"].toString(), true);
m_network->setUsername(data[QSL("username")].toString());
m_network->setBatchSize(data[QSL("batch_size")].toInt());
m_network->setDownloadOnlyUnreadMessages(data[QSL("download_only_unread")].toBool());
m_network->oauth()->setClientId(data[QSL("client_id")].toString());
m_network->oauth()->setClientSecret(data[QSL("client_secret")].toString());
m_network->oauth()->setRefreshToken(data[QSL("refresh_token")].toString());
m_network->oauth()->setRedirectUrl(data[QSL("redirect_uri")].toString(), true);
}
QList<Message> GmailServiceRoot::obtainNewMessages(Feed* feed,
@ -93,7 +93,7 @@ QList<Message> GmailServiceRoot::obtainNewMessages(Feed* feed,
bool GmailServiceRoot::downloadAttachmentOnMyOwn(const QUrl& url) const {
QString str_url = url.toString();
QString attachment_id = str_url.mid(str_url.indexOf(QL1C('?')) + 1);
QStringList parts = attachment_id.split(QL1S(GMAIL_ATTACHMENT_SEP));
QStringList parts = attachment_id.split(QSL(GMAIL_ATTACHMENT_SEP));
QString file = QFileDialog::getSaveFileName(qApp->mainFormWidget(), tr("Select attachment destination file"),
qApp->homeFolder() + QDir::separator() + parts.at(0));
@ -225,7 +225,7 @@ void GmailServiceRoot::saveAllCachedData(bool ignore_errors) {
QList<Message> messages = j.value();
if (!messages.isEmpty()) {
QStringList custom_ids;
QStringList custom_ids; custom_ids.reserve(messages.size());
for (const Message& msg : messages) {
custom_ids.append(msg.m_customId);

View file

@ -29,7 +29,7 @@ EmailRecipientControl::EmailRecipientControl(const QString& recipient, QWidget*
setFocusProxy(m_txtRecipient);
m_btnCloseMe->setToolTip("Remove this recipient.");
m_btnCloseMe->setToolTip(QSL("Remove this recipient."));
m_btnCloseMe->setIcon(qApp->icons()->fromTheme(QSL("list-remove")));
connect(m_btnCloseMe, &PlainToolButton::clicked, this, &EmailRecipientControl::removalRequested);

View file

@ -118,7 +118,7 @@ void FormAddEditEmail::onOkClicked() {
msg["Reply-To"] = rec_repl.join(',').toStdString();
}
msg["Subject"] = QString("=?utf-8?B?%1?=")
msg["Subject"] = QSL("=?utf-8?B?%1?=")
.arg(QString(m_ui.m_txtSubject->text().toUtf8().toBase64(QByteArray::Base64Option::Base64UrlEncoding)))
.toStdString();
msg.set_plain(m_ui.m_txtMessage->toPlainText().toStdString());

View file

@ -23,7 +23,7 @@ FormDownloadAttachment::FormDownloadAttachment(const QString& target_file, Downl
this,
[this, downloader, target_file](QNetworkReply::NetworkError status, const QByteArray& contents) {
if (status == QNetworkReply::NetworkError::NoError) {
QString data = QJsonDocument::fromJson(contents).object()["data"].toString();
QString data = QJsonDocument::fromJson(contents).object()[QSL("data")].toString();
if (!data.isEmpty()) {
IOFactory::writeFile(target_file, QByteArray::fromBase64(data.toLocal8Bit(),

View file

@ -97,7 +97,7 @@ void GmailAccountDetails::onAuthGranted() {
auto resp = fac.getProfile(m_lastProxy);
m_ui.m_txtUsername->lineEdit()->setText(resp["emailAddress"].toString());
m_ui.m_txtUsername->lineEdit()->setText(resp[QSL("emailAddress")].toString());
}
catch (const ApplicationException& ex) {
qCriticalNN << LOGSEC_GMAIL
@ -113,7 +113,7 @@ void GmailAccountDetails::hookNetwork() {
}
void GmailAccountDetails::registerApi() {
qApp->web()->openUrlInExternalBrowser(GMAIL_REG_API_URL);
qApp->web()->openUrlInExternalBrowser(QSL(GMAIL_REG_API_URL));
}
void GmailAccountDetails::checkOAuthValue(const QString& value) {

View file

@ -27,7 +27,7 @@ QString GreaderEntryPoint::name() const {
}
QString GreaderEntryPoint::code() const {
return SERVICE_CODE_GREADER;
return QSL(SERVICE_CODE_GREADER);
}
QString GreaderEntryPoint::description() const {
@ -36,7 +36,7 @@ QString GreaderEntryPoint::description() const {
}
QString GreaderEntryPoint::author() const {
return APP_AUTHOR;
return QSL(APP_AUTHOR);
}
QIcon GreaderEntryPoint::icon() const {

View file

@ -25,8 +25,8 @@ GreaderNetwork::GreaderNetwork(QObject* parent)
m_password(QString()), m_baseUrl(QString()), m_batchSize(GREADER_DEFAULT_BATCH_SIZE), m_downloadOnlyUnreadMessages(false),
m_prefetchedMessages({}), m_prefetchedStatus(Feed::Status::Normal), m_performGlobalFetching(false),
m_intelligentSynchronization(true), m_newerThanFilter(QDate::currentDate().addYears(-1)),
m_oauth(new OAuth2Service(INO_OAUTH_AUTH_URL, INO_OAUTH_TOKEN_URL,
{}, {}, INO_OAUTH_SCOPE, this)) {
m_oauth(new OAuth2Service(QSL(INO_OAUTH_AUTH_URL), QSL(INO_OAUTH_TOKEN_URL),
{}, {}, QSL(INO_OAUTH_SCOPE), this)) {
initializeOauth();
clearCredentials();
}
@ -38,16 +38,16 @@ QNetworkReply::NetworkError GreaderNetwork::editLabels(const QString& state,
QString full_url = generateFullUrl(Operations::EditTag);
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QNetworkReply::NetworkError network_err;
QNetworkReply::NetworkError network_err = QNetworkReply::NetworkError::UnknownNetworkError;
if (!ensureLogin(proxy, &network_err)) {
return network_err;
}
QStringList trimmed_ids;
QStringList trimmed_ids; trimmed_ids.reserve(msg_custom_ids.size());
for (const QString& id : msg_custom_ids) {
trimmed_ids.append(QString("i=") + id);
trimmed_ids.append(QSL("i=") + id);
}
QStringList working_subset; working_subset.reserve(std::min(GREADER_API_EDIT_TAG_BATCH, trimmed_ids.size()));
@ -62,10 +62,10 @@ QNetworkReply::NetworkError GreaderNetwork::editLabels(const QString& state,
QString args;
if (assign) {
args = QString("a=") + state + "&";
args = QSL("a=") + state + "&";
}
else {
args = QString("r=") + state + "&";
args = QSL("r=") + state + "&";
}
args += working_subset.join(QL1C('&'));
@ -103,7 +103,7 @@ QNetworkReply::NetworkError GreaderNetwork::editLabels(const QString& state,
QVariantHash GreaderNetwork::userInfo(const QNetworkProxy& proxy) {
QString full_url = generateFullUrl(Operations::UserInfo);
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QNetworkReply::NetworkError network_err;
QNetworkReply::NetworkError network_err = QNetworkReply::NetworkError::UnknownNetworkError;
if (!ensureLogin(proxy, &network_err)) {
throw NetworkException(network_err);
@ -153,7 +153,7 @@ void GreaderNetwork::prepareFeedFetching(GreaderServiceRoot* root,
<< "Percentage of feeds for fetching:"
<< QUOTE_W_SPACE_DOT(perc_of_fetching);
auto remote_starred_ids_list = itemIds(GREADER_API_FULL_STATE_IMPORTANT, false, proxy, -1, m_newerThanFilter);
auto remote_starred_ids_list = itemIds(QSL(GREADER_API_FULL_STATE_IMPORTANT), false, proxy, -1, m_newerThanFilter);
for (int i = 0; i < remote_starred_ids_list.size(); i++) {
remote_starred_ids_list.replace(i, convertShortStreamIdToLongStreamId(remote_starred_ids_list.at(i)));
@ -177,8 +177,8 @@ void GreaderNetwork::prepareFeedFetching(GreaderServiceRoot* root,
QStringList remote_all_ids_list = m_downloadOnlyUnreadMessages
? QStringList()
: itemIds(GREADER_API_FULL_STATE_READING_LIST, false, proxy, -1, m_newerThanFilter);
QStringList remote_unread_ids_list = itemIds(GREADER_API_FULL_STATE_READING_LIST, true, proxy, -1, m_newerThanFilter);
: itemIds(QSL(GREADER_API_FULL_STATE_READING_LIST), false, proxy, -1, m_newerThanFilter);
QStringList remote_unread_ids_list = itemIds(QSL(GREADER_API_FULL_STATE_READING_LIST), true, proxy, -1, m_newerThanFilter);
for (int i = 0; i < remote_all_ids_list.size(); i++) {
remote_all_ids_list.replace(i, convertShortStreamIdToLongStreamId(remote_all_ids_list.at(i)));
@ -339,17 +339,20 @@ QList<Message> GreaderNetwork::getMessagesIntelligently(ServiceRoot* root,
QNetworkReply::NetworkError GreaderNetwork::markMessagesRead(RootItem::ReadStatus status,
const QStringList& msg_custom_ids,
const QNetworkProxy& proxy) {
return editLabels(GREADER_API_FULL_STATE_READ, status == RootItem::ReadStatus::Read, msg_custom_ids, proxy);
return editLabels(QSL(GREADER_API_FULL_STATE_READ), status == RootItem::ReadStatus::Read, msg_custom_ids, proxy);
}
QNetworkReply::NetworkError GreaderNetwork::markMessagesStarred(RootItem::Importance importance,
const QStringList& msg_custom_ids,
const QNetworkProxy& proxy) {
return editLabels(GREADER_API_FULL_STATE_IMPORTANT, importance == RootItem::Importance::Important, msg_custom_ids, proxy);
return editLabels(QSL(GREADER_API_FULL_STATE_IMPORTANT),
importance == RootItem::Importance::Important,
msg_custom_ids,
proxy);
}
QStringList GreaderNetwork::itemIds(const QString& stream_id, bool unread_only, const QNetworkProxy& proxy,
int max_count, const QDate& newer_than) {
int max_count, QDate newer_than) {
QString continuation;
if (!ensureLogin(proxy)) {
@ -368,7 +371,7 @@ QStringList GreaderNetwork::itemIds(const QString& stream_id, bool unread_only,
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
if (unread_only) {
full_url += QSL("&xt=%1").arg(GREADER_API_FULL_STATE_READ);
full_url += QSL("&xt=%1").arg(QSL(GREADER_API_FULL_STATE_READ));
}
if (!continuation.isEmpty()) {
@ -503,7 +506,7 @@ QList<Message> GreaderNetwork::streamContents(ServiceRoot* root, const QString&
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
if (downloadOnlyUnreadMessages()) {
full_url += QSL("&xt=%1").arg(GREADER_API_FULL_STATE_READ);
full_url += QSL("&xt=%1").arg(QSL(GREADER_API_FULL_STATE_READ));
}
if (!continuation.isEmpty()) {
@ -606,15 +609,15 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
m_service == GreaderServiceRoot::Service::Reedah ||
m_service == GreaderServiceRoot::Service::Inoreader) {
// We need to process subscription list first and extract categories.
json = QJsonDocument::fromJson(feeds.toUtf8()).object()["subscriptions"].toArray();
json = QJsonDocument::fromJson(feeds.toUtf8()).object()[QSL("subscriptions")].toArray();
for (const QJsonValue& feed : qAsConst(json)) {
auto subscription = feed.toObject();
auto json_cats = subscription["categories"].toArray();
auto json_cats = subscription[QSL("categories")].toArray();
for (const QJsonValue& cat : qAsConst(json_cats)) {
auto cat_obj = cat.toObject();
auto cat_id = cat_obj["id"].toString();
auto cat_id = cat_obj[QSL("id")].toString();
if (!cats.contains(cat_id)) {
auto* category = new Category();
@ -629,28 +632,28 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
}
}
json = QJsonDocument::fromJson(categories.toUtf8()).object()["tags"].toArray();
json = QJsonDocument::fromJson(categories.toUtf8()).object()[QSL("tags")].toArray();
cats.insert(QString(), parent);
for (const QJsonValue& obj : qAsConst(json)) {
auto label = obj.toObject();
QString label_id = label["id"].toString();
QString label_id = label[QSL("id")].toString();
if ((label["type"].toString() == QL1S("folder")) ||
(m_service == GreaderServiceRoot::Service::TheOldReader &&
label_id.contains(QSL("/label/")))) {
if ((label[QSL("type")].toString() == QSL("folder") ||
(m_service == GreaderServiceRoot::Service::TheOldReader &&
label_id.contains(QSL("/label/"))))) {
// We have category (not "state" or "tag" or "label").
auto* category = new Category();
category->setDescription(label["htmlUrl"].toString());
category->setDescription(label[QSL("htmlUrl")].toString());
category->setTitle(label_id.mid(label_id.lastIndexOf(QL1C('/')) + 1));
category->setCustomId(label_id);
cats.insert(category->customId(), category);
parent->appendChild(category);
}
else if (label["type"] == QL1S("tag")) {
else if (label[QSL("type")] == QSL("tag")) {
QString plain_name = QRegularExpression(".+\\/([^\\/]+)").match(label_id).captured(1);
auto* new_lbl = new Label(plain_name, TextFactory::generateColorFromText(label_id));
@ -663,7 +666,7 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
label_id.contains(QSL("/label/"))) {
if (!cats.contains(label_id)) {
// This stream is not a category, it is label, bitches!
QString plain_name = QRegularExpression(".+\\/([^\\/]+)").match(label_id).captured(1);
QString plain_name = QRegularExpression(QSL(".+\\/([^\\/]+)")).match(label_id).captured(1);
auto* new_lbl = new Label(plain_name, TextFactory::generateColorFromText(label_id));
new_lbl->setCustomId(label_id);
@ -672,22 +675,22 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
}
}
json = QJsonDocument::fromJson(feeds.toUtf8()).object()["subscriptions"].toArray();
json = QJsonDocument::fromJson(feeds.toUtf8()).object()[QSL("subscriptions")].toArray();
for (const QJsonValue& obj : qAsConst(json)) {
auto subscription = obj.toObject();
QString id = subscription["id"].toString();
QString title = subscription["title"].toString();
QString url = subscription["htmlUrl"].toString();
QString id = subscription[QSL("id")].toString();
QString title = subscription[QSL("title")].toString();
QString url = subscription[QSL("htmlUrl")].toString();
QString parent_label;
QJsonArray assigned_categories = subscription["categories"].toArray();
QJsonArray assigned_categories = subscription[QSL("categories")].toArray();
if (id.startsWith(TOR_SPONSORED_STREAM_ID)) {
continue;
}
for (const QJsonValue& cat : qAsConst(assigned_categories)) {
QString potential_id = cat.toObject()["id"].toString();
QString potential_id = cat.toObject()[QSL("id")].toString();
if (potential_id.contains(QSL("/label/"))) {
parent_label = potential_id;
@ -704,7 +707,7 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
feed->setCustomId(id);
if (obtain_icons) {
QString icon_url = subscription["iconUrl"].toString();
QString icon_url = subscription[QSL("iconUrl")].toString();
QList<QPair<QString, bool>> icon_urls;
if (!icon_url.isEmpty()) {
@ -788,7 +791,7 @@ QNetworkReply::NetworkError GreaderNetwork::clientLogin(const QNetworkProxy& pro
}
}
QRegularExpression exp("^(NA|unused|none|null)$");
QRegularExpression exp(QSL("^(NA|unused|none|null)$"));
if (exp.match(m_authSid).hasMatch()) {
m_authSid = QString();
@ -834,7 +837,7 @@ GreaderServiceRoot::Service GreaderNetwork::service() const {
return m_service;
}
void GreaderNetwork::setService(const GreaderServiceRoot::Service& service) {
void GreaderNetwork::setService(GreaderServiceRoot::Service service) {
m_service = service;
}
@ -864,7 +867,7 @@ void GreaderNetwork::setBaseUrl(const QString& base_url) {
QPair<QByteArray, QByteArray> GreaderNetwork::authHeader() const {
if (m_service == GreaderServiceRoot::Service::Inoreader) {
return { QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
return { QSL(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
m_oauth->bearer().toLocal8Bit() };
}
else {
@ -921,19 +924,19 @@ QString GreaderNetwork::convertShortStreamIdToLongStreamId(const QString& stream
}
QString GreaderNetwork::simplifyStreamId(const QString& stream_id) const {
return QString(stream_id).replace(QRegularExpression("\\/\\d+\\/"), QSL("/-/"));
return QString(stream_id).replace(QRegularExpression(QSL("\\/\\d+\\/")), QSL("/-/"));
}
QStringList GreaderNetwork::decodeItemIds(const QString& stream_json_data, QString& continuation) {
QStringList ids;
QJsonDocument json_doc = QJsonDocument::fromJson(stream_json_data.toUtf8());
QJsonArray json = json_doc.object()["itemRefs"].toArray();
QJsonArray json = json_doc.object()[QSL("itemRefs")].toArray();
continuation = json_doc.object()["continuation"].toString();
continuation = json_doc.object()[QSL("continuation")].toString();
ids.reserve(json.count());
for (const QJsonValue& id : json) {
ids.append(id.toObject()["id"].toString());
ids.append(id.toObject()[QSL("id")].toString());
}
return ids;
@ -945,30 +948,30 @@ QList<Message> GreaderNetwork::decodeStreamContents(ServiceRoot* root,
QString& continuation) {
QList<Message> messages;
QJsonDocument json_doc = QJsonDocument::fromJson(stream_json_data.toUtf8());
QJsonArray json = json_doc.object()["items"].toArray();
QJsonArray json = json_doc.object()[QSL("items")].toArray();
auto active_labels = root->labelsNode() != nullptr ? root->labelsNode()->labels() : QList<Label*>();
continuation = json_doc.object()["continuation"].toString();
continuation = json_doc.object()[QSL("continuation")].toString();
messages.reserve(json.count());
for (const QJsonValue& obj : json) {
auto message_obj = obj.toObject();
Message message;
message.m_title = qApp->web()->unescapeHtml(message_obj["title"].toString());
message.m_author = qApp->web()->unescapeHtml(message_obj["author"].toString());
message.m_created = QDateTime::fromSecsSinceEpoch(message_obj["published"].toInt(), Qt::UTC);
message.m_title = qApp->web()->unescapeHtml(message_obj[QSL("title")].toString());
message.m_author = qApp->web()->unescapeHtml(message_obj[QSL("author")].toString());
message.m_created = QDateTime::fromSecsSinceEpoch(message_obj[QSL("published")].toInt(), Qt::UTC);
message.m_createdFromFeed = true;
message.m_customId = message_obj["id"].toString();
message.m_customId = message_obj[QSL("id")].toString();
auto alternates = message_obj["alternate"].toArray();
auto enclosures = message_obj["enclosure"].toArray();
auto categories = message_obj["categories"].toArray();
auto alternates = message_obj[QSL("alternate")].toArray();
auto enclosures = message_obj[QSL("enclosure")].toArray();
auto categories = message_obj[QSL("categories")].toArray();
for (const QJsonValue& alt : alternates) {
auto alt_obj = alt.toObject();
QString mime = alt_obj["type"].toString();
QString href = alt_obj["href"].toString();
QString mime = alt_obj[QSL("type")].toString();
QString href = alt_obj[QSL("href")].toString();
if (mime.isEmpty() || mime == QL1S("text/html")) {
message.m_url = href;
@ -980,8 +983,8 @@ QList<Message> GreaderNetwork::decodeStreamContents(ServiceRoot* root,
for (const QJsonValue& enc : enclosures) {
auto enc_obj = enc.toObject();
QString mime = enc_obj["type"].toString();
QString href = enc_obj["href"].toString();
QString mime = enc_obj[QSL("type")].toString();
QString href = enc_obj[QSL("href")].toString();
message.m_enclosures.append(Enclosure(href, mime));
}
@ -989,10 +992,10 @@ QList<Message> GreaderNetwork::decodeStreamContents(ServiceRoot* root,
for (const QJsonValue& cat : categories) {
QString category = cat.toString();
if (category.endsWith(GREADER_API_STATE_READ)) {
if (category.endsWith(QSL(GREADER_API_STATE_READ))) {
message.m_isRead = true;
}
else if (category.endsWith(GREADER_API_STATE_IMPORTANT)) {
else if (category.endsWith(QSL(GREADER_API_STATE_IMPORTANT))) {
message.m_isImportant = true;
}
else if (category.contains(QSL("label"))) {
@ -1007,10 +1010,10 @@ QList<Message> GreaderNetwork::decodeStreamContents(ServiceRoot* root,
}
}
message.m_contents = message_obj["summary"].toObject()["content"].toString();
message.m_contents = message_obj[QSL("summary")].toObject()[QSL("content")].toString();
message.m_rawContents = QJsonDocument(message_obj).toJson(QJsonDocument::JsonFormat::Compact);
message.m_feedId = stream_id.isEmpty()
? message_obj["origin"].toObject()["streamId"].toString()
? message_obj[QSL("origin")].toObject()[QSL("streamId")].toString()
: stream_id;
if (message.m_title.isEmpty()) {
@ -1037,7 +1040,7 @@ void GreaderNetwork::clearCredentials() {
QString GreaderNetwork::sanitizedBaseUrl() const {
QString base_url = m_service == GreaderServiceRoot::Service::Inoreader
? GREADER_URL_INOREADER
? QSL(GREADER_URL_INOREADER)
: m_baseUrl;
if (!base_url.endsWith('/')) {
@ -1046,7 +1049,7 @@ QString GreaderNetwork::sanitizedBaseUrl() const {
switch (m_service) {
case GreaderServiceRoot::Service::FreshRss:
base_url += FRESHRSS_BASE_URL_PATH;
base_url += QSL(FRESHRSS_BASE_URL_PATH);
break;
default:
@ -1059,31 +1062,31 @@ QString GreaderNetwork::sanitizedBaseUrl() const {
QString GreaderNetwork::generateFullUrl(GreaderNetwork::Operations operation) const {
switch (operation) {
case Operations::ClientLogin:
return sanitizedBaseUrl() + GREADER_API_CLIENT_LOGIN;
return sanitizedBaseUrl() + QSL(GREADER_API_CLIENT_LOGIN);
case Operations::Token:
return sanitizedBaseUrl() + GREADER_API_TOKEN;
return sanitizedBaseUrl() + QSL(GREADER_API_TOKEN);
case Operations::TagList:
return sanitizedBaseUrl() + GREADER_API_TAG_LIST;
return sanitizedBaseUrl() + QSL(GREADER_API_TAG_LIST);
case Operations::SubscriptionList:
return sanitizedBaseUrl() + GREADER_API_SUBSCRIPTION_LIST;
return sanitizedBaseUrl() + QSL(GREADER_API_SUBSCRIPTION_LIST);
case Operations::StreamContents:
return sanitizedBaseUrl() + GREADER_API_STREAM_CONTENTS;
return sanitizedBaseUrl() + QSL(GREADER_API_STREAM_CONTENTS);
case Operations::UserInfo:
return sanitizedBaseUrl() + GREADER_API_USER_INFO;
return sanitizedBaseUrl() + QSL(GREADER_API_USER_INFO);
case Operations::EditTag:
return sanitizedBaseUrl() + GREADER_API_EDIT_TAG;
return sanitizedBaseUrl() + QSL(GREADER_API_EDIT_TAG);
case Operations::ItemIds:
return sanitizedBaseUrl() + GREADER_API_ITEM_IDS;
return sanitizedBaseUrl() + QSL(GREADER_API_ITEM_IDS);
case Operations::ItemContents:
return sanitizedBaseUrl() + GREADER_API_ITEM_CONTENTS;
return sanitizedBaseUrl() + QSL(GREADER_API_ITEM_CONTENTS);
default:
return sanitizedBaseUrl();
@ -1120,11 +1123,11 @@ void GreaderNetwork::onAuthFailed() {
void GreaderNetwork::initializeOauth() {
#if defined(INOREADER_OFFICIAL_SUPPORT)
m_oauth->setClientSecretId(TextFactory::decrypt(INOREADER_CLIENT_ID, OAUTH_DECRYPTION_KEY));
m_oauth->setClientSecretSecret(TextFactory::decrypt(INOREADER_CLIENT_SECRET, OAUTH_DECRYPTION_KEY));
m_oauth->setClientSecretId(TextFactory::decrypt(QSL(INOREADER_CLIENT_ID), OAUTH_DECRYPTION_KEY));
m_oauth->setClientSecretSecret(TextFactory::decrypt(QSL(INOREADER_CLIENT_SECRET), OAUTH_DECRYPTION_KEY));
#endif
m_oauth->setRedirectUrl(QString(OAUTH_REDIRECT_URI) +
m_oauth->setRedirectUrl(QSL(OAUTH_REDIRECT_URI) +
QL1C(':') +
QString::number(INO_OAUTH_REDIRECT_URI_PORT),
false);

View file

@ -57,7 +57,7 @@ class GreaderNetwork : public QObject {
void clearPrefetchedMessages();
GreaderServiceRoot::Service service() const;
void setService(const GreaderServiceRoot::Service& service);
void setService(GreaderServiceRoot::Service service);
QString username() const;
void setUsername(const QString& username);
@ -87,7 +87,7 @@ class GreaderNetwork : public QObject {
const QStringList& msg_custom_ids, const QNetworkProxy& proxy);
QVariantHash userInfo(const QNetworkProxy& proxy);
QStringList itemIds(const QString& stream_id, bool unread_only, const QNetworkProxy& proxy, int max_count = -1,
const QDate& newer_than = {});
QDate newer_than = {});
QList<Message> itemContents(ServiceRoot* root, const QList<QString>& stream_ids,
Feed::Status& error, const QNetworkProxy& proxy);
QList<Message> streamContents(ServiceRoot* root, const QString& stream_id,

View file

@ -41,52 +41,52 @@ bool GreaderServiceRoot::editViaGui() {
QVariantHash GreaderServiceRoot::customDatabaseData() const {
QVariantHash data;
data["service"] = int(m_network->service());
data["username"] = m_network->username();
data["password"] = TextFactory::encrypt(m_network->password());
data["batch_size"] = m_network->batchSize();
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
data["intelligent_synchronization"] = m_network->intelligentSynchronization();
data[QSL("service")] = int(m_network->service());
data[QSL("username")] = m_network->username();
data[QSL("password")] = TextFactory::encrypt(m_network->password());
data[QSL("batch_size")] = m_network->batchSize();
data[QSL("download_only_unread")] = m_network->downloadOnlyUnreadMessages();
data[QSL("intelligent_synchronization")] = m_network->intelligentSynchronization();
if (m_network->newerThanFilter().isValid()) {
data["fetch_newer_than"] = m_network->newerThanFilter();
data[QSL("fetch_newer_than")] = m_network->newerThanFilter();
}
if (m_network->service() == Service::Inoreader) {
data["client_id"] = m_network->oauth()->clientId();
data["client_secret"] = m_network->oauth()->clientSecret();
data["refresh_token"] = m_network->oauth()->refreshToken();
data["redirect_uri"] = m_network->oauth()->redirectUrl();
data[QSL("client_id")] = m_network->oauth()->clientId();
data[QSL("client_secret")] = m_network->oauth()->clientSecret();
data[QSL("refresh_token")] = m_network->oauth()->refreshToken();
data[QSL("redirect_uri")] = m_network->oauth()->redirectUrl();
}
else {
data["url"] = m_network->baseUrl();
data[QSL("url")] = m_network->baseUrl();
}
return data;
}
void GreaderServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
m_network->setService(GreaderServiceRoot::Service(data["service"].toInt()));
m_network->setUsername(data["username"].toString());
m_network->setPassword(TextFactory::decrypt(data["password"].toString()));
m_network->setBatchSize(data["batch_size"].toInt());
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
m_network->setIntelligentSynchronization(data["intelligent_synchronization"].toBool());
m_network->setService(GreaderServiceRoot::Service(data[QSL("service")].toInt()));
m_network->setUsername(data[QSL("username")].toString());
m_network->setPassword(TextFactory::decrypt(data[QSL("password")].toString()));
m_network->setBatchSize(data[QSL("batch_size")].toInt());
m_network->setDownloadOnlyUnreadMessages(data[QSL("download_only_unread")].toBool());
m_network->setIntelligentSynchronization(data[QSL("intelligent_synchronization")].toBool());
if (data["fetch_newer_than"].toDate().isValid()) {
m_network->setNewerThanFilter(data["fetch_newer_than"].toDate());
if (data[QSL("fetch_newer_than")].toDate().isValid()) {
m_network->setNewerThanFilter(data[QSL("fetch_newer_than")].toDate());
}
if (m_network->service() == Service::Inoreader) {
m_network->oauth()->setClientId(data["client_id"].toString());
m_network->oauth()->setClientSecret(data["client_secret"].toString());
m_network->oauth()->setRefreshToken(data["refresh_token"].toString());
m_network->oauth()->setRedirectUrl(data["redirect_uri"].toString(), true);
m_network->oauth()->setClientId(data[QSL("client_id")].toString());
m_network->oauth()->setClientSecret(data[QSL("client_secret")].toString());
m_network->oauth()->setRefreshToken(data[QSL("refresh_token")].toString());
m_network->oauth()->setRedirectUrl(data[QSL("redirect_uri")].toString(), true);
m_network->setBaseUrl(QSL(GREADER_URL_INOREADER));
}
else {
m_network->setBaseUrl(data["url"].toString());
m_network->setBaseUrl(data[QSL("url")].toString());
}
}
@ -207,7 +207,7 @@ void GreaderServiceRoot::saveAllCachedData(bool ignore_errors) {
QList<Message> messages = j.value();
if (!messages.isEmpty()) {
QStringList custom_ids;
QStringList custom_ids; custom_ids.reserve(messages.size());
for (const Message& msg : messages) {
custom_ids.append(msg.m_customId);
@ -261,8 +261,8 @@ ServiceRoot::LabelOperation GreaderServiceRoot::supportedLabelOperations() const
}
void GreaderServiceRoot::updateTitleIcon() {
setTitle(QString("%1 (%2)").arg(TextFactory::extractUsernameFromEmail(m_network->username()),
GreaderServiceRoot::serviceToString(m_network->service())));
setTitle(QSL("%1 (%2)").arg(TextFactory::extractUsernameFromEmail(m_network->username()),
GreaderServiceRoot::serviceToString(m_network->service())));
switch (m_network->service()) {
case Service::TheOldReader:

View file

@ -123,7 +123,7 @@ void GreaderAccountDetails::onAuthGranted() {
fac.setOauth(m_oauth);
auto resp = fac.userInfo(m_lastProxy);
m_ui.m_txtUsername->lineEdit()->setText(resp["userEmail"].toString());
m_ui.m_txtUsername->lineEdit()->setText(resp[QSL("userEmail")].toString());
}
catch (const ApplicationException& ex) {
qCriticalNN << LOGSEC_GREADER
@ -141,7 +141,7 @@ void GreaderAccountDetails::hookNetwork() {
}
void GreaderAccountDetails::registerApi() {
qApp->web()->openUrlInExternalBrowser(INO_REG_API_URL);
qApp->web()->openUrlInExternalBrowser(QSL(INO_REG_API_URL));
}
void GreaderAccountDetails::checkOAuthValue(const QString& value) {

View file

@ -64,14 +64,16 @@ void OwnCloudAccountDetails::performTest(const QNetworkProxy& custom_proxy) {
tr("Network error, have you entered correct Nextcloud endpoint and password?"));
}
else if (result.isLoaded()) {
if (!SystemFactory::isVersionEqualOrNewer(result.version(), OWNCLOUD_MIN_VERSION)) {
if (!SystemFactory::isVersionEqualOrNewer(result.version(), QSL(OWNCLOUD_MIN_VERSION))) {
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("Installed version: %1, required at least: %2.").arg(result.version(), OWNCLOUD_MIN_VERSION),
tr("Installed version: %1, required at least: %2.").arg(result.version(),
QSL(OWNCLOUD_MIN_VERSION)),
tr("Selected Nextcloud News server is running unsupported version."));
}
else {
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Ok,
tr("Installed version: %1, required at least: %2.").arg(result.version(), OWNCLOUD_MIN_VERSION),
tr("Installed version: %1, required at least: %2.").arg(result.version(),
QSL(OWNCLOUD_MIN_VERSION)),
tr("Nextcloud News server is okay."));
}
}

View file

@ -193,15 +193,15 @@ bool OwnCloudNetworkFactory::deleteFeed(const QString& feed_id, const QNetworkPr
bool OwnCloudNetworkFactory::createFeed(const QString& url, int parent_id, const QNetworkProxy& custom_proxy) {
QJsonObject json;
json["url"] = url;
json[QSL("url")] = url;
auto nextcloud_version = status(custom_proxy).version();
if (SystemFactory::isVersionEqualOrNewer(nextcloud_version, QSL("15.1.0"))) {
json["folderId"] = parent_id == 0 ? QJsonValue(QJsonValue::Type::Null) : parent_id;
json[QSL("folderId")] = parent_id == 0 ? QJsonValue(QJsonValue::Type::Null) : parent_id;
}
else {
json["folderId"] = parent_id;
json[QSL("folderId")] = parent_id;
}
QByteArray result_raw;
@ -240,7 +240,7 @@ bool OwnCloudNetworkFactory::renameFeed(const QString& new_name,
QByteArray result_raw;
QJsonObject json;
json["feedTitle"] = new_name;
json[QSL("feedTitle")] = new_name;
QList<QPair<QByteArray, QByteArray>> headers;
@ -345,17 +345,17 @@ NetworkResult OwnCloudNetworkFactory::markMessagesRead(RootItem::ReadStatus stat
QString final_url;
if (status == RootItem::ReadStatus::Read) {
final_url = m_fixedUrl + OWNCLOUD_API_PATH + "items/read/multiple";
final_url = m_fixedUrl + QSL(OWNCLOUD_API_PATH) + QSL("items/read/multiple");
}
else {
final_url = m_fixedUrl + OWNCLOUD_API_PATH + "items/unread/multiple";
final_url = m_fixedUrl + QSL(OWNCLOUD_API_PATH) + QSL("items/unread/multiple");
}
for (const QString& id : custom_ids) {
ids.append(QJsonValue(id.toInt()));
}
json["items"] = ids;
json[QSL("items")] = ids;
QList<QPair<QByteArray, QByteArray>> headers;
@ -395,12 +395,12 @@ NetworkResult OwnCloudNetworkFactory::markMessagesStarred(RootItem::Importance i
for (int i = 0; i < feed_ids.size(); i++) {
QJsonObject item;
item["feedId"] = feed_ids.at(i);
item["guidHash"] = guid_hashes.at(i);
item[QSL("feedId")] = feed_ids.at(i);
item[QSL("guidHash")] = guid_hashes.at(i);
ids.append(item);
}
json["items"] = ids;
json[QSL("items")] = ids;
QList<QPair<QByteArray, QByteArray>> headers;
@ -463,22 +463,13 @@ OwnCloudStatusResponse::~OwnCloudStatusResponse() = default;
QString OwnCloudStatusResponse::version() const {
if (isLoaded()) {
return m_rawContent["version"].toString();
return m_rawContent[QSL("version")].toString();
}
else {
return QString();
}
}
bool OwnCloudStatusResponse::misconfiguredCron() const {
if (isLoaded()) {
return m_rawContent["warnings"].toObject()["improperlyConfiguredCron"].toBool();
}
else {
return false;
}
}
OwnCloudGetFeedsCategoriesResponse::OwnCloudGetFeedsCategoriesResponse(QNetworkReply::NetworkError response,
QString raw_categories,
QString raw_feeds)
@ -494,14 +485,14 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
cats.insert(QSL("0"), parent);
// Process categories first, then process feeds.
auto json_folders = QJsonDocument::fromJson(m_contentCategories.toUtf8()).object()["folders"].toArray();
auto json_folders = QJsonDocument::fromJson(m_contentCategories.toUtf8()).object()[QSL("folders")].toArray();
for (const QJsonValue& cat : qAsConst(json_folders)) {
QJsonObject item = cat.toObject();
auto* category = new Category();
category->setTitle(item["name"].toString());
category->setCustomId(QString::number(item["id"].toInt()));
category->setTitle(item[QSL("name")].toString());
category->setCustomId(QString::number(item[QSL("id")].toInt()));
cats.insert(category->customId(), category);
// All categories in Nextcloud are top-level.
@ -509,14 +500,14 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
}
// We have categories added, now add all feeds.
auto json_feeds = QJsonDocument::fromJson(m_contentFeeds.toUtf8()).object()["feeds"].toArray();
auto json_feeds = QJsonDocument::fromJson(m_contentFeeds.toUtf8()).object()[QSL("feeds")].toArray();
for (const QJsonValue& fed : qAsConst(json_feeds)) {
QJsonObject item = fed.toObject();
auto* feed = new OwnCloudFeed();
if (obtain_icons) {
QString icon_path = item["faviconLink"].toString();
QString icon_path = item[QSL("faviconLink")].toString();
if (!icon_path.isEmpty()) {
QByteArray icon_data;
@ -534,14 +525,14 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
}
}
feed->setCustomId(QString::number(item["id"].toInt()));
feed->setSource(item["url"].toString());
feed->setCustomId(QString::number(item[QSL("id")].toInt()));
feed->setSource(item[QSL("url")].toString());
if (feed->source().isEmpty()) {
feed->setSource(item["link"].toString());
feed->setSource(item[QSL("link")].toString());
}
feed->setTitle(item["title"].toString());
feed->setTitle(item[QSL("title")].toString());
if (feed->title().isEmpty()) {
if (feed->source().isEmpty()) {
@ -559,7 +550,7 @@ RootItem* OwnCloudGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons)
// NOTE: Starting with News 15.1.0, top-level feeds do not have parent folder ID 0, but JSON "null".
// Luckily, if folder ID is not convertible to int, then default 0 value is returned.
cats.value(QString::number(item["folderId"].toInt(0)))->appendChild(feed);
cats.value(QString::number(item[QSL("folderId")].toInt(0)))->appendChild(feed);
qDebugNN << LOGSEC_NEXTCLOUD
<< "Custom ID of next fetched processed feed is"
<< QUOTE_W_SPACE_DOT(feed->customId());
@ -575,35 +566,35 @@ OwnCloudGetMessagesResponse::~OwnCloudGetMessagesResponse() = default;
QList<Message>OwnCloudGetMessagesResponse::messages() const {
QList<Message>msgs;
auto json_items = m_rawContent["items"].toArray();
auto json_items = m_rawContent[QSL("items")].toArray();
for (const QJsonValue& message : qAsConst(json_items)) {
QJsonObject message_map = message.toObject();
Message msg;
msg.m_author = message_map["author"].toString();
msg.m_contents = message_map["body"].toString();
msg.m_created = TextFactory::parseDateTime(message_map["pubDate"].toDouble() * 1000);
msg.m_author = message_map[QSL("author")].toString();
msg.m_contents = message_map[QSL("body")].toString();
msg.m_created = TextFactory::parseDateTime(message_map[QSL("pubDate")].toDouble() * 1000);
msg.m_createdFromFeed = true;
msg.m_customId = message_map["id"].toVariant().toString();
msg.m_customHash = message_map["guidHash"].toString();
msg.m_customId = message_map[QSL("id")].toVariant().toString();
msg.m_customHash = message_map[QSL("guidHash")].toString();
msg.m_rawContents = QJsonDocument(message_map).toJson(QJsonDocument::JsonFormat::Compact);
QString enclosure_link = message_map["enclosureLink"].toString();
QString enclosure_link = message_map[QSL("enclosureLink")].toString();
if (!enclosure_link.isEmpty()) {
Enclosure enclosure;
enclosure.m_mimeType = message_map["enclosureMime"].toString();
enclosure.m_mimeType = message_map[QSL("enclosureMime")].toString();
enclosure.m_url = enclosure_link;
msg.m_enclosures.append(enclosure);
}
msg.m_feedId = message_map["feedId"].toVariant().toString();
msg.m_isImportant = message_map["starred"].toBool();
msg.m_isRead = !message_map["unread"].toBool();
msg.m_title = message_map["title"].toString();
msg.m_url = message_map["url"].toString();
msg.m_feedId = message_map[QSL("feedId")].toVariant().toString();
msg.m_isImportant = message_map[QSL("starred")].toBool();
msg.m_isRead = !message_map[QSL("unread")].toBool();
msg.m_title = message_map[QSL("title")].toString();
msg.m_url = message_map[QSL("url")].toString();
msgs.append(msg);
}

View file

@ -42,7 +42,6 @@ class OwnCloudStatusResponse : public OwnCloudResponse {
virtual ~OwnCloudStatusResponse();
QString version() const;
bool misconfiguredCron() const;
};
class RootItem;

View file

@ -2,9 +2,9 @@
#include "services/owncloud/owncloudserviceentrypoint.h"
#include "database/databasequeries.h"
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "database/databasequeries.h"
#include "miscellaneous/iconfactory.h"
#include "services/owncloud/definitions.h"
#include "services/owncloud/gui/formeditowncloudaccount.h"
@ -27,16 +27,16 @@ QString OwnCloudServiceEntryPoint::name() const {
}
QString OwnCloudServiceEntryPoint::code() const {
return SERVICE_CODE_OWNCLOUD;
return QSL(SERVICE_CODE_OWNCLOUD);
}
QString OwnCloudServiceEntryPoint::description() const {
return QObject::tr("The News app is an RSS/Atom feed aggregator. "
"It is part of Nextcloud suite. This plugin implements %1 API.").arg(OWNCLOUD_API_VERSION);
"It is part of Nextcloud suite. This plugin implements %1 API.").arg(QSL(OWNCLOUD_API_VERSION));
}
QString OwnCloudServiceEntryPoint::author() const {
return APP_AUTHOR;
return QSL(APP_AUTHOR);
}
QIcon OwnCloudServiceEntryPoint::icon() const {

View file

@ -131,23 +131,23 @@ RootItem* OwnCloudServiceRoot::obtainNewTreeForSyncIn() const {
QVariantHash OwnCloudServiceRoot::customDatabaseData() const {
QVariantHash data;
data["auth_username"] = m_network->authUsername();
data["auth_password"] = TextFactory::encrypt(m_network->authPassword());
data["url"] = m_network->url();
data["force_update"] = m_network->forceServerSideUpdate();
data["batch_size"] = m_network->batchSize();
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
data[QSL("auth_username")] = m_network->authUsername();
data[QSL("auth_password")] = TextFactory::encrypt(m_network->authPassword());
data[QSL("url")] = m_network->url();
data[QSL("force_update")] = m_network->forceServerSideUpdate();
data[QSL("batch_size")] = m_network->batchSize();
data[QSL("download_only_unread")] = m_network->downloadOnlyUnreadMessages();
return data;
}
void OwnCloudServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
m_network->setAuthUsername(data["auth_username"].toString());
m_network->setAuthPassword(TextFactory::decrypt(data["auth_password"].toString()));
m_network->setUrl(data["url"].toString());
m_network->setForceServerSideUpdate(data["force_update"].toBool());
m_network->setBatchSize(data["batch_size"].toInt());
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
m_network->setAuthUsername(data[QSL("auth_username")].toString());
m_network->setAuthPassword(TextFactory::decrypt(data[QSL("auth_password")].toString()));
m_network->setUrl(data[QSL("url")].toString());
m_network->setForceServerSideUpdate(data[QSL("force_update")].toBool());
m_network->setBatchSize(data[QSL("batch_size")].toInt());
m_network->setDownloadOnlyUnreadMessages(data[QSL("download_only_unread")].toBool());
}
QList<Message> OwnCloudServiceRoot::obtainNewMessages(Feed* feed,

View file

@ -42,10 +42,10 @@ QString AtomParser::feedAuthor() const {
}
}
return author_str.join(", ");
return author_str.join(QSL(", "));
}
Message AtomParser::extractMessage(const QDomElement& msg_element, QDateTime current_time) const {
Message AtomParser::extractMessage(const QDomElement& msg_element, const QDateTime& current_time) const {
Message new_message;
QString title = textsFromPath(msg_element, m_atomNamespace, QSL("title"), true).join(QSL(", "));
QString summary = rawXmlChild(msg_element.elementsByTagNameNS(m_atomNamespace, QSL("content")).at(0).toElement());
@ -144,7 +144,7 @@ QString AtomParser::messageAuthor(const QDomElement& msg_element) const {
}
}
return author_str.join(", ");
return author_str.join(QSL(", "));
}
QString AtomParser::atomNamespace() const {

View file

@ -19,7 +19,7 @@ class AtomParser : public FeedParser {
private:
QDomNodeList messageElements();
QString feedAuthor() const;
Message extractMessage(const QDomElement& msg_element, QDateTime current_time) const;
Message extractMessage(const QDomElement& msg_element, const QDateTime& current_time) const;
QString messageAuthor(const QDomElement& msg_element) const;
private:

View file

@ -37,7 +37,7 @@ QList<Message> FeedParser::messages() {
new_message.m_author = feed_author;
}
new_message.m_url = new_message.m_url.replace(QRegularExpression("[\\t\\n]"), QString());
new_message.m_url = new_message.m_url.replace(QRegularExpression(QSL("[\\t\\n]")), QString());
messages.append(new_message);
}
@ -53,7 +53,7 @@ QList<Message> FeedParser::messages() {
QList<Enclosure> FeedParser::mrssGetEnclosures(const QDomElement& msg_element) const {
QList<Enclosure> enclosures;
auto content_list = msg_element.elementsByTagNameNS(m_mrssNamespace, "content");
auto content_list = msg_element.elementsByTagNameNS(m_mrssNamespace, QSL("content"));
for (int i = 0; i < content_list.size(); i++) {
QDomElement elem_content = content_list.at(i).toElement();
@ -65,7 +65,7 @@ QList<Enclosure> FeedParser::mrssGetEnclosures(const QDomElement& msg_element) c
}
}
auto thumbnail_list = msg_element.elementsByTagNameNS(m_mrssNamespace, "thumbnail");
auto thumbnail_list = msg_element.elementsByTagNameNS(m_mrssNamespace, QSL("thumbnail"));
for (int i = 0; i < thumbnail_list.size(); i++) {
QDomElement elem_content = thumbnail_list.at(i).toElement();
@ -146,5 +146,5 @@ QStringList FeedParser::textsFromPath(const QDomElement& element, const QString&
}
QString FeedParser::feedAuthor() const {
return "";
return QL1S("");
}

View file

@ -22,7 +22,7 @@ class FeedParser {
QStringList textsFromPath(const QDomElement& element, const QString& namespace_uri, const QString& xml_path, bool only_first) const;
virtual QDomNodeList messageElements() = 0;
virtual QString feedAuthor() const;
virtual Message extractMessage(const QDomElement& msg_element, QDateTime current_time) const = 0;
virtual Message extractMessage(const QDomElement& msg_element, const QDateTime& current_time) const = 0;
protected:
QString m_xmlData;

View file

@ -39,7 +39,7 @@ FormStandardImportExport::FormStandardImportExport(StandardServiceRoot* service_
FormStandardImportExport::~FormStandardImportExport() = default;
void FormStandardImportExport::setMode(const FeedsImportExportModel::Mode& mode) {
void FormStandardImportExport::setMode(FeedsImportExportModel::Mode mode) {
m_model->setMode(mode);
m_ui->m_progressBar->setVisible(false);
@ -148,7 +148,7 @@ void FormStandardImportExport::selectExportFile(bool without_dialog) {
// Add more filters here.
filter += filter_opml20;
filter += ";;";
filter += QSL(";;");
filter += filter_txt_url_per_line;
selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"),
the_file,
@ -190,7 +190,7 @@ void FormStandardImportExport::selectImportFile() {
// Add more filters here.
filter += filter_opml20;
filter += ";;";
filter += QSL(";;");
filter += filter_txt_url_per_line;
const QString selected_file = QFileDialog::getOpenFileName(this, tr("Select file for feeds import"), qApp->homeFolder(),
filter, &selected_filter);

View file

@ -27,7 +27,7 @@ class FormStandardImportExport : public QDialog {
explicit FormStandardImportExport(StandardServiceRoot* service_root, QWidget* parent = nullptr);
virtual ~FormStandardImportExport();
void setMode(const FeedsImportExportModel::Mode& mode);
void setMode(FeedsImportExportModel::Mode mode);
private slots:
void performAction();

View file

@ -175,7 +175,7 @@ void StandardFeedDetails::guessFeed(StandardFeed::SourceType source_type, const
m_ui.m_cmbEncoding->setCurrentIndex(encoding_index);
}
else {
m_ui.m_cmbEncoding->setCurrentIndex(m_ui.m_cmbEncoding->findText(DEFAULT_FEED_ENCODING,
m_ui.m_cmbEncoding->setCurrentIndex(m_ui.m_cmbEncoding->findText(QSL(DEFAULT_FEED_ENCODING),
Qt::MatchFlag::MatchFixedString));
}
@ -223,7 +223,7 @@ void StandardFeedDetails::onDescriptionChanged(const QString& new_description) {
void StandardFeedDetails::onUrlChanged(const QString& new_url) {
if (sourceType() == StandardFeed::SourceType::Url) {
if (QRegularExpression(URL_REGEXP).match(new_url).hasMatch()) {
if (QRegularExpression(QSL(URL_REGEXP)).match(new_url).hasMatch()) {
m_ui.m_txtSource->setStatus(LineEditWithStatus::StatusType::Ok, tr("The URL is ok."));
}
else if (!new_url.simplified().isEmpty()) {
@ -236,7 +236,7 @@ void StandardFeedDetails::onUrlChanged(const QString& new_url) {
}
}
else if (sourceType() == StandardFeed::SourceType::Script) {
if (QRegularExpression(SCRIPT_SOURCE_TYPE_REGEXP).match(new_url).hasMatch()) {
if (QRegularExpression(QSL(SCRIPT_SOURCE_TYPE_REGEXP)).match(new_url).hasMatch()) {
m_ui.m_txtSource->setStatus(LineEditWithStatus::StatusType::Ok, tr("The source is ok."));
}
else if (!new_url.simplified().isEmpty()) {
@ -253,7 +253,7 @@ void StandardFeedDetails::onUrlChanged(const QString& new_url) {
}
void StandardFeedDetails::onPostProcessScriptChanged(const QString& new_pp) {
if (QRegularExpression(SCRIPT_SOURCE_TYPE_REGEXP).match(new_pp).hasMatch()) {
if (QRegularExpression(QSL(SCRIPT_SOURCE_TYPE_REGEXP)).match(new_pp).hasMatch()) {
m_ui.m_txtPostProcessScript->setStatus(LineEditWithStatus::StatusType::Ok, tr("Command is ok."));
}
else if (!new_pp.simplified().isEmpty()) {
@ -298,7 +298,7 @@ void StandardFeedDetails::prepareForNewFeed(RootItem* parent_to_select, const QS
// Make sure that "default" icon is used as the default option for new
// feed.
m_actionUseDefaultIcon->trigger();
int default_encoding_index = m_ui.m_cmbEncoding->findText(DEFAULT_FEED_ENCODING);
int default_encoding_index = m_ui.m_cmbEncoding->findText(QSL(DEFAULT_FEED_ENCODING));
if (default_encoding_index >= 0) {
m_ui.m_cmbEncoding->setCurrentIndex(default_encoding_index);

View file

@ -13,27 +13,29 @@ JsonParser::JsonParser(const QString& data) : m_jsonData(data) {}
QList<Message> JsonParser::messages() const {
QList<Message> msgs;
QJsonDocument json = QJsonDocument::fromJson(m_jsonData.toUtf8());
QString global_author = json.object()["author"].toObject()["name"].toString();
QString global_author = json.object()[QSL("author")].toObject()[QSL("name")].toString();
if (global_author.isEmpty()) {
global_author = json.object()["authors"].toArray().at(0).toObject()["name"].toString();
global_author = json.object()[QSL("authors")].toArray().at(0).toObject()[QSL("name")].toString();
}
auto json_items = json.object()["items"].toArray();
auto json_items = json.object()[QSL("items")].toArray();
for (const QJsonValue& msg_val : qAsConst(json_items)) {
QJsonObject msg_obj = msg_val.toObject();
Message msg;
msg.m_customId = msg_obj["id"].toString();
msg.m_title = msg_obj["title"].toString();
msg.m_url = msg_obj["url"].toString();
msg.m_contents = msg_obj.contains("content_html") ? msg_obj["content_html"].toString() : msg_obj["content_text"].toString();
msg.m_customId = msg_obj[QSL("id")].toString();
msg.m_title = msg_obj[QSL("title")].toString();
msg.m_url = msg_obj[QSL("url")].toString();
msg.m_contents = msg_obj.contains(QSL("content_html"))
? msg_obj[QSL("content_html")].toString()
: msg_obj[QSL("content_text")].toString();
msg.m_rawContents = QJsonDocument(msg_obj).toJson(QJsonDocument::JsonFormat::Compact);
msg.m_created = TextFactory::parseDateTime(msg_obj.contains("date_modified")
? msg_obj["date_modified"].toString()
: msg_obj["date_published"].toString());
msg.m_created = TextFactory::parseDateTime(msg_obj.contains(QSL("date_modified"))
? msg_obj[QSL("date_modified")].toString()
: msg_obj[QSL("date_published")].toString());
if (!msg.m_created.isValid()) {
msg.m_created = QDateTime::currentDateTime();
@ -43,22 +45,22 @@ QList<Message> JsonParser::messages() const {
msg.m_createdFromFeed = true;
}
if (msg_obj.contains("author")) {
msg.m_author = msg_obj["author"].toObject()["name"].toString();
if (msg_obj.contains(QSL("author"))) {
msg.m_author = msg_obj[QSL("author")].toObject()[QSL("name")].toString();
}
else if (msg_obj.contains("authors")) {
msg.m_author = msg_obj["authors"].toArray().at(0).toObject()["name"].toString();
else if (msg_obj.contains(QSL("authors"))) {
msg.m_author = msg_obj[QSL("authors")].toArray().at(0).toObject()[QSL("name")].toString();
}
else if (!global_author.isEmpty()) {
msg.m_author = global_author;
}
auto json_att = msg_obj["attachments"].toArray();
auto json_att = msg_obj[QSL("attachments")].toArray();
for (const QJsonValue& att : qAsConst(json_att)) {
QJsonObject att_obj = att.toObject();
msg.m_enclosures.append(Enclosure(att_obj["url"].toString(), att_obj["mime_type"].toString()));
msg.m_enclosures.append(Enclosure(att_obj[QSL("url")].toString(), att_obj[QSL("mime_type")].toString()));
}
if (msg.m_title.isEmpty() && !msg.m_url.isEmpty()) {

View file

@ -24,7 +24,7 @@ QDomNodeList RdfParser::messageElements() {
return xml_file.elementsByTagName(QSL("item"));
}
Message RdfParser::extractMessage(const QDomElement& msg_element, QDateTime current_time) const {
Message RdfParser::extractMessage(const QDomElement& msg_element, const QDateTime& current_time) const {
Message new_message;
// Deal with title and description.
@ -78,11 +78,11 @@ Message RdfParser::extractMessage(const QDomElement& msg_element, QDateTime curr
}
if (new_message.m_author.isNull()) {
new_message.m_author = "";
new_message.m_author = QL1S("");
}
if (new_message.m_url.isNull()) {
new_message.m_url = "";
new_message.m_url = QL1S("");
}
return new_message;

View file

@ -18,7 +18,7 @@ class RdfParser : public FeedParser {
private:
QDomNodeList messageElements();
Message extractMessage(const QDomElement& msg_element, QDateTime current_time) const;
Message extractMessage(const QDomElement& msg_element, const QDateTime& current_time) const;
QString m_rdfNamespace;
QString m_rssNamespace;

View file

@ -25,7 +25,7 @@ QDomNodeList RssParser::messageElements() {
}
}
Message RssParser::extractMessage(const QDomElement& msg_element, QDateTime current_time) const {
Message RssParser::extractMessage(const QDomElement& msg_element, const QDateTime& current_time) const {
Message new_message;
// Deal with titles & descriptions.
@ -111,13 +111,13 @@ Message RssParser::extractMessage(const QDomElement& msg_element, QDateTime curr
}
if (new_message.m_author.isNull()) {
new_message.m_author = "";
new_message.m_author = QL1S("");
}
new_message.m_author = qApp->web()->unescapeHtml(new_message.m_author);
if (new_message.m_url.isNull()) {
new_message.m_url = "";
new_message.m_url = QL1S("");
}
return new_message;

View file

@ -15,7 +15,7 @@ class RssParser : public FeedParser {
private:
QDomNodeList messageElements();
Message extractMessage(const QDomElement& msg_element, QDateTime current_time) const;
Message extractMessage(const QDomElement& msg_element, const QDateTime& current_time) const;
};
#endif // RSSPARSER_H

View file

@ -84,10 +84,10 @@ bool StandardCategory::removeItself() {
for (RootItem* child : qAsConst(chi)) {
if (child->kind() == RootItem::Kind::Category) {
children_removed &= dynamic_cast<StandardCategory*>(child)->removeItself();
children_removed &= qobject_cast<StandardCategory*>(child)->removeItself();
}
else if (child->kind() == RootItem::Kind::Feed) {
children_removed &= dynamic_cast<StandardFeed*>(child)->removeItself();
children_removed &= qobject_cast<StandardFeed*>(child)->removeItself();
}
}

View file

@ -123,25 +123,25 @@ void StandardFeed::setPassword(const QString& password) {
QVariantHash StandardFeed::customDatabaseData() const {
QVariantHash data;
data["source_type"] = int(sourceType());
data["type"] = int(type());
data["encoding"] = encoding();
data["post_process"] = postProcessScript();
data["protected"] = passwordProtected();
data["username"] = username();
data["password"] = TextFactory::encrypt(password());
data[QSL("source_type")] = int(sourceType());
data[QSL("type")] = int(type());
data[QSL("encoding")] = encoding();
data[QSL("post_process")] = postProcessScript();
data[QSL("protected")] = passwordProtected();
data[QSL("username")] = username();
data[QSL("password")] = TextFactory::encrypt(password());
return data;
}
void StandardFeed::setCustomDatabaseData(const QVariantHash& data) {
setSourceType(SourceType(data["source_type"].toInt()));
setType(Type(data["type"].toInt()));
setEncoding(data["encoding"].toString());
setPostProcessScript(data["post_process"].toString());
setPasswordProtected(data["protected"].toBool());
setUsername(data["username"].toString());
setPassword(TextFactory::decrypt(data["password"].toString()));
setSourceType(SourceType(data[QSL("source_type")].toInt()));
setType(Type(data[QSL("type")].toInt()));
setEncoding(data[QSL("encoding")].toString());
setPostProcessScript(data[QSL("post_process")].toString());
setPasswordProtected(data[QSL("protected")].toBool());
setUsername(data[QSL("username")].toString());
setPassword(TextFactory::decrypt(data[QSL("password")].toString()));
}
QString StandardFeed::typeToString(StandardFeed::Type type) {
@ -292,24 +292,24 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
feed = new StandardFeed();
// We have JSON feed.
feed->setEncoding(DEFAULT_FEED_ENCODING);
feed->setEncoding(QSL(DEFAULT_FEED_ENCODING));
feed->setType(Type::Json);
QJsonDocument json = QJsonDocument::fromJson(feed_contents);
feed->setTitle(json.object()["title"].toString());
feed->setDescription(json.object()["description"].toString());
feed->setTitle(json.object()[QSL("title")].toString());
feed->setDescription(json.object()[QSL("description")].toString());
auto home_page = json.object()["home_page_url"].toString();
auto home_page = json.object()[QSL("home_page_url")].toString();
if (!home_page.isEmpty()) {
icon_possible_locations.prepend({ home_page, false });
}
auto icon = json.object()["favicon"].toString();
auto icon = json.object()[QSL("favicon")].toString();
if (icon.isEmpty()) {
icon = json.object()["icon"].toString();
icon = json.object()[QSL("icon")].toString();
}
if (!icon.isEmpty()) {
@ -343,7 +343,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
// Feed encoding probably not guessed, set it as
// default.
xml_contents_encoded = feed_contents;
encod = DEFAULT_FEED_ENCODING;
encod = QSL(DEFAULT_FEED_ENCODING);
}
// Feed XML was obtained, guess it now.
@ -382,7 +382,7 @@ StandardFeed* StandardFeed::guessFeed(StandardFeed::SourceType source_type,
}
else if (root_element.tagName() == QL1S("rss")) {
// We found RSS 0.91/0.92/0.93/2.0/2.0.1 feed.
QString rss_type = root_element.attribute("version", "2.0");
QString rss_type = root_element.attribute(QSL("version"), QSL("2.0"));
if (rss_type == QL1S("0.91") || rss_type == QL1S("0.92") || rss_type == QL1S("0.93")) {
feed->setType(Type::Rss0X);
@ -505,7 +505,7 @@ void StandardFeed::setEncoding(const QString& encoding) {
}
QStringList StandardFeed::prepareExecutionLine(const QString& execution_line) {
auto split_exec = execution_line.split(EXECUTION_LINE_SEPARATOR,
auto split_exec = execution_line.split(QSL(EXECUTION_LINE_SEPARATOR),
#if QT_VERSION >= 0x050F00 // Qt >= 5.15.0
Qt::SplitBehaviorFlags::SkipEmptyParts);
#else
@ -582,7 +582,7 @@ QString StandardFeed::generateFeedFileWithScript(const QString& execution_line,
}
QString StandardFeed::postProcessFeedFileWithScript(const QString& execution_line,
const QString raw_feed_data,
const QString& raw_feed_data,
int run_timeout) {
auto prepared_query = prepareExecutionLine(execution_line);

View file

@ -91,7 +91,7 @@ class StandardFeed : public Feed {
static QStringList prepareExecutionLine(const QString& execution_line);
static QString generateFeedFileWithScript(const QString& execution_line, int run_timeout);
static QString postProcessFeedFileWithScript(const QString& execution_line,
const QString raw_feed_data,
const QString& raw_feed_data,
int run_timeout);
static QString runScriptProcess(const QStringList& cmd_args, const QString& working_directory,
int run_timeout, bool provide_input, const QString& input = {});

View file

@ -39,16 +39,17 @@ bool FeedsImportExportModel::exportToOMPL20(QByteArray& result) {
// Added OPML 2.0 metadata.
opml_document.appendChild(opml_document.createElement(QSL("opml")));
opml_document.documentElement().setAttribute(QSL("version"), QSL("2.0"));
opml_document.documentElement().setAttribute("xmlns:rssguard", APP_URL);
opml_document.documentElement().setAttribute(QSL("xmlns:rssguard"), QSL(APP_URL));
QDomElement elem_opml_head = opml_document.createElement(QSL("head"));
QDomElement elem_opml_title = opml_document.createElement(QSL("title"));
QDomText text_opml_title = opml_document.createTextNode(QString(APP_NAME));
QDomText text_opml_title = opml_document.createTextNode(QSL(APP_NAME));
elem_opml_title.appendChild(text_opml_title);
elem_opml_head.appendChild(elem_opml_title);
QDomElement elem_opml_created = opml_document.createElement(QSL("dateCreated"));
QDomText text_opml_created = opml_document.createTextNode(QLocale::c().toString(QDateTime::currentDateTimeUtc(),
QSL("ddd, dd MMM yyyy hh:mm:ss")) + QL1S(" GMT"));
QSL("ddd, dd MMM yyyy hh:mm:ss")) +
QSL(" GMT"));
elem_opml_created.appendChild(text_opml_created);
elem_opml_head.appendChild(elem_opml_created);
@ -176,7 +177,7 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
QStack<QDomElement> elements_to_process;
elements_to_process.push(opml_document.documentElement().elementsByTagName(QSL("body")).at(0).toElement());
total = opml_document.elementsByTagName("outline").size();
total = opml_document.elementsByTagName(QSL("outline")).size();
while (!elements_to_process.isEmpty()) {
RootItem* active_model_item = model_items.pop();
@ -221,8 +222,8 @@ void FeedsImportExportModel::importAsOPML20(const QByteArray& data, bool fetch_m
if (add_offline_anyway) {
QString feed_title = child_element.attribute(QSL("text"));
QString feed_encoding = child_element.attribute(QSL("encoding"), DEFAULT_FEED_ENCODING);
QString feed_type = child_element.attribute(QSL("version"), DEFAULT_FEED_TYPE).toUpper();
QString feed_encoding = child_element.attribute(QSL("encoding"), QSL(DEFAULT_FEED_ENCODING));
QString feed_type = child_element.attribute(QSL("version"), QSL(DEFAULT_FEED_TYPE)).toUpper();
QString feed_description = child_element.attribute(QSL("description"));
QIcon feed_icon = qApp->icons()->fromByteArray(child_element.attribute(QSL("rssguard:icon")).toLocal8Bit());
StandardFeed::SourceType source_type = StandardFeed::SourceType(child_element.attribute(QSL("rssguard:xmlUrlType")).toInt());
@ -368,7 +369,7 @@ void FeedsImportExportModel::importAsTxtURLPerLine(const QByteArray& data, bool
feed->setSource(url);
feed->setTitle(url);
feed->setIcon(qApp->icons()->fromTheme(QSL("application-rss+xml")));
feed->setEncoding(DEFAULT_FEED_ENCODING);
feed->setEncoding(QSL(DEFAULT_FEED_ENCODING));
root_item->appendChild(feed);
if (fetch_metadata_online) {
@ -401,6 +402,6 @@ FeedsImportExportModel::Mode FeedsImportExportModel::mode() const {
return m_mode;
}
void FeedsImportExportModel::setMode(const FeedsImportExportModel::Mode& mode) {
void FeedsImportExportModel::setMode(FeedsImportExportModel::Mode mode) {
m_mode = mode;
}

View file

@ -28,7 +28,7 @@ class FeedsImportExportModel : public AccountCheckSortedModel {
void importAsTxtURLPerLine(const QByteArray& data, bool fetch_metadata_online);
Mode mode() const;
void setMode(const Mode& mode);
void setMode(Mode mode);
signals:
void parsingStarted();

View file

@ -2,9 +2,9 @@
#include "services/standard/standardserviceentrypoint.h"
#include "database/databasequeries.h"
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "database/databasequeries.h"
#include "services/standard/gui/formeditstandardaccount.h"
#include "services/standard/standardserviceroot.h"
@ -17,7 +17,7 @@ QString StandardServiceEntryPoint::description() const {
}
QString StandardServiceEntryPoint::author() const {
return APP_AUTHOR;
return QSL(APP_AUTHOR);
}
QIcon StandardServiceEntryPoint::icon() const {
@ -25,7 +25,7 @@ QIcon StandardServiceEntryPoint::icon() const {
}
QString StandardServiceEntryPoint::code() const {
return SERVICE_CODE_STD_RSS;
return QSL(SERVICE_CODE_STD_RSS);
}
ServiceRoot* StandardServiceEntryPoint::createNewRoot() const {

View file

@ -65,8 +65,8 @@ void StandardServiceRoot::start(bool freshly_activated) {
if (QFile::exists(target_opml_file.arg(current_locale))) {
file_to_load = target_opml_file.arg(current_locale);
}
else if (QFile::exists(target_opml_file.arg(DEFAULT_LOCALE))) {
file_to_load = target_opml_file.arg(DEFAULT_LOCALE);
else if (QFile::exists(target_opml_file.arg(QSL(DEFAULT_LOCALE)))) {
file_to_load = target_opml_file.arg(QSL(DEFAULT_LOCALE));
}
FeedsImportExportModel model;
@ -312,7 +312,7 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model,
}
if (source_item->kind() == RootItem::Kind::Category) {
auto* source_category = dynamic_cast<StandardCategory*>(source_item);
auto* source_category = qobject_cast<StandardCategory*>(source_item);
auto* new_category = new StandardCategory(*source_category);
QString new_category_title = new_category->title();
@ -358,7 +358,7 @@ bool StandardServiceRoot::mergeImportExportModel(FeedsImportExportModel* model,
}
}
else if (source_item->kind() == RootItem::Kind::Feed) {
auto* source_feed = dynamic_cast<StandardFeed*>(source_item);
auto* source_feed = qobject_cast<StandardFeed*>(source_item);
auto* new_feed = new StandardFeed(*source_feed);
QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className());
@ -430,8 +430,8 @@ QList<QAction*> StandardServiceRoot::serviceMenu() {
if (m_serviceMenu.isEmpty()) {
ServiceRoot::serviceMenu();
auto* action_export_feeds = new QAction(qApp->icons()->fromTheme("document-export"), tr("Export feeds"), this);
auto* action_import_feeds = new QAction(qApp->icons()->fromTheme("document-import"), tr("Import feeds"), this);
auto* action_export_feeds = new QAction(qApp->icons()->fromTheme(QSL("document-export")), tr("Export feeds"), this);
auto* action_import_feeds = new QAction(qApp->icons()->fromTheme(QSL("document-import")), tr("Import feeds"), this);
connect(action_export_feeds, &QAction::triggered, this, &StandardServiceRoot::exportFeeds);
connect(action_import_feeds, &QAction::triggered, this, &StandardServiceRoot::importFeeds);

View file

@ -69,12 +69,12 @@ void TtRssAccountDetails::performTest(const QNetworkProxy& proxy) {
if (result.hasError()) {
QString error = result.error();
if (error == TTRSS_API_DISABLED) {
if (error == QSL(TTRSS_API_DISABLED)) {
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("API access on selected server is not enabled."),
tr("API access on selected server is not enabled."));
}
else if (error == TTRSS_LOGIN_ERROR) {
else if (error == QSL(TTRSS_LOGIN_ERROR)) {
m_ui.m_lblTestResult->setStatus(WidgetWithStatus::StatusType::Error,
tr("Entered credentials are incorrect."),
tr("Entered credentials are incorrect."));

View file

@ -15,7 +15,7 @@ TtRssFeedDetails::TtRssFeedDetails(QWidget* parent) : QWidget(parent) {
}
void TtRssFeedDetails::onUrlChanged(const QString& new_url) {
if (QRegularExpression(URL_REGEXP).match(new_url).hasMatch()) {
if (QRegularExpression(QSL(URL_REGEXP)).match(new_url).hasMatch()) {
// New url is well-formed.
ui.m_txtUrl->setStatus(LineEditWithStatus::StatusType::Ok, tr("The URL is ok."));
}

View file

@ -2,9 +2,9 @@
#include "services/tt-rss/ttrssfeed.h"
#include "database/databasequeries.h"
#include "definitions/definitions.h"
#include "miscellaneous/application.h"
#include "database/databasequeries.h"
#include "miscellaneous/iconfactory.h"
#include "miscellaneous/textfactory.h"
#include "services/tt-rss/definitions.h"
@ -27,7 +27,7 @@ bool TtRssFeed::deleteViaGui() {
TtRssUnsubscribeFeedResponse response = serviceRoot()->network()->unsubscribeFeed(customNumericId(),
getParentServiceRoot()->networkProxy());
if (response.code() == UFF_OK && removeItself()) {
if (response.code() == QSL(UFF_OK) && removeItself()) {
serviceRoot()->requestItemRemoval(this);
return true;
}

View file

@ -78,9 +78,9 @@ TtRssLoginResponse TtRssNetworkFactory::login(const QNetworkProxy& proxy) {
QJsonObject json;
json["op"] = QSL("login");
json["user"] = m_username;
json["password"] = m_password;
json[QSL("op")] = QSL("login");
json[QSL("user")] = m_username;
json[QSL("password")] = m_password;
QByteArray result_raw;
QList<QPair<QByteArray, QByteArray>> headers;
@ -120,8 +120,8 @@ TtRssResponse TtRssNetworkFactory::logout(const QNetworkProxy& proxy) {
if (!m_sessionId.isEmpty()) {
QJsonObject json;
json["op"] = QSL("logout");
json["sid"] = m_sessionId;
json[QSL("op")] = QSL("logout");
json[QSL("sid")] = m_sessionId;
QByteArray result_raw;
QList<QPair<QByteArray, QByteArray>> headers;
@ -165,8 +165,8 @@ TtRssResponse TtRssNetworkFactory::logout(const QNetworkProxy& proxy) {
TtRssGetLabelsResponse TtRssNetworkFactory::getLabels(const QNetworkProxy& proxy) {
QJsonObject json;
json["op"] = QSL("getLabels");
json["sid"] = m_sessionId;
json[QSL("op")] = QSL("getLabels");
json[QSL("sid")] = m_sessionId;
const int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray result_raw;
@ -185,7 +185,7 @@ TtRssGetLabelsResponse TtRssNetworkFactory::getLabels(const QNetworkProxy& proxy
if (result.isNotLoggedIn()) {
// We are not logged in.
login(proxy);
json["sid"] = m_sessionId;
json[QSL("sid")] = m_sessionId;
network_reply = NetworkFactory::performNetworkOperation(m_fullUrl,
timeout,
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
@ -212,9 +212,9 @@ TtRssGetLabelsResponse TtRssNetworkFactory::getLabels(const QNetworkProxy& proxy
TtRssGetFeedsCategoriesResponse TtRssNetworkFactory::getFeedsCategories(const QNetworkProxy& proxy) {
QJsonObject json;
json["op"] = QSL("getFeedTree");
json["sid"] = m_sessionId;
json["include_empty"] = true;
json[QSL("op")] = QSL("getFeedTree");
json[QSL("sid")] = m_sessionId;
json[QSL("include_empty")] = true;
const int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray result_raw;
QList<QPair<QByteArray, QByteArray>> headers;
@ -236,7 +236,7 @@ TtRssGetFeedsCategoriesResponse TtRssNetworkFactory::getFeedsCategories(const QN
if (result.isNotLoggedIn()) {
// We are not logged in.
login(proxy);
json["sid"] = m_sessionId;
json[QSL("sid")] = m_sessionId;
network_reply = NetworkFactory::performNetworkOperation(m_fullUrl,
timeout,
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
@ -266,16 +266,16 @@ TtRssGetHeadlinesResponse TtRssNetworkFactory::getHeadlines(int feed_id, int lim
const QNetworkProxy& proxy) {
QJsonObject json;
json["op"] = QSL("getHeadlines");
json["sid"] = m_sessionId;
json["feed_id"] = feed_id;
json["force_update"] = m_forceServerSideUpdate;
json["limit"] = limit;
json["skip"] = skip;
json["view_mode"] = unread_only ? QSL("unread") : QSL("all_articles");
json["show_content"] = show_content;
json["include_attachments"] = include_attachments;
json["sanitize"] = sanitize;
json[QSL("op")] = QSL("getHeadlines");
json[QSL("sid")] = m_sessionId;
json[QSL("feed_id")] = feed_id;
json[QSL("force_update")] = m_forceServerSideUpdate;
json[QSL("limit")] = limit;
json[QSL("skip")] = skip;
json[QSL("view_mode")] = unread_only ? QSL("unread") : QSL("all_articles");
json[QSL("show_content")] = show_content;
json[QSL("include_attachments")] = include_attachments;
json[QSL("sanitize")] = sanitize;
const int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray result_raw;
QList<QPair<QByteArray, QByteArray>> headers;
@ -298,7 +298,7 @@ TtRssGetHeadlinesResponse TtRssNetworkFactory::getHeadlines(int feed_id, int lim
if (result.isNotLoggedIn()) {
// We are not logged in.
login(proxy);
json["sid"] = m_sessionId;
json[QSL("sid")] = m_sessionId;
network_reply = NetworkFactory::performNetworkOperation(m_fullUrl,
timeout,
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
@ -326,11 +326,11 @@ TtRssResponse TtRssNetworkFactory::setArticleLabel(const QStringList& article_id
bool assign, const QNetworkProxy& proxy) {
QJsonObject json;
json["op"] = QSL("setArticleLabel");
json["sid"] = m_sessionId;
json["article_ids"] = article_ids.join(QSL(","));
json["label_id"] = label_custom_id.toInt();
json["assign"] = assign;
json[QSL("op")] = QSL("setArticleLabel");
json[QSL("sid")] = m_sessionId;
json[QSL("article_ids")] = article_ids.join(QSL(","));
json[QSL("label_id")] = label_custom_id.toInt();
json[QSL("assign")] = assign;
const int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray result_raw;
@ -354,7 +354,7 @@ TtRssResponse TtRssNetworkFactory::setArticleLabel(const QStringList& article_id
if (result.isNotLoggedIn()) {
// We are not logged in.
login(proxy);
json["sid"] = m_sessionId;
json[QSL("sid")] = m_sessionId;
network_reply = NetworkFactory::performNetworkOperation(m_fullUrl,
timeout,
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
@ -384,11 +384,11 @@ TtRssUpdateArticleResponse TtRssNetworkFactory::updateArticles(const QStringList
const QNetworkProxy& proxy) {
QJsonObject json;
json["op"] = QSL("updateArticle");
json["sid"] = m_sessionId;
json["article_ids"] = ids.join(QSL(","));
json["mode"] = (int) mode;
json["field"] = (int) field;
json[QSL("op")] = QSL("updateArticle");
json[QSL("sid")] = m_sessionId;
json[QSL("article_ids")] = ids.join(QSL(","));
json[QSL("mode")] = int(mode);
json[QSL("field")] = int(field);
const int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray result_raw;
@ -412,7 +412,7 @@ TtRssUpdateArticleResponse TtRssNetworkFactory::updateArticles(const QStringList
if (result.isNotLoggedIn()) {
// We are not logged in.
login(proxy);
json["sid"] = m_sessionId;
json[QSL("sid")] = m_sessionId;
network_reply = NetworkFactory::performNetworkOperation(m_fullUrl,
timeout,
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
@ -442,14 +442,14 @@ TtRssSubscribeToFeedResponse TtRssNetworkFactory::subscribeToFeed(const QString&
const QString& password) {
QJsonObject json;
json["op"] = QSL("subscribeToFeed");
json["sid"] = m_sessionId;
json["feed_url"] = url;
json["category_id"] = category_id;
json[QSL("op")] = QSL("subscribeToFeed");
json[QSL("sid")] = m_sessionId;
json[QSL("feed_url")] = url;
json[QSL("category_id")] = category_id;
if (protectd) {
json["login"] = username;
json["password"] = password;
json[QSL("login")] = username;
json[QSL("password")] = password;
}
const int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
@ -474,7 +474,7 @@ TtRssSubscribeToFeedResponse TtRssNetworkFactory::subscribeToFeed(const QString&
if (result.isNotLoggedIn()) {
// We are not logged in.
login(proxy);
json["sid"] = m_sessionId;
json[QSL("sid")] = m_sessionId;
network_reply = NetworkFactory::performNetworkOperation(m_fullUrl,
timeout,
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
@ -501,9 +501,9 @@ TtRssSubscribeToFeedResponse TtRssNetworkFactory::subscribeToFeed(const QString&
TtRssUnsubscribeFeedResponse TtRssNetworkFactory::unsubscribeFeed(int feed_id, const QNetworkProxy& proxy) {
QJsonObject json;
json["op"] = QSL("unsubscribeFeed");
json["sid"] = m_sessionId;
json["feed_id"] = feed_id;
json[QSL("op")] = QSL("unsubscribeFeed");
json[QSL("sid")] = m_sessionId;
json[QSL("feed_id")] = feed_id;
const int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
QByteArray result_raw;
QList<QPair<QByteArray, QByteArray>> headers;
@ -526,7 +526,7 @@ TtRssUnsubscribeFeedResponse TtRssNetworkFactory::unsubscribeFeed(int feed_id, c
if (result.isNotLoggedIn()) {
// We are not logged in.
login(proxy);
json["sid"] = m_sessionId;
json[QSL("sid")] = m_sessionId;
network_reply = NetworkFactory::performNetworkOperation(m_fullUrl,
timeout,
QJsonDocument(json).toJson(QJsonDocument::JsonFormat::Compact),
@ -613,7 +613,7 @@ int TtRssResponse::seq() const {
return TTRSS_CONTENT_NOT_LOADED;
}
else {
return m_rawContent["seq"].toInt();
return m_rawContent[QSL("seq")].toInt();
}
}
@ -622,12 +622,12 @@ int TtRssResponse::status() const {
return TTRSS_CONTENT_NOT_LOADED;
}
else {
return m_rawContent["status"].toInt();
return m_rawContent[QSL("status")].toInt();
}
}
bool TtRssResponse::isNotLoggedIn() const {
return status() == TTRSS_API_STATUS_ERR && hasError() && error() == TTRSS_NOT_LOGGED_IN;
return status() == TTRSS_API_STATUS_ERR && hasError() && error() == QSL(TTRSS_NOT_LOGGED_IN);
}
QString TtRssResponse::toString() const {
@ -642,7 +642,7 @@ int TtRssLoginResponse::apiLevel() const {
return TTRSS_CONTENT_NOT_LOADED;
}
else {
return m_rawContent["content"].toObject()["api_level"].toInt();
return m_rawContent[QSL("content")].toObject()[QSL("api_level")].toInt();
}
}
@ -651,7 +651,7 @@ QString TtRssLoginResponse::sessionId() const {
return QString();
}
else {
return m_rawContent["content"].toObject()["session_id"].toString();
return m_rawContent[QSL("content")].toObject()[QSL("session_id")].toString();
}
}
@ -660,7 +660,7 @@ QString TtRssResponse::error() const {
return QString();
}
else {
return m_rawContent["content"].toObject()["error"].toString();
return m_rawContent[QSL("content")].toObject()[QSL("error")].toString();
}
}
@ -669,7 +669,7 @@ bool TtRssResponse::hasError() const {
return false;
}
else {
return m_rawContent["content"].toObject().contains("error");
return m_rawContent[QSL("content")].toObject().contains(QSL("error"));
}
}
@ -686,7 +686,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
if (status() == TTRSS_API_STATUS_OK) {
// We have data, construct object tree according to data.
QJsonArray items_to_process = m_rawContent["content"].toObject()["categories"].toObject()["items"].toArray();
QJsonArray items_to_process = m_rawContent[QSL("content")].toObject()[QSL("categories")].toObject()[QSL("items")].toArray();
QVector<QPair<RootItem*, QJsonValue>> pairs;
for (const QJsonValue& item : items_to_process) {
@ -698,14 +698,14 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
RootItem* act_parent = pair.first;
QJsonObject item = pair.second.toObject();
int item_id = item["bare_id"].toInt();
bool is_category = item.contains("type") && item["type"].toString() == TTRSS_GFT_TYPE_CATEGORY;
bool is_category = item.contains(QSL("type")) && item[QSL("type")].toString() == QSL(TTRSS_GFT_TYPE_CATEGORY);
if (item_id >= 0) {
if (is_category) {
if (item_id == 0) {
// This is "Uncategorized" category, all its feeds belong to top-level root.
if (item.contains("items")) {
auto ite = item["items"].toArray();
if (item.contains(QSL("items"))) {
auto ite = item[QSL("items")].toArray();
for (const QJsonValue& child_feed : qAsConst(ite)) {
pairs.append(QPair<RootItem*, QJsonValue>(parent, child_feed));
@ -715,12 +715,12 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
else {
auto* category = new Category();
category->setTitle(item["name"].toString());
category->setTitle(item[QSL("name")].toString());
category->setCustomId(QString::number(item_id));
act_parent->appendChild(category);
if (item.contains("items")) {
auto ite = item["items"].toArray();
if (item.contains(QSL("items"))) {
auto ite = item[QSL("items")].toArray();
for (const QJsonValue& child : qAsConst(ite)) {
pairs.append(QPair<RootItem*, QJsonValue>(category, child));
@ -733,7 +733,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
auto* feed = new TtRssFeed();
if (obtain_icons) {
QString icon_path = item["icon"].type() == QJsonValue::String ? item["icon"].toString() : QString();
QString icon_path = item[QSL("icon")].type() == QJsonValue::String ? item[QSL("icon")].toString() : QString();
if (!icon_path.isEmpty()) {
// Chop the "api/" suffix out and append
@ -752,7 +752,7 @@ RootItem* TtRssGetFeedsCategoriesResponse::feedsCategories(bool obtain_icons, QS
}
}
feed->setTitle(item["name"].toString());
feed->setTitle(item[QSL("name")].toString());
feed->setCustomId(QString::number(item_id));
act_parent->appendChild(feed);
}
@ -770,19 +770,19 @@ TtRssGetHeadlinesResponse::~TtRssGetHeadlinesResponse() = default;
QList<Message> TtRssGetHeadlinesResponse::messages(ServiceRoot* root) const {
QList<Message> messages;
auto active_labels = root->labelsNode() != nullptr ? root->labelsNode()->labels() : QList<Label*>();
auto json_msgs = m_rawContent["content"].toArray();
auto json_msgs = m_rawContent[QSL("content")].toArray();
for (const QJsonValue& item : qAsConst(json_msgs)) {
QJsonObject mapped = item.toObject();
Message message;
message.m_author = mapped["author"].toString();
message.m_isRead = !mapped["unread"].toBool();
message.m_isImportant = mapped["marked"].toBool();
message.m_contents = mapped["content"].toString();
message.m_author = mapped[QSL("author")].toString();
message.m_isRead = !mapped[QSL("unread")].toBool();
message.m_isImportant = mapped[QSL("marked")].toBool();
message.m_contents = mapped[QSL("content")].toString();
message.m_rawContents = QJsonDocument(mapped).toJson(QJsonDocument::JsonFormat::Compact);
auto json_labels = mapped["labels"].toArray();
auto json_labels = mapped[QSL("labels")].toArray();
for (const QJsonValue& lbl_val : qAsConst(json_labels)) {
QString lbl_custom_id = QString::number(lbl_val.toArray().at(0).toInt());
@ -801,25 +801,25 @@ QList<Message> TtRssGetHeadlinesResponse::messages(ServiceRoot* root) const {
// Multiply by 1000 because Tiny Tiny RSS API does not include miliseconds in Unix
// date/time number.
const qint64 t = static_cast<qint64>(mapped["updated"].toDouble()) * 1000;
const qint64 t = static_cast<qint64>(mapped[QSL("updated")].toDouble()) * 1000;
message.m_created = TextFactory::parseDateTime(t);
message.m_createdFromFeed = true;
message.m_customId = QString::number(mapped["id"].toInt());
message.m_feedId = mapped["feed_id"].toString();
message.m_title = mapped["title"].toString();
message.m_url = mapped["link"].toString();
message.m_customId = QString::number(mapped[QSL("id")].toInt());
message.m_feedId = mapped[QSL("feed_id")].toString();
message.m_title = mapped[QSL("title")].toString();
message.m_url = mapped[QSL("link")].toString();
if (mapped.contains(QSL("attachments"))) {
// Process enclosures.
auto json_att = mapped["attachments"].toArray();
auto json_att = mapped[QSL("attachments")].toArray();
for (const QJsonValue& attachment : qAsConst(json_att)) {
QJsonObject mapped_attachemnt = attachment.toObject();
Enclosure enclosure;
enclosure.m_mimeType = mapped_attachemnt["content_type"].toString();
enclosure.m_url = mapped_attachemnt["content_url"].toString();
enclosure.m_mimeType = mapped_attachemnt[QSL("content_type")].toString();
enclosure.m_url = mapped_attachemnt[QSL("content_url")].toString();
message.m_enclosures.append(enclosure);
}
}
@ -836,7 +836,7 @@ TtRssUpdateArticleResponse::~TtRssUpdateArticleResponse() = default;
QString TtRssUpdateArticleResponse::updateStatus() const {
if (m_rawContent.contains(QSL("content"))) {
return m_rawContent["content"].toObject()["status"].toString();
return m_rawContent[QSL("content")].toObject()[QSL("status")].toString();
}
else {
return QString();
@ -845,7 +845,7 @@ QString TtRssUpdateArticleResponse::updateStatus() const {
int TtRssUpdateArticleResponse::articlesUpdated() const {
if (m_rawContent.contains(QSL("content"))) {
return m_rawContent["content"].toObject()["updated"].toInt();
return m_rawContent[QSL("content")].toObject()[QSL("updated")].toInt();
}
else {
return 0;
@ -857,7 +857,7 @@ TtRssSubscribeToFeedResponse::TtRssSubscribeToFeedResponse(const QString& raw_co
TtRssSubscribeToFeedResponse::~TtRssSubscribeToFeedResponse() = default;
int TtRssSubscribeToFeedResponse::code() const {
if (m_rawContent.contains(QSL("content"))) {
return m_rawContent["content"].toObject()["status"].toObject()["code"].toInt();
return m_rawContent[QSL("content")].toObject()[QSL("status")].toObject()[QSL("code")].toInt();
}
else {
return STF_UNKNOWN;
@ -869,13 +869,13 @@ TtRssUnsubscribeFeedResponse::TtRssUnsubscribeFeedResponse(const QString& raw_co
TtRssUnsubscribeFeedResponse::~TtRssUnsubscribeFeedResponse() = default;
QString TtRssUnsubscribeFeedResponse::code() const {
if (m_rawContent.contains(QSL("content"))) {
QJsonObject map = m_rawContent["content"].toObject();
QJsonObject map = m_rawContent[QSL("content")].toObject();
if (map.contains(QSL("error"))) {
return map["error"].toString();
return map[QSL("error")].toString();
}
else if (map.contains(QSL("status"))) {
return map["status"].toString();
return map[QSL("status")].toString();
}
}
@ -886,13 +886,13 @@ TtRssGetLabelsResponse::TtRssGetLabelsResponse(const QString& raw_content) : TtR
QList<RootItem*> TtRssGetLabelsResponse::labels() const {
QList<RootItem*> labels;
auto json_labels = m_rawContent["content"].toArray();
auto json_labels = m_rawContent[QSL("content")].toArray();
for (const QJsonValue& lbl_val : qAsConst(json_labels)) {
QJsonObject lbl_obj = lbl_val.toObject();
Label* lbl = new Label(lbl_obj["caption"].toString(), QColor(lbl_obj["fg_color"].toString()));
Label* lbl = new Label(lbl_obj[QSL("caption")].toString(), QColor(lbl_obj[QSL("fg_color")].toString()));
lbl->setCustomId(QString::number(lbl_obj["id"].toInt()));
lbl->setCustomId(QString::number(lbl_obj[QSL("id")].toInt()));
labels.append(lbl);
}

View file

@ -2,8 +2,8 @@
#include "services/tt-rss/ttrssserviceentrypoint.h"
#include "definitions/definitions.h"
#include "database/databasequeries.h"
#include "definitions/definitions.h"
#include "miscellaneous/iconfactory.h"
#include "services/tt-rss/definitions.h"
#include "services/tt-rss/gui/formeditttrssaccount.h"
@ -21,7 +21,7 @@ QString TtRssServiceEntryPoint::description() const {
}
QString TtRssServiceEntryPoint::author() const {
return APP_AUTHOR;
return QSL(APP_AUTHOR);
}
QIcon TtRssServiceEntryPoint::icon() const {
@ -29,7 +29,7 @@ QIcon TtRssServiceEntryPoint::icon() const {
}
QString TtRssServiceEntryPoint::code() const {
return SERVICE_CODE_TT_RSS;
return QSL(SERVICE_CODE_TT_RSS);
}
ServiceRoot* TtRssServiceEntryPoint::createNewRoot() const {

View file

@ -189,29 +189,29 @@ void TtRssServiceRoot::saveAllCachedData(bool ignore_errors) {
QVariantHash TtRssServiceRoot::customDatabaseData() const {
QVariantHash data;
data["username"] = m_network->username();
data["password"] = TextFactory::encrypt(m_network->password());
data["auth_protected"] = m_network->authIsUsed();
data["auth_username"] = m_network->authUsername();
data["auth_password"] = TextFactory::encrypt(m_network->authPassword());
data["url"] = m_network->url();
data["force_update"] = m_network->forceServerSideUpdate();
data["batch_size"] = m_network->batchSize();
data["download_only_unread"] = m_network->downloadOnlyUnreadMessages();
data[QSL("username")] = m_network->username();
data[QSL("password")] = TextFactory::encrypt(m_network->password());
data[QSL("auth_protected")] = m_network->authIsUsed();
data[QSL("auth_username")] = m_network->authUsername();
data[QSL("auth_password")] = TextFactory::encrypt(m_network->authPassword());
data[QSL("url")] = m_network->url();
data[QSL("force_update")] = m_network->forceServerSideUpdate();
data[QSL("batch_size")] = m_network->batchSize();
data[QSL("download_only_unread")] = m_network->downloadOnlyUnreadMessages();
return data;
}
void TtRssServiceRoot::setCustomDatabaseData(const QVariantHash& data) {
m_network->setUsername( data["username"].toString());
m_network->setPassword(TextFactory::decrypt(data["password"].toString()));
m_network->setAuthIsUsed(data["auth_protected"].toBool());
m_network->setAuthUsername(data["auth_username"].toString());
m_network->setAuthPassword(TextFactory::decrypt(data["auth_password"].toString()));
m_network->setUrl(data["url"].toString());
m_network->setForceServerSideUpdate(data["force_update"].toBool());
m_network->setBatchSize(data["batch_size"].toInt());
m_network->setDownloadOnlyUnreadMessages(data["download_only_unread"].toBool());
m_network->setUsername(data[QSL("username")].toString());
m_network->setPassword(TextFactory::decrypt(data[QSL("password")].toString()));
m_network->setAuthIsUsed(data[QSL("auth_protected")].toBool());
m_network->setAuthUsername(data[QSL("auth_username")].toString());
m_network->setAuthPassword(TextFactory::decrypt(data[QSL("auth_password")].toString()));
m_network->setUrl(data[QSL("url")].toString());
m_network->setForceServerSideUpdate(data[QSL("force_update")].toBool());
m_network->setBatchSize(data[QSL("batch_size")].toInt());
m_network->setDownloadOnlyUnreadMessages(data[QSL("download_only_unread")].toBool());
}
QList<Message> TtRssServiceRoot::obtainNewMessages(Feed* feed,

View file

@ -38,7 +38,7 @@ int main(int argc, char* argv[]) {
#endif
// Instantiate base application object.
Application application(APP_LOW_NAME, argc, argv);
Application application(QSL(APP_LOW_NAME), argc, argv);
qDebugNN << LOGSEC_CORE << "Starting" << NONQUOTE_W_SPACE_DOT(APP_LONG_NAME);
qDebugNN << LOGSEC_CORE << "Instantiated class " << QUOTE_W_SPACE_DOT(application.metaObject()->className());
@ -66,9 +66,9 @@ int main(int argc, char* argv[]) {
qApp->skins()->loadCurrentSkin();
// These settings needs to be set before any QSettings object.
Application::setApplicationName(APP_NAME);
Application::setApplicationVersion(APP_VERSION);
Application::setOrganizationDomain(APP_URL);
Application::setApplicationName(QSL(APP_NAME));
Application::setApplicationVersion(QSL(APP_VERSION));
Application::setOrganizationDomain(QSL(APP_URL));
Application::setWindowIcon(qApp->desktopAwareIcon());
qApp->reactOnForeignNotifications();
@ -87,7 +87,7 @@ int main(int argc, char* argv[]) {
qApp->offerChanges();
qApp->showPolls();
qApp->mainForm()->tabWidget()->feedMessageViewer()->feedsView()->loadAllExpandStates();
qApp->parseCmdArgumentsFromOtherInstance(qApp->cmdParser()->positionalArguments().join(ARGUMENTS_LIST_SEPARATOR));
qApp->parseCmdArgumentsFromOtherInstance(qApp->cmdParser()->positionalArguments().join(QSL(ARGUMENTS_LIST_SEPARATOR)));
return Application::exec();
}