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

« back to all changes in this revision

Viewing changes to src/daemon/manager.cpp

  • Committer: Alberto Mardegan
  • Date: 2015-02-10 10:24:08 UTC
  • mfrom: (3.1.3 accounts-daemon)
  • Revision ID: alberto.mardegan@canonical.com-20150210102408-alscglcpix51p1vj
Add AccountInfo class to group the account ID plus details

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
static const char FORBIDDEN_ERROR[] = "com.ubuntu.OnlineAccounts.Error.Forbidden";
9
9
 
 
10
QDBusArgument &operator<<(QDBusArgument &argument, const AccountInfo &info) {
 
11
    argument.beginStructure();
 
12
    argument << info.account_id << info.details;
 
13
    argument.endStructure();
 
14
    return argument;
 
15
}
 
16
 
 
17
const QDBusArgument &operator>>(const QDBusArgument &argument, AccountInfo &info) {
 
18
    argument.beginStructure();
 
19
    argument >> info.account_id >> info.details;
 
20
    argument.endStructure();
 
21
    return argument;
 
22
}
 
23
 
 
24
 
10
25
struct Manager::Private {
11
26
    AppArmorContext apparmor;
12
27
};
55
70
    return has_access;
56
71
}
57
72
 
58
 
QList<uint> Manager::GetAccounts(const QString &service_id) {
59
 
    if (!checkAccess(service_id)) {
60
 
        return QList<uint>();
 
73
QList<AccountInfo> Manager::GetAccounts(const QStringList &service_ids) {
 
74
    for (const auto &service_id : service_ids) {
 
75
        if (!checkAccess(service_id)) {
 
76
            return QList<AccountInfo>();
 
77
        }
61
78
    }
62
79
 
63
 
    return QList<uint>();
 
80
    return QList<AccountInfo>({AccountInfo(0, QVariantMap())});
64
81
}
65
82
 
66
 
QVariantMap Manager::GetAccountInfo(const QString &service_id, uint account_id) {
 
83
AccountInfo Manager::GetAccountInfo(const QString &service_id, uint account_id) {
67
84
    if (!checkAccess(service_id)) {
68
 
        return QVariantMap();
 
85
        return AccountInfo();
69
86
    }
70
87
 
71
 
    return QVariantMap();
 
88
    return AccountInfo(account_id, QVariantMap());
72
89
}
73
90
 
74
91
QVariantMap Manager::Authenticate(const QString &service_id, uint account_id, bool interactive, bool invalidate) {
79
96
    return QVariantMap();
80
97
}
81
98
 
82
 
uint Manager::Register(const QString &service_id, QVariantMap &details, QVariantMap &credentials) {
 
99
AccountInfo Manager::Register(const QString &service_id, QVariantMap &credentials) {
83
100
    if (!checkAccess(service_id)) {
84
 
        return 0;
 
101
        return AccountInfo();
85
102
    }
86
103
 
87
 
    return 0;
 
104
    return AccountInfo();
88
105
}