00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SITUARESERVICE_H
00024 #define SITUARESERVICE_H
00025
00026 #include <QObject>
00027 #include "../facebookservice/facebookcredentials.h"
00028 #include "../user/user.h"
00029 #include "imagefetcher.h"
00030
00031 class NetworkAccessManager;
00032 class QNetworkReply;
00033 class QNetworkRequest;
00034 class QPointF;
00035 class QUrl;
00036
00043 class SituareService : public QObject
00044 {
00045 Q_OBJECT
00046
00047 public:
00048
00054 SituareService(QObject *parent = 0);
00055
00060 ~SituareService();
00061
00062
00063
00064
00065
00070 void fetchLocations();
00071
00077 void reverseGeo(const QPointF &coordinates);
00078
00086 void updateLocation(const QPointF &coordinates, const QString &status, const bool &publish);
00087
00088 public slots:
00089
00094 void clearUserData();
00095
00101 void credentialsReady(const FacebookCredentials &credentials);
00102
00108 void requestFinished(QNetworkReply *reply);
00109
00110 private:
00111
00117 void addProfileImages();
00118
00131 QString formCookie(const QString &apiKeyValue, QString expiresValue, QString userValue,
00132 QString sessionKeyValue, QString sessionSecretValue,
00133 const QString &signatureValue, const QString &localeValue);
00134
00143 QUrl formUrl(const QString &baseUrl, const QString &phpScript,
00144 QString urlParameters = QString());
00145
00154 QString formUrlParameters(const QPointF &coordinates, QString status = QString(),
00155 QString publish = QString());
00156
00162 void parseUserData(const QByteArray &jsonReply);
00163
00171 void sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie);
00172
00173 private slots:
00174
00181 void imageReceived(const QUrl &url, const QPixmap &image);
00182
00183
00184
00185
00186
00187 signals:
00188
00194 void error(const QString &error);
00195
00201 void fetchImage(const QUrl &url);
00202
00208 void reverseGeoReady(const QString &address);
00209
00214 void updateWasSuccessful();
00215
00222 void userDataChanged(User *user, QList<User *> &friendList);
00223
00224
00225
00226
00227
00228 private:
00229
00230 int m_nbrOfImages;
00231 int m_visited;
00232
00233 bool m_defaultImage;
00234
00235 QList<QNetworkReply *> m_currentRequests;
00236 QList<User *> m_friendsList;
00237
00238 NetworkAccessManager *m_networkManager;
00239
00240 FacebookCredentials m_credentials;
00241 ImageFetcher *m_imageFetcher;
00242 User *m_user;
00243
00244
00245
00246 };
00247
00248 #endif // SITUARESERVICE_H