File indexing completed on 2024-04-28 04:55:42
0001 /* 0002 This file is part of Choqok, the KDE micro-blogging client 0003 0004 SPDX-FileCopyrightText: 2008-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com> 0005 0006 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0007 */ 0008 0009 #ifndef ACCOUNTMANAGER_H 0010 #define ACCOUNTMANAGER_H 0011 0012 #include <QObject> 0013 0014 #include "account.h" 0015 0016 namespace Choqok 0017 { 0018 /** 0019 Account manager class 0020 0021 @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\> 0022 */ 0023 class CHOQOK_EXPORT AccountManager : public QObject 0024 { 0025 Q_OBJECT 0026 public: 0027 ~AccountManager(); 0028 0029 /** 0030 * \brief Retrieve the instance of AccountManager. 0031 * 0032 * The account manager is a singleton class of which only a single 0033 * instance will exist. If no manager exists yet this function will 0034 * create one for you. 0035 * 0036 * \return the instance of the AccountManager 0037 */ 0038 static AccountManager *self(); 0039 0040 /** 0041 * \brief Retrieve the list of accounts 0042 * \return a list of all the accounts 0043 */ 0044 const QList<Account *> &accounts() const; 0045 0046 /** 0047 * \brief Return the account asked 0048 * \param alias is the alias of account 0049 * \return the Account object found 0050 */ 0051 Account *findAccount(const QString &alias); 0052 0053 /** 0054 * @brief Add the account. 0055 * 0056 * This adds the account to the manager's account list. 0057 * It will check no accounts already exist with the same Alias, if any, the account is deleted. and not added 0058 * 0059 * @return @p account, or nullptr if the account was deleted because alias collision 0060 */ 0061 Account *registerAccount(Account *account); 0062 0063 /** 0064 * \brief Delete the account and clean the config data 0065 * 0066 * This is praticaly called by the account config page when you remove the account. 0067 */ 0068 bool removeAccount(const QString &alias); 0069 0070 QString lastError() const; 0071 static QString generatePostBackupFileName(const QString &alias, const QString &name); 0072 0073 public Q_SLOTS: 0074 void loadAllAccounts(); 0075 0076 Q_SIGNALS: 0077 void accountAdded(Choqok::Account *account); 0078 void accountRemoved(const QString &alias); 0079 void allAccountsLoaded(); 0080 0081 private: 0082 AccountManager(); 0083 class Private; 0084 Private *const d; 0085 static AccountManager *mSelf; 0086 }; 0087 } 0088 #endif