GeoIpResolver.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _GEOIPRESOLVER_H
00018 #define _GEOIPRESOLVER_H
00019
00020 #include "GeoIpCache.h"
00021
00022 #include <QObject>
00023 #include <QList>
00024 #include <QHash>
00025 #include <QHostAddress>
00026
00027 class GeoIp;
00028 class GeoIpRequest;
00029 class GeoIpResponse;
00030 class QString;
00031 class QAbstractSocket;
00032
00033
00034 class GeoIpResolver : public QObject
00035 {
00036 Q_OBJECT
00037
00038 public:
00039
00040 GeoIpResolver(QObject *parent = 0);
00041
00042
00043
00044 void setSocksHost(const QHostAddress &addr, quint16 port);
00045
00046 int resolve(const QHostAddress &ip);
00047
00048 int resolve(const QList<QHostAddress> &ips);
00049
00050 bool resolveFromCache(const QHostAddress &ip);
00051
00052
00053 QList<QHostAddress> resolveFromCache(const QList<QHostAddress> &ips);
00054
00055 signals:
00056
00057 void resolved(int id, const QList<GeoIp> &geoips);
00058
00059 void resolveFailed(int id, const QString &errorString);
00060
00061 private slots:
00062
00063 void connected();
00064
00065 void disconnected();
00066
00067 void socketError(const QString &errorString);
00068
00069 private:
00070
00071 GeoIpRequest* createRequest(const QList<QHostAddress> &ips);
00072
00073 void parseGeoIpResponse(const QByteArray &response, GeoIpRequest *request);
00074
00075
00076 GeoIpCache* _cache;
00077
00078 QHash<QAbstractSocket *,GeoIpRequest*> _requestList;
00079
00080 QHostAddress _socksAddr;
00081
00082 quint16 _socksPort;
00083 };
00084
00085 #endif
00086