Attica::ProviderManager Class
class Attica::ProviderManagerAttica ProviderManager. More...
Header: | #include <Attica/ProviderManager> |
CMake: | find_package(KF6 REQUIRED COMPONENTS Attica) target_link_libraries(mytarget PRIVATE KF6::Attica) |
Inherits: | QObject |
Public Types
enum | ProviderFlag { NoFlags, DisablePlugins } |
flags | ProviderFlags |
Public Functions
ProviderManager(const Attica::ProviderManager::ProviderFlags &flags = NoFlags) | |
void | addProviderFile(const QUrl &file) |
void | addProviderFileToDefaultProviders(const QUrl &url) |
void | addProviderFromXml(const QString &providerXml) |
void | clear() |
bool | contains(const QUrl &provider) const |
QList<QUrl> | defaultProviderFiles() |
void | loadDefaultProviders() |
Attica::Provider | providerByUrl(const QUrl &url) const |
QList<QUrl> | providerFiles() const |
Attica::Provider | providerFor(const QUrl &url) const |
QList<Attica::Provider> | providers() const |
void | removeProviderFileFromDefaultProviders(const QUrl &url) |
void | setAuthenticationSuppressed(bool suppressed) |
Signals
void | authenticationCredentialsMissing(const Attica::Provider &provider) |
void | defaultProvidersLoaded() |
void | failedToLoad(const QUrl &provider, QNetworkReply::NetworkError error) |
void | providerAdded(const Attica::Provider &provider) |
Detailed Description
This class is the primary access to Attica's functions. Use the ProviderManager to load Open Collaboration Service providers, either the default system ones, or from XML or custom locations.
Provider Files
Provider files are defined here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services
Basic Use
See addProviderFileToDefaultProviders(const QUrl &url) for an example of what the provider file sohuld look like. You can add providers to the ProviderManager as either raw XML data using addProviderFromXml(const QString &providerXml), or from a file somewhere on the system through addProviderFile(const QUrl &file), or you can simply load the default providers provided by your system (which generally means KDE's provider opendesktop.org).
Importantly, to be able to detect when the ProviderManager is ready to manage things, before initialising it you will want to connect to the providerAdded(const Attica::Provider &provider) signal, which is fired every time a new provider is added to the manager.
If you manually add all providers from XML, you can expect this to happen immediately. This means that once you have added your providers that way, you can access them through the providers() function, which returns a list of all loaded Providers.
Once you have loaded a Provider, you can use its functions to access the services offered by that provider.
Member Type Documentation
enum ProviderManager::ProviderFlag
flags ProviderManager::ProviderFlags
Constant | Value |
---|---|
Attica::ProviderManager::NoFlags | 0x0 |
Attica::ProviderManager::DisablePlugins | 0x1 |
The ProviderFlags type is a typedef for QFlags<ProviderFlag>. It stores an OR combination of ProviderFlag values.
Member Function Documentation
ProviderManager::ProviderManager(const Attica::ProviderManager::ProviderFlags &flags = NoFlags)
void ProviderManager::addProviderFile(const QUrl &file)
void ProviderManager::addProviderFileToDefaultProviders(const QUrl &url)
Add a provider file to the default providers (xml that contains provider descriptions). Provider files contain information about each provider:
<providers> <provider> <id>opendesktop</id> <location>https://api.opendesktop.org/v1/</location> <name>openDesktop.org</name> <icon></icon> <termsofuse>https://opendesktop.org/terms/</termsofuse> <register>https://opendesktop.org/usermanager/new.php</register> <services> <person ocsversion="1.3" /> <friend ocsversion="1.3" /> <message ocsversion="1.3" /> <activity ocsversion="1.3" /> <content ocsversion="1.3" /> <fan ocsversion="1.3" /> <knowledgebase ocsversion="1.3" /> <event ocsversion="1.3" /> </services> </provider> </providers>
url the url of the provider file
void ProviderManager::addProviderFromXml(const QString &providerXml)
Parse a xml file containing a provider description
[signal]
void ProviderManager::authenticationCredentialsMissing(const Attica::Provider &provider)
void ProviderManager::clear()
Remove all providers and provider files that have been loaded
bool ProviderManager::contains(const QUrl &provider) const
Returns whether there's a provider with base url provider
QList<QUrl> ProviderManager::defaultProviderFiles()
The list of provider files that get loaded by loadDefaultProviders. Each of these files can contain multiple providers.
[signal]
void ProviderManager::defaultProvidersLoaded()
[signal]
void ProviderManager::failedToLoad(const QUrl &provider, QNetworkReply::NetworkError error)
void ProviderManager::loadDefaultProviders()
Load available providers from configuration
[signal]
void ProviderManager::providerAdded(const Attica::Provider &provider)
Attica::Provider ProviderManager::providerByUrl(const QUrl &url) const
Returns the provider with url base url.
QList<QUrl> ProviderManager::providerFiles() const
Attica::Provider ProviderManager::providerFor(const QUrl &url) const
Returns the provider for a given provider url.
QList<Attica::Provider> ProviderManager::providers() const
Returns all loaded providers
void ProviderManager::removeProviderFileFromDefaultProviders(const QUrl &url)
void ProviderManager::setAuthenticationSuppressed(bool suppressed)
Suppresses the authentication, so that the application can take care of authenticating itself