aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--connection.cpp8
-rw-r--r--events/event.h8
-rw-r--r--events/roommessageevent.cpp2
-rw-r--r--events/roommessageevent.h4
-rw-r--r--jobs/syncjob.h2
-rw-r--r--room.cpp22
-rw-r--r--room.h9
7 files changed, 35 insertions, 20 deletions
diff --git a/connection.cpp b/connection.cpp
index cbc0f4a0..d6338191 100644
--- a/connection.cpp
+++ b/connection.cpp
@@ -116,8 +116,12 @@ SyncJob* Connection::sync(int timeout)
d->processRooms(syncJob->roomData());
emit syncDone();
});
- connect( syncJob, &SyncJob::failure,
- [=] () { emit connectionError(syncJob->errorString());});
+ connect( syncJob, &SyncJob::failure, [=] () {
+ if (syncJob->error() == BaseJob::ContentAccessError)
+ emit loginError(syncJob->errorString());
+ else
+ emit connectionError(syncJob->errorString());
+ });
syncJob->start();
return syncJob;
}
diff --git a/events/event.h b/events/event.h
index a009aa99..72d26208 100644
--- a/events/event.h
+++ b/events/event.h
@@ -65,12 +65,12 @@ namespace QMatrixClient
* @return an iterator to an item with the earliest timestamp after
* the one of 'item'; or timeline.end(), if all events are earlier
*/
- template <class ItemT, template <typename> class ContT>
- typename ContT<ItemT *>::iterator
- findInsertionPos(ContT<ItemT *> & timeline, const ItemT *item)
+ template <class ItemT, class ContT>
+ typename ContT::iterator
+ findInsertionPos(ContT & timeline, const ItemT *item)
{
return std::lower_bound (timeline.begin(), timeline.end(), item,
- [](const ItemT * a, const ItemT * b) {
+ [](const typename ContT::value_type a, const ItemT * b) {
return a->timestamp() < b->timestamp();
}
);
diff --git a/events/roommessageevent.cpp b/events/roommessageevent.cpp
index b7459054..48f52453 100644
--- a/events/roommessageevent.cpp
+++ b/events/roommessageevent.cpp
@@ -171,7 +171,7 @@ RoomMessageEvent* RoomMessageEvent::fromJson(const QJsonObject& obj)
{
qDebug() << "RoomMessageEvent: unknown msgtype: " << msgtype;
qDebug() << obj;
- e->d->msgtype = MessageEventType::Unkown;
+ e->d->msgtype = MessageEventType::Unknown;
e->d->content = new MessageEventContent;
}
diff --git a/events/roommessageevent.h b/events/roommessageevent.h
index 939113d1..b0d5a1cb 100644
--- a/events/roommessageevent.h
+++ b/events/roommessageevent.h
@@ -27,7 +27,7 @@ namespace QMatrixClient
{
enum class MessageEventType
{
- Text, Emote, Notice, Image, File, Location, Video, Audio, Unkown
+ Text, Emote, Notice, Image, File, Location, Video, Audio, Unknown
};
class MessageEventContent
@@ -115,4 +115,4 @@ namespace QMatrixClient
}
-#endif // QMATRIXCLIENT_ROOMMESSAGEEVENT_H \ No newline at end of file
+#endif // QMATRIXCLIENT_ROOMMESSAGEEVENT_H
diff --git a/jobs/syncjob.h b/jobs/syncjob.h
index 51d07944..6e6b4f7c 100644
--- a/jobs/syncjob.h
+++ b/jobs/syncjob.h
@@ -81,4 +81,4 @@ namespace QMatrixClient
};
}
-#endif // QMATRIXCLIENT_GETEVENTSJOB_H
+#endif // QMATRIXCLIENT_SYNCJOB_H
diff --git a/room.cpp b/room.cpp
index 772d9f58..1513cbeb 100644
--- a/room.cpp
+++ b/room.cpp
@@ -53,8 +53,9 @@ class Room::Private
//static LogMessage* parseMessage(const QJsonObject& message);
- // This updates the room displayname field (which is the way a room should be shown in the room list)
- // It should be called whenever the list of members or the room name (m.room.name) or canonical alias change.
+ // This updates the room displayname field (which is the way a room
+ // should be shown in the room list) It should be called whenever the
+ // list of members or the room name (m.room.name) or canonical alias change.
void updateDisplayname();
Connection* connection;
@@ -75,9 +76,9 @@ class Room::Private
QString prevBatch;
RoomMessagesJob* roomMessagesJob;
- // Convenience methods to work with the membersMap and usersLeft. addMember()
- // and removeMember() emit respective Room:: signals after a succesful
- // operation.
+ // Convenience methods to work with the membersMap and usersLeft.
+ // addMember() and removeMember() emit respective Room:: signals
+ // after a succesful operation.
//void inviteUser(User* u); // We might get it at some point in time.
void addMember(User* u);
bool hasMember(User* u) const;
@@ -110,7 +111,7 @@ Room::Room(Connection* connection, QString id)
Room::~Room()
{
- qDebug() << "deconstructing room" << this;
+ qDebug() << "deconstructing room" << id();
delete d;
}
@@ -324,6 +325,11 @@ QString Room::roomMembername(User *u) const
return username % " <" % u->id() % ">";
}
+QString Room::roomMembername(QString userId) const
+{
+ return roomMembername(connection()->user(userId));
+}
+
void Room::addMessage(Event* event)
{
processMessageEvent(event);
@@ -398,7 +404,7 @@ void Room::Private::getPreviousContent()
}
}
-Connection* Room::connection()
+Connection* Room::connection() const
{
return d->connection;
}
@@ -497,7 +503,7 @@ QString Room::Private::roomNameFromMemberNames(const QList<User *> &userlist) co
// the current one to render the name of the room.
// std::array is the leanest C++ container
- std::array<User*, 2> first_two { nullptr, nullptr };
+ std::array<User*, 2> first_two = { {nullptr, nullptr} };
std::partial_sort_copy(
userlist.begin(), userlist.end(),
first_two.begin(), first_two.end(),
diff --git a/room.h b/room.h
index 831b5382..0f7967fb 100644
--- a/room.h
+++ b/room.h
@@ -55,9 +55,14 @@ namespace QMatrixClient
/**
* @brief Produces a disambiguated name for a given user in
- * the context of the room.
+ * the context of the room
*/
Q_INVOKABLE QString roomMembername(User* u) const;
+ /**
+ * @brief Produces a disambiguated name for a user with this id in
+ * the context of the room
+ */
+ Q_INVOKABLE QString roomMembername(QString userId) const;
Q_INVOKABLE void addMessage( Event* event );
Q_INVOKABLE void addInitialState( State* state );
@@ -95,7 +100,7 @@ namespace QMatrixClient
void notificationCountChanged(Room* room);
protected:
- Connection* connection();
+ Connection* connection() const;
virtual void processMessageEvent(Event* event);
virtual void processStateEvent(Event* event);
virtual void processEphemeralEvent(Event* event);