Changeset View
Changeset View
Standalone View
Standalone View
ktorrent-5.1.1/plugins/infowidget/geoipmanager.h
1 | /*************************************************************************** | 1 | /*************************************************************************** | ||
---|---|---|---|---|---|
2 | * Copyright (C) 2009 by Joris Guisson * | 2 | * Copyright (C) 2009 by Joris Guisson * | ||
3 | * joris.guisson@gmail.com * | 3 | * joris.guisson@gmail.com * | ||
4 | * Copyright (C) 2019 by Bernhard "Bero" Rosenkraenzer <bero@lindev.ch> * | ||||
4 | * * | 5 | * * | ||
5 | * This program is free software; you can redistribute it and/or modify * | 6 | * This program 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 | * it under the terms of the GNU General Public License as published by * | ||
Context not available. | |||||
25 | #include <QThread> | 26 | #include <QThread> | ||
26 | #include <QUrl> | 27 | #include <QUrl> | ||
27 | 28 | | |||
28 | #ifdef USE_SYSTEM_GEOIP | 29 | #ifdef HAVE_MAXMINDDB | ||
29 | #include <GeoIP.h> | 30 | #include <maxminddb.h> | ||
30 | #else | | |||
31 | #include "GeoIP.h" | | |||
32 | #endif | | |||
33 | 31 | | |||
34 | class KJob; | 32 | class KJob; | ||
35 | 33 | class KArchiveDirectory; | |||
36 | namespace bt | 34 | #endif | ||
37 | { | | |||
38 | class DecompressThread; | | |||
39 | } | | |||
40 | 35 | | |||
41 | namespace kt | 36 | namespace kt | ||
42 | { | 37 | { | ||
38 | #ifdef HAVE_MAXMINDDB | ||||
39 | class UntarThread : public QThread | ||||
40 | { | ||||
41 | Q_OBJECT | ||||
42 | public: | ||||
43 | UntarThread(QString srcFile, QString destFile, QObject *parent=nullptr):QThread(parent),src(srcFile),dest(destFile) {} | ||||
44 | protected: | ||||
45 | void run() override; | ||||
46 | private: | ||||
47 | void scanDir(const KArchiveDirectory *dir); | ||||
48 | | ||||
49 | QString src; | ||||
50 | QString dest; | ||||
51 | }; | ||||
52 | #endif | ||||
43 | 53 | | |||
44 | 54 | | |||
45 | /** | 55 | /** | ||
Context not available. | |||||
57 | * @param addr The IP address | 67 | * @param addr The IP address | ||
58 | * @return The country ID | 68 | * @return The country ID | ||
59 | */ | 69 | */ | ||
60 | int findCountry(const QString& addr); | 70 | QString findCountry(const QString& addr); | ||
61 | | ||||
62 | /** | | |||
63 | * Get the name of the country | | |||
64 | * @param country_id The country ID | | |||
65 | * @return The name | | |||
66 | */ | | |||
67 | QString countryName(int country_id); | | |||
68 | 71 | | |||
69 | /** | 72 | /** | ||
70 | * Get the code of the country | 73 | * Get the code of the country | ||
71 | * @param country_id The country ID | 74 | * @param addr The IP address | ||
72 | * @return The name | 75 | * @return The name | ||
73 | */ | 76 | */ | ||
74 | QString countryCode(int country_id); | 77 | QString countryCode(const QString& addr); | ||
75 | 78 | | |||
79 | #ifdef HAVE_MAXMINDDB | ||||
76 | /// Get the database URL | 80 | /// Get the database URL | ||
77 | static QUrl geoIPUrl() {return geoip_url;} | 81 | static QUrl geoIPUrl() {return geoip_url;} | ||
78 | 82 | | |||
Context not available. | |||||
87 | void decompressFinished(); | 91 | void decompressFinished(); | ||
88 | 92 | | |||
89 | private: | 93 | private: | ||
90 | GeoIP* geo_ip; | 94 | MMDB_s geo_ip; | ||
91 | QString geoip_data_file; | 95 | QString geoip_data_file; | ||
92 | QString download_destination; | 96 | QString download_destination; | ||
93 | bt::DecompressThread* decompress_thread; | 97 | UntarThread* untar_thread; | ||
94 | static QUrl geoip_url; | 98 | static QUrl geoip_url; | ||
99 | #endif | ||||
95 | }; | 100 | }; | ||
96 | 101 | | |||
97 | 102 | | |||
Context not available. |