2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
7 Situare is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 version 2 as published by the Free Software Foundation.
11 Situare is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Situare; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 #ifndef SITUARESERVICE_H
24 #define SITUARESERVICE_H
27 #include "../facebookservice/facebookauthentication.h"
28 #include "../facebookservice/facebookcredentials.h"
29 #include "../user/user.h"
31 class QNetworkAccessManager;
33 class QNetworkRequest;
38 * @brief SituareService class for communicating with Situare server
40 * @author Henri Lampela
41 * @class SituareService situareservice.h "situareservice/situareservice.h"
43 class SituareService : public QObject
50 * @brief Default constructor
52 * @param parent instance of parent
53 * @param manager instance of QNetworkAccessManager
55 SituareService(QObject *parent = 0, QNetworkAccessManager *manager = 0);
64 * @brief Retrieves location user and friends information from Situare server
67 void fetchLocations();
70 * @brief Translates coordinates to street address via Situare server
72 * @param coordinates coordinates to be translated
74 void reverseGeo(const QPointF &coordinates);
77 * @brief Updates location to the Situare server
79 * @param coordinates current cordinates
80 * @param status message
81 * @param publish publish location on Facebook wall (true/false)
83 void updateLocation(const QPointF &coordinates, const QString &status, const bool &publish);
88 * @brief Public slot, which indicates when http request has been completed
90 * @param reply storage for http reply
92 void requestFinished(QNetworkReply *reply);
96 * @brief Public slot, which indicates when facebook credentials are ready
99 void credentialsReady();
104 * @brief Forms a http url
106 * @param baseUrl Server url
107 * @param phpScript Server script
108 * @param urlParameters optional parameters for url
109 * @return QUrl formed url
111 QUrl formUrl(const QString &baseUrl, const QString &phpScript, QString urlParameters = 0);
114 * @brief Forms url parameters
116 * @param coordinates current coordinates
117 * @param status optional status message
118 * @param publish optional publish location on Facebook wall (true/false)
121 QString formUrlParameters(const QPointF &coordinates, QString status = 0, QString publish = 0);
124 * @brief Sends http request
126 * @param url destination
127 * @param cookieType type of the cookie
128 * @param cookie http cookie
130 void sendRequest(const QUrl &url, const QString &cookieType, const QString &cookie);
133 * @brief Parses user and friend data from JSON string
135 * @param jsonReply JSON string
137 void parseUserData(const QByteArray &jsonReply);
142 * @brief Signals error
144 * @param error error message
146 void error(const QString &error);
150 * @brief Signals when user data is retrieved
152 * @param user instance of user
153 * @param friendList list of friends
155 void userDataChanged(User &user, QList<User *> &friendList); // not final
159 FacebookCredentials m_credentials; ///< handle for FacebookCredentials
160 QList<QNetworkReply *> m_currentRequests; ///< List of current http requests
161 FacebookAuthentication m_facebookAuthentication; ///< Pointer to FacebookAuthentication
162 QNetworkAccessManager *m_networkManager; ///< Pointer to QNetworkAccessManager
163 //QList<User *> m_friendList;
167 #endif // SITUARESERVICE_H