accounts-qt  1.11
manager.h
1 /* vi: set et sw=4 ts=4 cino=t0,(0: */
2 /*
3  * This file is part of libaccounts-qt
4  *
5  * Copyright (C) 2009-2011 Nokia Corporation.
6  * Copyright (C) 2012 Canonical Ltd.
7  *
8  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
9  *
10  * This library is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public License
12  * version 2.1 as published by the Free Software Foundation.
13  *
14  * This library is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22  * 02110-1301 USA
23  */
24 
25 #ifndef ACCOUNTS_MANAGER_H
26 #define ACCOUNTS_MANAGER_H
27 
28 #include <QObject>
29 #include <QSettings>
30 #include <QString>
31 #include <QStringList>
32 
33 #include "Accounts/accountscommon.h"
34 #include "Accounts/account.h"
35 #include "Accounts/error.h"
36 #include "Accounts/provider.h"
37 #include "Accounts/service.h"
38 #include "Accounts/service-type.h"
39 
43 namespace Accounts
44 {
45 
46 class AccountService;
47 class Application;
48 
49 typedef QList<Application> ApplicationList;
50 
51 class ACCOUNTS_EXPORT Manager: public QObject
52 {
53  Q_OBJECT
54 
55 public:
56  Manager(QObject *parent = 0);
57  Manager(const QString &serviceType, QObject *parent = 0);
58  ~Manager();
59 
60  Account *account(const AccountId &id) const;
61 
62  AccountIdList accountList(const QString &serviceType = QString::null) const;
63  AccountIdList accountListEnabled(const QString &serviceType = QString::null) const;
64 
65  Account *createAccount(const QString &providerName);
66 
67  Service service(const QString &serviceName) const;
68  ServiceList serviceList(const QString &serviceType = QString::null) const;
69 
70  Provider provider(const QString &providerName) const;
71  ProviderList providerList() const;
72 
73  ServiceType serviceType(const QString &name) const;
74 
75  Application application(const QString &applicationName) const;
76  ApplicationList applicationList(const Service &service) const;
77 
78  QString serviceType() const;
79 
80  void setTimeout(quint32 timeout);
81  quint32 timeout();
82 
83  void setAbortOnTimeout(bool abort);
84  bool abortOnTimeout() const;
85 
86  Error lastError() const;
87 
88 Q_SIGNALS:
89  void accountCreated(Accounts::AccountId id);
90  void accountRemoved(Accounts::AccountId id);
91  void accountUpdated(Accounts::AccountId id);
92  void enabledEvent(Accounts::AccountId id);
93 
94 private:
95 
96  // \cond
97  class Private;
98  friend class Private;
99  Private *d; // Owned.
100 
101  friend class Account;
102  friend class AccountService;
103  // \endcond
104 }; // Manager
105 
106 } //namespace Accounts
107 
108 #endif // ACCOUNTS_MANAGER_H