2015-11-11 18:50:55 +00:00
|
|
|
#ifndef GPSLOCATION_H
|
|
|
|
#define GPSLOCATION_H
|
|
|
|
|
2015-11-11 23:19:09 +00:00
|
|
|
#include "units.h"
|
2015-11-11 18:52:52 +00:00
|
|
|
#include <QObject>
|
2015-11-11 18:50:55 +00:00
|
|
|
#include <QGeoCoordinate>
|
2015-11-11 18:52:52 +00:00
|
|
|
#include <QGeoPositionInfoSource>
|
|
|
|
#include <QGeoPositionInfo>
|
2015-11-11 23:19:09 +00:00
|
|
|
#include <QSettings>
|
2015-11-14 01:21:43 +00:00
|
|
|
#include <QNetworkReply>
|
2015-11-11 18:50:55 +00:00
|
|
|
|
2016-01-07 08:08:00 +00:00
|
|
|
struct gpsTracker {
|
|
|
|
degrees_t latitude;
|
|
|
|
degrees_t longitude;
|
|
|
|
time_t when;
|
|
|
|
QString name;
|
|
|
|
};
|
|
|
|
|
2015-11-11 18:52:52 +00:00
|
|
|
class GpsLocation : QObject
|
2015-11-11 18:50:55 +00:00
|
|
|
{
|
2015-11-11 18:52:52 +00:00
|
|
|
Q_OBJECT
|
2015-11-11 18:50:55 +00:00
|
|
|
public:
|
2015-11-19 02:10:58 +00:00
|
|
|
GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent);
|
2015-12-02 22:30:47 +00:00
|
|
|
~GpsLocation();
|
|
|
|
static GpsLocation *instance();
|
2015-11-19 03:23:19 +00:00
|
|
|
void applyLocations();
|
2015-11-13 17:17:13 +00:00
|
|
|
int getGpsNum() const;
|
2015-11-18 21:14:19 +00:00
|
|
|
QString getUserid(QString user, QString passwd);
|
2015-11-19 02:56:50 +00:00
|
|
|
bool hasLocationsSource();
|
2016-01-02 01:21:30 +00:00
|
|
|
QString currentPosition();
|
2015-11-11 18:52:52 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QGeoPositionInfo lastPos;
|
2015-11-30 18:58:18 +00:00
|
|
|
QGeoPositionInfoSource *getGpsSource();
|
2016-01-02 01:19:28 +00:00
|
|
|
QGeoPositionInfoSource *m_GpsSource;
|
2015-11-11 19:16:59 +00:00
|
|
|
void status(QString msg);
|
2015-11-13 19:55:39 +00:00
|
|
|
QSettings *geoSettings;
|
2015-11-14 01:21:43 +00:00
|
|
|
QNetworkReply *reply;
|
2015-11-18 22:44:07 +00:00
|
|
|
QString userAgent;
|
2015-11-19 02:10:58 +00:00
|
|
|
void (*showMessageCB)(const char *msg);
|
2015-12-02 22:30:47 +00:00
|
|
|
static GpsLocation *m_Instance;
|
2016-01-02 01:20:30 +00:00
|
|
|
bool waitingForPosition;
|
2015-11-11 18:50:55 +00:00
|
|
|
|
|
|
|
public slots:
|
2015-11-11 20:34:56 +00:00
|
|
|
void serviceEnable(bool toggle);
|
2015-11-11 18:52:52 +00:00
|
|
|
void newPosition(QGeoPositionInfo pos);
|
|
|
|
void updateTimeout();
|
2015-11-14 01:21:43 +00:00
|
|
|
void uploadToServer();
|
2016-01-08 05:32:24 +00:00
|
|
|
void downloadFromServer();
|
2015-11-14 01:21:43 +00:00
|
|
|
void postError(QNetworkReply::NetworkError error);
|
2015-11-18 21:14:19 +00:00
|
|
|
void getUseridError(QNetworkReply::NetworkError error);
|
2015-11-14 01:20:45 +00:00
|
|
|
void clearGpsData();
|
2015-11-14 01:21:43 +00:00
|
|
|
|
2015-11-11 18:50:55 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GPSLOCATION_H
|