mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-01 18:06:51 +01:00
New -n CLI switch to disable console outputs.
This commit is contained in:
parent
f049c667eb
commit
795e1b2f72
@ -90,6 +90,8 @@
|
||||
#define CLI_DAT_LONG "data"
|
||||
#define CLI_SIN_SHORT "s"
|
||||
#define CLI_SIN_LONG "no-single-instance"
|
||||
#define CLI_NDEBUG_SHORT "n"
|
||||
#define CLI_NDEBUG_LONG "no-debug-output"
|
||||
|
||||
#define HTTP_HEADERS_ACCEPT "Accept"
|
||||
#define HTTP_HEADERS_CONTENT_TYPE "Content-Type"
|
||||
|
@ -86,12 +86,15 @@ Application::~Application() {
|
||||
}
|
||||
|
||||
QString s_customLogFile = QString();
|
||||
bool s_disableDebug = false;
|
||||
|
||||
void Application::performLogging(QtMsgType type, const QMessageLogContext& context, const QString& msg) {
|
||||
#ifndef QT_NO_DEBUG_OUTPUT
|
||||
QString console_message = qFormatLogMessage(type, context, msg);
|
||||
|
||||
std::cerr << console_message.toStdString() << std::endl;
|
||||
if (!s_disableDebug) {
|
||||
std::cerr << console_message.toStdString() << std::endl;
|
||||
}
|
||||
|
||||
if (!s_customLogFile.isEmpty()) {
|
||||
QFile log_file(s_customLogFile);
|
||||
@ -572,8 +575,10 @@ void Application::parseCmdArguments() {
|
||||
"user-data-folder");
|
||||
QCommandLineOption disable_singleinstance(QStringList() << CLI_SIN_SHORT << CLI_SIN_LONG,
|
||||
"Allow running of multiple application instances.");
|
||||
QCommandLineOption disable_debug(QStringList() << CLI_NDEBUG_SHORT << CLI_NDEBUG_LONG,
|
||||
"Completely disable stdout/stderr outputs.");
|
||||
|
||||
m_cmdParser.addOptions({ log_file, custom_data_folder, disable_singleinstance });
|
||||
m_cmdParser.addOptions({ log_file, custom_data_folder, disable_singleinstance, disable_debug });
|
||||
m_cmdParser.addHelpOption();
|
||||
m_cmdParser.addVersionOption();
|
||||
m_cmdParser.setApplicationDescription(APP_NAME);
|
||||
@ -599,6 +604,11 @@ void Application::parseCmdArguments() {
|
||||
m_allowMultipleInstances = true;
|
||||
qDebugNN << LOGSEC_CORE << "Explicitly allowing this instance to run.";
|
||||
}
|
||||
|
||||
if (m_cmdParser.isSet(CLI_NDEBUG_SHORT)) {
|
||||
s_disableDebug = true;
|
||||
qDebugNN << LOGSEC_CORE << "Disabling any stdout/stderr outputs.";
|
||||
}
|
||||
}
|
||||
|
||||
QString Application::customDataFolder() const {
|
||||
|
@ -148,11 +148,8 @@ void OAuth2Service::retrieveAccessToken(const QString& auth_code) {
|
||||
m_networkManager.post(networkRequest, content.toUtf8());
|
||||
}
|
||||
|
||||
void OAuth2Service::refreshAccessToken(QString refresh_token) {
|
||||
if (refresh_token.isEmpty()) {
|
||||
refresh_token = refreshToken();
|
||||
}
|
||||
|
||||
void OAuth2Service::refreshAccessToken(const QString& refresh_token) {
|
||||
auto real_refresh_token = refresh_token.isEmpty() ? refreshToken() : refresh_token;
|
||||
QNetworkRequest networkRequest;
|
||||
|
||||
networkRequest.setUrl(m_tokenUrl);
|
||||
@ -161,7 +158,7 @@ void OAuth2Service::refreshAccessToken(QString refresh_token) {
|
||||
QString content = QString("client_id=%1&"
|
||||
"client_secret=%2&"
|
||||
"refresh_token=%3&"
|
||||
"grant_type=%4").arg(m_clientId, m_clientSecret, refresh_token, QSL("refresh_token"));
|
||||
"grant_type=%4").arg(m_clientId, m_clientSecret, real_refresh_token, QSL("refresh_token"));
|
||||
|
||||
qApp->showGuiMessage(tr("Logging in via OAuth 2.0..."),
|
||||
tr("Refreshing login tokens for '%1'...").arg(m_tokenUrl.toString()),
|
||||
@ -205,7 +202,7 @@ void OAuth2Service::tokenRequestFinished(QNetworkReply* network_reply) {
|
||||
<< "Obtained refresh token" << QUOTE_W_SPACE(refreshToken())
|
||||
<< "- expires on date/time" << QUOTE_W_SPACE_DOT(tokensExpireIn());
|
||||
|
||||
emit tokensReceived(accessToken(), refreshToken(), expires);
|
||||
emit tokensRetrieved(accessToken(), refreshToken(), expires);
|
||||
}
|
||||
|
||||
network_reply->deleteLater();
|
||||
|
@ -71,7 +71,7 @@ class OAuth2Service : public QObject {
|
||||
void setId(const QString& id);
|
||||
|
||||
signals:
|
||||
void tokensReceived(QString access_token, QString refresh_token, int expires_in);
|
||||
void tokensRetrieved(QString access_token, QString refresh_token, int expires_in);
|
||||
void tokensRetrieveError(QString error, QString error_description);
|
||||
|
||||
// User failed to authenticate or rejected it.
|
||||
@ -80,7 +80,7 @@ class OAuth2Service : public QObject {
|
||||
public slots:
|
||||
void retrieveAuthCode();
|
||||
void retrieveAccessToken(const QString& auth_code);
|
||||
void refreshAccessToken(QString refresh_token = QString());
|
||||
void refreshAccessToken(const QString& refresh_token = QString());
|
||||
|
||||
// Performs login if needed. If some refresh token is set, then
|
||||
// the initial "auth" step is skipped and attempt to refresh
|
||||
@ -93,6 +93,7 @@ class OAuth2Service : public QObject {
|
||||
// because widgets may be displayed.
|
||||
bool login();
|
||||
|
||||
// Removes all state data and stops redirection handler.
|
||||
void logout();
|
||||
|
||||
private slots:
|
||||
|
@ -39,7 +39,7 @@ FeedlyNetwork::FeedlyNetwork(QObject* parent)
|
||||
|
||||
connect(m_oauth, &OAuth2Service::tokensRetrieveError, this, &FeedlyNetwork::onTokensError);
|
||||
connect(m_oauth, &OAuth2Service::authFailed, this, &FeedlyNetwork::onAuthFailed);
|
||||
connect(m_oauth, &OAuth2Service::tokensReceived, this, &FeedlyNetwork::onTokensReceived);
|
||||
connect(m_oauth, &OAuth2Service::tokensRetrieved, this, &FeedlyNetwork::ontokensRetrieved);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ void FeedlyNetwork::onAuthFailed() {
|
||||
});
|
||||
}
|
||||
|
||||
void FeedlyNetwork::onTokensReceived(const QString& access_token, const QString& refresh_token, int expires_in) {
|
||||
void FeedlyNetwork::ontokensRetrieved(const QString& access_token, const QString& refresh_token, int expires_in) {
|
||||
Q_UNUSED(expires_in)
|
||||
Q_UNUSED(access_token)
|
||||
|
||||
|
@ -42,7 +42,7 @@ class FeedlyNetwork : public QObject {
|
||||
private slots:
|
||||
void onTokensError(const QString& error, const QString& error_description);
|
||||
void onAuthFailed();
|
||||
void onTokensReceived(const QString& access_token, const QString& refresh_token, int expires_in);
|
||||
void ontokensRetrieved(const QString& access_token, const QString& refresh_token, int expires_in);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -80,7 +80,7 @@ void FeedlyAccountDetails::getDeveloperAccessToken() {
|
||||
#if defined (FEEDLY_OFFICIAL_SUPPORT)
|
||||
|
||||
void FeedlyAccountDetails::hookNetwork() {
|
||||
connect(m_oauth, &OAuth2Service::tokensReceived, this, &FeedlyAccountDetails::onAuthGranted);
|
||||
connect(m_oauth, &OAuth2Service::tokensRetrieved, this, &FeedlyAccountDetails::onAuthGranted);
|
||||
connect(m_oauth, &OAuth2Service::tokensRetrieveError, this, &FeedlyAccountDetails::onAuthError);
|
||||
connect(m_oauth, &OAuth2Service::authFailed, this, &FeedlyAccountDetails::onAuthFailed);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void GmailAccountDetails::onAuthGranted() {
|
||||
}
|
||||
|
||||
void GmailAccountDetails::hookNetwork() {
|
||||
connect(m_oauth, &OAuth2Service::tokensReceived, this, &GmailAccountDetails::onAuthGranted);
|
||||
connect(m_oauth, &OAuth2Service::tokensRetrieved, this, &GmailAccountDetails::onAuthGranted);
|
||||
connect(m_oauth, &OAuth2Service::tokensRetrieveError, this, &GmailAccountDetails::onAuthError);
|
||||
connect(m_oauth, &OAuth2Service::authFailed, this, &GmailAccountDetails::onAuthFailed);
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ QString GmailNetworkFactory::sendEmail(Mimesis::Message msg, const QNetworkProxy
|
||||
void GmailNetworkFactory::initializeOauth() {
|
||||
connect(m_oauth2, &OAuth2Service::tokensRetrieveError, this, &GmailNetworkFactory::onTokensError);
|
||||
connect(m_oauth2, &OAuth2Service::authFailed, this, &GmailNetworkFactory::onAuthFailed);
|
||||
connect(m_oauth2, &OAuth2Service::tokensReceived, this, [this](QString access_token, QString refresh_token, int expires_in) {
|
||||
connect(m_oauth2, &OAuth2Service::tokensRetrieved, this, [this](QString access_token, QString refresh_token, int expires_in) {
|
||||
Q_UNUSED(expires_in)
|
||||
Q_UNUSED(access_token)
|
||||
|
||||
|
@ -99,7 +99,7 @@ void InoreaderAccountDetails::onAuthGranted() {
|
||||
}
|
||||
|
||||
void InoreaderAccountDetails::hookNetwork() {
|
||||
connect(m_oauth, &OAuth2Service::tokensReceived, this, &InoreaderAccountDetails::onAuthGranted);
|
||||
connect(m_oauth, &OAuth2Service::tokensRetrieved, this, &InoreaderAccountDetails::onAuthGranted);
|
||||
connect(m_oauth, &OAuth2Service::tokensRetrieveError, this, &InoreaderAccountDetails::onAuthError);
|
||||
connect(m_oauth, &OAuth2Service::authFailed, this, &InoreaderAccountDetails::onAuthFailed);
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ void InoreaderNetworkFactory::setBatchSize(int batch_size) {
|
||||
void InoreaderNetworkFactory::initializeOauth() {
|
||||
connect(m_oauth2, &OAuth2Service::tokensRetrieveError, this, &InoreaderNetworkFactory::onTokensError);
|
||||
connect(m_oauth2, &OAuth2Service::authFailed, this, &InoreaderNetworkFactory::onAuthFailed);
|
||||
connect(m_oauth2, &OAuth2Service::tokensReceived, this, [this](QString access_token, QString refresh_token, int expires_in) {
|
||||
connect(m_oauth2, &OAuth2Service::tokensRetrieved, this, [this](QString access_token, QString refresh_token, int expires_in) {
|
||||
Q_UNUSED(expires_in)
|
||||
Q_UNUSED(access_token)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user