X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fsituareservice%2Fsituareservice.h;h=a85127c0f7a8c9114df18f929ebb6a79acc3a41d;hb=5c278b1afcacc9371e8424b6af64b1cdfd233e61;hp=362f72adb34a153e364988cebda2d6ea7237f782;hpb=699f87eff1401e323543f8e279d75e1027d43de1;p=situare diff --git a/src/situareservice/situareservice.h b/src/situareservice/situareservice.h index 362f72a..a85127c 100644 --- a/src/situareservice/situareservice.h +++ b/src/situareservice/situareservice.h @@ -24,14 +24,14 @@ #define SITUARESERVICE_H #include -#include "../facebookservice/facebookcredentials.h" + #include "../user/user.h" #include "imagefetcher.h" class NetworkAccessManager; class QNetworkReply; class QNetworkRequest; -class QPointF; +class GeoCoordinate; class QUrl; /** @@ -74,16 +74,16 @@ public: * * @param coordinates coordinates to be translated */ - void reverseGeo(const QPointF &coordinates); + void reverseGeo(const GeoCoordinate &coordinates); /** * @brief Updates location to the Situare server * * @param coordinates current cordinates * @param status message - * @param publish publish location on Facebook wall (true/false) + * @param publish publish location on Facebook wall */ - void updateLocation(const QPointF &coordinates, const QString &status, const bool &publish); + void updateLocation(const GeoCoordinate &coordinates, const QString &status, const bool &publish); public slots: @@ -94,27 +94,43 @@ public slots: void clearUserData(); /** - * @brief Public slot, which indicates when facebook credentials are ready - * - * @param credentials New credentials - */ - void credentialsReady(const FacebookCredentials &credentials); - - /** * @brief Public slot, which indicates when http request has been completed * * @param reply storage for http reply */ void requestFinished(QNetworkReply *reply); + /** + * @brief Update session data + * + * @param session New session data + */ + void updateSession(const QString &session); + private: /** * @brief Requests ImageFetcher if user/friend has a profile image * uses members: m_user and m_friendsList * + * @param imageUrlList list of image urls */ - void addProfileImages(); + void addProfileImages(const QList &imageUrlList); + + /** + * @brief Append access_token and other session data to the reques url + * + * @param[in,out] requestUrl Request URL with other request parameters and ending to & + */ + void appendAccessToken(QString &requestUrl); + + /** + * @brief Convert coordinate value in degrees (double) to string with enough precision + * + * @param degrees Coordinate value in degrees + * @returns Coordinate value as string + */ + QString degreesToString(double degrees); /** * @brief Forms a http cookie @@ -148,11 +164,11 @@ private: * * @param coordinates current coordinates * @param status optional status message - * @param publish optional publish location on Facebook wall (true/false) + * @param publish optional publish location on Facebook wall * @return QString */ - QString formUrlParameters(const QPointF &coordinates, QString status = QString(), - QString publish = QString()); + QString formUrlParameters(const GeoCoordinate &coordinates, QString status = QString(), + bool publish = false); /** * @brief Parses user and friend data from JSON string @@ -170,9 +186,26 @@ private: */ void sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie); -private slots: + /** + * @brief Build and send request + * + * Appends script pathname and parameters to the server base URL. Access token is appended and + * the request sent if the access token is available, otherwise the request is queued. + * + * @param script Requested script pathname + * @param parameters Hash containing parameter key/value pairs. + */ + void buildRequest(const QString &script, const QHash ¶meters); /** + * @brief Send request + * + * @param requestUrl Request URL containing also all parameters + */ + void sendRequest(const QString &requestUrl); + +private slots: + /** * @brief Slot for received images * * @param url Image url @@ -202,6 +235,13 @@ signals: void fetchImage(const QUrl &url); /** + * @brief Signals when user's/friend's image is downloaded + * + * @param user Instance of user/friend + */ + void imageReady(User *user); + + /** * @brief Signals when address data is retrieved * * @param address Street address @@ -228,22 +268,18 @@ signals: private: - int m_nbrOfImages; ///< Indicates number of friends whose images has been downloaded - int m_visited; ///< Indicates number of friends with images - bool m_defaultImage; ///< Indicates if some of the friends/user doesn't have a image - QList m_currentRequests; ///< List of current http requests - QList m_friendsList; ///< List of friends(User) + QList m_currentRequests; ///< List of current http requests + QList m_requestsWaitingAccessToken; ///< Requests waiting for access_token + QList m_friendsList; ///< List of friends(User) + + QString m_session; ///< Session data - NetworkAccessManager *m_networkManager; ///< Pointer to QNetworkAccessManager + NetworkAccessManager *m_networkManager; ///< Pointer to QNetworkAccessManager - FacebookCredentials m_credentials; ///< handle for FacebookCredentials ImageFetcher *m_imageFetcher; ///< Instance of the image fetcher User *m_user; ///< Pointer to User - - - }; #endif // SITUARESERVICE_H