Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
url_parser.h
Go to the documentation of this file.
1#ifndef COCKATRICE_URL_PARSER_H
2#define COCKATRICE_URL_PARSER_H
3
4#include <QList>
5#include <QMetaObject>
6#include <QObject>
7#include <QString>
8#include <QUrlQuery>
9#include <qtmetamacros.h>
10
11class Intent;
12class MainWindow;
13struct ContextJoinGame;
14
23{
25
26 // Snapshot of the session in place when this chain started running, so a
27 // queued chain follows whichever server the chain before it settled on.
30
31 // Recorded at parse time when the user confirmed migrating away from a live
32 // session to the host/port named by the link.
35 bool pendingRestore = false;
36};
37
47class IntentUrlParser : public QObject
48{
49 Q_OBJECT
50
51public:
52 IntentUrlParser(QObject *parent, MainWindow *mainWindow);
53 void handle(const QString &urlStr);
54
55signals:
57 void urlChainFinished(bool connected);
58
59private:
60 Intent *createJoinGameIntent(const QUrlQuery &query, PendingIntentChain &chain);
61 Intent *createOpenDeckIntent(const QUrlQuery &query, PendingIntentChain &chain);
62 QString generateJoinGameMessage(const ContextJoinGame &context, const QString &gameDescription);
63 [[nodiscard]] bool isConnectedTo(const QString &hostname, const QString &port) const;
64 void startNextChain();
65 void chainEnded(bool chainSucceeded);
69
72 bool chainRunning = false;
73 // Disconnects the destroyed-signal backstop once a chain ends, so an old
74 // intent's deferred deletion cannot end the chain that runs after it.
75 QMetaObject::Connection chainBackstopConnection;
76};
77
78#endif // COCKATRICE_URL_PARSER_H
void restoreToPreviousServer(const PendingIntentChain &chain)
Definition url_parser.cpp:401
MainWindow * mainWindow
Definition url_parser.h:70
QMetaObject::Connection chainBackstopConnection
Definition url_parser.h:75
void restorePreviousServer(const PendingIntentChain &chain)
Definition url_parser.cpp:373
bool isConnectedTo(const QString &hostname, const QString &port) const
Definition url_parser.cpp:290
Intent * createOpenDeckIntent(const QUrlQuery &query, PendingIntentChain &chain)
Definition url_parser.cpp:185
QString generateJoinGameMessage(const ContextJoinGame &context, const QString &gameDescription)
Definition url_parser.cpp:150
QList< PendingIntentChain > pendingChains
Definition url_parser.h:71
void onChainIntentDestroyed()
Definition url_parser.cpp:364
void chainEnded(bool chainSucceeded)
Definition url_parser.cpp:342
void startNextChain()
Definition url_parser.cpp:302
Intent * createJoinGameIntent(const QUrlQuery &query, PendingIntentChain &chain)
Definition url_parser.cpp:79
bool chainRunning
Definition url_parser.h:72
IntentUrlParser(QObject *parent, MainWindow *mainWindow)
Definition url_parser.cpp:38
void urlChainFinished(bool connected)
Emitted when the last queued chain ended; carries whether the client is logged in.
void handle(const QString &urlStr)
Definition url_parser.cpp:42
Definition intent.h:9
Definition window_main.h:73
Definition remote_connection_controller.h:20
Definition context_join_game.h:6
One queued intent chain with the session-migration bookkeeping for it.
Definition url_parser.h:23
QString migrationTargetHost
Definition url_parser.h:33
QList< Intent * > intents
Definition url_parser.h:24
bool pendingRestore
Definition url_parser.h:35
QString migrationTargetPort
Definition url_parser.h:34
QString previousServerPort
Definition url_parser.h:29
QString previousServerHost
Definition url_parser.h:28