This repository has been archived by the owner on Feb 7, 2018. It is now read-only.
/
core.h
174 lines (137 loc) · 5.13 KB
/
core.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/***************************************************************************
* Copyright (C) 2008-2009 by Dominik Kapusta <d@ayoy.net> *
* Copyright (C) 2009 by Mariusz Pietrzyk <wijet@wijet.pl> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 2.1 of *
* the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this program; if not, write to *
* the Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef CORE_H
#define CORE_H
#include <QTimer>
#include <QMap>
#include <QCache>
#include <twitterapi/twitterapi.h>
#include "accountsmodel.h"
#include "statuslist.h"
class QAbstractItemModel;
class QStringList;
class MainWindow;
class ImageDownload;
class TwitPicEngine;
class StatusModel;
class ThemeData;
class StatusListView;
class AccountsController;
class Core : public QObject
{
Q_OBJECT
public:
enum AuthDialogState {
DialogAccepted,
DialogRejected,
DialogOpen,
DisableAccount,
RemoveAccount
};
enum CheckingForUnread {
CheckForUnread,
DontCheckForUnread
};
Core( QObject *parent = 0 );
bool setTimerInterval( int msecs );
#ifdef Q_WS_X11
void setBrowserPath( const QString& path );
#endif
void setModelTheme( const ThemeData &theme );
void setSettingsOpen( bool open );
QStringList twitpicLogins() const;
inline void incrementRequestCount( CheckingForUnread check = CheckForUnread )
{
if ( m_requestCount == 0 || check == CheckForUnread ) {
m_checkForUnread = check;
emit requestStarted();
}
m_requestCount++;
}
inline void decrementRequestCount()
{
if ( m_requestCount > 0 ) {
m_requestCount--;
}
if ( m_requestCount == 0 ) {
if ( m_checkForUnread == CheckForUnread )
checkUnreadStatuses();
emit resetUi();
m_checkForUnread = CheckForUnread;
}
}
inline int requestCount() { return m_requestCount; }
bool retryAuthorizing( Account *account, int role );
public slots:
void forceGet();
void get();
void get( const QString &serviceUrl, const QString &login, const QString &password );
void post( const QString &serviceUrl, const QString &login, const QString &status, quint64 inReplyTo );
void uploadPhoto( const QString &login, QString photoPath, QString status );
void abortUploadPhoto();
void twitPicResponse( bool responseStatus, QString message, bool newStatus );
void openBrowser( QUrl address );
void resetRequestsCount();
void applySettings();
void setModelData( const QString &serviceUrl, const QString &login );
void retranslateUi();
signals:
void accountsUpdated( const QList<Account> &accounts );
void errorMessage( const QString &message );
void twitPicResponseReceived();
void twitPicDataSendProgress(qint64,qint64);
void requestStarted();
void resetUi();
void pauseIcon();
void timelineUpdated();
void modelChanged( StatusModel *model );
void confirmDMSent( TwitterAPI::SocialNetwork network, const QString &login, TwitterAPI::ErrorCode error );
void sendNewsReport( QString message );
void accountDialogClosed( bool success );
private slots:
void createAccounts( QWidget *view );
AuthDialogState authDataDialog( Account *account );
void setImageForUrl( const QString& url, QPixmap *image );
void slotRequestDone( const QString &serviceUrl, const QString &login, int role );
void setWaitForAccounts( bool wait );
void markEverythingAsRead();
void addAccount();
private:
void storeSession();
void restoreSession();
void setupStatusLists();
void checkUnreadStatuses();
Account* findAccount( const Account &account );
bool authDialogOpen;
int m_requestCount;
CheckingForUnread m_checkForUnread;
bool waitForAccounts;
bool settingsOpen;
TwitPicEngine *twitpicUpload;
AccountsController *accounts;
AccountsModel *accountsModel;
QMap<Account*,StatusList*> statusLists;
QTimer *timer;
#ifdef Q_WS_X11
QString browserPath;
#endif
friend class QTwitterApp;
};
#endif //CORE_H