Rename desktop and appdata files.
This commit is contained in:
parent
2091ee7a9c
commit
c6d6cf32c0
@ -1534,7 +1534,7 @@
|
|||||||
<file>localizations/rssguard_pt.qm</file>
|
<file>localizations/rssguard_pt.qm</file>
|
||||||
<file>localizations/rssguard_sv.qm</file>
|
<file>localizations/rssguard_sv.qm</file>
|
||||||
<file>localizations/rssguard_zh.qm</file>
|
<file>localizations/rssguard_zh.qm</file>
|
||||||
<file>desktop/rssguard.desktop</file>
|
<file>desktop/com.github.rssguard.desktop</file>
|
||||||
<file>desktop/rssguard.desktop.autostart</file>
|
<file>desktop/rssguard.desktop.autostart</file>
|
||||||
<file>localizations/qt_bg.qm</file>
|
<file>localizations/qt_bg.qm</file>
|
||||||
<file>localizations/qt_ca.qm</file>
|
<file>localizations/qt_ca.qm</file>
|
||||||
|
@ -66,6 +66,7 @@ lessThan(QT_MAJOR_VERSION, 5)|lessThan(QT_MINOR_VERSION, 8) {
|
|||||||
|
|
||||||
APP_NAME = "RSS Guard"
|
APP_NAME = "RSS Guard"
|
||||||
APP_LOW_NAME = "rssguard"
|
APP_LOW_NAME = "rssguard"
|
||||||
|
APP_REVERSE_NAME = "com.github.rssguard"
|
||||||
APP_LOW_H_NAME = ".rssguard"
|
APP_LOW_H_NAME = ".rssguard"
|
||||||
APP_AUTHOR = "Martin Rotter"
|
APP_AUTHOR = "Martin Rotter"
|
||||||
APP_COPYRIGHT = "(C) 2011-2017 $$APP_AUTHOR"
|
APP_COPYRIGHT = "(C) 2011-2017 $$APP_AUTHOR"
|
||||||
@ -682,10 +683,10 @@ win32 {
|
|||||||
unix:!mac:!android {
|
unix:!mac:!android {
|
||||||
target.path = $$PREFIX/bin
|
target.path = $$PREFIX/bin
|
||||||
|
|
||||||
desktop_file.files = resources/desktop/$${TARGET}.desktop
|
desktop_file.files = resources/desktop/$${APP_REVERSE_NAME}.desktop
|
||||||
desktop_file.path = $$quote($$PREFIX/share/applications/)
|
desktop_file.path = $$quote($$PREFIX/share/applications/)
|
||||||
|
|
||||||
appdata.files = resources/desktop/$${TARGET}.appdata.xml
|
appdata.files = resources/desktop/$${APP_REVERSE_NAME}.appdata.xml
|
||||||
appdata.path = $$quote($$PREFIX/share/metainfo/)
|
appdata.path = $$quote($$PREFIX/share/metainfo/)
|
||||||
|
|
||||||
desktop_icon.files = resources/graphics/$${TARGET}.png
|
desktop_icon.files = resources/graphics/$${TARGET}.png
|
||||||
|
@ -228,7 +228,7 @@
|
|||||||
|
|
||||||
#if defined(Q_OS_LINUX)
|
#if defined(Q_OS_LINUX)
|
||||||
#define APP_DESKTOP_SOURCE_ENTRY_FILE "rssguard.desktop.autostart"
|
#define APP_DESKTOP_SOURCE_ENTRY_FILE "rssguard.desktop.autostart"
|
||||||
#define APP_DESKTOP_ENTRY_FILE "rssguard.desktop"
|
#define APP_DESKTOP_ENTRY_FILE "com.github.rssguard.desktop"
|
||||||
|
|
||||||
#define APP_DESKTOP_ENTRY_PATH QSL(":/desktop")
|
#define APP_DESKTOP_ENTRY_PATH QSL(":/desktop")
|
||||||
#endif
|
#endif
|
||||||
|
@ -5,13 +5,15 @@
|
|||||||
#include "network-web/silentnetworkaccessmanager.h"
|
#include "network-web/silentnetworkaccessmanager.h"
|
||||||
|
|
||||||
#include <QHttpMultiPart>
|
#include <QHttpMultiPart>
|
||||||
|
#include <QRegularExpression>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
Downloader::Downloader(QObject* parent)
|
Downloader::Downloader(QObject* parent)
|
||||||
: QObject(parent), m_activeReply(nullptr), m_downloadManager(new SilentNetworkAccessManager(this)),
|
: QObject(parent), m_activeReply(nullptr), m_downloadManager(new SilentNetworkAccessManager(this)),
|
||||||
m_timer(new QTimer(this)), m_customHeaders(QHash<QByteArray, QByteArray>()), m_inputData(QByteArray()),
|
m_timer(new QTimer(this)), m_customHeaders(QHash<QByteArray, QByteArray>()), m_inputData(QByteArray()),
|
||||||
m_inputMultipartData(nullptr), m_targetProtected(false), m_targetUsername(QString()), m_targetPassword(QString()),
|
m_inputMultipartData(nullptr), m_targetProtected(false), m_targetUsername(QString()), m_targetPassword(QString()),
|
||||||
m_lastOutputData(QByteArray()), m_lastOutputError(QNetworkReply::NoError), m_lastContentType(QVariant()) {
|
m_lastOutputData(QByteArray()), m_lastOutputMultipartData(QList<QHttpPart*>()), m_lastOutputError(QNetworkReply::NoError),
|
||||||
|
m_lastContentType(QVariant()) {
|
||||||
m_timer->setInterval(DOWNLOAD_TIMEOUT);
|
m_timer->setInterval(DOWNLOAD_TIMEOUT);
|
||||||
m_timer->setSingleShot(true);
|
m_timer->setSingleShot(true);
|
||||||
connect(m_timer, &QTimer::timeout, this, &Downloader::cancel);
|
connect(m_timer, &QTimer::timeout, this, &Downloader::cancel);
|
||||||
@ -124,8 +126,13 @@ void Downloader::finished() {
|
|||||||
runGetRequest(request);
|
runGetRequest(request);
|
||||||
}
|
}
|
||||||
else if (reply_operation == QNetworkAccessManager::PostOperation) {
|
else if (reply_operation == QNetworkAccessManager::PostOperation) {
|
||||||
|
if (m_inputMultipartData == nullptr) {
|
||||||
runPostRequest(request, m_inputData);
|
runPostRequest(request, m_inputData);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
runPostRequest(request, m_inputMultipartData);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (reply_operation == QNetworkAccessManager::PutOperation) {
|
else if (reply_operation == QNetworkAccessManager::PutOperation) {
|
||||||
runPutRequest(request, m_inputData);
|
runPutRequest(request, m_inputData);
|
||||||
}
|
}
|
||||||
@ -136,8 +143,15 @@ void Downloader::finished() {
|
|||||||
else {
|
else {
|
||||||
// No redirection is indicated. Final file is obtained in our "reply" object.
|
// No redirection is indicated. Final file is obtained in our "reply" object.
|
||||||
// Read the data into output buffer.
|
// Read the data into output buffer.
|
||||||
|
if (m_inputMultipartData == nullptr) {
|
||||||
m_lastOutputData = reply->readAll();
|
m_lastOutputData = reply->readAll();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_lastOutputMultipartData = decodeMultipartAnswer(reply);
|
||||||
|
}
|
||||||
|
|
||||||
m_lastContentType = reply->header(QNetworkRequest::ContentTypeHeader);
|
m_lastContentType = reply->header(QNetworkRequest::ContentTypeHeader);
|
||||||
|
|
||||||
m_lastOutputError = reply->error();
|
m_lastOutputError = reply->error();
|
||||||
m_activeReply->deleteLater();
|
m_activeReply->deleteLater();
|
||||||
m_activeReply = nullptr;
|
m_activeReply = nullptr;
|
||||||
@ -158,6 +172,25 @@ void Downloader::progressInternal(qint64 bytes_received, qint64 bytes_total) {
|
|||||||
emit progress(bytes_received, bytes_total);
|
emit progress(bytes_received, bytes_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QHttpPart*> Downloader::decodeMultipartAnswer(QNetworkReply* reply) {
|
||||||
|
QByteArray data = reply->readAll();
|
||||||
|
|
||||||
|
if (data.isEmpty()) {
|
||||||
|
return QList<QHttpPart*>();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString content_type = reply->header(QNetworkRequest::KnownHeaders::ContentTypeHeader).toString();
|
||||||
|
QString boundary = content_type.mid(content_type.indexOf(QL1S("boundary=")) + 9);
|
||||||
|
QRegularExpression regex(QL1S("--") + boundary + QL1S("(--)?(\\r\\n)?"));
|
||||||
|
QStringList list = QString::fromUtf8(data).split(regex, QString::SplitBehavior::SkipEmptyParts);
|
||||||
|
|
||||||
|
QList<QHttpPart*> parts;
|
||||||
|
|
||||||
|
parts.reserve(list.size());
|
||||||
|
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
void Downloader::runDeleteRequest(const QNetworkRequest& request) {
|
void Downloader::runDeleteRequest(const QNetworkRequest& request) {
|
||||||
m_timer->start();
|
m_timer->start();
|
||||||
m_activeReply = m_downloadManager->deleteResource(request);
|
m_activeReply = m_downloadManager->deleteResource(request);
|
||||||
@ -229,6 +262,10 @@ QNetworkReply::NetworkError Downloader::lastOutputError() const {
|
|||||||
return m_lastOutputError;
|
return m_lastOutputError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QHttpPart*> Downloader::lastOutputMultipartData() const {
|
||||||
|
return m_lastOutputMultipartData;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray Downloader::lastOutputData() const {
|
QByteArray Downloader::lastOutputData() const {
|
||||||
return m_lastOutputData;
|
return m_lastOutputData;
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
class SilentNetworkAccessManager;
|
class SilentNetworkAccessManager;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
|
class QHttpPart;
|
||||||
|
|
||||||
class Downloader : public QObject {
|
class Downloader : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -25,6 +26,7 @@ class Downloader : public QObject {
|
|||||||
// Access to last received full output data/error/content-type.
|
// Access to last received full output data/error/content-type.
|
||||||
QByteArray lastOutputData() const;
|
QByteArray lastOutputData() const;
|
||||||
QNetworkReply::NetworkError lastOutputError() const;
|
QNetworkReply::NetworkError lastOutputError() const;
|
||||||
|
QList<QHttpPart*> lastOutputMultipartData() const;
|
||||||
QVariant lastContentType() const;
|
QVariant lastContentType() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -65,6 +67,7 @@ class Downloader : public QObject {
|
|||||||
void progressInternal(qint64 bytes_received, qint64 bytes_total);
|
void progressInternal(qint64 bytes_received, qint64 bytes_total);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QList<QHttpPart*> decodeMultipartAnswer(QNetworkReply* reply);
|
||||||
void manipulateData(const QString& url, QNetworkAccessManager::Operation operation,
|
void manipulateData(const QString& url, QNetworkAccessManager::Operation operation,
|
||||||
const QByteArray& data, QHttpMultiPart* multipart_data,
|
const QByteArray& data, QHttpMultiPart* multipart_data,
|
||||||
int timeout = DOWNLOAD_TIMEOUT, bool protected_contents = false,
|
int timeout = DOWNLOAD_TIMEOUT, bool protected_contents = false,
|
||||||
@ -91,6 +94,8 @@ class Downloader : public QObject {
|
|||||||
// Response data.
|
// Response data.
|
||||||
QByteArray m_lastOutputData;
|
QByteArray m_lastOutputData;
|
||||||
|
|
||||||
|
QList<QHttpPart*> m_lastOutputMultipartData;
|
||||||
|
|
||||||
QNetworkReply::NetworkError m_lastOutputError;
|
QNetworkReply::NetworkError m_lastOutputError;
|
||||||
QVariant m_lastContentType;
|
QVariant m_lastContentType;
|
||||||
};
|
};
|
||||||
|
@ -204,3 +204,34 @@ NetworkResult NetworkFactory::performNetworkOperation(const QString& url, int ti
|
|||||||
result.second = downloader.lastContentType();
|
result.second = downloader.lastContentType();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NetworkResult NetworkFactory::performNetworkOperation(const QString& url,
|
||||||
|
int timeout,
|
||||||
|
QHttpMultiPart* input_data,
|
||||||
|
QList<QHttpPart*>& output,
|
||||||
|
QNetworkAccessManager::Operation operation,
|
||||||
|
QList<QPair<QByteArray, QByteArray>> additional_headers,
|
||||||
|
bool protected_contents,
|
||||||
|
const QString& username,
|
||||||
|
const QString& password) {
|
||||||
|
Downloader downloader;
|
||||||
|
QEventLoop loop;
|
||||||
|
NetworkResult result;
|
||||||
|
|
||||||
|
// We need to quit event loop when the download finishes.
|
||||||
|
QObject::connect(&downloader, &Downloader::completed, &loop, &QEventLoop::quit);
|
||||||
|
|
||||||
|
foreach (const auto& header, additional_headers) {
|
||||||
|
if (!header.first.isEmpty()) {
|
||||||
|
downloader.appendRawHeader(header.first, header.second);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
downloader.manipulateData(url, operation, input_data, timeout, protected_contents, username, password);
|
||||||
|
loop.exec();
|
||||||
|
|
||||||
|
output = downloader.lastOutputMultipartData();
|
||||||
|
result.first = downloader.lastOutputError();
|
||||||
|
result.second = downloader.lastContentType();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#define NETWORKFACTORY_H
|
#define NETWORKFACTORY_H
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
#include <QHttpPart>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@ -39,7 +40,8 @@ class NetworkFactory {
|
|||||||
bool protected_contents = false,
|
bool protected_contents = false,
|
||||||
const QString& username = QString(),
|
const QString& username = QString(),
|
||||||
const QString& password = QString());
|
const QString& password = QString());
|
||||||
static NetworkResult performNetworkOperation(const QString& url, int timeout, const QByteArray& input_data,
|
static NetworkResult performNetworkOperation(const QString& url, int timeout,
|
||||||
|
const QByteArray& input_data,
|
||||||
QByteArray& output,
|
QByteArray& output,
|
||||||
QNetworkAccessManager::Operation operation,
|
QNetworkAccessManager::Operation operation,
|
||||||
QList<QPair<QByteArray,
|
QList<QPair<QByteArray,
|
||||||
@ -47,6 +49,15 @@ class NetworkFactory {
|
|||||||
bool protected_contents = false,
|
bool protected_contents = false,
|
||||||
const QString& username = QString(),
|
const QString& username = QString(),
|
||||||
const QString& password = QString());
|
const QString& password = QString());
|
||||||
|
static NetworkResult performNetworkOperation(const QString& url, int timeout,
|
||||||
|
QHttpMultiPart* input_data,
|
||||||
|
QList<QHttpPart*>& output,
|
||||||
|
QNetworkAccessManager::Operation operation,
|
||||||
|
QList<QPair<QByteArray,
|
||||||
|
QByteArray>> additional_headers = QList<QPair<QByteArray, QByteArray>>(),
|
||||||
|
bool protected_contents = false,
|
||||||
|
const QString& username = QString(),
|
||||||
|
const QString& password = QString());
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NETWORKFACTORY_H
|
#endif // NETWORKFACTORY_H
|
||||||
|
@ -334,6 +334,8 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(const QList<Message>& lite
|
|||||||
|
|
||||||
multi->setContentType(QHttpMultiPart::ContentType::MixedType);
|
multi->setContentType(QHttpMultiPart::ContentType::MixedType);
|
||||||
|
|
||||||
|
QHash<QString, Message> msgs;
|
||||||
|
|
||||||
foreach (const Message& msg, lite_messages) {
|
foreach (const Message& msg, lite_messages) {
|
||||||
QHttpPart part;
|
QHttpPart part;
|
||||||
|
|
||||||
@ -342,29 +344,36 @@ bool GmailNetworkFactory::obtainAndDecodeFullMessages(const QList<Message>& lite
|
|||||||
|
|
||||||
part.setBody(full_msg_endpoint.toUtf8());
|
part.setBody(full_msg_endpoint.toUtf8());
|
||||||
multi->append(part);
|
multi->append(part);
|
||||||
|
msgs.insert(msg.m_customId, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
QEventLoop loop;
|
|
||||||
QNetworkRequest req;
|
|
||||||
QString bearer = m_oauth2->bearer();
|
QString bearer = m_oauth2->bearer();
|
||||||
|
|
||||||
req.setRawHeader(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(), bearer.toLocal8Bit());
|
if (bearer.isEmpty()) {
|
||||||
req.setUrl(QUrl(GMAIL_API_BATCH));
|
|
||||||
auto* repl = SilentNetworkAccessManager::instance()->post(req, multi);
|
|
||||||
|
|
||||||
connect(repl, &QNetworkReply::finished, &loop, &QEventLoop::quit);
|
|
||||||
loop.exec();
|
|
||||||
|
|
||||||
auto resp = repl->readAll();
|
|
||||||
auto aa = repl->error();
|
|
||||||
|
|
||||||
multi->deleteLater();
|
|
||||||
repl->deleteLater();
|
|
||||||
IOFactory::writeTextFile("b.html", resp);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QPair<QByteArray, QByteArray>> headers;
|
||||||
|
QList<QHttpPart*> output;
|
||||||
|
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||||
|
|
||||||
|
headers.append(QPair<QByteArray, QByteArray>(QString(HTTP_HEADERS_AUTHORIZATION).toLocal8Bit(),
|
||||||
|
bearer.toLocal8Bit()));
|
||||||
|
|
||||||
|
if (NetworkFactory::performNetworkOperation(GMAIL_API_BATCH,
|
||||||
|
timeout,
|
||||||
|
multi,
|
||||||
|
output,
|
||||||
|
QNetworkAccessManager::Operation::PostOperation,
|
||||||
|
headers).first == QNetworkReply::NetworkError::NoError) {
|
||||||
|
// We parse each part of HTTP response (it contains HTTP headers and payload with msg full data).
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QList<Message> GmailNetworkFactory::decodeLiteMessages(const QString& messages_json_data, const QString& stream_id,
|
QList<Message> GmailNetworkFactory::decodeLiteMessages(const QString& messages_json_data, const QString& stream_id,
|
||||||
QString& next_page_token) {
|
QString& next_page_token) {
|
||||||
QList<Message> messages;
|
QList<Message> messages;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user