00001 #ifndef LOCATION_H_
00002 #define LOCATION_H_
00003
00004
00005 #include <QString>
00006 #include <QByteArray>
00007 #include <QWidget>
00008
00009 #include <QNetworkAccessManager>
00010 #include <QNetworkRequest>
00011 #include <QNetworkReply>
00012
00013 #include <QProgressDialog>
00014
00015 #include <qgeocoordinate.h>
00016 #include <qsysteminfo.h>
00017
00018 #include <wlanscaninfo.h>
00019 #include <wlanmgmtclient.h>
00020
00021 #include "LocationCache.h"
00022 #include "Dummy.h"
00023 #include "Gps.h"
00024 #include "GeoCode.h"
00025
00026
00027 QTM_USE_NAMESPACE
00028
00029
00030
00045 class Location: public QWidget
00046 {
00047 Q_OBJECT
00048 public:
00049 Location(QWidget *parent = 0);
00050 virtual ~Location();
00051 void sendGeoRequest();
00052 void setNbTraces(int nb);
00053 void setMode(int m);
00054 void getLocation();
00055 void resetCache();
00056 void init();
00057 QGeoCoordinate getCacheCenter();
00058 void reinitCache();
00059
00060
00061
00062 public slots:
00063 void recvGeoAnswer(QNetworkReply *networkReply);
00064 void setNoGps(QString reason);
00065 void updateLocation(double lat, double lon);
00066 void setStatus(QString msg);
00067 void setCacheCenter(double lat, double lng);
00068 void updateProgress(QString src);
00069
00070 signals:
00071 void locationReady(QString type, double lat, double lng);
00072 void status(QString msg);
00073 void noLocalization(QString reason);
00074
00075
00076 private:
00077 QList<QPair<QString,uint> > getWifi();
00078 QByteArray getCell();
00079 void requestDummy();
00080
00081 int mode;
00082 LocationCache cache;
00083 Dummy dummy;
00084 QString wifiNets;
00085 QNetworkAccessManager networkManager;
00086 Gps gps;
00087 GeoCode gc;
00088 QProgressDialog qpd;
00089 int progress;
00090
00091 };
00092
00093 #endif