Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | List of all members
URLSchemesRegistry Class Referencefinal

#include <URLSchemesRegistry.h>

Inheritance diagram for URLSchemesRegistry:
[legend]
Collaboration diagram for URLSchemesRegistry:
[legend]

Public Member Functions

bool IsURLHandlingSupported () const noexcept
 Returns true, if Audacity can handle custom URLs. More...
 
bool RegisterScheme (std::string_view scheme)
 Associates a new scheme with Audacity. More...
 
void HandleURL (std::string_view url)
 
- Public Member Functions inherited from Observer::Publisher< URLschemeHandlerMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static URLSchemesRegistryGet ()
 Retrieves the registry instance. More...
 

Private Member Functions

 URLSchemesRegistry ()=default
 
 URLSchemesRegistry (const URLSchemesRegistry &)=delete
 
URLSchemesRegistryoperator= (const URLSchemesRegistry &)=delete
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< URLschemeHandlerMessage >
using message_type = URLschemeHandlerMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const URLschemeHandlerMessage &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Attributes inherited from Observer::Publisher< URLschemeHandlerMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< URLschemeHandlerMessage >
CallbackReturn Publish (const URLschemeHandlerMessage &message)
 Send a message to connected callbacks. More...
 

Detailed Description

Registry for custom URL schemes, that enables Audacity to handle open-url system requests

Definition at line 27 of file URLSchemesRegistry.h.

Constructor & Destructor Documentation

◆ URLSchemesRegistry() [1/2]

URLSchemesRegistry::URLSchemesRegistry ( )
privatedefault

◆ URLSchemesRegistry() [2/2]

URLSchemesRegistry::URLSchemesRegistry ( const URLSchemesRegistry )
privatedelete

Member Function Documentation

◆ Get()

URLSchemesRegistry & URLSchemesRegistry::Get ( )
static

Retrieves the registry instance.

Definition at line 39 of file URLSchemesRegistry.cpp.

40{
41 static URLSchemesRegistry registry;
42 return registry;
43}

Referenced by AudacityApp::InitPart2(), audacity::cloud::audiocom::UserPanel::OnLinkButtonPressed(), and AudacityApp::OnTimer().

Here is the caller graph for this function:

◆ HandleURL()

void URLSchemesRegistry::HandleURL ( std::string_view  url)

Called by the application main class when a custom-scheme URL is passed to Audacity, effectively sending URLschemeHandlerMessage to subscribers.

Definition at line 53 of file URLSchemesRegistry.cpp.

54{
55 Publish({ url });
56}
CallbackReturn Publish(const URLschemeHandlerMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207

References Observer::Publisher< URLschemeHandlerMessage >::Publish().

Referenced by AudacityApp::InitPart2(), and AudacityApp::OnTimer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsURLHandlingSupported()

bool URLSchemesRegistry::IsURLHandlingSupported ( ) const
noexcept

Returns true, if Audacity can handle custom URLs.

Definition at line 34 of file URLSchemesRegistry.cpp.

35{
36 return !!SchemeRegistrar;
37}
std::function< bool(std::string_view)> SchemeRegistrar

References anonymous_namespace{URLSchemesRegistry.cpp}::SchemeRegistrar.

Referenced by audacity::cloud::audiocom::UserPanel::OnLinkButtonPressed().

Here is the caller graph for this function:

◆ operator=()

URLSchemesRegistry & URLSchemesRegistry::operator= ( const URLSchemesRegistry )
privatedelete

◆ RegisterScheme()

bool URLSchemesRegistry::RegisterScheme ( std::string_view  scheme)

Associates a new scheme with Audacity.

On Windows, it is ensured that the last opened will handle the URL. Returns true if Audacity succeeded updating the registry.

On macOS, scheme registration is done using the Info.plist file and this function always returns true.

On other platforms - always returns false.

Definition at line 45 of file URLSchemesRegistry.cpp.

46{
47 if (!SchemeRegistrar)
48 return false;
49
50 return SchemeRegistrar(schema);
51}

References anonymous_namespace{URLSchemesRegistry.cpp}::SchemeRegistrar.

Referenced by AudacityApp::InitPart2().

Here is the caller graph for this function:

The documentation for this class was generated from the following files: