1
0
Fork 0
mirror of https://github.com/HenkKalkwater/harbour-sailfin.git synced 2025-09-04 01:42:44 +00:00

QuickConnect: init

This adds a page in the settings page that allows the user to enter a
quick connect code to allow another device to log in.
This commit is contained in:
Chris Josten 2024-01-02 19:51:27 +01:00
parent 13786f01c9
commit a66434afa8
10 changed files with 242 additions and 3 deletions

View file

@ -209,6 +209,14 @@ signals:
void supportedCommandsChanged();
void onlineChanged();
/**
* @brief Emitted after submitQuickConnectCode succeeded
*/
void quickConnectAccepted();
/**
* @brief Emitted after submitQuickConnectCode failed
*/
void quickConnectRejected();
/**
* @brief onUserDataChanged Emitted when the user data of an item is changed on the server.
@ -233,6 +241,7 @@ public slots:
*/
void setupConnection();
void authenticate(QString username, QString password, bool storeCredentials = false);
void submitQuickConnectCode(const QString &code);
/**
* @brief Logs the user out and clears the session.

View file

@ -256,6 +256,27 @@ public:
}
};
// Specialisation for endpoints that return "true" or "false" as response.
template<typename P>
class HttpLoaderBase<bool, P> : public Loader<bool, P> {
public:
explicit HttpLoaderBase(Jellyfin::ApiClient *apiClient)
: Loader<bool, P> (apiClient) {}
typename Loader<bool, P>::ResultType parseResponse(int statusCode, QByteArray response) {
QString text = QString::fromUtf8(response);
if (text == QStringLiteral("true")) {
return true;
} else if (text == QStringLiteral("false")) {
return false;
} else {
this->stopWithError(QStringLiteral("Could not parse boolean response: %1").arg(text));
return std::nullopt;
}
}
};
/**
* Implementation of Loader that loads Items over HTTP