Skip to content

Commit

Permalink
Apply the new brace wrapping to source files
Browse files Browse the repository at this point in the history
  • Loading branch information
KitsuneRal committed Aug 2, 2019
1 parent 1a1ea8f commit c05ade8
Show file tree
Hide file tree
Showing 66 changed files with 335 additions and 664 deletions.
7 changes: 2 additions & 5 deletions examples/qmc-example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ using std::cout;
using std::endl;
using namespace std::placeholders;

class QMCTest : public QObject
{
class QMCTest : public QObject {
public:
QMCTest(Connection* conn, QString testRoomName, QString source);

Expand Down Expand Up @@ -92,9 +91,7 @@ bool QMCTest::validatePendingEvent(const QString& txnId)
}

QMCTest::QMCTest(Connection* conn, QString testRoomName, QString source)
: c(conn)
, origin(std::move(source))
, targetRoomName(std::move(testRoomName))
: c(conn), origin(std::move(source)), targetRoomName(std::move(testRoomName))
{
if (!origin.isEmpty())
cout << "Origin for the test message: " << origin.toStdString() << endl;
Expand Down
15 changes: 4 additions & 11 deletions lib/avatar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@
using namespace QMatrixClient;
using std::move;

class Avatar::Private
{
class Avatar::Private {
public:
explicit Private(QUrl url = {})
: _url(move(url))
{}
explicit Private(QUrl url = {}) : _url(move(url)) {}
~Private()
{
if (isJobRunning(_thumbnailRequest))
Expand Down Expand Up @@ -65,13 +62,9 @@ class Avatar::Private
mutable std::vector<get_callback_t> callbacks;
};

Avatar::Avatar()
: d(std::make_unique<Private>())
{}
Avatar::Avatar() : d(std::make_unique<Private>()) {}

Avatar::Avatar(QUrl url)
: d(std::make_unique<Private>(std::move(url)))
{}
Avatar::Avatar(QUrl url) : d(std::make_unique<Private>(std::move(url))) {}

Avatar::Avatar(Avatar&&) = default;

Expand Down
6 changes: 2 additions & 4 deletions lib/avatar.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@
#include <functional>
#include <memory>

namespace QMatrixClient
{
namespace QMatrixClient {
class Connection;

class Avatar
{
class Avatar {
public:
explicit Avatar();
explicit Avatar(QUrl url);
Expand Down
79 changes: 38 additions & 41 deletions lib/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ HashT erase_if(HashT& hashMap, Pred pred)
return removals;
}

class Connection::Private
{
class Connection::Private {
public:
explicit Private(std::unique_ptr<ConnectionData>&& connection)
: data(move(connection))
Expand Down Expand Up @@ -151,15 +150,12 @@ class Connection::Private
};

Connection::Connection(const QUrl& server, QObject* parent)
: QObject(parent)
, d(new Private(std::make_unique<ConnectionData>(server)))
: QObject(parent), d(new Private(std::make_unique<ConnectionData>(server)))
{
d->q = this; // All d initialization should occur before this line
}

Connection::Connection(QObject* parent)
: Connection({}, parent)
{}
Connection::Connection(QObject* parent) : Connection({}, parent) {}

Connection::~Connection()
{
Expand All @@ -183,45 +179,47 @@ void Connection::resolveServer(const QString& mxid)
qCDebug(MAIN) << "Finding the server" << domain;

auto getWellKnownJob = callApi<GetWellknownJob>();
connect(getWellKnownJob, &BaseJob::finished,
[this, getWellKnownJob, maybeBaseUrl] {
if (getWellKnownJob->status() == BaseJob::NotFoundError) {
qCDebug(MAIN) << "No .well-known file, IGNORE";
} else if (getWellKnownJob->status() != BaseJob::Success) {
connect(
getWellKnownJob, &BaseJob::finished,
[this, getWellKnownJob, maybeBaseUrl] {
if (getWellKnownJob->status() == BaseJob::NotFoundError)
qCDebug(MAIN) << "No .well-known file, IGNORE";
else {
if (getWellKnownJob->status() != BaseJob::Success) {
qCDebug(MAIN)
<< "Fetching .well-known file failed, FAIL_PROMPT";
emit resolveError(tr("Fetching .well-known file failed"));
return;
} else if (getWellKnownJob->data().homeserver.baseUrl.isEmpty()) {
}
QUrl baseUrl(getWellKnownJob->data().homeserver.baseUrl);
if (baseUrl.isEmpty()) {
qCDebug(MAIN) << "base_url not provided, FAIL_PROMPT";
emit resolveError(tr("base_url not provided"));
return;
} else if (!QUrl(getWellKnownJob->data().homeserver.baseUrl)
.isValid()) {
}
if (!baseUrl.isValid()) {
qCDebug(MAIN) << "base_url invalid, FAIL_ERROR";
emit resolveError(tr("base_url invalid"));
return;
} else {
QUrl baseUrl(getWellKnownJob->data().homeserver.baseUrl);

qCDebug(MAIN) << ".well-known for" << maybeBaseUrl.host()
<< "is" << baseUrl.toString();
setHomeserver(baseUrl);
}

auto getVersionsJob = callApi<GetVersionsJob>();

connect(getVersionsJob, &BaseJob::finished,
[this, getVersionsJob] {
if (getVersionsJob->status() == BaseJob::Success) {
qCDebug(MAIN) << "homeserver url is valid";
emit resolved();
} else {
qCDebug(MAIN) << "homeserver url invalid";
emit resolveError(tr("homeserver url invalid"));
}
});
qCDebug(MAIN) << ".well-known for" << maybeBaseUrl.host()
<< "is" << baseUrl.toString();
setHomeserver(baseUrl);
}

auto getVersionsJob = callApi<GetVersionsJob>();

connect(getVersionsJob, &BaseJob::finished, [this, getVersionsJob] {
if (getVersionsJob->status() == BaseJob::Success) {
qCDebug(MAIN) << "homeserver url is valid";
emit resolved();
} else {
qCDebug(MAIN) << "homeserver url invalid";
emit resolveError(tr("homeserver url invalid"));
}
});
});
}

void Connection::connectToServer(const QString& user, const QString& password,
Expand Down Expand Up @@ -372,8 +370,8 @@ void Connection::sync(int timeout)
connect(job, &SyncJob::failure, this, [this, job] {
d->syncJob = nullptr;
if (job->error() == BaseJob::ContentAccessError) {
qCWarning(SYNCJOB)
<< "Sync job failed with ContentAccessError - login expired?";
qCWarning(SYNCJOB) << "Sync job failed with ContentAccessError - "
"login expired?";
emit loginError(job->errorString(), job->rawDataSample());
} else
emit syncError(job->errorString(), job->rawDataSample());
Expand Down Expand Up @@ -437,7 +435,6 @@ void Connection::onSyncSuccess(SyncData&& data, bool fromCache)
visit(
*eventPtr,
[this](const DirectChatEvent& dce) {
// See
// https://github.com/QMatrixClient/libqmatrixclient/wiki/Handling-direct-chat-events
const auto& usersToDCs = dce.usersToDirectChats();
DirectChatsMap remoteRemovals =
Expand Down Expand Up @@ -492,8 +489,8 @@ void Connection::onSyncSuccess(SyncData&& data, bool fromCache)
<< QStringList::fromSet(ignoredUsers()).join(',');

auto& currentData = d->accountData[accountEvent.matrixType()];
// A polymorphic event-specific comparison might be a bit more
// efficient; maaybe do it another day
// A polymorphic event-specific comparison might be a bit
// more efficient; maaybe do it another day
if (!currentData
|| currentData->contentJson() != accountEvent.contentJson()) {
currentData = std::move(eventPtr);
Expand Down Expand Up @@ -678,9 +675,9 @@ void Connection::requestDirectChat(const QString& userId)
if (auto* u = user(userId))
requestDirectChat(u);
else
qCCritical(MAIN)
<< "Connection::requestDirectChat: Couldn't get a user object for"
<< userId;
qCCritical(MAIN) << "Connection::requestDirectChat: Couldn't get a "
"user object for"
<< userId;
}

void Connection::requestDirectChat(User* u)
Expand Down
21 changes: 6 additions & 15 deletions lib/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,11 @@

#include <functional>

namespace QtOlm
{
namespace QtOlm {
class Account;
}

namespace QMatrixClient
{
namespace QMatrixClient {
class Room;
class User;
class ConnectionData;
Expand Down Expand Up @@ -93,14 +91,9 @@ static inline user_factory_t defaultUserFactory()
*
* \sa Connection::callApi
*/
enum RunningPolicy
{
ForegroundRequest = 0x0,
BackgroundRequest = 0x1
};
enum RunningPolicy { ForegroundRequest = 0x0, BackgroundRequest = 0x1 };

class Connection : public QObject
{
class Connection : public QObject {
Q_OBJECT

Q_PROPERTY(User* localUser READ user NOTIFY stateChanged)
Expand Down Expand Up @@ -129,8 +122,7 @@ class Connection : public QObject
using UsersToDevicesToEvents =
std::unordered_map<QString, std::unordered_map<QString, const Event&>>;

enum RoomVisibility
{
enum RoomVisibility {
PublishRoom,
UnpublishRoom
}; // FIXME: Should go inside CreateRoomJob
Expand Down Expand Up @@ -285,8 +277,7 @@ class Connection : public QObject

Q_INVOKABLE void getTurnServers();

struct SupportedRoomVersion
{
struct SupportedRoomVersion {
QString id;
QString status;

Expand Down
7 changes: 2 additions & 5 deletions lib/connectiondata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@

using namespace QMatrixClient;

struct ConnectionData::Private
{
explicit Private(QUrl url)
: baseUrl(std::move(url))
{}
struct ConnectionData::Private {
explicit Private(QUrl url) : baseUrl(std::move(url)) {}

QUrl baseUrl;
QByteArray accessToken;
Expand Down
6 changes: 2 additions & 4 deletions lib/connectiondata.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@

class QNetworkAccessManager;

namespace QMatrixClient
{
class ConnectionData
{
namespace QMatrixClient {
class ConnectionData {
public:
explicit ConnectionData(QUrl baseUrl);
virtual ~ConnectionData();
Expand Down
Loading

0 comments on commit c05ade8

Please sign in to comment.