diff options
Diffstat (limited to 'lib/connection.h')
-rw-r--r-- | lib/connection.h | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/lib/connection.h b/lib/connection.h index b22d63da..2ff27ea6 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -26,6 +26,7 @@ #include <QtCore/QObject> #include <QtCore/QUrl> #include <QtCore/QSize> +#include <QtCore/QDir> #include <functional> #include <memory> @@ -104,6 +105,7 @@ namespace QMatrixClient Q_PROPERTY(QByteArray accessToken READ accessToken NOTIFY stateChanged) Q_PROPERTY(QString defaultRoomVersion READ defaultRoomVersion NOTIFY capabilitiesLoaded) Q_PROPERTY(QUrl homeserver READ homeserver WRITE setHomeserver NOTIFY homeserverChanged) + Q_PROPERTY(QString domain READ domain NOTIFY homeserverChanged) Q_PROPERTY(bool cacheState READ cacheState WRITE setCacheState NOTIFY cacheStateChanged) Q_PROPERTY(bool lazyLoading READ lazyLoading WRITE setLazyLoading NOTIFY lazyLoadingChanged) @@ -218,10 +220,10 @@ namespace QMatrixClient QList<User*> directChatUsers(const Room* room) const; /** Check whether a particular user is in the ignore list */ - bool isIgnored(const User* user) const; + Q_INVOKABLE bool isIgnored(const User* user) const; /** Get the whole list of ignored users */ - IgnoredUsersList ignoredUsers() const; + Q_INVOKABLE IgnoredUsersList ignoredUsers() const; /** Add the user to the ignore list * The change signal is emitted synchronously, without waiting @@ -229,19 +231,22 @@ namespace QMatrixClient * * \sa ignoredUsersListChanged */ - void addToIgnoredUsers(const User* user); + Q_INVOKABLE void addToIgnoredUsers(const User* user); /** Remove the user from the ignore list */ /** Similar to adding, the change signal is emitted synchronously. * * \sa ignoredUsersListChanged */ - void removeFromIgnoredUsers(const User* user); + Q_INVOKABLE void removeFromIgnoredUsers(const User* user); /** Get the full list of users known to this account */ QMap<QString, User*> users() const; + /** Get the base URL of the homeserver to connect to */ QUrl homeserver() const; + /** Get the domain name used for ids/aliases on the server */ + QString domain() const; /** Find a room by its id and a mask of applicable states */ Q_INVOKABLE Room* room(const QString& roomId, JoinStates states = JoinState::Invite|JoinState::Join) const; @@ -301,8 +306,8 @@ namespace QMatrixClient * Call this before first sync to load from previously saved file. * * \param fromFile A local path to read the state from. Uses QUrl - * to be QML-friendly. Empty parameter means using a path - * defined by stateCachePath(). + * to be QML-friendly. Empty parameter means saving to the directory + * defined by stateCachePath() / stateCacheDir(). */ Q_INVOKABLE void loadState(); /** @@ -311,23 +316,30 @@ namespace QMatrixClient * loadState() on a next run of the client. * * \param toFile A local path to save the state to. Uses QUrl to be - * QML-friendly. Empty parameter means using a path defined by - * stateCachePath(). + * QML-friendly. Empty parameter means saving to the directory + * defined by stateCachePath() / stateCacheDir(). */ Q_INVOKABLE void saveState() const; /// This method saves the current state of a single room. void saveRoomState(Room* r) const; + /// Get the default directory path to save the room state to + /** \sa stateCacheDir */ + Q_INVOKABLE QString stateCachePath() const; + + /// Get the default directory to save the room state to /** - * The default path to store the cached room state, defined as - * follows: + * This function returns the default directory to store the cached + * room state, defined as follows: + * \code * QStandardPaths::writeableLocation(QStandardPaths::CacheLocation) + _safeUserId + "_state.json" - * where `_safeUserId` is userId() with `:` (colon) replaced with - * `_` (underscore) - * /see loadState(), saveState() + * \endcode + * where `_safeUserId` is userId() with `:` (colon) replaced by + * `_` (underscore), as colons are reserved characters on Windows. + * \sa loadState, saveState, stateCachePath */ - Q_INVOKABLE QString stateCachePath() const; + QDir stateCacheDir() const; bool cacheState() const; void setCacheState(bool newValue); |