~ci-train-bot/online-accounts-api/online-accounts-api-ubuntu-xenial-landing-033

« back to all changes in this revision

Viewing changes to src/lib/OnlineAccounts/manager.h

  • Committer: Alberto Mardegan
  • Date: 2015-04-28 17:01:03 UTC
  • mfrom: (5.1.30 qt-api-impl)
  • Revision ID: alberto.mardegan@canonical.com-20150428170103-9hty50555f6e7uz6
Qt client API implementation

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of libOnlineAccounts
 
3
 *
 
4
 * Copyright (C) 2015 Canonical Ltd.
 
5
 *
 
6
 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
 
7
 *
 
8
 * This program is free software: you can redistribute it and/or modify it
 
9
 * under the terms of the GNU Lesser General Public License version 3, as
 
10
 * published by the Free Software Foundation.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
15
 * PURPOSE.  See the GNU Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public License
 
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
 
21
#ifndef ONLINE_ACCOUNTS_MANAGER_H
 
22
#define ONLINE_ACCOUNTS_MANAGER_H
 
23
 
 
24
#include <QList>
 
25
#include <QObject>
 
26
 
 
27
#include "error.h"
 
28
#include "global.h"
 
29
#include "pending_call.h"
 
30
 
 
31
namespace OnlineAccounts {
 
32
 
 
33
class Account;
 
34
class AuthenticationData;
 
35
class RequestAccessReplyPrivate;
 
36
 
 
37
class ManagerPrivate;
 
38
class ONLINE_ACCOUNTS_EXPORT Manager: public QObject
 
39
{
 
40
    Q_OBJECT
 
41
 
 
42
public:
 
43
    explicit Manager(const QString &applicationId, QObject *parent = 0);
 
44
    ~Manager();
 
45
 
 
46
    bool isReady() const;
 
47
    void waitForReady();
 
48
 
 
49
    QList<Account*> availableAccounts(const QString &service = QString());
 
50
    Account *account(AccountId accountId);
 
51
 
 
52
    PendingCall requestAccess(const QString &service,
 
53
                              const AuthenticationData &authData);
 
54
 
 
55
Q_SIGNALS:
 
56
    void ready();
 
57
    void accountAvailable(OnlineAccounts::Account *account);
 
58
 
 
59
private:
 
60
    friend class Account;
 
61
    friend class RequestAccessReplyPrivate;
 
62
    Q_DECLARE_PRIVATE(Manager)
 
63
    Q_DISABLE_COPY(Manager)
 
64
    ManagerPrivate *d_ptr;
 
65
};
 
66
 
 
67
class ONLINE_ACCOUNTS_EXPORT RequestAccessReply
 
68
{
 
69
public:
 
70
    RequestAccessReply(const PendingCall &call);
 
71
    virtual ~RequestAccessReply();
 
72
 
 
73
    bool hasError() const { return error().isValid(); }
 
74
    Error error() const;
 
75
 
 
76
    Account *account();
 
77
 
 
78
private:
 
79
    Q_DECLARE_PRIVATE(RequestAccessReply)
 
80
    Q_DISABLE_COPY(RequestAccessReply)
 
81
    RequestAccessReplyPrivate *d_ptr;
 
82
};
 
83
 
 
84
} // namespace
 
85
 
 
86
#endif // ONLINE_ACCOUNTS_MANAGER_H