aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.h10
-rw-r--r--lib/eventitem.h2
-rw-r--r--lib/events/eventcontent.h2
-rw-r--r--lib/events/simplestateevents.h1
-rw-r--r--lib/networksettings.cpp6
-rw-r--r--lib/networksettings.h6
-rw-r--r--lib/room.cpp25
-rw-r--r--lib/room.h7
-rw-r--r--lib/settings.cpp6
-rw-r--r--lib/settings.h10
10 files changed, 54 insertions, 21 deletions
diff --git a/lib/connection.h b/lib/connection.h
index d669462e..23062664 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -51,11 +51,11 @@ class LeaveRoomJob;
using LoginFlow = GetLoginFlowsJob::LoginFlow;
/// Predefined login flows
-struct LoginFlows {
- static inline const LoginFlow Password { "m.login.password" };
- static inline const LoginFlow SSO { "m.login.sso" };
- static inline const LoginFlow Token { "m.login.token" };
-};
+namespace LoginFlows {
+ inline const LoginFlow Password { "m.login.password" };
+ inline const LoginFlow SSO { "m.login.sso" };
+ inline const LoginFlow Token { "m.login.token" };
+}
// To simplify comparisons of LoginFlows
diff --git a/lib/eventitem.h b/lib/eventitem.h
index 2f1e72cc..f04ef323 100644
--- a/lib/eventitem.h
+++ b/lib/eventitem.h
@@ -58,7 +58,7 @@ public:
}
/// Store arbitrary data with the event item
- void setUserData(std::any userData) { data = userData; }
+ void setUserData(std::any userData) { data = std::move(userData); }
/// Obtain custom data previously stored with the event item
const std::any& userdata() const { return data; }
std::any& userData() { return data; }
diff --git a/lib/events/eventcontent.h b/lib/events/eventcontent.h
index bfa7d926..87ea3672 100644
--- a/lib/events/eventcontent.h
+++ b/lib/events/eventcontent.h
@@ -106,7 +106,7 @@ namespace EventContent {
QJsonObject originalInfoJson;
QMimeType mimeType;
QUrl url;
- qint64 payloadSize;
+ qint64 payloadSize = 0;
QString originalName;
Omittable<EncryptedFile> file = none;
};
diff --git a/lib/events/simplestateevents.h b/lib/events/simplestateevents.h
index d6557012..e6c05880 100644
--- a/lib/events/simplestateevents.h
+++ b/lib/events/simplestateevents.h
@@ -52,6 +52,7 @@ namespace EventContent {
DEFINE_SIMPLE_STATE_EVENT(RoomNameEvent, "m.room.name", QString, name)
DEFINE_SIMPLE_STATE_EVENT(RoomTopicEvent, "m.room.topic", QString, topic)
+DEFINE_SIMPLE_STATE_EVENT(RoomPinnedEvent, "m.room.pinned_messages", QStringList, pinnedEvents)
class [[deprecated(
"m.room.aliases events are deprecated by the Matrix spec; use"
diff --git a/lib/networksettings.cpp b/lib/networksettings.cpp
index ce46ce5f..06b1fdf9 100644
--- a/lib/networksettings.cpp
+++ b/lib/networksettings.cpp
@@ -11,9 +11,9 @@ void NetworkSettings::setupApplicationProxy() const
{ proxyType(), proxyHostName(), proxyPort() });
}
-QTNT_DEFINE_SETTING(NetworkSettings, QNetworkProxy::ProxyType, proxyType,
+QUO_DEFINE_SETTING(NetworkSettings, QNetworkProxy::ProxyType, proxyType,
"proxy_type", QNetworkProxy::DefaultProxy, setProxyType)
-QTNT_DEFINE_SETTING(NetworkSettings, QString, proxyHostName, "proxy_hostname",
+QUO_DEFINE_SETTING(NetworkSettings, QString, proxyHostName, "proxy_hostname",
{}, setProxyHostName)
-QTNT_DEFINE_SETTING(NetworkSettings, quint16, proxyPort, "proxy_port", -1,
+QUO_DEFINE_SETTING(NetworkSettings, quint16, proxyPort, "proxy_port", -1,
setProxyPort)
diff --git a/lib/networksettings.h b/lib/networksettings.h
index c1446355..44247e59 100644
--- a/lib/networksettings.h
+++ b/lib/networksettings.h
@@ -12,9 +12,9 @@ Q_DECLARE_METATYPE(QNetworkProxy::ProxyType)
namespace Quotient {
class QUOTIENT_API NetworkSettings : public SettingsGroup {
Q_OBJECT
- QTNT_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType)
- QTNT_DECLARE_SETTING(QString, proxyHostName, setProxyHostName)
- QTNT_DECLARE_SETTING(quint16, proxyPort, setProxyPort)
+ QUO_DECLARE_SETTING(QNetworkProxy::ProxyType, proxyType, setProxyType)
+ QUO_DECLARE_SETTING(QString, proxyHostName, setProxyHostName)
+ QUO_DECLARE_SETTING(quint16, proxyPort, setProxyPort)
Q_PROPERTY(QString proxyHost READ proxyHostName WRITE setProxyHostName)
public:
template <typename... ArgTs>
diff --git a/lib/room.cpp b/lib/room.cpp
index b3438e08..edf5dcd9 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -558,6 +558,23 @@ QString Room::canonicalAlias() const
QString Room::displayName() const { return d->displayname; }
+QStringList Room::pinnedEventIds() const {
+ return d->getCurrentState<RoomPinnedEvent>()->pinnedEvents();
+}
+
+QVector< const Quotient::RoomEvent* > Quotient::Room::pinnedEvents() const
+{
+ QStringList events = d->getCurrentState<RoomPinnedEvent>()->pinnedEvents();
+ QVector<const RoomEvent*> pinnedEvents;
+ QStringList::iterator i;
+ for (i = events.begin(); i != events.end(); ++i) {
+ auto timelineItem = findInTimeline(*i);
+ if (timelineItem != historyEdge())
+ pinnedEvents.append(timelineItem->event());
+ }
+ return pinnedEvents;
+}
+
QString Room::displayNameForHtml() const
{
return displayName().toHtmlEscaped();
@@ -2133,6 +2150,10 @@ void Room::setCanonicalAlias(const QString& newAlias)
d->requestSetState<RoomCanonicalAliasEvent>(newAlias, altAliases());
}
+void Room::setPinnedEvents(const QStringList& events)
+{
+ d->requestSetState<RoomPinnedEvent>(events);
+}
void Room::setLocalAliases(const QStringList& aliases)
{
d->requestSetState<RoomCanonicalAliasEvent>(canonicalAlias(), aliases);
@@ -2902,6 +2923,10 @@ Room::Changes Room::processStateEvent(const RoomEvent& e)
return Change::Aliases;
// clang-format off
}
+ , [this] (const RoomPinnedEvent&) {
+ emit pinnedEventsChanged();
+ return Change::Other;
+ }
, [] (const RoomTopicEvent&) {
return Change::Topic;
}
diff --git a/lib/room.h b/lib/room.h
index 63a4aaea..e1e4fb91 100644
--- a/lib/room.h
+++ b/lib/room.h
@@ -124,6 +124,8 @@ class QUOTIENT_API Room : public QObject {
Q_PROPERTY(QStringList altAliases READ altAliases NOTIFY namesChanged)
Q_PROPERTY(QString canonicalAlias READ canonicalAlias NOTIFY namesChanged)
Q_PROPERTY(QString displayName READ displayName NOTIFY displaynameChanged)
+ Q_PROPERTY(QStringList pinnedEventIds READ pinnedEventIds WRITE setPinnedEvents
+ NOTIFY pinnedEventsChanged)
Q_PROPERTY(QString displayNameForHtml READ displayNameForHtml NOTIFY displaynameChanged)
Q_PROPERTY(QString topic READ topic NOTIFY topicChanged)
Q_PROPERTY(QString avatarMediaId READ avatarMediaId NOTIFY avatarChanged
@@ -253,6 +255,9 @@ public:
//! Get a list of both canonical and alternative aliases
QStringList aliases() const;
QString displayName() const;
+ QStringList pinnedEventIds() const;
+ // Returns events available locally, use pinnedEventIds() for full list
+ QVector<const RoomEvent*> pinnedEvents() const;
QString displayNameForHtml() const;
QString topic() const;
QString avatarMediaId() const;
@@ -832,6 +837,7 @@ public Q_SLOTS:
SetRoomStateWithKeyJob* setState(const StateEventBase& evt) const;
void setName(const QString& newName);
void setCanonicalAlias(const QString& newAlias);
+ void setPinnedEvents(const QStringList& events);
/// Set room aliases on the user's current server
void setLocalAliases(const QStringList& aliases);
void setTopic(const QString& newTopic);
@@ -938,6 +944,7 @@ Q_SIGNALS:
void namesChanged(Quotient::Room* room);
void displaynameAboutToChange(Quotient::Room* room);
void displaynameChanged(Quotient::Room* room, QString oldName);
+ void pinnedEventsChanged();
void topicChanged();
void avatarChanged();
void userAdded(Quotient::User* user);
diff --git a/lib/settings.cpp b/lib/settings.cpp
index ed9082b0..5549e4de 100644
--- a/lib/settings.cpp
+++ b/lib/settings.cpp
@@ -102,11 +102,11 @@ void SettingsGroup::remove(const QString& key)
Settings::remove(fullKey);
}
-QTNT_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {},
+QUO_DEFINE_SETTING(AccountSettings, QString, deviceId, "device_id", {},
setDeviceId)
-QTNT_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {},
+QUO_DEFINE_SETTING(AccountSettings, QString, deviceName, "device_name", {},
setDeviceName)
-QTNT_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false,
+QUO_DEFINE_SETTING(AccountSettings, bool, keepLoggedIn, "keep_logged_in", false,
setKeepLoggedIn)
static const auto HomeserverKey = QStringLiteral("homeserver");
diff --git a/lib/settings.h b/lib/settings.h
index b66879c5..ff99d488 100644
--- a/lib/settings.h
+++ b/lib/settings.h
@@ -106,7 +106,7 @@ private:
QString groupPath;
};
-#define QTNT_DECLARE_SETTING(type, propname, setter) \
+#define QUO_DECLARE_SETTING(type, propname, setter) \
Q_PROPERTY(type propname READ propname WRITE setter) \
public: \
type propname() const; \
@@ -114,7 +114,7 @@ public: \
\
private:
-#define QTNT_DEFINE_SETTING(classname, type, propname, qsettingname, \
+#define QUO_DEFINE_SETTING(classname, type, propname, qsettingname, \
defaultValue, setter) \
type classname::propname() const \
{ \
@@ -129,9 +129,9 @@ private:
class QUOTIENT_API AccountSettings : public SettingsGroup {
Q_OBJECT
Q_PROPERTY(QString userId READ userId CONSTANT)
- QTNT_DECLARE_SETTING(QString, deviceId, setDeviceId)
- QTNT_DECLARE_SETTING(QString, deviceName, setDeviceName)
- QTNT_DECLARE_SETTING(bool, keepLoggedIn, setKeepLoggedIn)
+ QUO_DECLARE_SETTING(QString, deviceId, setDeviceId)
+ QUO_DECLARE_SETTING(QString, deviceName, setDeviceName)
+ QUO_DECLARE_SETTING(bool, keepLoggedIn, setKeepLoggedIn)
Q_PROPERTY(QByteArray encryptionAccountPickle READ encryptionAccountPickle
WRITE setEncryptionAccountPickle)
public: