summaryrefslogtreecommitdiff
path: root/transferengine-plugins
diff options
context:
space:
mode:
Diffstat (limited to 'transferengine-plugins')
-rw-r--r--transferengine-plugins/fediverseshareplugin/FediverseSharePost.qml (renamed from transferengine-plugins/mastodonshareplugin/MastodonSharePost.qml)0
-rw-r--r--transferengine-plugins/fediverseshareplugin/fediverseplugininfo.cpp62
-rw-r--r--transferengine-plugins/fediverseshareplugin/fediverseplugininfo.h (renamed from transferengine-plugins/mastodonshareplugin/mastodonplugininfo.h)16
-rw-r--r--transferengine-plugins/fediverseshareplugin/fediverseshareplugin.cpp29
-rw-r--r--transferengine-plugins/fediverseshareplugin/fediverseshareplugin.h28
-rw-r--r--transferengine-plugins/fediverseshareplugin/fediverseshareplugin.pro (renamed from transferengine-plugins/mastodonshareplugin/mastodonshareplugin.pro)18
-rw-r--r--transferengine-plugins/fediverseshareservicestatus.cpp (renamed from transferengine-plugins/mastodonshareservicestatus.cpp)52
-rw-r--r--transferengine-plugins/fediverseshareservicestatus.h (renamed from transferengine-plugins/mastodonshareservicestatus.h)11
-rw-r--r--transferengine-plugins/fediversetransferplugin/fediverseapi.cpp (renamed from transferengine-plugins/mastodontransferplugin/mastodonapi.cpp)36
-rw-r--r--transferengine-plugins/fediversetransferplugin/fediverseapi.h (renamed from transferengine-plugins/mastodontransferplugin/mastodonapi.h)12
-rw-r--r--transferengine-plugins/fediversetransferplugin/fediversetransferplugin.cpp31
-rw-r--r--transferengine-plugins/fediversetransferplugin/fediversetransferplugin.h (renamed from transferengine-plugins/mastodontransferplugin/mastodontransferplugin.h)14
-rw-r--r--transferengine-plugins/fediversetransferplugin/fediversetransferplugin.pro (renamed from transferengine-plugins/mastodontransferplugin/mastodontransferplugin.pro)19
-rw-r--r--transferengine-plugins/fediversetransferplugin/fediverseuploader.cpp (renamed from transferengine-plugins/mastodontransferplugin/mastodonuploader.cpp)92
-rw-r--r--transferengine-plugins/fediversetransferplugin/fediverseuploader.h (renamed from transferengine-plugins/mastodontransferplugin/mastodonuploader.h)22
-rw-r--r--transferengine-plugins/mastodonshareplugin/mastodonplugininfo.cpp60
-rw-r--r--transferengine-plugins/mastodonshareplugin/mastodonshareplugin.cpp29
-rw-r--r--transferengine-plugins/mastodonshareplugin/mastodonshareplugin.h28
-rw-r--r--transferengine-plugins/mastodontransferplugin/mastodontransferplugin.cpp31
-rw-r--r--transferengine-plugins/transferengine-plugins.pro2
20 files changed, 303 insertions, 289 deletions
diff --git a/transferengine-plugins/mastodonshareplugin/MastodonSharePost.qml b/transferengine-plugins/fediverseshareplugin/FediverseSharePost.qml
index d859d96..d859d96 100644
--- a/transferengine-plugins/mastodonshareplugin/MastodonSharePost.qml
+++ b/transferengine-plugins/fediverseshareplugin/FediverseSharePost.qml
diff --git a/transferengine-plugins/fediverseshareplugin/fediverseplugininfo.cpp b/transferengine-plugins/fediverseshareplugin/fediverseplugininfo.cpp
new file mode 100644
index 0000000..4e04be1
--- /dev/null
+++ b/transferengine-plugins/fediverseshareplugin/fediverseplugininfo.cpp
@@ -0,0 +1,62 @@
+/*
+ * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "fediverseplugininfo.h"
+#include "fediverseshareservicestatus.h"
+
+FediversePluginInfo::FediversePluginInfo()
+ : SharingPluginInfo()
+ , m_fediverseShareServiceStatus(new FediverseShareServiceStatus(this))
+{
+ m_capabilities << QLatin1String("image/jpeg")
+ << QLatin1String("image/png")
+ << QLatin1String("video/mp4")
+ << QLatin1String("text/x-url")
+ << QLatin1String("text/plain");
+
+ connect(m_fediverseShareServiceStatus, &FediverseShareServiceStatus::serviceReady,
+ this, &FediversePluginInfo::serviceReady);
+ connect(m_fediverseShareServiceStatus, &FediverseShareServiceStatus::serviceError,
+ this, &FediversePluginInfo::infoError);
+}
+
+FediversePluginInfo::~FediversePluginInfo()
+{
+}
+
+QList<SharingMethodInfo> FediversePluginInfo::info() const
+{
+ return m_info;
+}
+
+void FediversePluginInfo::query()
+{
+ m_fediverseShareServiceStatus->queryStatus(FediverseShareServiceStatus::PassiveMode);
+}
+
+void FediversePluginInfo::serviceReady()
+{
+ m_info.clear();
+
+ for (int i = 0; i < m_fediverseShareServiceStatus->count(); ++i) {
+ SharingMethodInfo info;
+
+ const FediverseShareServiceStatus::AccountDetails details = m_fediverseShareServiceStatus->details(i);
+ info.setDisplayName(details.providerName);
+ info.setSubtitle(details.displayName);
+ info.setAccountId(details.accountId);
+
+ info.setMethodId(QLatin1String("Fediverse"));
+ info.setMethodIcon(details.iconPath.isEmpty()
+ ? QLatin1String("image://theme/icon-l-fediverse")
+ : details.iconPath);
+ info.setShareUIPath(QLatin1String("/usr/share/nemo-transferengine/plugins/sharing/FediverseSharePost.qml"));
+ info.setCapabilities(m_capabilities);
+ m_info << info;
+ }
+
+ emit infoReady();
+}
diff --git a/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.h b/transferengine-plugins/fediverseshareplugin/fediverseplugininfo.h
index 80fe552..fdd8fc6 100644
--- a/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.h
+++ b/transferengine-plugins/fediverseshareplugin/fediverseplugininfo.h
@@ -4,21 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef MASTODONPLUGININFO_H
-#define MASTODONPLUGININFO_H
+#ifndef FEDIVERSEPLUGININFO_H
+#define FEDIVERSEPLUGININFO_H
#include <sharingplugininfo.h>
#include <QStringList>
-class MastodonShareServiceStatus;
+class FediverseShareServiceStatus;
-class MastodonPluginInfo : public SharingPluginInfo
+class FediversePluginInfo : public SharingPluginInfo
{
Q_OBJECT
public:
- MastodonPluginInfo();
- ~MastodonPluginInfo();
+ FediversePluginInfo();
+ ~FediversePluginInfo();
QList<SharingMethodInfo> info() const;
void query();
@@ -27,9 +27,9 @@ private Q_SLOTS:
void serviceReady();
private:
- MastodonShareServiceStatus *m_mastodonShareServiceStatus;
+ FediverseShareServiceStatus *m_fediverseShareServiceStatus;
QList<SharingMethodInfo> m_info;
QStringList m_capabilities;
};
-#endif // MASTODONPLUGININFO_H
+#endif // FEDIVERSEPLUGININFO_H
diff --git a/transferengine-plugins/fediverseshareplugin/fediverseshareplugin.cpp b/transferengine-plugins/fediverseshareplugin/fediverseshareplugin.cpp
new file mode 100644
index 0000000..18c9c7c
--- /dev/null
+++ b/transferengine-plugins/fediverseshareplugin/fediverseshareplugin.cpp
@@ -0,0 +1,29 @@
+/*
+ * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "fediverseshareplugin.h"
+#include "fediverseplugininfo.h"
+
+#include <QtPlugin>
+
+FediverseSharePlugin::FediverseSharePlugin()
+ : QObject(), SharingPluginInterface()
+{
+}
+
+FediverseSharePlugin::~FediverseSharePlugin()
+{
+}
+
+SharingPluginInfo *FediverseSharePlugin::infoObject()
+{
+ return new FediversePluginInfo;
+}
+
+QString FediverseSharePlugin::pluginId() const
+{
+ return QLatin1String("Fediverse");
+}
diff --git a/transferengine-plugins/fediverseshareplugin/fediverseshareplugin.h b/transferengine-plugins/fediverseshareplugin/fediverseshareplugin.h
new file mode 100644
index 0000000..0eb7772
--- /dev/null
+++ b/transferengine-plugins/fediverseshareplugin/fediverseshareplugin.h
@@ -0,0 +1,28 @@
+/*
+ * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef FEDIVERSESHAREPLUGIN_H
+#define FEDIVERSESHAREPLUGIN_H
+
+#include <QtCore/QObject>
+
+#include <sharingplugininterface.h>
+
+class Q_DECL_EXPORT FediverseSharePlugin : public QObject, public SharingPluginInterface
+{
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.sailfishos.share.plugin.fediverse")
+ Q_INTERFACES(SharingPluginInterface)
+
+public:
+ FediverseSharePlugin();
+ ~FediverseSharePlugin();
+
+ SharingPluginInfo *infoObject();
+ QString pluginId() const;
+};
+
+#endif // FEDIVERSESHAREPLUGIN_H
diff --git a/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.pro b/transferengine-plugins/fediverseshareplugin/fediverseshareplugin.pro
index 59fb7e1..a085a30 100644
--- a/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.pro
+++ b/transferengine-plugins/fediverseshareplugin/fediverseshareplugin.pro
@@ -3,28 +3,30 @@
# SPDX-License-Identifier: BSD-3-Clause
TEMPLATE = lib
-TARGET = $$qtLibraryTarget(mastodonshareplugin)
+TARGET = $$qtLibraryTarget(fediverseshareplugin)
CONFIG += plugin
DEPENDPATH += .
INCLUDEPATH += ..
INCLUDEPATH += ../../common
+QT -= gui
+
CONFIG += link_pkgconfig
PKGCONFIG += nemotransferengine-qt5 accounts-qt5 sailfishaccounts libsignon-qt5
-HEADERS += mastodonshareplugin.h \
- mastodonplugininfo.h \
- ../mastodonshareservicestatus.h
+HEADERS += fediverseshareplugin.h \
+ fediverseplugininfo.h \
+ ../fediverseshareservicestatus.h
-SOURCES += mastodonshareplugin.cpp \
- mastodonplugininfo.cpp \
- ../mastodonshareservicestatus.cpp
+SOURCES += fediverseshareplugin.cpp \
+ fediverseplugininfo.cpp \
+ ../fediverseshareservicestatus.cpp
target.path = $$[QT_INSTALL_LIBS]/nemo-transferengine/plugins/sharing
OTHER_FILES += *.qml
-shareui.files = MastodonSharePost.qml
+shareui.files = FediverseSharePost.qml
shareui.path = /usr/share/nemo-transferengine/plugins/sharing
INSTALLS += target shareui
diff --git a/transferengine-plugins/mastodonshareservicestatus.cpp b/transferengine-plugins/fediverseshareservicestatus.cpp
index 2591520..0ab1460 100644
--- a/transferengine-plugins/mastodonshareservicestatus.cpp
+++ b/transferengine-plugins/fediverseshareservicestatus.cpp
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include "mastodonshareservicestatus.h"
-#include "mastodonauthutils.h"
+#include "fediverseshareservicestatus.h"
+#include "fediverseauthutils.h"
#include <Accounts/Account>
#include <Accounts/AccountService>
@@ -21,20 +21,20 @@
#include <QtCore/QVariantMap>
#include <QtDebug>
-MastodonShareServiceStatus::MastodonShareServiceStatus(QObject *parent)
+FediverseShareServiceStatus::FediverseShareServiceStatus(QObject *parent)
: QObject(parent)
, m_auth(new AccountAuthenticator(this))
, m_accountManager(new Accounts::Manager(this))
- , m_serviceName(QStringLiteral("mastodon-sharing"))
+ , m_serviceName(QStringLiteral("fediverse-sharing"))
{
}
-QString MastodonShareServiceStatus::authServiceName() const
+QString FediverseShareServiceStatus::authServiceName() const
{
- return QStringLiteral("mastodon-microblog");
+ return QStringLiteral("fediverse-microblog");
}
-void MastodonShareServiceStatus::signIn(int accountId)
+void FediverseShareServiceStatus::signIn(int accountId)
{
Accounts::Account *account = Accounts::Account::fromId(m_accountManager, accountId, this);
if (!account) {
@@ -78,7 +78,7 @@ void MastodonShareServiceStatus::signIn(int accountId)
QVariantMap signonSessionData = accountService.authData().parameters();
- MastodonAuthUtils::addSignOnSessionParameters(account, &signonSessionData);
+ FediverseAuthUtils::addSignOnSessionParameters(account, &signonSessionData);
connect(session, SIGNAL(response(SignOn::SessionData)),
this, SLOT(signOnResponse(SignOn::SessionData)),
@@ -92,16 +92,16 @@ void MastodonShareServiceStatus::signIn(int accountId)
session->process(SignOn::SessionData(signonSessionData), mechanism);
}
-void MastodonShareServiceStatus::signOnResponse(const SignOn::SessionData &responseData)
+void FediverseShareServiceStatus::signOnResponse(const SignOn::SessionData &responseData)
{
- const QVariantMap data = MastodonAuthUtils::responseDataToMap(responseData);
+ const QVariantMap data = FediverseAuthUtils::responseDataToMap(responseData);
SignOn::AuthSession *session = qobject_cast<SignOn::AuthSession *>(sender());
Accounts::Account *account = session->property("account").value<Accounts::Account *>();
SignOn::Identity *identity = session->property("identity").value<SignOn::Identity *>();
const int accountId = account ? account->id() : 0;
- QString accessToken = MastodonAuthUtils::accessToken(data);
+ QString accessToken = FediverseAuthUtils::accessToken(data);
if (accountId > 0 && m_accountIdToDetailsIdx.contains(accountId)) {
AccountDetails &accountDetails(m_accountDetails[m_accountIdToDetailsIdx[accountId]]);
@@ -119,7 +119,7 @@ void MastodonShareServiceStatus::signOnResponse(const SignOn::SessionData &respo
}
}
-void MastodonShareServiceStatus::signOnError(const SignOn::Error &error)
+void FediverseShareServiceStatus::signOnError(const SignOn::Error &error)
{
SignOn::AuthSession *session = qobject_cast<SignOn::AuthSession *>(sender());
Accounts::Account *account = session->property("account").value<Accounts::Account *>();
@@ -147,7 +147,7 @@ void MastodonShareServiceStatus::signOnError(const SignOn::Error &error)
}
}
-void MastodonShareServiceStatus::setAccountDetailsState(int accountId, AccountDetailsState state)
+void FediverseShareServiceStatus::setAccountDetailsState(int accountId, AccountDetailsState state)
{
if (!m_accountIdToDetailsIdx.contains(accountId)) {
return;
@@ -170,22 +170,22 @@ void MastodonShareServiceStatus::setAccountDetailsState(int accountId, AccountDe
if (anyPopulated) {
emit serviceReady();
} else {
- emit serviceError(QStringLiteral("Unable to retrieve Mastodon account credentials"));
+ emit serviceError(QStringLiteral("Unable to retrieve Fediverse account credentials"));
}
}
}
-int MastodonShareServiceStatus::count() const
+int FediverseShareServiceStatus::count() const
{
return m_accountDetails.count();
}
-bool MastodonShareServiceStatus::setCredentialsNeedUpdate(int accountId, const QString &serviceName)
+bool FediverseShareServiceStatus::setCredentialsNeedUpdate(int accountId, const QString &serviceName)
{
return m_auth->setCredentialsNeedUpdate(accountId, serviceName);
}
-void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode)
+void FediverseShareServiceStatus::queryStatus(QueryStatusMode mode)
{
m_accountDetails.clear();
m_accountIdToDetailsIdx.clear();
@@ -237,11 +237,16 @@ void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode)
AccountDetails details;
details.accountId = id;
acc->selectService(Accounts::Service());
- details.apiHost = MastodonAuthUtils::normalizeApiHost(acc->value(QStringLiteral("api/Host")).toString());
+ details.apiHost = FediverseAuthUtils::normalizeApiHost(acc->value(QStringLiteral("api/Host")).toString());
+ const QString instanceTitle = acc->value(QStringLiteral("instance/Title")).toString().trimmed();
+ details.iconPath = acc->value(QStringLiteral("iconPath")).toString().trimmed();
acc->selectService(service);
QUrl apiUrl(details.apiHost);
- details.providerName = apiUrl.host();
+ details.providerName = instanceTitle;
+ if (details.providerName.isEmpty()) {
+ details.providerName = apiUrl.host();
+ }
if (details.providerName.isEmpty()) {
details.providerName = details.apiHost;
if (details.providerName.startsWith(QLatin1String("https://"))) {
@@ -255,7 +260,10 @@ void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode)
}
}
- details.displayName = acc->displayName();
+ details.displayName = acc->value(QStringLiteral("description")).toString().trimmed();
+ if (details.displayName.isEmpty()) {
+ details.displayName = acc->displayName();
+ }
m_accountIdToDetailsIdx.insert(id, m_accountDetails.size());
m_accountDetails.append(details);
@@ -276,7 +284,7 @@ void MastodonShareServiceStatus::queryStatus(QueryStatusMode mode)
}
}
-MastodonShareServiceStatus::AccountDetails MastodonShareServiceStatus::details(int index) const
+FediverseShareServiceStatus::AccountDetails FediverseShareServiceStatus::details(int index) const
{
if (index < 0 || index >= m_accountDetails.size()) {
qWarning() << Q_FUNC_INFO << "Index out of range";
@@ -286,7 +294,7 @@ MastodonShareServiceStatus::AccountDetails MastodonShareServiceStatus::details(i
return m_accountDetails.at(index);
}
-MastodonShareServiceStatus::AccountDetails MastodonShareServiceStatus::detailsByIdentifier(int accountIdentifier) const
+FediverseShareServiceStatus::AccountDetails FediverseShareServiceStatus::detailsByIdentifier(int accountIdentifier) const
{
if (!m_accountIdToDetailsIdx.contains(accountIdentifier)) {
qWarning() << Q_FUNC_INFO << "No details known for account with identifier" << accountIdentifier;
diff --git a/transferengine-plugins/mastodonshareservicestatus.h b/transferengine-plugins/fediverseshareservicestatus.h
index be76c37..a82be17 100644
--- a/transferengine-plugins/mastodonshareservicestatus.h
+++ b/transferengine-plugins/fediverseshareservicestatus.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef MASTODONSHARESERVICESTATUS_H
-#define MASTODONSHARESERVICESTATUS_H
+#ifndef FEDIVERSESHARESERVICESTATUS_H
+#define FEDIVERSESHARESERVICESTATUS_H
#include <QtCore/QHash>
#include <QtCore/QObject>
@@ -23,12 +23,12 @@ class Error;
class SessionData;
}
-class MastodonShareServiceStatus : public QObject
+class FediverseShareServiceStatus : public QObject
{
Q_OBJECT
public:
- explicit MastodonShareServiceStatus(QObject *parent = 0);
+ explicit FediverseShareServiceStatus(QObject *parent = 0);
enum QueryStatusMode {
PassiveMode = 0,
@@ -43,6 +43,7 @@ public:
QString displayName;
QString accessToken;
QString apiHost;
+ QString iconPath;
};
AccountDetails details(int index = 0) const;
@@ -78,4 +79,4 @@ private:
QHash<int, AccountDetailsState> m_accountDetailsState;
};
-#endif // MASTODONSHARESERVICESTATUS_H
+#endif // FEDIVERSESHARESERVICESTATUS_H
diff --git a/transferengine-plugins/mastodontransferplugin/mastodonapi.cpp b/transferengine-plugins/fediversetransferplugin/fediverseapi.cpp
index fa973d0..d9de9eb 100644
--- a/transferengine-plugins/mastodontransferplugin/mastodonapi.cpp
+++ b/transferengine-plugins/fediversetransferplugin/fediverseapi.cpp
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include "mastodonapi.h"
-#include "mastodonauthutils.h"
+#include "fediverseapi.h"
+#include "fediverseauthutils.h"
#include <QtCore/QFile>
#include <QtCore/QFileInfo>
@@ -19,18 +19,18 @@
#include <QtDebug>
-MastodonApi::MastodonApi(QNetworkAccessManager *qnam, QObject *parent)
+FediverseApi::FediverseApi(QNetworkAccessManager *qnam, QObject *parent)
: QObject(parent)
, m_cancelRequested(false)
, m_qnam(qnam)
{
}
-MastodonApi::~MastodonApi()
+FediverseApi::~FediverseApi()
{
}
-bool MastodonApi::uploadImage(const QString &filePath,
+bool FediverseApi::uploadImage(const QString &filePath,
const QString &statusText,
const QString &mimeType,
const QString &apiHost,
@@ -43,7 +43,7 @@ bool MastodonApi::uploadImage(const QString &filePath,
}
m_cancelRequested = false;
- m_apiHost = MastodonAuthUtils::normalizeApiHost(apiHost);
+ m_apiHost = FediverseAuthUtils::normalizeApiHost(apiHost);
m_accessToken = accessToken;
m_statusText = statusText;
@@ -83,19 +83,19 @@ bool MastodonApi::uploadImage(const QString &filePath,
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(replyError(QNetworkReply::NetworkError)));
connect(reply, &QNetworkReply::uploadProgress,
- this, &MastodonApi::uploadProgress);
+ this, &FediverseApi::uploadProgress);
connect(reply, &QNetworkReply::finished,
- this, &MastodonApi::finished);
+ this, &FediverseApi::finished);
return true;
}
-bool MastodonApi::postStatus(const QString &statusText,
+bool FediverseApi::postStatus(const QString &statusText,
const QString &apiHost,
const QString &accessToken)
{
m_cancelRequested = false;
- m_apiHost = MastodonAuthUtils::normalizeApiHost(apiHost);
+ m_apiHost = FediverseAuthUtils::normalizeApiHost(apiHost);
m_accessToken = accessToken;
m_statusText = statusText;
@@ -107,7 +107,7 @@ bool MastodonApi::postStatus(const QString &statusText,
return postStatusInternal(QString());
}
-bool MastodonApi::postStatusInternal(const QString &mediaId)
+bool FediverseApi::postStatusInternal(const QString &mediaId)
{
if (m_statusText.trimmed().isEmpty() && mediaId.isEmpty()) {
qWarning() << Q_FUNC_INFO << "status and media id are empty";
@@ -139,12 +139,12 @@ bool MastodonApi::postStatusInternal(const QString &mediaId)
connect(reply, SIGNAL(error(QNetworkReply::NetworkError)),
this, SLOT(replyError(QNetworkReply::NetworkError)));
connect(reply, &QNetworkReply::finished,
- this, &MastodonApi::finished);
+ this, &FediverseApi::finished);
return true;
}
-void MastodonApi::cancelUpload()
+void FediverseApi::cancelUpload()
{
if (m_replies.isEmpty()) {
qWarning() << Q_FUNC_INFO << "can't cancel upload";
@@ -158,19 +158,19 @@ void MastodonApi::cancelUpload()
}
}
-void MastodonApi::replyError(QNetworkReply::NetworkError error)
+void FediverseApi::replyError(QNetworkReply::NetworkError error)
{
Q_UNUSED(error)
}
-void MastodonApi::uploadProgress(qint64 sent, qint64 total)
+void FediverseApi::uploadProgress(qint64 sent, qint64 total)
{
if (total > 0) {
emit transferProgressUpdated(sent / static_cast<qreal>(total));
}
}
-void MastodonApi::finished()
+void FediverseApi::finished()
{
QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
if (!reply || !m_replies.contains(reply)) {
@@ -212,7 +212,7 @@ void MastodonApi::finished()
}
if (!postStatusInternal(mediaId)) {
- qWarning() << Q_FUNC_INFO << "unable to create mastodon status";
+ qWarning() << Q_FUNC_INFO << "unable to create fediverse status";
emit transferError();
}
return;
@@ -226,7 +226,7 @@ void MastodonApi::finished()
emit transferError();
}
-void MastodonApi::finishTransfer(QNetworkReply::NetworkError error, int httpCode, const QByteArray &data)
+void FediverseApi::finishTransfer(QNetworkReply::NetworkError error, int httpCode, const QByteArray &data)
{
m_cancelRequested = false;
diff --git a/transferengine-plugins/mastodontransferplugin/mastodonapi.h b/transferengine-plugins/fediversetransferplugin/fediverseapi.h
index df4c87a..a85442c 100644
--- a/transferengine-plugins/mastodontransferplugin/mastodonapi.h
+++ b/transferengine-plugins/fediversetransferplugin/fediverseapi.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef MASTODONAPI_H
-#define MASTODONAPI_H
+#ifndef FEDIVERSEAPI_H
+#define FEDIVERSEAPI_H
#include <QtCore/QMap>
#include <QtCore/QObject>
@@ -13,7 +13,7 @@
#include <QtNetwork/QNetworkAccessManager>
#include <QtNetwork/QNetworkReply>
-class MastodonApi : public QObject
+class FediverseApi : public QObject
{
Q_OBJECT
@@ -24,8 +24,8 @@ public:
POST_STATUS
};
- explicit MastodonApi(QNetworkAccessManager *qnam, QObject *parent = 0);
- ~MastodonApi();
+ explicit FediverseApi(QNetworkAccessManager *qnam, QObject *parent = 0);
+ ~FediverseApi();
bool uploadImage(const QString &filePath,
const QString &statusText,
@@ -62,4 +62,4 @@ private:
QString m_statusText;
};
-#endif // MASTODONAPI_H
+#endif // FEDIVERSEAPI_H
diff --git a/transferengine-plugins/fediversetransferplugin/fediversetransferplugin.cpp b/transferengine-plugins/fediversetransferplugin/fediversetransferplugin.cpp
new file mode 100644
index 0000000..bd213f8
--- /dev/null
+++ b/transferengine-plugins/fediversetransferplugin/fediversetransferplugin.cpp
@@ -0,0 +1,31 @@
+/*
+ * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include "fediversetransferplugin.h"
+#include "fediverseuploader.h"
+
+#include <QtPlugin>
+#include <QNetworkAccessManager>
+
+FediverseTransferPlugin::FediverseTransferPlugin()
+ : QObject(), TransferPluginInterface()
+ , m_qnam(new QNetworkAccessManager(this))
+{
+}
+
+FediverseTransferPlugin::~FediverseTransferPlugin()
+{
+}
+
+MediaTransferInterface *FediverseTransferPlugin::transferObject()
+{
+ return new FediverseUploader(m_qnam, this);
+}
+
+QString FediverseTransferPlugin::pluginId() const
+{
+ return QLatin1String("Fediverse");
+}
diff --git a/transferengine-plugins/mastodontransferplugin/mastodontransferplugin.h b/transferengine-plugins/fediversetransferplugin/fediversetransferplugin.h
index 4d3baaf..163d23f 100644
--- a/transferengine-plugins/mastodontransferplugin/mastodontransferplugin.h
+++ b/transferengine-plugins/fediversetransferplugin/fediversetransferplugin.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef MASTODONTRANSFERPLUGIN_H
-#define MASTODONTRANSFERPLUGIN_H
+#ifndef FEDIVERSETRANSFERPLUGIN_H
+#define FEDIVERSETRANSFERPLUGIN_H
#include <QtCore/QObject>
@@ -13,15 +13,15 @@
class QNetworkAccessManager;
-class Q_DECL_EXPORT MastodonTransferPlugin : public QObject, public TransferPluginInterface
+class Q_DECL_EXPORT FediverseTransferPlugin : public QObject, public TransferPluginInterface
{
Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.sailfishos.transfer.plugin.mastodon")
+ Q_PLUGIN_METADATA(IID "org.sailfishos.transfer.plugin.fediverse")
Q_INTERFACES(TransferPluginInterface)
public:
- MastodonTransferPlugin();
- ~MastodonTransferPlugin();
+ FediverseTransferPlugin();
+ ~FediverseTransferPlugin();
MediaTransferInterface *transferObject();
QString pluginId() const;
@@ -30,4 +30,4 @@ private:
QNetworkAccessManager *m_qnam;
};
-#endif // MASTODONTRANSFERPLUGIN_H
+#endif // FEDIVERSETRANSFERPLUGIN_H
diff --git a/transferengine-plugins/mastodontransferplugin/mastodontransferplugin.pro b/transferengine-plugins/fediversetransferplugin/fediversetransferplugin.pro
index 422a889..8451dc5 100644
--- a/transferengine-plugins/mastodontransferplugin/mastodontransferplugin.pro
+++ b/transferengine-plugins/fediversetransferplugin/fediversetransferplugin.pro
@@ -3,26 +3,27 @@
# SPDX-License-Identifier: BSD-3-Clause
TEMPLATE = lib
-TARGET = $$qtLibraryTarget(mastodontransferplugin)
+TARGET = $$qtLibraryTarget(fediversetransferplugin)
CONFIG += plugin
DEPENDPATH += .
INCLUDEPATH += ..
INCLUDEPATH += ../../common
+QT -= gui
QT += network
CONFIG += link_pkgconfig
PKGCONFIG += nemotransferengine-qt5 accounts-qt5 sailfishaccounts libsignon-qt5
-HEADERS += mastodontransferplugin.h \
- mastodonuploader.h \
- ../mastodonshareservicestatus.h \
- mastodonapi.h
+HEADERS += fediversetransferplugin.h \
+ fediverseuploader.h \
+ ../fediverseshareservicestatus.h \
+ fediverseapi.h
-SOURCES += mastodontransferplugin.cpp \
- mastodonuploader.cpp \
- ../mastodonshareservicestatus.cpp \
- mastodonapi.cpp
+SOURCES += fediversetransferplugin.cpp \
+ fediverseuploader.cpp \
+ ../fediverseshareservicestatus.cpp \
+ fediverseapi.cpp
target.path = $$[QT_INSTALL_LIBS]/nemo-transferengine/plugins/transfer
diff --git a/transferengine-plugins/mastodontransferplugin/mastodonuploader.cpp b/transferengine-plugins/fediversetransferplugin/fediverseuploader.cpp
index 7b87823..7c8766b 100644
--- a/transferengine-plugins/mastodontransferplugin/mastodonuploader.cpp
+++ b/transferengine-plugins/fediversetransferplugin/fediverseuploader.cpp
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include "mastodonuploader.h"
-#include "mastodonapi.h"
+#include "fediverseuploader.h"
+#include "fediverseapi.h"
#include <imageoperation.h>
#include <mediaitem.h>
@@ -16,40 +16,40 @@
#include <QtDebug>
-MastodonUploader::MastodonUploader(QNetworkAccessManager *qnam, QObject *parent)
+FediverseUploader::FediverseUploader(QNetworkAccessManager *qnam, QObject *parent)
: MediaTransferInterface(parent)
, m_api(0)
- , m_mastodonShareServiceStatus(0)
+ , m_fediverseShareServiceStatus(0)
, m_qnam(qnam)
, m_useTmpFile(false)
{
}
-MastodonUploader::~MastodonUploader()
+FediverseUploader::~FediverseUploader()
{
}
-QString MastodonUploader::displayName() const
+QString FediverseUploader::displayName() const
{
- return tr("Mastodon");
+ return tr("Fediverse");
}
-QUrl MastodonUploader::serviceIcon() const
+QUrl FediverseUploader::serviceIcon() const
{
- return QUrl(QStringLiteral("image://theme/icon-l-mastodon"));
+ return QUrl(QStringLiteral("image://theme/icon-l-fediverse"));
}
-bool MastodonUploader::cancelEnabled() const
+bool FediverseUploader::cancelEnabled() const
{
return true;
}
-bool MastodonUploader::restartEnabled() const
+bool FediverseUploader::restartEnabled() const
{
return true;
}
-void MastodonUploader::start()
+void FediverseUploader::start()
{
if (!mediaItem()) {
qWarning() << Q_FUNC_INFO << "NULL MediaItem. Can't continue";
@@ -57,39 +57,39 @@ void MastodonUploader::start()
return;
}
- if (!m_mastodonShareServiceStatus) {
- m_mastodonShareServiceStatus = new MastodonShareServiceStatus(this);
- connect(m_mastodonShareServiceStatus, &MastodonShareServiceStatus::serviceReady,
- this, &MastodonUploader::startUploading);
- connect(m_mastodonShareServiceStatus, &MastodonShareServiceStatus::serviceError,
+ if (!m_fediverseShareServiceStatus) {
+ m_fediverseShareServiceStatus = new FediverseShareServiceStatus(this);
+ connect(m_fediverseShareServiceStatus, &FediverseShareServiceStatus::serviceReady,
+ this, &FediverseUploader::startUploading);
+ connect(m_fediverseShareServiceStatus, &FediverseShareServiceStatus::serviceError,
this, [this] (const QString &) {
transferError();
});
}
- m_mastodonShareServiceStatus->queryStatus();
+ m_fediverseShareServiceStatus->queryStatus();
}
-void MastodonUploader::cancel()
+void FediverseUploader::cancel()
{
if (m_api) {
m_api->cancelUpload();
} else {
- qWarning() << Q_FUNC_INFO << "Can't cancel. NULL MastodonApi object!";
+ qWarning() << Q_FUNC_INFO << "Can't cancel. NULL FediverseApi object!";
}
}
-void MastodonUploader::startUploading()
+void FediverseUploader::startUploading()
{
- if (!m_mastodonShareServiceStatus) {
- qWarning() << Q_FUNC_INFO << "NULL MastodonShareServiceStatus object!";
+ if (!m_fediverseShareServiceStatus) {
+ qWarning() << Q_FUNC_INFO << "NULL FediverseShareServiceStatus object!";
return;
}
const quint32 accountId = mediaItem()->value(MediaItem::AccountId).toInt();
- m_accountDetails = m_mastodonShareServiceStatus->detailsByIdentifier(accountId);
+ m_accountDetails = m_fediverseShareServiceStatus->detailsByIdentifier(accountId);
if (m_accountDetails.accountId <= 0 || m_accountDetails.accessToken.isEmpty()) {
- qWarning() << Q_FUNC_INFO << "Mastodon account details missing for id" << accountId;
+ qWarning() << Q_FUNC_INFO << "Fediverse account details missing for id" << accountId;
transferError();
return;
}
@@ -107,34 +107,34 @@ void MastodonUploader::startUploading()
}
}
-void MastodonUploader::transferFinished()
+void FediverseUploader::transferFinished()
{
setStatus(MediaTransferInterface::TransferFinished);
}
-void MastodonUploader::transferProgress(qreal progress)
+void FediverseUploader::transferProgress(qreal progress)
{
setProgress(progress);
}
-void MastodonUploader::transferError()
+void FediverseUploader::transferError()
{
setStatus(MediaTransferInterface::TransferInterrupted);
qWarning() << Q_FUNC_INFO << "Transfer interrupted";
}
-void MastodonUploader::transferCanceled()
+void FediverseUploader::transferCanceled()
{
setStatus(MediaTransferInterface::TransferCanceled);
}
-void MastodonUploader::credentialsExpired()
+void FediverseUploader::credentialsExpired()
{
const quint32 accountId = mediaItem()->value(MediaItem::AccountId).toInt();
- m_mastodonShareServiceStatus->setCredentialsNeedUpdate(accountId, QStringLiteral("mastodon-sharing"));
+ m_fediverseShareServiceStatus->setCredentialsNeedUpdate(accountId, QStringLiteral("fediverse-sharing"));
}
-void MastodonUploader::setStatus(MediaTransferInterface::TransferStatus status)
+void FediverseUploader::setStatus(MediaTransferInterface::TransferStatus status)
{
const bool finished = (status == TransferCanceled
|| status == TransferInterrupted
@@ -148,7 +148,7 @@ void MastodonUploader::setStatus(MediaTransferInterface::TransferStatus status)
MediaTransferInterface::setStatus(status);
}
-void MastodonUploader::postImage()
+void FediverseUploader::postImage()
{
m_useTmpFile = false;
m_filePath.clear();
@@ -204,7 +204,7 @@ void MastodonUploader::postImage()
}
}
-void MastodonUploader::postStatus()
+void FediverseUploader::postStatus()
{
ensureApi();
@@ -234,19 +234,19 @@ void MastodonUploader::postStatus()
}
}
-void MastodonUploader::ensureApi()
+void FediverseUploader::ensureApi()
{
if (!m_api) {
- m_api = new MastodonApi(m_qnam, this);
- connect(m_api, &MastodonApi::transferProgressUpdated,
- this, &MastodonUploader::transferProgress);
- connect(m_api, &MastodonApi::transferFinished,
- this, &MastodonUploader::transferFinished);
- connect(m_api, &MastodonApi::transferError,
- this, &MastodonUploader::transferError);
- connect(m_api, &MastodonApi::transferCanceled,
- this, &MastodonUploader::transferCanceled);
- connect(m_api, &MastodonApi::credentialsExpired,
- this, &MastodonUploader::credentialsExpired);
+ m_api = new FediverseApi(m_qnam, this);
+ connect(m_api, &FediverseApi::transferProgressUpdated,
+ this, &FediverseUploader::transferProgress);
+ connect(m_api, &FediverseApi::transferFinished,
+ this, &FediverseUploader::transferFinished);
+ connect(m_api, &FediverseApi::transferError,
+ this, &FediverseUploader::transferError);
+ connect(m_api, &FediverseApi::transferCanceled,
+ this, &FediverseUploader::transferCanceled);
+ connect(m_api, &FediverseApi::credentialsExpired,
+ this, &FediverseUploader::credentialsExpired);
}
}
diff --git a/transferengine-plugins/mastodontransferplugin/mastodonuploader.h b/transferengine-plugins/fediversetransferplugin/fediverseuploader.h
index 72d9689..2343145 100644
--- a/transferengine-plugins/mastodontransferplugin/mastodonuploader.h
+++ b/transferengine-plugins/fediversetransferplugin/fediverseuploader.h
@@ -4,24 +4,24 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef MASTODONUPLOADER_H
-#define MASTODONUPLOADER_H
+#ifndef FEDIVERSEUPLOADER_H
+#define FEDIVERSEUPLOADER_H
#include <QtNetwork/QNetworkAccessManager>
#include <mediatransferinterface.h>
-#include "mastodonshareservicestatus.h"
+#include "fediverseshareservicestatus.h"
-class MastodonApi;
+class FediverseApi;
-class MastodonUploader : public MediaTransferInterface
+class FediverseUploader : public MediaTransferInterface
{
Q_OBJECT
public:
- MastodonUploader(QNetworkAccessManager *qnam, QObject *parent = 0);
- ~MastodonUploader();
+ FediverseUploader(QNetworkAccessManager *qnam, QObject *parent = 0);
+ ~FediverseUploader();
QString displayName() const;
QUrl serviceIcon() const;
@@ -48,12 +48,12 @@ private:
void postImage();
void postStatus();
- MastodonApi *m_api;
- MastodonShareServiceStatus *m_mastodonShareServiceStatus;
+ FediverseApi *m_api;
+ FediverseShareServiceStatus *m_fediverseShareServiceStatus;
QNetworkAccessManager *m_qnam;
- MastodonShareServiceStatus::AccountDetails m_accountDetails;
+ FediverseShareServiceStatus::AccountDetails m_accountDetails;
bool m_useTmpFile;
QString m_filePath;
};
-#endif // MASTODONUPLOADER_H
+#endif // FEDIVERSEUPLOADER_H
diff --git a/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.cpp b/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.cpp
deleted file mode 100644
index 919d544..0000000
--- a/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "mastodonplugininfo.h"
-#include "mastodonshareservicestatus.h"
-
-MastodonPluginInfo::MastodonPluginInfo()
- : SharingPluginInfo()
- , m_mastodonShareServiceStatus(new MastodonShareServiceStatus(this))
-{
- m_capabilities << QLatin1String("image/jpeg")
- << QLatin1String("image/png")
- << QLatin1String("video/mp4")
- << QLatin1String("text/x-url")
- << QLatin1String("text/plain");
-
- connect(m_mastodonShareServiceStatus, &MastodonShareServiceStatus::serviceReady,
- this, &MastodonPluginInfo::serviceReady);
- connect(m_mastodonShareServiceStatus, &MastodonShareServiceStatus::serviceError,
- this, &MastodonPluginInfo::infoError);
-}
-
-MastodonPluginInfo::~MastodonPluginInfo()
-{
-}
-
-QList<SharingMethodInfo> MastodonPluginInfo::info() const
-{
- return m_info;
-}
-
-void MastodonPluginInfo::query()
-{
- m_mastodonShareServiceStatus->queryStatus(MastodonShareServiceStatus::PassiveMode);
-}
-
-void MastodonPluginInfo::serviceReady()
-{
- m_info.clear();
-
- for (int i = 0; i < m_mastodonShareServiceStatus->count(); ++i) {
- SharingMethodInfo info;
-
- const MastodonShareServiceStatus::AccountDetails details = m_mastodonShareServiceStatus->details(i);
- info.setDisplayName(details.providerName);
- info.setSubtitle(details.displayName);
- info.setAccountId(details.accountId);
-
- info.setMethodId(QLatin1String("Mastodon"));
- info.setMethodIcon(QLatin1String("image://theme/icon-l-mastodon"));
- info.setShareUIPath(QLatin1String("/usr/share/nemo-transferengine/plugins/sharing/MastodonSharePost.qml"));
- info.setCapabilities(m_capabilities);
- m_info << info;
- }
-
- emit infoReady();
-}
diff --git a/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.cpp b/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.cpp
deleted file mode 100644
index 8c139a2..0000000
--- a/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "mastodonshareplugin.h"
-#include "mastodonplugininfo.h"
-
-#include <QtPlugin>
-
-MastodonSharePlugin::MastodonSharePlugin()
- : QObject(), SharingPluginInterface()
-{
-}
-
-MastodonSharePlugin::~MastodonSharePlugin()
-{
-}
-
-SharingPluginInfo *MastodonSharePlugin::infoObject()
-{
- return new MastodonPluginInfo;
-}
-
-QString MastodonSharePlugin::pluginId() const
-{
- return QLatin1String("Mastodon");
-}
diff --git a/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.h b/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.h
deleted file mode 100644
index 04d8412..0000000
--- a/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#ifndef MASTODONSHAREPLUGIN_H
-#define MASTODONSHAREPLUGIN_H
-
-#include <QtCore/QObject>
-
-#include <sharingplugininterface.h>
-
-class Q_DECL_EXPORT MastodonSharePlugin : public QObject, public SharingPluginInterface
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "org.sailfishos.share.plugin.mastodon")
- Q_INTERFACES(SharingPluginInterface)
-
-public:
- MastodonSharePlugin();
- ~MastodonSharePlugin();
-
- SharingPluginInfo *infoObject();
- QString pluginId() const;
-};
-
-#endif // MASTODONSHAREPLUGIN_H
diff --git a/transferengine-plugins/mastodontransferplugin/mastodontransferplugin.cpp b/transferengine-plugins/mastodontransferplugin/mastodontransferplugin.cpp
deleted file mode 100644
index a843df2..0000000
--- a/transferengine-plugins/mastodontransferplugin/mastodontransferplugin.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2013 - 2026 Jolla Ltd.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include "mastodontransferplugin.h"
-#include "mastodonuploader.h"
-
-#include <QtPlugin>
-#include <QNetworkAccessManager>
-
-MastodonTransferPlugin::MastodonTransferPlugin()
- : QObject(), TransferPluginInterface()
- , m_qnam(new QNetworkAccessManager(this))
-{
-}
-
-MastodonTransferPlugin::~MastodonTransferPlugin()
-{
-}
-
-MediaTransferInterface *MastodonTransferPlugin::transferObject()
-{
- return new MastodonUploader(m_qnam, this);
-}
-
-QString MastodonTransferPlugin::pluginId() const
-{
- return QLatin1String("Mastodon");
-}
diff --git a/transferengine-plugins/transferengine-plugins.pro b/transferengine-plugins/transferengine-plugins.pro
index e2503a3..ce1a102 100644
--- a/transferengine-plugins/transferengine-plugins.pro
+++ b/transferengine-plugins/transferengine-plugins.pro
@@ -3,4 +3,4 @@
# SPDX-License-Identifier: BSD-3-Clause
TEMPLATE = subdirs
-SUBDIRS = mastodonshareplugin mastodontransferplugin
+SUBDIRS = fediverseshareplugin fediversetransferplugin