libaccounts-qt  1.6
account-service.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) 2012 Canonical Ltd.
6 *
7 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * version 2.1 as published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21 * 02110-1301 USA
22 */
23 
24 #ifndef ACCOUNTS_ACCOUNT_SERVICE_H
25 #define ACCOUNTS_ACCOUNT_SERVICE_H
26 
27 #include <QObject>
28 #include <QStringList>
29 
30 #include "Accounts/account.h"
31 #include "Accounts/auth-data.h"
32 
33 namespace Accounts
34 {
35 class Manager;
36 class Service;
37 
38 class AccountServicePrivate;
39 class ACCOUNTS_EXPORT AccountService: public QObject
40 {
41  Q_OBJECT
42 
43 public:
44  explicit AccountService(Account *account, const Service &service);
45  explicit AccountService(Account *account, const Service &service,
46  QObject *parent);
47  virtual ~AccountService();
48 
49  Account *account() const;
50  Service service() const;
51 
52  bool enabled() const;
53 
54  QStringList allKeys() const;
55 
56  void beginGroup(const QString &prefix);
57 
58  QStringList childGroups() const;
59  QStringList childKeys() const;
60 
61  void clear();
62 
63  bool contains(const QString &key) const;
64 
65  void endGroup();
66 
67  QString group() const;
68 
69  void remove(const QString &key);
70 
71  void setValue(const char *key, const QVariant &value);
72  void setValue(const QString &key, const QVariant &value);
73 
74  QVariant value(const QString &key,
75  const QVariant &defaultValue,
76  SettingSource *source = 0) const;
77  QVariant value(const QString &key, SettingSource *source = 0) const;
78  QVariant value(const char *key, SettingSource *source = 0) const;
79 
80  QStringList changedFields() const;
81 
82  AuthData authData() const;
83 
84 Q_SIGNALS:
85  void enabled(bool isEnabled);
86  void changed();
87 
88 private:
89  // Don't include private data in docs: \cond
90  AccountServicePrivate *d_ptr;
91  Q_DECLARE_PRIVATE(AccountService)
92  // \endcond
93 };
94 
95 typedef QList<AccountService*> AccountServiceList;
96 
97 } //namespace
98 
99 #endif // ACCOUNTS_ACCOUNT_SERVICE_H