mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-22 12:34:19 +00:00
- No longer ships GeoIP database since most distributions provide it in a separate package
- GeoIP database is no longer embedded in qBittorrent executable unless --with-geoip-database-embedded parameter is passed to configure (see src/geoip/REAME) - Dropped "CONFIG += x11 network" in project file since it does not seem to be required - Updated configure file to reflect Geoip changes
This commit is contained in:
parent
8df1708491
commit
968a5f3017
5
AUTHORS
5
AUTHORS
@ -12,11 +12,6 @@ Code from other projects:
|
||||
copyright: Malte Starostik <malte@kde.org>
|
||||
license: LGPL
|
||||
|
||||
GeoIP database author:
|
||||
* files: src/geoip/GeoIP.dat
|
||||
copyright: MaxMind, Inc (http://maxmind.com/)
|
||||
license: Open Data License (see src/geoip/LICENSE.txt)
|
||||
|
||||
Images Authors:
|
||||
* files: src/Icons/*.png
|
||||
copyright: Gnome Icon Theme
|
||||
|
55
configure
vendored
55
configure
vendored
@ -18,8 +18,12 @@ Main options:
|
||||
--help This help text.
|
||||
|
||||
Dependency options:
|
||||
--with-libboost-inc=[path] Path to libboost include files
|
||||
--disable-libnotify Disable use of libnotify
|
||||
--with-libboost-inc=[path] Path to libboost include files
|
||||
--disable-libnotify Disable use of libnotify
|
||||
--disable-geoip-database Disable use of geoip-database
|
||||
--with-geoip-database-embedded Geoip Database will be embedded in
|
||||
qBittorrent executable (please follow
|
||||
instructions in src/geoip/README)
|
||||
|
||||
EOT
|
||||
}
|
||||
@ -146,6 +150,16 @@ while [ $# -gt 0 ]; do
|
||||
shift
|
||||
;;
|
||||
|
||||
--disable-geoip-database)
|
||||
QC_DISABLE_geoip_database="Y"
|
||||
shift
|
||||
;;
|
||||
|
||||
--with-geoip-database-embedded)
|
||||
QC_WITH_GEOIP_DATABASE_EMBEDDED="Y"
|
||||
shift
|
||||
;;
|
||||
|
||||
--verbose)
|
||||
QC_VERBOSE="Y"
|
||||
shift
|
||||
@ -169,6 +183,8 @@ echo DATADIR=$DATADIR
|
||||
echo EX_QTDIR=$EX_QTDIR
|
||||
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
|
||||
echo QC_DISABLE_libnotify=$QC_DISABLE_libnotify
|
||||
echo QC_DISABLE_geoip_database=$QC_DISABLE_geoip_database
|
||||
echo QC_WITH_GEOIP_DATABASE_EMBEDDED=$QC_WITH_GEOIP_DATABASE_EMBEDDED
|
||||
echo
|
||||
fi
|
||||
|
||||
@ -422,6 +438,36 @@ public:
|
||||
return true;
|
||||
}
|
||||
};
|
||||
#line 1 "geoip-database.qcm"
|
||||
/*
|
||||
-----BEGIN QCMOD-----
|
||||
name: geoip-database
|
||||
arg: with-geoip-database-embedded, Geoip Database will be embedded in qBittorrent executable (please follow instructions in src/geoip/README)
|
||||
-----END QCMOD-----
|
||||
*/
|
||||
// see Conf::findPkgConfig
|
||||
class qc_geoip_database : public ConfObj
|
||||
{
|
||||
public:
|
||||
qc_geoip_database(Conf *c) : ConfObj(c) {}
|
||||
QString name() const { return "GeoIP Database (optional)"; }
|
||||
QString shortname() const { return "GeoIP Database"; }
|
||||
bool exec() {
|
||||
#ifdef Q_WS_X11
|
||||
if(!conf->getenv("QC_WITH_GEOIP_DATABASE_EMBEDDED").isEmpty()) {
|
||||
#endif
|
||||
conf->addDefine("WITH_GEOIP_EMBEDDED");
|
||||
printf(" embedded and");
|
||||
return true;
|
||||
#ifdef Q_WS_X11
|
||||
}
|
||||
if(QFile::exists("/usr/share/GeoIP/GeoIP.dat") || QFile::exists("/usr/local/share/GeoIP/GeoIP.dat"))
|
||||
return true;
|
||||
printf("\nWarning: GeoIP database was not found at /usr/share/GeoIP/GeoIP.dat\nCountry resolution will be slow.");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
EOT
|
||||
cat >$1/modules_new.cpp <<EOT
|
||||
@ -437,6 +483,9 @@ cat >$1/modules_new.cpp <<EOT
|
||||
o = new qc_libnotify(conf);
|
||||
o->required = false;
|
||||
o->disabled = false;
|
||||
o = new qc_geoip_database(conf);
|
||||
o->required = false;
|
||||
o->disabled = false;
|
||||
|
||||
EOT
|
||||
cat >$1/conf4.h <<EOT
|
||||
@ -1384,6 +1433,8 @@ export DATADIR
|
||||
export EX_QTDIR
|
||||
export QC_WITH_LIBBOOST_INC
|
||||
export QC_DISABLE_libnotify
|
||||
export QC_DISABLE_geoip_database
|
||||
export QC_WITH_GEOIP_DATABASE_EMBEDDED
|
||||
export QC_VERBOSE
|
||||
rm -rf .qconftemp
|
||||
(
|
||||
|
@ -14,4 +14,6 @@
|
||||
</dep>
|
||||
<dep type='libnotify'>
|
||||
</dep>
|
||||
<dep type='geoip-database'>
|
||||
</dep>
|
||||
</qconf>
|
||||
|
29
qcm/geoip-database.qcm
Normal file
29
qcm/geoip-database.qcm
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
-----BEGIN QCMOD-----
|
||||
name: geoip-database
|
||||
arg: with-geoip-database-embedded, Geoip Database will be embedded in qBittorrent executable (please follow instructions in src/geoip/README)
|
||||
-----END QCMOD-----
|
||||
*/
|
||||
// see Conf::findPkgConfig
|
||||
class qc_geoip_database : public ConfObj
|
||||
{
|
||||
public:
|
||||
qc_geoip_database(Conf *c) : ConfObj(c) {}
|
||||
QString name() const { return "GeoIP Database (optional)"; }
|
||||
QString shortname() const { return "GeoIP Database"; }
|
||||
bool exec() {
|
||||
#ifdef Q_WS_X11
|
||||
if(!conf->getenv("QC_WITH_GEOIP_DATABASE_EMBEDDED").isEmpty()) {
|
||||
#endif
|
||||
conf->addDefine("WITH_GEOIP_EMBEDDED");
|
||||
printf(" embedded and");
|
||||
return true;
|
||||
#ifdef Q_WS_X11
|
||||
}
|
||||
if(QFile::exists("/usr/share/GeoIP/GeoIP.dat") || QFile::exists("/usr/local/share/GeoIP/GeoIP.dat"))
|
||||
return true;
|
||||
printf("\nWarning: GeoIP database was not found at /usr/share/GeoIP/GeoIP.dat\nCountry resolution will be slow.");
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
};
|
42
src/geoip.h
42
src/geoip.h
@ -40,43 +40,27 @@
|
||||
|
||||
using namespace libtorrent;
|
||||
|
||||
// TODO: Update from Internet
|
||||
class GeoIP {
|
||||
protected:
|
||||
static QString geoipFolder(bool embedded=false) {
|
||||
#ifdef WITH_GEOIP_EMBEDDED
|
||||
if(embedded)
|
||||
return ":/geoip/";
|
||||
return misc::qBittorrentPath()+"geoip"+QDir::separator();
|
||||
#else
|
||||
if(QFile::exists("/usr/local/share/GeoIP/GeoIP.dat"))
|
||||
return "/usr/local/share/GeoIP/";
|
||||
return "/usr/share/GeoIP/";
|
||||
#endif
|
||||
}
|
||||
|
||||
static QString geoipDBpath(bool embedded=false) {
|
||||
return geoipFolder(embedded)+"GeoIP.dat";
|
||||
}
|
||||
|
||||
static QString geoipVersionPath(bool embedded=false) {
|
||||
return geoipFolder(embedded)+"VERSION";
|
||||
}
|
||||
|
||||
static int getDBVersion(bool embedded = false) {
|
||||
QFile vFile(geoipVersionPath(embedded));
|
||||
qDebug("Reading file at %s", geoipVersionPath(embedded).toLocal8Bit().data());
|
||||
if(vFile.exists() && vFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug("File exists and was opened");
|
||||
QByteArray v = vFile.readAll().trimmed();
|
||||
/*while(!v.isEmpty() && v[0] == '0') {
|
||||
v = v.mid(1);
|
||||
}*/
|
||||
qDebug("Read version: %s", v.data());
|
||||
bool ok = false;
|
||||
int version = v.toInt(&ok);
|
||||
qDebug("Read version %d (Error? %d)", version, (int) !ok);
|
||||
if(ok) return version;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void updateLocalDb() {
|
||||
if(getDBVersion(true) > getDBVersion(false)) { // Update required
|
||||
#ifdef WITH_GEOIP_EMBEDDED
|
||||
static void exportEmbeddedDb() {
|
||||
if(!QFile::exists(geoipDBpath(false)) || QFile(geoipDBpath(false)).size() != QFile(geoipDBpath(true)).size()) { // Export is required
|
||||
qDebug("A local Geoip database update is required, proceeding...");
|
||||
// Create geoip folder is necessary
|
||||
QDir gfolder(geoipFolder(false));
|
||||
@ -86,18 +70,18 @@ protected:
|
||||
// Remove destination files
|
||||
if(QFile::exists(geoipDBpath(false)))
|
||||
QFile::remove(geoipDBpath(false));
|
||||
if(QFile::exists(geoipVersionPath(false)))
|
||||
QFile::remove(geoipVersionPath(false));
|
||||
// Copy from executable to hard disk
|
||||
QFile::copy(geoipDBpath(true), geoipDBpath(false));
|
||||
QFile::copy(geoipVersionPath(true), geoipVersionPath(false));
|
||||
qDebug("Local Geoip database was updated");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public:
|
||||
static void loadDatabase(session *s) {
|
||||
updateLocalDb();
|
||||
#ifdef WITH_GEOIP_EMBEDDED
|
||||
exportEmbeddedDb();
|
||||
#endif
|
||||
if(QFile::exists(geoipDBpath(false))) {
|
||||
qDebug("Loading GeoIP database from %s...", geoipDBpath(false).toLocal8Bit().data());
|
||||
if(!s->load_country_db(geoipDBpath(false).toLocal8Bit().data())) {
|
||||
|
@ -1,7 +1,5 @@
|
||||
<!DOCTYPE RCC><RCC version="1.0">
|
||||
<qresource>
|
||||
<file>geoip/GeoIP.dat</file>
|
||||
<file>geoip/VERSION</file>
|
||||
</qresource>
|
||||
<RCC>
|
||||
<qresource prefix="/" >
|
||||
<file>geoip/GeoIP.dat</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
|
Binary file not shown.
@ -1,39 +0,0 @@
|
||||
There are two licenses, one for the C library software, and one for
|
||||
the database.
|
||||
|
||||
SOFTWARE LICENSE (C library)
|
||||
|
||||
The GeoIP C Library is licensed under the LGPL. For details see
|
||||
the COPYING file.
|
||||
|
||||
OPEN DATA LICENSE (GeoLite Country and GeoLite City databases)
|
||||
|
||||
Copyright (c) 2008 MaxMind, Inc. All Rights Reserved.
|
||||
|
||||
All advertising materials and documentation mentioning features or use of
|
||||
this database must display the following acknowledgment:
|
||||
"This product includes GeoLite data created by MaxMind, available from
|
||||
http://maxmind.com/"
|
||||
|
||||
Redistribution and use with or without modification, are permitted provided
|
||||
that the following conditions are met:
|
||||
1. Redistributions must retain the above copyright notice, this list of
|
||||
conditions and the following disclaimer in the documentation and/or other
|
||||
materials provided with the distribution.
|
||||
2. All advertising materials and documentation mentioning features or use of
|
||||
this database must display the following acknowledgement:
|
||||
"This product includes GeoLite data created by MaxMind, available from
|
||||
http://maxmind.com/"
|
||||
3. "MaxMind" may not be used to endorse or promote products derived from this
|
||||
database without specific prior written permission.
|
||||
|
||||
THIS DATABASE IS PROVIDED BY MAXMIND, INC ``AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL MAXMIND BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
DATABASE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
12
src/geoip/README
Normal file
12
src/geoip/README
Normal file
@ -0,0 +1,12 @@
|
||||
If you wish to embed GeoIP database into qBittorrent executable, please download put GeoIP.dat in this folder.
|
||||
|
||||
GeoIP Database can be downloaded from here:
|
||||
* http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
|
||||
Note that the database should be uncompressed.
|
||||
|
||||
Embedding GeoIP database into qBittorrent executable is advised for:
|
||||
* Windows
|
||||
* Mac OS X
|
||||
* Linux distributions that don't provide GeoIP database in a separate package
|
||||
|
||||
On Linux operating system, since this is not the default behavior, you also need to pass --with-geoip-database-embedded parameter to the configure file.
|
@ -1 +0,0 @@
|
||||
0911
|
40
src/src.pro
40
src/src.pro
@ -9,12 +9,10 @@ DEBUG_MODE = 0
|
||||
TEMPLATE = app
|
||||
TARGET = qbittorrent
|
||||
CONFIG += qt \
|
||||
thread \
|
||||
x11 \
|
||||
network
|
||||
thread
|
||||
|
||||
# Update this VERSION for each release
|
||||
DEFINES += VERSION=\\\"v2.0.0rc5\\\"
|
||||
DEFINES += VERSION=\\\"v2.0.0rc6\\\"
|
||||
DEFINES += VERSION_MAJOR=2
|
||||
DEFINES += VERSION_MINOR=0
|
||||
DEFINES += VERSION_BUGFIX=0
|
||||
@ -105,11 +103,41 @@ win32:LIBS += -lssl32 \
|
||||
-lwsock32 \
|
||||
-ladvapi32 \
|
||||
-lwinmm
|
||||
|
||||
win32 {
|
||||
DEFINES += WITH_GEOIP_EMBEDDED
|
||||
message("On Windows, GeoIP database must be embedded.")
|
||||
}
|
||||
|
||||
macx {
|
||||
DEFINES += WITH_GEOIP_EMBEDDED
|
||||
message("On Mac OS X, GeoIP database must be embedded.")
|
||||
}
|
||||
|
||||
unix:!macx {
|
||||
contains(DEFINES, WITH_GEOIP_EMBEDDED) {
|
||||
message("You chose to embed GeoIP database in qBittorrent executable.")
|
||||
}
|
||||
}
|
||||
|
||||
RESOURCES = icons.qrc \
|
||||
lang.qrc \
|
||||
search.qrc \
|
||||
webui.qrc \
|
||||
geoip.qrc
|
||||
webui.qrc
|
||||
|
||||
# Add GeoIP resource file if the GeoIP database
|
||||
# should be embedded in qBittorrent executable
|
||||
contains(DEFINES, WITH_GEOIP_EMBEDDED) {
|
||||
exists("geoip/GeoIP.dat") {
|
||||
message("GeoIP.dat was found in src/geoip/.")
|
||||
RESOURCES += geoip.qrc
|
||||
} else {
|
||||
DEFINES -= WITH_GEOIP_EMBEDDED
|
||||
error("GeoIP.dat was not found in src/geoip/ folder, please follow instructions in src/geoip/README.")
|
||||
}
|
||||
} else {
|
||||
message("GeoIP database will not be embedded in qBittorrent executable.")
|
||||
}
|
||||
|
||||
# Translations
|
||||
TRANSLATIONS = $$LANG_PATH/qbittorrent_fr.ts \
|
||||
|
Loading…
x
Reference in New Issue
Block a user