Browse Source

Several compilation and execution fixes for Windows and OS/2

Cleaner binutils gold linker support
adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
e5b8b41373
  1. 45
      configure
  2. 25
      qcm/libboost.qcm
  3. 12
      qcm/libtorrent-rasterbar.qcm
  4. 12
      src/GUI.cpp
  5. 13
      src/main.cpp
  6. 12
      src/propertieswidget.cpp
  7. 19
      src/src.pro
  8. 18
      src/torrentadditiondlg.h
  9. 6
      src/torrentfilesmodel.h

45
configure vendored

@ -21,6 +21,7 @@ Dependency options:
--disable-gui Disable qBittorrent Graphical user --disable-gui Disable qBittorrent Graphical user
interface for headless running interface for headless running
--with-libboost-inc=[path] Path to libboost include files --with-libboost-inc=[path] Path to libboost include files
--with-libboost-lib=[path] Path to libboost library files
--disable-libnotify Disable use of libnotify --disable-libnotify Disable use of libnotify
--disable-geoip-database Disable use of geoip-database --disable-geoip-database Disable use of geoip-database
--with-geoip-database-embedded Geoip Database will be embedded in --with-geoip-database-embedded Geoip Database will be embedded in
@ -152,6 +153,11 @@ while [ $# -gt 0 ]; do
shift shift
;; ;;
--with-libboost-lib=*)
QC_WITH_LIBBOOST_LIB=$optarg
shift
;;
--disable-libnotify) --disable-libnotify)
QC_DISABLE_libnotify="Y" QC_DISABLE_libnotify="Y"
shift shift
@ -190,6 +196,7 @@ echo DATADIR=$DATADIR
echo EX_QTDIR=$EX_QTDIR echo EX_QTDIR=$EX_QTDIR
echo QC_DISABLE_GUI=$QC_DISABLE_GUI echo QC_DISABLE_GUI=$QC_DISABLE_GUI
echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC echo QC_WITH_LIBBOOST_INC=$QC_WITH_LIBBOOST_INC
echo QC_WITH_LIBBOOST_LIB=$QC_WITH_LIBBOOST_LIB
echo QC_DISABLE_libnotify=$QC_DISABLE_libnotify echo QC_DISABLE_libnotify=$QC_DISABLE_libnotify
echo QC_DISABLE_geoip_database=$QC_DISABLE_geoip_database echo QC_DISABLE_geoip_database=$QC_DISABLE_geoip_database
echo QC_WITH_GEOIP_DATABASE_EMBEDDED=$QC_WITH_GEOIP_DATABASE_EMBEDDED echo QC_WITH_GEOIP_DATABASE_EMBEDDED=$QC_WITH_GEOIP_DATABASE_EMBEDDED
@ -362,11 +369,13 @@ public:
else else
conf->addDefine("LIBTORRENT_0_15"); conf->addDefine("LIBTORRENT_0_15");
// Get linking parameters // Get linking parameters
QStringList params; //QStringList params;
QByteArray staticlibs; //QByteArray staticlibs;
params << "--static" << "--libs" << "libtorrent-rasterbar"; //params << "--static" << "--libs" << "libtorrent-rasterbar";
conf->doCommand("pkg-config", params, &staticlibs); //conf->doCommand("pkg-config", params, &staticlibs);
conf->addLib(staticlibs.trimmed()); //conf->addLib(staticlibs.trimmed());
//libcrypto
conf->addLib("-lcrypto");
return true; return true;
} }
}; };
@ -375,6 +384,7 @@ public:
-----BEGIN QCMOD----- -----BEGIN QCMOD-----
name: libboost name: libboost
arg: with-libboost-inc=[path], Path to libboost include files arg: with-libboost-inc=[path], Path to libboost include files
arg: with-libboost-lib=[path], Path to libboost library files
-----END QCMOD----- -----END QCMOD-----
*/ */
class qc_libboost : public ConfObj class qc_libboost : public ConfObj
@ -424,6 +434,30 @@ public:
} }
} }
conf->addIncludePath(s); conf->addIncludePath(s);
// Find library
s = conf->getenv("QC_WITH_LIBBOOST_LIB");
if(!s.isEmpty()) {
if(!conf->checkLibrary(s, "boost_system-mt")) {
return false;
}
}else{
QStringList sl;
sl << "/usr/lib/";
sl << "/usr/lib64/";
sl << "/usr/local/lib/";
sl << "/usr/local/lib64/";
bool found = false;
foreach(s, sl){
if(conf->checkLibrary(s, "boost_system-mt")) {
found = true;
break;
}
}
if(!found)
return false;
}
conf->addLib(QString("-L") + s);
conf->addLib("-lboost_system-mt -lboost_filesystem-mt -lboost_thread-mt");
return true; return true;
} }
}; };
@ -1483,6 +1517,7 @@ export DATADIR
export EX_QTDIR export EX_QTDIR
export QC_DISABLE_GUI export QC_DISABLE_GUI
export QC_WITH_LIBBOOST_INC export QC_WITH_LIBBOOST_INC
export QC_WITH_LIBBOOST_LIB
export QC_DISABLE_libnotify export QC_DISABLE_libnotify
export QC_DISABLE_geoip_database export QC_DISABLE_geoip_database
export QC_WITH_GEOIP_DATABASE_EMBEDDED export QC_WITH_GEOIP_DATABASE_EMBEDDED

25
qcm/libboost.qcm

@ -2,6 +2,7 @@
-----BEGIN QCMOD----- -----BEGIN QCMOD-----
name: libboost name: libboost
arg: with-libboost-inc=[path], Path to libboost include files arg: with-libboost-inc=[path], Path to libboost include files
arg: with-libboost-lib=[path], Path to libboost library files
-----END QCMOD----- -----END QCMOD-----
*/ */
class qc_libboost : public ConfObj class qc_libboost : public ConfObj
@ -51,6 +52,30 @@ public:
} }
} }
conf->addIncludePath(s); conf->addIncludePath(s);
// Find library
s = conf->getenv("QC_WITH_LIBBOOST_LIB");
if(!s.isEmpty()) {
if(!conf->checkLibrary(s, "boost_system-mt")) {
return false;
}
}else{
QStringList sl;
sl << "/usr/lib/";
sl << "/usr/lib64/";
sl << "/usr/local/lib/";
sl << "/usr/local/lib64/";
bool found = false;
foreach(s, sl){
if(conf->checkLibrary(s, "boost_system-mt")) {
found = true;
break;
}
}
if(!found)
return false;
}
conf->addLib(QString("-L") + s);
conf->addLib("-lboost_system-mt -lboost_filesystem-mt -lboost_thread-mt");
return true; return true;
} }
}; };

12
qcm/libtorrent-rasterbar.qcm

@ -27,11 +27,13 @@ public:
else else
conf->addDefine("LIBTORRENT_0_15"); conf->addDefine("LIBTORRENT_0_15");
// Get linking parameters // Get linking parameters
QStringList params; //QStringList params;
QByteArray staticlibs; //QByteArray staticlibs;
params << "--static" << "--libs" << "libtorrent-rasterbar"; //params << "--static" << "--libs" << "libtorrent-rasterbar";
conf->doCommand("pkg-config", params, &staticlibs); //conf->doCommand("pkg-config", params, &staticlibs);
conf->addLib(staticlibs.trimmed()); //conf->addLib(staticlibs.trimmed());
//libcrypto
conf->addLib("-lcrypto");
return true; return true;
} }
}; };

12
src/GUI.cpp

@ -828,12 +828,7 @@ void GUI::trackerAuthenticationRequired(QTorrentHandle& h) {
void GUI::updateGUI() { void GUI::updateGUI() {
// update global informations // update global informations
if(systrayIcon) { if(systrayIcon) {
#ifdef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC)
// Windows does not support html here
QString html =tr("DL speed: %1 KiB/s", "e.g: Download speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1));
html += "\n";
html += tr("UP speed: %1 KiB/s", "e.g: Upload speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadUploadRate()/1024., 'f', 1));
#else
QString html = "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>"; QString html = "<div style='background-color: #678db2; color: #fff;height: 18px; font-weight: bold; margin-bottom: 5px;'>";
html += tr("qBittorrent"); html += tr("qBittorrent");
html += "</div>"; html += "</div>";
@ -843,6 +838,11 @@ void GUI::updateGUI() {
html += "<div style='vertical-align: baseline; height: 18px;'>"; html += "<div style='vertical-align: baseline; height: 18px;'>";
html += "<img src=':/Icons/skin/seeding.png'/>&nbsp;"+tr("UP speed: %1 KiB/s", "e.g: Upload speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadUploadRate()/1024., 'f', 1)); html += "<img src=':/Icons/skin/seeding.png'/>&nbsp;"+tr("UP speed: %1 KiB/s", "e.g: Upload speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadUploadRate()/1024., 'f', 1));
html += "</div>"; html += "</div>";
#else
// OSes such as Windows do not support html here
QString html =tr("DL speed: %1 KiB/s", "e.g: Download speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadDownloadRate()/1024., 'f', 1));
html += "\n";
html += tr("UP speed: %1 KiB/s", "e.g: Upload speed: 10 KiB/s").arg(QString::number(BTSession->getPayloadUploadRate()/1024., 'f', 1));
#endif #endif
systrayIcon->setToolTip(html); // tray icon systrayIcon->setToolTip(html); // tray icon
} }

13
src/main.cpp

@ -52,11 +52,14 @@
#include <QSettings> #include <QSettings>
#include <QLocalSocket> #include <QLocalSocket>
#include <sys/types.h> #include <sys/types.h>
#ifndef Q_WS_WIN
#if defined(Q_WS_X11) || defined(Q_WS_MAC)
#include <signal.h> #include <signal.h>
#include <execinfo.h> #include <execinfo.h>
#include "stacktrace.h" #include "stacktrace.h"
#else #endif
#ifdef Q_WS_WIN
#include <windows.h> #include <windows.h>
const int UNLEN = 256; const int UNLEN = 256;
#endif #endif
@ -125,7 +128,7 @@ public:
#include "main.moc" #include "main.moc"
#ifndef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC)
void sigintHandler(int) { void sigintHandler(int) {
signal(SIGINT, 0); signal(SIGINT, 0);
qDebug("Catching SIGINT, exiting cleanly"); qDebug("Catching SIGINT, exiting cleanly");
@ -301,7 +304,7 @@ int main(int argc, char *argv[]){
#ifndef DISABLE_GUI #ifndef DISABLE_GUI
app->setQuitOnLastWindowClosed(false); app->setQuitOnLastWindowClosed(false);
#endif #endif
#ifndef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC)
signal(SIGABRT, sigabrtHandler); signal(SIGABRT, sigabrtHandler);
signal(SIGTERM, sigtermHandler); signal(SIGTERM, sigtermHandler);
signal(SIGINT, sigintHandler); signal(SIGINT, sigintHandler);
@ -323,7 +326,7 @@ int main(int argc, char *argv[]){
#endif #endif
int ret = app->exec(); int ret = app->exec();
#ifndef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC)
// Application has exited, stop catching SIGINT and SIGTERM // Application has exited, stop catching SIGINT and SIGTERM
signal(SIGINT, 0); signal(SIGINT, 0);
signal(SIGTERM, 0); signal(SIGTERM, 0);

12
src/propertieswidget.cpp

@ -583,10 +583,10 @@ void PropertiesWidget::renameSelectedFile() {
// Check if that name is already used // Check if that name is already used
for(int i=0; i<h.num_files(); ++i) { for(int i=0; i<h.num_files(); ++i) {
if(i == file_index) continue; if(i == file_index) continue;
#ifdef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
if(misc::toQString(h.get_torrent_info().file_at(i).path.string()).compare(new_name, Qt::CaseInsensitive) == 0) {
#else
if(misc::toQString(h.get_torrent_info().file_at(i).path.string()).compare(new_name, Qt::CaseSensitive) == 0) { if(misc::toQString(h.get_torrent_info().file_at(i).path.string()).compare(new_name, Qt::CaseSensitive) == 0) {
#else
if(misc::toQString(h.get_torrent_info().file_at(i).path.string()).compare(new_name, Qt::CaseInsensitive) == 0) {
#endif #endif
// Display error message // Display error message
QMessageBox::warning(this, tr("The file could not be renamed"), QMessageBox::warning(this, tr("The file could not be renamed"),
@ -622,10 +622,10 @@ void PropertiesWidget::renameSelectedFile() {
const int num_files = h.num_files(); const int num_files = h.num_files();
for(int i=0; i<num_files; ++i) { for(int i=0; i<num_files; ++i) {
const QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string()); const QString current_name = misc::toQString(h.get_torrent_info().file_at(i).path.string());
#ifdef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
if(current_name.startsWith(new_path, Qt::CaseInsensitive)) {
#else
if(current_name.startsWith(new_path, Qt::CaseSensitive)) { if(current_name.startsWith(new_path, Qt::CaseSensitive)) {
#else
if(current_name.startsWith(new_path, Qt::CaseInsensitive)) {
#endif #endif
QMessageBox::warning(this, tr("The folder could not be renamed"), QMessageBox::warning(this, tr("The folder could not be renamed"),
tr("This name is already in use in this folder. Please use a different name."), tr("This name is already in use in this folder. Please use a different name."),

19
src/src.pro

@ -11,7 +11,7 @@ CONFIG += qt \
thread thread
# Update this VERSION for each release # Update this VERSION for each release
DEFINES += VERSION=\\\"v2.3.0alpha\\\" DEFINES += VERSION=\'\"v2.2.2\"\'
DEFINES += VERSION_MAJOR=2 DEFINES += VERSION_MAJOR=2
DEFINES += VERSION_MINOR=3 DEFINES += VERSION_MINOR=3
DEFINES += VERSION_BUGFIX=0 DEFINES += VERSION_BUGFIX=0
@ -100,8 +100,10 @@ else:TARGET = qbittorrent
# QMAKE_CXXFLAGS_RELEASE += -fwrapv # QMAKE_CXXFLAGS_RELEASE += -fwrapv
# QMAKE_CXXFLAGS_DEBUG += -fwrapv # QMAKE_CXXFLAGS_DEBUG += -fwrapv
unix:QMAKE_LFLAGS_SHAPP += -rdynamic unix:QMAKE_LFLAGS_SHAPP += -rdynamic
CONFIG += link_pkgconfig unix {
PKGCONFIG += "libtorrent-rasterbar" CONFIG += link_pkgconfig
PKGCONFIG += "libtorrent-rasterbar"
}
QT += network QT += network
!contains(DEFINES, DISABLE_GUI):QT += xml !contains(DEFINES, DISABLE_GUI):QT += xml
@ -121,11 +123,22 @@ win32:LIBS += -lssl32 \
-ladvapi32 \ -ladvapi32 \
-lwinmm -lwinmm
os2:LIBS += -ltorrent-rasterbar \
-lcurl \
-lboost_thread \
-lboost_system \
-lboost_filesystem \
-lssl -lcrypto -lidn -lpthread
!contains(DEFINES, DISABLE_GUI) { !contains(DEFINES, DISABLE_GUI) {
win32 { win32 {
DEFINES += WITH_GEOIP_EMBEDDED DEFINES += WITH_GEOIP_EMBEDDED
message("On Windows, GeoIP database must be embedded.") message("On Windows, GeoIP database must be embedded.")
} }
os2 {
DEFINES += WITH_GEOIP_EMBEDDED
message("On eCS(OS/2), GeoIP database must be embedded.")
}
macx { macx {
DEFINES += WITH_GEOIP_EMBEDDED DEFINES += WITH_GEOIP_EMBEDDED
message("On Mac OS X, GeoIP database must be embedded.") message("On Mac OS X, GeoIP database must be embedded.")

18
src/torrentadditiondlg.h

@ -305,10 +305,10 @@ public slots:
// Check if that name is already used // Check if that name is already used
for(uint i=0; i<nbFiles; ++i) { for(uint i=0; i<nbFiles; ++i) {
if(i == file_index) continue; if(i == file_index) continue;
#ifdef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
if(files_path.at(i).compare(new_name, Qt::CaseInsensitive) == 0) {
#else
if(files_path.at(i).compare(new_name, Qt::CaseSensitive) == 0) { if(files_path.at(i).compare(new_name, Qt::CaseSensitive) == 0) {
#else
if(files_path.at(i).compare(new_name, Qt::CaseInsensitive) == 0) {
#endif #endif
// Display error message // Display error message
QMessageBox::warning(this, tr("The file could not be renamed"), QMessageBox::warning(this, tr("The file could not be renamed"),
@ -339,10 +339,10 @@ public slots:
// Check for overwriting // Check for overwriting
for(uint i=0; i<nbFiles; ++i) { for(uint i=0; i<nbFiles; ++i) {
const QString &current_name = files_path.at(i); const QString &current_name = files_path.at(i);
#ifdef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
if(current_name.startsWith(new_path, Qt::CaseInsensitive)) {
#else
if(current_name.startsWith(new_path, Qt::CaseSensitive)) { if(current_name.startsWith(new_path, Qt::CaseSensitive)) {
#else
if(current_name.startsWith(new_path, Qt::CaseInsensitive)) {
#endif #endif
QMessageBox::warning(this, tr("The folder could not be renamed"), QMessageBox::warning(this, tr("The folder could not be renamed"),
tr("This name is already in use in this folder. Please use a different name."), tr("This name is already in use in this folder. Please use a different name."),
@ -456,10 +456,10 @@ public slots:
if(!is_magnet) { if(!is_magnet) {
bool path_changed = false; bool path_changed = false;
for(uint i=0; i<nbFiles; ++i) { for(uint i=0; i<nbFiles; ++i) {
#ifdef Q_WS_WIN #if defined(Q_WS_X11) || defined(Q_WS_MAC) || defined(Q_WS_QWS)
if(files_path.at(i).compare(misc::toQString(t->file_at(i).path.string()), Qt::CaseInsensitive) != 0) {
#else
if(files_path.at(i).compare(misc::toQString(t->file_at(i).path.string()), Qt::CaseSensitive) != 0) { if(files_path.at(i).compare(misc::toQString(t->file_at(i).path.string()), Qt::CaseSensitive) != 0) {
#else
if(files_path.at(i).compare(misc::toQString(t->file_at(i).path.string()), Qt::CaseInsensitive) != 0) {
#endif #endif
path_changed = true; path_changed = true;
break; break;

6
src/torrentfilesmodel.h

@ -507,7 +507,7 @@ public:
TreeItem *parent = this->rootItem; TreeItem *parent = this->rootItem;
if(t.num_files() == 1) { if(t.num_files() == 1) {
// Create possible parent folder // Create possible parent folder
QStringList path_parts = misc::toQString(t.file_at(0).path.string()).split(QDir::separator()); QStringList path_parts = misc::toQString(t.file_at(0).path.string()).split("/");
path_parts.removeLast(); path_parts.removeLast();
foreach(const QString &part, path_parts) { foreach(const QString &part, path_parts) {
TreeItem *folder = new TreeItem(part, parent); TreeItem *folder = new TreeItem(part, parent);
@ -520,7 +520,7 @@ public:
return; return;
} }
// Create parent folder // Create parent folder
QString root_name = misc::toQString(t.file_at(0).path.string()).split(QDir::separator()).first(); QString root_name = misc::toQString(t.file_at(0).path.string()).split("/").first();
TreeItem *current_parent = new TreeItem(root_name, parent); TreeItem *current_parent = new TreeItem(root_name, parent);
//parent->appendChild(current_parent); //parent->appendChild(current_parent);
TreeItem *root_folder = current_parent; TreeItem *root_folder = current_parent;
@ -532,7 +532,7 @@ public:
current_parent = root_folder; current_parent = root_folder;
QString path = QDir::cleanPath(misc::toQString(fi->path.string())); QString path = QDir::cleanPath(misc::toQString(fi->path.string()));
// Iterate of parts of the path to create necessary folders // Iterate of parts of the path to create necessary folders
QStringList pathFolders = path.split(QDir::separator()); QStringList pathFolders = path.split("/");
Q_ASSERT(pathFolders.size() >= 2); Q_ASSERT(pathFolders.size() >= 2);
QString fileName = pathFolders.takeLast(); QString fileName = pathFolders.takeLast();
QString currentFolderName = pathFolders.takeFirst(); QString currentFolderName = pathFolders.takeFirst();

Loading…
Cancel
Save