aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarawaaa <77910862+arawaaa@users.noreply.github.com>2021-05-25 13:11:53 -0500
committerarawaaa <77910862+arawaaa@users.noreply.github.com>2021-05-25 13:11:53 -0500
commit28823df2af5a4bfbab6dc455252c8ea0e211ffcb (patch)
tree1c1afb8fde16c15b8b4c110f635fed88c426ec4c
parent5155f825bb71fca649a97ac4a7fa356cf85ee722 (diff)
parent7761c2b791291adee0505c869305b5675e90ed3b (diff)
downloadlibquotient-28823df2af5a4bfbab6dc455252c8ea0e211ffcb.tar.gz
libquotient-28823df2af5a4bfbab6dc455252c8ea0e211ffcb.zip
Merge branch 'quotient-im:master' into pinned
-rw-r--r--.github/workflows/ci.yml2
-rw-r--r--.gitignore2
-rw-r--r--README.md6
-rw-r--r--lib/connection.cpp8
-rw-r--r--lib/user.cpp19
-rw-r--r--lib/user.h4
6 files changed, 26 insertions, 15 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index fd6f489e..24681460 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -58,7 +58,7 @@ jobs:
- name: Setup build environment
run: |
if [ "${{ matrix.compiler }}" == "GCC" ]; then
- if [ -n "${{ matrix.update-api }}" ]; then VERSION_POSTFIX='-8'; fi
+ if [ -n "${{ matrix.update-api }}" ]; then VERSION_POSTFIX='-9'; fi
echo "CC=gcc$VERSION_POSTFIX" >>$GITHUB_ENV
echo "CXX=g++$VERSION_POSTFIX" >>$GITHUB_ENV
else
diff --git a/.gitignore b/.gitignore
index e9b63926..769bdf45 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,7 +3,7 @@ build
build_dir
# IDE project files/directories
-.kdev4
+*.kdev4
.directory
*.user*
.idea
diff --git a/README.md b/README.md
index 0ed599b3..c993c31e 100644
--- a/README.md
+++ b/README.md
@@ -85,13 +85,13 @@ a recommended way of linking your application with libQuotient on this platform.
Static linkage is the default on Windows/macOS; feel free to experiment
with dynamic linking and submit PRs if you get reusable results.
-[Quotest](tests), the test application that comes with libQuotient, includes
+[Quotest](quotest), the test application that comes with libQuotient, includes
most common use cases such as sending messages, uploading files,
setting room state etc.; for more extensive usage check out the source code
of [Quaternion](https://github.com/quotient-im/Quaternion)
(the reference client of Quotient) or [Spectral](https://gitlab.com/b0/spectral).
-To ease the first step, `tests/CMakeLists.txt` is a good starting point
+To ease the first step, `quotest/CMakeLists.txt` is a good starting point
for your own CMake-based project using libQuotient.
## Building the library
@@ -155,7 +155,7 @@ You can install the library with CMake:
cmake --build . --target install
```
This will also install cmake package config files; once this is done, you
-should be able to use [`tests/CMakeLists.txt`](tests/CMakeLists.txt) to compile quotest
+should be able to use [`quotest/CMakeLists.txt`](quotest/CMakeLists.txt) to compile quotest
with the _installed_ library. Installation of the `quotest` binary
along with the rest of the library can be skipped
by setting `Quotient_INSTALL_TESTS` to `OFF`.
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 579c7920..a384783c 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -807,7 +807,7 @@ JoinRoomJob* Connection::joinRoom(const QString& roomAlias,
// that may add their own slots to finished().
connect(job, &BaseJob::finished, this, [this, job] {
if (job->status().good())
- provideRoom(job->roomId());
+ provideRoom(job->roomId(), JoinState::Join);
});
return job;
}
@@ -1464,11 +1464,13 @@ Room* Connection::provideRoom(const QString& id, Omittable<JoinState> joinState)
room = d->roomMap.value({ id, true }, nullptr);
if (room)
return room;
- // No Invite either, setup a new room object below
+ // No Invite either, setup a new room object in Join state
+ joinState = JoinState::Join;
}
if (!room) {
- room = roomFactory()(this, id, joinState.value_or(JoinState::Join));
+ Q_ASSERT(joinState.has_value());
+ room = roomFactory()(this, id, *joinState);
if (!room) {
qCCritical(MAIN) << "Failed to create a room" << id;
return nullptr;
diff --git a/lib/user.cpp b/lib/user.cpp
index c4c4fec8..7933c5d9 100644
--- a/lib/user.cpp
+++ b/lib/user.cpp
@@ -51,13 +51,7 @@ User::User(QString userId, Connection* connection)
setObjectName(id());
if (connection->userId() == id()) {
// Load profile information for local user.
- auto *profileJob = connection->callApi<GetUserProfileJob>(id());
- connect(profileJob, &BaseJob::result, this, [this, profileJob] {
- d->defaultName = profileJob->displayname();
- d->defaultAvatar = Avatar(QUrl(profileJob->avatarUrl()));
- emit defaultNameChanged();
- emit defaultAvatarChanged();
- });
+ load();
}
}
@@ -69,6 +63,17 @@ Connection* User::connection() const
User::~User() = default;
+void User::load()
+{
+ auto *profileJob = connection()->callApi<GetUserProfileJob>(id());
+ connect(profileJob, &BaseJob::result, this, [this, profileJob] {
+ d->defaultName = profileJob->displayname();
+ d->defaultAvatar = Avatar(QUrl(profileJob->avatarUrl()));
+ emit defaultNameChanged();
+ emit defaultAvatarChanged();
+ });
+}
+
QString User::id() const { return d->id; }
bool User::isGuest() const
diff --git a/lib/user.h b/lib/user.h
index d0926189..e4560843 100644
--- a/lib/user.h
+++ b/lib/user.h
@@ -130,6 +130,10 @@ public Q_SLOTS:
void unmarkIgnore();
/// Check whether the user is in ignore list
bool isIgnored() const;
+ /// Force loading displayName and avartar url. This is required in
+ /// some cases where the you need to use an user independent of the
+ /// room.
+ void load();
Q_SIGNALS:
void defaultNameChanged();