File indexing completed on 2019-04-16 11:59:10

0001 /*
0002     This file is part of Choqok, the KDE micro-blogging client
0003 
0004     Copyright (C) 2008-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
0005 
0006     This program is free software; you can redistribute it and/or
0007     modify it under the terms of the GNU General Public License as
0008     published by the Free Software Foundation; either version 2 of
0009     the License or (at your option) version 3 or any later version
0010     accepted by the membership of KDE e.V. (or its successor approved
0011     by the membership of KDE e.V.), which shall act as a proxy
0012     defined in Section 14 of version 3 of the license.
0013 
0014     This program is distributed in the hope that it will be useful,
0015     but WITHOUT ANY WARRANTY; without even the implied warranty of
0016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0017     GNU General Public License for more details.
0018 
0019     You should have received a copy of the GNU General Public License
0020     along with this program; if not, see http://www.gnu.org/licenses/
0021 
0022 */
0023 #ifndef CHOQOKACCOUNT_H
0024 #define CHOQOKACCOUNT_H
0025 
0026 #include <QString>
0027 
0028 #include <KConfigGroup>
0029 #include <memory>
0030 #include "choqok_export.h"
0031 
0032 namespace Choqok
0033 {
0034 class MicroBlog;
0035 /**
0036 \brief Account class base
0037 MicroBlog plugins can subclass this class or use it if fill their needs.
0038 
0039 @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\>
0040 */
0041 class CHOQOK_EXPORT Account : public QObject
0042 {
0043     Q_OBJECT
0044 public:
0045     Account(MicroBlog *parent, const QString &alias);
0046 
0047     ~Account();
0048     /**
0049     \brief MicroBlog for this account
0050     */
0051     MicroBlog *microblog() const;
0052 
0053     /**
0054     By default this will return @ref microblog() 's timelineNames()
0055     Some microblogs may need to change this per account base!
0056     */
0057     virtual QStringList timelineNames() const;
0058 
0059     QString username() const;
0060     void setUsername(const QString &name);
0061 
0062     QString password() const;
0063     void setPassword(const QString &pass);
0064 
0065     QString alias() const;
0066     void setAlias(const QString &alias);
0067 
0068     bool isReadOnly() const;
0069     void setReadOnly(bool readonly = true);
0070 
0071     bool isEnabled() const;
0072     void setEnabled(bool enabled = true);
0073 
0074     bool showInQuickPost() const;
0075     void setShowInQuickPost(bool show = true);
0076 
0077     void setPostCharLimit(const uint limit);
0078     /**
0079     Indicate character limit for a post. 0 means no limit.
0080     */
0081     uint postCharLimit() const;
0082 
0083     virtual void writeConfig();
0084     /**
0085     * \brief Get the priority of this account.
0086     *
0087     * Used for sorting mainwindow tab widgets.
0088     */
0089     uint priority() const;
0090 
0091     /**
0092     * \brief Set the priority of this account.
0093     *
0094     * @note This method is called by the UI, and should not be called elsewhere.
0095     */
0096     void setPriority(uint priority);
0097 
0098     /**
0099     * Return the @ref KConfigGroup used to write and read special properties
0100     *
0101     * "MicroBlog", "UserId", "Username" , "Password", "Priority", "Enabled" are reserved keyword
0102     * already in use in that group.
0103     *
0104     * for compatibility, try to not use key that start with a uppercase
0105     */
0106     KConfigGroup *configGroup() const;
0107 
0108 Q_SIGNALS:
0109     void modified(Choqok::Account *theAccount);
0110     void status(Choqok::Account *theAccount, bool enabled);
0111 
0112 private:
0113     class Private;
0114     std::unique_ptr<Private> d;
0115 };
0116 
0117 }
0118 #endif