2
This file is part of Choqok, the KDE micro-blogging client
4
Copyright (C) 2008-2009 Mehrdad Momeny <mehrdad.momeny@gmail.com>
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.
15
This program is distributed in the hope that it will be useful,
16
but WITHOUT ANY WARRANTY; without even the implied warranty of
17
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
GNU General Public License for more details.
20
You should have received a copy of the GNU General Public License
21
along with this program; if not, see http://www.gnu.org/licenses/
26
#include <QStringList>
27
#include <QtCore/QObject>
30
#include "datacontainers.h"
32
#include <QDomDocument>
38
@author Mehrdad Momeny <mehrdad.momeny@gmail.com>
40
class Backend : public QObject {
43
enum TimeLineType {HomeTimeLine = 1, ReplyTimeLine, InboxTimeLine, OutboxTimeLine, UserTimeLine};
44
enum DMessageType {Inbox = 1, Outbox};
45
explicit Backend( Account *account, QObject* parent = 0 );
49
void verifyCredential();
51
QDateTime dateFromString( const QString &date );
52
QString& latestErrorString();
54
static QString prepareStatus( QString status );
55
static QString shortenUrl(const QString &baseUrl);
58
void postNewStatus( const QString &statusMessage, qulonglong replyToStatusId = 0 );
59
void twitPicCreatePost(const KUrl &picUrl, const QString &message);
60
void sendDMessage( const QString &screenName, const QString &message );
61
void requestTimeLine( qulonglong latestStatusId, TimeLineType type, int page = 0 );
62
void requestDMessages( qulonglong latestStatusId, DMessageType type, int page = 0 );
63
void requestSingleStatus( qulonglong statusId );
64
void requestFavorited( qulonglong statusId, bool isFavorite );
65
void requestDestroy( qulonglong statusId );
66
void requestDestroyDMessage( qulonglong statusId );
67
void abortPostNewStatus();
68
void settingsChanged();
69
void listFollowersScreenName();
70
void listFriendsScreenName();
73
void sigPostNewStatusDone( bool isError );
74
void sigFavoritedDone( bool isError );
75
void sigDestroyDone( bool isError );
76
void sigError( const QString &errMsg );
77
void homeTimeLineReceived( QList<Status> &statusList );
78
void replyTimeLineReceived( QList<Status> &statusList );
79
void userVerified( Account *userAccount );
80
void directMessagesReceived( QList<Status> &msgList );
81
void outboxMessagesReceived( QList<Status> &msgList );
82
void followersListed( const QStringList &followersList );
83
void friendsListed( const QStringList &friendsList );
84
void singleStatusReceived( Status status );
87
void slotListFollowersScreenName( KJob *job );
88
void slotListFriendsScreenName( KJob *job );
89
void slotPostNewStatusFinished( KJob *job );
90
void slotPostNewStatusData(KIO::Job *job, const QByteArray &data);
91
void slotTwitPicCreatePost( KJob *job );
92
void slotRequestTimelineFinished( KJob *job );
93
void slotRequestFavoritedFinished( KJob *job );
94
void slotRequestDestroyFinished( KJob *job );
95
void slotUserInfoReceived( KJob *job );
96
void slotCredentialsReceived( KJob *job );
97
void slotRequestDMessagesFinished( KJob *job );
98
void slotRequestSingleStatusFinished( KJob* );
99
void slotSendDMessageFinished( KJob* );
100
void slotSendDMessageData(KIO::Job*, const QByteArray&);
103
QStringList readUsersNameFromXml( const QByteArray &buffer );
104
Status readStatusFromXml ( const QByteArray &buffer );
105
Status readStatusFromDomElement ( const QDomElement &root );
106
QList<Status> readTimelineFromXml ( const QByteArray &buffer );
107
Status readDMessageFromXml ( const QByteArray &buffer );
108
Status readDMessageFromDomElement ( const QDomElement &root );
109
QList<Status> readDMessagesFromXml ( const QByteArray &buffer );
111
void setDefaultArgs( KUrl &url );
112
void requestCurrentUser();
113
void requestFollowers( int page = 1 );
114
void requestFriends( int page = 1 );
116
QString mLatestErrorString;
117
QMap<KJob *, TimeLineType> mRequestTimelineMap;
118
QMap<KJob *, DMessageType> mRequestDMessagesMap;
119
QMap<KJob *, qulonglong> mRequestSingleStatusMap;
121
QMap<KJob *, QByteArray> mPostNewStatusBuffer;
122
QMap<KJob *, QByteArray> mSendDMessageBuffer;
123
Account *mCurrentAccount;
124
QMap<QString, int> monthes;
125
QStringList followersList;
127
QStringList friendsList;
130
QList<KJob*> jobList;