File indexing completed on 2024-04-21 04:55:25

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 CHOQOKACCOUNT_H
0010 #define CHOQOKACCOUNT_H
0011 
0012 #include <QString>
0013 
0014 #include <KConfigGroup>
0015 #include <memory>
0016 #include "choqok_export.h"
0017 
0018 namespace Choqok
0019 {
0020 class MicroBlog;
0021 /**
0022 \brief Account class base
0023 MicroBlog plugins can subclass this class or use it if fill their needs.
0024 
0025 @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\>
0026 */
0027 class CHOQOK_EXPORT Account : public QObject
0028 {
0029     Q_OBJECT
0030 public:
0031     Account(MicroBlog *parent, const QString &alias);
0032 
0033     ~Account();
0034     /**
0035     \brief MicroBlog for this account
0036     */
0037     MicroBlog *microblog() const;
0038 
0039     /**
0040     By default this will return @ref microblog() 's timelineNames()
0041     Some microblogs may need to change this per account base!
0042     */
0043     virtual QStringList timelineNames() const;
0044 
0045     QString username() const;
0046     void setUsername(const QString &name);
0047 
0048     QString password() const;
0049     void setPassword(const QString &pass);
0050 
0051     QString alias() const;
0052     void setAlias(const QString &alias);
0053 
0054     bool isReadOnly() const;
0055     void setReadOnly(bool readonly = true);
0056 
0057     bool isEnabled() const;
0058     void setEnabled(bool enabled = true);
0059 
0060     bool showInQuickPost() const;
0061     void setShowInQuickPost(bool show = true);
0062 
0063     void setPostCharLimit(const uint limit);
0064     /**
0065     Indicate character limit for a post. 0 means no limit.
0066     */
0067     uint postCharLimit() const;
0068 
0069     virtual void writeConfig();
0070     /**
0071     * \brief Get the priority of this account.
0072     *
0073     * Used for sorting mainwindow tab widgets.
0074     */
0075     uint priority() const;
0076 
0077     /**
0078     * \brief Set the priority of this account.
0079     *
0080     * @note This method is called by the UI, and should not be called elsewhere.
0081     */
0082     void setPriority(uint priority);
0083 
0084     /**
0085     * Return the @ref KConfigGroup used to write and read special properties
0086     *
0087     * "MicroBlog", "UserId", "Username" , "Password", "Priority", "Enabled" are reserved keyword
0088     * already in use in that group.
0089     *
0090     * for compatibility, try to not use key that start with a uppercase
0091     */
0092     KConfigGroup *configGroup() const;
0093 
0094 Q_SIGNALS:
0095     void modified(Choqok::Account *theAccount);
0096     void status(Choqok::Account *theAccount, bool enabled);
0097 
0098 private:
0099     class Private;
0100     std::unique_ptr<Private> d;
0101 };
0102 
0103 }
0104 #endif