00001 /* 00002 Situare - A location system for Facebook 00003 Copyright (C) 2010 Ixonos Plc. Authors: 00004 00005 Henri Lampela - henri.lampela@ixonos.com 00006 Sami Rämö - sami.ramo@ixonos.com 00007 00008 Situare is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License 00010 version 2 as published by the Free Software Foundation. 00011 00012 Situare is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with Situare; if not, write to the Free Software 00019 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 00020 USA. 00021 */ 00022 00023 #ifndef ROUTINGSERVICE_H 00024 #define ROUTINGSERVICE_H 00025 00026 #include <QObject> 00027 00028 class QNetworkReply; 00029 class QUrl; 00030 00031 class GeoCoordinate; 00032 class NetworkAccessManager; 00033 class Route; 00034 00042 class RoutingService : public QObject 00043 { 00044 Q_OBJECT 00045 00046 public: 00052 RoutingService(QObject *parent = 0); 00053 00054 /******************************************************************************* 00055 * MEMBER FUNCTIONS AND SLOTS 00056 ******************************************************************************/ 00057 public slots: 00063 void requestFinished(QNetworkReply *reply); 00064 00071 void requestRoute(const GeoCoordinate &from, const GeoCoordinate &to); 00072 00073 private: 00079 void parseRouteData(const QByteArray &jsonReply); 00080 00085 void requestAuthorizationToken(); 00086 00092 void sendRequest(const QUrl &url); 00093 00094 /******************************************************************************* 00095 * SIGNALS 00096 ******************************************************************************/ 00097 signals: 00104 void error(const int context, const int error); 00105 00111 void routeParsed(Route &route); 00112 00113 /******************************************************************************* 00114 * DATA MEMBERS 00115 ******************************************************************************/ 00116 private: 00117 QString m_pendingRequest; 00118 QString m_token; 00119 00120 NetworkAccessManager *m_networkManager; 00121 }; 00122 00123 #endif // ROUTINGSERVICE_H