diff options
Diffstat (limited to 'transferengine-plugins/mastodonshareplugin')
6 files changed, 161 insertions, 0 deletions
diff --git a/transferengine-plugins/mastodonshareplugin/MastodonShareImage.qml b/transferengine-plugins/mastodonshareplugin/MastodonShareImage.qml new file mode 100644 index 0000000..56b4b4b --- /dev/null +++ b/transferengine-plugins/mastodonshareplugin/MastodonShareImage.qml @@ -0,0 +1,10 @@ +import QtQuick 2.6 +import Sailfish.Silica 1.0 +import Sailfish.TransferEngine 1.0 + +ShareFilePreview { + id: root + + metadataStripped: true + descriptionPlaceholderText: qsTr("Write a post") +} diff --git a/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.cpp b/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.cpp new file mode 100644 index 0000000..405b86e --- /dev/null +++ b/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.cpp @@ -0,0 +1,52 @@ +#include "mastodonplugininfo.h" +#include "mastodonshareservicestatus.h" + +MastodonPluginInfo::MastodonPluginInfo() + : SharingPluginInfo() + , m_mastodonShareServiceStatus(new MastodonShareServiceStatus(this)) +{ + m_capabilities << QLatin1String("image/jpeg") + << QLatin1String("image/png"); + + 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/graphic-m-service-mastodon")); + info.setShareUIPath(QLatin1String("/usr/share/nemo-transferengine/plugins/sharing/MastodonShareImage.qml")); + info.setCapabilities(m_capabilities); + + m_info << info; + } + + emit infoReady(); +} diff --git a/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.h b/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.h new file mode 100644 index 0000000..28eb479 --- /dev/null +++ b/transferengine-plugins/mastodonshareplugin/mastodonplugininfo.h @@ -0,0 +1,29 @@ +#ifndef MASTODONPLUGININFO_H +#define MASTODONPLUGININFO_H + +#include <sharingplugininfo.h> +#include <QStringList> + +class MastodonShareServiceStatus; + +class MastodonPluginInfo : public SharingPluginInfo +{ + Q_OBJECT + +public: + MastodonPluginInfo(); + ~MastodonPluginInfo(); + + QList<SharingMethodInfo> info() const; + void query(); + +private Q_SLOTS: + void serviceReady(); + +private: + MastodonShareServiceStatus *m_mastodonShareServiceStatus; + QList<SharingMethodInfo> m_info; + QStringList m_capabilities; +}; + +#endif // MASTODONPLUGININFO_H diff --git a/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.cpp b/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.cpp new file mode 100644 index 0000000..ec7a732 --- /dev/null +++ b/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.cpp @@ -0,0 +1,23 @@ +#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 new file mode 100644 index 0000000..634d051 --- /dev/null +++ b/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.h @@ -0,0 +1,22 @@ +#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/mastodonshareplugin/mastodonshareplugin.pro b/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.pro new file mode 100644 index 0000000..6de949e --- /dev/null +++ b/transferengine-plugins/mastodonshareplugin/mastodonshareplugin.pro @@ -0,0 +1,25 @@ +TEMPLATE = lib +TARGET = $$qtLibraryTarget(mastodonshareplugin) +CONFIG += plugin +DEPENDPATH += . +INCLUDEPATH += .. + +CONFIG += link_pkgconfig +PKGCONFIG += nemotransferengine-qt5 accounts-qt5 sailfishaccounts libsignon-qt5 + +HEADERS += mastodonshareplugin.h \ + mastodonplugininfo.h \ + ../mastodonshareservicestatus.h + +SOURCES += mastodonshareplugin.cpp \ + mastodonplugininfo.cpp \ + ../mastodonshareservicestatus.cpp + +target.path = $$[QT_INSTALL_LIBS]/nemo-transferengine/plugins/sharing + +OTHER_FILES += *.qml + +shareui.files = MastodonShareImage.qml +shareui.path = /usr/share/nemo-transferengine/plugins/sharing + +INSTALLS += target shareui |
