Commit b7edbf47 authored by Andrius Štikonas's avatar Andrius Štikonas
Browse files

Add a new SetClientInfo method that accept QString version.

parent 2b6b0d81
......@@ -25,30 +25,36 @@
namespace bt
{
static QString g_name = QStringLiteral("KTorrent");
static int g_major = 0;
static int g_minor = 0;
static int g_release = 0;
static QString g_version = QStringLiteral("0.0.0");
static QString g_peer_id = QStringLiteral("KT");
static QString g_version_without_dots = QStringLiteral("000");
// TODO: create a function SetClientInfo(const QString &name, QString &version, const QString &peer_id) and mark this one [[deprecated]]
void SetClientInfo(const QString &name, int major, int minor, int release, VersionType type, const QString &peer_id)
void SetClientInfo(const QString &name, const QString &version, const QString &peer_id)
{
g_name = name;
g_version = version;
g_peer_id = peer_id;
g_version_without_dots = g_version;
g_version_without_dots = g_version_without_dots.remove(QChar('.'));
}
[[deprecated]] void SetClientInfo(const QString &name, int major, int minor, int release, VersionType type, const QString &peer_id)
{
Q_UNUSED(type)
g_name = name;
g_major = major;
g_minor = minor;
g_release = release;
g_version = QString("%1.%2.%3").arg(major).arg(minor).arg(release);
g_peer_id = peer_id;
g_version_without_dots = QString("%1%2%3").arg(major).arg(minor).arg(release);
}
QString PeerIDPrefix()
{
return QString("-%1%2%3%4-").arg(g_peer_id).arg(g_major).arg(g_minor).arg(g_release);
return QString("-%1%2-").arg(g_peer_id).arg(g_version_without_dots);
}
QString GetVersionString()
{
QString str = g_name + QString("/%1.%2.%3").arg(g_major).arg(g_minor).arg(g_release);
QString str = g_name + QString("/%1").arg(g_version);
return str;
}
}
......@@ -49,6 +49,15 @@ enum VersionType {
*/
KTORRENT_EXPORT void SetClientInfo(const QString &name, int major, int minor, int release, VersionType type, const QString &peer_id_code);
/**
* Set the client info. This information is used to create
* the PeerID and the version string (used in HTTP announces for example).
* @param name Name of the client
* @param version Version
* @param peer_id_code Peer ID code (2 letters identifying the client, KT for KTorrent)
*/
KTORRENT_EXPORT void SetClientInfo(const QString &name, const QString &version, const QString &peer_id_code);
/**
* Get the PeerID prefix set by SetClientInfo
* @return The PeerID prefix
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment