mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-23 09:49:52 +00:00
BUGFIX: Stop enforcing UTF-8 and use system locale instead
This commit is contained in:
parent
ca83fdecff
commit
0153b03160
@ -6,6 +6,7 @@
|
||||
- FEATURE: Search results tab columns are now remembered upon startup
|
||||
- FEATURE: Added right click menu in search engine to clear completion history
|
||||
- BUGFIX: Provide more helpful explanation when an I/O error occured
|
||||
- BUGFIX: Stop enforcing UTF-8 and use system locale instead
|
||||
- COSMETIC: Redesigned program preferences
|
||||
- COSMETIC: Updated icons set
|
||||
|
||||
|
@ -362,7 +362,7 @@ void FinishedTorrents::forceRecheck(){
|
||||
if(index.column() == F_NAME){
|
||||
QString hash = finishedListModel->data(finishedListModel->index(index.row(), F_HASH)).toString();
|
||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
qDebug("Forcing recheck for torrent %s", hash.toUtf8().data());
|
||||
qDebug("Forcing recheck for torrent %s", hash.toLocal8Bit().data());
|
||||
h.force_recheck();
|
||||
}
|
||||
}
|
||||
|
12
src/GUI.cpp
12
src/GUI.cpp
@ -441,7 +441,7 @@ void GUI::fullDiskError(QTorrentHandle& h, QString msg) const {
|
||||
}
|
||||
// Download will be paused by libtorrent. Updating GUI information accordingly
|
||||
QString hash = h.hash();
|
||||
qDebug("Full disk error, pausing torrent %s", hash.toUtf8().data());
|
||||
qDebug("Full disk error, pausing torrent %s", hash.toLocal8Bit().data());
|
||||
if(h.is_seed()) {
|
||||
// In finished list
|
||||
qDebug("Automatically paused torrent was in finished list");
|
||||
@ -758,7 +758,7 @@ void GUI::dropEvent(QDropEvent *event) {
|
||||
bool useTorrentAdditionDialog = settings.value(QString::fromUtf8("Preferences/Downloads/AdditionDialog"), true).toBool();
|
||||
foreach(QString file, files) {
|
||||
file = file.trimmed().replace(QString::fromUtf8("file://"), QString::fromUtf8(""), Qt::CaseInsensitive);
|
||||
qDebug("Dropped file %s on download list", file.toUtf8().data());
|
||||
qDebug("Dropped file %s on download list", file.toLocal8Bit().data());
|
||||
if(file.startsWith(QString::fromUtf8("http://"), Qt::CaseInsensitive) || file.startsWith(QString::fromUtf8("ftp://"), Qt::CaseInsensitive) || file.startsWith(QString::fromUtf8("https://"), Qt::CaseInsensitive)) {
|
||||
BTSession->downloadFromUrl(file);
|
||||
continue;
|
||||
@ -775,7 +775,7 @@ void GUI::dropEvent(QDropEvent *event) {
|
||||
// Decode if we accept drag 'n drop or not
|
||||
void GUI::dragEnterEvent(QDragEnterEvent *event) {
|
||||
foreach(const QString &mime, event->mimeData()->formats()){
|
||||
qDebug("mimeData: %s", mime.toUtf8().data());
|
||||
qDebug("mimeData: %s", mime.toLocal8Bit().data());
|
||||
}
|
||||
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
|
||||
event->acceptProposedAction();
|
||||
@ -1191,11 +1191,11 @@ void GUI::configureSession(bool deleteOptions) {
|
||||
// We need this for urllib in search engine plugins
|
||||
#ifdef Q_WS_WIN
|
||||
char proxystr[512];
|
||||
snprintf(proxystr, 512, "http_proxy=%s", proxy_str.toUtf8().data());
|
||||
snprintf(proxystr, 512, "http_proxy=%s", proxy_str.toLocal8Bit().data());
|
||||
putenv(proxystr);
|
||||
#else
|
||||
qDebug("HTTP: proxy string: %s", proxy_str.toUtf8().data());
|
||||
setenv("http_proxy", proxy_str.toUtf8().data(), 1);
|
||||
qDebug("HTTP: proxy string: %s", proxy_str.toLocal8Bit().data());
|
||||
setenv("http_proxy", proxy_str.toLocal8Bit().data(), 1);
|
||||
#endif
|
||||
} else {
|
||||
qDebug("Disabling search proxy");
|
||||
|
@ -150,7 +150,7 @@ class torrent_file {
|
||||
bool removeFromFS(QString saveDir) const {
|
||||
QString full_path = saveDir + QDir::separator() + rel_path;
|
||||
if(!QFile::exists(full_path)) {
|
||||
qDebug("%s does not exist, no need to remove it", full_path.toUtf8().data());
|
||||
qDebug("%s does not exist, no need to remove it", full_path.toLocal8Bit().data());
|
||||
return true;
|
||||
}
|
||||
bool success = true;
|
||||
@ -160,11 +160,11 @@ class torrent_file {
|
||||
success = s && success;
|
||||
}
|
||||
if(is_dir) {
|
||||
qDebug("trying to remove directory: %s", full_path.toUtf8().data());
|
||||
qDebug("trying to remove directory: %s", full_path.toLocal8Bit().data());
|
||||
QDir dir(full_path);
|
||||
dir.rmdir(full_path);
|
||||
} else {
|
||||
qDebug("trying to remove file: %s", full_path.toUtf8().data());
|
||||
qDebug("trying to remove file: %s", full_path.toLocal8Bit().data());
|
||||
bool s = QFile::remove(full_path);
|
||||
success = s && success;
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ unsigned int bittorrent::getUnfinishedPausedTorrentsNb() const {
|
||||
// Delete a torrent from the session, given its hash
|
||||
// permanent = true means that the torrent will be removed from the hard-drive too
|
||||
void bittorrent::deleteTorrent(QString hash, bool permanent) {
|
||||
qDebug("Deleting torrent with hash: %s", hash.toUtf8().data());
|
||||
qDebug("Deleting torrent with hash: %s", hash.toLocal8Bit().data());
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
if(!h.is_valid()) {
|
||||
qDebug("/!\\ Error: Invalid handle");
|
||||
@ -344,7 +344,7 @@ void bittorrent::loadWebSeeds(QString hash) {
|
||||
QStringList seeds_to_delete;
|
||||
QStringList existing_seeds = h.url_seeds();
|
||||
foreach(const QString &existing_seed, existing_seeds) {
|
||||
if(!url_seeds.contains(existing_seed.toUtf8())) {
|
||||
if(!url_seeds.contains(existing_seed.toLocal8Bit())) {
|
||||
seeds_to_delete << existing_seed;
|
||||
}
|
||||
}
|
||||
@ -372,7 +372,7 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||
// create it if it is not
|
||||
if(! torrentBackup.exists()) {
|
||||
if(! torrentBackup.mkpath(torrentBackup.path())) {
|
||||
std::cerr << "Couldn't create the directory: '" << torrentBackup.path().toUtf8().data() << "'\n";
|
||||
std::cerr << "Couldn't create the directory: '" << torrentBackup.path().toLocal8Bit().data() << "'\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@ -382,11 +382,11 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||
return h;
|
||||
}
|
||||
Q_ASSERT(!file.startsWith("http://", Qt::CaseInsensitive) && !file.startsWith("https://", Qt::CaseInsensitive) && !file.startsWith("ftp://", Qt::CaseInsensitive));
|
||||
qDebug("Adding %s to download list", file.toUtf8().data());
|
||||
qDebug("Adding %s to download list", file.toLocal8Bit().data());
|
||||
boost::intrusive_ptr<torrent_info> t;
|
||||
try {
|
||||
// Getting torrent file informations
|
||||
t = new torrent_info(file.toUtf8().data());
|
||||
t = new torrent_info(file.toLocal8Bit().data());
|
||||
} catch(std::exception&) {
|
||||
if(!from_url.isNull()) {
|
||||
addConsoleMessage(tr("Unable to decode torrent file: '%1'", "e.g: Unable to decode torrent file: '/home/y/xxx.torrent'").arg(from_url), QString::fromUtf8("red"));
|
||||
@ -410,7 +410,7 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||
QFileInfo fi(file);
|
||||
QString old_hash = fi.baseName();
|
||||
if(old_hash != hash){
|
||||
qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toUtf8().data(), hash.toUtf8().data());
|
||||
qDebug("* ERROR: Strange, hash changed from %s to %s", old_hash.toLocal8Bit().data(), hash.toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
// Check if torrent is already in download list
|
||||
@ -436,8 +436,8 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||
add_torrent_params p;
|
||||
//Getting fast resume data if existing
|
||||
std::vector<char> buf;
|
||||
qDebug("Trying to load fastresume data: %s", (torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toUtf8().data());
|
||||
if (load_file((torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toUtf8().data(), buf) == 0) {
|
||||
qDebug("Trying to load fastresume data: %s", (torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toLocal8Bit().data());
|
||||
if (load_file((torrentBackup.path()+QDir::separator()+hash+QString(".fastresume")).toLocal8Bit().data(), buf) == 0) {
|
||||
fastResume = true;
|
||||
p.resume_data = &buf;
|
||||
qDebug("Successfuly loaded");
|
||||
@ -447,13 +447,13 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
|
||||
QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
|
||||
if(!savepath_file.exists()) {
|
||||
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
savepath_file.write(savePath.toUtf8());
|
||||
savepath_file.write(savePath.toLocal8Bit());
|
||||
savepath_file.close();
|
||||
}
|
||||
if(defaultTempPath.isEmpty()) {
|
||||
p.save_path = savePath.toUtf8().data();
|
||||
p.save_path = savePath.toLocal8Bit().data();
|
||||
} else {
|
||||
p.save_path = defaultTempPath.toUtf8().data();
|
||||
p.save_path = defaultTempPath.toLocal8Bit().data();
|
||||
}
|
||||
p.ti = t;
|
||||
// Preallocate all?
|
||||
@ -648,7 +648,7 @@ void bittorrent::enableLSD(bool b) {
|
||||
}
|
||||
|
||||
void bittorrent::loadSessionState() {
|
||||
boost::filesystem::ifstream ses_state_file((misc::qBittorrentPath()+QString::fromUtf8("ses_state")).toUtf8().data()
|
||||
boost::filesystem::ifstream ses_state_file((misc::qBittorrentPath()+QString::fromUtf8("ses_state")).toLocal8Bit().data()
|
||||
, std::ios_base::binary);
|
||||
ses_state_file.unsetf(std::ios_base::skipws);
|
||||
s->load_state(bdecode(
|
||||
@ -659,7 +659,7 @@ void bittorrent::loadSessionState() {
|
||||
void bittorrent::saveSessionState() {
|
||||
qDebug("Saving session state to disk...");
|
||||
entry session_state = s->state();
|
||||
boost::filesystem::ofstream out((misc::qBittorrentPath()+QString::fromUtf8("ses_state")).toUtf8().data()
|
||||
boost::filesystem::ofstream out((misc::qBittorrentPath()+QString::fromUtf8("ses_state")).toLocal8Bit().data()
|
||||
, std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), session_state);
|
||||
@ -672,7 +672,7 @@ bool bittorrent::enableDHT(bool b) {
|
||||
entry dht_state;
|
||||
QString dht_state_path = misc::qBittorrentPath()+QString::fromUtf8("dht_state");
|
||||
if(QFile::exists(dht_state_path)) {
|
||||
boost::filesystem::ifstream dht_state_file(dht_state_path.toUtf8().data(), std::ios_base::binary);
|
||||
boost::filesystem::ifstream dht_state_file(dht_state_path.toLocal8Bit().data(), std::ios_base::binary);
|
||||
dht_state_file.unsetf(std::ios_base::skipws);
|
||||
try{
|
||||
dht_state = bdecode(std::istream_iterator<char>(dht_state_file), std::istream_iterator<char>());
|
||||
@ -701,13 +701,13 @@ bool bittorrent::enableDHT(bool b) {
|
||||
}
|
||||
|
||||
void bittorrent::saveTorrentSpeedLimits(QString hash) {
|
||||
qDebug("Saving speedLimits file for %s", hash.toUtf8().data());
|
||||
qDebug("Saving speedLimits file for %s", hash.toLocal8Bit().data());
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
int download_limit = h.download_limit();
|
||||
int upload_limit = h.upload_limit();
|
||||
QFile speeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".speedLimits");
|
||||
if(!speeds_file.open(QIODevice::WriteOnly | QIODevice::Text)) {
|
||||
qDebug("* Error: Couldn't open speed limits file for torrent: %s", hash.toUtf8().data());
|
||||
qDebug("* Error: Couldn't open speed limits file for torrent: %s", hash.toLocal8Bit().data());
|
||||
return;
|
||||
}
|
||||
speeds_file.write(misc::toQByteArray(download_limit)+QByteArray(" ")+misc::toQByteArray(upload_limit));
|
||||
@ -715,7 +715,7 @@ void bittorrent::saveTorrentSpeedLimits(QString hash) {
|
||||
}
|
||||
|
||||
void bittorrent::loadTorrentSpeedLimits(QString hash) {
|
||||
// qDebug("Loading speedLimits file for %s", hash.toUtf8().data());
|
||||
// qDebug("Loading speedLimits file for %s", hash.toLocal8Bit().data());
|
||||
QTorrentHandle h = getTorrentHandle(hash);
|
||||
QFile speeds_file(misc::qBittorrentPath()+"BT_backup"+QDir::separator()+hash+".speedLimits");
|
||||
if(!speeds_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
@ -748,7 +748,7 @@ void bittorrent::loadFilesPriorities(QTorrentHandle &h) {
|
||||
}
|
||||
// Read saved file
|
||||
if(!pieces_file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug("* Error: Couldn't open priorities file: %s", hash.toUtf8().data());
|
||||
qDebug("* Error: Couldn't open priorities file: %s", hash.toLocal8Bit().data());
|
||||
return;
|
||||
}
|
||||
QByteArray pieces_priorities = pieces_file.readAll();
|
||||
@ -833,7 +833,7 @@ void bittorrent::saveFastResumeData() {
|
||||
// Remove old fastresume file if it exists
|
||||
QFile::remove(torrentBackup.path()+QDir::separator()+ h.hash() + ".fastresume");
|
||||
QString file = h.hash()+".fastresume";
|
||||
boost::filesystem::ofstream out(fs::path(torrentBackup.path().toUtf8().data()) / file.toUtf8().data(), std::ios_base::binary);
|
||||
boost::filesystem::ofstream out(fs::path(torrentBackup.path().toLocal8Bit().data()) / file.toLocal8Bit().data(), std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), *rd->resume_data);
|
||||
// Remove torrent from session
|
||||
@ -888,7 +888,7 @@ bool bittorrent::isFilePreviewPossible(QString hash) const{
|
||||
// and add them to download list
|
||||
void bittorrent::scanDirectory(QString scan_dir) {
|
||||
FSMutex->lock();
|
||||
qDebug("Scanning directory: %s", scan_dir.toUtf8().data());
|
||||
qDebug("Scanning directory: %s", scan_dir.toLocal8Bit().data());
|
||||
QDir dir(scan_dir);
|
||||
QStringList filters;
|
||||
filters << "*.torrent";
|
||||
@ -897,10 +897,10 @@ void bittorrent::scanDirectory(QString scan_dir) {
|
||||
QString fullPath = dir.path()+QDir::separator()+file;
|
||||
QFile torrent(fullPath);
|
||||
if(torrent.size() != 0) {
|
||||
qDebug("Adding for scan_dir: %s", fullPath.toUtf8().data());
|
||||
qDebug("Adding for scan_dir: %s", fullPath.toLocal8Bit().data());
|
||||
addTorrent(fullPath, true);
|
||||
} else {
|
||||
qDebug("Ignoring empty file: %s", fullPath.toUtf8().data());
|
||||
qDebug("Ignoring empty file: %s", fullPath.toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
FSMutex->unlock();
|
||||
@ -1055,7 +1055,7 @@ bool bittorrent::loadTrackerFile(QString hash) {
|
||||
}
|
||||
|
||||
void bittorrent::saveTrackerFile(QString hash) {
|
||||
qDebug("Saving tracker file for %s", hash.toUtf8().data());
|
||||
qDebug("Saving tracker file for %s", hash.toLocal8Bit().data());
|
||||
QDir torrentBackup(misc::qBittorrentPath() + "BT_backup");
|
||||
QFile tracker_file(torrentBackup.path()+QDir::separator()+ hash + ".trackers");
|
||||
if(tracker_file.exists()) {
|
||||
@ -1161,7 +1161,7 @@ void bittorrent::readAlerts() {
|
||||
}
|
||||
}
|
||||
h.save_resume_data();
|
||||
qDebug("Received finished alert for %s", h.name().toUtf8().data());
|
||||
qDebug("Received finished alert for %s", h.name().toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
else if (save_resume_data_alert* p = dynamic_cast<save_resume_data_alert*>(a.get())) {
|
||||
@ -1171,10 +1171,10 @@ void bittorrent::readAlerts() {
|
||||
// Delete old fastresume file if necessary
|
||||
if(QFile::exists(file))
|
||||
QFile::remove(file);
|
||||
qDebug("Saving fastresume data in %s", file.toUtf8().data());
|
||||
qDebug("Saving fastresume data in %s", file.toLocal8Bit().data());
|
||||
if (p->resume_data)
|
||||
{
|
||||
boost::filesystem::ofstream out(fs::path(torrentBackup.path().toUtf8().data()) / file.toUtf8().data(), std::ios_base::binary);
|
||||
boost::filesystem::ofstream out(fs::path(torrentBackup.path().toLocal8Bit().data()) / file.toLocal8Bit().data(), std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), *p->resume_data);
|
||||
}
|
||||
@ -1211,7 +1211,7 @@ void bittorrent::readAlerts() {
|
||||
else if (tracker_reply_alert* p = dynamic_cast<tracker_reply_alert*>(a.get())) {
|
||||
QTorrentHandle h(p->handle);
|
||||
if(h.is_valid()){
|
||||
qDebug("Received a tracker reply from %s", (const char*)h.current_tracker().toUtf8());
|
||||
qDebug("Received a tracker reply from %s", (const char*)h.current_tracker().toLocal8Bit());
|
||||
QString hash = h.hash();
|
||||
QHash<QString, QString> errors = trackersErrors.value(hash, QHash<QString, QString>());
|
||||
// p->url requires at least libtorrent v0.13.1
|
||||
@ -1239,7 +1239,7 @@ void bittorrent::readAlerts() {
|
||||
else if (fastresume_rejected_alert* p = dynamic_cast<fastresume_rejected_alert*>(a.get())) {
|
||||
QTorrentHandle h(p->handle);
|
||||
if(h.is_valid()){
|
||||
qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toUtf8().data(), p->message().c_str());
|
||||
qDebug("/!\\ Fast resume failed for %s, reason: %s", h.name().toLocal8Bit().data(), p->message().c_str());
|
||||
addConsoleMessage(tr("Fast resume data was rejected for torrent %1, checking again...").arg(h.name()), QString::fromUtf8("red"));
|
||||
//emit fastResumeDataRejected(h.name());
|
||||
}
|
||||
@ -1252,7 +1252,7 @@ void bittorrent::readAlerts() {
|
||||
QTorrentHandle h(p->handle);
|
||||
if(h.is_valid()){
|
||||
QString hash = h.hash();
|
||||
qDebug("%s have just finished checking", hash.toUtf8().data());
|
||||
qDebug("%s have just finished checking", hash.toLocal8Bit().data());
|
||||
emit torrentFinishedChecking(h);
|
||||
}
|
||||
}
|
||||
@ -1291,7 +1291,7 @@ QString bittorrent::getSavePath(QString hash) {
|
||||
QDir saveDir(savePath);
|
||||
if(!saveDir.exists()) {
|
||||
if(!saveDir.mkpath(saveDir.path())) {
|
||||
std::cerr << "Couldn't create the save directory: " << saveDir.path().toUtf8().data() << "\n";
|
||||
std::cerr << "Couldn't create the save directory: " << saveDir.path().toLocal8Bit().data() << "\n";
|
||||
// XXX: handle this better
|
||||
return QDir::homePath();
|
||||
}
|
||||
@ -1357,7 +1357,7 @@ void bittorrent::saveDHTEntry() {
|
||||
if(DHTEnabled) {
|
||||
try{
|
||||
entry dht_state = s->dht_state();
|
||||
boost::filesystem::ofstream out((misc::qBittorrentPath()+QString::fromUtf8("dht_state")).toUtf8().data(), std::ios_base::binary);
|
||||
boost::filesystem::ofstream out((misc::qBittorrentPath()+QString::fromUtf8("dht_state")).toLocal8Bit().data(), std::ios_base::binary);
|
||||
out.unsetf(std::ios_base::skipws);
|
||||
bencode(std::ostream_iterator<char>(out), dht_state);
|
||||
qDebug("DHT entry saved");
|
||||
|
@ -192,7 +192,7 @@ void createtorrent::handleCreationSuccess(QString path, const char* branch_path)
|
||||
// Create save path file
|
||||
boost::intrusive_ptr<torrent_info> t;
|
||||
try {
|
||||
t = new torrent_info(path.toUtf8().data());
|
||||
t = new torrent_info(path.toLocal8Bit().data());
|
||||
} catch(std::exception&) {
|
||||
QMessageBox::critical(0, tr("Torrent creation"), tr("Created torrent file is invalid. It won't be added to download list."));
|
||||
return;
|
||||
@ -238,7 +238,7 @@ void torrentCreatorThread::run() {
|
||||
try {
|
||||
file_storage fs;
|
||||
file_pool fp;
|
||||
path full_path = complete(path(input_path.toUtf8().data()));
|
||||
path full_path = complete(path(input_path.toLocal8Bit().data()));
|
||||
// Adding files to the torrent
|
||||
add_files(fs, full_path, file_filter);
|
||||
if(abort) return;
|
||||
@ -247,10 +247,10 @@ void torrentCreatorThread::run() {
|
||||
// Add url seeds
|
||||
QString seed;
|
||||
foreach(seed, url_seeds){
|
||||
t.add_url_seed(seed.toUtf8().data());
|
||||
t.add_url_seed(seed.toLocal8Bit().data());
|
||||
}
|
||||
for(int i=0; i<trackers.size(); ++i){
|
||||
t.add_tracker(trackers.at(i).toUtf8().data());
|
||||
t.add_tracker(trackers.at(i).toLocal8Bit().data());
|
||||
}
|
||||
if(abort) return;
|
||||
// calculate the hash for all pieces
|
||||
@ -258,14 +258,14 @@ void torrentCreatorThread::run() {
|
||||
// Set qBittorrent as creator and add user comment to
|
||||
// torrent_info structure
|
||||
t.set_creator(creator_str);
|
||||
t.set_comment((const char*)comment.toUtf8());
|
||||
t.set_comment((const char*)comment.toLocal8Bit());
|
||||
// Is private ?
|
||||
if(is_private){
|
||||
t.set_priv(true);
|
||||
}
|
||||
if(abort) return;
|
||||
// create the torrent and print it to out
|
||||
ofstream out(complete(path((const char*)save_path.toUtf8())), std::ios_base::binary);
|
||||
ofstream out(complete(path((const char*)save_path.toLocal8Bit())), std::ios_base::binary);
|
||||
bencode(std::ostream_iterator<char>(out), t.generate());
|
||||
emit updateProgress(100);
|
||||
emit creationSuccess(save_path, full_path.branch_path().string().c_str());
|
||||
|
@ -84,7 +84,7 @@ void subDownloadThread::run(){
|
||||
filePath = tmpfile->fileName();
|
||||
}
|
||||
delete tmpfile;
|
||||
FILE *f = fopen(filePath.toUtf8().data(), "wb");
|
||||
FILE *f = fopen(filePath.toLocal8Bit().data(), "wb");
|
||||
if(!f) {
|
||||
std::cerr << "couldn't open destination file" << "\n";
|
||||
return;
|
||||
@ -93,7 +93,7 @@ void subDownloadThread::run(){
|
||||
CURLcode res = (CURLcode)-1;
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
std::string c_url = url.toUtf8().data();
|
||||
std::string c_url = url.toLocal8Bit().data();
|
||||
curl_easy_setopt(curl, CURLOPT_URL, c_url.c_str());
|
||||
// SSL support
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
@ -105,8 +105,8 @@ void subDownloadThread::run(){
|
||||
// Proxy enabled
|
||||
QString IP = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/IP"), "0.0.0.0").toString();
|
||||
QString port = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Port"), 8080).toString();
|
||||
qDebug("Using proxy: %s", (IP+QString(":")+port).toUtf8().data());
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYPORT, (IP+QString(":")+port).toUtf8().data());
|
||||
qDebug("Using proxy: %s", (IP+QString(":")+port).toLocal8Bit().data());
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYPORT, (IP+QString(":")+port).toLocal8Bit().data());
|
||||
// Default proxy type is HTTP, we must change if it is SOCKS5
|
||||
if(intValue%2==0) {
|
||||
qDebug("Proxy is SOCKS5, not HTTP");
|
||||
@ -117,7 +117,7 @@ void subDownloadThread::run(){
|
||||
qDebug("Proxy requires authentication, authenticating");
|
||||
QString username = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Username"), QString()).toString();
|
||||
QString password = settings.value(QString::fromUtf8("Preferences/Connection/HTTPProxy/Password"), QString()).toString();
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (username+QString(":")+password).toUtf8().data());
|
||||
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, (username+QString(":")+password).toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
// We have to define CURLOPT_WRITEFUNCTION or it will crash on windows
|
||||
@ -131,7 +131,7 @@ void subDownloadThread::run(){
|
||||
curl_easy_setopt(curl, CURLOPT_AUTOREFERER, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(curl, CURLOPT_MAXREDIRS, -1);
|
||||
qDebug("Downloading %s", url.toUtf8().data());
|
||||
qDebug("Downloading %s", url.toLocal8Bit().data());
|
||||
if(!abort)
|
||||
res = curl_easy_perform(curl);
|
||||
/* always cleanup */
|
||||
|
@ -572,7 +572,7 @@ bool DownloadingTorrents::updateTorrent(QTorrentHandle h) {
|
||||
void DownloadingTorrents::addTorrent(QString hash) {
|
||||
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
int row = getRowFromHash(hash);
|
||||
qDebug("DL: addTorrent(): %s, row: %d", (const char*)hash.toUtf8(), row);
|
||||
qDebug("DL: addTorrent(): %s, row: %d", (const char*)hash.toLocal8Bit(), row);
|
||||
if(row != -1) return;
|
||||
row = DLListModel->rowCount();
|
||||
// Adding torrent to download list
|
||||
|
@ -85,7 +85,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) {
|
||||
QStringList files=event->mimeData()->text().split(QString::fromUtf8("\n"));
|
||||
QString file;
|
||||
foreach(file, files) {
|
||||
qDebug("dropped %s", file.toUtf8().data());
|
||||
qDebug("dropped %s", file.toLocal8Bit().data());
|
||||
file = file.replace("file://", "");
|
||||
if(file.startsWith("http://", Qt::CaseInsensitive) || file.startsWith("https://", Qt::CaseInsensitive) || file.startsWith("ftp://", Qt::CaseInsensitive)) {
|
||||
downloader->downloadUrl(file);
|
||||
@ -108,7 +108,7 @@ void engineSelectDlg::dropEvent(QDropEvent *event) {
|
||||
void engineSelectDlg::dragEnterEvent(QDragEnterEvent *event) {
|
||||
QString mime;
|
||||
foreach(mime, event->mimeData()->formats()){
|
||||
qDebug("mimeData: %s", mime.toUtf8().data());
|
||||
qDebug("mimeData: %s", mime.toLocal8Bit().data());
|
||||
}
|
||||
if (event->mimeData()->hasFormat(QString::fromUtf8("text/plain")) || event->mimeData()->hasFormat(QString::fromUtf8("text/uri-list"))) {
|
||||
event->acceptProposedAction();
|
||||
@ -123,7 +123,7 @@ void engineSelectDlg::saveSettings() {
|
||||
foreach(engine, installed_engines.keys()) {
|
||||
known_engines << engine;
|
||||
known_enginesEnabled << QVariant(installed_engines.value(engine, true));
|
||||
qDebug("Engine %s has state: %d", engine.toUtf8().data(), installed_engines.value(engine, true));
|
||||
qDebug("Engine %s has state: %d", engine.toLocal8Bit().data(), installed_engines.value(engine, true));
|
||||
}
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
settings.setValue(QString::fromUtf8("SearchEngines/knownEngines"), known_engines);
|
||||
@ -264,7 +264,7 @@ bool engineSelectDlg::checkInstalled(QString plugin_name) const {
|
||||
result = result.replace("\r", "");
|
||||
result = result.replace("\n", "");
|
||||
QList<QByteArray> plugins_list = result.split(',');
|
||||
return plugins_list.contains(plugin_name.toUtf8());
|
||||
return plugins_list.contains(plugin_name.toLocal8Bit());
|
||||
}
|
||||
|
||||
void engineSelectDlg::loadSupportedSearchEngines(bool first) {
|
||||
@ -379,7 +379,7 @@ bool engineSelectDlg::isUpdateNeeded(QString plugin_name, float new_version) con
|
||||
void engineSelectDlg::installZipPlugin(QString path) {
|
||||
QStringList plugins;
|
||||
QStringList favicons;
|
||||
ZZIP_DIR* dir = zzip_dir_open(path.toUtf8().data(), 0);
|
||||
ZZIP_DIR* dir = zzip_dir_open(path.toLocal8Bit().data(), 0);
|
||||
if(!dir) {
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("Search engine plugin archive could not be read."));
|
||||
return;
|
||||
@ -412,8 +412,8 @@ void engineSelectDlg::installZipPlugin(QString path) {
|
||||
foreach(plugin, plugins) {
|
||||
QString plugin_name = plugin.split(QDir::separator()).last();
|
||||
plugin_name.chop(3); // Remove .py extension
|
||||
qDebug("Detected plugin %s in archive", plugin_name.toUtf8().data());
|
||||
ZZIP_FILE* fp = zzip_file_open(dir, plugin.toUtf8().data(), 0);
|
||||
qDebug("Detected plugin %s in archive", plugin_name.toLocal8Bit().data());
|
||||
ZZIP_FILE* fp = zzip_file_open(dir, plugin.toLocal8Bit().data(), 0);
|
||||
if(fp) {
|
||||
QTemporaryFile *tmpfile = new QTemporaryFile();
|
||||
QString tmpPath;
|
||||
@ -430,7 +430,7 @@ void engineSelectDlg::installZipPlugin(QString path) {
|
||||
tmpfile->close();
|
||||
} else {
|
||||
qDebug("Could not open tmp file");
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
delete tmpfile;
|
||||
continue;
|
||||
}
|
||||
@ -441,12 +441,12 @@ void engineSelectDlg::installZipPlugin(QString path) {
|
||||
qDebug("Deleted tmpfile");
|
||||
} else {
|
||||
qDebug("Cannot read file in archive");
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
}
|
||||
}
|
||||
QString favicon;
|
||||
foreach(favicon, favicons) {
|
||||
qDebug("Detected favicon %s in archive", favicon.toUtf8().data());
|
||||
qDebug("Detected favicon %s in archive", favicon.toLocal8Bit().data());
|
||||
// Ok we have a favicon here
|
||||
QString plugin_name = favicon.split(QDir::separator()).last();
|
||||
plugin_name.chop(4); // Remove .png extension
|
||||
@ -457,7 +457,7 @@ void engineSelectDlg::installZipPlugin(QString path) {
|
||||
if(QFile::exists(iconPath)) {
|
||||
QFile::remove(iconPath);
|
||||
}
|
||||
ZZIP_FILE* fp = zzip_file_open(dir, favicon.toUtf8().data(), 0);
|
||||
ZZIP_FILE* fp = zzip_file_open(dir, favicon.toLocal8Bit().data(), 0);
|
||||
if(fp) {
|
||||
QFile dest_icon(iconPath);
|
||||
// Write icon
|
||||
@ -482,12 +482,12 @@ void engineSelectDlg::installZipPlugin(QString path) {
|
||||
#endif
|
||||
|
||||
void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
||||
qDebug("Asked to install plugin at %s", path.toUtf8().data());
|
||||
qDebug("Asked to install plugin at %s", path.toLocal8Bit().data());
|
||||
float new_version = misc::getPluginVersion(path);
|
||||
qDebug("Version to be installed: %.2f", new_version);
|
||||
if(!isUpdateNeeded(plugin_name, new_version)) {
|
||||
qDebug("Apparently update it not needed, we have a more recent version");
|
||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("A more recent version of %1 search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("A more recent version of %1 search engine plugin is already installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
return;
|
||||
}
|
||||
// Process with install
|
||||
@ -509,12 +509,12 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
||||
// restore backup
|
||||
QFile::copy(dest_path+".bak", dest_path);
|
||||
QFile::remove(dest_path+".bak");
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be updated, keeping old version.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
return;
|
||||
} else {
|
||||
// Remove broken file
|
||||
QFile::remove(dest_path);
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::warning(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin could not be installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -525,10 +525,10 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
||||
// Refresh plugin list
|
||||
loadSupportedSearchEngines();
|
||||
if(update) {
|
||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully updated.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
return;
|
||||
} else {
|
||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::information(this, tr("Search plugin install")+" -- "+tr("qBittorrent"), tr("%1 search engine plugin was successfully installed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -595,17 +595,17 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file, QString updateSer
|
||||
plugin_name.chop(1); // remove trailing ':'
|
||||
bool ok;
|
||||
float version = list.last().toFloat(&ok);
|
||||
qDebug("read line %s: %.2f", plugin_name.toUtf8().data(), version);
|
||||
qDebug("read line %s: %.2f", plugin_name.toLocal8Bit().data(), version);
|
||||
if(!ok) continue;
|
||||
file_correct = true;
|
||||
if(isUpdateNeeded(plugin_name, version)) {
|
||||
qDebug("Plugin: %s is outdated", plugin_name.toUtf8().data());
|
||||
qDebug("Plugin: %s is outdated", plugin_name.toLocal8Bit().data());
|
||||
// Downloading update
|
||||
downloader->downloadUrl(updateServer+plugin_name+".pyqBT"); // Actually this is really a .py
|
||||
downloader->downloadUrl(updateServer+plugin_name+".png");
|
||||
updated = true;
|
||||
}else {
|
||||
qDebug("Plugin: %s is up to date", plugin_name.toUtf8().data());
|
||||
qDebug("Plugin: %s is up to date", plugin_name.toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
// Close file
|
||||
@ -619,7 +619,7 @@ bool engineSelectDlg::parseVersionsFile(QString versions_file, QString updateSer
|
||||
}
|
||||
|
||||
void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||
qDebug("engineSelectDlg received %s", url.toUtf8().data());
|
||||
qDebug("engineSelectDlg received %s", url.toLocal8Bit().data());
|
||||
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
|
||||
// Icon downloaded
|
||||
QImage fileIcon;
|
||||
@ -677,7 +677,7 @@ void engineSelectDlg::processDownloadedFile(QString url, QString filePath) {
|
||||
|
||||
void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
|
||||
if(url.endsWith("favicon.ico", Qt::CaseInsensitive)){
|
||||
qDebug("Could not download favicon: %s, reason: %s", url.toUtf8().data(), reason.toUtf8().data());
|
||||
qDebug("Could not download favicon: %s, reason: %s", url.toLocal8Bit().data(), reason.toLocal8Bit().data());
|
||||
return;
|
||||
}
|
||||
if(url == "http://www.dchris.eu/search_engine2/versions.txt") {
|
||||
@ -695,13 +695,13 @@ void engineSelectDlg::handleDownloadFailure(QString url, QString reason) {
|
||||
QString plugin_name = url.split('/').last();
|
||||
plugin_name.replace(".pyqBT", "", Qt::CaseInsensitive);
|
||||
plugin_name.replace(".py", "", Qt::CaseInsensitive);
|
||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
}
|
||||
#ifdef HAVE_ZZIP
|
||||
if(url.endsWith(".zip", Qt::CaseInsensitive)) {
|
||||
QString plugin_name = url.split('/').last();
|
||||
plugin_name.replace(".zip", "", Qt::CaseInsensitive);
|
||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toUtf8().data()));
|
||||
QMessageBox::warning(this, tr("Search plugin update")+" -- "+tr("qBittorrent"), tr("Sorry, %1 search plugin install failed.", "%1 is the name of the search engine").arg(plugin_name.toLocal8Bit().data()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -199,9 +199,9 @@ class FilterParserThread : public QThread {
|
||||
} else {
|
||||
// IPv6, ex : 1fff:0000:0a88:85a3:0000:0000:ac1f:8001
|
||||
IP = strStartIP.split(':');
|
||||
address_v6 start = address_v6::from_string(strStartIP.remove(':', 0).toUtf8().data());
|
||||
address_v6 start = address_v6::from_string(strStartIP.remove(':', 0).toLocal8Bit().data());
|
||||
IP = strEndIP.split(':');
|
||||
address_v6 last = address_v6::from_string(strEndIP.remove(':', 0).toUtf8().data());
|
||||
address_v6 last = address_v6::from_string(strEndIP.remove(':', 0).toLocal8Bit().data());
|
||||
// Apply to bittorrent session
|
||||
filter.add_rule(start, last, ip_filter::blocked);
|
||||
}
|
||||
|
@ -56,12 +56,12 @@ HttpConnection::~HttpConnection()
|
||||
}
|
||||
|
||||
void HttpConnection::processDownloadedFile(QString url, QString file_path) {
|
||||
qDebug("URL %s successfully downloaded !", (const char*)url.toUtf8());
|
||||
qDebug("URL %s successfully downloaded !", (const char*)url.toLocal8Bit());
|
||||
emit torrentReadyToBeDownloaded(file_path, false, url, false);
|
||||
}
|
||||
|
||||
void HttpConnection::handleDownloadFailure(QString url, QString reason) {
|
||||
std::cerr << "Could not download " << (const char*)url.toUtf8() << ", reason: " << (const char*)reason.toUtf8() << "\n";
|
||||
std::cerr << "Could not download " << (const char*)url.toLocal8Bit() << ", reason: " << (const char*)reason.toLocal8Bit() << "\n";
|
||||
}
|
||||
|
||||
void HttpConnection::read()
|
||||
@ -103,7 +103,7 @@ void HttpConnection::respond()
|
||||
{
|
||||
//qDebug("Respond called");
|
||||
QStringList auth = parser.value("Authorization").split(" ", QString::SkipEmptyParts);
|
||||
if (auth.size() != 2 || QString::compare(auth[0], "Basic", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth[1].toUtf8()))
|
||||
if (auth.size() != 2 || QString::compare(auth[0], "Basic", Qt::CaseInsensitive) != 0 || !parent->isAuthorized(auth[1].toLocal8Bit()))
|
||||
{
|
||||
generator.setStatusLine(401, "Unauthorized");
|
||||
generator.setValue("WWW-Authenticate", "Basic realm=\"you know what\"");
|
||||
@ -187,7 +187,7 @@ void HttpConnection::respondCommand(QString command)
|
||||
foreach(QString url, list){
|
||||
url = url.trimmed();
|
||||
if(!url.isEmpty()){
|
||||
qDebug("Downloading url: %s", (const char*)url.toUtf8());
|
||||
qDebug("Downloading url: %s", (const char*)url.toLocal8Bit());
|
||||
emit UrlReadyToBeDownloaded(url);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ void HttpResponseGenerator::setMessage(const QByteArray message)
|
||||
|
||||
void HttpResponseGenerator::setMessage(const QString message)
|
||||
{
|
||||
setMessage(message.QString::toUtf8());
|
||||
setMessage(message.QString::toLocal8Bit());
|
||||
}
|
||||
|
||||
void HttpResponseGenerator::stripMessage()
|
||||
@ -49,7 +49,7 @@ void HttpResponseGenerator::stripMessage()
|
||||
|
||||
QByteArray HttpResponseGenerator::toByteArray() const
|
||||
{
|
||||
return QHttpResponseHeader::toString().toUtf8() + message;
|
||||
return QHttpResponseHeader::toString().toLocal8Bit() + message;
|
||||
}
|
||||
|
||||
void HttpResponseGenerator::setContentTypeByExt(const QString ext)
|
||||
|
@ -96,7 +96,7 @@ void HttpServer::onTimer() {
|
||||
void HttpServer::setAuthorization(QString username, QString password)
|
||||
{
|
||||
QString cat = username + ":" + password;
|
||||
base64 = QByteArray(cat.toUtf8()).toBase64();
|
||||
base64 = QByteArray(cat.toLocal8Bit()).toBase64();
|
||||
}
|
||||
|
||||
bool HttpServer::isAuthorized(QByteArray auth) const
|
||||
|
@ -154,10 +154,10 @@ int main(int argc, char *argv[]){
|
||||
if(argc > 1){
|
||||
QStringList params;
|
||||
for(int i=1;i<argc;++i){
|
||||
params << QString::fromUtf8(argv[i]);
|
||||
params << QString::fromLocal8Bit(argv[i]);
|
||||
std::cout << argv[i] << '\n';
|
||||
}
|
||||
QByteArray block = params.join("\n").toUtf8();
|
||||
QByteArray block = params.join("\n").toLocal8Bit();
|
||||
std::cout << "writting: " << block.data() << '\n';
|
||||
std::cout << "size: " << block.size() << '\n';
|
||||
uint val = localSocket.write(block);
|
||||
@ -192,9 +192,9 @@ int main(int argc, char *argv[]){
|
||||
settings.setValue(QString::fromUtf8("Preferences/General/Locale"), locale);
|
||||
}
|
||||
if(translator.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
||||
qDebug("%s locale recognized, using translation.", (const char*)locale.toUtf8());
|
||||
qDebug("%s locale recognized, using translation.", (const char*)locale.toLocal8Bit());
|
||||
}else{
|
||||
qDebug("%s locale unrecognized, using default (en_GB).", (const char*)locale.toUtf8());
|
||||
qDebug("%s locale unrecognized, using default (en_GB).", (const char*)locale.toLocal8Bit());
|
||||
}
|
||||
app->installTranslator(&translator);
|
||||
app->setApplicationName(QString::fromUtf8("qBittorrent"));
|
||||
|
@ -218,7 +218,7 @@ class misc : public QObject{
|
||||
static float getPluginVersion(QString filePath) {
|
||||
QFile plugin(filePath);
|
||||
if(!plugin.exists()){
|
||||
qDebug("%s plugin does not exist, returning 0.0", filePath.toUtf8().data());
|
||||
qDebug("%s plugin does not exist, returning 0.0", filePath.toLocal8Bit().data());
|
||||
return 0.0;
|
||||
}
|
||||
if(!plugin.open(QIODevice::ReadOnly | QIODevice::Text)){
|
||||
@ -231,7 +231,7 @@ class misc : public QObject{
|
||||
line = line.split(' ').last();
|
||||
line.replace("\n", "");
|
||||
version = line.toFloat();
|
||||
qDebug("plugin %s version: %.2f", filePath.toUtf8().data(), version);
|
||||
qDebug("plugin %s version: %.2f", filePath.toLocal8Bit().data(), version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ class previewSelect: public QDialog, private Ui::preview {
|
||||
return;
|
||||
}
|
||||
}
|
||||
qDebug("Cannot find file: %s", path.toUtf8().data());
|
||||
qDebug("Cannot find file: %s", path.toLocal8Bit().data());
|
||||
QMessageBox::critical(0, tr("Preview impossible"), tr("Sorry, we can't preview this file"));
|
||||
close();
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ void properties::loadWebSeeds(){
|
||||
// Add manually added url seeds
|
||||
foreach(const QString &url_seed, urlSeeds){
|
||||
listWebSeeds->addItem(url_seed);
|
||||
qDebug("Added custom url seed to list: %s", url_seed.toUtf8().data());
|
||||
qDebug("Added custom url seed to list: %s", url_seed.toLocal8Bit().data());
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,7 +470,7 @@ void properties::askWebSeed(){
|
||||
tr("New url seed:"), QLineEdit::Normal,
|
||||
QString::fromUtf8("http://www."), &ok);
|
||||
if(!ok) return;
|
||||
qDebug("Adding %s web seed", url_seed.toUtf8().data());
|
||||
qDebug("Adding %s web seed", url_seed.toLocal8Bit().data());
|
||||
if(urlSeeds.indexOf(url_seed) != -1) {
|
||||
QMessageBox::warning(this, tr("qBittorrent"),
|
||||
tr("This url seed is already in the list."),
|
||||
@ -496,7 +496,7 @@ void properties::addTrackerList(QStringList myTrackers) {
|
||||
// Add the trackers to the list
|
||||
std::vector<announce_entry> trackers = h.trackers();
|
||||
foreach(const QString& tracker, myTrackers) {
|
||||
announce_entry new_tracker(misc::toString(tracker.trimmed().toUtf8().data()));
|
||||
announce_entry new_tracker(misc::toString(tracker.trimmed().toLocal8Bit().data()));
|
||||
new_tracker.tier = 0; // Will be fixed a bit later
|
||||
trackers.push_back(new_tracker);
|
||||
misc::fixTrackersTiers(trackers);
|
||||
@ -693,7 +693,7 @@ void properties::on_changeSavePathButton_clicked() {
|
||||
// Save savepath
|
||||
QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
|
||||
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
savepath_file.write(savePath.path().toUtf8());
|
||||
savepath_file.write(savePath.path().toLocal8Bit());
|
||||
savepath_file.close();
|
||||
// Actually move storage
|
||||
h.move_storage(savePath.path());
|
||||
@ -735,7 +735,7 @@ void properties::saveWebSeeds(){
|
||||
return;
|
||||
}
|
||||
foreach(const QString &url_seed, urlSeeds){
|
||||
urlseeds_file.write((url_seed+"\n").toUtf8());
|
||||
urlseeds_file.write((url_seed+"\n").toLocal8Bit());
|
||||
}
|
||||
urlseeds_file.close();
|
||||
qDebug("url seeds were saved");
|
||||
|
@ -354,12 +354,12 @@ void QTorrentHandle::resume() {
|
||||
|
||||
void QTorrentHandle::remove_url_seed(QString seed) {
|
||||
Q_ASSERT(h.is_valid());
|
||||
h.remove_url_seed(misc::toString((const char*)seed.toUtf8()));
|
||||
h.remove_url_seed(misc::toString((const char*)seed.toLocal8Bit()));
|
||||
}
|
||||
|
||||
void QTorrentHandle::add_url_seed(QString seed) {
|
||||
Q_ASSERT(h.is_valid());
|
||||
h.add_url_seed(misc::toString((const char*)seed.toUtf8()));
|
||||
h.add_url_seed(misc::toString((const char*)seed.toLocal8Bit()));
|
||||
}
|
||||
|
||||
void QTorrentHandle::set_max_uploads(int val) {
|
||||
@ -415,7 +415,7 @@ void QTorrentHandle::set_sequential_download(bool b) {
|
||||
|
||||
void QTorrentHandle::set_tracker_login(QString username, QString password) {
|
||||
Q_ASSERT(h.is_valid());
|
||||
h.set_tracker_login(std::string(username.toUtf8().data()), std::string(password.toUtf8().data()));
|
||||
h.set_tracker_login(std::string(username.toLocal8Bit().data()), std::string(password.toLocal8Bit().data()));
|
||||
}
|
||||
|
||||
void QTorrentHandle::force_recheck() const {
|
||||
@ -425,7 +425,7 @@ void QTorrentHandle::force_recheck() const {
|
||||
|
||||
void QTorrentHandle::move_storage(QString new_path) const {
|
||||
Q_ASSERT(h.is_valid());
|
||||
h.move_storage(new_path.toUtf8().data());
|
||||
h.move_storage(new_path.toLocal8Bit().data());
|
||||
}
|
||||
|
||||
//
|
||||
|
26
src/rss.h
26
src/rss.h
@ -239,7 +239,7 @@ class RssItem : public QObject {
|
||||
author = property.text();
|
||||
property = property.nextSibling().toElement();
|
||||
}
|
||||
hash = QCryptographicHash::hash(QByteArray(title.toUtf8())+QByteArray(description.toUtf8()), QCryptographicHash::Md5);
|
||||
hash = QCryptographicHash::hash(QByteArray(title.toLocal8Bit())+QByteArray(description.toLocal8Bit()), QCryptographicHash::Md5);
|
||||
}
|
||||
|
||||
~RssItem(){
|
||||
@ -374,26 +374,26 @@ class RssStream : public QObject{
|
||||
}
|
||||
|
||||
QString getAlias() const{
|
||||
qDebug("getAlias() returned Alias: %s", (const char*)alias.toUtf8());
|
||||
qDebug("getAlias() returned Alias: %s", (const char*)alias.toLocal8Bit());
|
||||
return alias;
|
||||
}
|
||||
|
||||
void setAlias(QString _alias){
|
||||
qDebug("setAlias() to %s", (const char*)_alias.toUtf8());
|
||||
qDebug("setAlias() to %s", (const char*)_alias.toLocal8Bit());
|
||||
alias = _alias;
|
||||
}
|
||||
|
||||
// Return the alias if the stream has one, the url if it has no alias
|
||||
QString getAliasOrUrl() const{
|
||||
if(!alias.isEmpty()) {
|
||||
qDebug("getAliasOrUrl() returned alias: %s", (const char*)alias.toUtf8());
|
||||
qDebug("getAliasOrUrl() returned alias: %s", (const char*)alias.toLocal8Bit());
|
||||
return alias;
|
||||
}
|
||||
if(!title.isEmpty()) {
|
||||
qDebug("getAliasOrUrl() returned title: %s", (const char*)title.toUtf8());
|
||||
qDebug("getAliasOrUrl() returned title: %s", (const char*)title.toLocal8Bit());
|
||||
return title;
|
||||
}
|
||||
qDebug("getAliasOrUrl() returned url: %s", (const char*)url.toUtf8());
|
||||
qDebug("getAliasOrUrl() returned url: %s", (const char*)url.toLocal8Bit());
|
||||
return url;
|
||||
}
|
||||
|
||||
@ -494,7 +494,7 @@ class RssStream : public QObject{
|
||||
return -1;
|
||||
}
|
||||
else if(root.tagName() != QString::fromUtf8("rss")){
|
||||
qDebug("the file is not a rss stream, <rss> omitted: %s", root.tagName().toUtf8().data());
|
||||
qDebug("the file is not a rss stream, <rss> omitted: %s", root.tagName().toLocal8Bit().data());
|
||||
return -1;
|
||||
}
|
||||
QDomNode rss = root.firstChild();
|
||||
@ -569,7 +569,7 @@ class RssStream : public QObject{
|
||||
QDomDocument doc("Rss Seed");
|
||||
QFile fileRss(filePath);
|
||||
if(!fileRss.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qDebug("openRss error : open failed, no file or locked, %s", (const char*)filePath.toUtf8());
|
||||
qDebug("openRss error : open failed, no file or locked, %s", (const char*)filePath.toLocal8Bit());
|
||||
if(QFile::exists(filePath)) {
|
||||
fileRss.remove();
|
||||
}
|
||||
@ -622,7 +622,7 @@ class RssManager : public QObject{
|
||||
emit feedIconChanged(stream->getUrl(), stream->getIconPath());
|
||||
}
|
||||
}else{
|
||||
qDebug("Unsupported icon format at %s", (const char*)url.toUtf8());
|
||||
qDebug("Unsupported icon format at %s", (const char*)url.toLocal8Bit());
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -645,7 +645,7 @@ class RssManager : public QObject{
|
||||
void handleDownloadFailure(QString url, QString reason) {
|
||||
if(url.endsWith("favicon.ico")){
|
||||
// Icon download failure
|
||||
qDebug("Could not download icon at %s, reason: %s", (const char*)url.toUtf8(), (const char*)reason.toUtf8());
|
||||
qDebug("Could not download icon at %s, reason: %s", (const char*)url.toLocal8Bit(), (const char*)reason.toLocal8Bit());
|
||||
return;
|
||||
}
|
||||
RssStream *stream = streams.value(url, 0);
|
||||
@ -654,7 +654,7 @@ class RssManager : public QObject{
|
||||
return;
|
||||
}
|
||||
stream->setLoading(false);
|
||||
qDebug("Could not download Rss at %s, reason: %s", (const char*)url.toUtf8(), (const char*)reason.toUtf8());
|
||||
qDebug("Could not download Rss at %s, reason: %s", (const char*)url.toLocal8Bit(), (const char*)reason.toLocal8Bit());
|
||||
stream->setDownloadFailed();
|
||||
emit feedInfosChanged(url, stream->getAliasOrUrl(), stream->getNbUnRead());
|
||||
}
|
||||
@ -665,7 +665,7 @@ class RssManager : public QObject{
|
||||
QString url = stream->getUrl();
|
||||
if(stream->isLoading()) return;
|
||||
if(stream->getLastRefreshElapsed() != -1 && stream->getLastRefreshElapsed() < (int)refreshInterval) return;
|
||||
qDebug("Refreshing old feed: %s...", (const char*)url.toUtf8());
|
||||
qDebug("Refreshing old feed: %s...", (const char*)url.toLocal8Bit());
|
||||
stream->setLoading(true);
|
||||
downloader->downloadUrl(url);
|
||||
if(!stream->hasCustomIcon()){
|
||||
@ -801,7 +801,7 @@ class RssManager : public QObject{
|
||||
foreach(stream, streams){
|
||||
QString url = stream->getUrl();
|
||||
if(stream->isLoading()) return;
|
||||
qDebug("Refreshing feed: %s...", (const char*)url.toUtf8());
|
||||
qDebug("Refreshing feed: %s...", (const char*)url.toLocal8Bit());
|
||||
stream->setLoading(true);
|
||||
downloader->downloadUrl(url);
|
||||
if(!stream->hasCustomIcon()){
|
||||
|
@ -276,7 +276,7 @@
|
||||
if(item->text(1) == url)
|
||||
return item;
|
||||
}
|
||||
qDebug("Cannot find url %s in feeds list", (const char*)url.toUtf8());
|
||||
qDebug("Cannot find url %s in feeds list", (const char*)url.toLocal8Bit());
|
||||
Q_ASSERT(false); // Should never go through here
|
||||
return (QTreeWidgetItem*)0;
|
||||
}
|
||||
|
@ -421,12 +421,12 @@ void SearchEngine::updateNova() {
|
||||
// Copy python classes
|
||||
if(file.endsWith(".py")) {
|
||||
if(misc::getPluginVersion(shipped_file) > misc::getPluginVersion(destDir+file) ) {
|
||||
qDebug("shippped %s is more recent then local plugin, updating", file.toUtf8().data());
|
||||
qDebug("shippped %s is more recent then local plugin, updating", file.toLocal8Bit().data());
|
||||
if(QFile::exists(destDir+file)) {
|
||||
qDebug("Removing old %s", (destDir+file).toUtf8().data());
|
||||
qDebug("Removing old %s", (destDir+file).toLocal8Bit().data());
|
||||
QFile::remove(destDir+file);
|
||||
}
|
||||
qDebug("%s copied to %s", shipped_file.toUtf8().data(), (destDir+file).toUtf8().data());
|
||||
qDebug("%s copied to %s", shipped_file.toLocal8Bit().data(), (destDir+file).toLocal8Bit().data());
|
||||
QFile::copy(shipped_file, destDir+file);
|
||||
}
|
||||
} else {
|
||||
|
@ -117,7 +117,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||
// Getting torrent file informations
|
||||
boost::intrusive_ptr<torrent_info> t;
|
||||
try {
|
||||
t = new torrent_info(filePath.toUtf8().data());
|
||||
t = new torrent_info(filePath.toLocal8Bit().data());
|
||||
} catch(std::exception&) {
|
||||
qDebug("Caught error loading torrent");
|
||||
if(!from_url.isNull()){
|
||||
@ -405,7 +405,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{
|
||||
// Save savepath
|
||||
QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath"));
|
||||
savepath_file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
savepath_file.write(savePath.path().toUtf8());
|
||||
savepath_file.write(savePath.path().toLocal8Bit());
|
||||
savepath_file.close();
|
||||
// Save last dir to remember it
|
||||
QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent"));
|
||||
|
Loading…
Reference in New Issue
Block a user