accounts-qt  1.13
account-service.h
00001 /* vi: set et sw=4 ts=4 cino=t0,(0: */
00002 /*
00003 * This file is part of libaccounts-qt
00004 *
00005 * Copyright (C) 2012 Canonical Ltd.
00006 *
00007 * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00008 *
00009 * This library is free software; you can redistribute it and/or
00010 * modify it under the terms of the GNU Lesser General Public License
00011 * version 2.1 as published by the Free Software Foundation.
00012 *
00013 * This library is distributed in the hope that it will be useful, but
00014 * WITHOUT ANY WARRANTY; without even the implied warranty of
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016 * Lesser General Public License for more details.
00017 *
00018 * You should have received a copy of the GNU Lesser General Public
00019 * License along with this library; if not, write to the Free Software
00020 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021 * 02110-1301 USA
00022 */
00023 
00024 #ifndef ACCOUNTS_ACCOUNT_SERVICE_H
00025 #define ACCOUNTS_ACCOUNT_SERVICE_H
00026 
00027 #include <QObject>
00028 #include <QStringList>
00029 
00030 #include "Accounts/account.h"
00031 #include "Accounts/auth-data.h"
00032 
00033 namespace Accounts
00034 {
00035 class Manager;
00036 class Service;
00037 
00038 class AccountServicePrivate;
00039 class ACCOUNTS_EXPORT AccountService: public QObject
00040 {
00041     Q_OBJECT
00042 
00043 public:
00044     explicit AccountService(Account *account, const Service &service);
00045     explicit AccountService(Account *account, const Service &service,
00046                             QObject *parent);
00047     virtual ~AccountService();
00048 
00049     Account *account() const;
00050     Service service() const;
00051 
00052     bool enabled() const;
00053     bool isEnabled() const;
00054 
00055     QStringList allKeys() const;
00056 
00057     void beginGroup(const QString &prefix);
00058 
00059     QStringList childGroups() const;
00060     QStringList childKeys() const;
00061 
00062     void clear();
00063 
00064     bool contains(const QString &key) const;
00065 
00066     void endGroup();
00067 
00068     QString group() const;
00069 
00070     void remove(const QString &key);
00071 
00072     void setValue(const char *key, const QVariant &value);
00073     void setValue(const QString &key, const QVariant &value);
00074 
00075     QVariant value(const QString &key,
00076                    const QVariant &defaultValue,
00077                    SettingSource *source = 0) const;
00078     QVariant value(const QString &key, SettingSource *source = 0) const;
00079     QVariant value(const char *key, SettingSource *source = 0) const;
00080 
00081     QStringList changedFields() const;
00082 
00083     AuthData authData() const;
00084 
00085 Q_SIGNALS:
00086     void enabled(bool isEnabled);
00087     void changed();
00088 
00089 private:
00090     // Don't include private data in docs: \cond
00091     AccountServicePrivate *d_ptr;
00092     Q_DECLARE_PRIVATE(AccountService)
00093     // \endcond
00094 };
00095 
00096 typedef QList<AccountService*> AccountServiceList;
00097 
00098 } //namespace
00099 
00100 #endif // ACCOUNTS_ACCOUNT_SERVICE_H