mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-24 10:23:02 -07:00
[DeckShare] Build share links with QUrl and QUrlQuery for percent-encoding
This commit is contained in:
parent
0cd900fc60
commit
65adf1c6af
1 changed files with 13 additions and 2 deletions
|
|
@ -4,6 +4,8 @@
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QTimeZone>
|
#include <QTimeZone>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QUrlQuery>
|
||||||
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
#include <libcockatrice/network/client/abstract/abstract_client.h>
|
||||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/response_deck_share_create.pb.h>
|
#include <libcockatrice/protocol/pb/response_deck_share_create.pb.h>
|
||||||
|
|
@ -13,8 +15,17 @@ namespace DeckShareUtils
|
||||||
|
|
||||||
QString buildShareLink(const AbstractClient *client, const QString &token)
|
QString buildShareLink(const AbstractClient *client, const QString &token)
|
||||||
{
|
{
|
||||||
return QString("cockatrice://opendeck?share=%1&hostname=%2&port=%3")
|
QUrl url;
|
||||||
.arg(token, client->serverName(), QString::number(client->serverPort()));
|
url.setScheme(QStringLiteral("cockatrice"));
|
||||||
|
url.setHost(QStringLiteral("opendeck"));
|
||||||
|
|
||||||
|
QUrlQuery query;
|
||||||
|
query.addQueryItem(QStringLiteral("share"), token);
|
||||||
|
query.addQueryItem(QStringLiteral("hostname"), client->serverName());
|
||||||
|
query.addQueryItem(QStringLiteral("port"), QString::number(client->serverPort()));
|
||||||
|
url.setQuery(query);
|
||||||
|
|
||||||
|
return url.toString(QUrl::FullyEncoded);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString copyShareLinkToClipboard(const QString &link)
|
QString copyShareLinkToClipboard(const QString &link)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue