summaryrefslogtreecommitdiff
path: root/buteo-plugins/buteo-sync-plugin-mastodon-posts
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@jolla.com>2026-03-09 09:44:01 +0100
committerAndrew Branson <andrew.branson@jolla.com>2026-03-09 21:13:03 +0100
commite93766b063432347bd1062aa59bbe122ee7a43f3 (patch)
tree4b2f66a383400e8428f6c6388084685a915b2902 /buteo-plugins/buteo-sync-plugin-mastodon-posts
parent9182ffb1573c77367ad6b5e4b1f3e4f52b3c3ea4 (diff)
Localize settings text and refresh Mastodon docsrefactor
- Add QTranslator to notifications plugin - Create own logging category now trace is gone
Diffstat (limited to 'buteo-plugins/buteo-sync-plugin-mastodon-posts')
-rw-r--r--buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodondatatypesyncadaptor.cpp24
-rw-r--r--buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodonpostssyncadaptor.cpp12
2 files changed, 20 insertions, 16 deletions
diff --git a/buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodondatatypesyncadaptor.cpp b/buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodondatatypesyncadaptor.cpp
index 7b47fe8..577e185 100644
--- a/buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodondatatypesyncadaptor.cpp
+++ b/buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodondatatypesyncadaptor.cpp
@@ -20,8 +20,8 @@
#include "mastodondatatypesyncadaptor.h"
#include "mastodonauthutils.h"
-#include "trace.h"
+#include <QtCore/QLoggingCategory>
#include <QtCore/QVariantMap>
#include <QtNetwork/QNetworkRequest>
@@ -36,6 +36,8 @@
#include <SignOn/AuthSession>
#include <SignOn/SessionData>
+Q_LOGGING_CATEGORY(lcMastodonSync, "buteo.plugin.mastodon.sync", QtWarningMsg)
+
MastodonDataTypeSyncAdaptor::MastodonDataTypeSyncAdaptor(
SocialNetworkSyncAdaptor::DataType dataType,
QObject *parent)
@@ -50,7 +52,7 @@ MastodonDataTypeSyncAdaptor::~MastodonDataTypeSyncAdaptor()
void MastodonDataTypeSyncAdaptor::sync(const QString &dataTypeString, int accountId)
{
if (dataTypeString != SocialNetworkSyncAdaptor::dataTypeName(m_dataType)) {
- qCWarning(lcSocialPlugin) << "Mastodon" << SocialNetworkSyncAdaptor::dataTypeName(m_dataType)
+ qCWarning(lcMastodonSync) << "Mastodon" << SocialNetworkSyncAdaptor::dataTypeName(m_dataType)
<< "sync adaptor was asked to sync" << dataTypeString;
setStatus(SocialNetworkSyncAdaptor::Error);
return;
@@ -58,14 +60,14 @@ void MastodonDataTypeSyncAdaptor::sync(const QString &dataTypeString, int accoun
setStatus(SocialNetworkSyncAdaptor::Busy);
updateDataForAccount(accountId);
- qCDebug(lcSocialPlugin) << "successfully triggered sync with profile:" << m_accountSyncProfile->name();
+ qCDebug(lcMastodonSync) << "successfully triggered sync with profile:" << m_accountSyncProfile->name();
}
void MastodonDataTypeSyncAdaptor::updateDataForAccount(int accountId)
{
Accounts::Account *account = Accounts::Account::fromId(m_accountManager, accountId, this);
if (!account) {
- qCWarning(lcSocialPlugin) << "existing account with id" << accountId << "couldn't be retrieved";
+ qCWarning(lcMastodonSync) << "existing account with id" << accountId << "couldn't be retrieved";
setStatus(SocialNetworkSyncAdaptor::Error);
return;
}
@@ -89,7 +91,7 @@ void MastodonDataTypeSyncAdaptor::errorHandler(QNetworkReply::NetworkError err)
const int accountId = reply->property("accountId").toInt();
const int httpStatus = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
- qCWarning(lcSocialPlugin) << SocialNetworkSyncAdaptor::dataTypeName(m_dataType)
+ qCWarning(lcMastodonSync) << SocialNetworkSyncAdaptor::dataTypeName(m_dataType)
<< "request with account" << accountId
<< "experienced error:" << err
<< "HTTP:" << httpStatus;
@@ -114,7 +116,7 @@ void MastodonDataTypeSyncAdaptor::sslErrorsHandler(const QList<QSslError> &errs)
sslerrs.chop(2);
}
- qCWarning(lcSocialPlugin) << SocialNetworkSyncAdaptor::dataTypeName(m_dataType)
+ qCWarning(lcMastodonSync) << SocialNetworkSyncAdaptor::dataTypeName(m_dataType)
<< "request with account" << sender()->property("accountId").toInt()
<< "experienced ssl errors:" << sslerrs;
sender()->setProperty("isError", QVariant::fromValue<bool>(true));
@@ -122,7 +124,7 @@ void MastodonDataTypeSyncAdaptor::sslErrorsHandler(const QList<QSslError> &errs)
void MastodonDataTypeSyncAdaptor::setCredentialsNeedUpdate(Accounts::Account *account)
{
- qCInfo(lcSocialPlugin) << "sociald:Mastodon: setting CredentialsNeedUpdate to true for account:" << account->id();
+ qCInfo(lcMastodonSync) << "sociald:Mastodon: setting CredentialsNeedUpdate to true for account:" << account->id();
Accounts::Service srv(m_accountManager->service(syncServiceName()));
account->selectService(srv);
account->setValue(QStringLiteral("CredentialsNeedUpdate"), QVariant::fromValue<bool>(true));
@@ -145,7 +147,7 @@ void MastodonDataTypeSyncAdaptor::signIn(Accounts::Account *account)
? SignOn::Identity::existingIdentity(account->credentialsId())
: 0;
if (!identity) {
- qCWarning(lcSocialPlugin) << "account" << accountId << "has no valid credentials, cannot sign in";
+ qCWarning(lcMastodonSync) << "account" << accountId << "has no valid credentials, cannot sign in";
decrementSemaphore(accountId);
return;
}
@@ -155,7 +157,7 @@ void MastodonDataTypeSyncAdaptor::signIn(Accounts::Account *account)
const QString mechanism = accSrv.authData().mechanism();
SignOn::AuthSession *session = identity->createSession(method);
if (!session) {
- qCWarning(lcSocialPlugin) << "could not create signon session for account" << accountId;
+ qCWarning(lcMastodonSync) << "could not create signon session for account" << accountId;
identity->deleteLater();
decrementSemaphore(accountId);
return;
@@ -183,7 +185,7 @@ void MastodonDataTypeSyncAdaptor::signOnError(const SignOn::Error &error)
SignOn::Identity *identity = session->property("identity").value<SignOn::Identity*>();
const int accountId = account->id();
- qCWarning(lcSocialPlugin) << "credentials for account with id" << accountId
+ qCWarning(lcMastodonSync) << "credentials for account with id" << accountId
<< "couldn't be retrieved:" << error.type() << error.message();
if (error.type() == SignOn::Error::UserInteraction) {
@@ -211,7 +213,7 @@ void MastodonDataTypeSyncAdaptor::signOnResponse(const SignOn::SessionData &resp
accessToken = MastodonAuthUtils::accessToken(data);
if (accessToken.isEmpty()) {
- qCWarning(lcSocialPlugin) << "signon response for account with id" << accountId
+ qCWarning(lcMastodonSync) << "signon response for account with id" << accountId
<< "contained no access token; keys:" << data.keys();
}
diff --git a/buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodonpostssyncadaptor.cpp b/buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodonpostssyncadaptor.cpp
index 160d6cc..6c9a280 100644
--- a/buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodonpostssyncadaptor.cpp
+++ b/buteo-plugins/buteo-sync-plugin-mastodon-posts/mastodonpostssyncadaptor.cpp
@@ -19,9 +19,9 @@
****************************************************************************/
#include "mastodonpostssyncadaptor.h"
-#include "trace.h"
#include "mastodontextutils.h"
+#include <QtCore/QLoggingCategory>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonValue>
@@ -30,6 +30,8 @@
#include <QtNetwork/QNetworkRequest>
namespace {
+ Q_LOGGING_CATEGORY(lcMastodonPostsSync, "buteo.plugin.mastodon.posts.sync", QtWarningMsg)
+
QString displayNameForAccount(const QJsonObject &account)
{
const QString displayName = account.value(QStringLiteral("display_name")).toString().trimmed();
@@ -80,7 +82,7 @@ void MastodonPostsSyncAdaptor::beginSync(int accountId, const QString &accessTok
void MastodonPostsSyncAdaptor::finalize(int accountId)
{
if (syncAborted()) {
- qCInfo(lcSocialPlugin) << "sync aborted, won't commit database changes";
+ qCInfo(lcMastodonPostsSync) << "sync aborted, won't commit database changes";
} else {
m_db.commit();
m_db.wait();
@@ -121,7 +123,7 @@ void MastodonPostsSyncAdaptor::requestPosts(int accountId, const QString &access
incrementSemaphore(accountId);
setupReplyTimeout(accountId, reply);
} else {
- qCWarning(lcSocialPlugin) << "unable to request home timeline posts from Mastodon account with id" << accountId;
+ qCWarning(lcMastodonPostsSync) << "unable to request home timeline posts from Mastodon account with id" << accountId;
}
}
@@ -146,7 +148,7 @@ void MastodonPostsSyncAdaptor::finishedPostsHandler()
m_db.removePosts(accountId);
if (!statuses.size()) {
- qCDebug(lcSocialPlugin) << "no feed posts received for account" << accountId;
+ qCDebug(lcMastodonPostsSync) << "no feed posts received for account" << accountId;
decrementSemaphore(accountId);
return;
}
@@ -249,7 +251,7 @@ void MastodonPostsSyncAdaptor::finishedPostsHandler()
accountId);
}
} else {
- qCWarning(lcSocialPlugin) << "unable to parse event feed data from request with account" << accountId
+ qCWarning(lcMastodonPostsSync) << "unable to parse event feed data from request with account" << accountId
<< ", got:" << QString::fromUtf8(replyData);
}