File indexing completed on 2024-05-05 04:57:28
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 TWITTERMICROBLOGPLUGIN_H 0010 #define TWITTERMICROBLOGPLUGIN_H 0011 0012 #include <QPointer> 0013 0014 #include "twitterapimicroblog.h" 0015 0016 #include "twitterlist.h" 0017 0018 class TwitterAccount; 0019 class TwitterSearch; 0020 class ChoqokEditAccountWidget; 0021 class KJob; 0022 0023 /** 0024 @author Mehrdad Momeny \<mehrdad.momeny@gmail.com\> 0025 */ 0026 class TwitterMicroBlog : public TwitterApiMicroBlog 0027 { 0028 Q_OBJECT 0029 public: 0030 TwitterMicroBlog(QObject *parent, const QVariantList &args); 0031 ~TwitterMicroBlog(); 0032 0033 virtual Choqok::Account *createNewAccount(const QString &alias) override; 0034 virtual ChoqokEditAccountWidget *createEditAccountWidget(Choqok::Account *account, QWidget *parent) override; 0035 virtual Choqok::UI::MicroBlogWidget *createMicroBlogWidget(Choqok::Account *account, QWidget *parent) override; 0036 virtual Choqok::UI::TimelineWidget *createTimelineWidget(Choqok::Account *account, 0037 const QString &timelineName, QWidget *parent) override; 0038 virtual Choqok::UI::PostWidget *createPostWidget(Choqok::Account *account, 0039 Choqok::Post *post, QWidget *parent) override; 0040 virtual Choqok::UI::ComposerWidget *createComposerWidget(Choqok::Account *account, QWidget *parent) override; 0041 0042 virtual QUrl postUrl(Choqok::Account *account, const QString &username, const QString &postId) const override; 0043 0044 virtual QUrl profileUrl(Choqok::Account *account, const QString &username) const override; 0045 0046 virtual void fetchPost(Choqok::Account *theAccount, Choqok::Post *post) override; 0047 0048 virtual TwitterApiSearch *searchBackend() override; 0049 0050 virtual QString generateRepeatedByUserTooltip(const QString &username) override; 0051 virtual QString repeatQuestion() override; 0052 virtual QMenu *createActionsMenu(Choqok::Account *theAccount, QWidget *parent = Choqok::UI::Global::mainWindow()) override; 0053 0054 void fetchUserLists(TwitterAccount *theAccount, const QString &username); 0055 void addListTimeline(TwitterAccount *theAccount, const QString &username, const QString &listname); 0056 void setListTimelines(TwitterAccount *theAccount, const QStringList &lists); 0057 0058 virtual Choqok::TimelineInfo *timelineInfo(const QString &timelineName) override; 0059 0060 void createPostWithAttachment(Choqok::Account *theAccount, Choqok::Post *post, const QString &mediumToAttach = QString()); 0061 0062 void verifyCredentials(TwitterAccount *theAccount); 0063 0064 Q_SIGNALS: 0065 void userLists(Choqok::Account *theAccount, const QString &username, QList<Twitter::List> lists); 0066 0067 public Q_SLOTS: 0068 virtual void showDirectMessageDialog(TwitterApiAccount *theAccount = nullptr, 0069 const QString &toUsername = QString()) override; 0070 0071 protected Q_SLOTS: 0072 void showListDialog(TwitterApiAccount *theAccount = nullptr); 0073 void slotFetchUserLists(KJob *job); 0074 void slotFetchVerifyCredentials(KJob *job); 0075 0076 protected: 0077 virtual void requestTimeLine(Choqok::Account *theAccount, QString timelineName, 0078 QString sincePostId, int page = 1, QString maxId = QString()) override; 0079 using TwitterApiMicroBlog::readDirectMessage; 0080 virtual Choqok::Post *readDirectMessage(Choqok::Account *theAccount, const QVariantMap &var) override; 0081 using TwitterApiMicroBlog::readPost; 0082 virtual Choqok::Post *readPost(Choqok::Account *account, const QVariantMap &var, Choqok::Post *post) override; 0083 void setTimelineInfos() override; 0084 0085 QList<Twitter::List> readUserListsFromJson(Choqok::Account *theAccount, QByteArray buffer); 0086 Twitter::List readListFromJsonMap(Choqok::Account *theAccount, QVariantMap map); 0087 QMap<KJob *, QString> mFetchUsersListMap; 0088 0089 private: 0090 QPointer<TwitterSearch> mSearchBackend; 0091 QMap<QString, Choqok::TimelineInfo *> mListsInfo; 0092 }; 0093 0094 #endif