Browse Source

Replace Utils::String::toStdString() by QString::toStdString()

adaptive-webui-19844
Chocobo1 8 years ago
parent
commit
ffdcfe9686
  1. 12
      src/app/upgrade.h
  2. 20
      src/base/bittorrent/session.cpp
  3. 8
      src/base/bittorrent/torrentcreatorthread.cpp
  4. 18
      src/base/bittorrent/torrenthandle.cpp
  5. 4
      src/base/bittorrent/torrentinfo.cpp
  6. 4
      src/base/bittorrent/tracker.cpp
  7. 2
      src/base/bittorrent/trackerentry.cpp
  8. 5
      src/base/utils/string.cpp
  9. 1
      src/base/utils/string.h

12
src/app/upgrade.h

@ -119,7 +119,7 @@ bool upgradeResumeFile(const QString &filepath, const QVariantHash &oldTorrent = @@ -119,7 +119,7 @@ bool upgradeResumeFile(const QString &filepath, const QVariantHash &oldTorrent =
}
else {
queuePosition = fastOld.dict_find_int_value("qBt-queuePosition", 0);
fastNew["qBt-name"] = Utils::String::toStdString(oldTorrent.value("name").toString());
fastNew["qBt-name"] = oldTorrent.value("name").toString().toStdString();
fastNew["qBt-tempPathDisabled"] = false;
}
@ -192,14 +192,14 @@ bool upgrade(bool ask = true) @@ -192,14 +192,14 @@ bool upgrade(bool ask = true)
QVariantHash oldTorrent = oldResumeData[hash].toHash();
if (oldTorrent.value("is_magnet", false).toBool()) {
libtorrent::entry resumeData;
resumeData["qBt-magnetUri"] = Utils::String::toStdString(oldTorrent.value("magnet_uri").toString());
resumeData["qBt-magnetUri"] = oldTorrent.value("magnet_uri").toString().toStdString();
resumeData["qBt-paused"] = false;
resumeData["qBt-forced"] = false;
resumeData["qBt-savePath"] = Utils::String::toStdString(oldTorrent.value("save_path").toString());
resumeData["qBt-ratioLimit"] = Utils::String::toStdString(QString::number(oldTorrent.value("max_ratio", -2).toReal()));
resumeData["qBt-label"] = Utils::String::toStdString(oldTorrent.value("label").toString());
resumeData["qBt-name"] = Utils::String::toStdString(oldTorrent.value("name").toString());
resumeData["qBt-savePath"] = oldTorrent.value("save_path").toString().toStdString();
resumeData["qBt-ratioLimit"] = QString::number(oldTorrent.value("max_ratio", -2).toReal()).toStdString();
resumeData["qBt-label"] = oldTorrent.value("label").toString().toStdString();
resumeData["qBt-name"] = oldTorrent.value("name").toString().toStdString();
resumeData["qBt-seedStatus"] = oldTorrent.value("seed").toBool();
resumeData["qBt-tempPathDisabled"] = false;

20
src/base/bittorrent/session.cpp

@ -976,11 +976,11 @@ void Session::configure(libtorrent::settings_pack &settingsPack) @@ -976,11 +976,11 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
Net::ProxyConfiguration proxyConfig = proxyManager->proxyConfiguration();
if (m_useProxy || (proxyConfig.type != Net::ProxyType::None)) {
if (proxyConfig.type != Net::ProxyType::None) {
settingsPack.set_str(libt::settings_pack::proxy_hostname, Utils::String::toStdString(proxyConfig.ip));
settingsPack.set_str(libt::settings_pack::proxy_hostname, proxyConfig.ip.toStdString());
settingsPack.set_int(libt::settings_pack::proxy_port, proxyConfig.port);
if (proxyManager->isAuthenticationRequired()) {
settingsPack.set_str(libt::settings_pack::proxy_username, Utils::String::toStdString(proxyConfig.username));
settingsPack.set_str(libt::settings_pack::proxy_password, Utils::String::toStdString(proxyConfig.password));
settingsPack.set_str(libt::settings_pack::proxy_username, proxyConfig.username.toStdString());
settingsPack.set_str(libt::settings_pack::proxy_password, proxyConfig.password.toStdString());
}
settingsPack.set_bool(libt::settings_pack::proxy_peer_connections, isProxyPeerConnectionsEnabled());
}
@ -1055,7 +1055,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack) @@ -1055,7 +1055,7 @@ void Session::configure(libtorrent::settings_pack &settingsPack)
// Include overhead in transfer limits
settingsPack.set_bool(libt::settings_pack::rate_limit_ip_overhead, includeOverheadInLimits());
// IP address to announce to trackers
settingsPack.set_str(libt::settings_pack::announce_ip, Utils::String::toStdString(announceIP()));
settingsPack.set_str(libt::settings_pack::announce_ip, announceIP().toStdString());
// Super seeding
settingsPack.set_bool(libt::settings_pack::strict_super_seeding, isSuperSeedingEnabled());
// * Max Half-open connections
@ -1123,11 +1123,11 @@ void Session::configure(libtorrent::session_settings &sessionSettings) @@ -1123,11 +1123,11 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
if (m_useProxy || (proxyConfig.type != Net::ProxyType::None)) {
libt::proxy_settings proxySettings;
if (proxyConfig.type != Net::ProxyType::None) {
proxySettings.hostname = Utils::String::toStdString(proxyConfig.ip);
proxySettings.hostname = proxyConfig.ip.toStdString();
proxySettings.port = proxyConfig.port;
if (proxyManager->isAuthenticationRequired()) {
proxySettings.username = Utils::String::toStdString(proxyConfig.username);
proxySettings.password = Utils::String::toStdString(proxyConfig.password);
proxySettings.username = proxyConfig.username.toStdString();
proxySettings.password = proxyConfig.password.toStdString();
}
proxySettings.proxy_peer_connections = isProxyPeerConnectionsEnabled();
}
@ -1200,7 +1200,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings) @@ -1200,7 +1200,7 @@ void Session::configure(libtorrent::session_settings &sessionSettings)
// Include overhead in transfer limits
sessionSettings.rate_limit_ip_overhead = includeOverheadInLimits();
// IP address to announce to trackers
sessionSettings.announce_ip = Utils::String::toStdString(announceIP());
sessionSettings.announce_ip = announceIP().toStdString();
// Super seeding
sessionSettings.strict_super_seeding = isSuperSeedingEnabled();
// * Max Half-open connections
@ -1699,7 +1699,7 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri @@ -1699,7 +1699,7 @@ bool Session::addTorrent_impl(AddTorrentData addData, const MagnetUri &magnetUri
// Limits
p.max_connections = maxConnectionsPerTorrent();
p.max_uploads = maxUploadsPerTorrent();
p.save_path = Utils::String::toStdString(Utils::Fs::toNativePath(savePath));
p.save_path = Utils::Fs::toNativePath(savePath).toStdString();
m_addingTorrents.insert(hash, addData);
// Adding torrent to BitTorrent session
@ -1787,7 +1787,7 @@ bool Session::loadMetadata(const MagnetUri &magnetUri) @@ -1787,7 +1787,7 @@ bool Session::loadMetadata(const MagnetUri &magnetUri)
p.max_uploads = maxUploadsPerTorrent();
QString savePath = QString("%1/%2").arg(QDir::tempPath()).arg(hash);
p.save_path = Utils::String::toStdString(Utils::Fs::toNativePath(savePath));
p.save_path = Utils::Fs::toNativePath(savePath).toStdString();
// Forced start
p.flags &= ~libt::add_torrent_params::flag_paused;

8
src/base/bittorrent/torrentcreatorthread.cpp

@ -107,14 +107,14 @@ void TorrentCreatorThread::run() @@ -107,14 +107,14 @@ void TorrentCreatorThread::run()
try {
libt::file_storage fs;
// Adding files to the torrent
libt::add_files(fs, Utils::String::toStdString(Utils::Fs::toNativePath(m_inputPath)), fileFilter);
libt::add_files(fs, Utils::Fs::toNativePath(m_inputPath).toStdString(), fileFilter);
if (m_abort) return;
libt::create_torrent t(fs, m_pieceSize);
// Add url seeds
foreach (const QString &seed, m_urlSeeds)
t.add_url_seed(Utils::String::toStdString(seed.trimmed()));
t.add_url_seed(seed.trimmed().toStdString());
int tier = 0;
bool newline = false;
@ -126,14 +126,14 @@ void TorrentCreatorThread::run() @@ -126,14 +126,14 @@ void TorrentCreatorThread::run()
newline = true;
continue;
}
t.add_tracker(Utils::String::toStdString(tracker.trimmed()), tier);
t.add_tracker(tracker.trimmed().toStdString(), tier);
newline = false;
}
if (m_abort) return;
// calculate the hash for all pieces
const QString parentPath = Utils::Fs::branchPath(m_inputPath) + "/";
libt::set_piece_hashes(t, Utils::String::toStdString(Utils::Fs::toNativePath(parentPath)), boost::bind(&TorrentCreatorThread::sendProgressSignal, this, _1, t.num_pieces()));
libt::set_piece_hashes(t, Utils::Fs::toNativePath(parentPath).toStdString(), boost::bind(&TorrentCreatorThread::sendProgressSignal, this, _1, t.num_pieces()));
// Set qBittorrent as creator and add user comment to
// torrent_info structure
t.set_creator(creator_str.toUtf8().constData());

18
src/base/bittorrent/torrenthandle.cpp

@ -484,7 +484,7 @@ bool TorrentHandle::addUrlSeed(const QUrl &urlSeed) @@ -484,7 +484,7 @@ bool TorrentHandle::addUrlSeed(const QUrl &urlSeed)
QList<QUrl> seeds = urlSeeds();
if (seeds.contains(urlSeed)) return false;
SAFE_CALL_BOOL(add_url_seed, Utils::String::toStdString(urlSeed.toString()));
SAFE_CALL_BOOL(add_url_seed, urlSeed.toString().toStdString());
}
bool TorrentHandle::removeUrlSeed(const QUrl &urlSeed)
@ -492,13 +492,13 @@ bool TorrentHandle::removeUrlSeed(const QUrl &urlSeed) @@ -492,13 +492,13 @@ bool TorrentHandle::removeUrlSeed(const QUrl &urlSeed)
QList<QUrl> seeds = urlSeeds();
if (!seeds.contains(urlSeed)) return false;
SAFE_CALL_BOOL(remove_url_seed, Utils::String::toStdString(urlSeed.toString()));
SAFE_CALL_BOOL(remove_url_seed, urlSeed.toString().toStdString());
}
bool TorrentHandle::connectPeer(const PeerAddress &peerAddress)
{
libt::error_code ec;
libt::address addr = libt::address::from_string(Utils::String::toStdString(peerAddress.ip.toString()), ec);
libt::address addr = libt::address::from_string(peerAddress.ip.toString().toStdString(), ec);
if (ec) return false;
boost::asio::ip::tcp::endpoint ep(addr, peerAddress.port);
@ -1338,7 +1338,7 @@ void TorrentHandle::renameFile(int index, const QString &name) @@ -1338,7 +1338,7 @@ void TorrentHandle::renameFile(int index, const QString &name)
{
++m_renameCount;
qDebug() << Q_FUNC_INFO << index << name;
SAFE_CALL(rename_file, index, Utils::String::toStdString(Utils::Fs::toNativePath(name)));
SAFE_CALL(rename_file, index, Utils::Fs::toNativePath(name).toStdString());
}
bool TorrentHandle::saveTorrentFile(const QString &path)
@ -1530,14 +1530,14 @@ void TorrentHandle::handleSaveResumeDataAlert(libtorrent::save_resume_data_alert @@ -1530,14 +1530,14 @@ void TorrentHandle::handleSaveResumeDataAlert(libtorrent::save_resume_data_alert
libtorrent::entry &resumeData = useDummyResumeData ? dummyEntry : *(p->resume_data);
if (useDummyResumeData) {
resumeData["qBt-magnetUri"] = Utils::String::toStdString(toMagnetUri());
resumeData["qBt-magnetUri"] = toMagnetUri().toStdString();
resumeData["qBt-paused"] = isPaused();
resumeData["qBt-forced"] = isForced();
}
resumeData["qBt-savePath"] = m_useAutoTMM ? "" : Utils::String::toStdString(m_savePath);
resumeData["qBt-ratioLimit"] = Utils::String::toStdString(QString::number(m_ratioLimit));
resumeData["qBt-category"] = Utils::String::toStdString(m_category);
resumeData["qBt-name"] = Utils::String::toStdString(m_name);
resumeData["qBt-savePath"] = m_useAutoTMM ? "" : m_savePath.toStdString();
resumeData["qBt-ratioLimit"] = QString::number(m_ratioLimit).toStdString();
resumeData["qBt-category"] = m_category.toStdString();
resumeData["qBt-name"] = m_name.toStdString();
resumeData["qBt-seedStatus"] = m_hasSeedStatus;
resumeData["qBt-tempPathDisabled"] = m_tempPathDisabled;
resumeData["qBt-queuePosition"] = queuePosition();

4
src/base/bittorrent/torrentinfo.cpp

@ -64,7 +64,7 @@ TorrentInfo TorrentInfo::loadFromFile(const QString &path, QString &error) @@ -64,7 +64,7 @@ TorrentInfo TorrentInfo::loadFromFile(const QString &path, QString &error)
{
error.clear();
libt::error_code ec;
TorrentInfo info(NativePtr(new libt::torrent_info(Utils::String::toStdString(Utils::Fs::toNativePath(path)), ec)));
TorrentInfo info(NativePtr(new libt::torrent_info(Utils::Fs::toNativePath(path).toStdString(), ec)));
if (ec) {
error = QString::fromUtf8(ec.message().c_str());
qDebug("Cannot load .torrent file: %s", qPrintable(error));
@ -279,7 +279,7 @@ TorrentInfo::PieceRange TorrentInfo::filePieces(int fileIndex) const @@ -279,7 +279,7 @@ TorrentInfo::PieceRange TorrentInfo::filePieces(int fileIndex) const
void TorrentInfo::renameFile(uint index, const QString &newPath)
{
if (!isValid()) return;
nativeInfo()->rename_file(index, Utils::String::toStdString(newPath));
nativeInfo()->rename_file(index, newPath.toStdString());
}
int BitTorrent::TorrentInfo::fileIndex(const QString& fileName) const

4
src/base/bittorrent/tracker.cpp

@ -65,8 +65,8 @@ libtorrent::entry Peer::toEntry(bool noPeerId) const @@ -65,8 +65,8 @@ libtorrent::entry Peer::toEntry(bool noPeerId) const
{
libtorrent::entry::dictionary_type peerMap;
if (!noPeerId)
peerMap["id"] = libtorrent::entry(Utils::String::toStdString(peerId));
peerMap["ip"] = libtorrent::entry(Utils::String::toStdString(ip));
peerMap["id"] = libtorrent::entry(peerId.toStdString());
peerMap["ip"] = libtorrent::entry(ip.toStdString());
peerMap["port"] = libtorrent::entry(port);
return libtorrent::entry(peerMap);

2
src/base/bittorrent/trackerentry.cpp

@ -35,7 +35,7 @@ @@ -35,7 +35,7 @@
using namespace BitTorrent;
TrackerEntry::TrackerEntry(const QString &url)
: m_nativeEntry(libtorrent::announce_entry(Utils::String::toStdString(url)))
: m_nativeEntry(libtorrent::announce_entry(url.toStdString()))
{
}

5
src/base/utils/string.cpp

@ -157,11 +157,6 @@ QString Utils::String::fromStdString(const std::string &str) @@ -157,11 +157,6 @@ QString Utils::String::fromStdString(const std::string &str)
return QString::fromUtf8(str.c_str());
}
std::string Utils::String::toStdString(const QString &str)
{
return str.toStdString();
}
// to send numbers instead of strings with suffixes
QString Utils::String::fromDouble(double n, int precision)
{

1
src/base/utils/string.h

@ -40,7 +40,6 @@ namespace Utils @@ -40,7 +40,6 @@ namespace Utils
namespace String
{
QString fromStdString(const std::string &str);
std::string toStdString(const QString &str);
QString fromDouble(double n, int precision);
// Implements constant-time comparison to protect against timing attacks

Loading…
Cancel
Save