accounts-qt  1.15
manager.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) 2009-2011 Nokia Corporation.
00006  * Copyright (C) 2012-2016 Canonical Ltd.
00007  *
00008  * Contact: Alberto Mardegan <alberto.mardegan@canonical.com>
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public License
00012  * version 2.1 as published by the Free Software Foundation.
00013  *
00014  * This library is distributed in the hope that it will be useful, but
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00022  * 02110-1301 USA
00023  */
00024 
00025 #ifndef ACCOUNTS_MANAGER_H
00026 #define ACCOUNTS_MANAGER_H
00027 
00028 #include <QObject>
00029 #include <QSettings>
00030 #include <QString>
00031 #include <QStringList>
00032 
00033 #include "Accounts/accountscommon.h"
00034 #include "Accounts/account.h"
00035 #include "Accounts/error.h"
00036 #include "Accounts/provider.h"
00037 #include "Accounts/service.h"
00038 #include "Accounts/service-type.h"
00039 
00043 namespace Accounts
00044 {
00045 
00046 class AccountService;
00047 class Application;
00048 
00049 typedef QList<Application> ApplicationList;
00050 
00051 class ACCOUNTS_EXPORT Manager: public QObject
00052 {
00053     Q_OBJECT
00054 
00055 public:
00060     enum Option {
00061         DisableNotifications = 0x1, 
00062     };
00063     Q_DECLARE_FLAGS(Options, Option)
00064 
00065     Manager(QObject *parent = 0);
00066     Manager(const QString &serviceType, QObject *parent = 0);
00067     Manager(Options options, QObject *parent = 0);
00068     ~Manager();
00069 
00070     Account *account(const AccountId &id) const;
00071 
00072     AccountIdList accountList(const QString &serviceType = QString::null) const;
00073     AccountIdList accountListEnabled(const QString &serviceType = QString::null) const;
00074 
00075     Account *createAccount(const QString &providerName);
00076 
00077     Service service(const QString &serviceName) const;
00078     ServiceList serviceList(const QString &serviceType = QString::null) const;
00079     ServiceList serviceList(const Application &application) const;
00080 
00081     Provider provider(const QString &providerName) const;
00082     ProviderList providerList() const;
00083 
00084     ServiceType serviceType(const QString &name) const;
00085 
00086     Application application(const QString &applicationName) const;
00087     ApplicationList applicationList(const Service &service) const;
00088 
00089     QString serviceType() const;
00090 
00091     void setTimeout(quint32 timeout);
00092     quint32 timeout();
00093 
00094     void setAbortOnTimeout(bool abort);
00095     bool abortOnTimeout() const;
00096 
00097     Options options() const;
00098 
00099     Error lastError() const;
00100 
00101 Q_SIGNALS:
00102     void accountCreated(Accounts::AccountId id);
00103     void accountRemoved(Accounts::AccountId id);
00104     void accountUpdated(Accounts::AccountId id);
00105     void enabledEvent(Accounts::AccountId id);
00106 
00107 private:
00108 
00109     // \cond
00110     class Private;
00111     friend class Private;
00112     Private *d; // Owned.
00113 
00114     friend class Account;
00115     friend class AccountService;
00116     // \endcond
00117 }; // Manager
00118 
00119 } //namespace Accounts
00120 
00121 Q_DECLARE_OPERATORS_FOR_FLAGS(Accounts::Manager::Options)
00122 
00123 #endif // ACCOUNTS_MANAGER_H