~ubuntu-branches/debian/jessie/attica-kf5/jessie

« back to all changes in this revision

Viewing changes to src/providermanager.h

  • Committer: Package Import Robot
  • Author(s): Maximiliano Curia
  • Date: 2014-07-15 10:53:09 UTC
  • Revision ID: package-import@ubuntu.com-20140715105309-nnjxenwcs6h4qznf
Tags: upstream-5.0.0
Import upstream version 5.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    This file is part of KDE.
 
3
 
 
4
    Copyright (c) 2009 Eckhart Wörner <ewoerner@kde.org>
 
5
    Copyright (c) 2009 Frederik Gladhorn <gladhorn@kde.org>
 
6
 
 
7
    This library is free software; you can redistribute it and/or
 
8
    modify it under the terms of the GNU Lesser General Public
 
9
    License as published by the Free Software Foundation; either
 
10
    version 2.1 of the License, or (at your option) version 3, or any
 
11
    later version accepted by the membership of KDE e.V. (or its
 
12
    successor approved by the membership of KDE e.V.), which shall
 
13
    act as a proxy defined in Section 6 of version 3 of the license.
 
14
 
 
15
    This library is distributed in the hope that it will be useful,
 
16
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
18
    Lesser General Public License for more details.
 
19
 
 
20
    You should have received a copy of the GNU Lesser General Public
 
21
    License along with this library.  If not, see <http://www.gnu.org/licenses/>.
 
22
 
 
23
*/
 
24
 
 
25
#ifndef ATTICA_PROVIDERMANAGER_H
 
26
#define ATTICA_PROVIDERMANAGER_H
 
27
 
 
28
#include <QtCore/QUrl>
 
29
 
 
30
#include "provider.h"
 
31
#include "atticaclient_export.h"
 
32
 
 
33
namespace Attica
 
34
{
 
35
 
 
36
/**
 
37
 * Attica ProviderManager
 
38
 *
 
39
 * This class is the primary access to Attica's functions.
 
40
 * Use the ProviderManager to load Open Collaboration Service providers,
 
41
 * either the default system ones, or from XML or custom locations.
 
42
 *
 
43
 * \section providerfiles Provider Files
 
44
 * Provider files are defined here:
 
45
 * http://www.freedesktop.org/wiki/Specifications/open-collaboration-services
 
46
 *
 
47
 * <pre>
 
48
   provider file example
 
49
 * </pre>
 
50
 *
 
51
 * Once you have loaded a Provider, use its functions to access the service.
 
52
 */
 
53
class ATTICA_EXPORT ProviderManager : public QObject
 
54
{
 
55
    Q_OBJECT
 
56
 
 
57
public:
 
58
 
 
59
    enum ProviderFlag {
 
60
        NoFlags = 0x0,
 
61
        DisablePlugins = 0x1
 
62
    };
 
63
    Q_DECLARE_FLAGS(ProviderFlags, ProviderFlag)
 
64
 
 
65
    ProviderManager(const ProviderFlags &flags = NoFlags);
 
66
    ~ProviderManager();
 
67
 
 
68
    /**
 
69
     * Load available providers from configuration
 
70
     */
 
71
    void loadDefaultProviders();
 
72
 
 
73
    /**
 
74
     * The list of provider files that get loaded by loadDefaultProviders.
 
75
     * Each of these files can contain multiple providers.
 
76
     * @return list of provider file urls
 
77
     */
 
78
    QList<QUrl> defaultProviderFiles();
 
79
 
 
80
    /**
 
81
    * Add a provider file to the default providers (xml that contains provider descriptions).
 
82
      Provider files contain information about each provider:
 
83
     <pre>
 
84
     <providers>
 
85
     <provider>
 
86
        <id>opendesktop</id>
 
87
        <location>https://api.opendesktop.org/v1/</location>
 
88
        <name>openDesktop.org</name>
 
89
        <icon></icon>
 
90
        <termsofuse>https://opendesktop.org/terms/</termsofuse>
 
91
        <register>https://opendesktop.org/usermanager/new.php</register>
 
92
        <services>
 
93
            <person ocsversion="1.3" />
 
94
            <friend ocsversion="1.3" />
 
95
            <message ocsversion="1.3" />
 
96
            <activity ocsversion="1.3" />
 
97
            <content ocsversion="1.3" />
 
98
            <fan ocsversion="1.3" />
 
99
            <knowledgebase ocsversion="1.3" />
 
100
            <event ocsversion="1.3" />
 
101
        </services>
 
102
     </provider>
 
103
     </providers>
 
104
     </pre>
 
105
    * @param url the url of the provider file
 
106
    */
 
107
    void addProviderFileToDefaultProviders(const QUrl &url);
 
108
 
 
109
    void removeProviderFileFromDefaultProviders(const QUrl &url);
 
110
 
 
111
    /**
 
112
     * Suppresses the authentication, so that the application can take care of authenticating itself
 
113
     */
 
114
    void setAuthenticationSuppressed(bool suppressed);
 
115
 
 
116
    /**
 
117
     * Remove all providers and provider files that have been loaded
 
118
     */
 
119
    void clear();
 
120
 
 
121
    /**
 
122
     * Parse a xml file containing a provider description
 
123
     */
 
124
    void addProviderFromXml(const QString &providerXml);
 
125
    void addProviderFile(const QUrl &file);
 
126
    QList<QUrl> providerFiles() const;
 
127
 
 
128
    QList<Provider> providers() const;
 
129
    bool contains(const QString &provider) const;
 
130
    Provider providerByUrl(const QUrl &url) const;
 
131
 
 
132
Q_SIGNALS:
 
133
    void providerAdded(const Attica::Provider &provider);
 
134
    void defaultProvidersLoaded();
 
135
    void authenticationCredentialsMissing(const Provider &provider);
 
136
 
 
137
private Q_SLOTS:
 
138
    void fileFinished(const QString &url);
 
139
    void authenticate(QNetworkReply *, QAuthenticator *);
 
140
    void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
 
141
    void slotLoadDefaultProvidersInternal();
 
142
 
 
143
private:
 
144
    ProviderManager(const ProviderManager &other);
 
145
    ProviderManager &operator=(const ProviderManager &other);
 
146
 
 
147
    void initNetworkAccesssManager();
 
148
    PlatformDependent *loadPlatformDependent(const ProviderFlags &flags);
 
149
 
 
150
    void parseProviderFile(const QString &xmlString, const QString &url);
 
151
 
 
152
    class Private;
 
153
    Private *const d;
 
154
};
 
155
 
 
156
}
 
157
 
 
158
Q_DECLARE_OPERATORS_FOR_FLAGS(Attica::ProviderManager::ProviderFlags)
 
159
 
 
160
#endif