1 // Copyright 2010 Jochen Becher
3 // This file is part of MovieSchedule.
5 // MovieSchedule is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // MovieSchedule is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with MovieSchedule. If not, see <http://www.gnu.org/licenses/>.
21 #include "searchclientsemaphore.h"
25 #include <QNetworkReply>
27 class QNetworkAccessManager;
29 #ifdef QT_MOBILITY_LOCATION
30 #include <qmobilityglobal.h>
33 class QGeoPositionInfo;
34 class QGeoPositionInfoSource;
42 #include <location/location-gps-device.h>
43 #include <location/location-gpsd-control.h>
48 class GpsClient : public QObject
52 static const int INVALID_SEARCH_TASK_ID = -1;
59 int GetSearchTaskId() const { return _search_task_id; }
61 void SearchLocation();
63 static void CancelAllRunningSearchs();
66 Q_SIGNAL void SearchStarted(int search_task_id);
67 Q_SIGNAL void PositionUpdate(int search_task_id);
68 Q_SIGNAL void SearchForTownStarted(int search_task_id);
69 Q_SIGNAL void TownUpdate(int search_task_id, QString town);
70 Q_SIGNAL void SearchError(int search_task_id);
71 Q_SIGNAL void SearchFinished(int search_task_id, bool success);
74 #ifdef QT_MOBILITY_LOCATION
75 Q_SLOT void GeoPositionUpdated(const QGeoPositionInfo &);
76 Q_SLOT void GeoPositionTimedOut();
83 void GpsDisconnected();
84 Q_SLOT void GpsTimedOut();
88 void SearchTown(const QString &longitude, const QString &latitude);
89 Q_SLOT void ReplyFinished(QNetworkReply *);
90 Q_SLOT void NetworkError(QNetworkReply::NetworkError);
93 #ifdef QT_MOBILITY_LOCATION
94 QGeoPositionInfoSource *_geo_position_info_source;
98 LocationGPSDControl *_location_gpsd_control;
99 LocationGPSDevice *_location_gps_device;
100 QTimer *_time_out_timer;
103 QNetworkAccessManager *_network;
104 static QMutex _next_search_task_id_mutex;
105 static int _next_search_task_id;
107 static SearchClientSemaphore _semaphore;
110 #endif // GPSCLIENT_H