mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-21 00:55:09 -07:00
* [Application] Add single instance guard and mime types. Took 2 hours 39 minutes Took 18 minutes Took 5 minutes Took 12 seconds Took 11 seconds * Rework Took 30 minutes Took 50 seconds * Only enforce single instance if launched with arguments. Took 5 minutes * Prototype intents Took 53 minutes Took 6 seconds * Connect/disconnect and join game/room intents. Took 3 hours 14 minutes Took 2 seconds Took 15 seconds * Fix include. Took 1 minute Took 23 seconds Took 2 seconds * Mac handling. Took 10 minutes Took 12 seconds Took 3 minutes * Lint. Took 3 minutes * Rebase. Took 3 minutes Took 17 seconds * Implement UrlSchemeEventFilter Took 10 minutes Took 7 seconds * Qt Moc Took 3 minutes * Modern PList. Took 21 minutes Took 1 minute * Debug output. Took 6 minutes Took 19 minutes * Watch file:// prefix. Took 15 minutes Took 7 seconds * Better handler. Took 6 minutes * Don't store reference in member Took 5 minutes * Move impl to cpp, fix lifetime issues. Took 11 minutes Took 2 minutes * Better single-instance handoff, url intent harded copy game link context-menu Polish for installers Took 35 minutes Took 8 seconds --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
46 lines
1.6 KiB
C++
46 lines
1.6 KiB
C++
#include "intent_connect_to_server.h"
|
|
|
|
#include "intent_disconnect_from_server.h"
|
|
|
|
#include <QTimer>
|
|
|
|
IntentConnectToServer::IntentConnectToServer(RemoteClient *_remoteClient, ContextConnectToServer *_context)
|
|
: Intent(), remoteClient(_remoteClient), context(_context)
|
|
{
|
|
}
|
|
|
|
bool IntentConnectToServer::checkPrecondition() const
|
|
{
|
|
return remoteClient->getStatus() == ClientStatus::StatusDisconnected;
|
|
}
|
|
|
|
void IntentConnectToServer::onPreconditionSatisfied()
|
|
{
|
|
remoteClient->connectToServer(context->hostname, context->port.toUInt(), context->username, context->password);
|
|
connect(remoteClient, &RemoteClient::statusChanged, this, &IntentConnectToServer::onStatusChanged);
|
|
connect(remoteClient, &RemoteClient::socketError, this, &IntentConnectToServer::onSocketError);
|
|
connect(
|
|
remoteClient, &RemoteClient::loginError, this,
|
|
[this](Response::ResponseCode, const QString &reason, quint32, const QList<QString> &) { emitFailed(reason); });
|
|
|
|
QTimer::singleShot(15000, this, [this]() {
|
|
emitFailed(tr("Timed out while connecting to %1:%2").arg(context->hostname, context->port));
|
|
});
|
|
}
|
|
|
|
void IntentConnectToServer::onPreconditionNotSatisfied()
|
|
{
|
|
runDependency(new IntentDisconnectFromServer(remoteClient));
|
|
}
|
|
|
|
void IntentConnectToServer::onStatusChanged(ClientStatus status)
|
|
{
|
|
if (status == ClientStatus::StatusLoggedIn) {
|
|
emitFinished();
|
|
}
|
|
}
|
|
|
|
void IntentConnectToServer::onSocketError(const QString &errorString)
|
|
{
|
|
emitFailed(tr("Failed to connect to %1:%2: %3").arg(context->hostname, context->port, errorString));
|
|
}
|