~ubuntu-branches/ubuntu/karmic/choqok/karmic

« back to all changes in this revision

Viewing changes to src/backend.h

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi, Alessandro Ghersi, Christian Mangold
  • Date: 2009-08-11 22:29:59 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090811222959-7tnr98ptcnyx3pjg
Tags: 0.6.6-0ubuntu1
[Alessandro Ghersi]
* New upstream release
  - Bump Standards-Version to 3.8.2
  - Long description formatted to fit in 80 characters

[Christian Mangold]
* Improve long description
* Update Maintainer, package is in main now
* Add a watch file

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of Choqok, the KDE micro-blogging client
3
 
 
4
 
    Copyright (C) 2008-2009 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
 
 
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.
19
 
 
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/
22
 
 
23
 
*/
24
 
#ifndef BACKEND_H
25
 
#define BACKEND_H
26
 
#include <QStringList>
27
 
#include <QtCore/QObject>
28
 
#include <QMap>
29
 
#include <KUrl>
30
 
#include "datacontainers.h"
31
 
#include "account.h"
32
 
#include <QDomDocument>
33
 
class KJob;
34
 
namespace KIO {
35
 
    class Job;
36
 
}
37
 
/**
38
 
    @author Mehrdad Momeny <mehrdad.momeny@gmail.com>
39
 
*/
40
 
class Backend : public QObject {
41
 
    Q_OBJECT
42
 
public:
43
 
    enum TimeLineType {HomeTimeLine = 1, ReplyTimeLine, InboxTimeLine, OutboxTimeLine, UserTimeLine};
44
 
    enum DMessageType {Inbox = 1, Outbox};
45
 
    explicit Backend( Account *account, QObject* parent = 0 );
46
 
 
47
 
    ~Backend();
48
 
 
49
 
    void verifyCredential();
50
 
 
51
 
    QDateTime dateFromString( const QString &date );
52
 
    QString& latestErrorString();
53
 
 
54
 
    static QString prepareStatus( QString status );
55
 
    static QString shortenUrl(const QString &baseUrl);
56
 
 
57
 
public slots:
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();
71
 
 
72
 
signals:
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 );
85
 
 
86
 
protected slots:
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&);
101
 
 
102
 
private:
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 );
110
 
 
111
 
    void setDefaultArgs( KUrl &url );
112
 
    void requestCurrentUser();
113
 
    void requestFollowers( int page = 1 );
114
 
    void requestFriends( int page = 1 );
115
 
 
116
 
    QString mLatestErrorString;
117
 
    QMap<KJob *, TimeLineType> mRequestTimelineMap;
118
 
    QMap<KJob *, DMessageType> mRequestDMessagesMap;
119
 
    QMap<KJob *, qulonglong> mRequestSingleStatusMap;
120
 
 
121
 
    QMap<KJob *, QByteArray> mPostNewStatusBuffer;
122
 
    QMap<KJob *, QByteArray> mSendDMessageBuffer;
123
 
    Account *mCurrentAccount;
124
 
    QMap<QString, int> monthes;
125
 
    QStringList followersList;
126
 
    short followersPage;
127
 
    QStringList friendsList;
128
 
    short friendsPage;
129
 
    QString mScheme;
130
 
    QList<KJob*> jobList;
131
 
};
132
 
 
133
 
#endif