diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-14 01:22:04 +0200 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2017-10-14 01:53:02 +0200 |
commit | 76c42a9863b83229e6afaf4be32e9582e3d97d3f (patch) | |
tree | 1aacf03ab8d9ae96e4f21f430d7e99ddf4b0bb10 /room.cpp | |
parent | 2d3590dbdb23c82f1960327ffbd78e778231b9c8 (diff) | |
download | libquotient-76c42a9863b83229e6afaf4be32e9582e3d97d3f.tar.gz libquotient-76c42a9863b83229e6afaf4be32e9582e3d97d3f.zip |
Cleanup around Room (potentially breaks API compatibility, beware)
Notably:
* API for SendEventJob and SetRoomStateJob has been altered to accept references, not pointers.
* Methods on Room that invoke requests to the server, have lost const, because they may be reflecting the changed state on the fly, within themselves
Diffstat (limited to 'room.cpp')
-rw-r--r-- | room.cpp | 27 |
1 files changed, 11 insertions, 16 deletions
@@ -445,7 +445,8 @@ void Room::Private::addMember(User *u) if (!hasMember(u)) { insertMemberIntoMap(u); - connect(u, &User::nameChanged, q, &Room::userRenamed); + connect(u, &User::nameChanged, q, + [=] (User* u, const QString& newName) { renameMember(u, newName); }); emit q->userAdded(u); } } @@ -490,11 +491,6 @@ void Room::Private::removeMember(User* u) } } -void Room::userRenamed(User* user, QString oldName) -{ - d->renameMember(user, std::move(oldName)); -} - QString Room::roomMembername(User *u) const { // See the CS spec, section 11.2.2.3 @@ -581,16 +577,15 @@ void Room::updateData(SyncRoomData&& data) void Room::postMessage(const QString& type, const QString& plainText) { - connection()->callApi<SendEventJob>(id(), type, plainText); + postMessage(RoomMessageEvent { plainText, type }); } void Room::postMessage(const QString& plainText, MessageEventType type) { - RoomMessageEvent rme(plainText, type); - postMessage(&rme); + postMessage(RoomMessageEvent { plainText, type }); } -void Room::postMessage(RoomMessageEvent* event) +void Room::postMessage(const RoomMessageEvent& event) { connection()->callApi<SendEventJob>(id(), event); } @@ -598,7 +593,7 @@ void Room::postMessage(RoomMessageEvent* event) void Room::setTopic(const QString& newTopic) { RoomTopicEvent evt(newTopic); - connection()->callApi<SetRoomStateJob>(id(), &evt); + connection()->callApi<SetRoomStateJob>(id(), evt); } void Room::getPreviousContent(int limit) @@ -623,27 +618,27 @@ void Room::Private::getPreviousContent(int limit) } } -void Room::inviteToRoom(const QString& memberId) const +void Room::inviteToRoom(const QString& memberId) { connection()->callApi<InviteUserJob>(id(), memberId); } -void Room::leaveRoom() const +void Room::leaveRoom() { connection()->callApi<LeaveRoomJob>(id()); } -void Room::kickMember(const QString& memberId, const QString& reason) const +void Room::kickMember(const QString& memberId, const QString& reason) { connection()->callApi<KickJob>(id(), memberId, reason); } -void Room::ban(const QString& userId, const QString& reason) const +void Room::ban(const QString& userId, const QString& reason) { connection()->callApi<BanJob>(id(), userId, reason); } -void Room::unban(const QString& userId) const +void Room::unban(const QString& userId) { connection()->callApi<UnbanJob>(id(), userId); } |