Browse Source

Merge pull request #6445 from Chocobo1/fix

Follow http user-agent format
adaptive-webui-19844
sledgehammer999 8 years ago committed by GitHub
parent
commit
147f4d76e2
  1. 14
      CMakeLists.txt
  2. 2
      src/app/application.cpp
  3. 8
      src/app/main.cpp
  4. 2
      src/app/stacktrace_win_dlg.h
  5. 6
      src/base/bittorrent/session.cpp
  6. 2
      src/base/bittorrent/torrentcreatorthread.cpp
  7. 4
      src/base/net/dnsupdater.cpp
  8. 2
      src/gui/about_imp.h
  9. 6
      src/gui/mainwindow.cpp
  10. 8
      src/gui/programupdater.cpp
  11. BIN
      src/qbittorrent.rc
  12. 2
      src/webui/abstractwebapplication.cpp
  13. 2
      src/webui/webapplication.cpp
  14. 19
      version.pri

14
CMakeLists.txt

@ -17,15 +17,17 @@ endif() @@ -17,15 +17,17 @@ endif()
set(PROJECT_VERSION "${PROJECT_VERSION}${VER_STATUS}")
add_definitions(-DVERSION_MAJOR=${VER_MAJOR})
add_definitions(-DVERSION_MINOR=${VER_MINOR})
add_definitions(-DVERSION_BUGFIX=${VER_BUGFIX})
add_definitions(-DVERSION_BUILD=${VER_BUILD})
add_definitions(-DQBT_VERSION_MAJOR=${VER_MAJOR})
add_definitions(-DQBT_VERSION_MINOR=${VER_MINOR})
add_definitions(-DQBT_VERSION_BUGFIX=${VER_BUGFIX})
add_definitions(-DQBT_VERSION_BUILD=${VER_BUILD})
# os2 {
# DEFINES += VERSION=\'\"v$${PROJECT_VERSION}\"\'
# DEFINES += DQBT_VERSION=\'\"v$${PROJECT_VERSION}\"\'
# DEFINES += DQBT_VERSION_2=\'\"$${PROJECT_VERSION}\"\'
# } else {
add_definitions(-DVERSION="v${PROJECT_VERSION}")
add_definitions(-DQBT_VERSION="v${PROJECT_VERSION}")
add_definitions(-DQBT_VERSION_2="${PROJECT_VERSION}")
# }
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og")

2
src/app/application.cpp

@ -127,7 +127,7 @@ Application::Application(const QString &id, int &argc, char **argv) @@ -127,7 +127,7 @@ Application::Application(const QString &id, int &argc, char **argv)
if (isFileLoggerEnabled())
m_fileLogger = new FileLogger(fileLoggerPath(), isFileLoggerBackup(), fileLoggerMaxSize(), isFileLoggerDeleteOld(), fileLoggerAge(), static_cast<FileLogger::FileLogAgeType>(fileLoggerAgeType()));
Logger::instance()->addMessage(tr("qBittorrent %1 started", "qBittorrent v3.2.0alpha started").arg(VERSION));
Logger::instance()->addMessage(tr("qBittorrent %1 started", "qBittorrent v3.2.0alpha started").arg(QBT_VERSION));
}
#ifndef DISABLE_GUI

8
src/app/main.cpp

@ -189,7 +189,7 @@ int main(int argc, char *argv[]) @@ -189,7 +189,7 @@ int main(int argc, char *argv[])
}
// Set environment variable
if (!qputenv("QBITTORRENT", QByteArray(VERSION)))
if (!qputenv("QBITTORRENT", QBT_VERSION))
std::cerr << "Couldn't set environment variable...\n";
#ifndef DISABLE_GUI
@ -359,7 +359,7 @@ void sigAbnormalHandler(int signum) @@ -359,7 +359,7 @@ void sigAbnormalHandler(int signum)
const char str1[] = "\n\n*************************************************************\nCatching signal: ";
const char *sigName = sysSigName[signum];
const char str2[] = "\nPlease file a bug report at http://bug.qbittorrent.org and provide the following information:\n\n"
"qBittorrent version: " VERSION "\n";
"qBittorrent version: " QBT_VERSION "\n";
write(STDERR_FILENO, str1, strlen(str1));
write(STDERR_FILENO, sigName, strlen(sigName));
write(STDERR_FILENO, str2, strlen(str2));
@ -380,7 +380,7 @@ void showSplashScreen() @@ -380,7 +380,7 @@ void showSplashScreen()
{
QPixmap splash_img(":/icons/skin/splash.png");
QPainter painter(&splash_img);
QString version = VERSION;
QString version = QBT_VERSION;
painter.setPen(QPen(Qt::white));
painter.setFont(QFont("Arial", 22, QFont::Black));
painter.drawText(224 - painter.fontMetrics().width(version), 270, version);
@ -393,7 +393,7 @@ void showSplashScreen() @@ -393,7 +393,7 @@ void showSplashScreen()
void displayVersion()
{
std::cout << qPrintable(qApp->applicationName()) << " " << VERSION << std::endl;
std::cout << qPrintable(qApp->applicationName()) << " " << QBT_VERSION << std::endl;
}
QString makeUsage(const QString &prg_name)

2
src/app/stacktrace_win_dlg.h

@ -60,7 +60,7 @@ public: @@ -60,7 +60,7 @@ public:
"</p></font>"
"<br/><hr><br/>"
"<p align=center><font size=4>"
"qBittorrent version: " VERSION "<br/>"
"qBittorrent version: " QBT_VERSION "<br/>"
"Libtorrent version: %1<br/>"
"Qt version: " QT_VERSION_STR "<br/>"
"Boost version: %2<br/>"

6
src/base/bittorrent/session.cpp

@ -91,7 +91,7 @@ @@ -91,7 +91,7 @@
static const char PEER_ID[] = "qB";
static const char RESUME_FOLDER[] = "BT_backup";
static const char USER_AGENT[] = "qBittorrent " VERSION;
static const char USER_AGENT[] = "qBittorrent/" QBT_VERSION; // to pass trackers whitelists, using the "v" prefixed version string
namespace libt = libtorrent;
using namespace BitTorrent;
@ -310,7 +310,7 @@ Session::Session(QObject *parent) @@ -310,7 +310,7 @@ Session::Session(QObject *parent)
;
#if LIBTORRENT_VERSION_NUM < 10100
libt::fingerprint fingerprint(PEER_ID, VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, VERSION_BUILD);
libt::fingerprint fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
std::string peerId = fingerprint.to_string();
const ushort port = this->port();
std::pair<int, int> ports(port, port);
@ -340,7 +340,7 @@ Session::Session(QObject *parent) @@ -340,7 +340,7 @@ Session::Session(QObject *parent)
dispatchAlerts(alertPtr.release());
});
#else
std::string peerId = libt::generate_fingerprint(PEER_ID, VERSION_MAJOR, VERSION_MINOR, VERSION_BUGFIX, VERSION_BUILD);
std::string peerId = libt::generate_fingerprint(PEER_ID, QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD);
libt::settings_pack pack;
pack.set_int(libt::settings_pack::alert_mask, alertMask);
pack.set_str(libt::settings_pack::peer_fingerprint, peerId);

2
src/base/bittorrent/torrentcreatorthread.cpp

@ -103,7 +103,7 @@ void TorrentCreatorThread::run() @@ -103,7 +103,7 @@ void TorrentCreatorThread::run()
{
emit updateProgress(0);
QString creator_str("qBittorrent " VERSION);
QString creator_str("qBittorrent " QBT_VERSION);
try {
libt::file_storage fs;
// Adding files to the torrent

4
src/base/net/dnsupdater.cpp

@ -78,7 +78,7 @@ void DNSUpdater::checkPublicIP() @@ -78,7 +78,7 @@ void DNSUpdater::checkPublicIP()
DownloadHandler *handler = DownloadManager::instance()->downloadUrl(
"http://checkip.dyndns.org", false, 0, false,
QString("qBittorrent/%1").arg(VERSION));
"qBittorrent/" QBT_VERSION_2);
connect(handler, SIGNAL(downloadFinished(QString, QByteArray)), SLOT(ipRequestFinished(QString, QByteArray)));
connect(handler, SIGNAL(downloadFailed(QString, QString)), SLOT(ipRequestFailed(QString, QString)));
@ -125,7 +125,7 @@ void DNSUpdater::updateDNSService() @@ -125,7 +125,7 @@ void DNSUpdater::updateDNSService()
m_lastIPCheckTime = QDateTime::currentDateTime();
DownloadHandler *handler = DownloadManager::instance()->downloadUrl(
getUpdateUrl(), false, 0, false,
QString("qBittorrent/%1").arg(VERSION));
"qBittorrent/" QBT_VERSION_2);
connect(handler, SIGNAL(downloadFinished(QString, QByteArray)), SLOT(ipUpdateFinished(QString, QByteArray)));
connect(handler, SIGNAL(downloadFailed(QString, QString)), SLOT(ipUpdateFailed(QString, QString)));
}

2
src/gui/about_imp.h

@ -47,7 +47,7 @@ public: @@ -47,7 +47,7 @@ public:
setAttribute(Qt::WA_DeleteOnClose);
// Title
lb_name->setText("<b><h2>qBittorrent " VERSION "</h2></b>");
lb_name->setText("<b><h2>qBittorrent " QBT_VERSION "</h2></b>");
// About
QString aboutText = QString(

6
src/gui/mainwindow.cpp

@ -139,7 +139,7 @@ MainWindow::MainWindow(QWidget *parent) @@ -139,7 +139,7 @@ MainWindow::MainWindow(QWidget *parent)
Preferences *const pref = Preferences::instance();
m_uiLocked = pref->isUILocked();
setWindowTitle("qBittorrent " VERSION);
setWindowTitle("qBittorrent " QBT_VERSION);
m_displaySpeedInTitle = pref->speedInTitleBar();
// Setting icons
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
@ -1332,7 +1332,7 @@ void MainWindow::updateGUI() @@ -1332,7 +1332,7 @@ void MainWindow::updateGUI()
setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version")
.arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true))
.arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true))
.arg(VERSION));
.arg(QBT_VERSION));
}
}
@ -1495,7 +1495,7 @@ void MainWindow::on_actionSpeedInTitleBar_triggered() @@ -1495,7 +1495,7 @@ void MainWindow::on_actionSpeedInTitleBar_triggered()
if (m_displaySpeedInTitle)
updateGUI();
else
setWindowTitle("qBittorrent " VERSION);
setWindowTitle("qBittorrent " QBT_VERSION);
}
void MainWindow::on_actionRSSReader_triggered()

8
src/gui/programupdater.cpp

@ -66,7 +66,7 @@ void ProgramUpdater::checkForUpdates() @@ -66,7 +66,7 @@ void ProgramUpdater::checkForUpdates()
RSS_URL, false, 0, false,
// Don't change this User-Agent. In case our updater goes haywire,
// the filehost can identify it and contact us.
QString("qBittorrent/%1 ProgramUpdater (www.qbittorrent.org)").arg(VERSION));
"qBittorrent/" QBT_VERSION_2 " ProgramUpdater (www.qbittorrent.org)");
connect(handler, SIGNAL(downloadFinished(QString,QByteArray)), SLOT(rssDownloadFinished(QString,QByteArray)));
connect(handler, SIGNAL(downloadFailed(QString,QString)), SLOT(rssDownloadFailed(QString,QString)));
}
@ -137,9 +137,9 @@ void ProgramUpdater::updateProgram() @@ -137,9 +137,9 @@ void ProgramUpdater::updateProgram()
bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const
{
QRegExp regVer("([0-9.]+)");
if (regVer.indexIn(QString(VERSION)) >= 0) {
if (regVer.indexIn(QBT_VERSION) >= 0) {
QString localVersion = regVer.cap(1);
qDebug() << Q_FUNC_INFO << "local version:" << localVersion << "/" << VERSION;
qDebug() << Q_FUNC_INFO << "local version:" << localVersion << "/" << QBT_VERSION;
QStringList remoteParts = remoteVersion.split('.');
QStringList localParts = localVersion.split('.');
for (int i = 0; i<qMin(remoteParts.size(), localParts.size()); ++i) {
@ -153,7 +153,7 @@ bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const @@ -153,7 +153,7 @@ bool ProgramUpdater::isVersionMoreRecent(const QString &remoteVersion) const
return true;
// versions are equal, check if the local version is a development release, in which case it is older (2.9.2beta < 2.9.2)
QRegExp regDevel("(alpha|beta|rc)");
if (regDevel.indexIn(VERSION) >= 0)
if (regDevel.indexIn(QBT_VERSION) >= 0)
return true;
}
return false;

BIN
src/qbittorrent.rc

Binary file not shown.

2
src/webui/abstractwebapplication.cpp

@ -206,7 +206,7 @@ bool AbstractWebApplication::readFile(const QString& path, QByteArray &data, QSt @@ -206,7 +206,7 @@ bool AbstractWebApplication::readFile(const QString& path, QByteArray &data, QSt
translateDocument(dataStr);
if (path.endsWith("about.html") || path.endsWith("index.html") || path.endsWith("client.js"))
dataStr.replace("${VERSION}", VERSION);
dataStr.replace("${VERSION}", QBT_VERSION);
data = dataStr.toUtf8();
translatedFiles_[path] = data; // cashing translated file

2
src/webui/webapplication.cpp

@ -348,7 +348,7 @@ void WebApplication::action_version_api_min() @@ -348,7 +348,7 @@ void WebApplication::action_version_api_min()
void WebApplication::action_version_qbittorrent()
{
CHECK_URI(0);
print(QString(VERSION), Http::CONTENT_TYPE_TXT);
print(QString(QBT_VERSION), Http::CONTENT_TYPE_TXT);
}
void WebApplication::action_command_shutdown()

19
version.pri

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
# keep it all lowercase to match program naming convention on *nix systems
PROJECT_NAME = qbittorrent
# Define version numbers here
@ -16,14 +17,16 @@ PROJECT_VERSION = $${VER_MAJOR}.$${VER_MINOR}.$${VER_BUGFIX} @@ -16,14 +17,16 @@ PROJECT_VERSION = $${VER_MAJOR}.$${VER_MINOR}.$${VER_BUGFIX}
PROJECT_VERSION = $${PROJECT_VERSION}$${VER_STATUS}
DEFINES += VERSION_MAJOR=$${VER_MAJOR}
DEFINES += VERSION_MINOR=$${VER_MINOR}
DEFINES += VERSION_BUGFIX=$${VER_BUGFIX}
DEFINES += VERSION_BUILD=$${VER_BUILD}
DEFINES += QBT_VERSION_MAJOR=$${VER_MAJOR}
DEFINES += QBT_VERSION_MINOR=$${VER_MINOR}
DEFINES += QBT_VERSION_BUGFIX=$${VER_BUGFIX}
DEFINES += QBT_VERSION_BUILD=$${VER_BUILD}
os2 {
DEFINES += VERSION=\'\"v$${PROJECT_VERSION}\"\'
} else {
DEFINES += VERSION=\\\"v$${PROJECT_VERSION}\\\"
DEFINES += QBT_VERSION=\'\"v$${PROJECT_VERSION}\"\'
DEFINES += QBT_VERSION_2=\'\"$${PROJECT_VERSION}\"\'
}
else {
DEFINES += QBT_VERSION=\\\"v$${PROJECT_VERSION}\\\"
DEFINES += QBT_VERSION_2=\\\"$${PROJECT_VERSION}\\\"
}

Loading…
Cancel
Save