aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-25 14:46:18 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2017-12-25 14:46:18 +0900
commitcbfe29b3435fbe47fee268facbe6a82000fce0ad (patch)
treee922f1a1505ff1d0a3cdaca56ed5fd151c3aa410 /examples
parentb1dd0e7ea87842fb5ff9deb14beb3474136b06f3 (diff)
parenta4a1129385731c3999a6d5986a24fc069938245c (diff)
downloadlibquotient-cbfe29b3435fbe47fee268facbe6a82000fce0ad.tar.gz
libquotient-cbfe29b3435fbe47fee268facbe6a82000fce0ad.zip
Merge branch 'master' into kitsune-gtad
Diffstat (limited to 'examples')
-rw-r--r--examples/qmc-example.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/examples/qmc-example.cpp b/examples/qmc-example.cpp
index dc0c94e4..dbb9912b 100644
--- a/examples/qmc-example.cpp
+++ b/examples/qmc-example.cpp
@@ -15,15 +15,21 @@ void onNewRoom(Room* r)
{
cout << "New room: " << r->id().toStdString() << endl;
QObject::connect(r, &Room::namesChanged, [=] {
- cout << "Room " << r->id().toStdString() << ", name(s) changed:" << endl;
- cout << " Name: " << r->name().toStdString() << endl;
- cout << " Canonical alias: " << r->canonicalAlias().toStdString() << endl;
+ cout << "Room " << r->id().toStdString() << ", name(s) changed:" << endl
+ << " Name: " << r->name().toStdString() << endl
+ << " Canonical alias: " << r->canonicalAlias().toStdString()
+ << endl << endl;
});
- QObject::connect(r, &Room::aboutToAddNewMessages, [=] (RoomEvents evs) {
- cout << "New events in room " << r->id().toStdString() << ":" << endl;
- for (auto e: evs)
+ QObject::connect(r, &Room::aboutToAddNewMessages, [=] (RoomEventsRange timeline) {
+ cout << timeline.size() << " new event(s) in room "
+ << r->id().toStdString() << ":" << endl;
+ for (const auto& item: timeline)
{
- cout << string(e->originalJson()) << endl;
+ cout << "From: "
+ << r->roomMembername(item->senderId()).toStdString()
+ << endl << "Timestamp:"
+ << item->timestamp().toString().toStdString() << endl
+ << "JSON:" << endl << string(item->originalJson()) << endl;
}
});
}
@@ -36,7 +42,7 @@ int main(int argc, char* argv[])
auto conn = new Connection(QUrl("https://matrix.org"));
conn->connectToServer(argv[1], argv[2], "QMatrixClient example application");
- QObject::connect(conn, &Connection::connected, [=] {
+ auto c = QObject::connect(conn, &Connection::connected, [=] {
cout << "Connected" << endl;
conn->sync();
});