diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-03-25 22:07:06 -0700 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-03-25 22:07:06 -0700 |
commit | aacc01fbddc32ceee36a0baedad219ad5d07f955 (patch) | |
tree | 5690b2587cc6a5b306eae0953018c4db8bf5827b /connection.h | |
parent | e9cdf6c887b80210dcb6d754c1db82d3fad2ec06 (diff) | |
parent | a73bb17418a6dfea556a837c48463e454c8db130 (diff) | |
download | libquotient-aacc01fbddc32ceee36a0baedad219ad5d07f955.tar.gz libquotient-aacc01fbddc32ceee36a0baedad219ad5d07f955.zip |
Merge branch 'kitsune-more-on-direct-chats'
Diffstat (limited to 'connection.h')
-rw-r--r-- | connection.h | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/connection.h b/connection.h index 4497e200..7c11c32d 100644 --- a/connection.h +++ b/connection.h @@ -89,18 +89,30 @@ namespace QMatrixClient /** Get the list of rooms with the specified tag */ QVector<Room*> roomsWithTag(const QString& tagName) const; - /** Mark the room as a direct chat with the user */ + /** Mark the room as a direct chat with the user + * This function marks \p room as a direct chat with \p user. + * Emits the signal synchronously, without waiting to complete + * synchronisation with the server. + * + * \sa directChatsListChanged + */ void addToDirectChats(const Room* room, const User* user); /** Unmark the room from direct chats - * This function removes the room from direct chats either for + * This function removes the room id from direct chats either for * a specific \p user or for all users if \p user in nullptr. + * The room id is used to allow removal of, e.g., ids of forgotten + * rooms; a Room object need not exist. Emits the signal + * immediately, without waiting to complete synchronisation with + * the server. + * + * \sa directChatsListChanged */ - void removeFromDirectChats(const Room* room, + void removeFromDirectChats(const QString& roomId, const User* user = nullptr); - /** Check whether the room is a direct chat */ - bool isDirectChat(const Room* room) const; + /** Check whether the room id corresponds to a direct chat */ + bool isDirectChat(const QString& roomId) const; QMap<QString, User*> users() const; @@ -249,6 +261,15 @@ namespace QMatrixClient */ Q_INVOKABLE void requestDirectChat(const QString& userId); + /** Run an operation in a direct chat with the user + * This method may return synchronously or asynchoronously depending + * on whether a direct chat room with the respective person exists + * already. Instead of emitting a signal it executes the passed + * function object with the direct chat room as its parameter. + */ + Q_INVOKABLE void doInDirectChat(const QString& userId, + std::function<void(Room*)> operation); + /** Create a direct chat with a single user, optional name and topic * A room will always be created, unlike in requestDirectChat. * It is advised to use requestDirectChat as a default way of getting |