summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@jolla.com>2026-02-13 06:26:11 +0100
committerAndrew Branson <andrew.branson@jolla.com>2026-02-13 06:26:11 +0100
commitce4447024641c0ee793539d79a6d9be7a34a000b (patch)
tree9fc690b3c5e8c0f6f6b027f2d8461f5907397a55
parent8c09980c00061a97eab050a4f0fd5fb4135d6ee7 (diff)
Drop libsocialcache files in MastodonPostsModel
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml6
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel.cpp190
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel.h72
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel_p.h53
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/eventsview-plugin-mastodon.pro3
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.cpp104
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.h21
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/postimagehelper_p.h45
-rw-r--r--eventsview-plugins/eventsview-plugin-mastodon/synchronizelists_p.h224
-rw-r--r--rpm/sailfish-account-mastodon.spec4
10 files changed, 82 insertions, 640 deletions
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml b/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml
index b9e5049..b9eb3ce 100644
--- a/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml
+++ b/eventsview-plugins/eventsview-plugin-mastodon/MastodonFeedItem.qml
@@ -46,7 +46,11 @@ SocialMediaFeedItem {
_actionMenu.close()
}
}
- onPressAndHold: {
+ onPressAndHold: function(mouse) {
+ if (mouse) {
+ mouse.accepted = true
+ }
+ Lipstick.compositor.eventsLayer.setHousekeeping(false)
if (!housekeeping && !lockScreenActive) {
_contextMenuOpen = false
openActionMenu()
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel.cpp b/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel.cpp
deleted file mode 100644
index 895ad72..0000000
--- a/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (C) 2013-2026 Jolla Ltd.
- * Contact: Lucien Xu <lucien.xu@jollamobile.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "abstractsocialcachemodel.h"
-#include "abstractsocialcachemodel_p.h"
-
-#include <synchronizelists_p.h>
-
-#include <QtCore/QDebug>
-#include <QtCore/QMutexLocker>
-
-template <> bool compareIdentity<SocialCacheModelRow>(
- const SocialCacheModelRow &item, const SocialCacheModelRow &reference)
-{
- return item.value(0) == reference.value(0);
-}
-
-template <>
-int updateRange<AbstractSocialCacheModelPrivate, SocialCacheModelData>(
- AbstractSocialCacheModelPrivate *d,
- int index,
- int count,
- const SocialCacheModelData &source,
- int sourceIndex)
-{
- d->updateRange(index, count, source, sourceIndex);
-
- return count;
-}
-
-AbstractSocialCacheModelPrivate::AbstractSocialCacheModelPrivate(AbstractSocialCacheModel *q)
- : q_ptr(q)
-{
-}
-
-AbstractSocialCacheModelPrivate::~AbstractSocialCacheModelPrivate()
-{
-}
-
-void AbstractSocialCacheModelPrivate::clearData()
-{
- Q_Q(AbstractSocialCacheModel);
- if (m_data.count() > 0) {
- q->beginRemoveRows(QModelIndex(), 0, m_data.count() - 1);
- m_data.clear();
- q->endRemoveRows();
- emit q->countChanged();
- }
-}
-
-void AbstractSocialCacheModelPrivate::updateData(const SocialCacheModelData &data)
-{
- Q_Q(AbstractSocialCacheModel);
- q->updateData(data);
-}
-
-void AbstractSocialCacheModelPrivate::updateRow(int row, const SocialCacheModelRow &data)
-{
- Q_Q(AbstractSocialCacheModel);
- q->updateRow(row, data);
-}
-
-void AbstractSocialCacheModelPrivate::insertRange(
- int index, int count, const SocialCacheModelData &source, int sourceIndex)
-{
- Q_Q(AbstractSocialCacheModel);
-
- if (count > 0 && index >= 0) {
- q->beginInsertRows(QModelIndex(), index, index + count - 1);
- m_data = m_data.mid(0, index) + source.mid(sourceIndex, count) + m_data.mid(index);
- q->endInsertRows();
- emit q->countChanged();
- }
-}
-
-void AbstractSocialCacheModelPrivate::removeRange(int index, int count)
-{
- Q_Q(AbstractSocialCacheModel);
-
- if (count > 0 && index >= 0) {
- q->beginRemoveRows(QModelIndex(), index, index + count - 1);
- m_data = m_data.mid(0, index) + m_data.mid(index + count);
- q->endRemoveRows();
- emit q->countChanged();
- }
-}
-
-void AbstractSocialCacheModelPrivate::updateRange(
- int index, int count, const SocialCacheModelData &source, int sourceIndex)
-{
- Q_Q(AbstractSocialCacheModel);
-
- for (int i = 0; i < count; ++i) {
- m_data[index + i] = source[sourceIndex + i];
- }
-
- emit q->dataChanged(q->createIndex(index, 0), q->createIndex(index + count - 1, 0));
-}
-
-AbstractSocialCacheModel::AbstractSocialCacheModel(AbstractSocialCacheModelPrivate &dd,
- QObject *parent)
- : QAbstractListModel(parent), d_ptr(&dd)
-{
-}
-
-AbstractSocialCacheModel::~AbstractSocialCacheModel()
-{
-}
-
-int AbstractSocialCacheModel::rowCount(const QModelIndex &parent) const
-{
- Q_UNUSED(parent)
- Q_D(const AbstractSocialCacheModel);
- return d->m_data.count();
-}
-
-QVariant AbstractSocialCacheModel::data(const QModelIndex &index, int role) const
-{
- int row = index.row();
- return getField(row, role);
-}
-
-QVariant AbstractSocialCacheModel::getField(int row, int role) const
-{
- Q_D(const AbstractSocialCacheModel);
- if (row < 0 || row >= d->m_data.count()) {
- return QVariant();
- }
-
- return d->m_data.at(row).value(role);
-}
-
-QString AbstractSocialCacheModel::nodeIdentifier() const
-{
- Q_D(const AbstractSocialCacheModel);
- return d->nodeIdentifier;
-}
-
-void AbstractSocialCacheModel::setNodeIdentifier(const QString &nodeIdentifier)
-{
- Q_D(AbstractSocialCacheModel);
- if (d->nodeIdentifier != nodeIdentifier) {
- d->nodeIdentifier = nodeIdentifier;
- emit nodeIdentifierChanged();
- d->nodeIdentifierChanged();
- }
-}
-
-int AbstractSocialCacheModel::count() const
-{
- return rowCount();
-}
-
-void AbstractSocialCacheModel::updateData(const SocialCacheModelData &data)
-{
- Q_D(AbstractSocialCacheModel);
-
- const int count = d->m_data.count();
- synchronizeList(d, d->m_data, data);
-
- if (d->m_data.count() != count) {
- emit countChanged();
- }
- emit modelUpdated();
-}
-
-void AbstractSocialCacheModel::updateRow(int row, const SocialCacheModelRow &data)
-{
- Q_D(AbstractSocialCacheModel);
- foreach (int key, data.keys()) {
- d->m_data[row].insert(key, data.value(key));
- }
- emit dataChanged(index(row), index(row));
-}
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel.h b/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel.h
deleted file mode 100644
index c3c3ffe..0000000
--- a/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2013-2026 Jolla Ltd.
- * Contact: Lucien Xu <lucien.xu@jollamobile.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef ABSTRACTSOCIALCACHEMODEL_H
-#define ABSTRACTSOCIALCACHEMODEL_H
-
-#include <QtCore/QAbstractListModel>
-
-typedef QMap<int, QVariant> SocialCacheModelRow;
-typedef QList<SocialCacheModelRow> SocialCacheModelData;
-
-class AbstractSocialCacheModelPrivate;
-
-class AbstractSocialCacheModel : public QAbstractListModel
-{
- Q_OBJECT
- Q_PROPERTY(QString nodeIdentifier READ nodeIdentifier WRITE setNodeIdentifier NOTIFY nodeIdentifierChanged)
- Q_PROPERTY(int count READ count NOTIFY countChanged)
-
-public:
- virtual ~AbstractSocialCacheModel();
-
- int rowCount(const QModelIndex &parent = QModelIndex()) const;
- QVariant data(const QModelIndex &index, int role) const;
- Q_INVOKABLE QVariant getField(int row, int role) const;
-
- // properties
- QString nodeIdentifier() const;
- void setNodeIdentifier(const QString &nodeIdentifier);
- int count() const;
-
-
-public Q_SLOTS:
- virtual void refresh() = 0;
-
-Q_SIGNALS:
- void nodeIdentifierChanged();
- void countChanged();
- void modelUpdated();
-
-protected:
- // Methods used to update the model in the C++ side
- void updateData(const SocialCacheModelData &data);
- void updateRow(int row, const SocialCacheModelRow &data);
-
- explicit AbstractSocialCacheModel(AbstractSocialCacheModelPrivate &dd, QObject *parent = 0);
- QScopedPointer<AbstractSocialCacheModelPrivate> d_ptr;
-
-private:
- Q_DECLARE_PRIVATE(AbstractSocialCacheModel)
-};
-
-Q_DECLARE_METATYPE(SocialCacheModelRow)
-Q_DECLARE_METATYPE(SocialCacheModelData)
-
-#endif // ABSTRACTSOCIALCACHEMODEL_H
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel_p.h b/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel_p.h
deleted file mode 100644
index fa62ac5..0000000
--- a/eventsview-plugins/eventsview-plugin-mastodon/abstractsocialcachemodel_p.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2013-2026 Jolla Ltd.
- * Contact: Lucien Xu <lucien.xu@jollamobile.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef ABSTRACTSOCIALCACHEMODEL_P_H
-#define ABSTRACTSOCIALCACHEMODEL_P_H
-
-#include "abstractsocialcachemodel.h"
-
-#include <QtCore/QMap>
-
-class AbstractSocialCacheModelPrivate
-{
-public:
- virtual ~AbstractSocialCacheModelPrivate();
- QString nodeIdentifier;
-
- void insertRange(int index, int count, const SocialCacheModelData &source, int sourceIndex);
- void updateRange(int index, int count, const SocialCacheModelData &source, int sourceIndex);
- void removeRange(int index, int count);
-
- void clearData();
- void updateData(const SocialCacheModelData &data);
- void updateRow(int row, const SocialCacheModelRow &data);
-
- QList<QMap<int, QVariant> > m_data;
-
-protected:
- explicit AbstractSocialCacheModelPrivate(AbstractSocialCacheModel *q);
-
- virtual void nodeIdentifierChanged() {}
-
- AbstractSocialCacheModel * const q_ptr;
-private:
- Q_DECLARE_PUBLIC(AbstractSocialCacheModel)
-};
-
-#endif // ABSTRACTSOCIALCACHEMODEL_P_H
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/eventsview-plugin-mastodon.pro b/eventsview-plugins/eventsview-plugin-mastodon/eventsview-plugin-mastodon.pro
index 109478e..4699324 100644
--- a/eventsview-plugins/eventsview-plugin-mastodon/eventsview-plugin-mastodon.pro
+++ b/eventsview-plugins/eventsview-plugin-mastodon/eventsview-plugin-mastodon.pro
@@ -40,13 +40,10 @@ PRE_TARGETDEPS += ts engineering_english
INSTALLS += ts_install engineering_english_install
HEADERS += \
- abstractsocialcachemodel.h \
- abstractsocialcachemodel_p.h \
mastodonpostactions.h \
mastodonpostsmodel.h
SOURCES += \
- abstractsocialcachemodel.cpp \
mastodonpostactions.cpp \
mastodonpostsmodel.cpp \
plugin.cpp
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.cpp b/eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.cpp
index 855d9be..aa98a95 100644
--- a/eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.cpp
+++ b/eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.cpp
@@ -17,37 +17,57 @@
*/
#include "mastodonpostsmodel.h"
-#include "abstractsocialcachemodel_p.h"
-#include "mastodonpostsdatabase.h"
-#include "postimagehelper_p.h"
+#include <QtCore/QVariantMap>
-class MastodonPostsModelPrivate: public AbstractSocialCacheModelPrivate
-{
-public:
- explicit MastodonPostsModelPrivate(MastodonPostsModel *q);
-
- MastodonPostsDatabase database;
+namespace {
-private:
- Q_DECLARE_PUBLIC(MastodonPostsModel)
-};
+static const char *URL_KEY = "url";
+static const char *TYPE_KEY = "type";
+static const char *TYPE_PHOTO = "photo";
+static const char *TYPE_VIDEO = "video";
-MastodonPostsModelPrivate::MastodonPostsModelPrivate(MastodonPostsModel *q)
- : AbstractSocialCacheModelPrivate(q)
+QVariantMap createImageData(const SocialPostImage::ConstPtr &image)
{
+ QVariantMap imageData;
+ imageData.insert(QLatin1String(URL_KEY), image->url());
+ switch (image->type()) {
+ case SocialPostImage::Video:
+ imageData.insert(QLatin1String(TYPE_KEY), QLatin1String(TYPE_VIDEO));
+ break;
+ default:
+ imageData.insert(QLatin1String(TYPE_KEY), QLatin1String(TYPE_PHOTO));
+ break;
+ }
+ return imageData;
+}
+
}
MastodonPostsModel::MastodonPostsModel(QObject *parent)
- : AbstractSocialCacheModel(*(new MastodonPostsModelPrivate(this)), parent)
+ : QAbstractListModel(parent)
{
- Q_D(MastodonPostsModel);
-
- connect(&d->database, &AbstractSocialPostCacheDatabase::postsChanged,
+ connect(&m_database, &AbstractSocialPostCacheDatabase::postsChanged,
this, &MastodonPostsModel::postsChanged);
- connect(&d->database, SIGNAL(accountIdFilterChanged()),
+ connect(&m_database, SIGNAL(accountIdFilterChanged()),
this, SIGNAL(accountIdFilterChanged()));
}
+int MastodonPostsModel::rowCount(const QModelIndex &parent) const
+{
+ Q_UNUSED(parent)
+ return m_data.count();
+}
+
+QVariant MastodonPostsModel::data(const QModelIndex &index, int role) const
+{
+ const int row = index.row();
+ if (!index.isValid() || row < 0 || row >= m_data.count()) {
+ return QVariant();
+ }
+
+ return m_data.at(row).value(role);
+}
+
QHash<int, QByteArray> MastodonPostsModel::roleNames() const
{
QHash<int, QByteArray> roleNames;
@@ -75,41 +95,33 @@ QHash<int, QByteArray> MastodonPostsModel::roleNames() const
QVariantList MastodonPostsModel::accountIdFilter() const
{
- Q_D(const MastodonPostsModel);
-
- return d->database.accountIdFilter();
+ return m_database.accountIdFilter();
}
void MastodonPostsModel::setAccountIdFilter(const QVariantList &accountIds)
{
- Q_D(MastodonPostsModel);
-
- d->database.setAccountIdFilter(accountIds);
+ m_database.setAccountIdFilter(accountIds);
}
void MastodonPostsModel::refresh()
{
- Q_D(MastodonPostsModel);
-
- d->database.refresh();
+ m_database.refresh();
}
void MastodonPostsModel::postsChanged()
{
- Q_D(MastodonPostsModel);
-
- SocialCacheModelData data;
- QList<SocialPost::ConstPtr> postsData = d->database.posts();
+ QList<RowData> data;
+ QList<SocialPost::ConstPtr> postsData = m_database.posts();
Q_FOREACH (const SocialPost::ConstPtr &post, postsData) {
- QMap<int, QVariant> eventMap;
- const QString accountName = d->database.accountName(post);
- const QString postUrl = d->database.url(post);
- const QString boostedBy = d->database.boostedBy(post);
- const int repliesCount = d->database.repliesCount(post);
- const int favouritesCount = d->database.favouritesCount(post);
- const int reblogsCount = d->database.reblogsCount(post);
- const bool favourited = d->database.favourited(post);
- const bool reblogged = d->database.reblogged(post);
+ RowData eventMap;
+ const QString accountName = m_database.accountName(post);
+ const QString postUrl = m_database.url(post);
+ const QString boostedBy = m_database.boostedBy(post);
+ const int repliesCount = m_database.repliesCount(post);
+ const int favouritesCount = m_database.favouritesCount(post);
+ const int reblogsCount = m_database.reblogsCount(post);
+ const bool favourited = m_database.favourited(post);
+ const bool reblogged = m_database.reblogged(post);
eventMap.insert(MastodonPostsModel::MastodonId, post->identifier());
eventMap.insert(MastodonPostsModel::Name, post->name());
@@ -127,7 +139,7 @@ void MastodonPostsModel::postsChanged()
eventMap.insert(MastodonPostsModel::ReblogsCount, reblogsCount);
eventMap.insert(MastodonPostsModel::Favourited, favourited);
eventMap.insert(MastodonPostsModel::Reblogged, reblogged);
- eventMap.insert(MastodonPostsModel::InstanceUrl, d->database.instanceUrl(post));
+ eventMap.insert(MastodonPostsModel::InstanceUrl, m_database.instanceUrl(post));
QVariantList images;
Q_FOREACH (const SocialPostImage::ConstPtr &image, post->images()) {
@@ -143,5 +155,11 @@ void MastodonPostsModel::postsChanged()
data.append(eventMap);
}
- updateData(data);
+ const int oldCount = m_data.count();
+ beginResetModel();
+ m_data = data;
+ endResetModel();
+ if (oldCount != m_data.count()) {
+ emit countChanged();
+ }
}
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.h b/eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.h
index 565b2bb..e30437d 100644
--- a/eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.h
+++ b/eventsview-plugins/eventsview-plugin-mastodon/mastodonpostsmodel.h
@@ -19,14 +19,15 @@
#ifndef MASTODONPOSTSMODEL_H
#define MASTODONPOSTSMODEL_H
-#include "abstractsocialcachemodel.h"
+#include "mastodonpostsdatabase.h"
+#include <QtCore/QAbstractListModel>
+#include <QtCore/QMap>
-class MastodonPostsModelPrivate;
-
-class MastodonPostsModel: public AbstractSocialCacheModel
+class MastodonPostsModel: public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QVariantList accountIdFilter READ accountIdFilter WRITE setAccountIdFilter NOTIFY accountIdFilterChanged)
+ Q_PROPERTY(int count READ rowCount NOTIFY countChanged)
public:
enum MastodonPostsRole {
@@ -52,21 +53,27 @@ public:
};
explicit MastodonPostsModel(QObject *parent = 0);
- QHash<int, QByteArray> roleNames() const;
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const override;
+ QVariant data(const QModelIndex &index, int role) const override;
+ QHash<int, QByteArray> roleNames() const override;
QVariantList accountIdFilter() const;
void setAccountIdFilter(const QVariantList &accountIds);
- void refresh();
+ Q_INVOKABLE void refresh();
signals:
void accountIdFilterChanged();
+ void countChanged();
private slots:
void postsChanged();
private:
- Q_DECLARE_PRIVATE(MastodonPostsModel)
+ typedef QMap<int, QVariant> RowData;
+ QList<RowData> m_data;
+ MastodonPostsDatabase m_database;
};
#endif // MASTODONPOSTSMODEL_H
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/postimagehelper_p.h b/eventsview-plugins/eventsview-plugin-mastodon/postimagehelper_p.h
deleted file mode 100644
index 0d70ffa..0000000
--- a/eventsview-plugins/eventsview-plugin-mastodon/postimagehelper_p.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2013-2026 Jolla Ltd.
- * Contact: Lucien Xu <lucien.xu@jollamobile.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef POSTIMAGEHELPER_P_H
-#define POSTIMAGEHELPER_P_H
-
-#include <QtCore/QVariantMap>
-
-static const char *URL_KEY = "url";
-static const char *TYPE_KEY = "type";
-static const char *TYPE_PHOTO = "photo";
-static const char *TYPE_VIDEO = "video";
-
-inline static QVariantMap createImageData(const SocialPostImage::ConstPtr &image)
-{
- QVariantMap imageData;
- imageData.insert(QLatin1String(URL_KEY), image->url());
- switch (image->type()) {
- case SocialPostImage::Video:
- imageData.insert(QLatin1String(TYPE_KEY), QLatin1String(TYPE_VIDEO));
- break;
- default:
- imageData.insert(QLatin1String(TYPE_KEY), QLatin1String(TYPE_PHOTO));
- break;
- }
- return imageData;
-}
-
-#endif // POSTIMAGEHELPER_P_H
diff --git a/eventsview-plugins/eventsview-plugin-mastodon/synchronizelists_p.h b/eventsview-plugins/eventsview-plugin-mastodon/synchronizelists_p.h
deleted file mode 100644
index 78d5863..0000000
--- a/eventsview-plugins/eventsview-plugin-mastodon/synchronizelists_p.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2013-2026 Jolla Ltd.
- *
- * You may use this file under the terms of the BSD license as follows:
- *
- * "Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Nemo Mobile nor the names of its contributors
- * may be used to endorse or promote products derived from this
- * software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
- */
-
-#ifndef SYNCHRONIZELISTS_P_H
-#define SYNCHRONIZELISTS_P_H
-
-template <typename T>
-bool compareIdentity(const T &item, const T &reference)
-{
- return item == reference;
-}
-
-template <typename Agent, typename ReferenceList>
-int insertRange(Agent *agent, int index, int count, const ReferenceList &source, int sourceIndex)
-{
- agent->insertRange(index, count, source, sourceIndex);
- return count;
-}
-
-template <typename Agent>
-int removeRange(Agent *agent, int index, int count)
-{
- agent->removeRange(index, count);
- return 0;
-}
-
-template <typename Agent, typename ReferenceList>
-int updateRange(Agent *agent, int index, int count, const ReferenceList &source, int sourceIndex)
-{
- Q_UNUSED(agent);
- Q_UNUSED(index);
- Q_UNUSED(source);
- Q_UNUSED(sourceIndex);
- return count;
-}
-
-template <typename Agent, typename CacheList, typename ReferenceList>
-class SynchronizeList
-{
-public:
- SynchronizeList(
- Agent *agent,
- const CacheList &cache,
- int &c,
- const ReferenceList &reference,
- int &r)
- : agent(agent), cache(cache), c(c), reference(reference), r(r)
- {
- int lastEqualC = c;
- int lastEqualR = r;
- for (; c < cache.count() && r < reference.count(); ++c, ++r) {
- if (compareIdentity(cache.at(c), reference.at(r))) {
- continue;
- }
-
- if (c > lastEqualC) {
- lastEqualC += updateRange(agent, lastEqualC, c - lastEqualC, reference, lastEqualR);
- c = lastEqualC;
- lastEqualR = r;
- }
-
- bool match = false;
-
- // Iterate through both the reference and cache lists in parallel looking for first
- // point of commonality, when that is found resolve the differences and continue
- // looking.
- int count = 1;
- for (; !match && c + count < cache.count() && r + count < reference.count(); ++count) {
- typename CacheList::const_reference cacheItem = cache.at(c + count);
- typename ReferenceList::const_reference referenceItem = reference.at(r + count);
-
- for (int i = 0; i <= count; ++i) {
- if (cacheMatch(i, count, referenceItem) || referenceMatch(i, count, cacheItem)) {
- match = true;
- break;
- }
- }
- }
-
- // Continue scanning the reference list if the cache has been exhausted.
- for (int re = r + count; !match && re < reference.count(); ++re) {
- typename ReferenceList::const_reference referenceItem = reference.at(re);
- for (int i = 0; i < count; ++i) {
- if (cacheMatch(i, re - r, referenceItem)) {
- match = true;
- break;
- }
- }
- }
-
- // Continue scanning the cache if the reference list has been exhausted.
- for (int ce = c + count; !match && ce < cache.count(); ++ce) {
- typename CacheList::const_reference cacheItem = cache.at(ce);
- for (int i = 0; i < count; ++i) {
- if (referenceMatch(i, ce - c, cacheItem)) {
- match = true;
- break;
- }
- }
- }
-
- if (!match)
- return;
-
- lastEqualC = c;
- lastEqualR = r;
- }
-
- if (c > lastEqualC) {
- updateRange(agent, lastEqualC, c - lastEqualC, reference, lastEqualR);
- }
- }
-
-private:
- // Tests if the cached contact id at i matches a referenceId.
- // If there is a match removes all items traversed in the cache since the previous match
- // and inserts any items in the reference set found to to not be in the cache.
- bool cacheMatch(int i, int count, typename ReferenceList::const_reference referenceItem)
- {
- if (compareIdentity(cache.at(c + i), referenceItem)) {
- if (i > 0)
- c += removeRange(agent, c, i);
- c += insertRange(agent, c, count, reference, r);
- r += count;
- return true;
- } else {
- return false;
- }
- }
-
- // Tests if the reference contact id at i matches a cacheId.
- // If there is a match inserts all items traversed in the reference set since the
- // previous match and removes any items from the cache that were not found in the
- // reference list.
- bool referenceMatch(int i, int count, typename ReferenceList::const_reference cacheItem)
- {
- if (compareIdentity(reference.at(r + i), cacheItem)) {
- c += removeRange(agent, c, count);
- if (i > 0)
- c += insertRange(agent, c, i, reference, r);
- r += i;
- return true;
- } else {
- return false;
- }
- }
-
- Agent * const agent;
- const CacheList &cache;
- int &c;
- const ReferenceList &reference;
- int &r;
-};
-
-template <typename Agent, typename CacheList, typename ReferenceList>
-void completeSynchronizeList(
- Agent *agent,
- const CacheList &cache,
- int &cacheIndex,
- const ReferenceList &reference,
- int &referenceIndex)
-{
- if (cacheIndex < cache.count()) {
- agent->removeRange(cacheIndex, cache.count() - cacheIndex);
- }
- if (referenceIndex < reference.count()) {
- agent->insertRange(cache.count(), reference.count() - referenceIndex, reference, referenceIndex);
- }
-
- cacheIndex = 0;
- referenceIndex = 0;
-}
-
-template <typename Agent, typename CacheList, typename ReferenceList>
-void synchronizeList(
- Agent *agent,
- const CacheList &cache,
- int &cacheIndex,
- const ReferenceList &reference,
- int &referenceIndex)
-{
- SynchronizeList<Agent, CacheList, ReferenceList>(
- agent, cache, cacheIndex, reference, referenceIndex);
-}
-
-template <typename Agent, typename CacheList, typename ReferenceList>
-void synchronizeList(Agent *agent, const CacheList &cache, const ReferenceList &reference)
-{
- int cacheIndex = 0;
- int referenceIndex = 0;
- SynchronizeList<Agent, CacheList, ReferenceList>(
- agent, cache, cacheIndex, reference, referenceIndex);
- completeSynchronizeList(agent, cache, cacheIndex, reference, referenceIndex);
-}
-
-#endif
diff --git a/rpm/sailfish-account-mastodon.spec b/rpm/sailfish-account-mastodon.spec
index fc18d9f..389b6a9 100644
--- a/rpm/sailfish-account-mastodon.spec
+++ b/rpm/sailfish-account-mastodon.spec
@@ -1,8 +1,8 @@
# Copyright (C) 2013-2026 Jolla Ltd.
Name: sailfish-account-mastodon
-License: LGPLv2+
-Version: 0.1.0
+License: LGPLv3
+Version: 1.0.0
Release: 1
Source0: %{name}-%{version}.tar.bz2
Summary: SailfishOS account plugin for Mastodon