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 GeoCoordinate;
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 GeoCoordinate &coordinates);
00078
00086 void updateLocation(const GeoCoordinate &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
00118 void addProfileImages(const QList<QUrl> &imageUrlList);
00119
00132 QString formCookie(const QString &apiKeyValue, QString expiresValue, QString userValue,
00133 QString sessionKeyValue, QString sessionSecretValue,
00134 const QString &signatureValue, const QString &localeValue);
00135
00144 QUrl formUrl(const QString &baseUrl, const QString &phpScript,
00145 QString urlParameters = QString());
00146
00155 QString formUrlParameters(const GeoCoordinate &coordinates, QString status = QString(),
00156 bool publish = false);
00157
00163 void parseUserData(const QByteArray &jsonReply);
00164
00172 void sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie);
00173
00174 private slots:
00175
00182 void imageReceived(const QUrl &url, const QPixmap &image);
00183
00184
00185
00186
00187
00188 signals:
00189
00196 void error(const int context, const int error);
00197
00203 void fetchImage(const QUrl &url);
00204
00210 void imageReady(User *user);
00211
00217 void reverseGeoReady(const QString &address);
00218
00223 void updateWasSuccessful();
00224
00231 void userDataChanged(User *user, QList<User *> &friendList);
00232
00233
00234
00235
00236
00237 private:
00238
00239 bool m_defaultImage;
00240
00241 QList<QNetworkReply *> m_currentRequests;
00242 QList<User *> m_friendsList;
00243
00244 NetworkAccessManager *m_networkManager;
00245
00246 FacebookCredentials m_credentials;
00247 ImageFetcher *m_imageFetcher;
00248 User *m_user;
00249 };
00250
00251 #endif // SITUARESERVICE_H