1 /*
2     This file is part of Choqok, the KDE micro-blogging client
3 
4     Copyright (C) 2010-2012 Mehrdad Momeny <mehrdad.momeny@gmail.com>
5 
6     This program is free software; you can redistribute it and/or
7     modify it under the terms of the GNU General Public License as
8     published by the Free Software Foundation; either version 2 of
9     the License or (at your option) version 3 or any later version
10     accepted by the membership of KDE e.V. (or its successor approved
11     by the membership of KDE e.V.), which shall act as a proxy
12     defined in Section 14 of version 3 of the license.
13 
14     This program is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     GNU General Public License for more details.
18 
19     You should have received a copy of the GNU General Public License
20     along with this program; if not, see http://www.gnu.org/licenses/
21 */
22 
23 #ifndef OCSMICROBLOG_H
24 #define OCSMICROBLOG_H
25 #include "microblog.h"
26 
27 #include <Attica/Activity>
28 
29 class OCSAccount;
30 namespace Attica
31 {
32 class ProviderManager;
33 class BaseJob;
34 }
35 
36 class OCSMicroblog : public Choqok::MicroBlog
37 {
38     Q_OBJECT
39 public:
40     OCSMicroblog(QObject *parent, const QVariantList &args);
41     ~OCSMicroblog();
42 
43     virtual ChoqokEditAccountWidget *createEditAccountWidget(Choqok::Account *account, QWidget *parent) override;
44     virtual void createPost(Choqok::Account *theAccount, Choqok::Post *post) override;
45     virtual void abortCreatePost(Choqok::Account *theAccount, Choqok::Post *post = nullptr) override;
46     virtual void fetchPost(Choqok::Account *theAccount, Choqok::Post *post) override;
47     virtual void removePost(Choqok::Account *theAccount, Choqok::Post *post) override;
48     virtual void saveTimeline(Choqok::Account *account, const QString &timelineName,
49                               const QList< Choqok::UI::PostWidget * > &timeline) override;
50     virtual QList< Choqok::Post * > loadTimeline(Choqok::Account *account, const QString &timelineName) override;
51     virtual Choqok::Account *createNewAccount(const QString &alias) override;
52     virtual void updateTimelines(Choqok::Account *theAccount) override;
53     virtual Choqok::TimelineInfo *timelineInfo(const QString &timelineName) override;
54 
55     virtual QUrl profileUrl(Choqok::Account *account, const QString &username) const override;
56 
57     Attica::ProviderManager *providerManager();
58 
59     bool isOperational();
60     virtual void aboutToUnload() override;
61 
62 Q_SIGNALS:
63     void initialized();
64 
65 protected Q_SLOTS:
66     void slotTimelineLoaded(Attica::BaseJob *);
67     void slotCreatePost(Attica::BaseJob *);
68     void slotDefaultProvidersLoaded();
69 
70 private:
71     enum Task {Update};
72     QList <Choqok::Post *> parseActivityList(const Attica::Activity::List &list);
73     Attica::ProviderManager *mProviderManager;
74     QMap<Attica::BaseJob *, OCSAccount *> mJobsAccount;
75     QMap<Attica::BaseJob *, Choqok::Post *> mJobsPost;
76     QMultiMap<Choqok::Account *, Task> scheduledTasks;
77     bool mIsOperational;
78 };
79 
80 #endif // OCSMICROBLOG_H
81