libaccounts-qt  1.1
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  *
00007  * Contact: Alberto Mardegan <alberto.mardegan@nokia.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 ACCOUNTMANAGER_H
00025 #define ACCOUNTMANAGER_H
00026 
00027 #include <QObject>
00028 #include <QSettings>
00029 #include <QString>
00030 #include <QStringList>
00031 
00032 #include "Accounts/accountscommon.h"
00033 #include "Accounts/account.h"
00034 #include "Accounts/error.h"
00035 #include "Accounts/provider.h"
00036 #include "Accounts/service.h"
00037 #include "Accounts/service-type.h"
00038 
00042 namespace Accounts
00043 {
00044 
00045 class AccountService;
00046 
00047 class ACCOUNTS_EXPORT Manager : public QObject
00048 {
00049     Q_OBJECT
00050 
00051 public:
00052     Manager(QObject *parent = 0);
00053     Manager(const QString &serviceType, QObject *parent = 0);
00054     ~Manager();
00055 
00056     Account *account(const AccountId &id) const;
00057 
00058     AccountIdList accountList(const QString &serviceType = QString::null) const;
00059     AccountIdList accountListEnabled(const QString &serviceType = QString::null) const;
00060 
00061     Account *createAccount(const QString &providerName);
00062 
00063     Service *service(const QString &serviceName) const;
00064     ServiceList serviceList(const QString &serviceType = QString::null) const;
00065 
00066     Provider *provider(const QString &providerName) const;
00067     ProviderList providerList() const;
00068 
00069     ServiceType *serviceType(const QString &name) const;
00070 
00071     QString serviceType() const;
00072 
00073     void setTimeout(quint32 timeout);
00074     quint32 timeout();
00075 
00076     void setAbortOnTimeout(bool abort);
00077     bool abortOnTimeout() const;
00078 
00079     Error lastError() const;
00080 
00081 Q_SIGNALS:
00082     void accountCreated(Accounts::AccountId id);
00083     void accountRemoved(Accounts::AccountId id);
00084     void accountUpdated(Accounts::AccountId id);
00085     void enabledEvent(Accounts::AccountId id);
00086 
00087 private:
00088 
00089     // \cond
00090     class Private;
00091     friend class Private;
00092     Private *d; // Owned.
00093 
00094     Provider *providerInstance(AgProvider *provider) const;
00095     Service *serviceInstance(AgService *service) const;
00096     friend class Account;
00097     friend class AccountService;
00098     // \endcond
00099 }; // Manager
00100 
00101 } //namespace Accounts
00102 
00103 #endif // ACCOUNTMANAGER_H