Audacity 3.2.0
AuthorizationHandler.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 AuthorizationHandler.cpp
7
8 Dmitry Vedenko
9
10**********************************************************************/
12
13#include <cassert>
14
15#include "OAuthService.h"
16
17#include "LinkFailedDialog.h"
18#include "LinkSucceededDialog.h"
19
21{
22namespace
23{
25}
26
28{
29 return handler;
30}
31
33 : mAuthStateChangedSubscription(GetOAuthService().Subscribe(
34 [this](const auto& message) { OnAuthStateChanged(message); }))
35{
36}
37
39{
41}
42
44{
45 assert(mSuppressed > 0);
46
47 if (mSuppressed > 0)
49}
50
52 const AuthStateChangedMessage& message)
53{
54 if (mSuppressed > 0)
55 return;
56
57 if (!message.errorMessage.empty())
58 {
59 LinkFailedDialog dialog { nullptr };
60 dialog.ShowModal();
61 }
62 else if (message.authorised)
63 {
64 LinkSucceededDialog dialog { nullptr };
65 dialog.ShowModal();
66 }
67}
68} // namespace cloud::audiocom
void OnAuthStateChanged(const AuthStateChangedMessage &message)
AuthorizationHandler & GetAuthorizationHandler()
OAuthService & GetOAuthService()
Returns the instance of the OAuthService.
Message that is sent when authorization state changes.
Definition: OAuthService.h:26
std::string_view errorMessage
Error message returned by the server in case of oauth error.
Definition: OAuthService.h:30
bool authorised
Flag that indicates if user is authorised.
Definition: OAuthService.h:32