2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
6 Sami Rämö - sami.ramo@ixonos.com
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
23 #ifndef ROUTINGSERVICE_H
24 #define ROUTINGSERVICE_H
32 class QNetworkRequest;
36 class NetworkAccessManager;
39 * @brief RoutingService class for communicating with CloudMade server
40 * and parsing routing data
42 * @author Henri Lampela - henri.lampela@ixonos.com
43 * @author Sami Rämö - sami.ramo@ixonos.com
45 class RoutingService : public QObject
51 * @brief Default constructor
53 * @param parent instance of parent
55 RoutingService(QObject *parent = 0);
57 /*******************************************************************************
58 * MEMBER FUNCTIONS AND SLOTS
59 ******************************************************************************/
62 * @brief Public slot, which indicates when http request has been completed
64 * @param reply storage for http reply
66 void requestFinished(QNetworkReply *reply);
69 * @brief Request routing information from the server
71 * @param from Start point of the route
72 * @param to End point of the route
74 void requestRoute(const GeoCoordinate &from, const GeoCoordinate &to);
77 * @brief Request location information from the server
79 * @param location location (address, city etc.)
81 void requestLocation(const QString &location);
85 * @brief Parses routing data from JSON string
87 * @param jsonReply JSON string
89 void parseRouteData(const QByteArray &jsonReply);
92 * @brief Parses location data from JSON string
94 * @param jsonReply JSON string
96 void parseSearchResults(const QByteArray &jsonReply);
99 * @brief Request authorization token
102 void requestAuthorizationToken();
105 * @brief Sends http request
107 * @param url destination
109 void sendRequest(const QUrl &url);
111 /*******************************************************************************
113 ******************************************************************************/
116 * @brief Signals error
118 * @param context error context
119 * @param error error code
121 void error(const int context, const int error);
124 * @brief Emited when route is parsed and is ready for further processing
126 * @param route Route item containing parsed route details
128 void routeParsed(Route &route);
131 * @brief Emited when location request is parsed and is ready for further processing
133 * @param result List of Location items
135 void locationDataParsed(QList<Location> &result);
137 /*******************************************************************************
139 ******************************************************************************/
141 QList<QNetworkReply *> m_currentRequests; ///< List of current http requests
142 QList<Location> m_searchResults; ///< List of search results
144 QString m_pendingRequest; ///< Placeholder for pending route request
145 QString m_token; ///< Placeholder for authentication token
147 NetworkAccessManager *m_networkManager; ///< Pointer to QNetworkAccessManager
150 #endif // ROUTINGSERVICE_H